[PyQt] [SIP] bug - wrap argument incorrect if argument's default
value is static class member
Nian Wu
Nian.Wu at autodesk.com
Thu Aug 20 10:00:32 BST 2009
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
More information about the PyQt
mailing list