Skip to content
Permalink
Browse files

try to fix FPC 3.0.4 branch compilation

  • Loading branch information...
Arnaud Bouchez
Arnaud Bouchez committed Sep 3, 2019
1 parent 0056ace commit 0418c5be8f4bb1cd5e4cd98aae76c277f1ce53fd
Showing with 37 additions and 27 deletions.
  1. +4 −4 SynCommons.pas
  2. +32 −22 SynFPCTypInfo.pas
  3. +1 −1 SynopseCommit.inc
if aValueLen<>0 then
for result := 0 to MaxValue do begin
PLen := ord(List^[0]);
if (PLen=aValuelen) and IdemPropNameUSameLen(@List^[1],aValue,aValueLen) then
if (PLen=aValuelen) and IdemPropNameUSameLen(@List^[1],aValue,PLen) then
exit;
inc(PByte(List),PLen+1); // next short string
end;
source := VariantLoad(PVariant(data)^,source,@JSON_OPTIONS[true]);
result := SizeOf(Variant); // size of tkVariant in record
end;
{$endif}
{$endif NOVARIANTS}
tkDynArray: begin
DynArray.Init(info,data^);
source := DynArray.LoadFrom(source);
inc(source,SizeOf(Int64)); // consume 64-bit even on CPU32
result := SizeOf(PtrUInt);
end;
{$endif}
{$endif DELPHI5OROLDER}
else begin
source := nil;
result := 0;
begin
firstfield := @info^.ManagedFields[0];
result := info^.ManagedCount;
{$endif}
{$endif FPC_NEWRTTI}
end;

function RecordEquals(const RecA, RecB; TypeInfo: pointer;
@@ -65,16 +65,17 @@ interface
ptConst = 3;

{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
function AlignToPtr(p : pointer): pointer; inline;
function GetFPCAlignPtr(P: pointer): pointer; inline;
function AlignToPtr(p: pointer): pointer; inline;
function GetFPCAlignPtr(p: pointer): pointer; inline;
function AlignTypeData(p : Pointer): pointer; inline;
{$else FPC_REQUIRES_PROPER_ALIGNMENT}
type
AlignToPtr = pointer;
AlignTypeData = pointer;
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}

function GetFPCEnumName(TypeInfo: PTypeInfo; Value: Integer): PShortString; inline;
function GetFPCEnumValue(TypeInfo: PTypeInfo; const Name: string): Integer; inline;
function AlignTypeData(p : Pointer) : Pointer; inline;
function GetFPCTypeData(TypeInfo: PTypeInfo): PTypeData; inline;
function GetFPCPropInfo(AClass: TClass; const PropName: string): PPropInfo; inline;

@@ -107,16 +108,39 @@ procedure FPCRecordAddRef(var Data; TypeInfo : pointer);
[external name 'FPC_ADDREF'];


{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT} // copied from latest typinfo.pp
function AlignToPtr(p : pointer): pointer; inline;
begin
result := align(p,sizeof(p));
end;
{$endif}

function AlignTypeData(p: pointer): pointer;
{$packrecords c}
type
TAlignCheck = record
b : byte;
q : qword;
end;
{$packrecords default}
begin
{$ifdef VER3_0}
result := Pointer(align(p,SizeOf(Pointer)));
{$else VER3_0}
result := Pointer(align(p,PtrInt(@TAlignCheck(nil^).q)))
{$endif VER3_0}
end;

function GetFPCAlignPtr(P: pointer): pointer;
begin
result := AlignTypeData(P+2+Length(PTypeInfo(P)^.Name));
Dec(PtrUInt(result),2*SizeOf(pointer));
end;
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}

function GetFPCTypeData(TypeInfo: PTypeInfo): PTypeData;
begin
result := PTypeData(TypInfo.AlignTypeData(PTypeData(pointer(TypeInfo)+2+PByte(pointer(TypeInfo)+1)^)));
result := PTypeData({$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}AlignTypeData{$endif}
(PTypeData(pointer(TypeInfo)+2+PByte(pointer(TypeInfo)+1)^)));
end;

function GetFPCEnumValue(TypeInfo: PTypeInfo; const Name: string): Integer;
@@ -170,19 +194,6 @@ function GetFPCEnumName(TypeInfo: PTypeInfo; Value: Integer): PShortString;
end;
end;

function AlignTypeData(p: Pointer): Pointer;
begin
result := TypInfo.AlignTypeData(p);
end;

{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
function GetFPCAlignPtr(P: pointer): pointer;
begin
result := TypInfo.AlignTypeData(P+2+Length(PTypeInfo(P)^.Name));
Dec(PtrUInt(result),2*SizeOf(pointer));
end;
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}

function GetFPCPropInfo(AClass: TClass; const PropName: string): PPropInfo;
begin
result := typinfo.GetPropInfo(AClass,PropName);
@@ -192,9 +203,8 @@ function GetFPCPropInfo(AClass: TClass; const PropName: string): PPropInfo;
function GetFPCRecInitData(TypeData: Pointer): Pointer;
begin
if PTypeData(TypeData)^.RecInitInfo = nil then
result := TypeData
else
result := TypInfo.AlignTypeData(pointer(PTypeData(TypeData)^.RecInitData));
result := TypeData else
result := AlignTypeData(pointer(PTypeData(TypeData)^.RecInitData));
end;
{$endif FPC_NEWRTTI}

@@ -1 +1 @@
'1.18.5320'
'1.18.5321'

0 comments on commit 0418c5b

Please sign in to comment.
You can’t perform that action at this time.