[PyQt] Type map for python to Qt?

Shaheed Haque srhaque at theiet.org
Sun Feb 5 12:18:49 GMT 2017

The use of unions is really limited: across the whole of my
/usr/include/KF5, I see 5 in one component called kjs (some Javascript
interpreter thing by the looks of it). From a superficial look, it really
does look like the polymorphic case but there is no obvious/explicit
"what_type" in any of those case.

That said, my basic thinking is to assume that the reader/writer knows what
they are doing AND that from a SIP perspective, all I need is to provide
Python access to the storage. So, for access to the individual members of
the union, all I need do is take care of the change in representation
between a C++ int/float/whatever and the corresponding Python object. That
then leaves the union itself: there it seems to me that just doing a C++
memcpy in one direction or the other is all that is required. I *think*
that pretty much covers the bases...

On 5 February 2017 at 11:15, Barry Scott <barry at barrys-emacs.org> wrote:

> > On 4 Feb 2017, at 23:53, Shaheed Haque <srhaque at theiet.org> wrote:
> >
> > Acknowledged. Any thoughts on the union idea?
> >
> I don’t know SIP but thinking about what it should look like from Python.
> Some unions are for interpreting the bit pattern in memory different ways.
> Hopefully you have none of them.
> Other unions are really polymorphism. Can you return each of the types
> that the union represents on output and accept any of the types on input?
> Struct OddUNionTHing {
> Enum what_type;
> Union {
>         Struct1 type1;
>         Struct2 type2;
> } union1;
> }
> If what_type says we have type1 return conversion of type1, etc.
> Does the KDE code really use unions? I’m surprised in OO code.
> Barry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170205/5e9b966d/attachment.html>

More information about the PyQt mailing list