فهرست منبع

* fixed fpc_dynarr_copy() for making copies of arrays of implicit pointer
types (the elements have to be cloned)

git-svn-id: branches/jvmbackend@18810 -

Jonas Maebe 14 سال پیش
والد
کامیت
79e971ea12
2فایلهای تغییر یافته به همراه35 افزوده شده و 5 حذف شده
  1. 20 5
      rtl/java/jdynarr.inc
  2. 15 0
      rtl/java/jdynarrh.inc

+ 20 - 5
rtl/java/jdynarr.inc

@@ -372,15 +372,30 @@ function fpc_dynarray_copy(src: JLObject; start, len: longint; ndim: longint; el
       begin
         case eletype of
           FPCJDynArrTypeRecord:
-            fpc_copy_jrecord_array(TJRecordArray(src),TJRecordArray(result),start,len);
+            begin
+              for i:=0 to len-1 do
+                TJObjectArray(result)[i]:=FpcBaseRecordType(TJObjectArray(src)[i]).clone;
+            end;
           FPCJDynArrTypeEnumSet:
-            fpc_copy_jenumset_array(TJEnumSetArray(src),TJEnumSetArray(result),start,len);
+            begin
+              for i:=0 to len-1 do
+                TJObjectArray(result)[i]:=JUEnumSet(TJObjectArray(src)[i]).clone;
+            end;
           FPCJDynArrTypeBitSet:
-            fpc_copy_jbitset_array(TJBitSetArray(src),TJBitSetArray(result),start,len);
+            begin
+              for i:=0 to len-1 do
+                TJObjectArray(result)[i]:=FpcBitSet(TJObjectArray(src)[i]).clone;
+            end;
           FPCJDynArrTypeProcvar:
-            fpc_copy_jprocvar_array(TJProcVarArray(src),TJProcVarArray(result),start,len);
+            begin
+              for i:=0 to len-1 do
+                TJObjectArray(result)[i]:=FpcBaseProcVarType(TJObjectArray(src)[i]).clone;
+            end;
           FPCJDynArrTypeShortstring:
-            fpc_copy_jshortstring_array(TShortstringArray(src),TShortstringArray(result),start,len);
+            begin
+              for i:=0 to len-1 do
+                TJObjectArray(result)[i]:=ShortStringClass(TJObjectArray(src)[i]).clone;
+            end;
           else
             fpc_copy_shallow_array(src,result,start,len);
         end

+ 15 - 0
rtl/java/jdynarrh.inc

@@ -80,5 +80,20 @@ procedure fpc_copy_jshortstring_array(src, dst: TShortstringArray; srcstart: jin
 function fpc_setlength_dynarr_multidim(aorg, anew: TJObjectArray; deepcopy: boolean; ndim: longint; eletype: jchar): TJObjectArray;
 
 
+{ create a copy of an array.
+
+  src points to the array.
+
+  Start is the start index and len the length. If both are -1, this means that
+  the entire array has to be copied.
+
+  ndim is the number of array dimensions that needs to be copied (can't be
+  determined by reflection, since we may have dynamic arrays of normal arrays
+  or vice versa).
+
+  eletype is the type of the array elements
+
+  The array copy is returned.
+  }
 function fpc_dynarray_copy(src: JLObject; start, len: longint; ndim: longint; eletype: jchar): JLObject;