|
@@ -42,17 +42,36 @@ type
|
|
{$endif}
|
|
{$endif}
|
|
end;
|
|
end;
|
|
|
|
|
|
- PRecordInfo=^TRecordInfo;
|
|
|
|
- TRecordInfo=
|
|
|
|
|
|
+ PRecordInfoFull=^TRecordInfoFull;
|
|
|
|
+ TRecordInfoFull=
|
|
{$ifdef USE_PACKED}
|
|
{$ifdef USE_PACKED}
|
|
packed
|
|
packed
|
|
{$endif USE_PACKED}
|
|
{$endif USE_PACKED}
|
|
record
|
|
record
|
|
|
|
+{$ifndef VER3_0}
|
|
|
|
+ InitTable: PPointer;
|
|
|
|
+{$endif VER3_0}
|
|
Size: Longint;
|
|
Size: Longint;
|
|
Count: Longint;
|
|
Count: Longint;
|
|
{ Elements: array[count] of TRecordElement }
|
|
{ Elements: array[count] of TRecordElement }
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ PRecordInfoInit=^TRecordInfoInit;
|
|
|
|
+{$ifndef VER3_0}
|
|
|
|
+ TRecordInfoInit=
|
|
|
|
+{$ifdef USE_PACKED}
|
|
|
|
+ packed
|
|
|
|
+{$endif USE_PACKED}
|
|
|
|
+ record
|
|
|
|
+ Terminator: Pointer;
|
|
|
|
+ Size: Longint;
|
|
|
|
+ Count: Longint;
|
|
|
|
+ { Elements: array[count] of TRecordElement }
|
|
|
|
+ end;
|
|
|
|
+{$else VER3_0}
|
|
|
|
+ TRecordInfoInit=TRecordInfoFull;
|
|
|
|
+{$endif VER3_0}
|
|
|
|
+
|
|
PArrayInfo=^TArrayInfo;
|
|
PArrayInfo=^TArrayInfo;
|
|
TArrayInfo=
|
|
TArrayInfo=
|
|
{$ifdef USE_PACKED}
|
|
{$ifdef USE_PACKED}
|
|
@@ -83,7 +102,22 @@ end;
|
|
function RTTIRecordSize(typeInfo: Pointer): SizeInt;
|
|
function RTTIRecordSize(typeInfo: Pointer): SizeInt;
|
|
begin
|
|
begin
|
|
typeInfo:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
|
|
typeInfo:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
|
|
- result:=PRecordInfo(typeInfo)^.Size;
|
|
|
|
|
|
+ { for size field init table is compatible with rtti table }
|
|
|
|
+ result:=PRecordInfoFull(typeInfo)^.Size;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function RTTIRecordRttiInfoToInitInfo(typeInfo: Pointer): Pointer; inline;
|
|
|
|
+begin
|
|
|
|
+ result:=typeInfo;
|
|
|
|
+{$ifndef VER3_0}
|
|
|
|
+ { find init table }
|
|
|
|
+ typeInfo:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
|
|
|
|
+
|
|
|
|
+ { check terminator, maybe we are already in init table }
|
|
|
|
+ if Assigned(PRecordInfoInit(typeInfo)^.Terminator) then
|
|
|
|
+ { point to more optimal initrtti }
|
|
|
|
+ result:=PRecordInfoFull(result)^.InitTable^;
|
|
|
|
+{$endif VER3_0}
|
|
end;
|
|
end;
|
|
|
|
|
|
function RTTISize(typeInfo: Pointer): SizeInt;
|
|
function RTTISize(typeInfo: Pointer): SizeInt;
|
|
@@ -112,8 +146,8 @@ var
|
|
i : longint;
|
|
i : longint;
|
|
begin
|
|
begin
|
|
typeInfo:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
|
|
typeInfo:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
|
|
- Count:=PRecordInfo(typeInfo)^.Count;
|
|
|
|
- Inc(PRecordInfo(typeInfo));
|
|
|
|
|
|
+ Count:=PRecordInfoInit(typeInfo)^.Count;
|
|
|
|
+ Inc(PRecordInfoInit(typeInfo));
|
|
{ Process elements }
|
|
{ Process elements }
|
|
for i:=1 to count Do
|
|
for i:=1 to count Do
|
|
begin
|
|
begin
|
|
@@ -173,7 +207,10 @@ begin
|
|
tkObject,
|
|
tkObject,
|
|
{$endif FPC_HAS_FEATURE_OBJECTS}
|
|
{$endif FPC_HAS_FEATURE_OBJECTS}
|
|
tkRecord:
|
|
tkRecord:
|
|
- recordrtti(data,typeinfo,@int_initialize);
|
|
|
|
|
|
+ begin
|
|
|
|
+ typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
|
|
|
|
+ recordrtti(data,typeinfo,@int_initialize);
|
|
|
|
+ end;
|
|
{$ifdef FPC_HAS_FEATURE_VARIANTS}
|
|
{$ifdef FPC_HAS_FEATURE_VARIANTS}
|
|
tkVariant:
|
|
tkVariant:
|
|
variant_init(PVarData(Data)^);
|
|
variant_init(PVarData(Data)^);
|
|
@@ -203,7 +240,10 @@ begin
|
|
tkObject,
|
|
tkObject,
|
|
{$endif FPC_HAS_FEATURE_OBJECTS}
|
|
{$endif FPC_HAS_FEATURE_OBJECTS}
|
|
tkRecord:
|
|
tkRecord:
|
|
- recordrtti(data,typeinfo,@int_finalize);
|
|
|
|
|
|
+ begin
|
|
|
|
+ typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
|
|
|
|
+ recordrtti(data,typeinfo,@int_finalize);
|
|
|
|
+ end;
|
|
tkInterface:
|
|
tkInterface:
|
|
Intf_Decr_Ref(PPointer(Data)^);
|
|
Intf_Decr_Ref(PPointer(Data)^);
|
|
{$ifdef FPC_HAS_FEATURE_DYNARRAYS}
|
|
{$ifdef FPC_HAS_FEATURE_DYNARRAYS}
|
|
@@ -239,7 +279,10 @@ begin
|
|
tkobject,
|
|
tkobject,
|
|
{$endif FPC_HAS_FEATURE_OBJECTS}
|
|
{$endif FPC_HAS_FEATURE_OBJECTS}
|
|
tkrecord :
|
|
tkrecord :
|
|
- recordrtti(data,typeinfo,@int_addref);
|
|
|
|
|
|
+ begin
|
|
|
|
+ typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
|
|
|
|
+ recordrtti(data,typeinfo,@int_addref);
|
|
|
|
+ end;
|
|
{$ifdef FPC_HAS_FEATURE_DYNARRAYS}
|
|
{$ifdef FPC_HAS_FEATURE_DYNARRAYS}
|
|
tkDynArray:
|
|
tkDynArray:
|
|
fpc_dynarray_incr_ref(PPointer(Data)^);
|
|
fpc_dynarray_incr_ref(PPointer(Data)^);
|
|
@@ -311,11 +354,12 @@ begin
|
|
{$endif FPC_HAS_FEATURE_OBJECTS}
|
|
{$endif FPC_HAS_FEATURE_OBJECTS}
|
|
tkrecord:
|
|
tkrecord:
|
|
begin
|
|
begin
|
|
|
|
+ typeInfo:=RTTIRecordRttiInfoToInitInfo(typeInfo);
|
|
Temp:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
|
|
Temp:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
|
|
|
|
|
|
- Result:=PRecordInfo(Temp)^.Size;
|
|
|
|
- Count:=PRecordInfo(Temp)^.Count;
|
|
|
|
- Inc(PRecordInfo(Temp));
|
|
|
|
|
|
+ Result:=PRecordInfoInit(Temp)^.Size;
|
|
|
|
+ Count:=PRecordInfoInit(Temp)^.Count;
|
|
|
|
+ Inc(PRecordInfoInit(Temp));
|
|
expectedoffset:=0;
|
|
expectedoffset:=0;
|
|
{ Process elements with rtti }
|
|
{ Process elements with rtti }
|
|
for i:=1 to count Do
|
|
for i:=1 to count Do
|