编译包含TForm.Create(nil)的dwscript时堆栈溢出

Mar*_*ius 5 stack-overflow delphi dwscript

我正在尝试用dwscript创建一个模态表单.我使用ExposeRtti注册表单,然后执行脚本,但在Script.Compile期间它在"堆栈溢出"时失败.有没有人有这个错误的解决方案.

我当然希望我不必手动注册所有TForm属性和函数,就像我们必须使用remobjects PascalScript一样,在这个时代它会让我们难看,就像避免那样......

dwscript可以这样做,还是形式超出了dwscript的范围(在这个阶段?)?

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;
Run Code Online (Sandbox Code Playgroud)

Mar*_*ius 0

显然 dwscript 无法通过扩展 RTTI 正确注册任何内容,除非它是简单的类。这不是我对脚本引擎的想法,所以(目前)dwscript 完全是图表中的内容,除非它可以 rtti 注册复杂的结构。它非常有前途,但在这个包完成并可用之前还有很长的路要走。

现在回到 pascalscript、paxcompiler 或 tmsscript