sysutilh.inc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. { exceptions }
  48. Exception = class(TObject)
  49. private
  50. fmessage : string;
  51. fhelpcontext : longint;
  52. public
  53. constructor Create(const msg : string);
  54. constructor CreateFmt(const msg : string; const args : array of const);
  55. constructor CreateRes(ResString: PString);
  56. constructor CreateResFmt(ResString: PString; const Args: array of const);
  57. constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  58. constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  59. AHelpContext: Integer);
  60. constructor CreateResHelp(ResString: PString; AHelpContext: Integer);
  61. constructor CreateResFmtHelp(ResString: PString; const Args: array of const;
  62. AHelpContext: Integer);
  63. { !!!! }
  64. property HelpContext : longint read fhelpcontext write fhelpcontext;
  65. property Message : string read fmessage write fmessage;
  66. end;
  67. ExceptClass = class of Exception;
  68. EExternal = class(Exception)
  69. public
  70. {$ifdef win32}
  71. ExceptionRecord : PExceptionRecord;
  72. {$endif win32}
  73. end;
  74. { integer math exceptions }
  75. EInterror = Class(EExternal);
  76. EDivByZero = Class(EIntError);
  77. ERangeError = Class(EIntError);
  78. EIntOverflow = Class(EIntError);
  79. { General math errors }
  80. EMathError = Class(EExternal);
  81. EInvalidOp = Class(EMathError);
  82. EZeroDivide = Class(EMathError);
  83. EOverflow = Class(EMathError);
  84. EUnderflow = Class(EMathError);
  85. { Run-time and I/O Errors }
  86. EInOutError = class(Exception)
  87. public
  88. ErrorCode : Longint;
  89. end;
  90. EHeapMemoryError = class(Exception)
  91. protected
  92. AllowFree : boolean;
  93. procedure FreeInstance;override;
  94. end;
  95. EHeapException = EHeapMemoryError;
  96. EExternalException = class(EExternal);
  97. EInvalidPointer = Class(EHeapMemoryError);
  98. EOutOfMemory = Class(EHeapMemoryError);
  99. EInvalidCast = Class(Exception);
  100. EVariantError = Class(Exception);
  101. EAccessViolation = Class(EExternal);
  102. EPrivilege = class(EExternal);
  103. EStackOverflow = class(EExternal);
  104. EControlC = class(EExternal);
  105. { String conversion errors }
  106. EConvertError = class(Exception);
  107. { Other errors }
  108. EAbort = Class(Exception);
  109. EAbstractError = Class(Exception);
  110. EAssertionFailed = Class(Exception);
  111. EPropReadOnly = class(Exception);
  112. EPropWriteOnly = class(Exception);
  113. EIntfCastError = class(Exception);
  114. EInvalidContainer = class(Exception);
  115. EInvalidInsert = class(Exception);
  116. EPackageError = class(Exception);
  117. EOSError = class(Exception)
  118. public
  119. ErrorCode: Longint;
  120. end;
  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. type
  134. TTerminateProc = Function: Boolean;
  135. procedure AddTerminateProc(TermProc: TTerminateProc);
  136. function CallTerminateProcs: Boolean;
  137. Var
  138. OnShowException : Procedure (Msg : ShortString);
  139. { FileRec/TextRec }
  140. {$i filerec.inc}
  141. {$i textrec.inc}
  142. Const
  143. HexDisplayPrefix : string = '$';
  144. const
  145. // commenting is VP fix. These idents are in a different unit there.
  146. PathDelim={System.}DirectorySeparator;
  147. DriveDelim={System.}DriveSeparator;
  148. PathSep={System.}PathSeparator;
  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. {$ifndef VER1_0}
  161. { wide string functions }
  162. {$i syswideh.inc}
  163. {$endif VER1_0}
  164. { Read filename handling functions declaration }
  165. {$i finah.inc}
  166. { Read other file handling function declarations }
  167. {$i filutilh.inc}
  168. { Read disk function declarations }
  169. {$i diskh.inc}
  170. { read thread handling }
  171. {$i systhrdh.inc}
  172. procedure FreeAndNil(var obj);
  173. {$ifdef HASINTF}
  174. { interface handling }
  175. {$i intfh.inc}
  176. {$endif HASINTF}
  177. {
  178. $Log$
  179. Revision 1.13 2005-02-14 17:13:31 peter
  180. * truncate log
  181. Revision 1.12 2005/02/03 18:40:02 florian
  182. * compilation with 1.0.x fixed
  183. + infrastructure for WideCompareText implemented
  184. Revision 1.11 2005/02/03 16:21:59 peter
  185. * 1.0.x fix
  186. Revision 1.10 2005/02/01 20:22:50 florian
  187. * improved widestring infrastructure manager
  188. }