[PyQt] Arrays in SIP

Shaheed Haque srhaque at theiet.org
Tue Sep 5 17:39:48 BST 2017


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

On 2 Sep 2017, at 3:29 am, Shaheed Haque <srhaque at 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?

Thanks, Shaheed


Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170905/c5280e62/attachment.html>


More information about the PyQt mailing list