fpc/tests/test/trtti12.pp
svenbarth 460f309035 * fix for Mantis #31123, applied patch by Maciej Izak
* adjusted test trtti10.pp due to renamed RecInitTable field

Original commit message:

Public interface for init table for records in TypInfo:

* Rename RecInitTable to RecInitInfo (because it is special kind of PTypeInfo for init table of record). Has more sense in practical usage.
+ New structure TRecInitData (and related PRecInitData) to handle data for (init) type info for records (aka init table)
+ New structure TInitManagedField and pointer type PInitManagedField (for init table)
+ Special helper property RecInitData to get PRecInitData for tkRecord

+ test attached

git-svn-id: trunk@35134 -
2016-12-16 13:43:12 +00:00

36 lines
466 B
ObjectPascal

program trtti12;
{$MODE DELPHI}
uses
TypInfo;
type
PFoo = ^TFoo;
TFoo = packed record
public
B: Byte;
W: Word;
L: LongWord;
S: string;
I: IInterface;
A: TArray<byte>;
end;
var
td: PTypeData;
id: PRecInitData;
begin
td := GetTypeData(TypeInfo(TFoo));
id := td.RecInitData;
if id.Terminator <> nil then
Halt(1);
if td.ManagedFldCount <> 6 then
Halt(2);
if id.ManagedFieldCount <> 3 then
Halt(3);
end.