[fpc-devel] RTTI module and "IsManaged" critical problem

Maciej Izak hnb.code at gmail.com
Sun Dec 11 13:18:12 CET 2016

2016-12-10 0:54 GMT+01:00 Sven Barth <pascaldragon at googlemail.com>:

> We rename ManagedFldCount to TotalFieldCount, add a field
> ManagedFieldCount and a property ManagedFldCount that returns
> TotalFieldCount for backwards compatibility (and maybe marked as
> deprecated).

I've created new bug report to express my strong stand about this problem:

(copied from bug report)

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
* 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});


  TRecordTypeField = packed record
    Field: TManagedField;
    Flags: Byte; // visibility
    Name: ShortString;

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:


The patch provided in #29767 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.

Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20161211/a253ec4f/attachment.html>

More information about the fpc-devel mailing list