[PyQt] Re: SIP errors: class inherits from std::list

Ovidiu Ciule ovidiu.ciule at gmail.com
Mon Sep 3 10:30:38 BST 2007


This is a relaunch of the earlier mail. I have found a work around: I
define AccountList as a MappedType, still std::list<Account>, but not
a template. The sip file includes %ConvertToTypeCode and
%ConvertFromTypeCode  This is messy though. So I'm still hoping
someone (Phil?) could clear the template issue. Oh, and the typedef

For reference, here's the original text:
I have a class, AccountList, that inherits from std::list. When trying
to generate bindings for it, SIP reports errors. I'm using SIP 4.5 on
Ubuntu. I'm downloading SIP 4.7 now, but I don't think it'll help, as
the change log doesn't mention anything relevant about templates.

Here's the the .sip file:
class AccountList : std::list<Account> {
#include <coipmanager_base/account/AccountList.h>
... various boring methods

The relevant portion of the header file is similar, so I will not post it.
SIP gives the following error:
 sip_files/coipmanager_base/AccountList.sip:1: syntax error

std::list is defined, so it's not that. I use a stdlist.sip inspired
by the stl.sip work of Giovanni Bajo. I read the relevant SIP doc, and
found nothing about template inheritance. Moreso, std::list<Account>
work fine as a return type or as a parameter.

I tried defining std::list<Account> with a typedef:
typedef std::list<Account> AccountList1;
I did in the SIP file, then in the header, then in both. In all cases
I got errors.
In the .sip file, it looks like this:
typedef std::list<Account> AccList;
class AccountList : AccList {

The error I get is:
sip: AccList has not been defined
which in my eyes, makes no sense. But I'm not SIP, so I have no idea
what I'm talking about.

1. Does anybody know how if inheriting from templates works? That is,
if it is usable with SIP. I read and re-read the doc, and found
nothing. If I missed something, sorry.

2. What's up with typedef?
Am I using it wrong? I don't think so. I looked over PyQt's Metasip
generated sip files, and of course they use lots of typedefs.

BTW, Phil, thanks for not releasing metasip. I had lots of fun writing
my own sip file generator. You know, the kind of fun you have when you
reinvent the wheel.

Thanks a lot, and have a nice day.

Ovidiu CIULE
Paris, France

More information about the PyQt mailing list