views:

70

answers:

2

suppose i have a unit like this

unit sample;

interface

function Test1:Integer;
procedure Test2;

implementation

function Test1:Integer;
begin
 result:=0;
end;

procedure Test2;
begin

end;

end.

Is possible enumerate all the procedures and functions of the unit sample in runtime?

A: 

I don't think so.

That is a compile-time config, it's used so as the compiler knows which function name is being called or not. As far as I know, there is nothing at runtime which comes close to listing these functions.

Delphi's excellent runtime features come from RTTI, you might want to see what it offers in relation to this. But as I said, I don't think it's possible (know that I've delved in RTTI for quite some time...).

Edit: Oh and by the way, after compilation, functions lose their human-readable names (to addresses). There are some tables which pinpoint those names to addresses, most notably, RTTI and the Debug info.

Christian Sciberras
+3  A: 

No. RTTI is not generated for standalone methods. Hopefully this will be fixed in a later version, (they'd probably need a TRttiUnit type to do that,) but for now it's not available.

Mason Wheeler