[fpc-pascal] RE: Implementing an COM-style Interface: Function Redirection Problems
Leandro Conde
lconde at str.com.ar
Fri Mar 24 19:59:21 CET 2006
I'm sorry, I'm here again:
I have to make clear one point about this problem.
I've looked at the details more carefully and found that the problem is not
with the methods in the interface itself, but with the methods inherited
from an acenstor. Like this:
Ibase = interface
//... GUID
function A1(a: SomeType): SomeReturn;
function A2(b: OtherType): SomeOtherReturn;
end;
Iderived1 = interface (Ibase)
//... GUID
function Specific1(<specific 1 args>): <result 1>;
end;
Iderived2 = interface (Ibase)
//... GUID
function Specific2(<specific 2 args>): <result 2>
end;
Then, in the implementation:
Tx = class(
TInterfacedObject,
Iderived1, // note: we implement the derived interfaces, *NOT* the base.
Iderived2
)
protected // Ibase functions for Iderived1 ..
function Iderived1.A1 = Derived1_A1;
function Iderived1.A2 = Derived1_A2;
protected // Iderived1 implementation ...
function Derived1_A1(a: sometype): SomeReturn;
function Derived1_A1(b: othertype): SomeOtherReturn; end;
function Specific2(<specific 2 args>): <result 2>;
protected // Ibase functions for Iderived2 ..
function Iderived2.A1 = Derived2_A1;
function Iderived2.A2 = Derived2_A2;
protected
function Derived2_A1(a: sometype): SomeReturn;
function Derived2_A1(b: othertype): SomeOtherReturn;
function Specific2(<specific 2 args>): <result 2>;
end;
Now, the compiler complains about the *missing* implementation for functions
in interface Ibase when the class doesn't explicitly names it in the
interface list. It seems that the compiler thinks that the interface Ibase
must have an implementation (a VTable) and wants to find the functions to
put in there.
Needless to say, in Delphi this compiles and works ok.
Thanks again!
Cheers, see you later.
Leandro.
-----Original Message-----
From: Leandro Conde [mailto:lconde at str.com.ar]
Sent: Friday, March 24, 2006 15:14
To: 'fpc-pascal at lists.freepascal.org'
Subject: Implementing an COM-style Interface: Function Redirection Problems
Hi people,
I've been trying to port, from Delphi to FPC in windows, a large open source
library which uses many COM-style interfaces, and in this process found that
the "interface function redirection" [1: see below] feature, for redirecting
the interface's methods to other functions with different names, is not
working properly ...
I'm using the version 2.0.2:
Free Pascal Compiler version 2.0.2 [2005/11/26] for i386
Copyright (c) 1993-2005 by Florian Klaempfl
Where I can find more information about this? Is this a problem with the
compiler? I haven't found it reported in the bugs section, nor can I found a
mention of it in the Wiki (search).
Thank you for any help.
Leandro.
[1] I talking about this:
Ix = interface
//... GUID
function A1(a: sometype): SomeReturn;
function A2(b: othertype): SomeOtherReturn; end;
And then, implementing it:
Tx = class(TInterfacedObject, Ix)
protected // Ix impl ..
function Ix.A1 = MyA1;
function Ix.A2 = MyA2;
protected
function MyA1(a: sometype): SomeReturn;
function MyA2(b: othertype): SomeOtherReturn; end;
With that, the compiler complains about not finding the implementation for
functions A1 & A2 for interface Ix.
This is the error text:
"Error: No matching implementation for interface method"
It is a known bug? If it is not reported I can prepare a sample program for
reproducing this issue.
Cheers,
Leandro.
More information about the fpc-pascal
mailing list