[PyQt] SIP sytax error

Phil Thompson phil at riverbankcomputing.com
Fri Jul 22 10:39:52 BST 2011


On Tue, 19 Jul 2011 00:05:44 -0700, "Vivek Narvekar"
<Vivek.Narvekar at mscsoftware.com> wrote:
> Hello,
> 
>  
> 
> I am badly stuck up with some SIP syntax. Please help.
> 
> I am trying to upgrade SIP files, which were originally written for SIP
> version 3.3, to a newer version SIP 4.7.9
> 
>  
> 
> 1)       I have a class member function, written in one of the SIP file,
> which looks as below.
> 
> double* GetIcValues(); 
> 
> %MemberCode
> 
>            int i;
> 
>          int num;
> 
>            double *XIC=0;
> 
>            PyObject *XList=PyList_New(0);
> 
>            ------
> 
>             //Some code
> 
>            ------
> 
>            
> 
>          return XList;  
> 
> %End
> 
>  
> 
>  
> 
> Here, first thing that I did was, replace %MemberCode With %MethodCode.
> Hope that this is correct.
> 
> Then, it gives me an error for return type as follows.
> 
> unsupported function return type - provide %MethodCode and a C++
> signature.
> 
> It seems like, returning pointer is not allowed in newer version of SIP.

...or in older versions which is why you had the %MemberCode.

> What should be done to get rid of this error ?

Your %MethodCode is returning a Python list not a double *, so it should
be...

SIP_PYLIST GetIcValues();

> 2)  If a function takes a argument as void (eg double* AFunc(void); ) it
> gives following error. 
> 
> unsupported function argument type - provide %Method code and a valid
> C++ signature

Just remove the void.
 
> 3)      Also, constructors are not working properly eg. If I have a
> constructor as follows, then,
> 
>      class AcGSE 
> 
>     {
> 
>       public:
> 
>             AcGSE(const int, const double* );
> 
>        %MethodCode
> 
>          int nRows;
> 
>          PyObject *dList;
> 
>        ----------
> 
>       //some more code
> 
>       ----------
> 
>       %End
> 
>  
> 
>      }
> 
> It gives following error.
> 
> unsupported ctor argument type - provide %MethodCode and a C++ signature

When you specify a signature you are specifying the Python signature, not
the C++ signature. SIP will assume, unless told otherwise, that the C++
signature is the same as the Python signature. Where they are different
(and when it matters to SIP, which is not all the time) then you have to
specify both...

    AcGSE(int, SIP_PYLIST) [(const int const double *)];

Phil


More information about the PyQt mailing list