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

List:       pykde
Subject:    Re: [PyQt] Arrays in SIP
From:       Shaheed Haque <srhaque () theiet ! org>
Date:       2017-09-05 16:44:33
Message-ID: CAHAc2jf6iwTw1AoZoFpm+RMMVqqFGF=H-gcH-+Msqzd=aYcejA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On 5 Sep 2017 17:42, "Phil Thompson" <phil@riverbankcomputing.com> wrote:

On 5 Sep 2017, at 5:39 pm, Shaheed Haque <srhaque@theiet.org> wrote:
>
>
>
> On 5 Sep 2017 17:00, "Phil Thompson" <phil@riverbankcomputing.com> wrote:
> On 2 Sep 2017, at 3:29 am, Shaheed Haque <srhaque@theiet.org> wrote:
> >
> > Hi,
> >
> > Can I just check my understanding of simple arrays in SIP? Given the
> > following C++
> >
> > ===========
> > enum E
> > {
> >    A,
> >    B
> > };
> >
> > static const E e[] = { A, A, B, B };
> > ===========
> >
> > I think that the best SIP I can come up with is:
> >
> > ===========
> > %Module(name=foo)
> >
> > enum E
> > {
> >    A,
> >    B
> > };
> >
> > const E *e /NoSetter/;
> > ===========
> >
> > (I also tried SIP_PYBUFFER etc.) But of course, that needs %GetCode,
> > and %GetCode is not allowed outside class scope. Are *any* arrays
> > possible outside class scope?
>
> Arrays aren't really supported by SIP at all.
>
> I get that...
>
> You'd have to provide hand-written code that implements the sequence
protocol and proxies for the underlying array.
>
> ...and for N-dimensional array variable members of classes, I already
generate the needed %GetCode etc. Can you clarify what directives I could
use to "host" the generated code in this case, where the variable is not in
a class?
>
> (Although as this case is const you could get away with creating a tuple
with the same elements.)
>
> Acknowledged. But even for SIP_PYTUPLE, I'd need the same directives
wouldn't I?

You have to write pure C code - no help from SIP.


As I feared. Thanks for confirming.

Shaheed


Phil

[Attachment #5 (text/html)]

<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On 5 \
Sep 2017 17:42, &quot;Phil Thompson&quot; &lt;<a \
href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>&gt; \
wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="elided-text">On 5 Sep \
2017, at 5:39 pm, Shaheed Haque &lt;<a \
href="mailto:srhaque@theiet.org">srhaque@theiet.org</a>&gt; wrote:<br> &gt;<br>
&gt;<br>
&gt;<br>
&gt; On 5 Sep 2017 17:00, &quot;Phil Thompson&quot; &lt;<a \
href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>&gt; \
wrote:<br> &gt; On 2 Sep 2017, at 3:29 am, Shaheed Haque &lt;<a \
href="mailto:srhaque@theiet.org">srhaque@theiet.org</a>&gt; wrote:<br> &gt; &gt;<br>
&gt; &gt; Hi,<br>
&gt; &gt;<br>
&gt; &gt; Can I just check my understanding of simple arrays in SIP? Given the<br>
&gt; &gt; following C++<br>
&gt; &gt;<br>
&gt; &gt; ===========<br>
&gt; &gt; enum E<br>
&gt; &gt; {<br>
&gt; &gt;      A,<br>
&gt; &gt;      B<br>
&gt; &gt; };<br>
&gt; &gt;<br>
&gt; &gt; static const E e[] = { A, A, B, B };<br>
&gt; &gt; ===========<br>
&gt; &gt;<br>
&gt; &gt; I think that the best SIP I can come up with is:<br>
&gt; &gt;<br>
&gt; &gt; ===========<br>
&gt; &gt; %Module(name=foo)<br>
&gt; &gt;<br>
&gt; &gt; enum E<br>
&gt; &gt; {<br>
&gt; &gt;      A,<br>
&gt; &gt;      B<br>
&gt; &gt; };<br>
&gt; &gt;<br>
&gt; &gt; const E *e /NoSetter/;<br>
&gt; &gt; ===========<br>
&gt; &gt;<br>
&gt; &gt; (I also tried SIP_PYBUFFER etc.) But of course, that needs %GetCode,<br>
&gt; &gt; and %GetCode is not allowed outside class scope. Are *any* arrays<br>
&gt; &gt; possible outside class scope?<br>
&gt;<br>
&gt; Arrays aren&#39;t really supported by SIP at all.<br>
&gt;<br>
&gt; I get that...<br>
&gt;<br>
&gt; You&#39;d have to provide hand-written code that implements the sequence \
protocol and proxies for the underlying array.<br> &gt;<br>
&gt; ...and for N-dimensional array variable members of classes, I already generate \
the needed %GetCode etc. Can you clarify what directives I could use to \
&quot;host&quot; the generated code in this case, where the variable is not in a \
class?<br> &gt;<br>
&gt; (Although as this case is const you could get away with creating a tuple with \
the same elements.)<br> &gt;<br>
&gt; Acknowledged. But even for SIP_PYTUPLE, I&#39;d need the same directives \
wouldn&#39;t I?<br> <br>
</div>You have to write pure C code - no help from \
SIP.<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">As I \
feared. Thanks for confirming.</div><div dir="auto"><br></div><div \
dir="auto">Shaheed</div><div dir="auto"><br></div><div dir="auto"><div \
class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <font \
color="#888888"><br> Phil</font></blockquote></div><br></div></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

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

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