From 6936bbf2e9d64059d7ce88ec2da157b0c642f9f3 Mon Sep 17 00:00:00 2001 From: ev1313 Date: Tue, 3 Sep 2013 13:52:47 +0200 Subject: [PATCH] fixed for delphi --- sdl2.pas | 1 + sdlerror.inc | 6 +++--- sdlerror.~inc | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 sdlerror.~inc diff --git a/sdl2.pas b/sdl2.pas index 49443ad..0f04567 100644 --- a/sdl2.pas +++ b/sdl2.pas @@ -77,6 +77,7 @@ { Changelog: ---------- + v.1.62-stable; 03.09.2013: fixed. v.1.61-stable; 02.09.2013: now it should REALLY work with Mac... v.1.60-stable; 01.09.2013: now it should work with Delphi XE4 for Windows and MacOS and of course Lazarus. thx to kotai :D diff --git a/sdlerror.inc b/sdlerror.inc index 27e4477..523e9cb 100644 --- a/sdlerror.inc +++ b/sdlerror.inc @@ -6,9 +6,9 @@ const {* Public functions *} {* SDL_SetError() unconditionally returns -1. *} -function SDL_SetError(const fmt: PAnsiChar): SInt32 cdecl; external {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetError' {$ENDIF} {$ENDIF}; -function SDL_GetError: PAnsiChar cdecl; external {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetError' {$ENDIF} {$ENDIF}; -procedure SDL_ClearError cdecl; external {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ClearError' {$ENDIF} {$ENDIF}; +function SDL_SetError(const fmt: PAnsiChar): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetError' {$ENDIF} {$ENDIF}; +function SDL_GetError: PAnsiChar cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetError' {$ENDIF} {$ENDIF}; +procedure SDL_ClearError cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ClearError' {$ENDIF} {$ENDIF}; {*Internal error functions*} {** * Internal error functions diff --git a/sdlerror.~inc b/sdlerror.~inc new file mode 100644 index 0000000..27e4477 --- /dev/null +++ b/sdlerror.~inc @@ -0,0 +1,55 @@ +//from "sdl_error.h" +const + ERR_MAX_STRLEN = 128; + ERR_MAX_ARGS = 5; + + {* Public functions *} + + {* SDL_SetError() unconditionally returns -1. *} +function SDL_SetError(const fmt: PAnsiChar): SInt32 cdecl; external {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetError' {$ENDIF} {$ENDIF}; +function SDL_GetError: PAnsiChar cdecl; external {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetError' {$ENDIF} {$ENDIF}; +procedure SDL_ClearError cdecl; external {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ClearError' {$ENDIF} {$ENDIF}; + {*Internal error functions*} + {** + * Internal error functions + * + * Private error reporting function - used internally. + *} + + { +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) +#define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) + } +type + TSDL_ErrorCode = (SDL_ENOMEM, + SDL_EFREAD, + SDL_EFWRITE, + SDL_EFSEEK, + SDL_UNSUPPORTED, + SDL_LASTERROR); + + TSDL_Error = record + {* This is a numeric value corresponding to the current error *} + error: SInt32; + + {* This is a key used to index into a language hashtable containing + internationalized versions of the SDL error messages. If the key + is not in the hashtable, or no hashtable is available, the key is + used directly as an error message format string. + *} + key: String[ERR_MAX_STRLEN]; + + {* These are the arguments for the error functions *} + argc: SInt32; + case SInt32 of + {* What is a character anyway? (UNICODE issues) *} + 0: (value_c: Byte;); + 1: (value_ptr: Pointer;); + 2: (value_i: SInt32;); + 3: (value_f: Double;); + 4: (buf: String[ERR_MAX_STRLEN];); + end; + + {* SDL_Error() unconditionally returns -1. *} +function SDL_Error(code: TSDL_ErrorCode): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_Error' {$ENDIF} {$ENDIF};