sysutilh.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Florian Klaempfl
  4. member of the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. { Using inlining for small system functions/wrappers }
  12. {$inline on}
  13. {$define SYSUTILSINLINE}
  14. { Read date & Time function declarations }
  15. {$i osutilsh.inc}
  16. {$i datih.inc}
  17. { Read String Handling functions declaration }
  18. {$i sysstrh.inc}
  19. type
  20. { some helpful data types }
  21. THandle = System.THandle;
  22. TProcedure = procedure;
  23. TFilename = String;
  24. TIntegerSet = Set of 0..SizeOf(Integer)*8-1;
  25. LongRec = packed record
  26. case Integer of
  27. 0 : (Lo,Hi : Word);
  28. 1 : (Bytes : Array[0..3] of Byte);
  29. end;
  30. WordRec = packed record
  31. Lo,Hi : Byte;
  32. end;
  33. Int64Rec = packed record
  34. case integer of
  35. 0 : (Lo,Hi : Cardinal);
  36. 1 : (Words : Array[0..3] of Word);
  37. 2 : (Bytes : Array[0..7] of Byte);
  38. end;
  39. PByteArray = ^TByteArray;
  40. TByteArray = Array[0..32767] of Byte;
  41. PWordarray = ^TWordArray;
  42. TWordArray = array[0..16383] of Word;
  43. { exceptions }
  44. Exception = class(TObject)
  45. private
  46. fmessage : string;
  47. fhelpcontext : longint;
  48. public
  49. constructor Create(const msg : string);
  50. constructor CreateFmt(const msg : string; const args : array of const);
  51. constructor CreateRes(ResString: PString);
  52. constructor CreateResFmt(ResString: PString; const Args: array of const);
  53. constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  54. constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  55. AHelpContext: Integer);
  56. constructor CreateResHelp(ResString: PString; AHelpContext: Integer);
  57. constructor CreateResFmtHelp(ResString: PString; const Args: array of const;
  58. AHelpContext: Integer);
  59. { !!!! }
  60. property HelpContext : longint read fhelpcontext write fhelpcontext;
  61. property Message : string read fmessage write fmessage;
  62. end;
  63. ExceptClass = class of Exception;
  64. EExternal = class(Exception)
  65. public
  66. {$ifdef win32}
  67. ExceptionRecord : PExceptionRecord;
  68. {$endif win32}
  69. end;
  70. { integer math exceptions }
  71. EInterror = Class(EExternal);
  72. EDivByZero = Class(EIntError);
  73. ERangeError = Class(EIntError);
  74. EIntOverflow = Class(EIntError);
  75. { General math errors }
  76. EMathError = Class(EExternal);
  77. EInvalidOp = Class(EMathError);
  78. EZeroDivide = Class(EMathError);
  79. EOverflow = Class(EMathError);
  80. EUnderflow = Class(EMathError);
  81. { Run-time and I/O Errors }
  82. EInOutError = class(Exception)
  83. public
  84. ErrorCode : Longint;
  85. end;
  86. EHeapMemoryError = class(Exception)
  87. protected
  88. AllowFree : boolean;
  89. procedure FreeInstance;override;
  90. end;
  91. EHeapException = EHeapMemoryError;
  92. EExternalException = class(EExternal);
  93. EInvalidPointer = Class(EHeapMemoryError);
  94. EOutOfMemory = Class(EHeapMemoryError);
  95. EInvalidCast = Class(Exception);
  96. EVariantError = Class(Exception)
  97. ErrCode : longint;
  98. Constructor CreateCode(Code : Longint);
  99. end;
  100. EAccessViolation = Class(EExternal);
  101. EBusError = Class(EAccessViolation);
  102. EPrivilege = class(EExternal);
  103. EStackOverflow = class(EExternal);
  104. EControlC = class(EExternal);
  105. { String conversion errors }
  106. EConvertError = class(Exception);
  107. EFormatError = class(Exception);
  108. { Other errors }
  109. EAbort = Class(Exception);
  110. EAbstractError = Class(Exception);
  111. EAssertionFailed = Class(Exception);
  112. EPropReadOnly = class(Exception);
  113. EPropWriteOnly = class(Exception);
  114. EIntfCastError = class(Exception);
  115. EInvalidContainer = class(Exception);
  116. EInvalidInsert = class(Exception);
  117. EPackageError = class(Exception);
  118. EOSError = class(Exception)
  119. public
  120. ErrorCode: Longint;
  121. end;
  122. ESafecallException = class(Exception);
  123. ENoThreadSupport = Class(Exception);
  124. { Exception handling routines }
  125. function ExceptObject: TObject;
  126. function ExceptAddr: Pointer;
  127. function ExceptFrameCount: Longint;
  128. function ExceptFrames: PPointer;
  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. TCreateGUIDFunc = Function(Out GUID : TGUID) : Integer;
  138. Var
  139. OnCreateGUID : TCreateGUIDFunc = Nil;
  140. Function CreateGUID(out GUID : TGUID) : Integer;
  141. type
  142. TTerminateProc = Function: Boolean;
  143. procedure AddTerminateProc(TermProc: TTerminateProc);
  144. function CallTerminateProcs: Boolean;
  145. Var
  146. OnShowException : Procedure (Msg : ShortString);
  147. { FileRec/TextRec }
  148. {$i filerec.inc}
  149. {$i textrec.inc}
  150. Const
  151. HexDisplayPrefix : string = '$';
  152. const
  153. // commenting is VP fix. These idents are in a different unit there.
  154. PathDelim={System.}DirectorySeparator;
  155. DriveDelim={System.}DriveSeparator;
  156. PathSep={System.}PathSeparator;
  157. MAX_PATH={System.}MaxPathLen;
  158. Type
  159. TFileRec=FileRec;
  160. TTextRec=TextRec;
  161. { Read internationalization settings }
  162. {$i sysinth.inc}
  163. { Read pchar handling functions declaration }
  164. {$i syspchh.inc}
  165. { MCBS functions }
  166. {$i sysansih.inc}
  167. { wide string functions }
  168. {$i syswideh.inc}
  169. { Read filename handling functions declaration }
  170. {$i finah.inc}
  171. { Read other file handling function declarations }
  172. {$i filutilh.inc}
  173. { Read disk function declarations }
  174. {$i diskh.inc}
  175. { read thread handling }
  176. {$i systhrdh.inc}
  177. procedure FreeAndNil(var obj);
  178. { interface handling }
  179. {$i intfh.inc}