sysutilh.inc 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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.7 2004-01-28 22:09:52 peter
  179. * EOSError.errorcode change to Longint which is more compatible
  180. with unix platforms
  181. Revision 1.6 2004/01/05 22:37:24 florian
  182. * changed sysutils.exec to ExecuteProcess
  183. Revision 1.5 2003/11/26 22:17:42 michael
  184. + Merged fixbranch fixes, missing in main branch
  185. Revision 1.4 2003/11/26 20:12:08 michael
  186. + New runerror 231 (exception stack error) and 232 (nothread support)
  187. Revision 1.3 2003/11/26 20:00:19 florian
  188. * error handling for Variants improved
  189. Revision 1.2 2003/10/25 23:43:59 hajny
  190. * THandle in sysutils common using System.THandle
  191. Revision 1.1 2003/10/06 21:01:06 peter
  192. * moved classes unit to rtl
  193. Revision 1.20 2003/09/06 20:49:54 marco
  194. * Two minimal VP fixes
  195. Revision 1.19 2003/01/01 20:58:07 florian
  196. + added invalid instruction exception
  197. Revision 1.18 2002/10/07 19:43:24 florian
  198. + empty prototypes for the AnsiStr* multi byte functions added
  199. Revision 1.17 2002/09/07 16:01:22 peter
  200. * old logs removed and tabs fixed
  201. Revision 1.16 2002/01/25 17:42:03 peter
  202. * interface helpers
  203. }