Re: 回复:ConvertToSubClassCode for IDispatch

Weitian Leung just_fancy at live.com
Mon May 1 02:16:55 BST 2023


Thanks, now it work with a simple `typedef struct _Foo Foo;` in sip file.

________________________________
From: Phil Thompson <phil at riverbankcomputing.com>
Sent: Monday, May 1, 2023 12:51 AM
To: ‪‪‪‪just_fancy at live.com‬‬‬‬ <just_fancy at live.com>
Cc: pyqt at riverbankcomputing.com <pyqt at riverbankcomputing.com>
Subject: Re: 回复:ConvertToSubClassCode for IDispatch

On 30/04/2023 16:53, ‪‪‪‪just_fancy at live.com‬‬‬‬ wrote:
> Yes it means compiles and runs fine.
> What did you mean `wrapped _Foo`?
> The _Foo just write as normal class, no special code in sip file.

'wrapped _Foo' means created a .sip file for it.

If I've understood correctly then you could just refer to _Foo rather
than Foo in your .sip files.

Alternatively you could add the missing...

typedef struct _Foo Foo;

...to the .sip file for _Foo.

Either way, don't define Foo as a class in a .sip file.

Phil

> -------- 原始邮件 --------
> 发件人: Phil Thompson <phil at riverbankcomputing.com>
> 日期: 2023年4月30日周日 23:42
> 收件人: "‪‪‪‪just_fancy at live.com‬‬‬‬"
> <just_fancy at live.com>
> 抄送: pyqt at riverbankcomputing.com
> 主 题: Re: 回复:ConvertToSubClassCode for IDispatch
> On 30/04/2023 16:10, ‪‪‪‪just_fancy at live.com‬‬‬‬
> wrote:
>> No, it's `typedef interface Foo Foo` and without further definition.
>> It works for `open` I mean the returned foo, it could use as _Foo
>> normally (_Foo contains methods).
>> But I can't pass the foo returns from `open` to `dosomething` . It's
>> actully a _Foo because I use ConvertToSubClassCode for `Foo`
>
> "It works" means it compiles or it runs correctly?
>
> Have you wrapped _Foo?
>
> Phil
>
>> -------- 原始邮件 --------
>> 发件人: Phil Thompson <phil at riverbankcomputing.com>
>> 日期: 2023年4月30日周日 22:27
>> 收件人: Weitian Leung <Just_Fancy at live.com>
>> 抄送: pyqt at riverbankcomputing.com
>> 主 题: Re: ConvertToSubClassCode for IDispatch
>>
>>> On 30/04/2023 14:39, Weitian Leung wrote:
>>>> Hello,
>>>> I have a IDispatch related sdk header, say it contains two
>>>> IDispatch interfaces:
>>>> ```
>>>> interface _Foo : public IDispatch {…};
>>>> typedef interface Foo Foo; // No definition at all
>>>> ```
>>>
>>> Do you mean...
>>>
>>> typedef interface _Foo Foo;
>>>
>>>> `Foo` can be QueryInterface from `_Foo` in C++ (or just do a
>>> cast),
>>>> and for this case I asume they are just the same class.
>>>>
>>>> As the sdk internal only uses the Foo interface, such as:
>>>> ```
>>>> interface Bar : public IDispatch
>>>> {
>>>> bool open(…, Foo** out);
>>>> void dosomething(Foo* f);
>>>> };
>>>> ```
>>>>
>>>> So I use ConvertToSubClassCode to resolve the buggy sdk:
>>>> ```
>>>> class Foo /Abstract,NoDefaultCtors/
>>>> {
>>>> %ConvertToSubClassCode
>>>> sipType = sipType__Foo;
>>>> %End
>>>> };
>>>> ```
>>>
>>> As Foo above doesn't have a super-class, and nothing sub-classes
> it,
>>> the
>>> %ConvertToSubClassCode isn't having any effect.
>>>
>>>> It works for `open`, but not for `dosomething` due to
>>>> ConvertToSubClassCode make `open` returns a `_Foo`, they have no
>>>> inherits from python’s view.
>>>
>>> Sorry, I don't understand what you mean. What do you mean by "it
>>> works"?
>>>
>>>> I can’t change the C++ sdk as it out of my control.
>>>> So is there any chance to make SIP works for such case?
>>>
>>> Your example is too incomplete to say.
>>>
>>> Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230501/3791a2c6/attachment-0001.htm>


More information about the PyQt mailing list