objpash.inc 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. This unit makes Free Pascal as much as possible Delphi compatible
  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. {*****************************************************************************
  13. Basic Types/constants
  14. *****************************************************************************}
  15. const
  16. {$ifdef NEWVMTOFFSET}
  17. vmtInstanceSize = 0;
  18. vmtParent = 8;
  19. { These were negative value's, but are now positive, else classes
  20. couldn't be used with shared linking which copies only all data from
  21. the .global directive and not the data before the directive (PFV) }
  22. vmtClassName = 12;
  23. vmtDynamicTable = 16;
  24. vmtMethodTable = 20;
  25. vmtFieldTable = 24;
  26. vmtTypeInfo = 28;
  27. vmtInitTable = 32;
  28. vmtAutoTable = 36;
  29. vmtIntfTable = 40;
  30. vmtMsgStrPtr = 44;
  31. { methods }
  32. vmtMethodStart = 48;
  33. vmtDestroy = vmtMethodStart;
  34. vmtNewInstance = vmtMethodStart+4;
  35. vmtFreeInstance = vmtMethodStart+8;
  36. vmtSafeCallException = vmtMethodStart+12;
  37. vmtDefaultHandler = vmtMethodStart+16;
  38. vmtAfterConstruction = vmtMethodStart+20;
  39. vmtBeforeDestruction = vmtMethodStart+24;
  40. vmtDefaultHandlerStr = vmtMethodStart+28;
  41. {$else}
  42. vmtMsgStrPtr = -36;
  43. vmtIntfTable = -32;
  44. vmtAutoTable = -28;
  45. vmtInitTable = -24;
  46. vmtTypeInfo = -20;
  47. vmtFieldTable = -16;
  48. vmtMethodTable = -12;
  49. vmtDynamicTable = -8;
  50. vmtClassName = -4;
  51. vmtInstanceSize = 0;
  52. vmtParent = 8;
  53. vmtDestroy = 12;
  54. vmtNewInstance = 16;
  55. vmtFreeInstance = 20;
  56. vmtSafeCallException = 24;
  57. vmtDefaultHandler = 28;
  58. vmtAfterConstruction = 32;
  59. vmtBeforeDestruction = 36;
  60. vmtDefaultHandlerStr = 40;
  61. {$endif}
  62. type
  63. { some pointer definitions }
  64. pshortstring = ^shortstring;
  65. plongstring = ^longstring;
  66. pansistring = ^ansistring;
  67. pwidestring = ^widestring;
  68. // pstring = pansistring;
  69. pextended = ^extended;
  70. ppointer = ^pointer;
  71. { now the let's declare the base classes for the class object }
  72. { model }
  73. tobject = class;
  74. tclass = class of tobject;
  75. pclass = ^tclass;
  76. { to access the message table from outside }
  77. tmsgstrtable = record
  78. name : pshortstring;
  79. method : pointer;
  80. end;
  81. pmsgstrtable = ^tmsgstrtable;
  82. tstringmessagetable = record
  83. count : dword;
  84. msgstrtable : array[0..0] of tmsgstrtable;
  85. end;
  86. pstringmessagetable = ^tstringmessagetable;
  87. tobject = class
  88. public
  89. { please don't change the order of virtual methods, because }
  90. { their vmt offsets are used by some assembler code which uses }
  91. { hard coded addresses (FK) }
  92. constructor create;
  93. { the virtual procedures must be in THAT order }
  94. destructor destroy;virtual;
  95. class function newinstance : tobject;virtual;
  96. procedure freeinstance;virtual;
  97. function safecallexception(exceptobject : tobject;
  98. exceptaddr : pointer) : longint;virtual;
  99. procedure defaulthandler(var message);virtual;
  100. procedure free;
  101. class function initinstance(instance : pointer) : tobject;
  102. procedure cleanupinstance;
  103. function classtype : tclass;
  104. class function classinfo : pointer;
  105. class function classname : shortstring;
  106. class function classnameis(const name : string) : boolean;
  107. class function classparent : tclass;
  108. class function instancesize : longint;
  109. class function inheritsfrom(aclass : tclass) : boolean;
  110. class function stringmessagetable : pstringmessagetable;
  111. { message handling routines }
  112. procedure dispatch(var message);
  113. procedure dispatchstr(var message);
  114. class function methodaddress(const name : shortstring) : pointer;
  115. class function methodname(address : pointer) : shortstring;
  116. function fieldaddress(const name : shortstring) : pointer;
  117. { new since Delphi 4 }
  118. procedure AfterConstruction;virtual;
  119. procedure BeforeDestruction;virtual;
  120. { new for gtk, default handler for text based messages }
  121. procedure DefaultHandlerStr(var message);virtual;
  122. { interface functions, I don't know if we need this }
  123. {
  124. function getinterface(const iid : tguid;out obj) : boolean;
  125. class function getinterfaceentry(const iid : tguid) : pinterfaceentry;
  126. class function getinterfacetable : pinterfacetable;
  127. }
  128. end;
  129. TExceptProc = Procedure (Obj : TObject; Addr,Frame: Pointer);
  130. { Exception object stack }
  131. PExceptObject = ^TExceptObject;
  132. TExceptObject = record
  133. FObject : TObject;
  134. Addr,
  135. Frame : pointer;
  136. Next : PExceptObject;
  137. end;
  138. Const
  139. ExceptProc : TExceptProc = Nil;
  140. Function RaiseList : PExceptObject;
  141. {*****************************************************************************
  142. Variant Type
  143. *****************************************************************************}
  144. Const
  145. varEmpty = $0000;
  146. varNull = $0001;
  147. varSmallint = $0002;
  148. varInteger = $0003;
  149. varSingle = $0004;
  150. varDouble = $0005;
  151. varCurrency = $0006;
  152. varDate = $0007;
  153. varOleStr = $0008;
  154. varDispatch = $0009;
  155. varError = $000A;
  156. varBoolean = $000B;
  157. varVariant = $000C;
  158. varUnknown = $000D;
  159. varByte = $0011;
  160. varString = $0100;
  161. varAny = $0101;
  162. varTypeMask = $0FFF;
  163. varArray = $2000;
  164. varByRef = $4000;
  165. vtInteger = 0;
  166. vtBoolean = 1;
  167. vtChar = 2;
  168. vtExtended = 3;
  169. vtString = 4;
  170. vtPointer = 5;
  171. vtPChar = 6;
  172. vtObject = 7;
  173. vtClass = 8;
  174. vtWideChar = 9;
  175. vtPWideChar = 10;
  176. vtAnsiString = 11;
  177. vtCurrency = 12;
  178. vtVariant = 13;
  179. vtInterface = 14;
  180. vtWideString = 15;
  181. vtInt64 = 16;
  182. vtQWord = 17;
  183. Type
  184. PVarRec = ^TVarRec;
  185. TVarRec = record
  186. case VType : Longint of
  187. vtInteger : (VInteger: Longint);
  188. vtBoolean : (VBoolean: Boolean);
  189. vtChar : (VChar: Char);
  190. vtExtended : (VExtended: PExtended);
  191. vtString : (VString: PShortString);
  192. vtPointer : (VPointer: Pointer);
  193. vtPChar : (VPChar: PChar);
  194. vtObject : (VObject: TObject);
  195. vtClass : (VClass: TClass);
  196. // vtWideChar : (VWideChar: WideChar);
  197. // vtPWideChar : (VPWideChar: PWideChar);
  198. vtAnsiString : (VAnsiString: Pointer);
  199. // vtCurrency : (VCurrency: PCurrency);
  200. // vtVariant : (VVariant: PVariant);
  201. // vtInterface : (VInterface: Pointer);
  202. vtWideString : (VWideString: Pointer);
  203. vtInt64 : (VInt64: PInt64);
  204. vtQWord : (VQWord: PQWord);
  205. end;
  206. {
  207. $Log$
  208. Revision 1.11 2000-06-22 18:05:56 michael
  209. + Modifications for exception support in sysutils. Mainly added
  210. RaiseList function.
  211. Revision 1.10 2000/05/14 18:47:53 florian
  212. * TVarRec with Int64/QWord stuff extended
  213. Revision 1.9 2000/04/24 11:11:50 peter
  214. * backtraces for exceptions are now only generated from the place of the
  215. exception
  216. * frame is also pushed for exceptions
  217. * raise statement enhanced with [,<frame>]
  218. Revision 1.8 2000/02/09 16:59:31 peter
  219. * truncated log
  220. Revision 1.7 2000/01/07 16:41:36 daniel
  221. * copyright 2000
  222. Revision 1.6 2000/01/07 16:32:25 daniel
  223. * copyright 2000 added
  224. Revision 1.5 1999/12/02 19:28:53 peter
  225. * public added to TObject
  226. Revision 1.4 1999/08/09 22:20:03 peter
  227. * classes vmt changed to only positive addresses
  228. * sharedlib creation is working
  229. }