mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:26:24 +02:00
* move initialization of TValue to a separate method to avoid duplicate implementations
This commit is contained in:
parent
322d91758c
commit
f1059679a1
@ -110,6 +110,7 @@ type
|
|||||||
function GetTypeInfo: PTypeInfo; inline;
|
function GetTypeInfo: PTypeInfo; inline;
|
||||||
function GetTypeKind: TTypeKind; inline;
|
function GetTypeKind: TTypeKind; inline;
|
||||||
function GetIsEmpty: boolean; inline;
|
function GetIsEmpty: boolean; inline;
|
||||||
|
procedure Init; inline;
|
||||||
public
|
public
|
||||||
class function Empty: TValue; static;
|
class function Empty: TValue; static;
|
||||||
class procedure Make(ABuffer: pointer; ATypeInfo: PTypeInfo; out result: TValue); static;
|
class procedure Make(ABuffer: pointer; ATypeInfo: PTypeInfo; out result: TValue); static;
|
||||||
@ -1488,15 +1489,21 @@ end;
|
|||||||
|
|
||||||
{ TValue }
|
{ TValue }
|
||||||
|
|
||||||
|
procedure TValue.Init;
|
||||||
|
begin
|
||||||
|
{ resets the whole variant part; FValueData is already Nil }
|
||||||
|
{$if SizeOf(TMethod) > SizeOf(QWord)}
|
||||||
|
FData.FAsMethod.Code := Nil;
|
||||||
|
FData.FAsMethod.Data := Nil;
|
||||||
|
{$else}
|
||||||
|
FData.FAsUInt64 := 0;
|
||||||
|
{$endif}
|
||||||
|
end;
|
||||||
|
|
||||||
class function TValue.Empty: TValue;
|
class function TValue.Empty: TValue;
|
||||||
begin
|
begin
|
||||||
|
Result.Init;
|
||||||
result.FData.FTypeInfo := nil;
|
result.FData.FTypeInfo := nil;
|
||||||
{$if SizeOf(TMethod) > SizeOf(QWord)}
|
|
||||||
Result.FData.FAsMethod.Code := Nil;
|
|
||||||
Result.FData.FAsMethod.Data := Nil;
|
|
||||||
{$else}
|
|
||||||
Result.FData.FAsUInt64 := 0;
|
|
||||||
{$endif}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TValue.GetTypeDataProp: PTypeData;
|
function TValue.GetTypeDataProp: PTypeData;
|
||||||
@ -1605,14 +1612,8 @@ type
|
|||||||
var
|
var
|
||||||
td: PTypeData;
|
td: PTypeData;
|
||||||
begin
|
begin
|
||||||
|
result.Init;
|
||||||
result.FData.FTypeInfo:=ATypeInfo;
|
result.FData.FTypeInfo:=ATypeInfo;
|
||||||
{ resets the whole variant part; FValueData is already Nil }
|
|
||||||
{$if SizeOf(TMethod) > SizeOf(QWord)}
|
|
||||||
Result.FData.FAsMethod.Code := Nil;
|
|
||||||
Result.FData.FAsMethod.Data := Nil;
|
|
||||||
{$else}
|
|
||||||
Result.FData.FAsUInt64 := 0;
|
|
||||||
{$endif}
|
|
||||||
if not Assigned(ATypeInfo) then
|
if not Assigned(ATypeInfo) then
|
||||||
Exit;
|
Exit;
|
||||||
{ first handle those types that need a TValueData implementation }
|
{ first handle those types that need a TValueData implementation }
|
||||||
|
Loading…
Reference in New Issue
Block a user