-1

The answer to Which language elements can be annotated using attributes language feature of Delphi? suggests that it is possible to add attributes to ordinary procedures and functions. My question is how can one retrieve that information given the string name of the procedure or function?

[myProcAttribute('Some useful info')]
procedure myProc;
begin
  // Do something
end;

Given the string 'myProc' I would like to retrieve the associate attribute.

I'm using XE6

Community
  • 1
  • 1
rhody
  • 2,274
  • 2
  • 22
  • 40
  • The article you link to concludes with this: *There's no way of retrieving any sort of RTTI for "unit" level or local variables and procedures, hence no way of retrieving information about attributes.* – David Heffernan Nov 21 '14 at 20:28
  • I saw that but I was wondering if anyone had figured something since then because the question is three years ago. – rhody Nov 21 '14 at 20:31

1 Answers1

0

The article you link to says:

There's no way of retrieving any sort of RTTI for "unit" level or local variables and procedures, hence no way of retrieving information about attributes.

I believe that this is correct. The documentation lists a number of methods for TRttiContext. These are:

  • Create
  • DropContext
  • FindType
  • Free
  • GetPackages
  • GetType
  • GetTypes
  • KeepContext

These give you means to locate types, but not procedures. Once you locate a type you can enumerate its methods, but that's no use to here because you want to find a procedure rather than a method.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490