class method exposed via RTTI not working
Issue #211
new
I'm using ExposeRTTI to expose a class with a class method but when calling the class method there is an 'invalid typecast' exception.
Here is the code:
// TSimple test class
TSimple = class(TObject)
published
procedure a();
class procedure c();
end;
procedure TSimple.a;
begin
ShowMessage('a');
end;
class procedure TSimple.c;
begin
ShowMessage('c');
end;
...
// expose TSimple class
procedure TForm1.Button1Click(Sender: TObject);
begin
dwsUnit1.Script := DelphiWebScript1;
dwsUnit1.ExposeRTTI(TypeInfo(TSimple));
//
Self.DoRun(DelphiWebScript1, Memo1.Lines.Text);
end;
and this is the script:
var aTest := TSimple.Create();
aTest.a();
TSimple.c();
Anything I'm doing wrong?
Attached is the full sample code.
Invoking of class function in Delphi (in FPC same, i think so) need 1 “hidden” argument - NOT
Instance
(like for usual object methods) , butInstance.ClassType
But in DWS for class methods missing ScriptObj, so we cannot obtain this info.
Need fix.