rttidecl.inc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. {$ifndef VER3_0}
  17. { 3.1.1 and newer also (re)stores $MinEnumSize and $PackSet upon $Push/$Pop }
  18. {$push}
  19. {$endif}
  20. {$MINENUMSIZE 1 this saves a lot of memory }
  21. {$ifdef FPC_RTTI_PACKSET1}
  22. { for Delphi compatibility }
  23. {$packset 1}
  24. {$endif}
  25. type
  26. PTypeKind = ^TTypeKind;
  27. const
  28. // all potentially managed types
  29. tkManagedTypes = [tkAstring,tkWstring,tkUstring,tkArray,
  30. tkObject,tkRecord,tkDynArray,tkInterface,tkVariant];
  31. type
  32. PRecordElement=^TRecordElement;
  33. TRecordElement=
  34. {$ifdef USE_PACKED}
  35. packed
  36. {$endif USE_PACKED}
  37. record
  38. {$ifdef VER3_0}
  39. TypeInfo: Pointer;
  40. {$else}
  41. TypeInfo: PPointer;
  42. {$endif}
  43. Offset: SizeInt;
  44. end;
  45. PRecordInfoFull=^TRecordInfoFull;
  46. TRecordInfoFull=
  47. {$ifdef USE_PACKED}
  48. packed
  49. {$endif USE_PACKED}
  50. record
  51. {$if declared(TRttiDataCommon)}
  52. Common: TRttiDataCommon;
  53. {$endif declared TRttiDataCommon}
  54. case TTypeKind of
  55. tkRecord: (
  56. {$ifndef VER3_0}
  57. InitTable: Pointer;
  58. {$endif VER3_0}
  59. Size: Longint;
  60. Count: Longint;
  61. { Elements: array[count] of TRecordElement }
  62. );
  63. { include for proper alignment }
  64. tkInt64: (
  65. dummy : Int64
  66. );
  67. end;
  68. PRecordInfoInit=^TRecordInfoInit;
  69. {$ifndef VER3_0}
  70. TRTTIRecVarOp=procedure(ARec: Pointer);
  71. TRTTIRecCopyOp=procedure(ASrc, ADest: Pointer);
  72. TRTTIRecOpType=(rotAny, rotInitialize, rotFinalize, rotAddRef, rotCopy);
  73. PRTTIRecordOpVMT=^TRTTIRecordOpVMT;
  74. TRTTIRecordOpVMT=
  75. {$ifdef USE_PACKED}
  76. packed
  77. {$endif USE_PACKED}
  78. record
  79. Initialize: TRTTIRecVarOp;
  80. Finalize: TRTTIRecVarOp;
  81. AddRef: TRTTIRecVarOp;
  82. Copy: TRTTIRecCopyOp;
  83. end;
  84. TRTTIRecordOpOffsetEntry =
  85. {$ifdef USE_PACKED}
  86. packed
  87. {$endif USE_PACKED}
  88. record
  89. ManagmentOperator: CodePointer;
  90. FieldOffset: SizeUInt;
  91. end;
  92. TRTTIRecordOpOffsetTable =
  93. {$ifdef USE_PACKED}
  94. packed
  95. {$endif USE_PACKED}
  96. record
  97. Count: LongWord;
  98. Entries: array[0..0] of TRTTIRecordOpOffsetEntry;
  99. end;
  100. PRTTIRecordOpOffsetTable = ^TRTTIRecordOpOffsetTable;
  101. TRecordInfoInit=
  102. {$ifdef USE_PACKED}
  103. packed
  104. {$endif USE_PACKED}
  105. record
  106. {$if declared(TRttiDataCommon)}
  107. Common: TRttiDataCommon;
  108. {$endif declared TRttiDataCommon}
  109. case TTypeKind of
  110. tkRecord: (
  111. Terminator: Pointer;
  112. Size: Longint;
  113. {$ifndef VER3_0}
  114. InitRecordOpTable: PRTTIRecordOpOffsetTable;
  115. RecordOp: PRTTIRecordOpVMT;
  116. {$endif VER3_0}
  117. Count: Longint;
  118. { Elements: array[count] of TRecordElement }
  119. );
  120. { include for proper alignment }
  121. tkInt64: (
  122. dummy : Int64
  123. );
  124. end;
  125. {$else VER3_0}
  126. TRecordInfoInit=TRecordInfoFull;
  127. {$endif VER3_0}
  128. PArrayInfo=^TArrayInfo;
  129. TArrayInfo=
  130. {$ifdef USE_PACKED}
  131. packed
  132. {$endif USE_PACKED}
  133. record
  134. {$if declared(TRttiDataCommon)}
  135. Common: TRttiDataCommon;
  136. {$endif declared TRttiDataCommon}
  137. case TTypeKind of
  138. tkArray: (
  139. Size: SizeInt;
  140. ElCount: SizeInt;
  141. {$ifdef VER3_0}
  142. ElInfo: Pointer;
  143. {$else}
  144. ElInfo: PPointer;
  145. {$endif}
  146. DimCount: Byte;
  147. Dims:array[0..255] of Pointer;
  148. );
  149. { include for proper alignment }
  150. tkInt64: (
  151. dummy : Int64
  152. );
  153. end;
  154. {$ifndef VER3_0}
  155. function RTTIRecordMopInitTable(ti: Pointer): PRTTIRecordOpOffsetTable; forward;
  156. {$endif VER3_0}
  157. {$ifdef VER3_0}
  158. {$MINENUMSIZE DEFAULT}
  159. {$PACKSET DEFAULT}
  160. {$else}
  161. {$pop}
  162. {$endif}