objpash.inc 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1998,99 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. // vmtSelfPtr = -36; { not implemented yet }
  17. vmtMsgStrPtr = -36;
  18. vmtIntfTable = -32;
  19. vmtAutoTable = -28;
  20. vmtInitTable = -24;
  21. vmtTypeInfo = -20;
  22. vmtFieldTable = -16;
  23. vmtMethodTable = -12;
  24. vmtDynamicTable = -8;
  25. vmtClassName = -4;
  26. vmtInstanceSize = 0;
  27. vmtParent = 8;
  28. vmtDestroy = 12;
  29. vmtNewInstance = 16;
  30. vmtFreeInstance = 20;
  31. vmtSafeCallException = 24;
  32. vmtDefaultHandler = 28;
  33. vmtAfterConstruction = 32;
  34. vmtBeforeDestruction = 36;
  35. vmtDefaultHandlerStr = 40;
  36. type
  37. { some pointer definitions }
  38. pshortstring = ^shortstring;
  39. plongstring = ^longstring;
  40. pansistring = ^ansistring;
  41. pwidestring = ^widestring;
  42. // pstring = pansistring;
  43. pextended = ^extended;
  44. ppointer = ^pointer;
  45. { now the let's declare the base classes for the class object }
  46. { model }
  47. tobject = class;
  48. tclass = class of tobject;
  49. pclass = ^tclass;
  50. { to access the message table from outside }
  51. tmsgstrtable = record
  52. name : pshortstring;
  53. method : pointer;
  54. end;
  55. pmsgstrtable = ^tmsgstrtable;
  56. tstringmessagetable = record
  57. count : dword;
  58. msgstrtable : array[0..0] of tmsgstrtable;
  59. end;
  60. pstringmessagetable = ^tstringmessagetable;
  61. tobject = class
  62. { please don't change the order of virtual methods, because }
  63. { their vmt offsets are used by some assembler code which uses }
  64. { hard coded addresses (FK) }
  65. constructor create;
  66. { the virtual procedures must be in THAT order }
  67. destructor destroy;virtual;
  68. class function newinstance : tobject;virtual;
  69. procedure freeinstance;virtual;
  70. function safecallexception(exceptobject : tobject;
  71. exceptaddr : pointer) : longint;virtual;
  72. procedure defaulthandler(var message);virtual;
  73. procedure free;
  74. class function initinstance(instance : pointer) : tobject;
  75. procedure cleanupinstance;
  76. function classtype : tclass;
  77. class function classinfo : pointer;
  78. class function classname : shortstring;
  79. class function classnameis(const name : string) : boolean;
  80. class function classparent : tclass;
  81. class function instancesize : longint;
  82. class function inheritsfrom(aclass : tclass) : boolean;
  83. class function stringmessagetable : pstringmessagetable;
  84. { message handling routines }
  85. procedure dispatch(var message);
  86. procedure dispatchstr(var message);
  87. class function methodaddress(const name : shortstring) : pointer;
  88. class function methodname(address : pointer) : shortstring;
  89. function fieldaddress(const name : shortstring) : pointer;
  90. { new since Delphi 4 }
  91. procedure AfterConstruction;virtual;
  92. procedure BeforeDestruction;virtual;
  93. { new for gtk, default handler for text based messages }
  94. procedure DefaultHandlerStr(var message);virtual;
  95. { interface functions, I don't know if we need this }
  96. {
  97. function getinterface(const iid : tguid;out obj) : boolean;
  98. class function getinterfaceentry(const iid : tguid) : pinterfaceentry;
  99. class function getinterfacetable : pinterfacetable;
  100. }
  101. end;
  102. TExceptProc = Procedure (Obj : TObject; Addr: Pointer);
  103. Const
  104. ExceptProc : Pointer {TExceptProc} = Nil;
  105. {*****************************************************************************
  106. Variant Type
  107. *****************************************************************************}
  108. Const
  109. varEmpty = $0000;
  110. varNull = $0001;
  111. varSmallint = $0002;
  112. varInteger = $0003;
  113. varSingle = $0004;
  114. varDouble = $0005;
  115. varCurrency = $0006;
  116. varDate = $0007;
  117. varOleStr = $0008;
  118. varDispatch = $0009;
  119. varError = $000A;
  120. varBoolean = $000B;
  121. varVariant = $000C;
  122. varUnknown = $000D;
  123. varByte = $0011;
  124. varString = $0100;
  125. varAny = $0101;
  126. varTypeMask = $0FFF;
  127. varArray = $2000;
  128. varByRef = $4000;
  129. vtInteger = 0;
  130. vtBoolean = 1;
  131. vtChar = 2;
  132. vtExtended = 3;
  133. vtString = 4;
  134. vtPointer = 5;
  135. vtPChar = 6;
  136. vtObject = 7;
  137. vtClass = 8;
  138. vtWideChar = 9;
  139. vtPWideChar = 10;
  140. vtAnsiString = 11;
  141. vtCurrency = 12;
  142. vtVariant = 13;
  143. vtInterface = 14;
  144. vtWideString = 15;
  145. vtInt64 = 16;
  146. Type
  147. PVarRec = ^TVarRec;
  148. TVarRec = record
  149. case VType : Longint of
  150. vtInteger : (VInteger: Longint);
  151. vtBoolean : (VBoolean: Boolean);
  152. vtChar : (VChar: Char);
  153. vtExtended : (VExtended: PExtended);
  154. vtString : (VString: PShortString);
  155. vtPointer : (VPointer: Pointer);
  156. vtPChar : (VPChar: PChar);
  157. vtObject : (VObject: TObject);
  158. vtClass : (VClass: TClass);
  159. // vtWideChar : (VWideChar: WideChar);
  160. // vtPWideChar : (VPWideChar: PWideChar);
  161. vtAnsiString : (VAnsiString: Pointer);
  162. // vtCurrency : (VCurrency: PCurrency);
  163. // vtVariant : (VVariant: PVariant);
  164. // vtInterface : (VInterface: Pointer);
  165. vtWideString : (VWideString: Pointer);
  166. // vtInt64 : (VInt64: PInt64);
  167. end;
  168. {
  169. $Log$
  170. Revision 1.3 1999-05-17 21:52:38 florian
  171. * most of the Object Pascal stuff moved to the system unit
  172. }