If an IScriptObj link is IScriptObj , how do I get to the corresponding IInfo or TProgramInfo ?
I have a script object that wraps a Delphi object.
To control the lifetime of a script object, the Delphi object stores a reference to the script object. The script object is declared by the TdwsUnit component. It is pretty standard and looks something like this:
Delphi
type TDelphiObject = class private FScriptObject: IScriptObj; public procedure DoSomething; property ScriptObject: IScriptObj read FScriptObject write FScriptObject; end;
Script
type TScriptObject = class protected procedure DoSomething; virtual; public constructor Create; end;
The implementation of the Delphi object and the configuration of the Delphi / script links occurs in the implementation of the Delphi script object constructor. Also pretty standard:
Delphi
Ideally, I would keep the IInfo link, and IScriptObj , since IInfo does everything I need later, but from experience it seems that the IInfo object IInfo valid only for the duration of the method call.
In any case, the problem occurs later when TDelphiObject.DoSomething is called on the Delphi side. TDelphiObject.DoSomething intended to call the appropriate virtual method for the script object:
Delphi
procedure TDelphiObject.DoSomething; var Info: IInfo; DoSomethingInfo: IInfo; begin // I have a IScriptObj but I need a IInfo... Info := { what happens here? }; // Call the virtual DoSomething method DoSomethingInfo := Info.Method['DoSomething']; DoSomethingInfo.Call([]); end;
I tried many different methods to get a useful IInfo or TProgramInfo from a saved IScriptObj , but everything failed. So what is the right way to do this?
delphi dwscript
Speedfreak
source share