sysutilh.inc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. (* This must be placed before other functions, because TDateTime from DosCalls
  14. would be used under OS/2 instead of that one from datih.inc otherwise. *)
  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. tprocedure = procedure;
  22. tfilename = string;
  23. tsyscharset = set of char;
  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. TMethod = packed record
  44. Code, Data: Pointer;
  45. end;
  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. ESafecallException = class(Exception);
  117. { Exception handling routines }
  118. function ExceptObject: TObject;
  119. function ExceptAddr: Pointer;
  120. function ExceptionErrorMessage(ExceptObject: TObject; ExceptAddr: Pointer;
  121. Buffer: PChar; Size: Integer): Integer;
  122. procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
  123. procedure Abort;
  124. procedure OutOfMemoryError;
  125. procedure Beep;
  126. function SysErrorMessage(ErrorCode: Integer): String;
  127. Var
  128. OnShowException : Procedure (Msg : ShortString);
  129. { FileRec/TextRec }
  130. {$i filerec.inc}
  131. {$i textrec.inc}
  132. Const
  133. HexDisplayPrefix : string = '$';
  134. const
  135. PathDelim=System.DirectorySeparator;
  136. DriveDelim=System.DriveSeparator;
  137. PathSep=System.PathSeparator;
  138. Type
  139. TFileRec=FileRec;
  140. TTextRec=TextRec;
  141. { Read internationalization settings }
  142. {$i sysinth.inc}
  143. { Read pchar handling functions declaration }
  144. {$i syspchh.inc}
  145. { MCBS functions }
  146. {$i sysansih.inc}
  147. { Read filename handling functions declaration }
  148. {$i finah.inc}
  149. { Read other file handling function declarations }
  150. {$i filutilh.inc}
  151. { Read disk function declarations }
  152. {$i diskh.inc}
  153. { read thread handling }
  154. {$i systhrdh.inc}
  155. procedure FreeAndNil(var obj);
  156. {$ifdef HASINTF}
  157. { interface handling }
  158. {$i intfh.inc}
  159. {$endif HASINTF}
  160. {
  161. $Log$
  162. Revision 1.19 2003-01-01 20:58:07 florian
  163. + added invalid instruction exception
  164. Revision 1.18 2002/10/07 19:43:24 florian
  165. + empty prototypes for the AnsiStr* multi byte functions added
  166. Revision 1.17 2002/09/07 16:01:22 peter
  167. * old logs removed and tabs fixed
  168. Revision 1.16 2002/01/25 17:42:03 peter
  169. * interface helpers
  170. }