<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Thanks, now it work with a simple `<font size="2"><span style="font-size:11pt" class="ContentPasted0">typedef struct _Foo Foo;</span></font>` in sip file.<br>
</div>
<div id="appendonsend"></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size: 11pt; color: rgb(0, 0, 0);" face="Calibri, sans-serif"><b>From:</b> Phil Thompson <phil@riverbankcomputing.com><br>
<b>Sent:</b> Monday, May 1, 2023 12:51 AM<br>
<b>To:</b> ‪‪‪‪just_fancy@live.com‬‬‬‬ <just_fancy@live.com><br>
<b>Cc:</b> pyqt@riverbankcomputing.com <pyqt@riverbankcomputing.com><br>
<b>Subject:</b> Re: 回复:ConvertToSubClassCode for IDispatch</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText elementToProof">On 30/04/2023 16:53, ‪‪‪‪just_fancy@live.com‬‬‬‬ wrote:<br>
> Yes it means compiles and runs fine.<br>
> What did you mean `wrapped _Foo`?<br>
> The _Foo just write as normal class, no special code in sip file.<br>
<br>
'wrapped _Foo' means created a .sip file for it.<br>
<br>
If I've understood correctly then you could just refer to _Foo rather <br>
than Foo in your .sip files.<br>
<br>
Alternatively you could add the missing...<br>
<br>
typedef struct _Foo Foo;<br>
<br>
...to the .sip file for _Foo.<br>
<br>
Either way, don't define Foo as a class in a .sip file.<br>
<br>
Phil<br>
<br>
> -------- 原始邮件 --------<br>
> 发件人: Phil Thompson <phil@riverbankcomputing.com><br>
> 日期: 2023年4月30日周日 23:42<br>
> 收件人: "‪‪‪‪just_fancy@live.com‬‬‬‬"<br>
> <just_fancy@live.com><br>
> 抄送: pyqt@riverbankcomputing.com<br>
> 主 题: Re: 回复:ConvertToSubClassCode for IDispatch<br>
> On 30/04/2023 16:10, ‪‪‪‪just_fancy@live.com‬‬‬‬<br>
> wrote:<br>
>> No, it's `typedef interface Foo Foo` and without further definition.<br>
>> It works for `open` I mean the returned foo, it could use as _Foo<br>
>> normally (_Foo contains methods).<br>
>> But I can't pass the foo returns from `open` to `dosomething` . It's<br>
>> actully a _Foo because I use ConvertToSubClassCode for `Foo`<br>
> <br>
> "It works" means it compiles or it runs correctly?<br>
> <br>
> Have you wrapped _Foo?<br>
> <br>
> Phil<br>
> <br>
>> -------- 原始邮件 --------<br>
>> 发件人: Phil Thompson <phil@riverbankcomputing.com><br>
>> 日期: 2023年4月30日周日 22:27<br>
>> 收件人: Weitian Leung <Just_Fancy@live.com><br>
>> 抄送: pyqt@riverbankcomputing.com<br>
>> 主 题: Re: ConvertToSubClassCode for IDispatch<br>
>> <br>
>>> On 30/04/2023 14:39, Weitian Leung wrote:<br>
>>>> Hello,<br>
>>>> I have a IDispatch related sdk header, say it contains two<br>
>>>> IDispatch interfaces:<br>
>>>> ```<br>
>>>> interface _Foo : public IDispatch {…};<br>
>>>> typedef interface Foo Foo; // No definition at all<br>
>>>> ```<br>
>>> <br>
>>> Do you mean...<br>
>>> <br>
>>> typedef interface _Foo Foo;<br>
>>> <br>
>>>> `Foo` can be QueryInterface from `_Foo` in C++ (or just do a<br>
>>> cast),<br>
>>>> and for this case I asume they are just the same class.<br>
>>>> <br>
>>>> As the sdk internal only uses the Foo interface, such as:<br>
>>>> ```<br>
>>>> interface Bar : public IDispatch<br>
>>>> {<br>
>>>> bool open(…, Foo** out);<br>
>>>> void dosomething(Foo* f);<br>
>>>> };<br>
>>>> ```<br>
>>>> <br>
>>>> So I use ConvertToSubClassCode to resolve the buggy sdk:<br>
>>>> ```<br>
>>>> class Foo /Abstract,NoDefaultCtors/<br>
>>>> {<br>
>>>> %ConvertToSubClassCode<br>
>>>> sipType = sipType__Foo;<br>
>>>> %End<br>
>>>> };<br>
>>>> ```<br>
>>> <br>
>>> As Foo above doesn't have a super-class, and nothing sub-classes<br>
> it,<br>
>>> the<br>
>>> %ConvertToSubClassCode isn't having any effect.<br>
>>> <br>
>>>> It works for `open`, but not for `dosomething` due to<br>
>>>> ConvertToSubClassCode make `open` returns a `_Foo`, they have no<br>
>>>> inherits from python’s view.<br>
>>> <br>
>>> Sorry, I don't understand what you mean. What do you mean by "it<br>
>>> works"?<br>
>>> <br>
>>>> I can’t change the C++ sdk as it out of my control.<br>
>>>> So is there any chance to make SIP works for such case?<br>
>>> <br>
>>> Your example is too incomplete to say.<br>
>>> <br>
>>> Phil<br>
</div>
</span></font></div>
</body>
</html>