Stack overflow on dwscript compilation containing TForm.Create (nil)

I am trying to create a modal form with dwscript. I register the form with ExposeRtti, then execute the script, but it fails when the stack overflows during Script.Compile. Does anyone have a solution to this error.

Of course, I hope that I do not need to register all the properties and functions of TForm manually, as we should with PascalScript remobjects, it would be ugly in this era, as if to avoid it.

Can dwscript do this or forms that go beyond dwscript (at this stage?)?

procedure TMainForm.Button1Click(Sender: TObject);
var AdwsProgramExecution: IdwsProgramExecution;
  ADelphiWebScript: TDelphiWebScript;
  AdwsProgram: IdwsProgram;
  AdwsUnit: TdwsUnit;
begin
  AdwsUnit := TdwsUnit.Create(nil);
  ADelphiWebScript := TDelphiWebScript.Create(nil);
  try
    AdwsUnit.UnitName := 'ShowModalTest';
    AdwsUnit.Script := ADelphiWebScript;
    AdwsUnit.ExposeRTTI(TypeInfo(TObject)); //Otherwise GetOnAlignInsertBefore error when 'compiling'
    AdwsUnit.ExposeRTTI(TypeInfo(TForm)); //Want t ocreate a form
    AdwsProgram := ADelphiWebScript.Compile('procedure TestShowModal; begin TForm.Create(nil).ShowModal; end; end.'); //Stack overflow
    if AdwsProgram.Msgs.Count = 0 then 
    begin
      AdwsProgramExecution := AdwsProgram.Execute;
      MEResult.Lines.Text := AdwsProgramExecution.Result.ToString;
    end
    else 
      MEResult.Lines.Text := AdwsProgram.Msgs.AsInfo;
  finally
    ADelphiWebScript.Free;
    AdwsUnit.Free;
  end;
end;
+5
source share
1 answer

-, dwscript - RTTI, . , script, ( ) dwscript , rtti . , - , .

pascalscript, paxcompiler tmsscript

0

All Articles