[fpc-pascal] get class of procedure variable

Ryan Joseph genericptr at gmail.com
Fri May 29 09:03:58 CEST 2020


In the example below "callback" is assigned to a method of "obj", but is it possible to get the class back from the variable? In the pseudo code I would expect .GetClass to return "obj". I think "of object" must be a record which keep both the class and method pointer but I don't know how to access it.

  
  type TCallback = procedure of object;
  var 
    callback: TCallback;
    obj: TObject;
  begin
    callback := obj.SomeMethod;
  
    // get the class which callback is assigned to
    if callback.GetClass = XXX then
      ;

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list