[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: Question about extending QtAndroidExtras
From:       Kálmán Viktor <viktorvector () gmail ! com>
Date:       2020-05-14 6:50:09
Message-ID: CA+sJfQyEQZWCcvz8hd2Su-+5pbGrdq5zxQkOM5Ntq3JKhpMW-g () mail ! gmail ! com
[Download RAW message or body]

Yes I agree, that would be more user friendly.

Only downside I see with that is that I'm not sure how an error would
propagate "out of JNI" call, but py->java way it would be hard to mess up
considering we could just pass in dicts, java->py way would be probably
okay too with json builder.

Phil Thompson <phil@riverbankcomputing.com> ezt írta (időpont: 2020. máj.
12., K, 10:19):

> On 11/05/2020 22:38, Kálmán Viktor wrote:
> > My idea was that with a single string argument and string return value
> > users can simply pass in/return JSON and that would cover multiple
> > arguments and string/int/bool/float/list/dict types.
> >
> > It's a little hacky but probably still nicer than hacking Qt and
> > pyjnius
> > together.
>
> In that case I'd be more receptive to a method that took a QJsonObject
> argument and returned a QJsonObject value that under the covers
> converted to and from string data.
>
> That way it would be more obviously a PyQt extension and less likely to
> compromise a possible (future) wrapping of the actual API.
>
> Phil
> > Phil Thompson <phil@riverbankcomputing.com> ezt írta (időpont: 2020.
> > máj.
> > 11., H, 22:39):
> >
> >> On 11/05/2020 18:38, Kálmán Viktor wrote:
> >> > Hello!
> >> >
> >> > I'm wondering if it would be possible to
> >> > extend QAndroidJniObject's callStaticMethod to a version that supports
> >> > passing in a single string argument and the return value is also a
> >> > string.
> >> >
> >> > I tried something like this locally, but both gave me JNI error when
> >> > trying
> >> > to use them (the parameterless int return valued callStaticMethod
> works
> >> > fine but would it be good to pass in string,  same for return value),
> >> > but
> >> > I'm not really familiar with SIP so it was just guess work (also tried
> >> > changing int to QString but that also gave me an error)
> >> >
> >> >     static int callStaticMethod(const char *className, const char
> >> > *methodName, const char *signature, const char *parameter);
> >> > %MethodCode
> >> >         sipRes = QAndroidJniObject::callStaticMethod<int>(a0, a1, a2,
> >> > a3);
> >> > %End
> >> >
> >> >     static int callStaticMethod(const char *className, const char
> >> > *methodName, const char *parameter);
> >> > %MethodCode
> >> >         sipRes = QAndroidJniObject::callStaticMethod<int>(a0, a1,
> >> > "(Ljava/lang/String;)I", a2);
> >> > %End
> >>
> >> And what about other combinations of arguments? Each combination would
> >> have to be implemented on a case by case basis and I don't want to
> >> start
> >> taking random requests.
> >>
> >> Phil
> >>
>
>

[Attachment #3 (text/html)]

<div dir="ltr"><div>Yes I agree, that would be more user \
friendly.</div><div><br></div>Only downside I see with that is that I&#39;m not sure \
how an error would propagate  &quot;out of JNI&quot; call, but py-&gt;java way it \
would be hard to mess up considering we could just pass in dicts, java-&gt;py way \
would be probably okay too with json builder.</div><br><div class="gmail_quote"><div \
dir="ltr" class="gmail_attr">Phil Thompson &lt;<a \
href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>&gt; ezt \
írta (időpont: 2020. máj. 12., K, 10:19):<br></div><blockquote class="gmail_quote" \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">On 11/05/2020 22:38, Kálmán Viktor wrote:<br> \
&gt; My idea was that with a single string argument and string return value<br> &gt; \
users can simply pass in/return JSON and that would cover multiple<br> &gt; arguments \
and string/int/bool/float/list/dict types.<br> &gt; <br>
&gt; It&#39;s a little hacky but probably still nicer than hacking Qt and <br>
&gt; pyjnius<br>
&gt; together.<br>
<br>
In that case I&#39;d be more receptive to a method that took a QJsonObject <br>
argument and returned a QJsonObject value that under the covers <br>
converted to and from string data.<br>
<br>
That way it would be more obviously a PyQt extension and less likely to <br>
compromise a possible (future) wrapping of the actual API.<br>
<br>
Phil<br>
&gt; Phil Thompson &lt;<a href="mailto:phil@riverbankcomputing.com" \
target="_blank">phil@riverbankcomputing.com</a>&gt; ezt írta (időpont: 2020. <br> \
&gt; máj.<br> &gt; 11., H, 22:39):<br>
&gt; <br>
&gt;&gt; On 11/05/2020 18:38, Kálmán Viktor wrote:<br>
&gt;&gt; &gt; Hello!<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I&#39;m wondering if it would be possible to<br>
&gt;&gt; &gt; extend QAndroidJniObject&#39;s callStaticMethod to a version that \
supports<br> &gt;&gt; &gt; passing in a single string argument and the return value \
is also a<br> &gt;&gt; &gt; string.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I tried something like this locally, but both gave me JNI error \
when<br> &gt;&gt; &gt; trying<br>
&gt;&gt; &gt; to use them (the parameterless int return valued callStaticMethod \
works<br> &gt;&gt; &gt; fine but would it be good to pass in string,   same for \
return value),<br> &gt;&gt; &gt; but<br>
&gt;&gt; &gt; I&#39;m not really familiar with SIP so it was just guess work (also \
tried<br> &gt;&gt; &gt; changing int to QString but that also gave me an error)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;        static int callStaticMethod(const char *className, const \
char<br> &gt;&gt; &gt; *methodName, const char *signature, const char \
*parameter);<br> &gt;&gt; &gt; %MethodCode<br>
&gt;&gt; &gt;              sipRes = \
QAndroidJniObject::callStaticMethod&lt;int&gt;(a0, a1, a2,<br> &gt;&gt; &gt; a3);<br>
&gt;&gt; &gt; %End<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;        static int callStaticMethod(const char *className, const \
char<br> &gt;&gt; &gt; *methodName, const char *parameter);<br>
&gt;&gt; &gt; %MethodCode<br>
&gt;&gt; &gt;              sipRes = \
QAndroidJniObject::callStaticMethod&lt;int&gt;(a0, a1,<br> &gt;&gt; &gt; \
&quot;(Ljava/lang/String;)I&quot;, a2);<br> &gt;&gt; &gt; %End<br>
&gt;&gt; <br>
&gt;&gt; And what about other combinations of arguments? Each combination would<br>
&gt;&gt; have to be implemented on a case by case basis and I don&#39;t want to <br>
&gt;&gt; start<br>
&gt;&gt; taking random requests.<br>
&gt;&gt; <br>
&gt;&gt; Phil<br>
&gt;&gt; <br>
<br>
</blockquote></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic