sysutilh.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Florian Klaempfl
  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. { Read date & Time function declarations }
  13. {$i osutilsh.inc}
  14. {$i datih.inc}
  15. { Read String Handling functions declaration }
  16. {$i sysstrh.inc}
  17. type
  18. { some helpful data types }
  19. {$IFDEF VER1_0}
  20. (* System type alias cannot be used under version *)
  21. (* 1.0 because of different names of System unit. *)
  22. THandle = longint;
  23. {$ELSE VER1_0}
  24. THandle = System.THandle;
  25. {$ENDIF VER1_0}
  26. tprocedure = procedure;
  27. tfilename = string;
  28. tsyscharset = set of char;
  29. tintegerset = set of 0..sizeof(integer)*8-1;
  30. longrec = packed record
  31. case integer of
  32. 0 : (lo,hi : word);
  33. 1 : (bytes : array[0..3] of byte);
  34. end;
  35. wordrec = packed record
  36. lo,hi : byte;
  37. end;
  38. int64rec = packed record
  39. case integer of
  40. 0 : (lo,hi : cardinal);
  41. 1 : (words : array[0..3] of word);
  42. 2 : (bytes : array[0..7] of byte);
  43. end;
  44. pbytearray = ^tbytearray;
  45. tbytearray = array[0..32767] of byte;
  46. pwordarray = ^twordarray;
  47. twordarray = array[0..16383] of word;
  48. TMethod = packed record
  49. Code, Data: Pointer;
  50. end;
  51. { exceptions }
  52. Exception = class(TObject)
  53. private
  54. fmessage : string;
  55. fhelpcontext : longint;
  56. public
  57. constructor Create(const msg : string);
  58. constructor CreateFmt(const msg : string; const args : array of const);
  59. constructor CreateRes(ResString: PString);
  60. constructor CreateResFmt(ResString: PString; const Args: array of const);
  61. constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  62. constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  63. AHelpContext: Integer);
  64. constructor CreateResHelp(ResString: PString; AHelpContext: Integer);
  65. constructor CreateResFmtHelp(ResString: PString; const Args: array of const;
  66. AHelpContext: Integer);
  67. { !!!! }
  68. property helpcontext : longint read fhelpcontext write fhelpcontext;
  69. property message : string read fmessage write fmessage;
  70. end;
  71. ExceptClass = class of Exception;
  72. EExternal = class(Exception)
  73. public
  74. {$ifdef win32}
  75. ExceptionRecord : PExceptionRecord;
  76. {$endif win32}
  77. end;
  78. { integer math exceptions }
  79. EInterror = Class(EExternal);
  80. EDivByZero = Class(EIntError);
  81. ERangeError = Class(EIntError);
  82. EIntOverflow = Class(EIntError);
  83. { General math errors }
  84. EMathError = Class(EExternal);
  85. EInvalidOp = Class(EMathError);
  86. EZeroDivide = Class(EMathError);
  87. EOverflow = Class(EMathError);
  88. EUnderflow = Class(EMathError);
  89. { Run-time and I/O Errors }
  90. EInOutError = class(Exception)
  91. public
  92. ErrorCode : Longint;
  93. end;
  94. EHeapMemoryError = class(Exception)
  95. protected
  96. AllowFree : boolean;
  97. procedure FreeInstance;override;
  98. end;
  99. EHeapException = EHeapMemoryError;
  100. EExternalException = class(EExternal);
  101. EInvalidPointer = Class(EHeapMemoryError);
  102. EOutOfMemory = Class(EHeapMemoryError);
  103. EInvalidCast = Class(Exception);
  104. EVariantError = Class(Exception);
  105. EAccessViolation = Class(EExternal);
  106. EPrivilege = class(EExternal);
  107. EStackOverflow = class(EExternal);
  108. EControlC = class(EExternal);
  109. { String conversion errors }
  110. EConvertError = class(Exception);
  111. { Other errors }
  112. EAbort = Class(Exception);
  113. EAbstractError = Class(Exception);
  114. EAssertionFailed = Class(Exception);
  115. EPropReadOnly = class(Exception);
  116. EPropWriteOnly = class(Exception);
  117. EIntfCastError = class(Exception);
  118. EInvalidContainer = class(Exception);
  119. EInvalidInsert = class(Exception);
  120. EPackageError = class(Exception);
  121. ESafecallException = class(Exception);
  122. ENoThreadSupport = Class(Exception);
  123. { Exception handling routines }
  124. function ExceptObject: TObject;
  125. function ExceptAddr: Pointer;
  126. function ExceptionErrorMessage(ExceptObject: TObject; ExceptAddr: Pointer;
  127. Buffer: PChar; Size: Integer): Integer;
  128. procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
  129. procedure Abort;
  130. procedure OutOfMemoryError;
  131. procedure Beep;
  132. function SysErrorMessage(ErrorCode: Integer): String;
  133. Var
  134. OnShowException : Procedure (Msg : ShortString);
  135. { FileRec/TextRec }
  136. {$i filerec.inc}
  137. {$i textrec.inc}
  138. Const
  139. HexDisplayPrefix : string = '$';
  140. const
  141. // commenting is VP fix. These idents are in a different unit there.
  142. PathDelim={System.}DirectorySeparator;
  143. DriveDelim={System.}DriveSeparator;
  144. PathSep={System.}PathSeparator;
  145. Type
  146. TFileRec=FileRec;
  147. TTextRec=TextRec;
  148. { Read internationalization settings }
  149. {$i sysinth.inc}
  150. { Read pchar handling functions declaration }
  151. {$IFNDEF VIRTUALPASCAL}
  152. {$i syspchh.inc}
  153. {$ENDIF}
  154. { MCBS functions }
  155. {$i sysansih.inc}
  156. { Read filename handling functions declaration }
  157. {$i finah.inc}
  158. { Read other file handling function declarations }
  159. {$i filutilh.inc}
  160. { Read disk function declarations }
  161. {$i diskh.inc}
  162. { read thread handling }
  163. {$i systhrdh.inc}
  164. procedure FreeAndNil(var obj);
  165. {$ifdef HASINTF}
  166. { interface handling }
  167. {$i intfh.inc}
  168. {$endif HASINTF}
  169. {
  170. $Log$
  171. Revision 1.4 2003-11-26 20:12:08 michael
  172. + New runerror 231 (exception stack error) and 232 (nothread support)
  173. Revision 1.3 2003/11/26 20:00:19 florian
  174. * error handling for Variants improved
  175. Revision 1.2 2003/10/25 23:43:59 hajny
  176. * THandle in sysutils common using System.THandle
  177. Revision 1.1 2003/10/06 21:01:06 peter
  178. * moved classes unit to rtl
  179. Revision 1.20 2003/09/06 20:49:54 marco
  180. * Two minimal VP fixes
  181. Revision 1.19 2003/01/01 20:58:07 florian
  182. + added invalid instruction exception
  183. Revision 1.18 2002/10/07 19:43:24 florian
  184. + empty prototypes for the AnsiStr* multi byte functions added
  185. Revision 1.17 2002/09/07 16:01:22 peter
  186. * old logs removed and tabs fixed
  187. Revision 1.16 2002/01/25 17:42:03 peter
  188. * interface helpers
  189. }