2
0

sysutilh.inc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. tsyscharset = set of char;
  29. tintegerset = set of 0..sizeof(integer)*8-1;
  30. longrec = packed record
  31. case integer of
  32. 0 : (lo,hi : word);
  33. 1 : (bytes : array[0..3] of byte);
  34. end;
  35. wordrec = packed record
  36. lo,hi : byte;
  37. end;
  38. int64rec = packed record
  39. case integer of
  40. 0 : (lo,hi : cardinal);
  41. 1 : (words : array[0..3] of word);
  42. 2 : (bytes : array[0..7] of byte);
  43. end;
  44. pbytearray = ^tbytearray;
  45. tbytearray = array[0..32767] of byte;
  46. pwordarray = ^twordarray;
  47. twordarray = array[0..16383] of word;
  48. TMethod = packed record
  49. Code, Data: Pointer;
  50. end;
  51. { exceptions }
  52. Exception = class(TObject)
  53. private
  54. fmessage : string;
  55. fhelpcontext : longint;
  56. public
  57. constructor Create(const msg : string);
  58. constructor CreateFmt(const msg : string; const args : array of const);
  59. constructor CreateRes(ResString: PString);
  60. constructor CreateResFmt(ResString: PString; const Args: array of const);
  61. constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  62. constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  63. AHelpContext: Integer);
  64. constructor CreateResHelp(ResString: PString; AHelpContext: Integer);
  65. constructor CreateResFmtHelp(ResString: PString; const Args: array of const;
  66. AHelpContext: Integer);
  67. { !!!! }
  68. property helpcontext : longint read fhelpcontext write fhelpcontext;
  69. property message : string read fmessage write fmessage;
  70. end;
  71. ExceptClass = class of Exception;
  72. EExternal = class(Exception)
  73. public
  74. {$ifdef win32}
  75. ExceptionRecord : PExceptionRecord;
  76. {$endif win32}
  77. end;
  78. { integer math exceptions }
  79. EInterror = Class(EExternal);
  80. EDivByZero = Class(EIntError);
  81. ERangeError = Class(EIntError);
  82. EIntOverflow = Class(EIntError);
  83. { General math errors }
  84. EMathError = Class(EExternal);
  85. EInvalidOp = Class(EMathError);
  86. EZeroDivide = Class(EMathError);
  87. EOverflow = Class(EMathError);
  88. EUnderflow = Class(EMathError);
  89. { Run-time and I/O Errors }
  90. EInOutError = class(Exception)
  91. public
  92. ErrorCode : Longint;
  93. end;
  94. EHeapMemoryError = class(Exception)
  95. protected
  96. AllowFree : boolean;
  97. procedure FreeInstance;override;
  98. end;
  99. EHeapException = EHeapMemoryError;
  100. EExternalException = class(EExternal);
  101. EInvalidPointer = Class(EHeapMemoryError);
  102. EOutOfMemory = Class(EHeapMemoryError);
  103. EInvalidCast = Class(Exception);
  104. EVariantError = Class(Exception);
  105. EAccessViolation = Class(EExternal);
  106. EPrivilege = class(EExternal);
  107. EStackOverflow = class(EExternal);
  108. EControlC = class(EExternal);
  109. { String conversion errors }
  110. EConvertError = class(Exception);
  111. { Other errors }
  112. EAbort = Class(Exception);
  113. EAbstractError = Class(Exception);
  114. EAssertionFailed = Class(Exception);
  115. EPropReadOnly = class(Exception);
  116. EPropWriteOnly = class(Exception);
  117. EIntfCastError = class(Exception);
  118. EInvalidContainer = class(Exception);
  119. EInvalidInsert = class(Exception);
  120. EPackageError = class(Exception);
  121. ESafecallException = 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. Var
  133. OnShowException : Procedure (Msg : ShortString);
  134. { FileRec/TextRec }
  135. {$i filerec.inc}
  136. {$i textrec.inc}
  137. Const
  138. HexDisplayPrefix : string = '$';
  139. const
  140. // commenting is VP fix. These idents are in a different unit there.
  141. PathDelim={System.}DirectorySeparator;
  142. DriveDelim={System.}DriveSeparator;
  143. PathSep={System.}PathSeparator;
  144. Type
  145. TFileRec=FileRec;
  146. TTextRec=TextRec;
  147. { Read internationalization settings }
  148. {$i sysinth.inc}
  149. { Read pchar handling functions declaration }
  150. {$IFNDEF VIRTUALPASCAL}
  151. {$i syspchh.inc}
  152. {$ENDIF}
  153. { MCBS functions }
  154. {$i sysansih.inc}
  155. { Read filename handling functions declaration }
  156. {$i finah.inc}
  157. { Read other file handling function declarations }
  158. {$i filutilh.inc}
  159. { Read disk function declarations }
  160. {$i diskh.inc}
  161. { read thread handling }
  162. {$i systhrdh.inc}
  163. procedure FreeAndNil(var obj);
  164. {$ifdef HASINTF}
  165. { interface handling }
  166. {$i intfh.inc}
  167. {$endif HASINTF}
  168. {
  169. $Log$
  170. Revision 1.2 2003-10-25 23:43:59 hajny
  171. * THandle in sysutils common using System.THandle
  172. Revision 1.1 2003/10/06 21:01:06 peter
  173. * moved classes unit to rtl
  174. Revision 1.20 2003/09/06 20:49:54 marco
  175. * Two minimal VP fixes
  176. Revision 1.19 2003/01/01 20:58:07 florian
  177. + added invalid instruction exception
  178. Revision 1.18 2002/10/07 19:43:24 florian
  179. + empty prototypes for the AnsiStr* multi byte functions added
  180. Revision 1.17 2002/09/07 16:01:22 peter
  181. * old logs removed and tabs fixed
  182. Revision 1.16 2002/01/25 17:42:03 peter
  183. * interface helpers
  184. }