rttip.inc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by xxxx
  5. member of the Free Pascal development team
  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. { Run-Time type information routines - processor dependent part }
  13. Procedure Initialize (Data,TypeInfo : pointer);[Alias : 'FPC_INITIALIZE'];
  14. { this definition is sometimes (depending on switches)
  15. already defined or not so define it locally to avoid problems PM }
  16. Type
  17. Pbyte = ^Byte;
  18. Var Temp : PByte;
  19. I : longint;
  20. Size,Count : longint;
  21. TInfo : Pointer;
  22. begin
  23. Temp:=PByte(TypeInfo);
  24. case temp^ of
  25. tkLstring,tkWstring : PPchar(Data)^:=Nil;
  26. tkArray :
  27. begin
  28. temp:=Temp+1;
  29. I:=temp^;
  30. temp:=temp+(I+1); // skip name string;
  31. Size:=PArrayRec(Temp)^.Size; // get element size
  32. Count:=PArrayRec(Temp)^.Count; // get element Count
  33. TInfo:=PArrayRec(Temp)^.Info; // Get element info
  34. For I:=0 to Count-1 do
  35. Initialize (Data+(I*size),TInfo);
  36. end;
  37. tkrecord :
  38. begin
  39. Temp:=Temp+1;
  40. I:=Temp^;
  41. temp:=temp+(I+1); // skip name string;
  42. Size:=PRecRec(Temp)^.Size; // get record size; not needed.
  43. Count:=PRecRec(Temp)^.Count; // get element Count
  44. For I:=1 to count Do
  45. With PRecRec(Temp)^.elements[I] do
  46. Initialize (Data+Offset,Info);
  47. end;
  48. end;
  49. end;
  50. Procedure Finalize (Data,TypeInfo: Pointer);[Alias : 'FPC_FINALIZE'];
  51. { this definition is sometimes (depending on switches)
  52. already defined or not so define it locally to avoid problems PM }
  53. Type
  54. Pbyte = ^Byte;
  55. Var Temp : PByte;
  56. I : longint;
  57. Size,Count : longint;
  58. TInfo : Pointer;
  59. begin
  60. Temp:=PByte(TypeInfo);
  61. case temp^ of
  62. tkLstring,tkWstring : Decr_Ansi_ref(Data);
  63. tkArray :
  64. begin
  65. Temp:=Temp+1;
  66. I:=temp^;
  67. temp:=temp+(I+1); // skip name string;
  68. Size:=PArrayRec(Temp)^.Size; // get element size
  69. Count:=PArrayRec(Temp)^.Count; // get element Count
  70. TInfo:=PArrayRec(Temp)^.Info; // Get element info
  71. For I:=0 to Count-1 do
  72. Finalize (Data+(I*size),TInfo);
  73. end;
  74. tkrecord :
  75. begin
  76. Temp:=Temp+1;
  77. I:=Temp^;
  78. temp:=temp+(I+1); // skip name string;
  79. Size:=PRecRec(Temp)^.Size; // get record size; not needed.
  80. Count:=PRecRec(Temp)^.Count; // get element Count
  81. For I:=1 to count do
  82. With PRecRec(Temp)^.elements[I] do
  83. Finalize (Data+Offset,Info);
  84. end;
  85. end;
  86. end;
  87. Procedure Addref (Data,TypeInfo : Pointer); [alias : 'FPC_ADDREF'];
  88. { this definition is sometimes (depending on switches)
  89. already defined or not so define it locally to avoid problems PM }
  90. Type
  91. Pbyte = ^Byte;
  92. Var Temp : PByte;
  93. I : longint;
  94. Size,Count : longint;
  95. TInfo : Pointer;
  96. begin
  97. Temp:=PByte(TypeInfo);
  98. case temp^ of
  99. tkLstring,tkWstring : Incr_Ansi_ref(Data);
  100. tkArray :
  101. begin
  102. Temp:=Temp+1;
  103. I:=temp^;
  104. temp:=temp+(I+1); // skip name string;
  105. Size:=PArrayRec(Temp)^.Size; // get element size
  106. Count:=PArrayRec(Temp)^.Count; // get element Count
  107. TInfo:=PArrayRec(Temp)^.Info; // Get element info
  108. For I:=0 to Count-1 do
  109. AddRef (Data+(I*size),TInfo);
  110. end;
  111. tkrecord :
  112. begin
  113. Temp:=Temp+1;
  114. I:=Temp^;
  115. temp:=temp+(I+1); // skip name string;
  116. Size:=PRecRec(Temp)^.Size; // get record size; not needed.
  117. Count:=PRecRec(Temp)^.Count; // get element Count
  118. For I:=1 to count do
  119. With PRecRec(Temp)^.elements[I] do
  120. AddRef (Data+Offset,Info);
  121. end;
  122. end;
  123. end;
  124. Procedure DecRef (Data, TypeInfo : Pointer);[Public,alias : 'FPC_DECREF'];
  125. { this definition is sometimes (depending on switches)
  126. already defined or not so define it locally to avoid problems PM }
  127. Type
  128. Pbyte = ^Byte;
  129. Var Temp : PByte;
  130. I : longint;
  131. Size,Count : longint;
  132. TInfo : Pointer;
  133. begin
  134. Temp:=PByte(TypeInfo);
  135. case temp^ of
  136. tkLstring,tkWstring : Decr_Ansi_ref(Data);
  137. tkArray :
  138. begin
  139. Temp:=Temp+1;
  140. I:=temp^;
  141. temp:=temp+(I+1); // skip name string;
  142. Size:=PArrayRec(Temp)^.Size; // get element size
  143. Count:=PArrayRec(Temp)^.Count; // get element Count
  144. TInfo:=PArrayRec(Temp)^.Info; // Get element info
  145. For I:=0 to Count-1 do
  146. DecRef (Data+(I*size),TInfo);
  147. end;
  148. tkrecord :
  149. begin
  150. Temp:=Temp+1;
  151. I:=Temp^;
  152. temp:=temp+(I+1); // skip name string;
  153. Size:=PRecRec(Temp)^.Size; // get record size; not needed.
  154. Count:=PRecRec(Temp)^.Count; // get element Count
  155. For I:=1 to count do
  156. With PRecRec(Temp)^.elements[I] do
  157. DecRef (Data+Offset,Info);
  158. end;
  159. end;
  160. end;
  161. {
  162. $Log$
  163. Revision 1.2 2000-07-13 11:33:50 michael
  164. + removed logs
  165. }