SIP: using %InstanceCode for pure virtual class
James Jurack
James.Jurack at ametek.com
Mon Aug 9 16:26:01 BST 2021
Thank you for that! I had somehow missed the annotations documentation entirely. I think perhaps /Abstract/ is the one I need in this case, but I seem to be on the right track now. Thanks again!
--
James Jurack
Systems Engineer
[cid:6ba39e1a-7562-4c91-9062-8acc474a02a4] [cid:fc8c1e49-c487-4366-99a3-ef3c4077bc1b]
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>
________________________________
From: Phil Thompson <phil at riverbankcomputing.com>
Sent: Saturday, August 7, 2021 5:01 AM
To: James Jurack <James.Jurack at ametek.com>
Cc: pyqt at riverbankcomputing.com <pyqt at riverbankcomputing.com>
Subject: Re: SIP: using %InstanceCode for pure virtual class
***NOTICE*** This came from an external source. Use caution when replying, clicking links, or opening attachments.
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://urldefense.com/v3/__https://www.riverbankcomputing.com/static/Docs/sip/annotations.html*class-annotation-NoDefaultCtors__;Iw!!HKOSU0g!S_W52V65neQiX3WDsLXU8dQBvA-Cc2dMuk6Q22pZQx7TPxi1LAuV9jcjr8xYYQEPGWk$
Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210809/62e4bc04/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-vdh5tn3i.jpg
Type: image/jpeg
Size: 1664 bytes
Desc: Outlook-vdh5tn3i.jpg
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210809/62e4bc04/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-jbgh1mit.jpg
Type: image/jpeg
Size: 1151 bytes
Desc: Outlook-jbgh1mit.jpg
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210809/62e4bc04/attachment-0001.jpg>
More information about the PyQt
mailing list