mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 06:29:32 +02:00
* 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:
parent
4d0ab82ef7
commit
8536abce8a
@ -3602,7 +3602,6 @@ procedure read_arguments(cmd:TCmdStr);
|
||||
def_system_macro('FPC_HAS_INTERNAL_ABS_INT64');
|
||||
{$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_RTTI_PACKSET1');
|
||||
def_system_macro('FPC_HAS_CPSTRING');
|
||||
|
@ -193,11 +193,11 @@ procedure fpc_dynarray_setlength(var p : pointer;pti : pointer;
|
||||
exit;
|
||||
getmem(newp,size);
|
||||
fillchar(newp^,size,0);
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
{ call int_InitializeArray for management operators }
|
||||
if assigned(eletypemngd) and (PTypeKind(eletype)^ in [tkRecord, tkObject]) then
|
||||
int_InitializeArray(pointer(newp)+sizeof(tdynarray), eletype, dims[0]);
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
updatep := true;
|
||||
end
|
||||
else
|
||||
@ -270,12 +270,12 @@ procedure fpc_dynarray_setlength(var p : pointer;pti : pointer;
|
||||
reallocmem(realp,size);
|
||||
fillchar((pointer(realp)+sizeof(tdynarray)+elesize*(realp^.high+1))^,
|
||||
(dims[0]-realp^.high-1)*elesize,0);
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
{ call int_InitializeArray for management operators }
|
||||
if assigned(eletypemngd) and (PTypeKind(eletype)^ in [tkRecord, tkObject]) then
|
||||
int_InitializeArray(pointer(realp)+sizeof(tdynarray)+elesize*(realp^.high+1),
|
||||
eletype, dims[0]-realp^.high-1);
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
end;
|
||||
newp := realp;
|
||||
updatep := true;
|
||||
|
@ -379,12 +379,12 @@
|
||||
|
||||
class function TObject.InitInstance(instance : pointer) : tobject; {$ifdef SYSTEMINLINE} inline; {$ENDIF}
|
||||
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
var
|
||||
vmt : PVmt;
|
||||
temp : pointer;
|
||||
flags : TRecordInfoInitFlags;
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
begin
|
||||
{ the size is saved at offset 0 }
|
||||
fillchar(instance^, InstanceSize, 0);
|
||||
@ -394,7 +394,7 @@
|
||||
if {$ifdef VER3_0}PVmt(self)^.vIntfTable <> @emptyintf{$else}assigned(PVmt(self)^.vIntfTable){$endif} then
|
||||
InitInterfacePointers(self,instance);
|
||||
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
{ for management operators like initialize call int_initialize }
|
||||
vmt := PVmt(self);
|
||||
while vmt<>nil do
|
||||
@ -415,7 +415,7 @@
|
||||
end;
|
||||
vmt:= vmt^.vParent;
|
||||
end;
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
|
||||
InitInstance:=TObject(Instance);
|
||||
end;
|
||||
|
@ -39,7 +39,7 @@ begin
|
||||
result:=PRecordInfoFull(typeInfo)^.Size;
|
||||
end;
|
||||
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
function RTTIRecordOp(typeInfo: Pointer; var initrtti: Pointer): PRecordInfoInit; inline;
|
||||
begin
|
||||
{ find init table and management operators }
|
||||
@ -55,7 +55,7 @@ begin
|
||||
result:=aligntoqword(initrtti+2+PByte(initrtti)[1]);
|
||||
end
|
||||
end;
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
function RTTIRecordRttiInfoToInitInfo(typeInfo: Pointer): Pointer; inline;
|
||||
begin
|
||||
result:=typeInfo;
|
||||
@ -69,17 +69,17 @@ begin
|
||||
result:=PRecordInfoFull(typeInfo)^.InitTable;
|
||||
{$endif VER3_0}
|
||||
end;
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
function RTTISizeAndOp(typeInfo: Pointer;
|
||||
const expectedManagementOp: TRTTIRecOpType; out hasManagementOp: boolean): SizeInt;
|
||||
begin
|
||||
hasManagementOp:=false;
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
function RTTISize(typeInfo: Pointer): SizeInt;
|
||||
begin
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
case PTypeKind(typeinfo)^ of
|
||||
tkAString,tkWString,tkUString,
|
||||
tkInterface,tkDynarray:
|
||||
@ -90,7 +90,7 @@ begin
|
||||
{$endif FPC_HAS_FEATURE_VARIANTS}
|
||||
tkArray:
|
||||
result:=RTTIArraySize(typeinfo);
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
tkObject:
|
||||
result:=RTTIRecordSize(typeinfo);
|
||||
tkRecord:
|
||||
@ -106,10 +106,10 @@ begin
|
||||
rotCopy: hasManagementOp:=Assigned(RecordOp^.Copy);
|
||||
end;
|
||||
end;
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
tkObject,tkRecord:
|
||||
result:=RTTIRecordSize(typeinfo);
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
else
|
||||
result:=-1;
|
||||
end;
|
||||
@ -204,7 +204,7 @@ begin
|
||||
tkObject,
|
||||
{$endif FPC_HAS_FEATURE_OBJECTS}
|
||||
tkRecord:
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
{ if possible try to use more optimal initrtti }
|
||||
with RTTIRecordOp(typeinfo, typeinfo)^ do
|
||||
begin
|
||||
@ -212,12 +212,12 @@ begin
|
||||
if Assigned(recordop) and Assigned(recordop^.Initialize) then
|
||||
recordop^.Initialize(data);
|
||||
end;
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
begin
|
||||
typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
|
||||
recordrtti(data,typeinfo,@int_initialize);
|
||||
end;
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
{$ifdef FPC_HAS_FEATURE_VARIANTS}
|
||||
tkVariant:
|
||||
variant_init(PVarData(Data)^);
|
||||
@ -247,7 +247,7 @@ begin
|
||||
tkObject,
|
||||
{$endif FPC_HAS_FEATURE_OBJECTS}
|
||||
tkRecord:
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
{ if possible try to use more optimal initrtti }
|
||||
with RTTIRecordOp(typeinfo, typeinfo)^ do
|
||||
begin
|
||||
@ -255,12 +255,12 @@ begin
|
||||
recordop^.Finalize(data);
|
||||
recordrtti(data,typeinfo,@int_finalize);
|
||||
end;
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
begin
|
||||
typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
|
||||
recordrtti(data,typeinfo,@int_finalize);
|
||||
end;
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
tkInterface:
|
||||
Intf_Decr_Ref(PPointer(Data)^);
|
||||
{$ifdef FPC_HAS_FEATURE_DYNARRAYS}
|
||||
@ -296,7 +296,7 @@ begin
|
||||
tkobject,
|
||||
{$endif FPC_HAS_FEATURE_OBJECTS}
|
||||
tkrecord :
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
{ find init table }
|
||||
with RTTIRecordOp(typeinfo, typeinfo)^ do
|
||||
begin
|
||||
@ -304,12 +304,12 @@ begin
|
||||
if Assigned(recordop) and Assigned(recordop^.AddRef) then
|
||||
recordop^.AddRef(Data);
|
||||
end;
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
begin
|
||||
typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
|
||||
recordrtti(data,typeinfo,@int_addref);
|
||||
end;
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
{$ifdef FPC_HAS_FEATURE_DYNARRAYS}
|
||||
tkDynArray:
|
||||
fpc_dynarray_incr_ref(PPointer(Data)^);
|
||||
@ -384,31 +384,29 @@ begin
|
||||
tkobject,
|
||||
{$endif FPC_HAS_FEATURE_OBJECTS}
|
||||
tkrecord:
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
{ find init table }
|
||||
with RTTIRecordOp(typeinfo, typeinfo)^ do
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
begin
|
||||
{$ifndef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
typeInfo:=RTTIRecordRttiInfoToInitInfo(typeInfo);
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifdef VER3_0}
|
||||
typeInfo:=RTTIRecordRttiInfoToInitInfo(typeInfo);
|
||||
Temp:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
|
||||
{$else VER3_0}
|
||||
Temp:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]);
|
||||
{$endif VER3_0}
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
if Assigned(recordop) and Assigned(recordop^.Copy) then
|
||||
recordop^.Copy(Src,Dest)
|
||||
else
|
||||
begin
|
||||
Result:=Size;
|
||||
Inc(PRecordInfoInit(Temp));
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
Result:=PRecordInfoFull(Temp)^.Size;
|
||||
Count:=PRecordInfoFull(Temp)^.Count;
|
||||
Inc(PRecordInfoFull(Temp));
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
expectedoffset:=0;
|
||||
{ Process elements with rtti }
|
||||
for i:=1 to Count Do
|
||||
@ -424,9 +422,9 @@ begin
|
||||
{ elements remaining? }
|
||||
if result>expectedoffset then
|
||||
move((Src+expectedoffset)^,(Dest+expectedoffset)^,Result-expectedoffset);
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
end;
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
end;
|
||||
{$ifdef FPC_HAS_FEATURE_DYNARRAYS}
|
||||
tkDynArray:
|
||||
@ -457,16 +455,16 @@ end;
|
||||
procedure fpc_initialize_array(data,typeinfo : pointer;count : SizeInt); [public,alias:'FPC_INITIALIZE_ARRAY']; compilerproc;
|
||||
var
|
||||
i, size : SizeInt;
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
hasManagementOp: boolean;
|
||||
begin
|
||||
size:=RTTISizeAndOp(typeinfo, rotInitialize, hasManagementOp);
|
||||
if (size>0) or hasManagementOp then
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
begin
|
||||
size:=RTTISize(typeInfo);
|
||||
if size>0 then
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
for i:=0 to count-1 do
|
||||
int_initialize(data+size*i,typeinfo);
|
||||
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;
|
||||
var
|
||||
i, size: SizeInt;
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
hasManagementOp: boolean;
|
||||
begin
|
||||
size:=RTTISizeAndOp(typeinfo, rotFinalize, hasManagementOp);
|
||||
if (size>0) or hasManagementOp then
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
begin
|
||||
size:=RTTISize(typeInfo);
|
||||
if size>0 then
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
for i:=0 to count-1 do
|
||||
int_finalize(data+size*i,typeinfo);
|
||||
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;
|
||||
var
|
||||
i, size: SizeInt;
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
hasManagementOp: boolean;
|
||||
begin
|
||||
size:=RTTISizeAndOp(typeinfo, rotAddRef, hasManagementOp);
|
||||
if (size>0) or hasManagementOp then
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
begin
|
||||
size:=RTTISize(typeInfo);
|
||||
if size>0 then
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
for i:=0 to count-1 do
|
||||
int_addref(data+size*i,typeinfo);
|
||||
end;
|
||||
@ -527,16 +525,16 @@ procedure FinalizeArray(p, typeInfo: Pointer; count: SizeInt);
|
||||
procedure CopyArray(dest, source, typeInfo: Pointer; count: SizeInt);
|
||||
var
|
||||
i, size: SizeInt;
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
hasManagementOp: boolean;
|
||||
begin
|
||||
size:=RTTISizeAndOp(typeinfo, rotCopy, hasManagementOp);
|
||||
if (size>0) or hasManagementOp then
|
||||
{$else FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$else VER3_0}
|
||||
begin
|
||||
size:=RTTISize(typeInfo);
|
||||
if size>0 then
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
for i:=0 to count-1 do
|
||||
fpc_Copy_internal(source+size*i, dest+size*i, typeInfo);
|
||||
end;
|
||||
|
@ -77,7 +77,6 @@ type
|
||||
|
||||
PRecordInfoInit=^TRecordInfoInit;
|
||||
{$ifndef VER3_0}
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
TRTTIRecVarOp=procedure(ARec: Pointer);
|
||||
TRTTIRecCopyOp=procedure(ASrc, ADest: Pointer);
|
||||
TRTTIRecOpType=(rotAny, rotInitialize, rotFinalize, rotAddRef, rotCopy);
|
||||
@ -92,7 +91,6 @@ type
|
||||
AddRef: TRTTIRecVarOp;
|
||||
Copy: TRTTIRecCopyOp;
|
||||
end;
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
|
||||
{$ifndef VER3_0}
|
||||
{$push}
|
||||
@ -120,10 +118,10 @@ type
|
||||
record
|
||||
Terminator: Pointer;
|
||||
Size: Longint;
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
Flags: TRecordInfoInitFlags;
|
||||
RecordOp: PRTTIRecordOpVMT;
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$endif VER3_0}
|
||||
Count: Longint;
|
||||
{ Elements: array[count] of TRecordElement }
|
||||
end;
|
||||
|
@ -436,7 +436,7 @@ unit TypInfo;
|
||||
record
|
||||
Terminator: Pointer;
|
||||
Size: Integer;
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{$ifndef VER3_0}
|
||||
Flags: TRecordInfoInitFlags;
|
||||
ManagementOp: Pointer;
|
||||
{$endif}
|
||||
|
Loading…
Reference in New Issue
Block a user