Wrong value for ManagedFldCount (TypInfo.TTypeData)
Original Reporter info from Mantis: hnb
-
Reporter name: Maciej Izak
Original Reporter info from Mantis: hnb
- Reporter name: Maciej Izak
Description:
FPC has long standing critical issue. ManagedFldCount field in TypInfo (TTypeData) contains "count" for all fields (but should contains "count" for managed fields only - as name suggest). It is not feature but highly visible bug.
* The bug has critical meaning for development of RTTI.pas because is impossible to implement in rational way IsManaged function (ManagedFldCount is used for that)
* The bug has many performance issues especially for InitializeArray/FinalizeArray.
* The bug means more Delphi incompatibility RTTI.
* For scripting languages it means many troubles (for Delphi porting code)
* TManagedField entry for each (I mean here unmanaged fields) field has zero value for programmer, it has no sense.
any partial fix with pseudo backward compatibility has no sens and will bring much more noise and confusion and more complicated RTTI code without real gain.
the proper layout for part related to records (in current state) in TTypeData is:
tkRecord: ( // could be extended for info about attributes, methods and operators (maybe also properties)
RecSize: Integer;
ManagedFldCount: Integer;
{ManagedFields: array[0..ManagedFldCnt - 1] of TManagedField;
RecFldCnt: Integer;
RecFields: array[1..RecFldCnt] of TRecordTypeField});
where
TRecordTypeField = packed record
Field: TManagedField;
Flags: Byte; // visibility
Name: ShortString;
end;
When we have additional "Name" and "Flag" for managed and unamanaged fields it has sense, because when we have more info than pure TManagedField for each field, it could be used for ORM or for scripts. Probably is good idea to correlate RecFields together with:
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
The patch provided in #29767 (closed) is wrong when we thinking about extended RTTI (init table should stay simple as possible), same for MO PART 2 ( http://bugs.freepascal.org/view.php?id=30687#c96093 )
It must be changed same as was needed change for indirect type info (PPTypeInfo) for greater good. Thanks.
Mantis conversion info:
- Mantis ID: 31102
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 35180 (#73ed1a9b)