Improved API consistency for flag data types

Flag data types are always unsigned and have the valid values following the typedef.
This commit is contained in:
Sam Lantinga 2024-05-07 11:12:53 -07:00
parent 1d2b00efe1
commit aecb62e30d
12 changed files with 154 additions and 168 deletions

View File

@ -86,17 +86,14 @@ extern "C" {
*/
typedef Uint16 SDL_AudioFormat;
#define SDL_AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */
#define SDL_AUDIO_S8 0x8008 /**< Signed 8-bit samples */
#define SDL_AUDIO_S16LE 0x8010 /**< Signed 16-bit samples */
#define SDL_AUDIO_S16BE 0x9010 /**< As above, but big-endian byte order */
#define SDL_AUDIO_S32LE 0x8020 /**< 32-bit integer samples */
#define SDL_AUDIO_S32BE 0x9020 /**< As above, but big-endian byte order */
#define SDL_AUDIO_F32LE 0x8120 /**< 32-bit floating point samples */
#define SDL_AUDIO_F32BE 0x9120 /**< As above, but big-endian byte order */
#define SDL_AUDIO_U8 0x0008u /**< Unsigned 8-bit samples */
#define SDL_AUDIO_S8 0x8008u /**< Signed 8-bit samples */
#define SDL_AUDIO_S16LE 0x8010u /**< Signed 16-bit samples */
#define SDL_AUDIO_S16BE 0x9010u /**< As above, but big-endian byte order */
#define SDL_AUDIO_S32LE 0x8020u /**< 32-bit integer samples */
#define SDL_AUDIO_S32BE 0x9020u /**< As above, but big-endian byte order */
#define SDL_AUDIO_F32LE 0x8120u /**< 32-bit floating point samples */
#define SDL_AUDIO_F32BE 0x9120u /**< As above, but big-endian byte order */
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define SDL_AUDIO_S16 SDL_AUDIO_S16LE

View File

@ -35,36 +35,31 @@ extern "C" {
#endif
/**
* An enumeration of blend modes used in drawing operations.
* A set of blend modes used in drawing operations.
*
* Note that additional values may be obtained from
* SDL_ComposeCustomBlendMode.
* Note that additional values may be obtained from SDL_ComposeCustomBlendMode.
*
* \since This enum is available since SDL 3.0.0.
* \since This datatype is available since SDL 3.0.0.
*
* \sa SDL_ComposeCustomBlendMode
*/
typedef enum SDL_BlendMode
{
SDL_BLENDMODE_NONE = 0x00000000, /**< no blending
dstRGBA = srcRGBA */
SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending
dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
dstA = srcA + (dstA * (1-srcA)) */
SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending
dstRGB = (srcRGB * srcA) + dstRGB
dstA = dstA */
SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate
dstRGB = srcRGB * dstRGB
dstA = dstA */
SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply
dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
dstA = dstA */
SDL_BLENDMODE_INVALID = 0x7FFFFFFF
typedef Uint32 SDL_BlendMode;
/* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */
} SDL_BlendMode;
#define SDL_BLENDMODE_NONE 0x00000000u /**< no blending
dstRGBA = srcRGBA */
#define SDL_BLENDMODE_BLEND 0x00000001u /**< alpha blending
dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
dstA = srcA + (dstA * (1-srcA)) */
#define SDL_BLENDMODE_ADD 0x00000002u /**< additive blending
dstRGB = (srcRGB * srcA) + dstRGB
dstA = dstA */
#define SDL_BLENDMODE_MOD 0x00000004u /**< color modulate
dstRGB = srcRGB * dstRGB
dstA = dstA */
#define SDL_BLENDMODE_MUL 0x00000008u /**< color multiply
dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
dstA = dstA */
#define SDL_BLENDMODE_INVALID 0x7FFFFFFFu
/**
* The blend operation used when combining source and destination pixel

View File

@ -193,7 +193,7 @@ typedef struct SDL_Haptic SDL_Haptic;
*
* \sa SDL_HapticPeriodic
*/
#define SDL_HAPTIC_SQUARE (1<<2)
#define SDL_HAPTIC_SQUARE (1u<<2)
/**
* Triangle wave effect supported.

View File

@ -45,7 +45,7 @@ extern "C" {
* These are the flags which may be passed to SDL_Init(). You should specify
* the subsystems which you will be using in your application.
*
* \since This enum is available since SDL 3.0.0.
* \since This datatype is available since SDL 3.0.0.
*
* \sa SDL_Init
* \sa SDL_Quit
@ -53,18 +53,17 @@ extern "C" {
* \sa SDL_QuitSubSystem
* \sa SDL_WasInit
*/
typedef enum SDL_InitFlags
{
SDL_INIT_TIMER = 0x00000001,
SDL_INIT_AUDIO = 0x00000010, /**< `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS` */
SDL_INIT_VIDEO = 0x00000020, /**< `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS` */
SDL_INIT_JOYSTICK = 0x00000200, /**< `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS`, should be initialized on the same thread as SDL_INIT_VIDEO on Windows if you don't set SDL_HINT_JOYSTICK_THREAD */
SDL_INIT_HAPTIC = 0x00001000,
SDL_INIT_GAMEPAD = 0x00002000, /**< `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` */
SDL_INIT_EVENTS = 0x00004000,
SDL_INIT_SENSOR = 0x00008000, /**< `SDL_INIT_SENSOR` implies `SDL_INIT_EVENTS` */
SDL_INIT_CAMERA = 0x00010000 /**< `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS` */
} SDL_InitFlags;
typedef Uint32 SDL_InitFlags;
#define SDL_INIT_TIMER 0x00000001u
#define SDL_INIT_AUDIO 0x00000010u /**< `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS` */
#define SDL_INIT_VIDEO 0x00000020u /**< `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS` */
#define SDL_INIT_JOYSTICK 0x00000200u /**< `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS`, should be initialized on the same thread as SDL_INIT_VIDEO on Windows if you don't set SDL_HINT_JOYSTICK_THREAD */
#define SDL_INIT_HAPTIC 0x00001000u
#define SDL_INIT_GAMEPAD 0x00002000u /**< `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` */
#define SDL_INIT_EVENTS 0x00004000u
#define SDL_INIT_SENSOR 0x00008000u /**< `SDL_INIT_SENSOR` implies `SDL_INIT_EVENTS` */
#define SDL_INIT_CAMERA 0x00010000u /**< `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS` */
/**
* Initialize the SDL library.
@ -112,7 +111,7 @@ typedef enum SDL_InitFlags
* \sa SDL_SetMainReady
* \sa SDL_WasInit
*/
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
extern DECLSPEC int SDLCALL SDL_Init(SDL_InitFlags flags);
/**
* Compatibility function to initialize the SDL library.
@ -129,7 +128,7 @@ extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
* \sa SDL_Quit
* \sa SDL_QuitSubSystem
*/
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
extern DECLSPEC int SDLCALL SDL_InitSubSystem(SDL_InitFlags flags);
/**
* Shut down specific SDL subsystems.
@ -144,7 +143,7 @@ extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
* \sa SDL_InitSubSystem
* \sa SDL_Quit
*/
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(SDL_InitFlags flags);
/**
* Get a mask of the specified subsystems which are currently initialized.
@ -158,7 +157,7 @@ extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
* \sa SDL_Init
* \sa SDL_InitSubSystem
*/
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
extern DECLSPEC SDL_InitFlags SDLCALL SDL_WasInit(SDL_InitFlags flags);
/**
* Clean up all initialized subsystems.

View File

@ -997,11 +997,11 @@ extern DECLSPEC int SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball
*/
extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int hat);
#define SDL_HAT_CENTERED 0x00
#define SDL_HAT_UP 0x01
#define SDL_HAT_RIGHT 0x02
#define SDL_HAT_DOWN 0x04
#define SDL_HAT_LEFT 0x08
#define SDL_HAT_CENTERED 0x00u
#define SDL_HAT_UP 0x01u
#define SDL_HAT_RIGHT 0x02u
#define SDL_HAT_DOWN 0x04u
#define SDL_HAT_LEFT 0x08u
#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)

View File

@ -48,7 +48,7 @@
*/
typedef Sint32 SDL_Keycode;
#define SDLK_SCANCODE_MASK (1<<30)
#define SDLK_SCANCODE_MASK (1u<<30)
#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK)
#define SDLK_UNKNOWN 0
#define SDLK_RETURN '\r'
@ -296,30 +296,28 @@ typedef Sint32 SDL_Keycode;
#define SDLK_ENDCALL SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ENDCALL)
/**
* Enumeration of valid key mods (possibly OR'd together).
* Valid key modifiers (possibly OR'd together).
*
* \since This enum is available since SDL 3.0.0.
* \since This datatype is available since SDL 3.0.0.
*/
typedef enum SDL_Keymod
{
SDL_KMOD_NONE = 0x0000, /**< no modifier is applicable. */
SDL_KMOD_LSHIFT = 0x0001, /**< the left Shift key is down. */
SDL_KMOD_RSHIFT = 0x0002, /**< the right Shift key is down. */
SDL_KMOD_LCTRL = 0x0040, /**< the left Ctrl (Control) key is down. */
SDL_KMOD_RCTRL = 0x0080, /**< the right Ctrl (Control) key is down. */
SDL_KMOD_LALT = 0x0100, /**< the left Alt key is down. */
SDL_KMOD_RALT = 0x0200, /**< the right Alt key is down. */
SDL_KMOD_LGUI = 0x0400, /**< the left GUI key (often the Windows key) is down. */
SDL_KMOD_RGUI = 0x0800, /**< the right GUI key (often the Windows key) is down. */
SDL_KMOD_NUM = 0x1000, /**< the Num Lock key (may be located on an extended keypad) is down. */
SDL_KMOD_CAPS = 0x2000, /**< the Caps Lock key is down. */
SDL_KMOD_MODE = 0x4000, /**< the !AltGr key is down. */
SDL_KMOD_SCROLL = 0x8000, /**< the Scoll Lock key is down. */
typedef Uint32 SDL_Keymod;
SDL_KMOD_CTRL = SDL_KMOD_LCTRL | SDL_KMOD_RCTRL, /**< Any Ctrl key is down. */
SDL_KMOD_SHIFT = SDL_KMOD_LSHIFT | SDL_KMOD_RSHIFT, /**< Any Shift key is down. */
SDL_KMOD_ALT = SDL_KMOD_LALT | SDL_KMOD_RALT, /**< Any Alt key is down. */
SDL_KMOD_GUI = SDL_KMOD_LGUI | SDL_KMOD_RGUI /**< Any GUI key is down. */
} SDL_Keymod;
#define SDL_KMOD_NONE 0x0000u /**< no modifier is applicable. */
#define SDL_KMOD_LSHIFT 0x0001u /**< the left Shift key is down. */
#define SDL_KMOD_RSHIFT 0x0002u /**< the right Shift key is down. */
#define SDL_KMOD_LCTRL 0x0040u /**< the left Ctrl (Control) key is down. */
#define SDL_KMOD_RCTRL 0x0080u /**< the right Ctrl (Control) key is down. */
#define SDL_KMOD_LALT 0x0100u /**< the left Alt key is down. */
#define SDL_KMOD_RALT 0x0200u /**< the right Alt key is down. */
#define SDL_KMOD_LGUI 0x0400u /**< the left GUI key (often the Windows key) is down. */
#define SDL_KMOD_RGUI 0x0800u /**< the right GUI key (often the Windows key) is down. */
#define SDL_KMOD_NUM 0x1000u /**< the Num Lock key (may be located on an extended keypad) is down. */
#define SDL_KMOD_CAPS 0x2000u /**< the Caps Lock key is down. */
#define SDL_KMOD_MODE 0x4000u /**< the !AltGr key is down. */
#define SDL_KMOD_SCROLL 0x8000u /**< the Scoll Lock key is down. */
#define SDL_KMOD_CTRL (SDL_KMOD_LCTRL | SDL_KMOD_RCTRL) /**< Any Ctrl key is down. */
#define SDL_KMOD_SHIFT (SDL_KMOD_LSHIFT | SDL_KMOD_RSHIFT) /**< Any Shift key is down. */
#define SDL_KMOD_ALT (SDL_KMOD_LALT | SDL_KMOD_RALT) /**< Any Alt key is down. */
#define SDL_KMOD_GUI (SDL_KMOD_LGUI | SDL_KMOD_RGUI) /**< Any GUI key is down. */
#endif /* SDL_keycode_h_ */

View File

@ -37,27 +37,25 @@ extern "C" {
*
* If supported will display warning icon, etc.
*
* \since This enum is available since SDL 3.0.0.
* \since This datatype is available since SDL 3.0.0.
*/
typedef enum SDL_MessageBoxFlags
{
SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */
SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */
SDL_MESSAGEBOX_INFORMATION = 0x00000040, /**< informational dialog */
SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080, /**< buttons placed left to right */
SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100 /**< buttons placed right to left */
} SDL_MessageBoxFlags;
typedef Uint32 SDL_MessageBoxFlags;
#define SDL_MESSAGEBOX_ERROR 0x00000010u /**< error dialog */
#define SDL_MESSAGEBOX_WARNING 0x00000020u /**< warning dialog */
#define SDL_MESSAGEBOX_INFORMATION 0x00000040u /**< informational dialog */
#define SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT 0x00000080u /**< buttons placed left to right */
#define SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT 0x00000100u /**< buttons placed right to left */
/**
* Flags for SDL_MessageBoxButtonData.
* SDL_MessageBoxButtonData flags.
*
* \since This enum is available since SDL 3.0.0.
* \since This datatype is available since SDL 3.0.0.
*/
typedef enum SDL_MessageBoxButtonFlags
{
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */
} SDL_MessageBoxButtonFlags;
typedef Uint32 SDL_MessageBoxButtonFlags;
#define SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT 0x00000001u /**< Marks the default button when return is hit */
#define SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT 0x00000002u /**< Marks the default button when escape is hit */
/**
* Individual button data.
@ -66,7 +64,7 @@ typedef enum SDL_MessageBoxButtonFlags
*/
typedef struct SDL_MessageBoxButtonData
{
Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */
SDL_MessageBoxButtonFlags flags;
int buttonID; /**< User defined button id (value returned via SDL_ShowMessageBox) */
const char *text; /**< The UTF-8 button text */
} SDL_MessageBoxButtonData;
@ -112,7 +110,7 @@ typedef struct SDL_MessageBoxColorScheme
*/
typedef struct SDL_MessageBoxData
{
Uint32 flags; /**< ::SDL_MessageBoxFlags */
SDL_MessageBoxFlags flags;
SDL_Window *window; /**< Parent window, can be NULL */
const char *title; /**< UTF-8 title */
const char *message; /**< UTF-8 message text */
@ -198,7 +196,7 @@ extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *message
*
* \sa SDL_ShowMessageBox
*/
extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window);
extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window);
/* Ends C function definitions when using C++ */

View File

@ -71,12 +71,11 @@ extern "C" {
/**
* Flags used when creating a rendering context.
*
* \since This enum is available since SDL 3.0.0.
* \since This datatype is available since SDL 3.0.0.
*/
typedef enum SDL_RendererFlags
{
SDL_RENDERER_PRESENTVSYNC = 0x00000004 /**< Present is synchronized with the refresh rate */
} SDL_RendererFlags;
typedef Uint32 SDL_RendererFlags;
#define SDL_RENDERER_PRESENTVSYNC 0x00000004u /**< Present is synchronized with the refresh rate */
/**
* Information on the capabilities of a render driver or context.

View File

@ -133,30 +133,30 @@ typedef struct SDL_Window SDL_Window;
*/
typedef Uint32 SDL_WindowFlags;
#define SDL_WINDOW_FULLSCREEN 0x00000001U /**< window is in fullscreen mode */
#define SDL_WINDOW_OPENGL 0x00000002U /**< window usable with OpenGL context */
#define SDL_WINDOW_OCCLUDED 0x00000004U /**< window is occluded */
#define SDL_WINDOW_HIDDEN 0x00000008U /**< window is neither mapped onto the desktop nor shown in the taskbar/dock/window list; SDL_ShowWindow() is required for it to become visible */
#define SDL_WINDOW_BORDERLESS 0x00000010U /**< no window decoration */
#define SDL_WINDOW_RESIZABLE 0x00000020U /**< window can be resized */
#define SDL_WINDOW_MINIMIZED 0x00000040U /**< window is minimized */
#define SDL_WINDOW_MAXIMIZED 0x00000080U /**< window is maximized */
#define SDL_WINDOW_MOUSE_GRABBED 0x00000100U /**< window has grabbed mouse input */
#define SDL_WINDOW_INPUT_FOCUS 0x00000200U /**< window has input focus */
#define SDL_WINDOW_MOUSE_FOCUS 0x00000400U /**< window has mouse focus */
#define SDL_WINDOW_EXTERNAL 0x00000800U /**< window not created by SDL */
#define SDL_WINDOW_MODAL 0x00001000U /**< window is modal */
#define SDL_WINDOW_HIGH_PIXEL_DENSITY 0x00002000U /**< window uses high pixel density back buffer if possible */
#define SDL_WINDOW_MOUSE_CAPTURE 0x00004000U /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
#define SDL_WINDOW_ALWAYS_ON_TOP 0x00008000U /**< window should always be above others */
#define SDL_WINDOW_UTILITY 0x00020000U /**< window should be treated as a utility window, not showing in the task bar and window list */
#define SDL_WINDOW_TOOLTIP 0x00040000U /**< window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window */
#define SDL_WINDOW_POPUP_MENU 0x00080000U /**< window should be treated as a popup menu, requires a parent window */
#define SDL_WINDOW_KEYBOARD_GRABBED 0x00100000U /**< window has grabbed keyboard input */
#define SDL_WINDOW_VULKAN 0x10000000U /**< window usable for Vulkan surface */
#define SDL_WINDOW_METAL 0x20000000U /**< window usable for Metal view */
#define SDL_WINDOW_TRANSPARENT 0x40000000U /**< window with transparent buffer */
#define SDL_WINDOW_NOT_FOCUSABLE 0x80000000U /**< window should not be focusable */
#define SDL_WINDOW_FULLSCREEN 0x00000001u /**< window is in fullscreen mode */
#define SDL_WINDOW_OPENGL 0x00000002u /**< window usable with OpenGL context */
#define SDL_WINDOW_OCCLUDED 0x00000004u /**< window is occluded */
#define SDL_WINDOW_HIDDEN 0x00000008u /**< window is neither mapped onto the desktop nor shown in the taskbar/dock/window list; SDL_ShowWindow() is required for it to become visible */
#define SDL_WINDOW_BORDERLESS 0x00000010u /**< no window decoration */
#define SDL_WINDOW_RESIZABLE 0x00000020u /**< window can be resized */
#define SDL_WINDOW_MINIMIZED 0x00000040u /**< window is minimized */
#define SDL_WINDOW_MAXIMIZED 0x00000080u /**< window is maximized */
#define SDL_WINDOW_MOUSE_GRABBED 0x00000100u /**< window has grabbed mouse input */
#define SDL_WINDOW_INPUT_FOCUS 0x00000200u /**< window has input focus */
#define SDL_WINDOW_MOUSE_FOCUS 0x00000400u /**< window has mouse focus */
#define SDL_WINDOW_EXTERNAL 0x00000800u /**< window not created by SDL */
#define SDL_WINDOW_MODAL 0x00001000u /**< window is modal */
#define SDL_WINDOW_HIGH_PIXEL_DENSITY 0x00002000u /**< window uses high pixel density back buffer if possible */
#define SDL_WINDOW_MOUSE_CAPTURE 0x00004000u /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
#define SDL_WINDOW_ALWAYS_ON_TOP 0x00008000u /**< window should always be above others */
#define SDL_WINDOW_UTILITY 0x00020000u /**< window should be treated as a utility window, not showing in the task bar and window list */
#define SDL_WINDOW_TOOLTIP 0x00040000u /**< window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window */
#define SDL_WINDOW_POPUP_MENU 0x00080000u /**< window should be treated as a popup menu, requires a parent window */
#define SDL_WINDOW_KEYBOARD_GRABBED 0x00100000u /**< window has grabbed keyboard input */
#define SDL_WINDOW_VULKAN 0x10000000u /**< window usable for Vulkan surface */
#define SDL_WINDOW_METAL 0x20000000u /**< window usable for Metal view */
#define SDL_WINDOW_TRANSPARENT 0x40000000u /**< window with transparent buffer */
#define SDL_WINDOW_NOT_FOCUSABLE 0x80000000u /**< window should not be focusable */
/**

View File

@ -574,9 +574,9 @@ SDL_DYNAPI_PROC(SDL_IOStream*,SDL_IOFromDynamicMem,(void),(),return)
SDL_DYNAPI_PROC(SDL_IOStream*,SDL_IOFromFile,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_IOStream*,SDL_IOFromMem,(void *a, size_t b),(a,b),return)
SDL_DYNAPI_PROC(size_t,SDL_IOvprintf,(SDL_IOStream *a, SDL_PRINTF_FORMAT_STRING const char *b, va_list c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_Init,(Uint32 a),(a),return)
SDL_DYNAPI_PROC(int,SDL_Init,(SDL_InitFlags a),(a),return)
SDL_DYNAPI_PROC(int,SDL_InitHapticRumble,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_InitSubSystem,(Uint32 a),(a),return)
SDL_DYNAPI_PROC(int,SDL_InitSubSystem,(SDL_InitFlags a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_IsAndroidTV,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_IsChromebook,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_IsDeXMode,(void),(),return)
@ -657,7 +657,7 @@ SDL_DYNAPI_PROC(int,SDL_PushEvent,(SDL_Event *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_PutAudioStreamData,(SDL_AudioStream *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_QueryTexture,(SDL_Texture *a, SDL_PixelFormatEnum *b, int *c, int *d, int *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void,SDL_Quit,(void),(),)
SDL_DYNAPI_PROC(void,SDL_QuitSubSystem,(Uint32 a),(a),)
SDL_DYNAPI_PROC(void,SDL_QuitSubSystem,(SDL_InitFlags a),(a),)
SDL_DYNAPI_PROC(int,SDL_RaiseWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(size_t,SDL_ReadIO,(SDL_IOStream *a, void *b, size_t c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS16BE,(SDL_IOStream *a, Sint16 *b),(a,b),return)
@ -820,7 +820,7 @@ SDL_DYNAPI_PROC(int,SDL_ShowMessageBox,(const SDL_MessageBoxData *a, int *b),(a,
SDL_DYNAPI_PROC(void,SDL_ShowOpenFileDialog,(SDL_DialogFileCallback a, void *b, SDL_Window *c, const SDL_DialogFileFilter *d, const char *e, int f),(a,b,c,d,e,f),)
SDL_DYNAPI_PROC(void,SDL_ShowOpenFolderDialog,(SDL_DialogFileCallback a, void *b, SDL_Window *c, const char *d, int e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_ShowSaveFileDialog,(SDL_DialogFileCallback a, void *b, SDL_Window *c, const SDL_DialogFileFilter *d, const char *e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(int,SDL_ShowSimpleMessageBox,(Uint32 a, const char *b, const char *c, SDL_Window *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_ShowSimpleMessageBox,(SDL_MessageBoxFlags a, const char *b, const char *c, SDL_Window *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_ShowWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_ShowWindowSystemMenu,(SDL_Window *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SignalCondition,(SDL_Condition *a),(a),return)
@ -879,7 +879,7 @@ SDL_DYNAPI_PROC(int,SDL_WaitSemaphoreTimeout,(SDL_Semaphore *a, Sint32 b),(a,b),
SDL_DYNAPI_PROC(void,SDL_WaitThread,(SDL_Thread *a, int *b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_WarpMouseGlobal,(float a, float b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_WarpMouseInWindow,(SDL_Window *a, float b, float c),(a,b,c),)
SDL_DYNAPI_PROC(Uint32,SDL_WasInit,(Uint32 a),(a),return)
SDL_DYNAPI_PROC(SDL_InitFlags,SDL_WasInit,(SDL_InitFlags a),(a),return)
SDL_DYNAPI_PROC(SDL_WinRT_DeviceFamily,SDL_WinRTGetDeviceFamily,(void),(),return)
SDL_DYNAPI_PROC(const char*,SDL_WinRTGetFSPath,(SDL_WinRT_Path a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_WindowHasSurface,(SDL_Window *a),(a),return)

View File

@ -30,7 +30,7 @@ static int keyboard_getKeyboardState(void *arg)
state = SDL_GetKeyboardState(&numkeys);
SDLTest_AssertPass("Call to SDL_GetKeyboardState(&numkeys)");
SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %i", numkeys);
SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %d", numkeys);
return TEST_COMPLETED;
}
@ -61,37 +61,37 @@ static int keyboard_getKeyFromName(void *arg)
/* Case where Key is known, 1 character input */
result = SDL_GetKeyFromName("A");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/single)");
SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_a, result);
SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %d, got: %" SDL_PRIs32, SDLK_a, result);
/* Case where Key is known, 2 character input */
result = SDL_GetKeyFromName("F1");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/double)");
SDLTest_AssertCheck(result == SDLK_F1, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_F1, result);
SDLTest_AssertCheck(result == SDLK_F1, "Verify result from call, expected: %d, got: %" SDL_PRIs32, SDLK_F1, result);
/* Case where Key is known, 3 character input */
result = SDL_GetKeyFromName("End");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/triple)");
SDLTest_AssertCheck(result == SDLK_END, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_END, result);
SDLTest_AssertCheck(result == SDLK_END, "Verify result from call, expected: %d, got: %" SDL_PRIs32, SDLK_END, result);
/* Case where Key is known, 4 character input */
result = SDL_GetKeyFromName("Find");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/quad)");
SDLTest_AssertCheck(result == SDLK_FIND, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_FIND, result);
SDLTest_AssertCheck(result == SDLK_FIND, "Verify result from call, expected: %d, got: %" SDL_PRIs32, SDLK_FIND, result);
/* Case where Key is known, multiple character input */
result = SDL_GetKeyFromName("AudioStop");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/multi)");
SDLTest_AssertCheck(result == SDLK_AUDIOSTOP, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_AUDIOSTOP, result);
SDLTest_AssertCheck(result == SDLK_AUDIOSTOP, "Verify result from call, expected: %d, got: %" SDL_PRIs32, SDLK_AUDIOSTOP, result);
/* Case where Key is unknown */
result = SDL_GetKeyFromName("NotThere");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(unknown)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %d, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
/* Case where input is NULL/invalid */
result = SDL_GetKeyFromName(NULL);
SDLTest_AssertPass("Call to SDL_GetKeyFromName(NULL)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %d, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
return TEST_COMPLETED;
}
@ -126,12 +126,12 @@ static int keyboard_getKeyFromScancode(void *arg)
/* Case where input is valid */
result = SDL_GetKeyFromScancode(SDL_SCANCODE_A);
SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(valid)");
SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %" SDL_PRIs32, SDLK_a, result);
SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %d, got: %" SDL_PRIs32, SDLK_a, result);
/* Case where input is zero */
result = SDL_GetKeyFromScancode(0);
SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(0)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %d, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
/* Clear error message */
SDL_ClearError();
@ -140,13 +140,13 @@ static int keyboard_getKeyFromScancode(void *arg)
/* Case where input is invalid (too small) */
result = SDL_GetKeyFromScancode(-999);
SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %d, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
checkInvalidScancodeError();
/* Case where input is invalid (too big) */
result = SDL_GetKeyFromScancode(999);
SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %d, got: %" SDL_PRIs32, SDLK_UNKNOWN, result);
checkInvalidScancodeError();
return TEST_COMPLETED;
@ -298,31 +298,31 @@ static int keyboard_getSetModState(void *arg)
/* Get state, cache for later reset */
result = SDL_GetModState();
SDLTest_AssertPass("Call to SDL_GetModState()");
SDLTest_AssertCheck(/*result >= 0 &&*/ result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result);
SDLTest_AssertCheck(/*result >= 0 &&*/ result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %" SDL_PRIu32 ", got: %" SDL_PRIu32, allStates, result);
currentState = result;
/* Set random state */
newState = SDLTest_RandomIntegerInRange(0, allStates);
SDL_SetModState(newState);
SDLTest_AssertPass("Call to SDL_SetModState(%i)", newState);
SDLTest_AssertPass("Call to SDL_SetModState(%" SDL_PRIu32 ")", newState);
result = SDL_GetModState();
SDLTest_AssertPass("Call to SDL_GetModState()");
SDLTest_AssertCheck(result == newState, "Verify result from call is valid, expected: %i, got: %i", newState, result);
SDLTest_AssertCheck(result == newState, "Verify result from call is valid, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32, newState, result);
/* Set zero state */
SDL_SetModState(0);
SDLTest_AssertPass("Call to SDL_SetModState(0)");
result = SDL_GetModState();
SDLTest_AssertPass("Call to SDL_GetModState()");
SDLTest_AssertCheck(result == 0, "Verify result from call is valid, expected: 0, got: %i", result);
SDLTest_AssertCheck(result == 0, "Verify result from call is valid, expected: 0, got: %" SDL_PRIu32, result);
/* Revert back to cached current state if needed */
if (currentState != 0) {
SDL_SetModState(currentState);
SDLTest_AssertPass("Call to SDL_SetModState(%i)", currentState);
SDLTest_AssertPass("Call to SDL_SetModState(%" SDL_PRIu32 ")", currentState);
result = SDL_GetModState();
SDLTest_AssertPass("Call to SDL_GetModState()");
SDLTest_AssertCheck(result == currentState, "Verify result from call is valid, expected: %i, got: %i", currentState, result);
SDLTest_AssertCheck(result == currentState, "Verify result from call is valid, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32, currentState, result);
}
return TEST_COMPLETED;
@ -366,10 +366,10 @@ static void testSetTextInputRect(SDL_Rect refRect)
testRect = refRect;
SDL_SetTextInputRect(&testRect);
SDLTest_AssertPass("Call to SDL_SetTextInputRect with refRect(x:%i,y:%i,w:%i,h:%i)", refRect.x, refRect.y, refRect.w, refRect.h);
SDLTest_AssertPass("Call to SDL_SetTextInputRect with refRect(x:%d,y:%d,w:%d,h:%d)", refRect.x, refRect.y, refRect.w, refRect.h);
SDLTest_AssertCheck(
(refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h),
"Check that input data was not modified, expected: x:%i,y:%i,w:%i,h:%i, got: x:%i,y:%i,w:%i,h:%i",
"Check that input data was not modified, expected: x:%d,y:%d,w:%d,h:%d, got: x:%d,y:%d,w:%d,h:%d",
refRect.x, refRect.y, refRect.w, refRect.h,
testRect.x, testRect.y, testRect.w, testRect.h);
}
@ -503,12 +503,12 @@ static int keyboard_getScancodeFromKey(void *arg)
/* Regular key */
scancode = SDL_GetScancodeFromKey(SDLK_4);
SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_4)");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %d, got: %d", SDL_SCANCODE_4, scancode);
/* Virtual key */
scancode = SDL_GetScancodeFromKey(SDLK_PLUS);
SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_PLUS)");
SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode);
SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %d", scancode);
return TEST_COMPLETED;
}
@ -526,42 +526,42 @@ static int keyboard_getScancodeFromName(void *arg)
/* Regular key, 1 character, first name in list */
scancode = SDL_GetScancodeFromName("A");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('A')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_A, scancode);
/* Regular key, 1 character */
scancode = SDL_GetScancodeFromName("4");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('4')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_4, scancode);
/* Regular key, 2 characters */
scancode = SDL_GetScancodeFromName("F1");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('F1')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_F1, scancode);
/* Regular key, 3 characters */
scancode = SDL_GetScancodeFromName("End");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('End')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_END, scancode);
/* Regular key, 4 characters */
scancode = SDL_GetScancodeFromName("Find");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Find')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_FIND, scancode);
/* Regular key, several characters */
scancode = SDL_GetScancodeFromName("Backspace");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Backspace')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_BACKSPACE, scancode);
/* Regular key, several characters with space */
scancode = SDL_GetScancodeFromName("Keypad Enter");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Keypad Enter')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_KP_ENTER, scancode);
/* Regular key, last name in list */
scancode = SDL_GetScancodeFromName("Sleep");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Sleep')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_SLEEP, scancode);
return TEST_COMPLETED;
}
@ -608,21 +608,21 @@ static int keyboard_getScancodeFromNameNegative(void *arg)
scancode = SDL_GetScancodeFromName(name);
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name);
SDL_free(name);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_UNKNOWN, scancode);
checkInvalidNameError();
/* Zero length string input */
name = "";
scancode = SDL_GetScancodeFromName(name);
SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_UNKNOWN, scancode);
checkInvalidNameError();
/* NULL input */
name = NULL;
scancode = SDL_GetScancodeFromName(name);
SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %d, got: %d", SDL_SCANCODE_UNKNOWN, scancode);
checkInvalidNameError();
return TEST_COMPLETED;

View File

@ -56,7 +56,7 @@ static void surfaceSetUp(void *arg)
SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result);
result = SDL_GetSurfaceBlendMode(testSurface, &currentBlendMode);
SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result);
SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode);
SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32, blendMode, currentBlendMode);
}
}