Implemendet host interface in script
Is it possible to write a script with class that implements an
interface that is defined in the host? And then provide the interface
(from the script) to host and using it like a other interfaces?
Example:
Delphi-Host definition:
type
ISomething = interface
function Do(aParam : Variant) : Integer;
end;
script code:
TSomething = class(ISomething, TInterfacedObject)
public
function Do(aParam : Variant) : Integer;
end;
funcion TSomething.Do(aParam : Variant) : Integer;
begin
<code>
result := 0;
end;
Delphi-Host interface use code:
var
ISom : ISomething;
begin
ISom := GetImplementationFromFastScript();
case ISom.Do(some_variant) of
0: <code>
1: <code>
end;
where:
GetImplementationFromFastScript() - a "magical" way to obtain a reference interface implemented in the script.
--
kind regards
Jacek
interface that is defined in the host? And then provide the interface
(from the script) to host and using it like a other interfaces?
Example:
Delphi-Host definition:
type
ISomething = interface
function Do(aParam : Variant) : Integer;
end;
script code:
TSomething = class(ISomething, TInterfacedObject)
public
function Do(aParam : Variant) : Integer;
end;
funcion TSomething.Do(aParam : Variant) : Integer;
begin
<code>
result := 0;
end;
Delphi-Host interface use code:
var
ISom : ISomething;
begin
ISom := GetImplementationFromFastScript();
case ISom.Do(some_variant) of
0: <code>
1: <code>
end;
where:
GetImplementationFromFastScript() - a "magical" way to obtain a reference interface implemented in the script.
--
kind regards
Jacek