[fpc-pascal] Check In Interface Type Helpers
Sven Barth
pascaldragon at googlemail.com
Wed Aug 23 21:00:54 CEST 2017
On 23.08.2017 20:38, Marcos Douglas B. Santos wrote:
> On Wed, Aug 23, 2017 at 3:25 PM, Sven Barth via fpc-pascal
> <fpc-pascal at lists.freepascal.org> wrote:
>> On 23.08.2017 19:57, Marcos Douglas B. Santos wrote:
>>> Would we have any problem of memory leaks using Interface helper with
>>> COM interfaces (refcount)?
>>> I mean, the "type helper" has constructor/destructor to create/release
>>> something?
>>
>> It doesn't need to. A type helper is essentially syntactic sugar for a
>> class method with the extended parameter as first type.
>
> So, is this work?
>
> === code begin ===
>
> type
> IFoo = interface
> function Execute: IFoo;
> end;
>
> TFooHelper = type helper for IFoo
> procedure Something;
> end;
>
> TFoo = class(TInterfacedObject, IFoo)
> public
> function Execute: IFoo;
> end;
>
> var
> F: IFoo;
> begin
> F := TFoo.Create;
> F.Execute.Something;
> end;
>
> === code end ===
Yes, this should work.
Regards,
Sven
More information about the fpc-pascal
mailing list