sdlerror.inc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // based on "sdl_error.h" (2.0.14)
  2. {**
  3. * \file SDL_error.h
  4. *
  5. * Simple error message routines for SDL.
  6. *}
  7. {* Public functions *}
  8. {**
  9. * \brief Set the error message for the current thread
  10. *
  11. * \return -1, there is no error handling for this function
  12. *}
  13. function SDL_SetError(const fmt: PAnsiChar; args: array of const): cint; cdecl;
  14. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetError' {$ENDIF} {$ENDIF};
  15. {**
  16. * \brief Get the last error message that was set
  17. *
  18. * SDL API functions may set error messages and then succeed, so you should
  19. * only use the error value if a function fails.
  20. *
  21. * This returns a pointer to a static buffer for convenience and should not
  22. * be called by multiple threads simultaneously.
  23. *
  24. * \return a pointer to the last error message that was set
  25. *}
  26. function SDL_GetError: PAnsiChar; cdecl;
  27. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetError' {$ENDIF} {$ENDIF};
  28. {**
  29. * \brief Get the last error message that was set for the current thread
  30. *
  31. * SDL API functions may set error messages and then succeed, so you should
  32. * only use the error value if a function fails.
  33. *
  34. * \param errstr A buffer to fill with the last error message that was set
  35. * for the current thread
  36. * \param maxlen The size of the buffer pointed to by the errstr parameter
  37. *
  38. * \return errstr
  39. *}
  40. function SDL_GetErrorMsg(const errstr: PAnsiChar; maxlen: cint): PAnsiChar; cdecl;
  41. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetErrorMsg' {$ENDIF} {$ENDIF};
  42. {**
  43. * \brief Clear the error message for the current thread
  44. *}
  45. procedure SDL_ClearError cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ClearError' {$ENDIF} {$ENDIF};
  46. {*Internal error functions*}
  47. {**
  48. * Internal error functions
  49. *
  50. * Private error reporting function - used internally.
  51. *}
  52. {
  53. #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
  54. #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
  55. #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param))
  56. }
  57. type
  58. PPSDL_ErrorCode = ^PSDL_ErrorCode;
  59. PSDL_ErrorCode = ^TSDL_ErrorCode;
  60. TSDL_ErrorCode = (SDL_ENOMEM,
  61. SDL_EFREAD,
  62. SDL_EFWRITE,
  63. SDL_EFSEEK,
  64. SDL_UNSUPPORTED,
  65. SDL_LASTERROR);
  66. {* SDL_Error() unconditionally returns -1. *}
  67. function SDL_Error(code: TSDL_ErrorCode): cint; cdecl;
  68. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_Error' {$ENDIF} {$ENDIF};