[PyQt] [SIP] bug - wrap argument incorrect if argument's default value is static class member

Phil Thompson phil at riverbankcomputing.com
Thu Aug 20 10:48:15 BST 2009


On Thu, 20 Aug 2009 11:38:13 +0200, Sébastien Petitdemange
<sebastien.petitdemange at esrf.fr> wrote:
> Hi Nian,
> 
> I have to specify the class :
> instead of
> void ConvertChildren( KFbxNode* pRoot, const KFbxSystemUnit& pSrcUnit,
> const KFbxUnitConversionOptions& pOptions = DefaultConversionOptions )
> const;
> try
> void ConvertChildren( KFbxNode* pRoot, const KFbxSystemUnit& pSrcUnit,
> const KFbxUnitConversionOptions& pOptions =
> KFbxSystemUnit::DefaultConversionOptions ) const;
> 
> Regards,
> 
> SEB

Yes - SIP doesn't contain a full C++ parser. It's usually best to be
explicit about scopes.

Phil

> Nian Wu wrote:
>> Hi,
>> 
>> I am wrapping our C++ library with SIP. I met a compile failure when I
>> wrapped a class, the sip script is like:
>> 
>> class KFbxSystemUnit 
>> {
>> 
>> %TypeHeaderCode
>> #include <fbxsdk.h>
>> %End
>> 
>> public:
>>     struct KFbxUnitConversionOptions
>>     {
>>         bool mConvertLightIntensity;
>>         bool mConvertRrsNodes;  
>>     };
>>     
>>     KFbxSystemUnit(double pScaleFactor, double pMultiplier = 1.0);
>>     ~KFbxSystemUnit();    
>>     static const KFbxUnitConversionOptions DefaultConversionOptions;
>>     void ConvertChildren( KFbxNode* pRoot, const KFbxSystemUnit&
>>     pSrcUnit, const KFbxUnitConversionOptions& pOptions =
>>     DefaultConversionOptions ) const;
>> };
>> 
>> The argument "pOptions" of method "ConvertChildren" has default value
>> which is a static class member.
>> 
>> After run sip, the method "ConvertChildren" is wrapped as following:
>>
====================================================================================
>> 1 extern "C" {static PyObject
>> *meth_KFbxSystemUnit_ConvertChildren(PyObject *, PyObject *);}
>> 2 static PyObject *meth_KFbxSystemUnit_ConvertChildren(PyObject
>> *sipSelf,PyObject *sipArgs)
>>  {
>> 3     int sipArgsParsed = 0;
>> 
>>     {
>> 4        KFbxNode * a0;
>> 5        const KFbxSystemUnit * a1;
>> 6        const KFbxSystemUnit::KFbxUnitConversionOptions& a2def =
>> DefaultConversionOptions;
>> 7        const KFbxSystemUnit::KFbxUnitConversionOptions * a2 = &a2def;
>> 8        KFbxSystemUnit *sipCpp;
>> 
>> 9        if
>>
(sipParseArgs(&sipArgsParsed,sipArgs,"BJ8J9|J9",&sipSelf,sipType_KFbxSystemUnit,&sipCpp,sipType_KFbxNode,&a0,sipType_KFbxSystemUnit,&a1,sipType_KFbxSystemUnit_KFbxUnitConversionOptions,&a2))
>>         {
>> 10            sipCpp->ConvertChildren(a0,*a1,*a2);
>> 
>> 11            Py_INCREF(Py_None);
>> 12           return Py_None;
>>         }
>>     }
>> 
>>     /* Raise an exception if the arguments couldn't be parsed. */
>>    
sipNoMethod(sipArgsParsed,sipName_KFbxSystemUnit,sipName_ConvertChildren);
>> 
>>     return NULL;
>> }
>> =====================================================
>> 
>> Please notice the Line 6, the variable " DefaultConversionOptions" is
>> referred as global variable, so compile failed here.
>> 
>> Thanks,
>> Nian Wu
>> 
>> 
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list