sysutilh.inc 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. TIntegerSet = Set of 0..SizeOf(Integer)*8-1;
  29. LongRec = packed record
  30. case Integer of
  31. 0 : (Lo,Hi : Word);
  32. 1 : (Bytes : Array[0..3] of Byte);
  33. end;
  34. WordRec = packed record
  35. Lo,Hi : Byte;
  36. end;
  37. Int64Rec = packed record
  38. case integer of
  39. 0 : (Lo,Hi : Cardinal);
  40. 1 : (Words : Array[0..3] of Word);
  41. 2 : (Bytes : Array[0..7] of Byte);
  42. end;
  43. PByteArray = ^TByteArray;
  44. TByteArray = Array[0..32767] of Byte;
  45. PWordarray = ^TWordArray;
  46. TWordArray = array[0..16383] of Word;
  47. TMethod = packed record
  48. Code, Data: Pointer;
  49. end;
  50. { exceptions }
  51. Exception = class(TObject)
  52. private
  53. fmessage : string;
  54. fhelpcontext : longint;
  55. public
  56. constructor Create(const msg : string);
  57. constructor CreateFmt(const msg : string; const args : array of const);
  58. constructor CreateRes(ResString: PString);
  59. constructor CreateResFmt(ResString: PString; const Args: array of const);
  60. constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  61. constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  62. AHelpContext: Integer);
  63. constructor CreateResHelp(ResString: PString; AHelpContext: Integer);
  64. constructor CreateResFmtHelp(ResString: PString; const Args: array of const;
  65. AHelpContext: Integer);
  66. { !!!! }
  67. property HelpContext : longint read fhelpcontext write fhelpcontext;
  68. property Message : string read fmessage write fmessage;
  69. end;
  70. ExceptClass = class of Exception;
  71. EExternal = class(Exception)
  72. public
  73. {$ifdef win32}
  74. ExceptionRecord : PExceptionRecord;
  75. {$endif win32}
  76. end;
  77. { integer math exceptions }
  78. EInterror = Class(EExternal);
  79. EDivByZero = Class(EIntError);
  80. ERangeError = Class(EIntError);
  81. EIntOverflow = Class(EIntError);
  82. { General math errors }
  83. EMathError = Class(EExternal);
  84. EInvalidOp = Class(EMathError);
  85. EZeroDivide = Class(EMathError);
  86. EOverflow = Class(EMathError);
  87. EUnderflow = Class(EMathError);
  88. { Run-time and I/O Errors }
  89. EInOutError = class(Exception)
  90. public
  91. ErrorCode : Longint;
  92. end;
  93. EHeapMemoryError = class(Exception)
  94. protected
  95. AllowFree : boolean;
  96. procedure FreeInstance;override;
  97. end;
  98. EHeapException = EHeapMemoryError;
  99. EExternalException = class(EExternal);
  100. EInvalidPointer = Class(EHeapMemoryError);
  101. EOutOfMemory = Class(EHeapMemoryError);
  102. EInvalidCast = Class(Exception);
  103. EVariantError = Class(Exception);
  104. EAccessViolation = Class(EExternal);
  105. EPrivilege = class(EExternal);
  106. EStackOverflow = class(EExternal);
  107. EControlC = class(EExternal);
  108. { String conversion errors }
  109. EConvertError = class(Exception);
  110. { Other errors }
  111. EAbort = Class(Exception);
  112. EAbstractError = Class(Exception);
  113. EAssertionFailed = Class(Exception);
  114. EPropReadOnly = class(Exception);
  115. EPropWriteOnly = class(Exception);
  116. EIntfCastError = class(Exception);
  117. EInvalidContainer = class(Exception);
  118. EInvalidInsert = class(Exception);
  119. EPackageError = class(Exception);
  120. EOSError = class(Exception)
  121. public
  122. ErrorCode: Longint;
  123. end;
  124. ESafecallException = class(Exception);
  125. ENoThreadSupport = Class(Exception);
  126. { Exception handling routines }
  127. function ExceptObject: TObject;
  128. function ExceptAddr: Pointer;
  129. function ExceptionErrorMessage(ExceptObject: TObject; ExceptAddr: Pointer;
  130. Buffer: PChar; Size: Integer): Integer;
  131. procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
  132. procedure Abort;
  133. procedure OutOfMemoryError;
  134. procedure Beep;
  135. function SysErrorMessage(ErrorCode: Integer): String;
  136. type
  137. TTerminateProc = Function: Boolean;
  138. procedure AddTerminateProc(TermProc: TTerminateProc);
  139. function CallTerminateProcs: Boolean;
  140. Var
  141. OnShowException : Procedure (Msg : ShortString);
  142. { FileRec/TextRec }
  143. {$i filerec.inc}
  144. {$i textrec.inc}
  145. Const
  146. HexDisplayPrefix : string = '$';
  147. const
  148. // commenting is VP fix. These idents are in a different unit there.
  149. PathDelim={System.}DirectorySeparator;
  150. DriveDelim={System.}DriveSeparator;
  151. PathSep={System.}PathSeparator;
  152. Type
  153. TFileRec=FileRec;
  154. TTextRec=TextRec;
  155. { Read internationalization settings }
  156. {$i sysinth.inc}
  157. { Read pchar handling functions declaration }
  158. {$IFNDEF VIRTUALPASCAL}
  159. {$i syspchh.inc}
  160. {$ENDIF}
  161. { MCBS functions }
  162. {$i sysansih.inc}
  163. { Read filename handling functions declaration }
  164. {$i finah.inc}
  165. { Read other file handling function declarations }
  166. {$i filutilh.inc}
  167. { Read disk function declarations }
  168. {$i diskh.inc}
  169. { read thread handling }
  170. {$i systhrdh.inc}
  171. procedure FreeAndNil(var obj);
  172. {$ifdef HASINTF}
  173. { interface handling }
  174. {$i intfh.inc}
  175. {$endif HASINTF}
  176. {
  177. $Log$
  178. Revision 1.9 2004-08-31 11:03:35 michael
  179. + Some capitalization added for documentation purposes
  180. Revision 1.8 2004/08/31 10:34:11 michael
  181. + Some capitalization added for documentation purposes
  182. Revision 1.7 2004/01/28 22:09:52 peter
  183. * EOSError.errorcode change to Longint which is more compatible
  184. with unix platforms
  185. Revision 1.6 2004/01/05 22:37:24 florian
  186. * changed sysutils.exec to ExecuteProcess
  187. Revision 1.5 2003/11/26 22:17:42 michael
  188. + Merged fixbranch fixes, missing in main branch
  189. Revision 1.4 2003/11/26 20:12:08 michael
  190. + New runerror 231 (exception stack error) and 232 (nothread support)
  191. Revision 1.3 2003/11/26 20:00:19 florian
  192. * error handling for Variants improved
  193. Revision 1.2 2003/10/25 23:43:59 hajny
  194. * THandle in sysutils common using System.THandle
  195. Revision 1.1 2003/10/06 21:01:06 peter
  196. * moved classes unit to rtl
  197. Revision 1.20 2003/09/06 20:49:54 marco
  198. * Two minimal VP fixes
  199. Revision 1.19 2003/01/01 20:58:07 florian
  200. + added invalid instruction exception
  201. Revision 1.18 2002/10/07 19:43:24 florian
  202. + empty prototypes for the AnsiStr* multi byte functions added
  203. Revision 1.17 2002/09/07 16:01:22 peter
  204. * old logs removed and tabs fixed
  205. Revision 1.16 2002/01/25 17:42:03 peter
  206. * interface helpers
  207. }