I have a bit of a delicate problem...
This idea compiles in Delphi well:
program project1;
{$mode Delphi}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Classes, SysUtils, CustApp
{ you can add units after this };
type
IBaseIntf = interface
['{99B2F4ED-0F79-47BD-8F77-594CD26C5FD1}']
function TestBase( a : integer ) : integer;
end;
type
IDerriveIntf = interface(IBaseIntf)
['{C9C458E1-EB08-45ED-B7DE-EA9FBF3ADFD3}']
function TestDerrive(a : integer) : Integer;
end;
type
{ TBaseClass }
TBaseClass = class(TInterfacedObject, IBaseIntf)
protected
function IBaseIntf.TestBase = TestBaseI;
function TestBaseI( a : integer ) : integer;
end;
type
{ TDerrivedClass }
TDerrivedClass = class(TBaseClass, IDerriveIntf)
protected
function TestDerrive(a : integer) : Integer;
end;
type
{ TIntfTestApp }
TIntfTestApp = class(TCustomApplication)
protected
procedure DoRun; override;
public
end;
{ TBaseClass }
function TBaseClass.TestBaseI(a: integer): integer;
begin
Result := a - 4;
end;
{ TDerrivedClass }
function TDerrivedClass.TestDerrive(a: integer): Integer;
begin
Result := a + 4;
end;
{ TIntfTestApp }
procedure TIntfTestApp.DoRun;
var
ErrorMsg: String;
a : IDerriveIntf;
b : IBaseIntf;
begin
a := TDerrivedClass.Create;
Writeln(a.TestDerrive(44));
Writeln(a.TestBase(44));
b := TBaseClass.Create;
Writeln(b.TestBase(44));
readln;
// stop program loop
Terminate;
end;
var
Application: TIntfTestApp;
begin
Application:=TIntfTestApp.Create(nil);
Application.Title:='Interface Test';
Application.Run;
Application.Free;
end.
And by idea I mean that there is a base interface def, a derrived one that includes the base interface and two classes that implement these interfaces.
Note that I need some kind of delegation in the base class in the form
IBaseIntf.TestBase = TestBaseI
In this case - if I have a delegating declaration like this the compiler starts to mock and throws an "this is not implemented" error. My problem is that this compiles in Delphi :/ . Is there anything that I can do in that regard? How can I fix the compile error - without removing the "delegation" stuff.
Background is that:
* I want to have a generic base matrix interface and class
* 2 derrived classes for complex and real valued matrices
* 2 derrived interfaces that implement complex and double valued matrices with the overlap of generic (IMatrix) functions that sometimes are also are superseeded (with the same name) in the derrived classes.
Note that the delphi implementation on github.com/mikerabat/mrmath already does all these things but I'm stuck now with the FPC stuff :/
Is there anything I can do in that regard?
kind regards
Mike