jdynarrh.inc 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2011 by Jonas Maebe
  4. member of the Free Pascal development team.
  5. This file implements the helper routines for dyn. Arrays in FPC
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************
  12. }
  13. type
  14. TJByteArray = array of jbyte;
  15. TJShortArray = array of jshort;
  16. TJIntArray = array of jint;
  17. TJLongArray = array of jlong;
  18. TJCharArray = array of jchar;
  19. TJFloatArray = array of jfloat;
  20. TJDoubleArray = array of jdouble;
  21. TJObjectArray = array of JLObject;
  22. TJRecordArray = array of FpcBaseRecordType;
  23. TJStringArray = array of unicodestring;
  24. const
  25. FPCJDynArrTypeJByte = 'B';
  26. FPCJDynArrTypeJShort = 'S';
  27. FPCJDynArrTypeJInt = 'I';
  28. FPCJDynArrTypeJLong = 'J';
  29. FPCJDynArrTypeJChar = 'C';
  30. FPCJDynArrTypeJFloat = 'F';
  31. FPCJDynArrTypeJDouble = 'D';
  32. FPCJDynArrTypeJObject = 'A';
  33. FPCJDynArrTypeRecord = 'R';
  34. { 1-dimensional setlength routines
  35. Convention: aorg, is the current array, anew: is a newly allocated array of the
  36. size specified to setlength. The function either returns org if it had the
  37. right size already, or copies (part of) org in new and returns new.
  38. }
  39. function fpc_setlength_dynarr_jbyte(aorg, anew: TJByteArray; deepcopy: boolean): TJByteArray;
  40. function fpc_setlength_dynarr_jshort(aorg, anew: TJShortArray; deepcopy: boolean): TJShortArray;
  41. function fpc_setlength_dynarr_jint(aorg, anew: TJIntArray; deepcopy: boolean): TJIntArray;
  42. function fpc_setlength_dynarr_jlong(aorg, anew: TJLongArray; deepcopy: boolean): TJLongArray;
  43. function fpc_setlength_dynarr_jchar(aorg, anew: TJCharArray; deepcopy: boolean): TJCharArray;
  44. function fpc_setlength_dynarr_jfloat(aorg, anew: TJFloatArray; deepcopy: boolean): TJFloatArray;
  45. function fpc_setlength_dynarr_jdouble(aorg, anew: TJDoubleArray; deepcopy: boolean): TJDoubleArray;
  46. function fpc_setlength_dynarr_jobject(aorg, anew: TJObjectArray; deepcopy: boolean; docopy : boolean = true): TJObjectArray;
  47. function fpc_setlength_dynarr_jrecord(aorg, anew: TJRecordArray; deepcopy: boolean): TJRecordArray;
  48. { array copying helpers }
  49. procedure fpc_copy_jbyte_array(src, dst: TJByteArray);
  50. procedure fpc_copy_jshort_array(src, dst: TJShortArray);
  51. procedure fpc_copy_jint_array(src, dst: TJIntArray);
  52. procedure fpc_copy_jlong_array(src, dst: TJLongArray);
  53. procedure fpc_copy_jchar_array(src, dst: TJCharArray);
  54. procedure fpc_copy_jfloat_array(src, dst: TJFloatArray);
  55. procedure fpc_copy_jdouble_array(src, dst: TJDoubleArray);
  56. procedure fpc_copy_jobject_array(src, dst: TJObjectArray);
  57. procedure fpc_copy_jrecord_array(src, dst: TJRecordArray);
  58. { multi-dimendional setlength routine: all intermediate dimensions are arrays
  59. of arrays, so that's the same for all array kinds. Only the type of the final
  60. dimension matters.
  61. org is the current array, new is a newly allocated array of the
  62. (multi-demensional) size specified to setlength.
  63. This routine uses the intermediate levels from the old array if possible so
  64. that an unchanged array remains in the same place.
  65. Warning: ndim must be >= 2 when this routine is called.
  66. }
  67. function fpc_setlength_dynarr_multidim(aorg, anew: TJObjectArray; deepcopy: boolean; ndim: longint; eletype: jchar): TJObjectArray;