jdynarrh.inc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_generic(aorg, anew: JLObject; deepcopy: boolean; docopy: boolean = true): JLObject;
  40. function fpc_setlength_dynarr_jrecord(aorg, anew: TJRecordArray; deepcopy: boolean): TJRecordArray;
  41. { array copying helpers }
  42. procedure fpc_copy_shallow_array(src, dst: JLObject; srcstart: jint = -1; srccopylen: jint = -1);
  43. procedure fpc_copy_jrecord_array(src, dst: TJRecordArray; srcstart: jint = -1; srccopylen: jint = -1);
  44. { multi-dimendional setlength routine: all intermediate dimensions are arrays
  45. of arrays, so that's the same for all array kinds. Only the type of the final
  46. dimension matters.
  47. org is the current array, new is a newly allocated array of the
  48. (multi-demensional) size specified to setlength.
  49. This routine uses the intermediate levels from the old array if possible so
  50. that an unchanged array remains in the same place.
  51. Warning: ndim must be >= 2 when this routine is called.
  52. }
  53. function fpc_setlength_dynarr_multidim(aorg, anew: TJObjectArray; deepcopy: boolean; ndim: longint; eletype: jchar): TJObjectArray;