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

Sven Barth pascaldragon at googlemail.com
Mon Oct 8 11:21:16 CEST 2018


silvioprog <silvioprog at gmail.com> schrieb am Mo., 8. Okt. 2018, 10:11:

> 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?
>

Short answer: No.

Long answer: No. The extended RTTI required for that is currently only
generated for interfaces with $M+ set.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20181008/f3bf1841/attachment.html>


More information about the fpc-pascal mailing list