Implementing an COM-style Interface: Function Redirection Problems

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Implementing an COM-style Interface: Function Redirection Problems

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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Implementing an COM-style Interface: Function Redirection Problems

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.

-----Original Message-----
From: Leandro Conde [mailto:[hidden email]]
Sent: Friday, March 24, 2006 15:14
To: '[hidden email]'
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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Implementing an COM-style Interface: Function Redirection Problems

Michael Van Canneyt
In reply to this post by Leandro Conde


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.

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

Michael.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Implementing an COM-style Interface: FunctionRedirection Problems

Leandro Conde-2
Hi Michael,
Thank you for your response.

(read below)

>
> 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 ...

>
> 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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Implementing an COM-style Interface: FunctionRedirection Problems

Peter Vreman
>> > 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.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Implementing an COM-style Interface: FunctionRedirection Problems

Leandro Conde-2
Hi Peter:

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] 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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal