system.pp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2006 by Florian Klaempfl
  4. member of the Free Pascal development team.
  5. System unit for embedded systems
  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. Unit system;
  13. {$namespace org.freepascal.rtl}
  14. {*****************************************************************************}
  15. interface
  16. {*****************************************************************************}
  17. {$define FPC_IS_SYSTEM}
  18. {$I-,Q-,H-,R-,V-,P+,T+}
  19. {$implicitexceptions off}
  20. {$mode objfpc}
  21. {$undef FPC_HAS_FEATURE_ANSISTRINGS}
  22. {$undef FPC_HAS_FEATURE_TEXTIO}
  23. {$undef FPC_HAS_FEATURE_VARIANTS}
  24. {$undef FPC_HAS_FEATURE_CLASSES}
  25. {$undef FPC_HAS_FEATURE_EXCEPTIONS}
  26. {$undef FPC_HAS_FEATURE_OBJECTS}
  27. {$undef FPC_HAS_FEATURE_RTTI}
  28. {$undef FPC_HAS_FEATURE_FILEIO}
  29. {$undef FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE}
  30. Type
  31. { The compiler has all integer types defined internally. Here
  32. we define only aliases }
  33. DWord = LongWord;
  34. Cardinal = LongWord;
  35. Integer = SmallInt;
  36. UInt64 = QWord;
  37. SizeInt = Longint;
  38. SizeUInt = Longint;
  39. PtrInt = Longint;
  40. PtrUInt = Longint;
  41. ValReal = Double;
  42. AnsiChar = Char;
  43. UnicodeChar = WideChar;
  44. { map comp to int64 }
  45. Comp = Int64;
  46. HResult = type longint;
  47. PShortString = ^ShortString;
  48. { Java primitive types }
  49. jboolean = boolean;
  50. jbyte = shortint;
  51. jshort = smallint;
  52. jint = longint;
  53. jlong = int64;
  54. jchar = widechar;
  55. jfloat = single;
  56. jdouble = double;
  57. Arr1jboolean = array of jboolean;
  58. Arr1jbyte = array of jbyte;
  59. Arr1jshort = array of jshort;
  60. Arr1jint = array of jint;
  61. Arr1jlong = array of jlong;
  62. Arr1jchar = array of jchar;
  63. Arr1jfloat = array of jfloat;
  64. Arr1jdouble = array of jdouble;
  65. Arr2jboolean = array of Arr1jboolean;
  66. Arr2jbyte = array of Arr1jbyte;
  67. Arr2jshort = array of Arr1jshort;
  68. Arr2jint = array of Arr1jint;
  69. Arr2jlong = array of Arr1jlong;
  70. Arr2jchar = array of Arr1jchar;
  71. Arr2jfloat = array of Arr1jfloat;
  72. Arr2jdouble = array of Arr1jdouble;
  73. Arr3jboolean = array of Arr2jboolean;
  74. Arr3jbyte = array of Arr2jbyte;
  75. Arr3jshort = array of Arr2jshort;
  76. Arr3jint = array of Arr2jint;
  77. Arr3jlong = array of Arr2jlong;
  78. Arr3jchar = array of Arr2jchar;
  79. Arr3jfloat = array of Arr2jfloat;
  80. Arr3jdouble = array of Arr2jdouble;
  81. const
  82. { max. values for longint and int}
  83. maxLongint = $7fffffff;
  84. maxSmallint = 32767;
  85. maxint = maxsmallint;
  86. { Java base class type }
  87. {$i java_sysh.inc}
  88. {$i java_sys.inc}
  89. type
  90. TObject = class(JLObject)
  91. strict private
  92. DestructorCalled: Boolean;
  93. public
  94. procedure Free;
  95. destructor Destroy; virtual;
  96. procedure finalize; override;
  97. end;
  98. FpcEnumValueObtainable = interface
  99. function fpcOrdinal: jint;
  100. function fpcGenericValueOf(__fpc_int: longint): JLEnum;
  101. end;
  102. {$i innr.inc}
  103. {$i jmathh.inc}
  104. {$i jrech.inc}
  105. {$i jseth.inc}
  106. {$i sstringh.inc}
  107. {$i jdynarrh.inc}
  108. {$i astringh.inc}
  109. {$ifndef nounsupported}
  110. type
  111. tmethod = record
  112. code: jlobject;
  113. end;
  114. const
  115. vtInteger = 0;
  116. vtBoolean = 1;
  117. vtChar = 2;
  118. {$ifndef FPUNONE}
  119. vtExtended = 3;
  120. {$endif}
  121. vtString = 4;
  122. vtPointer = 5;
  123. vtPChar = 6;
  124. vtObject = 7;
  125. vtClass = 8;
  126. vtWideChar = 9;
  127. vtPWideChar = 10;
  128. vtAnsiString = 11;
  129. vtCurrency = 12;
  130. vtVariant = 13;
  131. vtInterface = 14;
  132. vtWideString = 15;
  133. vtInt64 = 16;
  134. vtQWord = 17;
  135. vtUnicodeString = 18;
  136. type
  137. TVarRec = record
  138. case VType : sizeint of
  139. {$ifdef ENDIAN_BIG}
  140. vtInteger : ({$IFDEF CPU64}integerdummy1 : Longint;{$ENDIF CPU64}VInteger: Longint);
  141. vtBoolean : ({$IFDEF CPU64}booldummy : Longint;{$ENDIF CPU64}booldummy1,booldummy2,booldummy3: byte; VBoolean: Boolean);
  142. vtChar : ({$IFDEF CPU64}chardummy : Longint;{$ENDIF CPU64}chardummy1,chardummy2,chardummy3: byte; VChar: Char);
  143. vtWideChar : ({$IFDEF CPU64}widechardummy : Longint;{$ENDIF CPU64}wchardummy1,VWideChar: WideChar);
  144. {$else ENDIAN_BIG}
  145. vtInteger : (VInteger: Longint);
  146. vtBoolean : (VBoolean: Boolean);
  147. vtChar : (VChar: Char);
  148. vtWideChar : (VWideChar: WideChar);
  149. {$endif ENDIAN_BIG}
  150. // vtString : (VString: PShortString);
  151. // vtPointer : (VPointer: Pointer);
  152. /// vtPChar : (VPChar: PChar);
  153. vtObject : (VObject: TObject);
  154. // vtClass : (VClass: TClass);
  155. // vtPWideChar : (VPWideChar: PWideChar);
  156. vtAnsiString : (VAnsiString: JLObject);
  157. vtCurrency : (VCurrency: Currency);
  158. // vtVariant : (VVariant: PVariant);
  159. vtInterface : (VInterface: JLObject);
  160. vtWideString : (VWideString: JLString);
  161. vtInt64 : (VInt64: Int64);
  162. vtUnicodeString : (VUnicodeString: JLString);
  163. vtQWord : (VQWord: QWord);
  164. end;
  165. {$endif}
  166. Function lo(i : Integer) : byte; [INTERNPROC: fpc_in_lo_Word];
  167. Function lo(w : Word) : byte; [INTERNPROC: fpc_in_lo_Word];
  168. Function lo(l : Longint) : Word; [INTERNPROC: fpc_in_lo_long];
  169. Function lo(l : DWord) : Word; [INTERNPROC: fpc_in_lo_long];
  170. Function lo(i : Int64) : DWord; [INTERNPROC: fpc_in_lo_qword];
  171. Function lo(q : QWord) : DWord; [INTERNPROC: fpc_in_lo_qword];
  172. Function hi(i : Integer) : byte; [INTERNPROC: fpc_in_hi_Word];
  173. Function hi(w : Word) : byte; [INTERNPROC: fpc_in_hi_Word];
  174. Function hi(l : Longint) : Word; [INTERNPROC: fpc_in_hi_long];
  175. Function hi(l : DWord) : Word; [INTERNPROC: fpc_in_hi_long];
  176. Function hi(i : Int64) : DWord; [INTERNPROC: fpc_in_hi_qword];
  177. Function hi(q : QWord) : DWord; [INTERNPROC: fpc_in_hi_qword];
  178. Function chr(b : byte) : AnsiChar; [INTERNPROC: fpc_in_chr_byte];
  179. function RorByte(Const AValue : Byte): Byte;[internproc:fpc_in_ror_x];
  180. function RorByte(Const AValue : Byte;Dist : Byte): Byte;[internproc:fpc_in_ror_x_x];
  181. function RolByte(Const AValue : Byte): Byte;[internproc:fpc_in_rol_x];
  182. function RolByte(Const AValue : Byte;Dist : Byte): Byte;[internproc:fpc_in_rol_x_x];
  183. function RorWord(Const AValue : Word): Word;[internproc:fpc_in_ror_x];
  184. function RorWord(Const AValue : Word;Dist : Byte): Word;[internproc:fpc_in_ror_x_x];
  185. function RolWord(Const AValue : Word): Word;[internproc:fpc_in_rol_x];
  186. function RolWord(Const AValue : Word;Dist : Byte): Word;[internproc:fpc_in_rol_x_x];
  187. function RorDWord(Const AValue : DWord): DWord;[internproc:fpc_in_ror_x];
  188. function RorDWord(Const AValue : DWord;Dist : Byte): DWord;[internproc:fpc_in_ror_x_x];
  189. function RolDWord(Const AValue : DWord): DWord;[internproc:fpc_in_rol_x];
  190. function RolDWord(Const AValue : DWord;Dist : Byte): DWord;[internproc:fpc_in_rol_x_x];
  191. function RorQWord(Const AValue : QWord): QWord;[internproc:fpc_in_ror_x];
  192. function RorQWord(Const AValue : QWord;Dist : Byte): QWord;[internproc:fpc_in_ror_x_x];
  193. function RolQWord(Const AValue : QWord): QWord;[internproc:fpc_in_rol_x];
  194. function RolQWord(Const AValue : QWord;Dist : Byte): QWord;[internproc:fpc_in_rol_x_x];
  195. function SarShortint(Const AValue : Shortint): Shortint;[internproc:fpc_in_sar_x];
  196. function SarShortint(Const AValue : Shortint;Shift : Byte): Shortint;[internproc:fpc_in_sar_x_y];
  197. function SarSmallint(Const AValue : Smallint): Smallint;[internproc:fpc_in_sar_x];
  198. function SarSmallint(Const AValue : Smallint;Shift : Byte): Smallint;[internproc:fpc_in_sar_x_y];
  199. function SarLongint(Const AValue : Longint): Longint;[internproc:fpc_in_sar_x];
  200. function SarLongint(Const AValue : Longint;Shift : Byte): Longint;[internproc:fpc_in_sar_x_y];
  201. function SarInt64(Const AValue : Int64): Int64;[internproc:fpc_in_sar_x];
  202. function SarInt64(Const AValue : Int64;Shift : Byte): Int64;[internproc:fpc_in_sar_x_y];
  203. {$i compproc.inc}
  204. {$i ustringh.inc}
  205. {*****************************************************************************}
  206. implementation
  207. {*****************************************************************************}
  208. {i jdynarr.inc}
  209. {
  210. This file is part of the Free Pascal run time library.
  211. Copyright (c) 2011 by Jonas Maebe
  212. member of the Free Pascal development team.
  213. This file implements the helper routines for dyn. Arrays in FPC
  214. See the file COPYING.FPC, included in this distribution,
  215. for details about the copyright.
  216. This program is distributed in the hope that it will be useful,
  217. but WITHOUT ANY WARRANTY; without even the implied warranty of
  218. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  219. **********************************************************************
  220. }
  221. function min(a,b : longint) : longint;
  222. begin
  223. if a<=b then
  224. min:=a
  225. else
  226. min:=b;
  227. end;
  228. {$i sstrings.inc}
  229. {$i astrings.inc}
  230. {$i ustrings.inc}
  231. {$i rtti.inc}
  232. {$i jrec.inc}
  233. {$i jset.inc}
  234. {$i jint64.inc}
  235. { copying helpers }
  236. procedure fpc_copy_shallow_array(src, dst: JLObject; srcstart: jint = -1; srccopylen: jint = -1);
  237. var
  238. srclen, dstlen: jint;
  239. begin
  240. if assigned(src) then
  241. srclen:=JLRArray.getLength(src)
  242. else
  243. srclen:=0;
  244. if assigned(dst) then
  245. dstlen:=JLRArray.getLength(dst)
  246. else
  247. dstlen:=0;
  248. if srcstart=-1 then
  249. srcstart:=0
  250. else if srcstart>=srclen then
  251. exit;
  252. if srccopylen=-1 then
  253. srccopylen:=srclen
  254. else if srcstart+srccopylen>srclen then
  255. srccopylen:=srclen-srcstart;
  256. { causes exception in JLSystem.arraycopy }
  257. if (srccopylen=0) or
  258. (dstlen=0) then
  259. exit;
  260. JLSystem.arraycopy(src,srcstart,dst,0,min(srccopylen,dstlen));
  261. end;
  262. procedure fpc_copy_jrecord_array(src, dst: TJRecordArray; srcstart: jint = -1; srccopylen: jint = -1);
  263. var
  264. i: longint;
  265. srclen, dstlen: jint;
  266. begin
  267. srclen:=length(src);
  268. dstlen:=length(dst);
  269. if srcstart=-1 then
  270. srcstart:=0
  271. else if srcstart>=srclen then
  272. exit;
  273. if srccopylen=-1 then
  274. srccopylen:=srclen
  275. else if srcstart+srccopylen>srclen then
  276. srccopylen:=srclen-srcstart;
  277. { no arraycopy, have to clone each element }
  278. for i:=0 to min(srccopylen,dstlen)-1 do
  279. dst[i]:=FpcBaseRecordType(src[srcstart+i].clone);
  280. end;
  281. procedure fpc_copy_jenumset_array(src, dst: TJEnumSetArray; srcstart: jint = -1; srccopylen: jint = -1);
  282. var
  283. i: longint;
  284. srclen, dstlen: jint;
  285. begin
  286. srclen:=length(src);
  287. dstlen:=length(dst);
  288. if srcstart=-1 then
  289. srcstart:=0
  290. else if srcstart>=srclen then
  291. exit;
  292. if srccopylen=-1 then
  293. srccopylen:=srclen
  294. else if srcstart+srccopylen>srclen then
  295. srccopylen:=srclen-srcstart;
  296. { no arraycopy, have to clone each element }
  297. for i:=0 to min(srccopylen,dstlen)-1 do
  298. dst[i]:=JUEnumSet(src[srcstart+i].clone);
  299. end;
  300. procedure fpc_copy_jbitset_array(src, dst: TJBitSetArray; srcstart: jint = -1; srccopylen: jint = -1);
  301. var
  302. i: longint;
  303. srclen, dstlen: jint;
  304. begin
  305. srclen:=length(src);
  306. dstlen:=length(dst);
  307. if srcstart=-1 then
  308. srcstart:=0
  309. else if srcstart>=srclen then
  310. exit;
  311. if srccopylen=-1 then
  312. srccopylen:=srclen
  313. else if srcstart+srccopylen>srclen then
  314. srccopylen:=srclen-srcstart;
  315. { no arraycopy, have to clone each element }
  316. for i:=0 to min(srccopylen,dstlen)-1 do
  317. dst[i]:=JUBitset(src[srcstart+i].clone);
  318. end;
  319. procedure fpc_copy_jshortstring_array(src, dst: TShortstringArray; srcstart: jint = -1; srccopylen: jint = -1);
  320. var
  321. i: longint;
  322. srclen, dstlen: jint;
  323. begin
  324. srclen:=length(src);
  325. dstlen:=length(dst);
  326. if srcstart=-1 then
  327. srcstart:=0
  328. else if srcstart>=srclen then
  329. exit;
  330. if srccopylen=-1 then
  331. srccopylen:=srclen
  332. else if srcstart+srccopylen>srclen then
  333. srccopylen:=srclen-srcstart;
  334. { no arraycopy, have to clone each element }
  335. for i:=0 to min(srccopylen,dstlen)-1 do
  336. dst[i]:=ShortstringClass(src[srcstart+i].clone);
  337. end;
  338. { 1-dimensional setlength routines }
  339. function fpc_setlength_dynarr_generic(aorg, anew: JLObject; deepcopy: boolean; docopy: boolean = true): JLObject;
  340. var
  341. orglen, newlen: jint;
  342. begin
  343. orglen:=0;
  344. newlen:=0;
  345. if not deepcopy then
  346. begin
  347. if assigned(aorg) then
  348. orglen:=JLRArray.getLength(aorg)
  349. else
  350. orglen:=0;
  351. if assigned(anew) then
  352. newlen:=JLRArray.getLength(anew)
  353. else
  354. newlen:=0;
  355. end;
  356. if deepcopy or
  357. (orglen<>newlen) then
  358. begin
  359. if docopy then
  360. fpc_copy_shallow_array(aorg,anew);
  361. result:=anew
  362. end
  363. else
  364. result:=aorg;
  365. end;
  366. function fpc_setlength_dynarr_jrecord(aorg, anew: TJRecordArray; deepcopy: boolean): TJRecordArray;
  367. begin
  368. if deepcopy or
  369. (length(aorg)<>length(anew)) then
  370. begin
  371. fpc_copy_jrecord_array(aorg,anew);
  372. result:=anew
  373. end
  374. else
  375. result:=aorg;
  376. end;
  377. function fpc_setlength_dynarr_jenumset(aorg, anew: TJEnumSetArray; deepcopy: boolean): TJEnumSetArray;
  378. begin
  379. if deepcopy or
  380. (length(aorg)<>length(anew)) then
  381. begin
  382. fpc_copy_jenumset_array(aorg,anew);
  383. result:=anew
  384. end
  385. else
  386. result:=aorg;
  387. end;
  388. function fpc_setlength_dynarr_jbitset(aorg, anew: TJBitSetArray; deepcopy: boolean): TJBitSetArray;
  389. begin
  390. if deepcopy or
  391. (length(aorg)<>length(anew)) then
  392. begin
  393. fpc_copy_jbitset_array(aorg,anew);
  394. result:=anew
  395. end
  396. else
  397. result:=aorg;
  398. end;
  399. function fpc_setlength_dynarr_jshortstring(aorg, anew: TShortstringArray; deepcopy: boolean): TShortstringArray;
  400. begin
  401. if deepcopy or
  402. (length(aorg)<>length(anew)) then
  403. begin
  404. fpc_copy_jshortstring_array(aorg,anew);
  405. result:=anew
  406. end
  407. else
  408. result:=aorg;
  409. end;
  410. { multi-dimensional setlength routine }
  411. function fpc_setlength_dynarr_multidim(aorg, anew: TJObjectArray; deepcopy: boolean; ndim: longint; eletype: jchar): TJObjectArray;
  412. var
  413. partdone,
  414. i: longint;
  415. begin
  416. { resize the current dimension; no need to copy the subarrays of the old
  417. array, as the subarrays will be (re-)initialised immediately below }
  418. { the srcstart/srccopylen always refers to the first dimension (since copy()
  419. performs a shallow copy of a dynamic array }
  420. result:=TJObjectArray(fpc_setlength_dynarr_generic(JLObject(aorg),JLObject(anew),deepcopy,false));
  421. { if aorg was empty, there's nothing else to do since result will now
  422. contain anew, of which all other dimensions are already initialised
  423. correctly since there are no aorg elements to copy }
  424. if not assigned(aorg) and
  425. not deepcopy then
  426. exit;
  427. partdone:=min(high(result),high(aorg));
  428. { ndim must be >=2 when this routine is called, since it has to return
  429. an array of java.lang.Object! (arrays are also objects, but primitive
  430. types are not) }
  431. if ndim=2 then
  432. begin
  433. { final dimension -> copy the primitive arrays }
  434. case eletype of
  435. FPCJDynArrTypeRecord:
  436. begin
  437. for i:=low(result) to partdone do
  438. result[i]:=JLObject(fpc_setlength_dynarr_jrecord(TJRecordArray(aorg[i]),TJRecordArray(anew[i]),deepcopy));
  439. for i:=succ(partdone) to high(result) do
  440. result[i]:=JLObject(fpc_setlength_dynarr_jrecord(nil,TJRecordArray(anew[i]),deepcopy));
  441. end;
  442. FPCJDynArrTypeEnumSet:
  443. begin
  444. for i:=low(result) to partdone do
  445. result[i]:=JLObject(fpc_setlength_dynarr_jenumset(TJEnumSetArray(aorg[i]),TJEnumSetArray(anew[i]),deepcopy));
  446. for i:=succ(partdone) to high(result) do
  447. result[i]:=JLObject(fpc_setlength_dynarr_jenumset(nil,TJEnumSetArray(anew[i]),deepcopy));
  448. end;
  449. FPCJDynArrTypeBitSet:
  450. begin
  451. for i:=low(result) to partdone do
  452. result[i]:=JLObject(fpc_setlength_dynarr_jbitset(TJBitSetArray(aorg[i]),TJBitSetArray(anew[i]),deepcopy));
  453. for i:=succ(partdone) to high(result) do
  454. result[i]:=JLObject(fpc_setlength_dynarr_jbitset(nil,TJBitSetArray(anew[i]),deepcopy));
  455. end;
  456. FPCJDynArrTypeShortstring:
  457. begin
  458. for i:=low(result) to partdone do
  459. result[i]:=JLObject(fpc_setlength_dynarr_jshortstring(TShortstringArray(aorg[i]),TShortstringArray(anew[i]),deepcopy));
  460. for i:=succ(partdone) to high(result) do
  461. result[i]:=JLObject(fpc_setlength_dynarr_jshortstring(nil,TShortstringArray(anew[i]),deepcopy));
  462. end;
  463. else
  464. begin
  465. for i:=low(result) to partdone do
  466. result[i]:=fpc_setlength_dynarr_generic(aorg[i],anew[i],deepcopy);
  467. for i:=succ(partdone) to high(result) do
  468. result[i]:=fpc_setlength_dynarr_generic(nil,anew[i],deepcopy);
  469. end;
  470. end;
  471. end
  472. else
  473. begin
  474. { recursively handle the next dimension }
  475. for i:=low(result) to partdone do
  476. result[i]:=JLObject(fpc_setlength_dynarr_multidim(TJObjectArray(aorg[i]),TJObjectArray(anew[i]),deepcopy,pred(ndim),eletype));
  477. for i:=succ(partdone) to high(result) do
  478. result[i]:=JLObject(fpc_setlength_dynarr_multidim(nil,TJObjectArray(anew[i]),deepcopy,pred(ndim),eletype));
  479. end;
  480. end;
  481. function fpc_dynarray_copy(src: JLObject; start, len: longint; ndim: longint; eletype: jchar): JLObject;
  482. var
  483. i: longint;
  484. srclen: longint;
  485. begin
  486. if not assigned(src) then
  487. begin
  488. result:=nil;
  489. exit;
  490. end;
  491. srclen:=JLRArray.getLength(src);
  492. if (start=-1) and
  493. (len=-1) then
  494. begin
  495. len:=srclen;
  496. start:=0;
  497. end
  498. else if (start+len>srclen) then
  499. len:=srclen-start+1;
  500. result:=JLRArray.newInstance(src.getClass.getComponentType,len);
  501. if ndim=1 then
  502. begin
  503. case eletype of
  504. FPCJDynArrTypeRecord:
  505. fpc_copy_jrecord_array(TJRecordArray(src),TJRecordArray(result),start,len);
  506. FPCJDynArrTypeEnumSet:
  507. fpc_copy_jenumset_array(TJEnumSetArray(src),TJEnumSetArray(result),start,len);
  508. FPCJDynArrTypeBitSet:
  509. fpc_copy_jbitset_array(TJBitSetArray(src),TJBitSetArray(result),start,len);
  510. FPCJDynArrTypeShortstring:
  511. fpc_copy_jshortstring_array(TShortstringArray(src),TShortstringArray(result),start,len);
  512. else
  513. fpc_copy_shallow_array(src,result,start,len);
  514. end
  515. end
  516. else
  517. begin
  518. for i:=0 to len-1 do
  519. TJObjectArray(result)[i]:=fpc_dynarray_copy(TJObjectArray(src)[start+i],-1,-1,ndim-1,eletype);
  520. end;
  521. end;
  522. {i jdynarr.inc end}
  523. {*****************************************************************************
  524. Misc. System Dependent Functions
  525. *****************************************************************************}
  526. procedure TObject.Free;
  527. begin
  528. if not DestructorCalled then
  529. begin
  530. DestructorCalled:=true;
  531. Destroy;
  532. end;
  533. end;
  534. destructor TObject.Destroy;
  535. begin
  536. end;
  537. procedure TObject.Finalize;
  538. begin
  539. Free;
  540. end;
  541. {*****************************************************************************
  542. SystemUnit Initialization
  543. *****************************************************************************}
  544. end.