[PyQt] Sip wrapping error

Sébastien Petitdemange sebastien.petitdemange at esrf.fr
Mon Feb 22 09:09:59 GMT 2010


Phil Thompson wrote:
> On Fri, 19 Feb 2010 11:24:40 +0100, Sébastien Petitdemange
> <sebastien.petitdemange at esrf.fr> wrote:
>> Sébastien Petitdemange wrote:
>>> Phil Thompson wrote:
>>>> On Fri, 19 Feb 2010 10:42:51 +0100, Sébastien Petitdemange
>>>> <sebastien.petitdemange at esrf.fr> wrote:
>>>>> Hi Phil,
>>>>>
>>>>> We use the latest sip (4.10) to wrap your C++ library and I think I
>>>>> found a bug in the wrapping code generated by sip.
>>>>>
>>>>> Sip Code:
>>>>>
>>>>> class HwSyncCtrlObj
>>>>> {
>>>>> %TypeHeaderCode
>>>>> #include <HwSyncCtrlObj.h>
>>>>> using namespace lima;
>>>>> %End
>>>>> public:
>>>>> 	struct ValidRangesType
>>>>> 	{
>>>>> 	  double min_exp_time;
>>>>> 	  double max_exp_time;
>>>>> 	  double min_lat_time;
>>>>> 	  double max_lat_time;
>>>>> 	  const char* __repr__();
>>>>> %MethodCode
>>>>> std::ostringstream str;
>>>>> str << *sipCpp;
>>>>> sipRes = str.str().c_str();
>>>>> %End
>>>>> 	};
>>>>>
>>>>> 	virtual void getValidRanges(HwSyncCtrlObj::ValidRangesType& range
>>>>> /Out/) = 0;
>>>>> };
>>>>>
>>>>> C++ Code result:
>>>>>
>>>>> void sipVH_lima_8(sip_gilstate_t sipGILState,PyObject
>>>>> *sipMethod,HwSyncCtrlObj::ValidRangesType& a0)
>>>>> {
>>>>>     PyObject *resObj = sipCallMethod(0,sipMethod,"");
>>>>>
>>>>>     if (!resObj ||
>>>>>
> sipParseResult(0,sipMethod,resObj,"D4",sipType_HwSyncCtrlObj_ValidRangesType,&a0)
>>>>> < 0)
>>>>>         PyErr_Print();
>>>>>
>>>>>     Py_XDECREF(resObj);
>>>>>     Py_DECREF(sipMethod);
>>>>>
>>>>>     SIP_RELEASE_GIL(sipGILState)
>>>>> }
>>>>>
>>>>> We try to get the pointer of a0 instead of the reference!
>>>>>
>>>>> Is it a bug or miss I something?
>>>> If you are referring to the use of &a0 in the call to sipParseResult()
>>>> then
>>>> that is correct.
>>>>
>>>> Phil
>>>>
>>> Hi Phil,
>>>
>>> It's not correct because you want to fill the structure instead of
>>> retrieve the pointer of that structure.
>>>
>>> I made a small patch:
>>>
>>> void sipVH_lima_8(sip_gilstate_t sipGILState,PyObject
>>> *sipMethod,HwSyncCtrlObj::ValidRangesType& a0)
>>> {
>>>     PyObject *resObj = sipCallMethod(0,sipMethod,"");
>>>
>>>     HwSyncCtrlObj::ValidRangesType *tmpValue = NULL
>>>     if (!resObj ||
>>>
> sipParseResult(0,sipMethod,resObj,"D4",sipType_HwSyncCtrlObj_ValidRangesType,tmpValue)
>>> < 0)
>>>         PyErr_Print();
>>>     else
>>>       a0 = *tmpValue;
>>>
>>>     Py_XDECREF(resObj);
>>>     Py_DECREF(sipMethod);
>>>
>>>     SIP_RELEASE_GIL(sipGILState)
>>> }
>>>
>>>
>>> Sorry I wasn't really clear In my first mail...
>>>
>>> Regards,
>>>
>>> SEB
>>>
>>> _______________________________________________
>>> PyQt mailing list    PyQt at riverbankcomputing.com
>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>> Sorry there is a mistake it:
>>
>>
> sipParseResult(0,sipMethod,resObj,"D4",sipType_HwSyncCtrlObj_ValidRangesType,&tmpValue)
>> instead of :
>>
>>
> sipParseResult(0,sipMethod,resObj,"D4",sipType_HwSyncCtrlObj_ValidRangesType,tmpValue)
>> SEB
> 
> Got it now...
> 
> Should be fixed in tonight's SIP snapshot.
> 
> Thanks,
> Phil
> 
Hi Phil,

You fix work fine. Thanks a lot.


SEB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sebastien_petitdemange.vcf
Type: text/x-vcard
Size: 218 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100222/e8f6ce82/attachment-0001.vcf>


More information about the PyQt mailing list