Recent

Author Topic: RTTI (3.3.1)  (Read 543 times)

DevilDevil

  • New Member
  • *
  • Posts: 49
RTTI (3.3.1)
« on: December 08, 2020, 04:11:23 am »
Hi everyone

Trying to analyze the new RTTI (ver. 3.3.1).
Can't figure out how to get the list of methods.

Code: Pascal  [Select][+][-]
  1. type
  2.   TTest = class
  3.   public
  4.     X: Integer;
  5.     Y: string;
  6.   published
  7.     procedure SomeMethod(const V: Integer); virtual; abstract;
  8.     property D: Integer read X write X;
  9.   end;  
  10.  
  11. var
  12.   Context: TRttiContext;
  13.   RttiType: TRttiType;
  14. begin
  15.   RttiType := Context.GetType(TTest);
  16.   Writeln(Length(RttiType.GetMethods));

Method list is empty. Can't figure out how to adjust the visibility level in RTTI. In Delphi, it is done like this (it does not work in FPC):

Code: Pascal  [Select][+][-]
  1. {$RTTI EXPLICIT FIELDS/PROPERTIES/METHODS([vcPrivate, vcProtected, vcPublic, vcPublished])}

PascalDragon

  • Hero Member
  • *****
  • Posts: 2885
  • Compiler Developer
Re: RTTI (3.3.1)
« Reply #1 on: December 08, 2020, 09:46:05 am »
Trying to analyze the new RTTI (ver. 3.3.1).
Can't figure out how to get the list of methods.

This is not yet supported. For now you can only retrieve the methods from interface types (COM only, not CORBA/raw) with {$M+} enabled.

In Delphi, it is done like this (it does not work in FPC):

Code: Pascal  [Select][+][-]
  1. {$RTTI EXPLICIT FIELDS/PROPERTIES/METHODS([vcPrivate, vcProtected, vcPublic, vcPublished])}

FPC does not yet support Extended RTTI.

DevilDevil

  • New Member
  • *
  • Posts: 49
Re: RTTI (3.3.1)
« Reply #2 on: December 08, 2020, 12:36:24 pm »
Got it
Keep in touch :)

 

TinyPortal © 2005-2018