Hello
we have come accross 2 problems with interfaces. Since Pascal Script is supposed to fully support interfaces I am writing this ticket. We have tested it both in Delphi XE2 and FPC 2.6.4
This is the definition in the pascal program. Nothing special here.
type
IMyInterface = Interface(IUnknown)
[’{8B7D2D7D-567D-46F4-A294-A52C9F1F4EAF}’]
procedure writeoutput(a: ansistring);
end;
TMyClass = class(TRetainableObject, IMyInterface)
public
procedure writeoutput(a: ansistring);
end;
Both the class methods and interface with methods is registered in the compiler and runtime PS classes.
What works is:
passing an interface back to the pascal program
What does not work:
calling interface methods
pascal script:
var
m: tmyclass;
i: imyinterface;
begin
m := tmyclass.create;
i := m;
i.writeoutput(‘1’);
end.
This results in an PS compiler error (assign expected on the line of “i.writeoutput…”).
The same code works in Delphi or FPC directly of course
overtyping interface to class instance
pascal script:
var
m: tmyclass;
i: imyinterface;
begin
m := tmyclass.create;
i := m;
m := i as tmyclass;
m.writeoutput(‘aaaa’);
end.
This does not fire any runtime or compilation error but PS exists / stops executing anything after the line “m := i as tmyclass;”. Simply anything that follows is never executed.
The same code works in Delphi or FPC…
We believe these to be bugs.
Please, let me know if we can assist any more