objpash.inc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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: Pointer);
  130. Const
  131. ExceptProc : Pointer {TExceptProc} = Nil;
  132. {*****************************************************************************
  133. Variant Type
  134. *****************************************************************************}
  135. Const
  136. varEmpty = $0000;
  137. varNull = $0001;
  138. varSmallint = $0002;
  139. varInteger = $0003;
  140. varSingle = $0004;
  141. varDouble = $0005;
  142. varCurrency = $0006;
  143. varDate = $0007;
  144. varOleStr = $0008;
  145. varDispatch = $0009;
  146. varError = $000A;
  147. varBoolean = $000B;
  148. varVariant = $000C;
  149. varUnknown = $000D;
  150. varByte = $0011;
  151. varString = $0100;
  152. varAny = $0101;
  153. varTypeMask = $0FFF;
  154. varArray = $2000;
  155. varByRef = $4000;
  156. vtInteger = 0;
  157. vtBoolean = 1;
  158. vtChar = 2;
  159. vtExtended = 3;
  160. vtString = 4;
  161. vtPointer = 5;
  162. vtPChar = 6;
  163. vtObject = 7;
  164. vtClass = 8;
  165. vtWideChar = 9;
  166. vtPWideChar = 10;
  167. vtAnsiString = 11;
  168. vtCurrency = 12;
  169. vtVariant = 13;
  170. vtInterface = 14;
  171. vtWideString = 15;
  172. vtInt64 = 16;
  173. Type
  174. PVarRec = ^TVarRec;
  175. TVarRec = record
  176. case VType : Longint of
  177. vtInteger : (VInteger: Longint);
  178. vtBoolean : (VBoolean: Boolean);
  179. vtChar : (VChar: Char);
  180. vtExtended : (VExtended: PExtended);
  181. vtString : (VString: PShortString);
  182. vtPointer : (VPointer: Pointer);
  183. vtPChar : (VPChar: PChar);
  184. vtObject : (VObject: TObject);
  185. vtClass : (VClass: TClass);
  186. // vtWideChar : (VWideChar: WideChar);
  187. // vtPWideChar : (VPWideChar: PWideChar);
  188. vtAnsiString : (VAnsiString: Pointer);
  189. // vtCurrency : (VCurrency: PCurrency);
  190. // vtVariant : (VVariant: PVariant);
  191. // vtInterface : (VInterface: Pointer);
  192. vtWideString : (VWideString: Pointer);
  193. // vtInt64 : (VInt64: PInt64);
  194. end;
  195. {
  196. $Log$
  197. Revision 1.8 2000-02-09 16:59:31 peter
  198. * truncated log
  199. Revision 1.7 2000/01/07 16:41:36 daniel
  200. * copyright 2000
  201. Revision 1.6 2000/01/07 16:32:25 daniel
  202. * copyright 2000 added
  203. Revision 1.5 1999/12/02 19:28:53 peter
  204. * public added to TObject
  205. Revision 1.4 1999/08/09 22:20:03 peter
  206. * classes vmt changed to only positive addresses
  207. * sharedlib creation is working
  208. }