* as the management operator feature is not platform specific using a specific define for it aside from a

version check is unnecessary, thus remove the FPC_HAS_MANAGEMENT_OPERATOR define and instead check for VER3_0

git-svn-id: trunk@39257 -
This commit is contained in:
svenbarth 2018-06-20 19:00:24 +00:00
parent 4d0ab82ef7
commit 8536abce8a
6 changed files with 49 additions and 54 deletions

View File

@ -3602,7 +3602,6 @@ procedure read_arguments(cmd:TCmdStr);
def_system_macro('FPC_HAS_INTERNAL_ABS_INT64'); def_system_macro('FPC_HAS_INTERNAL_ABS_INT64');
{$endif i8086 or i386 or x86_64 or powerpc64 or aarch64} {$endif i8086 or i386 or x86_64 or powerpc64 or aarch64}
def_system_macro('FPC_HAS_MANAGEMENT_OPERATORS');
def_system_macro('FPC_HAS_UNICODESTRING'); def_system_macro('FPC_HAS_UNICODESTRING');
def_system_macro('FPC_RTTI_PACKSET1'); def_system_macro('FPC_RTTI_PACKSET1');
def_system_macro('FPC_HAS_CPSTRING'); def_system_macro('FPC_HAS_CPSTRING');

View File

@ -193,11 +193,11 @@ procedure fpc_dynarray_setlength(var p : pointer;pti : pointer;
exit; exit;
getmem(newp,size); getmem(newp,size);
fillchar(newp^,size,0); fillchar(newp^,size,0);
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
{ call int_InitializeArray for management operators } { call int_InitializeArray for management operators }
if assigned(eletypemngd) and (PTypeKind(eletype)^ in [tkRecord, tkObject]) then if assigned(eletypemngd) and (PTypeKind(eletype)^ in [tkRecord, tkObject]) then
int_InitializeArray(pointer(newp)+sizeof(tdynarray), eletype, dims[0]); int_InitializeArray(pointer(newp)+sizeof(tdynarray), eletype, dims[0]);
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
updatep := true; updatep := true;
end end
else else
@ -270,12 +270,12 @@ procedure fpc_dynarray_setlength(var p : pointer;pti : pointer;
reallocmem(realp,size); reallocmem(realp,size);
fillchar((pointer(realp)+sizeof(tdynarray)+elesize*(realp^.high+1))^, fillchar((pointer(realp)+sizeof(tdynarray)+elesize*(realp^.high+1))^,
(dims[0]-realp^.high-1)*elesize,0); (dims[0]-realp^.high-1)*elesize,0);
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
{ call int_InitializeArray for management operators } { call int_InitializeArray for management operators }
if assigned(eletypemngd) and (PTypeKind(eletype)^ in [tkRecord, tkObject]) then if assigned(eletypemngd) and (PTypeKind(eletype)^ in [tkRecord, tkObject]) then
int_InitializeArray(pointer(realp)+sizeof(tdynarray)+elesize*(realp^.high+1), int_InitializeArray(pointer(realp)+sizeof(tdynarray)+elesize*(realp^.high+1),
eletype, dims[0]-realp^.high-1); eletype, dims[0]-realp^.high-1);
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
end; end;
newp := realp; newp := realp;
updatep := true; updatep := true;

View File

@ -379,12 +379,12 @@
class function TObject.InitInstance(instance : pointer) : tobject; {$ifdef SYSTEMINLINE} inline; {$ENDIF} class function TObject.InitInstance(instance : pointer) : tobject; {$ifdef SYSTEMINLINE} inline; {$ENDIF}
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
var var
vmt : PVmt; vmt : PVmt;
temp : pointer; temp : pointer;
flags : TRecordInfoInitFlags; flags : TRecordInfoInitFlags;
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
begin begin
{ the size is saved at offset 0 } { the size is saved at offset 0 }
fillchar(instance^, InstanceSize, 0); fillchar(instance^, InstanceSize, 0);
@ -394,7 +394,7 @@
if {$ifdef VER3_0}PVmt(self)^.vIntfTable <> @emptyintf{$else}assigned(PVmt(self)^.vIntfTable){$endif} then if {$ifdef VER3_0}PVmt(self)^.vIntfTable <> @emptyintf{$else}assigned(PVmt(self)^.vIntfTable){$endif} then
InitInterfacePointers(self,instance); InitInterfacePointers(self,instance);
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
{ for management operators like initialize call int_initialize } { for management operators like initialize call int_initialize }
vmt := PVmt(self); vmt := PVmt(self);
while vmt<>nil do while vmt<>nil do
@ -415,7 +415,7 @@
end; end;
vmt:= vmt^.vParent; vmt:= vmt^.vParent;
end; end;
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
InitInstance:=TObject(Instance); InitInstance:=TObject(Instance);
end; end;

View File

@ -39,7 +39,7 @@ begin
result:=PRecordInfoFull(typeInfo)^.Size; result:=PRecordInfoFull(typeInfo)^.Size;
end; end;
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
function RTTIRecordOp(typeInfo: Pointer; var initrtti: Pointer): PRecordInfoInit; inline; function RTTIRecordOp(typeInfo: Pointer; var initrtti: Pointer): PRecordInfoInit; inline;
begin begin
{ find init table and management operators } { find init table and management operators }
@ -55,7 +55,7 @@ begin
result:=aligntoqword(initrtti+2+PByte(initrtti)[1]); result:=aligntoqword(initrtti+2+PByte(initrtti)[1]);
end end
end; end;
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
function RTTIRecordRttiInfoToInitInfo(typeInfo: Pointer): Pointer; inline; function RTTIRecordRttiInfoToInitInfo(typeInfo: Pointer): Pointer; inline;
begin begin
result:=typeInfo; result:=typeInfo;
@ -69,17 +69,17 @@ begin
result:=PRecordInfoFull(typeInfo)^.InitTable; result:=PRecordInfoFull(typeInfo)^.InitTable;
{$endif VER3_0} {$endif VER3_0}
end; end;
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
function RTTISizeAndOp(typeInfo: Pointer; function RTTISizeAndOp(typeInfo: Pointer;
const expectedManagementOp: TRTTIRecOpType; out hasManagementOp: boolean): SizeInt; const expectedManagementOp: TRTTIRecOpType; out hasManagementOp: boolean): SizeInt;
begin begin
hasManagementOp:=false; hasManagementOp:=false;
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
function RTTISize(typeInfo: Pointer): SizeInt; function RTTISize(typeInfo: Pointer): SizeInt;
begin begin
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
case PTypeKind(typeinfo)^ of case PTypeKind(typeinfo)^ of
tkAString,tkWString,tkUString, tkAString,tkWString,tkUString,
tkInterface,tkDynarray: tkInterface,tkDynarray:
@ -90,7 +90,7 @@ begin
{$endif FPC_HAS_FEATURE_VARIANTS} {$endif FPC_HAS_FEATURE_VARIANTS}
tkArray: tkArray:
result:=RTTIArraySize(typeinfo); result:=RTTIArraySize(typeinfo);
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
tkObject: tkObject:
result:=RTTIRecordSize(typeinfo); result:=RTTIRecordSize(typeinfo);
tkRecord: tkRecord:
@ -106,10 +106,10 @@ begin
rotCopy: hasManagementOp:=Assigned(RecordOp^.Copy); rotCopy: hasManagementOp:=Assigned(RecordOp^.Copy);
end; end;
end; end;
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
tkObject,tkRecord: tkObject,tkRecord:
result:=RTTIRecordSize(typeinfo); result:=RTTIRecordSize(typeinfo);
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
else else
result:=-1; result:=-1;
end; end;
@ -204,7 +204,7 @@ begin
tkObject, tkObject,
{$endif FPC_HAS_FEATURE_OBJECTS} {$endif FPC_HAS_FEATURE_OBJECTS}
tkRecord: tkRecord:
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
{ if possible try to use more optimal initrtti } { if possible try to use more optimal initrtti }
with RTTIRecordOp(typeinfo, typeinfo)^ do with RTTIRecordOp(typeinfo, typeinfo)^ do
begin begin
@ -212,12 +212,12 @@ begin
if Assigned(recordop) and Assigned(recordop^.Initialize) then if Assigned(recordop) and Assigned(recordop^.Initialize) then
recordop^.Initialize(data); recordop^.Initialize(data);
end; end;
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
begin begin
typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo); typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
recordrtti(data,typeinfo,@int_initialize); recordrtti(data,typeinfo,@int_initialize);
end; end;
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
{$ifdef FPC_HAS_FEATURE_VARIANTS} {$ifdef FPC_HAS_FEATURE_VARIANTS}
tkVariant: tkVariant:
variant_init(PVarData(Data)^); variant_init(PVarData(Data)^);
@ -247,7 +247,7 @@ begin
tkObject, tkObject,
{$endif FPC_HAS_FEATURE_OBJECTS} {$endif FPC_HAS_FEATURE_OBJECTS}
tkRecord: tkRecord:
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
{ if possible try to use more optimal initrtti } { if possible try to use more optimal initrtti }
with RTTIRecordOp(typeinfo, typeinfo)^ do with RTTIRecordOp(typeinfo, typeinfo)^ do
begin begin
@ -255,12 +255,12 @@ begin
recordop^.Finalize(data); recordop^.Finalize(data);
recordrtti(data,typeinfo,@int_finalize); recordrtti(data,typeinfo,@int_finalize);
end; end;
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
begin begin
typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo); typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
recordrtti(data,typeinfo,@int_finalize); recordrtti(data,typeinfo,@int_finalize);
end; end;
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
tkInterface: tkInterface:
Intf_Decr_Ref(PPointer(Data)^); Intf_Decr_Ref(PPointer(Data)^);
{$ifdef FPC_HAS_FEATURE_DYNARRAYS} {$ifdef FPC_HAS_FEATURE_DYNARRAYS}
@ -296,7 +296,7 @@ begin
tkobject, tkobject,
{$endif FPC_HAS_FEATURE_OBJECTS} {$endif FPC_HAS_FEATURE_OBJECTS}
tkrecord : tkrecord :
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
{ find init table } { find init table }
with RTTIRecordOp(typeinfo, typeinfo)^ do with RTTIRecordOp(typeinfo, typeinfo)^ do
begin begin
@ -304,12 +304,12 @@ begin
if Assigned(recordop) and Assigned(recordop^.AddRef) then if Assigned(recordop) and Assigned(recordop^.AddRef) then
recordop^.AddRef(Data); recordop^.AddRef(Data);
end; end;
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
begin begin
typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo); typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
recordrtti(data,typeinfo,@int_addref); recordrtti(data,typeinfo,@int_addref);
end; end;
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
{$ifdef FPC_HAS_FEATURE_DYNARRAYS} {$ifdef FPC_HAS_FEATURE_DYNARRAYS}
tkDynArray: tkDynArray:
fpc_dynarray_incr_ref(PPointer(Data)^); fpc_dynarray_incr_ref(PPointer(Data)^);
@ -384,31 +384,29 @@ begin
tkobject, tkobject,
{$endif FPC_HAS_FEATURE_OBJECTS} {$endif FPC_HAS_FEATURE_OBJECTS}
tkrecord: tkrecord:
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
{ find init table } { find init table }
with RTTIRecordOp(typeinfo, typeinfo)^ do with RTTIRecordOp(typeinfo, typeinfo)^ do
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
begin begin
{$ifndef FPC_HAS_MANAGEMENT_OPERATORS}
typeInfo:=RTTIRecordRttiInfoToInitInfo(typeInfo);
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
{$ifdef VER3_0} {$ifdef VER3_0}
typeInfo:=RTTIRecordRttiInfoToInitInfo(typeInfo);
Temp:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]); Temp:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
{$else VER3_0} {$else VER3_0}
Temp:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]); Temp:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]);
{$endif VER3_0} {$endif VER3_0}
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
if Assigned(recordop) and Assigned(recordop^.Copy) then if Assigned(recordop) and Assigned(recordop^.Copy) then
recordop^.Copy(Src,Dest) recordop^.Copy(Src,Dest)
else else
begin begin
Result:=Size; Result:=Size;
Inc(PRecordInfoInit(Temp)); Inc(PRecordInfoInit(Temp));
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
Result:=PRecordInfoFull(Temp)^.Size; Result:=PRecordInfoFull(Temp)^.Size;
Count:=PRecordInfoFull(Temp)^.Count; Count:=PRecordInfoFull(Temp)^.Count;
Inc(PRecordInfoFull(Temp)); Inc(PRecordInfoFull(Temp));
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
expectedoffset:=0; expectedoffset:=0;
{ Process elements with rtti } { Process elements with rtti }
for i:=1 to Count Do for i:=1 to Count Do
@ -424,9 +422,9 @@ begin
{ elements remaining? } { elements remaining? }
if result>expectedoffset then if result>expectedoffset then
move((Src+expectedoffset)^,(Dest+expectedoffset)^,Result-expectedoffset); move((Src+expectedoffset)^,(Dest+expectedoffset)^,Result-expectedoffset);
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
end; end;
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
end; end;
{$ifdef FPC_HAS_FEATURE_DYNARRAYS} {$ifdef FPC_HAS_FEATURE_DYNARRAYS}
tkDynArray: tkDynArray:
@ -457,16 +455,16 @@ end;
procedure fpc_initialize_array(data,typeinfo : pointer;count : SizeInt); [public,alias:'FPC_INITIALIZE_ARRAY']; compilerproc; procedure fpc_initialize_array(data,typeinfo : pointer;count : SizeInt); [public,alias:'FPC_INITIALIZE_ARRAY']; compilerproc;
var var
i, size : SizeInt; i, size : SizeInt;
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
hasManagementOp: boolean; hasManagementOp: boolean;
begin begin
size:=RTTISizeAndOp(typeinfo, rotInitialize, hasManagementOp); size:=RTTISizeAndOp(typeinfo, rotInitialize, hasManagementOp);
if (size>0) or hasManagementOp then if (size>0) or hasManagementOp then
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
begin begin
size:=RTTISize(typeInfo); size:=RTTISize(typeInfo);
if size>0 then if size>0 then
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
for i:=0 to count-1 do for i:=0 to count-1 do
int_initialize(data+size*i,typeinfo); int_initialize(data+size*i,typeinfo);
end; end;
@ -475,16 +473,16 @@ procedure fpc_initialize_array(data,typeinfo : pointer;count : SizeInt); [public
procedure fpc_finalize_array(data,typeinfo : pointer;count : SizeInt); [Public,Alias:'FPC_FINALIZE_ARRAY']; compilerproc; procedure fpc_finalize_array(data,typeinfo : pointer;count : SizeInt); [Public,Alias:'FPC_FINALIZE_ARRAY']; compilerproc;
var var
i, size: SizeInt; i, size: SizeInt;
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
hasManagementOp: boolean; hasManagementOp: boolean;
begin begin
size:=RTTISizeAndOp(typeinfo, rotFinalize, hasManagementOp); size:=RTTISizeAndOp(typeinfo, rotFinalize, hasManagementOp);
if (size>0) or hasManagementOp then if (size>0) or hasManagementOp then
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
begin begin
size:=RTTISize(typeInfo); size:=RTTISize(typeInfo);
if size>0 then if size>0 then
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
for i:=0 to count-1 do for i:=0 to count-1 do
int_finalize(data+size*i,typeinfo); int_finalize(data+size*i,typeinfo);
end; end;
@ -493,16 +491,16 @@ procedure fpc_finalize_array(data,typeinfo : pointer;count : SizeInt); [Public,A
procedure fpc_addref_array(data,typeinfo: pointer; count: SizeInt); [public,alias:'FPC_ADDREF_ARRAY']; compilerproc; procedure fpc_addref_array(data,typeinfo: pointer; count: SizeInt); [public,alias:'FPC_ADDREF_ARRAY']; compilerproc;
var var
i, size: SizeInt; i, size: SizeInt;
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
hasManagementOp: boolean; hasManagementOp: boolean;
begin begin
size:=RTTISizeAndOp(typeinfo, rotAddRef, hasManagementOp); size:=RTTISizeAndOp(typeinfo, rotAddRef, hasManagementOp);
if (size>0) or hasManagementOp then if (size>0) or hasManagementOp then
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
begin begin
size:=RTTISize(typeInfo); size:=RTTISize(typeInfo);
if size>0 then if size>0 then
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
for i:=0 to count-1 do for i:=0 to count-1 do
int_addref(data+size*i,typeinfo); int_addref(data+size*i,typeinfo);
end; end;
@ -527,16 +525,16 @@ procedure FinalizeArray(p, typeInfo: Pointer; count: SizeInt);
procedure CopyArray(dest, source, typeInfo: Pointer; count: SizeInt); procedure CopyArray(dest, source, typeInfo: Pointer; count: SizeInt);
var var
i, size: SizeInt; i, size: SizeInt;
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
hasManagementOp: boolean; hasManagementOp: boolean;
begin begin
size:=RTTISizeAndOp(typeinfo, rotCopy, hasManagementOp); size:=RTTISizeAndOp(typeinfo, rotCopy, hasManagementOp);
if (size>0) or hasManagementOp then if (size>0) or hasManagementOp then
{$else FPC_HAS_MANAGEMENT_OPERATORS} {$else VER3_0}
begin begin
size:=RTTISize(typeInfo); size:=RTTISize(typeInfo);
if size>0 then if size>0 then
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
for i:=0 to count-1 do for i:=0 to count-1 do
fpc_Copy_internal(source+size*i, dest+size*i, typeInfo); fpc_Copy_internal(source+size*i, dest+size*i, typeInfo);
end; end;

View File

@ -77,7 +77,6 @@ type
PRecordInfoInit=^TRecordInfoInit; PRecordInfoInit=^TRecordInfoInit;
{$ifndef VER3_0} {$ifndef VER3_0}
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
TRTTIRecVarOp=procedure(ARec: Pointer); TRTTIRecVarOp=procedure(ARec: Pointer);
TRTTIRecCopyOp=procedure(ASrc, ADest: Pointer); TRTTIRecCopyOp=procedure(ASrc, ADest: Pointer);
TRTTIRecOpType=(rotAny, rotInitialize, rotFinalize, rotAddRef, rotCopy); TRTTIRecOpType=(rotAny, rotInitialize, rotFinalize, rotAddRef, rotCopy);
@ -92,7 +91,6 @@ type
AddRef: TRTTIRecVarOp; AddRef: TRTTIRecVarOp;
Copy: TRTTIRecCopyOp; Copy: TRTTIRecCopyOp;
end; end;
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
{$ifndef VER3_0} {$ifndef VER3_0}
{$push} {$push}
@ -120,10 +118,10 @@ type
record record
Terminator: Pointer; Terminator: Pointer;
Size: Longint; Size: Longint;
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
Flags: TRecordInfoInitFlags; Flags: TRecordInfoInitFlags;
RecordOp: PRTTIRecordOpVMT; RecordOp: PRTTIRecordOpVMT;
{$endif FPC_HAS_MANAGEMENT_OPERATORS} {$endif VER3_0}
Count: Longint; Count: Longint;
{ Elements: array[count] of TRecordElement } { Elements: array[count] of TRecordElement }
end; end;

View File

@ -436,7 +436,7 @@ unit TypInfo;
record record
Terminator: Pointer; Terminator: Pointer;
Size: Integer; Size: Integer;
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS} {$ifndef VER3_0}
Flags: TRecordInfoInitFlags; Flags: TRecordInfoInitFlags;
ManagementOp: Pointer; ManagementOp: Pointer;
{$endif} {$endif}