Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-03

Implementing an COM-style Interface: Function Redirection Problems

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Leandro Conde

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.

Reply by email

Leandro Conde

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.

Earlier message 60 lines
-----Original Message----- From: Leandro Conde Sent: Friday, March 24, 2006 15:14 To: '' 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.

Reply by email

Michael Van Canneyt
to Leandro Conde: I've been trying to port, from Delphi to FPC in windows, a large open source library…
Leandro Conde wrote 7 lines
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 ...

interface function redirection does not work in FPC, AFAIK. There is a comment about this in the documentation.

Unless Florian or Peter have implemented it in the meanwhile, there has been some discussion about this.

Michael.

Reply by email

Leandro Conde
to Michael Van Canneyt

Hi Michael,
Thank you for your response.

(read below)

Show quoted text 15 lines
On Fri, 24 Mar 2006, Leandro Conde wrote: > 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 ... interface function redirection does not work in FPC, AFAIK. There is a comment about this in the documentation.

As I've been working in the port, my main goal was to make the library compile. With this in mind, I'm sure that the compiler doesn't complain about all the cases in which function redirection is used, just when it is used in the form described in my other message ...

Show quoted text 5 lines
Unless Florian or Peter have implemented it in the meanwhile, there has been some discussion about this. Michael.

Thanks for the info, I'm going to do some searches then.

See you,
Leo.

Reply by email

Peter Vreman
to Leandro Conde
Show quoted text 15 lines
> > 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 ... > > interface function redirection does not work in FPC, AFAIK. > There is a comment about this in the documentation. As I've been working in the port, my main goal was to make the library compile. With this in mind, I'm sure that the compiler doesn't complain about all the cases in which function redirection is used, just when it is used in the form described in my other message ...

Please submit a bug report with complete source to reproduce.

Reply by email

Leandro Conde
to Peter Vreman

Hi Peter:

Show quoted text 7 lines
-----Original Message----- From: On Behalf Of Peter Vreman Please submit a bug report with complete source to reproduce.

I've been trying to do so, but a cannot send the full sample code in the bug report form. It ignores me :)
Seems it is too large for it ... but a cannot reduce it without making it useless.

How can I do to send it?

Thanks.
Leandro.

Reply by email