From 568ef396fb0daf25c03d9bb9bfd943f1f4d39cb0 Mon Sep 17 00:00:00 2001 From: sergei Date: Thu, 19 Jan 2012 17:43:37 +0000 Subject: [PATCH] * Added fpc_dynarray_assign (a helper for dynamic array assignments), added local access to fpc_intf_assign, and switched fpc_copy to use assignment helpers instead of incr_ref/decr_ref combinations. git-svn-id: trunk@20114 - --- rtl/inc/compproc.inc | 1 + rtl/inc/dynarr.inc | 9 +++++++++ rtl/inc/objpas.inc | 1 + rtl/inc/rtti.inc | 18 +++--------------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/rtl/inc/compproc.inc b/rtl/inc/compproc.inc index 6aa20c15d5..cd46f3ad5b 100644 --- a/rtl/inc/compproc.inc +++ b/rtl/inc/compproc.inc @@ -64,6 +64,7 @@ procedure fpc_dynarray_clear(var p : pointer;ti : pointer); compilerproc; procedure fpc_dynarray_decr_ref(var p : pointer;ti : pointer); compilerproc; procedure fpc_dynarray_incr_ref(p : pointer); compilerproc; procedure fpc_dynarray_setlength(var p : pointer;pti : pointer; dimcount : sizeint;dims : pdynarrayindex); compilerproc; +procedure fpc_dynarray_assign(var dest : pointer; src : pointer; ti: pointer); compilerproc; {$endif FPC_HAS_FEATURE_DYNARRAYS} { Str() support } diff --git a/rtl/inc/dynarr.inc b/rtl/inc/dynarr.inc index 1a1654be36..0b11bd491b 100644 --- a/rtl/inc/dynarr.inc +++ b/rtl/inc/dynarr.inc @@ -134,6 +134,15 @@ procedure fpc_dynarray_incr_ref(p : pointer);[Public,Alias:'FPC_DYNARRAY_INCR_RE procedure fpc_dynarray_incr_ref(p : pointer); [external name 'FPC_DYNARRAY_INCR_REF']; +procedure fpc_dynarray_assign(var dest: Pointer; src: Pointer; ti: pointer);[public,alias:'FPC_DYNARRAY_ASSIGN']; compilerproc; + begin + fpc_dynarray_incr_ref(src); + fpc_dynarray_decr_ref(dest,ti); + Dest:=Src; + end; + +procedure fpc_dynarray_assign(var dest: Pointer; src: Pointer; ti: pointer);[external name 'FPC_DYNARRAY_ASSIGN']; + { provide local access to dynarr_setlength } procedure int_dynarray_setlength(var p : pointer;pti : pointer; dimcount : sizeint;dims : pdynarrayindex);[external name 'FPC_DYNARR_SETLENGTH']; diff --git a/rtl/inc/objpas.inc b/rtl/inc/objpas.inc index 7a587ab172..ebeae02c09 100644 --- a/rtl/inc/objpas.inc +++ b/rtl/inc/objpas.inc @@ -82,6 +82,7 @@ D:=S; end; + procedure fpc_intf_assign(var D: pointer; const s: pointer); [external name 'FPC_INTF_ASSIGN']; {procedure fpc_intf_assign_by_iid(var D: pointer; const S: pointer; const iid: TGUID);[public,alias: 'FPC_INTF_ASSIGN2']; compilerproc; var diff --git a/rtl/inc/rtti.inc b/rtl/inc/rtti.inc index de07a63662..83116a67cb 100644 --- a/rtl/inc/rtti.inc +++ b/rtl/inc/rtti.inc @@ -275,11 +275,7 @@ begin case PByte(TypeInfo)^ of {$ifdef FPC_HAS_FEATURE_ANSISTRINGS} tkAstring: - begin - fpc_AnsiStr_Incr_Ref(PPointer(Src)^); - fpc_AnsiStr_Decr_Ref(PPointer(Dest)^); - PPointer(Dest)^:=PPointer(Src)^; - end; + fpc_AnsiStr_Assign(PPointer(Dest)^,PPointer(Src)^); {$endif FPC_HAS_FEATURE_ANSISTRINGS} {$ifdef FPC_HAS_FEATURE_WIDESTRINGS} {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING} @@ -325,18 +321,10 @@ begin end; {$ifdef FPC_HAS_FEATURE_DYNARRAYS} tkDynArray: - begin - fpc_dynarray_Incr_Ref(PPointer(Src)^); - fpc_dynarray_Decr_Ref(PPointer(Dest)^,typeinfo); - PPointer(Dest)^:=PPointer(Src)^; - end; + fpc_dynarray_assign(PPointer(Dest)^,PPointer(Src)^,typeinfo); {$endif FPC_HAS_FEATURE_DYNARRAYS} tkInterface: - begin - Intf_Incr_Ref(PPointer(Src)^); - Intf_Decr_Ref(PPointer(Dest)^); - PPointer(Dest)^:=PPointer(Src)^; - end; + fpc_intf_assign(PPointer(Dest)^,PPointer(Src)^); {$ifdef FPC_HAS_FEATURE_VARIANTS} tkVariant: begin