Delphi Web Script: How to find the Class Name of a Script-TClass in Delphi

我怕爱的太早我们不能终老 提交于 2020-01-25 04:20:12

问题


Imagine this procedure, which is callable in a script:

// Foo is not implemented in the Script but via Delphi
procedure Foo(ClassType: TClass); 

The Script looks like that:

type 
  TMyClass = class
  end;

Foo(TMyClass);

When Foo gets called my Delphi App sees an Int64-Value for the ClassType.

e.g. Foo(661259635); 

You can see in the DWS sources that a TClass is explicitly converted to an Int64 (see dwsCompiler.pas, procedure TObjectClassTypeMethod.Execute -> Info.ResultAsInteger := Int64(info.ValueAsClassSymbol[SYS_SELF]);).

Now in which structure I can search for that number to find the corresponding TdwsClass?

Note: In fact TMyClass is not implemented in the script, but created exposed via the Delphi App...I don't know if this makes a difference.


回答1:


You currently have to cast the Int64 back to a TClassSymbol manually, the conversion is performed to store the reference in a Variant (which doesn't support TClass).

Once you have the TClassSymbol, you can lookup the symbol table, or navigate to the members.

There is at the moment no IInfo helper to class symbols.



来源:https://stackoverflow.com/questions/7109376/delphi-web-script-how-to-find-the-class-name-of-a-script-tclass-in-delphi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!