SIP: using %InstanceCode for pure virtual class

James Jurack James.Jurack at ametek.com
Fri Aug 6 21:12:50 BST 2021


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?

Thanks very much for any help!


--

James Jurack

Systems Engineer

[cid:fb44a353-f222-4d6f-916f-b787ae52e8fa]                                                                                                 [cid:66a639b5-c3f2-4379-bf03-21abfc8848ff]

5425 Warner Rd. | Suite 13 | Valley View, OH 44125 | http://www.vtiinstruments.com<http://www.vtiinstruments.com/>

P. +1.216.447.8950 x2013 | F: +1.216.447.8951 | james.jurack at ametek.com<mailto:email at vtiinstruments.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210806/3f3fb594/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-3s2hj143.jpg
Type: image/jpeg
Size: 1664 bytes
Desc: Outlook-3s2hj143.jpg
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210806/3f3fb594/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-0w0iz24j.jpg
Type: image/jpeg
Size: 1151 bytes
Desc: Outlook-0w0iz24j.jpg
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210806/3f3fb594/attachment-0003.jpg>


More information about the PyQt mailing list