SIP: using %InstanceCode for pure virtual class
Phil Thompson
phil at riverbankcomputing.com
Sat Aug 7 10:01:03 BST 2021
On 06/08/2021 21:12, James Jurack wrote:
> Hello,
>
> I am trying to use SIP to wrap a pure virtual class. Since it does not
> have a callable constructor, it instead has a static factory function
> that returns an instance of a hidden subclass.
>
> From the docs, I've gathered that SIP provides %InstanceCode to cover
> this use case, but it appears it's not doing anything. My class is
> defined in my .sip file like so:
>
> class MyLib
> {
> %TypeHeaderCode
> #include <MyLib.h>
> %End
> %InstanceCode
> sipCpp = ::MyLib::Create();
> %End
> };
>
> But there is no change in the CPP code that SIP generates, whether I
> include the %InstanceCode or not; it's still trying to call my class's
> constructor directly, and I can't find my call to Create() anywhere in
> the generated code.
>
> Am I misunderstanding how %InstanceCode is supposed to work?
You haven't told SIP that there are no default ctors. See...
https://www.riverbankcomputing.com/static/Docs/sip/annotations.html#class-annotation-NoDefaultCtors
Phil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-3s2hj143.jpg
Type: image/jpeg
Size: 1664 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210807/1f59185d/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-0w0iz24j.jpg
Type: image/jpeg
Size: 1151 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210807/1f59185d/attachment-0001.jpg>
More information about the PyQt
mailing list