2
0

rtti.inc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt
  4. member of the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. { Run-Time type information routines }
  12. function RTTIArraySize(typeInfo: Pointer): SizeInt;
  13. begin
  14. {$ifdef VER3_0}
  15. typeInfo:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
  16. {$else VER3_0}
  17. typeInfo:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]);
  18. {$endif VER3_0}
  19. result:=PArrayInfo(typeInfo)^.Size;
  20. end;
  21. function RTTIRecordSize(typeInfo: Pointer): SizeInt;
  22. begin
  23. {$ifdef VER3_0}
  24. typeInfo:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
  25. {$else VER3_0}
  26. typeInfo:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]);
  27. {$endif VER3_0}
  28. { for size field init table is compatible with rtti table }
  29. result:=PRecordInfoFull(typeInfo)^.Size;
  30. end;
  31. {$ifndef VER3_0}
  32. function RTTIRecordOp(typeInfo: Pointer; var initrtti: Pointer): PRecordInfoInit; inline;
  33. begin
  34. { find init table and management operators }
  35. typeInfo:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]);
  36. result:=typeInfo;
  37. { check terminator, maybe we are already in init table }
  38. if Assigned(result^.Terminator) then
  39. begin
  40. { point to more optimal initrtti }
  41. initrtti:=PRecordInfoFull(result)^.InitTable;
  42. { and point to management operators in our init table }
  43. result:=aligntoqword(initrtti+2+PByte(initrtti)[1]);
  44. end
  45. end;
  46. {$else VER3_0}
  47. function RTTIRecordRttiInfoToInitInfo(typeInfo: Pointer): Pointer; inline;
  48. begin
  49. result:=typeInfo;
  50. {$ifndef VER3_0}
  51. { find init table }
  52. typeInfo:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]);
  53. { check terminator, maybe we are already in init table }
  54. if Assigned(PRecordInfoInit(typeInfo)^.Terminator) then
  55. { point to more optimal initrtti }
  56. result:=PRecordInfoFull(typeInfo)^.InitTable;
  57. {$endif VER3_0}
  58. end;
  59. {$endif VER3_0}
  60. {$ifndef VER3_0}
  61. function RTTISizeAndOp(typeInfo: Pointer;
  62. const expectedManagementOp: TRTTIRecOpType; out hasManagementOp: boolean): SizeInt;
  63. begin
  64. hasManagementOp:=false;
  65. {$else VER3_0}
  66. function RTTISize(typeInfo: Pointer): SizeInt;
  67. begin
  68. {$endif VER3_0}
  69. case PTypeKind(typeinfo)^ of
  70. tkAString,tkWString,tkUString,
  71. tkInterface,tkDynarray:
  72. result:=sizeof(Pointer);
  73. {$ifdef FPC_HAS_FEATURE_VARIANTS}
  74. tkVariant:
  75. result:=sizeof(TVarData);
  76. {$endif FPC_HAS_FEATURE_VARIANTS}
  77. tkArray:
  78. result:=RTTIArraySize(typeinfo);
  79. {$ifndef VER3_0}
  80. tkObject:
  81. result:=RTTIRecordSize(typeinfo);
  82. tkRecord:
  83. with RTTIRecordOp(typeInfo,typeInfo)^ do
  84. begin
  85. result:=Size;
  86. hasManagementOp := Assigned(RecordOp);
  87. if hasManagementOp then
  88. case expectedManagementOp of
  89. rotInitialize: hasManagementOp:=Assigned(RecordOp^.Initialize);
  90. rotFinalize: hasManagementOp:=Assigned(RecordOp^.Finalize);
  91. rotAddRef: hasManagementOp:=Assigned(RecordOp^.AddRef);
  92. rotCopy: hasManagementOp:=Assigned(RecordOp^.Copy);
  93. end;
  94. end;
  95. {$else VER3_0}
  96. tkObject,tkRecord:
  97. result:=RTTIRecordSize(typeinfo);
  98. {$endif VER3_0}
  99. else
  100. result:=-1;
  101. end;
  102. end;
  103. { if you modify this procedure, fpc_copy must be probably modified as well }
  104. procedure RecordRTTI(Data,TypeInfo:Pointer;rttiproc:TRTTIProc);
  105. var
  106. count,
  107. i : longint;
  108. begin
  109. {$ifdef VER3_0}
  110. typeInfo:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
  111. {$else VER3_0}
  112. typeInfo:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]);
  113. {$endif VER3_0}
  114. Count:=PRecordInfoInit(typeInfo)^.Count;
  115. { Get element info, hacky, but what else can we do? }
  116. typeInfo:=AlignTypeData(Pointer(@PRecordInfoInit(typeInfo)^.Count)+SizeOf(PRecordInfoInit(typeInfo)^.Count));
  117. { Process elements }
  118. for i:=1 to count Do
  119. begin
  120. rttiproc(Data+PRecordElement(typeInfo)^.Offset,PRecordElement(typeInfo)^.TypeInfo{$ifndef VER3_0}^{$endif});
  121. Inc(PRecordElement(typeInfo));
  122. end;
  123. end;
  124. {$ifndef VER3_0}
  125. function RTTIRecordMopInitTable(ti: Pointer): PRTTIRecordOpOffsetTable;
  126. begin
  127. ti:=aligntoqword(ti+2+PByte(ti)[1]);
  128. Result:=PRecordInfoInit(ti)^.InitRecordOpTable;
  129. end;
  130. {$endif VER3_0}
  131. { if you modify this procedure, fpc_copy must be probably modified as well }
  132. procedure ArrayRTTI(Data,TypeInfo:Pointer;rttiproc:TRTTIProc);
  133. var
  134. i,Count,ElSize: SizeInt;
  135. Info: Pointer;
  136. begin
  137. {$ifdef VER3_0}
  138. typeInfo:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
  139. {$else VER3_0}
  140. typeInfo:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]);
  141. {$endif VER3_0}
  142. Count:=PArrayInfo(typeInfo)^.ElCount;
  143. { no elements to process => exit }
  144. if Count = 0 then
  145. Exit;
  146. ElSize:=PArrayInfo(typeInfo)^.Size div Count;
  147. Info:=PArrayInfo(typeInfo)^.ElInfo{$ifndef VER3_0}^{$endif};
  148. { Process elements }
  149. for I:=0 to Count-1 do
  150. rttiproc(Data+(I*ElSize),Info);
  151. end;
  152. Procedure fpc_Initialize (Data,TypeInfo : pointer);[Public,Alias : 'FPC_INITIALIZE']; compilerproc;
  153. begin
  154. case PTypeKind(TypeInfo)^ of
  155. {$ifdef FPC_HAS_FEATURE_DYNARRAYS}
  156. tkDynArray,
  157. {$endif FPC_HAS_FEATURE_DYNARRAYS}
  158. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  159. tkAstring,
  160. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  161. {$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
  162. tkWstring,tkUString,
  163. {$endif FPC_HAS_FEATURE_WIDESTRINGS}
  164. tkInterface:
  165. PPchar(Data)^:=Nil;
  166. tkArray:
  167. arrayrtti(data,typeinfo,@int_initialize);
  168. {$ifdef FPC_HAS_FEATURE_OBJECTS}
  169. tkObject,
  170. {$endif FPC_HAS_FEATURE_OBJECTS}
  171. tkRecord:
  172. {$ifndef VER3_0}
  173. { if possible try to use more optimal initrtti }
  174. with RTTIRecordOp(typeinfo, typeinfo)^ do
  175. begin
  176. recordrtti(data,typeinfo,@int_initialize);
  177. if Assigned(recordop) and Assigned(recordop^.Initialize) then
  178. recordop^.Initialize(data);
  179. end;
  180. {$else VER3_0}
  181. begin
  182. typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
  183. recordrtti(data,typeinfo,@int_initialize);
  184. end;
  185. {$endif VER3_0}
  186. {$ifdef FPC_HAS_FEATURE_VARIANTS}
  187. tkVariant:
  188. variant_init(PVarData(Data)^);
  189. {$endif FPC_HAS_FEATURE_VARIANTS}
  190. end;
  191. end;
  192. Procedure fpc_finalize (Data,TypeInfo: Pointer);[Public,Alias : 'FPC_FINALIZE']; compilerproc;
  193. begin
  194. case PTypeKind(TypeInfo)^ of
  195. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  196. tkAstring :
  197. fpc_AnsiStr_Decr_Ref(PPointer(Data)^);
  198. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  199. {$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
  200. tkUstring :
  201. fpc_UnicodeStr_Decr_Ref(PPointer(Data)^);
  202. {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
  203. tkWstring :
  204. fpc_WideStr_Decr_Ref(PPointer(Data)^);
  205. {$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
  206. {$endif FPC_HAS_FEATURE_WIDESTRINGS}
  207. tkArray :
  208. arrayrtti(data,typeinfo,@int_finalize);
  209. {$ifdef FPC_HAS_FEATURE_OBJECTS}
  210. tkObject,
  211. {$endif FPC_HAS_FEATURE_OBJECTS}
  212. tkRecord:
  213. {$ifndef VER3_0}
  214. { if possible try to use more optimal initrtti }
  215. with RTTIRecordOp(typeinfo, typeinfo)^ do
  216. begin
  217. if Assigned(recordop) and Assigned(recordop^.Finalize) then
  218. recordop^.Finalize(data);
  219. recordrtti(data,typeinfo,@int_finalize);
  220. end;
  221. {$else VER3_0}
  222. begin
  223. typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
  224. recordrtti(data,typeinfo,@int_finalize);
  225. end;
  226. {$endif VER3_0}
  227. {$ifdef FPC_HAS_FEATURE_CLASSES}
  228. tkInterface:
  229. Intf_Decr_Ref(PPointer(Data)^);
  230. {$endif FPC_HAS_FEATURE_CLASSES}
  231. {$ifdef FPC_HAS_FEATURE_DYNARRAYS}
  232. tkDynArray:
  233. fpc_dynarray_clear(PPointer(Data)^,TypeInfo);
  234. {$endif FPC_HAS_FEATURE_DYNARRAYS}
  235. {$ifdef FPC_HAS_FEATURE_VARIANTS}
  236. tkVariant:
  237. variant_clear(PVarData(Data)^);
  238. {$endif FPC_HAS_FEATURE_VARIANTS}
  239. end;
  240. end;
  241. Procedure fpc_Addref (Data,TypeInfo : Pointer); [Public,alias : 'FPC_ADDREF']; compilerproc;
  242. begin
  243. case PTypeKind(TypeInfo)^ of
  244. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  245. tkAstring :
  246. fpc_AnsiStr_Incr_Ref(PPointer(Data)^);
  247. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  248. {$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
  249. {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
  250. tkWstring :
  251. fpc_WideStr_Incr_Ref(PPointer(Data)^);
  252. {$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
  253. tkUstring :
  254. fpc_UnicodeStr_Incr_Ref(PPointer(Data)^);
  255. {$endif FPC_HAS_FEATURE_WIDESTRINGS}
  256. tkArray :
  257. arrayrtti(data,typeinfo,@int_addref);
  258. {$ifdef FPC_HAS_FEATURE_OBJECTS}
  259. tkobject,
  260. {$endif FPC_HAS_FEATURE_OBJECTS}
  261. tkrecord :
  262. {$ifndef VER3_0}
  263. { find init table }
  264. with RTTIRecordOp(typeinfo, typeinfo)^ do
  265. begin
  266. recordrtti(data,typeinfo,@int_addref);
  267. if Assigned(recordop) and Assigned(recordop^.AddRef) then
  268. recordop^.AddRef(Data);
  269. end;
  270. {$else VER3_0}
  271. begin
  272. typeinfo:=RTTIRecordRttiInfoToInitInfo(typeinfo);
  273. recordrtti(data,typeinfo,@int_addref);
  274. end;
  275. {$endif VER3_0}
  276. {$ifdef FPC_HAS_FEATURE_DYNARRAYS}
  277. tkDynArray:
  278. fpc_dynarray_incr_ref(PPointer(Data)^);
  279. {$endif FPC_HAS_FEATURE_DYNARRAYS}
  280. {$ifdef FPC_HAS_FEATURE_CLASSES}
  281. tkInterface:
  282. Intf_Incr_Ref(PPointer(Data)^);
  283. {$endif FPC_HAS_FEATURE_CLASSES}
  284. {$ifdef FPC_HAS_FEATURE_VARIANTS}
  285. tkVariant:
  286. variant_addref(pvardata(Data)^);
  287. {$endif FPC_HAS_FEATURE_DYNARRAYS}
  288. end;
  289. end;
  290. { define alias for internal use in the system unit }
  291. Function fpc_Copy_internal (Src, Dest, TypeInfo : Pointer) : SizeInt;[external name 'FPC_COPY'];
  292. Function fpc_Copy (Src, Dest, TypeInfo : Pointer) : SizeInt;[Public,alias : 'FPC_COPY']; compilerproc;
  293. var
  294. Temp: pbyte;
  295. copiedsize,
  296. expectedoffset,
  297. EleCount,
  298. offset,
  299. i: SizeInt;
  300. info: pointer;
  301. begin
  302. result:=sizeof(pointer);
  303. case PTypeKind(TypeInfo)^ of
  304. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  305. tkAstring:
  306. fpc_AnsiStr_Assign(PPointer(Dest)^,PPointer(Src)^);
  307. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  308. {$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
  309. {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
  310. tkWstring:
  311. fpc_WideStr_Assign(PPointer(Dest)^,PPointer(Src)^);
  312. {$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
  313. tkUstring:
  314. fpc_UnicodeStr_Assign(PPointer(Dest)^,PPointer(Src)^);
  315. {$endif FPC_HAS_FEATURE_WIDESTRINGS}
  316. tkArray:
  317. begin
  318. {$ifdef VER3_0}
  319. Temp:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
  320. {$else VER3_0}
  321. Temp:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]);
  322. {$endif VER3_0}
  323. Result:=PArrayInfo(Temp)^.Size;
  324. EleCount:=PArrayInfo(Temp)^.ElCount;
  325. { no elements to process => exit }
  326. if EleCount = 0 then
  327. Exit;
  328. Info:=PArrayInfo(Temp)^.ElInfo{$ifndef VER3_0}^{$endif};
  329. copiedsize:=Result div EleCount;
  330. Offset:=0;
  331. { Process elements }
  332. for I:=1 to EleCount do
  333. begin
  334. fpc_Copy_internal(Src+Offset,Dest+Offset,Info);
  335. inc(Offset,copiedsize);
  336. end;
  337. end;
  338. {$ifdef FPC_HAS_FEATURE_OBJECTS}
  339. tkobject,
  340. {$endif FPC_HAS_FEATURE_OBJECTS}
  341. tkrecord:
  342. {$ifndef VER3_0}
  343. { find init table }
  344. with RTTIRecordOp(typeinfo, typeinfo)^ do
  345. {$endif VER3_0}
  346. begin
  347. {$ifdef VER3_0}
  348. typeInfo:=RTTIRecordRttiInfoToInitInfo(typeInfo);
  349. Temp:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
  350. {$else VER3_0}
  351. Temp:=aligntoqword(typeInfo+2+PByte(typeInfo)[1]);
  352. {$endif VER3_0}
  353. {$ifndef VER3_0}
  354. if Assigned(recordop) and Assigned(recordop^.Copy) then
  355. begin
  356. recordop^.Copy(Src,Dest);
  357. Result:=PRecordInfoFull(Temp)^.Size;
  358. end
  359. else
  360. begin
  361. Result:=PRecordInfoInit(Temp)^.Size;
  362. EleCount:=PRecordInfoInit(Temp)^.Count;
  363. { Get element info, hacky, but what else can we do? }
  364. Temp:=AlignTypeData(Pointer(@PRecordInfoInit(Temp)^.Count)+SizeOf(PRecordInfoInit(Temp)^.Count));
  365. {$else VER3_0}
  366. Result:=PRecordInfoFull(Temp)^.Size;
  367. EleCount:=PRecordInfoFull(Temp)^.Count;
  368. { Get element info, hacky, but what else can we do? }
  369. Temp:=Pointer(@PRecordInfoFull(Temp)^.Count)+SizeOf(PRecordInfoFull(Temp)^.Count);
  370. {$endif VER3_0}
  371. expectedoffset:=0;
  372. { Process elements with rtti }
  373. for i:=1 to EleCount Do
  374. begin
  375. Info:=PRecordElement(Temp)^.TypeInfo{$ifndef VER3_0}^{$endif};
  376. Offset:=PRecordElement(Temp)^.Offset;
  377. Inc(PRecordElement(Temp));
  378. if Offset>expectedoffset then
  379. move((Src+expectedoffset)^,(Dest+expectedoffset)^,Offset-expectedoffset);
  380. copiedsize:=fpc_Copy_internal(Src+Offset,Dest+Offset,Info);
  381. expectedoffset:=Offset+copiedsize;
  382. end;
  383. { elements remaining? }
  384. if result>expectedoffset then
  385. move((Src+expectedoffset)^,(Dest+expectedoffset)^,Result-expectedoffset);
  386. {$ifndef VER3_0}
  387. end;
  388. {$endif VER3_0}
  389. end;
  390. {$ifdef FPC_HAS_FEATURE_DYNARRAYS}
  391. tkDynArray:
  392. fpc_dynarray_assign(PPointer(Dest)^,PPointer(Src)^,typeinfo);
  393. {$endif FPC_HAS_FEATURE_DYNARRAYS}
  394. {$ifdef FPC_HAS_FEATURE_CLASSES}
  395. tkInterface:
  396. fpc_intf_assign(PPointer(Dest)^,PPointer(Src)^);
  397. {$endif FPC_HAS_FEATURE_CLASSES}
  398. {$ifdef FPC_HAS_FEATURE_VARIANTS}
  399. tkVariant:
  400. begin
  401. VarCopyProc(pvardata(dest)^,pvardata(src)^);
  402. result:=sizeof(tvardata);
  403. end;
  404. {$endif FPC_HAS_FEATURE_VARIANTS}
  405. end;
  406. end;
  407. { For internal use by the compiler, because otherwise $x- can cause trouble. }
  408. { Generally disabling extended syntax checking for all compilerprocs may }
  409. { have unintended side-effects }
  410. procedure fpc_Copy_proc (Src, Dest, TypeInfo : Pointer);compilerproc; inline;
  411. begin
  412. fpc_copy_internal(src,dest,typeinfo);
  413. end;
  414. procedure fpc_initialize_array(data,typeinfo : pointer;count : SizeInt); [public,alias:'FPC_INITIALIZE_ARRAY']; compilerproc;
  415. var
  416. i, size : SizeInt;
  417. {$ifndef VER3_0}
  418. hasManagementOp: boolean;
  419. begin
  420. size:=RTTISizeAndOp(typeinfo, rotInitialize, hasManagementOp);
  421. if (size>0) or hasManagementOp then
  422. {$else VER3_0}
  423. begin
  424. size:=RTTISize(typeInfo);
  425. if size>0 then
  426. {$endif VER3_0}
  427. for i:=0 to count-1 do
  428. int_initialize(data+size*i,typeinfo);
  429. end;
  430. procedure fpc_finalize_array(data,typeinfo : pointer;count : SizeInt); [Public,Alias:'FPC_FINALIZE_ARRAY']; compilerproc;
  431. var
  432. i, size: SizeInt;
  433. {$ifndef VER3_0}
  434. hasManagementOp: boolean;
  435. begin
  436. size:=RTTISizeAndOp(typeinfo, rotFinalize, hasManagementOp);
  437. if (size>0) or hasManagementOp then
  438. {$else VER3_0}
  439. begin
  440. size:=RTTISize(typeInfo);
  441. if size>0 then
  442. {$endif VER3_0}
  443. for i:=0 to count-1 do
  444. int_finalize(data+size*i,typeinfo);
  445. end;
  446. procedure fpc_addref_array(data,typeinfo: pointer; count: SizeInt); [public,alias:'FPC_ADDREF_ARRAY']; compilerproc;
  447. var
  448. i, size: SizeInt;
  449. {$ifndef VER3_0}
  450. hasManagementOp: boolean;
  451. begin
  452. size:=RTTISizeAndOp(typeinfo, rotAddRef, hasManagementOp);
  453. if (size>0) or hasManagementOp then
  454. {$else VER3_0}
  455. begin
  456. size:=RTTISize(typeInfo);
  457. if size>0 then
  458. {$endif VER3_0}
  459. for i:=0 to count-1 do
  460. int_addref(data+size*i,typeinfo);
  461. end;
  462. { The following two procedures are now obsolete, needed only for bootstrapping }
  463. procedure fpc_decref (Data, TypeInfo : Pointer);[Public,alias : 'FPC_DECREF']; compilerproc;
  464. begin
  465. int_finalize(Data,TypeInfo);
  466. end;
  467. procedure fpc_decref_array(data,typeinfo: pointer; count: SizeInt); [public,alias:'FPC_DECREF_ARRAY']; compilerproc;
  468. begin
  469. int_finalizeArray(data,typeinfo,count);
  470. end;
  471. procedure InitializeArray(p, typeInfo: Pointer; count: SizeInt);
  472. external name 'FPC_INITIALIZE_ARRAY';
  473. procedure FinalizeArray(p, typeInfo: Pointer; count: SizeInt);
  474. external name 'FPC_FINALIZE_ARRAY';
  475. procedure CopyArray(dest, source, typeInfo: Pointer; count: SizeInt);
  476. var
  477. i, size: SizeInt;
  478. {$ifndef VER3_0}
  479. hasManagementOp: boolean;
  480. begin
  481. size:=RTTISizeAndOp(typeinfo, rotCopy, hasManagementOp);
  482. if (size>0) or hasManagementOp then
  483. {$else VER3_0}
  484. begin
  485. size:=RTTISize(typeInfo);
  486. if size>0 then
  487. {$endif VER3_0}
  488. for i:=0 to count-1 do
  489. fpc_Copy_internal(source+size*i, dest+size*i, typeInfo);
  490. end;