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

@@ -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.