[PyQt] Regression in SIP sip-4.8-snapshot-20090409 wrt MappedTypes

Phil Thompson phil at riverbankcomputing.com
Sun Apr 19 13:00:20 BST 2009


On Sun, 19 Apr 2009 10:25:11 +0200, Simon Edwards <simon at simonzone.com>
wrote:
> Hello Phil,
> 
> I'm working on getting PyKDE4 trunk working on SIP 4.8 and PyQt 4.5 and 
> hit what looks like a fairly straight forward regression bug.
> 
> The compile error is:
> 
>
/home/sbe/devel/svn/kde/trunk/KDE/kdebindings/python/pykde4/sip/kdecore/typedefs.sip:
> 
> In function ‘int
convertTo_KSharedPtr_0200DNSSD_RemoteService(PyObject*, 
> void**, int*, PyObject*)’:
>
/home/sbe/devel/svn/kde/trunk/KDE/kdebindings/python/pykde4/sip/kdecore/typedefs.sip:247:
> 
> error: ‘sipForceConvertTo_DNSSD’ was not declared in this scope 
> 
>
/home/sbe/devel/svn/kde/trunk/KDE/kdebindings/python/pykde4/sip/kdecore/typedefs.sip:247:
> 
> error: expected ‘,’ or ‘;’ before ‘::’ token 
> 
> 
> The offending C++ code is:
> 
>      DNSSD::RemoteService *cpp = (DNSSD::RemoteService 
> *)sipForceConvertTo_DNSSD::RemoteService (sipPy, &iserr);
> 
> which was expanded from the mapped type:
> 
> -----------------------------------------------
> template <TYPE>
> %MappedType KSharedPtr<TYPE>
> {
> // ... etc etc ...
> 
> %ConvertToTypeCode
>      // Convert a Python instance to a Ptr on the heap.
> 
>      if (sipIsErr == NULL)
>          return PyInstance_Check(sipPy);
> 
>      int iserr = 0;
>      TYPE *cpp = (TYPE *)sipForceConvertTo_TYPE (sipPy, &iserr);
> // ... etc etc ...
> -----------------------------------------------
> 
> elsewhere in the sip files I've got this which sets it all in motion:
> 
>      typedef KSharedPtr<DNSSD::RemoteService> Ptr;

sipForceConvertTo_*() (and related functions) are internal and should not
be used by handwritten code. If it isn't documented then you can't use it.

For SIP prior to v4.8 you should use sipForceConvertToInstance(). For v4.8
then sipForceConvertToType() is preferred (though the former will be
supported for all SIP v4.x versions). The advantage of the latter is that
it will automatically handle (for example) QString when it is implemented
as a wrapped class or a mapped type.

Phil


More information about the PyQt mailing list