[PyQt] Arrays in SIP

Phil Thompson phil at riverbankcomputing.com
Tue Sep 5 16:59:53 BST 2017


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.

You'd have to provide hand-written code that implements the sequence protocol and proxies for the underlying array. (Although as this case is const you could get away with creating a tuple with the same elements.)

Phil


More information about the PyQt mailing list