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.


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 :)

-- 
Best regards,
Maciej Izak
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to