加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 09:45:27 所属栏目:大数据 来源:网络整理
导读:我正在尝试用dwscript创建一个模态表单.我使用ExposeRtti注册表单,然后执行脚本,但在Script.Compile期间它在“堆栈溢出”时失败.有没有人有这个错误的解决方案. 我当然希望我不必手动注册所有TForm属性和函数,就像我们必须使用remobjects PascalScript一样,
我正在尝试用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;

解决方法

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

现在回到pascalscript,paxcompiler或tmsscript

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读