Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-09

how do I get Run Time info from a published method?

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dennis Poon

say for example:

   type
      TmyClass = class
      published
         procedure Something (sender : Tobject);virtual;
     end;
var
   myClass  : TmyClass;

then somewhere

     AddMethodToQueue(@myclass.Something);

Is it possible within AddMethodToQueue, I can query the Run Time Type Info of the method passed in ?

procedure AddMethodToQueue(const TheEvent : TNotifyEvent);
var aMethodObjectname : String;
begin
     //I can already do this
      aMethodObjectName := TObject(TMethod(TheEvent).Data).ToString;
     //how do I check the RTTI of TheEvent and get the name of the
method i.e. 'Something'?
    //since it is published, it should be possible, right?
end;

Thanks in advance.

Dennis

Reply by email

Flávio Etrusco
to Dennis Poon
Dennis Poon wrote 39 lines
say for example: type TmyClass = class published procedure Something (sender : Tobject);virtual; end; var myClass : TmyClass; then somewhere AddMethodToQueue(@myclass.Something); Is it possible within AddMethodToQueue, I can query the Run Time Type Info of the method passed in ? procedure AddMethodToQueue(const TheEvent : TNotifyEvent); var aMethodObjectname : String; begin //I can already do this aMethodObjectName := TObject(TMethod(TheEvent).Data).ToString; //how do I check the RTTI of TheEvent and get the name of the method i.e. 'Something'? //since it is published, it should be possible, right? end; Thanks in advance. Dennis _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Simply:

  vObj := TObject(TMethod(TheEvent).Data);
  vMethodName := vObj.MethodName(TMethod(TheEvent).Code);

?

Regards,
Flávio

Reply by email