[fpc-pascal] Listing the type (even as string) of the parameters and the return of a function

silvioprog silvioprog at gmail.com
Mon Oct 8 01:33:57 CEST 2018


Hi.

First, thanks for the great work in the invoke.inc for win64! ☺

So, consider the following example:

uses RTTI;

type
  TFoo = class
  public
    function Bar(const A: string; B: Integer): string;
  end;

function TFoo.Bar(const A: string; B: Integer): string;
begin
end;

var
  m: TRttiMethod;
  p: TRttiParameter;
begin
  m := TRttiContext.Create.GetType(TFoo.ClassInfo).GetMethod('Bar');
  Writeln('m: ', m.ReturnType.ToString);
  for p in m.GetParameters do
    Writeln(' p: ', p.ParamType.ToString);
end.

in Delphi, it returns:

m: string
 p: string
 p: Integer

in the current stage of RTTI or TypInfo, is there any way to retrieve the
type (even as string) of the parameters and the return of a function
passing its name as string and only the vtypeinfo of the instance of showed
in the above example?

Thanks in advance!

-- 
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20181007/8345284b/attachment.html>


More information about the fpc-pascal mailing list