sysutilh.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. {
  2. $Id: sysutilh.inc,v 1.15 2005/05/12 20:30:51 michael Exp $
  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. { Using inlining for small system functions/wrappers }
  13. {$ifdef HASINLINE}
  14. {$inline on}
  15. {$define SYSUTILSINLINE}
  16. {$endif}
  17. { Read date & Time function declarations }
  18. {$i osutilsh.inc}
  19. {$i datih.inc}
  20. { Read String Handling functions declaration }
  21. {$i sysstrh.inc}
  22. type
  23. { some helpful data types }
  24. THandle = System.THandle;
  25. TProcedure = procedure;
  26. TFilename = String;
  27. TIntegerSet = Set of 0..SizeOf(Integer)*8-1;
  28. LongRec = packed record
  29. case Integer of
  30. 0 : (Lo,Hi : Word);
  31. 1 : (Bytes : Array[0..3] of Byte);
  32. end;
  33. WordRec = packed record
  34. Lo,Hi : Byte;
  35. end;
  36. Int64Rec = packed record
  37. case integer of
  38. 0 : (Lo,Hi : Cardinal);
  39. 1 : (Words : Array[0..3] of Word);
  40. 2 : (Bytes : Array[0..7] of Byte);
  41. end;
  42. PByteArray = ^TByteArray;
  43. TByteArray = Array[0..32767] of Byte;
  44. PWordarray = ^TWordArray;
  45. TWordArray = array[0..16383] of Word;
  46. { exceptions }
  47. Exception = class(TObject)
  48. private
  49. fmessage : string;
  50. fhelpcontext : longint;
  51. public
  52. constructor Create(const msg : string);
  53. constructor CreateFmt(const msg : string; const args : array of const);
  54. constructor CreateRes(ResString: PString);
  55. constructor CreateResFmt(ResString: PString; const Args: array of const);
  56. constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  57. constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  58. AHelpContext: Integer);
  59. constructor CreateResHelp(ResString: PString; AHelpContext: Integer);
  60. constructor CreateResFmtHelp(ResString: PString; const Args: array of const;
  61. AHelpContext: Integer);
  62. { !!!! }
  63. property HelpContext : longint read fhelpcontext write fhelpcontext;
  64. property Message : string read fmessage write fmessage;
  65. end;
  66. ExceptClass = class of Exception;
  67. EExternal = class(Exception)
  68. public
  69. {$ifdef win32}
  70. ExceptionRecord : PExceptionRecord;
  71. {$endif win32}
  72. end;
  73. { integer math exceptions }
  74. EInterror = Class(EExternal);
  75. EDivByZero = Class(EIntError);
  76. ERangeError = Class(EIntError);
  77. EIntOverflow = Class(EIntError);
  78. { General math errors }
  79. EMathError = Class(EExternal);
  80. EInvalidOp = Class(EMathError);
  81. EZeroDivide = Class(EMathError);
  82. EOverflow = Class(EMathError);
  83. EUnderflow = Class(EMathError);
  84. { Run-time and I/O Errors }
  85. EInOutError = class(Exception)
  86. public
  87. ErrorCode : Longint;
  88. end;
  89. EHeapMemoryError = class(Exception)
  90. protected
  91. AllowFree : boolean;
  92. procedure FreeInstance;override;
  93. end;
  94. EHeapException = EHeapMemoryError;
  95. EExternalException = class(EExternal);
  96. EInvalidPointer = Class(EHeapMemoryError);
  97. EOutOfMemory = Class(EHeapMemoryError);
  98. EInvalidCast = Class(Exception);
  99. EVariantError = Class(Exception);
  100. EAccessViolation = Class(EExternal);
  101. EPrivilege = class(EExternal);
  102. EStackOverflow = class(EExternal);
  103. EControlC = class(EExternal);
  104. { String conversion errors }
  105. EConvertError = class(Exception);
  106. { Other errors }
  107. EAbort = Class(Exception);
  108. EAbstractError = Class(Exception);
  109. EAssertionFailed = Class(Exception);
  110. EPropReadOnly = class(Exception);
  111. EPropWriteOnly = class(Exception);
  112. EIntfCastError = class(Exception);
  113. EInvalidContainer = class(Exception);
  114. EInvalidInsert = class(Exception);
  115. EPackageError = class(Exception);
  116. EOSError = class(Exception)
  117. public
  118. ErrorCode: Longint;
  119. end;
  120. ESafecallException = class(Exception);
  121. ENoThreadSupport = Class(Exception);
  122. { Exception handling routines }
  123. function ExceptObject: TObject;
  124. function ExceptAddr: Pointer;
  125. function ExceptionErrorMessage(ExceptObject: TObject; ExceptAddr: Pointer;
  126. Buffer: PChar; Size: Integer): Integer;
  127. procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
  128. procedure Abort;
  129. procedure OutOfMemoryError;
  130. procedure Beep;
  131. function SysErrorMessage(ErrorCode: Integer): String;
  132. type
  133. TTerminateProc = Function: Boolean;
  134. procedure AddTerminateProc(TermProc: TTerminateProc);
  135. function CallTerminateProcs: Boolean;
  136. Var
  137. OnShowException : Procedure (Msg : ShortString);
  138. { FileRec/TextRec }
  139. {$i filerec.inc}
  140. {$i textrec.inc}
  141. Const
  142. HexDisplayPrefix : string = '$';
  143. const
  144. // commenting is VP fix. These idents are in a different unit there.
  145. PathDelim={System.}DirectorySeparator;
  146. DriveDelim={System.}DriveSeparator;
  147. PathSep={System.}PathSeparator;
  148. MAX_PATH={System.}MaxPathLen;
  149. Type
  150. TFileRec=FileRec;
  151. TTextRec=TextRec;
  152. { Read internationalization settings }
  153. {$i sysinth.inc}
  154. { Read pchar handling functions declaration }
  155. {$IFNDEF VIRTUALPASCAL}
  156. {$i syspchh.inc}
  157. {$ENDIF}
  158. { MCBS functions }
  159. {$i sysansih.inc}
  160. { wide string functions }
  161. {$i syswideh.inc}
  162. { Read filename handling functions declaration }
  163. {$i finah.inc}
  164. { Read other file handling function declarations }
  165. {$i filutilh.inc}
  166. { Read disk function declarations }
  167. {$i diskh.inc}
  168. { read thread handling }
  169. {$i systhrdh.inc}
  170. procedure FreeAndNil(var obj);
  171. {$ifdef HASINTF}
  172. { interface handling }
  173. {$i intfh.inc}
  174. {$endif HASINTF}
  175. {
  176. $Log: sysutilh.inc,v $
  177. Revision 1.15 2005/05/12 20:30:51 michael
  178. + Added MAX_PATH for Delphi/Kylix compatibility.
  179. Revision 1.14 2005/03/12 14:56:22 florian
  180. + added Ansi* routines to widestring manager
  181. * made them using OS calls on windows
  182. Revision 1.13 2005/02/14 17:13:31 peter
  183. * truncate log
  184. Revision 1.12 2005/02/03 18:40:02 florian
  185. * compilation with 1.0.x fixed
  186. + infrastructure for WideCompareText implemented
  187. Revision 1.11 2005/02/03 16:21:59 peter
  188. * 1.0.x fix
  189. Revision 1.10 2005/02/01 20:22:50 florian
  190. * improved widestring infrastructure manager
  191. }