class method exposed via RTTI not working

Issue #211 new
Former user created an issue

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.

Comments (1)

  1. Alex Bespalov

    Invoking of class function in Delphi (in FPC same, i think so) need 1 “hidden” argument - NOT Instance(like for usual object methods) , but Instance.ClassType

    But in DWS for class methods missing ScriptObj, so we cannot obtain this info.

    Need fix.

  2. Log in to comment