[PyQt] SIP template

Shaheed Haque srhaque at theiet.org
Mon Aug 14 11:13:29 BST 2017


On 8 August 2017 at 22:12, Shaheed Haque <srhaque at theiet.org> wrote:

> On 8 August 2017 at 17:23, Phil Thompson <phil at riverbankcomputing.com>
> wrote:
> > On 2 Aug 2017, at 9:21 am, Shaheed Haque <srhaque at theiet.org> wrote:
> >>
> >> Hi,
> >>
> >> On 18 May 2017 at 13:14, Denis Rouzaud <denis.rouzaud at gmail.com> wrote:
> >>>
> >>> Sorry, for the noise.
> >>>
> >>> I missed the second typedef in the ModuleHeaderCode, it works!
> >>> Thanks to David, Phil and Shaheed for the hints!
> >>
> >> Is there a variation on this technique that works for nested classes?
> >> It turns out that in all 17 places this affects PyKF5 involve nested
> >> classes, and attempting to modify this SIP:
> >>
> >> =============
> >> namespace KContacts
> >> {
> >>    class AddresseeList: QVector<KContacts::Addressee>
> >>    {
> >> =============
> >>
> >> into this SIP:
> >>
> >> =============
> >> namespace KContacts
> >> {
> >> %TypeHeaderCode
> >> typedef QVector<KContacts::Addressee> foo_t;
> >> %End
> >> typedef QVector<KContacts::Addressee> foo_t;
> >>    class AddresseeList: KContacts::foo_t
> >>    {
> >> =============
> >>
> >> only results in:
> >>
> >> sip: tmp/KContacts/KContacts/AddresseeList.sip:121: Super-class list
> >> contains an invalid type
> >>
> >> I stared a the code that emits the message in parser.y (and also tried
> >> moving foo_t to global scope), without the solution becoming obvious.
> >> So, any clues or ideas welcomed!
> >
> > PyQt has the same problem with QPolygon. The workaround is to say that
> AddresseeList does not have a super-class and to add any QVector methods
> you want to AddresseeList. See qpolygon.sip in PyQt.
>
> Thanks Phil...
>

I'm still working on variations of this topic. The problem I am having at
the moment is that a sequence like this, where Bar has a base which is a
%MappedType:

=======
%Module(name=xxx)

%MappedType FooBad
{
%ConvertFromTypeCode
// blah.
%End
%ConvertToTypeCode
// blah.
%End
};

class FooOK
{
public:
    FooOK();
};

class Bar: FooBad
{  <<<<<<<<<<<<<<<< This is line 20
public:
    Bar();
};
=======

gives the error "sip: tmp.sip:20: A class, exception, namespace or mapped
type has already been defined with the same name" but if I change the base
class from FooBad to the non-%MappedType normal class FooOK, it compiles
just fine. I'm on 4.19.4.dev1708081632...have I gone mad?

Thanks, Shaheed


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


More information about the PyQt mailing list