Am 13.12.2016 09:22 schrieb "Maciej Izak" <hnb.c...@gmail.com>: > > > 2016-12-12 23:14 GMT+01:00 Maciej Izak <hnb.c...@gmail.com>: >> >> With second iteration we could add your modifications, I have no other objections. >
Comment regarding your previous mail: right, I forgot that due to InitializeArray() and FinalizeArray() being publicly available version of the internal helpers we either need to keep INIT and FULL RTTI in sync or a way to differentiate them... That's why you added the Terminator field I guess? > New day new ideas :) > > With my patch we don't really need ManagedFieldCount, ManagedFields, ManagedFieldTable in TTypeData (each of Managed* can still be added later). It means also much better memory usage and it solves RTL problems (which was mentioned in my previous message). All what we need is: > > === code begin === > type > TInitManagedField = record > TypeRefRef: TypeInfoPtr; > FldOffset: SizeInt; > end; > > PPRecInitTable = ^PRecInitTable; > PRecInitTable = TRecInitTable; > TRecInitTable = packed record > Size: Longint; > Terminator: Pointer; > ManagedFieldCount: Longint; > { ManagedFields: array[0..ManagedFieldCount - 1] of TInitManagedField ; } > end; > > TRecordField = record > Visibility: TVisibility; > TypeRef: TypeInfoPtr; > FldOffset: SizeInt; > > Name: PShortString; { can be NULL if no ext RTTI } > end; > > TManagedField = TRecordField deprecated; > > TTypeData = record > // ... > tkRecord: ( > RecSize: Integer; > RecInitTable: PPRecInitTable; > case Boolean of > True: (ManagedFldCount: Integer deprecated 'Use RecInitTable^^.ManagedFieldCount or TotalFieldCount depending on your use case') > False: (TotalFieldCount: Integer) > { Fields: array[1..TotalFieldCount] of TRecordField } > { Names: array[1..TotalFieldCount] of {packed} ShortString } > ); > end; > === code end === > > I have hope that this is final solution :) Okay, I think we can indeed go with this aside from one small remark: the double indirection for Pointers is only needed if data resides in different units as those might be in different dynamic packages. Since the INIT and FULL RTTI of a record are always in the same unit a single indirection is sufficient (thus PRecInitTable instead of PPRecInitTable). Other than that I think we've found a good compromise for our wishes and hopes for this :) Regards, Sven
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel