我正在尝试用dwscript创建一个模态表单。我正在向ExposeRtti注册表单,然后执行脚本,但在Script.Compile期间出现“堆栈溢出”而失败。有谁有解决这个错误的办法吗?
我当然希望我不必像使用远程对象PascalScript那样手动注册所有的TForm属性和函数,这在这个时代是丑陋的,我们想要避免这种情况。
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;发布于 2012-05-21 05:54:40
显然,dwscript不能通过扩展RTTI正确注册任何东西,除非它是简单的类。这不是我心目中的脚本引擎,所以(目前) dwscript完全属于图表,除非它可以rtti注册复杂的结构。它很有前途,但在这个包完成和使用之前还有很长的路要走。
现在返回到pascalscript、For编译器或tmsscript
https://stackoverflow.com/questions/10608731
复制相似问题