2
0

rttidecl.inc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2018 by Sven Barth
  4. member of the Free Pascal development team
  5. Contains various RTTI related, private declarations that are used inside
  6. the system unit before rtti.inc might be included.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
  14. {$define USE_PACKED}
  15. {$endif}
  16. {$ifdef VER2_6}
  17. {$define USE_PACKED}
  18. {$endif}
  19. {$ifndef VER3_0}
  20. { 3.1.1 and newer also (re)stores $MinEnumSize and $PackSet upon $Push/$Pop }
  21. {$push}
  22. {$endif}
  23. {$MINENUMSIZE 1 this saves a lot of memory }
  24. {$ifdef FPC_RTTI_PACKSET1}
  25. { for Delphi compatibility }
  26. {$packset 1}
  27. {$endif}
  28. type
  29. PTypeKind = ^TTypeKind;
  30. const
  31. // all potentially managed types
  32. tkManagedTypes = [tkAstring,tkWstring,tkUstring,tkArray,
  33. tkObject,tkRecord,tkDynArray,tkInterface,tkVariant];
  34. type
  35. PRecordElement=^TRecordElement;
  36. TRecordElement=
  37. {$ifdef USE_PACKED}
  38. packed
  39. {$endif USE_PACKED}
  40. record
  41. {$ifdef VER3_0}
  42. TypeInfo: Pointer;
  43. {$else}
  44. TypeInfo: PPointer;
  45. {$endif}
  46. {$ifdef VER2_6}
  47. Offset: Longint;
  48. {$else}
  49. Offset: SizeInt;
  50. {$endif}
  51. end;
  52. PRecordInfoFull=^TRecordInfoFull;
  53. TRecordInfoFull=
  54. {$ifdef USE_PACKED}
  55. packed
  56. {$endif USE_PACKED}
  57. record
  58. {$if declared(TRttiDataCommon)}
  59. Common: TRttiDataCommon;
  60. {$endif declared TRttiDataCommon}
  61. case TTypeKind of
  62. tkRecord: (
  63. {$ifndef VER3_0}
  64. InitTable: Pointer;
  65. {$endif VER3_0}
  66. Size: Longint;
  67. Count: Longint;
  68. { Elements: array[count] of TRecordElement }
  69. );
  70. { include for proper alignment }
  71. tkInt64: (
  72. dummy : Int64
  73. );
  74. end;
  75. PRecordInfoInit=^TRecordInfoInit;
  76. {$ifndef VER3_0}
  77. TRTTIRecVarOp=procedure(ARec: Pointer);
  78. TRTTIRecCopyOp=procedure(ASrc, ADest: Pointer);
  79. TRTTIRecOpType=(rotAny, rotInitialize, rotFinalize, rotAddRef, rotCopy);
  80. PRTTIRecordOpVMT=^TRTTIRecordOpVMT;
  81. TRTTIRecordOpVMT=
  82. {$ifdef USE_PACKED}
  83. packed
  84. {$endif USE_PACKED}
  85. record
  86. Initialize: TRTTIRecVarOp;
  87. Finalize: TRTTIRecVarOp;
  88. AddRef: TRTTIRecVarOp;
  89. Copy: TRTTIRecCopyOp;
  90. end;
  91. TRTTIRecordOpOffsetEntry =
  92. {$ifdef USE_PACKED}
  93. packed
  94. {$endif USE_PACKED}
  95. record
  96. ManagmentOperator: CodePointer;
  97. FieldOffset: SizeUInt;
  98. end;
  99. TRTTIRecordOpOffsetTable =
  100. {$ifdef USE_PACKED}
  101. packed
  102. {$endif USE_PACKED}
  103. record
  104. Count: LongWord;
  105. Entries: array[0..0] of TRTTIRecordOpOffsetEntry;
  106. end;
  107. PRTTIRecordOpOffsetTable = ^TRTTIRecordOpOffsetTable;
  108. TRecordInfoInit=
  109. {$ifdef USE_PACKED}
  110. packed
  111. {$endif USE_PACKED}
  112. record
  113. {$if declared(TRttiDataCommon)}
  114. Common: TRttiDataCommon;
  115. {$endif declared TRttiDataCommon}
  116. case TTypeKind of
  117. tkRecord: (
  118. Terminator: Pointer;
  119. Size: Longint;
  120. {$ifndef VER3_0}
  121. InitRecordOpTable: PRTTIRecordOpOffsetTable;
  122. RecordOp: PRTTIRecordOpVMT;
  123. {$endif VER3_0}
  124. Count: Longint;
  125. { Elements: array[count] of TRecordElement }
  126. );
  127. { include for proper alignment }
  128. tkInt64: (
  129. dummy : Int64
  130. );
  131. end;
  132. {$else VER3_0}
  133. TRecordInfoInit=TRecordInfoFull;
  134. {$endif VER3_0}
  135. PArrayInfo=^TArrayInfo;
  136. TArrayInfo=
  137. {$ifdef USE_PACKED}
  138. packed
  139. {$endif USE_PACKED}
  140. record
  141. {$if declared(TRttiDataCommon)}
  142. Common: TRttiDataCommon;
  143. {$endif declared TRttiDataCommon}
  144. case TTypeKind of
  145. tkArray: (
  146. Size: SizeInt;
  147. ElCount: SizeInt;
  148. {$ifdef VER3_0}
  149. ElInfo: Pointer;
  150. {$else}
  151. ElInfo: PPointer;
  152. {$endif}
  153. DimCount: Byte;
  154. Dims:array[0..255] of Pointer;
  155. );
  156. { include for proper alignment }
  157. tkInt64: (
  158. dummy : Int64
  159. );
  160. end;
  161. {$ifndef VER3_0}
  162. function RTTIRecordMopInitTable(ti: Pointer): PRTTIRecordOpOffsetTable; forward;
  163. {$endif VER3_0}
  164. {$ifdef VER3_0}
  165. {$MINENUMSIZE DEFAULT}
  166. {$PACKSET DEFAULT}
  167. {$else}
  168. {$pop}
  169. {$endif}