|
@@ -249,11 +249,17 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+{ define alias for internal use in the system unit }
|
|
|
+Function fpc_Copy_internal (Src, Dest, TypeInfo : Pointer; DoMove : Boolean) : SizeInt;[external name 'FPC_COPY'];
|
|
|
|
|
|
+Function fpc_Copy (Src, Dest, TypeInfo : Pointer; DoMove : Boolean) : SizeInt;[Public,alias : 'FPC_COPY']; compilerproc;
|
|
|
+{$else}
|
|
|
{ define alias for internal use in the system unit }
|
|
|
Function fpc_Copy_internal (Src, Dest, TypeInfo : Pointer) : SizeInt;[external name 'FPC_COPY'];
|
|
|
|
|
|
Function fpc_Copy (Src, Dest, TypeInfo : Pointer) : SizeInt;[Public,alias : 'FPC_COPY']; compilerproc;
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
var
|
|
|
copiedsize,
|
|
|
expectedoffset,
|
|
@@ -267,14 +273,41 @@ begin
|
|
|
case PTypeKind(TypeInfo)^ of
|
|
|
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
|
|
|
tkAstring:
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+ if domove then
|
|
|
+ begin
|
|
|
+ fpc_AnsiStr_Decr_Ref(PPointer(Dest)^);
|
|
|
+ PPointer(Dest)^:=PPointer(src)^;
|
|
|
+ PPointer(Src)^:=nil;
|
|
|
+ end
|
|
|
+ else
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
fpc_AnsiStr_Assign(PPointer(Dest)^,PPointer(Src)^);
|
|
|
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
|
|
|
{$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
|
|
|
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
|
|
|
tkWstring:
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+ if domove then
|
|
|
+ begin
|
|
|
+ fpc_WideStr_Decr_Ref(PPointer(Dest)^);
|
|
|
+ PPointer(Dest)^:=PPointer(src)^;
|
|
|
+ PPointer(Src)^:=nil;
|
|
|
+ end
|
|
|
+ else
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
fpc_WideStr_Assign(PPointer(Dest)^,PPointer(Src)^);
|
|
|
{$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
|
|
|
tkUstring:
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+ if domove then
|
|
|
+ begin
|
|
|
+ fpc_UnicodeStr_Decr_Ref(PPointer(Dest)^);
|
|
|
+ PPointer(Dest)^:=PPointer(src)^;
|
|
|
+ PPointer(Src)^:=nil;
|
|
|
+ end
|
|
|
+ else
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
fpc_UnicodeStr_Assign(PPointer(Dest)^,PPointer(Src)^);
|
|
|
{$endif FPC_HAS_FEATURE_WIDESTRINGS}
|
|
|
tkArray:
|
|
@@ -291,7 +324,11 @@ begin
|
|
|
{ Process elements }
|
|
|
for I:=1 to EleCount do
|
|
|
begin
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+ fpc_Copy_internal(Src+Offset,Dest+Offset,Info,DoMove);
|
|
|
+{$else}
|
|
|
fpc_Copy_internal(Src+Offset,Dest+Offset,Info);
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
inc(Offset,copiedsize);
|
|
|
end;
|
|
|
end;
|
|
@@ -302,6 +339,15 @@ begin
|
|
|
begin
|
|
|
Temp:=RTTIRecordInfoInit(typeinfo);
|
|
|
Result:=PRecordInfoInit(Temp)^.Size;
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+ if domove then
|
|
|
+ begin
|
|
|
+ int_finalize(Dest,TypeInfo);
|
|
|
+ move(src^,dest^,result);
|
|
|
+ int_initialize(Src,TypeInfo);
|
|
|
+ end
|
|
|
+ else
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
if Assigned(PRecordInfoInit(Temp)^.recordop) and Assigned(PRecordInfoInit(Temp)^.recordop^.Copy) then
|
|
|
PRecordInfoInit(Temp)^.recordop^.Copy(Src,Dest)
|
|
|
else
|
|
@@ -316,7 +362,11 @@ begin
|
|
|
Offset:=PRecordElement(Temp)^.Offset;
|
|
|
if Offset>expectedoffset then
|
|
|
move((Src+expectedoffset)^,(Dest+expectedoffset)^,Offset-expectedoffset);
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+ expectedoffset:=Offset+fpc_Copy_internal(Src+Offset,Dest+Offset,PRecordElement(Temp)^.TypeInfo^,DoMove);
|
|
|
+{$else}
|
|
|
expectedoffset:=Offset+fpc_Copy_internal(Src+Offset,Dest+Offset,PRecordElement(Temp)^.TypeInfo^);
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
Inc(PRecordElement(Temp));
|
|
|
end;
|
|
|
{ elements remaining? }
|
|
@@ -326,10 +376,27 @@ begin
|
|
|
end;
|
|
|
{$ifdef FPC_HAS_FEATURE_DYNARRAYS}
|
|
|
tkDynArray:
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+ if domove then
|
|
|
+ begin
|
|
|
+ fpc_dynarray_clear(PPointer(Dest)^,TypeInfo);
|
|
|
+ PPointer(Dest)^:=PPointer(src)^;
|
|
|
+ PPointer(Src)^:=nil;
|
|
|
+ end
|
|
|
+ else
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
fpc_dynarray_assign(PPointer(Dest)^,PPointer(Src)^,typeinfo);
|
|
|
{$endif FPC_HAS_FEATURE_DYNARRAYS}
|
|
|
{$ifdef FPC_HAS_FEATURE_CLASSES}
|
|
|
tkInterface:
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+ if domove then
|
|
|
+ begin
|
|
|
+ PPointer(Dest)^:=PPointer(src)^;
|
|
|
+ PPointer(Src)^:=nil;
|
|
|
+ end
|
|
|
+ else
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
fpc_intf_assign(PPointer(Dest)^,PPointer(Src)^);
|
|
|
{$endif FPC_HAS_FEATURE_CLASSES}
|
|
|
{$ifdef FPC_HAS_FEATURE_VARIANTS}
|
|
@@ -346,10 +413,17 @@ end;
|
|
|
{ For internal use by the compiler, because otherwise $x- can cause trouble. }
|
|
|
{ Generally disabling extended syntax checking for all compilerprocs may }
|
|
|
{ have unintended side-effects }
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+procedure fpc_Copy_proc (Src, Dest, TypeInfo : Pointer; DoMove : Boolean);compilerproc; inline;
|
|
|
+begin
|
|
|
+ fpc_copy_internal(src,dest,typeinfo,domove);
|
|
|
+end;
|
|
|
+{$else}
|
|
|
procedure fpc_Copy_proc (Src, Dest, TypeInfo : Pointer);compilerproc; inline;
|
|
|
begin
|
|
|
fpc_copy_internal(src,dest,typeinfo);
|
|
|
end;
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
|
|
|
|
|
|
procedure fpc_initialize_array(data,typeinfo : pointer;count : SizeInt); [public,alias:'FPC_INITIALIZE_ARRAY']; compilerproc;
|
|
@@ -404,6 +478,10 @@ procedure CopyArray(dest, source, typeInfo: Pointer; count: SizeInt);
|
|
|
begin
|
|
|
if RTTIManagementAndSize(typeinfo, rotCopy, size, manBuiltin)<>manNone then
|
|
|
for i:=0 to count-1 do
|
|
|
+{$ifdef FPC_MANAGED_MOVE}
|
|
|
+ fpc_Copy_internal(source+size*i, dest+size*i, typeInfo, False);
|
|
|
+{$else}
|
|
|
fpc_Copy_internal(source+size*i, dest+size*i, typeInfo);
|
|
|
+{$endif FPC_MANAGED_MOVE}
|
|
|
end;
|
|
|
|