1

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.

ain
  • 22,394
  • 3
  • 54
  • 74
Steffen Binas
  • 1,463
  • 20
  • 30

1 Answers1

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.

Eric Grange
  • 5,931
  • 1
  • 39
  • 61
  • Thanks. I tried to look it up but ended in `function TdwsClass.DoGenerate`. That's where the `TClassSymbol` is created with no reference to the TdwsClass. I didn't find any backlink. Did I miss something? If not I assume I have to stick with the class name and search over all known units. – Steffen Binas Aug 19 '11 at 15:02