Extended RTTI must be extended to enable Delphi compatible behaviour.
-
Support for $RTTI directive
- includes both EXPLICIT and INHERIT options
- includes TVisibilityClasses set type
- includes DefaultFieldRttiVisibility, DefaultMethodRttiVisibility and DefaultPropertyRttiVisibility constants
- by default values of the Default*RttiVisibility constants is Delphi compatible with the following restrictions:
- the constants can be forced to '[]' by passing a define (e.g. RTL_NO_EX_RTTI) when building the RTL
- on resource restricted systems the constants have by default the value '[]'
- this includes at least the CPUs i8086 and AVR
- and at least the targets GBA, NDS, Wii, Amiga68k, GO32V2
- this can be avoided by compiling the RTL with a define (e.g. RTL_FORCE_EX_RTTI) -
Generating the RTTI metadata for fields, methods and properties
- this includes classes, records and helper types
- the record format should in principle be usable for the object type as well (which does not have RTTI enabled currently)
- interface types should obey the $RTTI switch as well in addition to $M
Note: Raw interfaces currently don't have additional RTTI (properties, methods enabled), but the data should in principle work for those as well
- the format of the new RTTI metadata should be Delphi compatible where it doesn't make sense to implement something faster (especially related to enumeration of the data) - e.g. identifier names can be
implemented using references to shared string data as is done in the RTTI for interface methods
- the format of the new RTTI metadata should be as source compatible as reasonably possible to old, existing FPC code
- check how extended RTTI is handled for generic methods in Delphi (both the generic and the specialization)
- new metadata should contain pointers to a TAttributeTable
- the compiler should fill this already (all defs and syms already have a corresponding field)
- having the compiler bind attributes to fields, methods, properties is not yet necessary (though if desired it can be implemented already as well) -
Support for accessing the extended RTTI in the TypInfo unit
-
Support for accessing the extended RTTI in the RTTI unit (preferrably using functionality of the TypInfo unit to avoid code duplication)
-
Explicitely not part of this assignment:
- enumerating types in a unit/the whole program
- $WEAKLINKRTTI (which relies on the above point)
-
Tests for both the lowlevel functionality as well as the TypInfo/RTTI units, that should pass at least on the following platforms:
- any i386 or x86_64 target
- any arm target (32-bit) (due to alignment hassle)
- a Big Endian target
- i8086-msdos with both near pointers and far pointers
Note: it's enough for the tests to pass in a VM (e.g. QEMU's user mode VM for ARM and the Big Endian target and DOSBox for MSDOS) - Further fixes/functionality for the RTTI unit that are independent of the Extended RTTI feature
(e.g. fixes for TValue type) should be reported/provided independently and ASAP as that unit is otherwise actively used and developed on