Change SDL sources to use more proper types

This helps consumers avoid having to do ugly casts
as was previously done in `SDL_quit.cs`.

It's very important that the underlying type doesn't change
as that might break ABI compat.
This commit is contained in:
Susko3 2024-04-06 14:43:18 +02:00
parent 91cef07624
commit e85349e3fa
8 changed files with 352 additions and 44 deletions

View File

@ -1,5 +1,308 @@
diff --git a/include/SDL3/SDL.h b/include/SDL3/SDL.h
index b178d2ade..5c54b9ab5 100644
--- a/include/SDL3/SDL.h
+++ b/include/SDL3/SDL.h
@@ -29,6 +29,8 @@
#ifndef SDL_h_
#define SDL_h_
+#error Don't build with enum type changes
+
#include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_assert.h>
#include <SDL3/SDL_atomic.h>
diff --git a/include/SDL3/SDL_events.h b/include/SDL3/SDL_events.h
index 0fddf1f24..36b98b569 100644
--- a/include/SDL3/SDL_events.h
+++ b/include/SDL3/SDL_events.h
@@ -244,7 +244,7 @@ typedef enum
*/
typedef struct SDL_CommonEvent
{
- Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */
+ SDL_EventType type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */
Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
} SDL_CommonEvent;
@@ -726,7 +726,7 @@ typedef struct SDL_QuitEvent
*/
typedef struct SDL_UserEvent
{
- Uint32 type; /**< ::SDL_EVENT_USER through ::SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration */
+ SDL_EventType type; /**< ::SDL_EVENT_USER through ::SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration */
Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_WindowID windowID; /**< The associated window if any */
@@ -741,7 +741,7 @@ typedef struct SDL_UserEvent
*/
typedef union SDL_Event
{
- Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */
+ SDL_EventType type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */
SDL_CommonEvent common; /**< Common event data */
SDL_DisplayEvent display; /**< Display event data */
SDL_WindowEvent window; /**< Window event data */
@@ -868,7 +868,7 @@ typedef enum
* \sa SDL_PumpEvents
* \sa SDL_PushEvent
*/
-extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType);
+extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventaction action, SDL_EventType minType, SDL_EventType maxType);
/* @} */
/**
@@ -885,7 +885,7 @@ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, SDL
*
* \sa SDL_HasEvents
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
+extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(SDL_EventType type);
/**
@@ -904,7 +904,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
*
* \sa SDL_HasEvents
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
+extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(SDL_EventType minType, SDL_EventType maxType);
/**
* Clear events of a specific type from the event queue.
@@ -930,7 +930,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
*
* \sa SDL_FlushEvents
*/
-extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
+extern DECLSPEC void SDLCALL SDL_FlushEvent(SDL_EventType type);
/**
* Clear events of a range of types from the event queue.
@@ -955,7 +955,7 @@ extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
*
* \sa SDL_FlushEvent
*/
-extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
+extern DECLSPEC void SDLCALL SDL_FlushEvents(SDL_EventType minType, SDL_EventType maxType);
/**
* Poll for currently pending events.
@@ -1234,7 +1234,7 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *user
*
* \sa SDL_IsEventEnabled
*/
-extern DECLSPEC void SDLCALL SDL_SetEventEnabled(Uint32 type, SDL_bool enabled);
+extern DECLSPEC void SDLCALL SDL_SetEventEnabled(SDL_EventType type, SDL_bool enabled);
/**
* Query the state of processing events by type.
@@ -1246,7 +1246,7 @@ extern DECLSPEC void SDLCALL SDL_SetEventEnabled(Uint32 type, SDL_bool enabled);
*
* \sa SDL_SetEventEnabled
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_EventEnabled(Uint32 type);
+extern DECLSPEC SDL_bool SDLCALL SDL_EventEnabled(SDL_EventType type);
/**
* Allocate a set of user-defined events, and return the beginning event
diff --git a/include/SDL3/SDL_init.h b/include/SDL3/SDL_init.h
index d1b925270..30cc4a8b7 100644
--- a/include/SDL3/SDL_init.h
+++ b/include/SDL3/SDL_init.h
@@ -110,7 +110,7 @@ typedef enum
* \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.
@@ -127,7 +127,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.
@@ -142,7 +142,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.
@@ -156,7 +156,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.
diff --git a/include/SDL3/SDL_log.h b/include/SDL3/SDL_log.h
index 99d2f2c36..eef01cac7 100644
--- a/include/SDL3/SDL_log.h
+++ b/include/SDL3/SDL_log.h
@@ -135,7 +135,7 @@ extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
* \sa SDL_LogResetPriorities
* \sa SDL_LogSetAllPriority
*/
-extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
+extern DECLSPEC void SDLCALL SDL_LogSetPriority(SDL_LogCategory category,
SDL_LogPriority priority);
/**
@@ -148,7 +148,7 @@ extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
*
* \sa SDL_LogSetPriority
*/
-extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category);
+extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(SDL_LogCategory category);
/**
* Reset all priorities to default.
@@ -201,7 +201,7 @@ extern DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, .
* \sa SDL_LogMessageV
* \sa SDL_LogWarn
*/
-extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
+extern DECLSPEC void SDLCALL SDL_LogVerbose(SDL_LogCategory category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
/**
* Log a message with SDL_LOG_PRIORITY_DEBUG.
@@ -222,7 +222,7 @@ extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRI
* \sa SDL_LogVerbose
* \sa SDL_LogWarn
*/
-extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
+extern DECLSPEC void SDLCALL SDL_LogDebug(SDL_LogCategory category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
/**
* Log a message with SDL_LOG_PRIORITY_INFO.
@@ -243,7 +243,7 @@ extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING
* \sa SDL_LogVerbose
* \sa SDL_LogWarn
*/
-extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
+extern DECLSPEC void SDLCALL SDL_LogInfo(SDL_LogCategory category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
/**
* Log a message with SDL_LOG_PRIORITY_WARN.
@@ -264,7 +264,7 @@ extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING
* \sa SDL_LogMessageV
* \sa SDL_LogVerbose
*/
-extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
+extern DECLSPEC void SDLCALL SDL_LogWarn(SDL_LogCategory category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
/**
* Log a message with SDL_LOG_PRIORITY_ERROR.
@@ -285,7 +285,7 @@ extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING
* \sa SDL_LogVerbose
* \sa SDL_LogWarn
*/
-extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
+extern DECLSPEC void SDLCALL SDL_LogError(SDL_LogCategory category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
/**
* Log a message with SDL_LOG_PRIORITY_CRITICAL.
@@ -306,7 +306,7 @@ extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING
* \sa SDL_LogVerbose
* \sa SDL_LogWarn
*/
-extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
+extern DECLSPEC void SDLCALL SDL_LogCritical(SDL_LogCategory category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
/**
* Log a message with the specified category and priority.
@@ -328,7 +328,7 @@ extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STR
* \sa SDL_LogVerbose
* \sa SDL_LogWarn
*/
-extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
+extern DECLSPEC void SDLCALL SDL_LogMessage(SDL_LogCategory category,
SDL_LogPriority priority,
SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3);
@@ -351,7 +351,7 @@ extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
* \sa SDL_LogVerbose
* \sa SDL_LogWarn
*/
-extern DECLSPEC void SDLCALL SDL_LogMessageV(int category,
+extern DECLSPEC void SDLCALL SDL_LogMessageV(SDL_LogCategory category,
SDL_LogPriority priority,
SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3);
@@ -365,7 +365,7 @@ extern DECLSPEC void SDLCALL SDL_LogMessageV(int category,
* \param priority the priority of the message
* \param message the message being output
*/
-typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message);
+typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, SDL_LogCategory category, SDL_LogPriority priority, const char *message);
/**
* Get the current log output function.
diff --git a/include/SDL3/SDL_messagebox.h b/include/SDL3/SDL_messagebox.h
index 3d6855275..2b540a3fa 100644
--- a/include/SDL3/SDL_messagebox.h
+++ b/include/SDL3/SDL_messagebox.h
@@ -58,7 +58,7 @@ typedef enum
*/
typedef struct
{
- Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */
+ SDL_MessageBoxButtonFlags flags; /**< ::SDL_MessageBoxButtonFlags */
int buttonID; /**< User defined button id (value returned via SDL_ShowMessageBox) */
const char *text; /**< The UTF-8 button text */
} SDL_MessageBoxButtonData;
@@ -94,7 +94,7 @@ typedef struct
*/
typedef struct
{
- Uint32 flags; /**< ::SDL_MessageBoxFlags */
+ SDL_MessageBoxFlags flags; /**< ::SDL_MessageBoxFlags */
SDL_Window *window; /**< Parent window, can be NULL */
const char *title; /**< UTF-8 title */
const char *message; /**< UTF-8 message text */
@@ -180,7 +180,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++ */
diff --git a/include/SDL3/SDL_render.h b/include/SDL3/SDL_render.h
index 5024931e7..f1f61be21 100644
--- a/include/SDL3/SDL_render.h
+++ b/include/SDL3/SDL_render.h
@@ -80,7 +80,7 @@ typedef enum
typedef struct SDL_RendererInfo
{
const char *name; /**< The name of the renderer */
- Uint32 flags; /**< Supported ::SDL_RendererFlags */
+ SDL_RendererFlags flags; /**< Supported ::SDL_RendererFlags */
int num_texture_formats; /**< The number of available texture formats */
SDL_PixelFormatEnum texture_formats[16]; /**< The available texture formats */
int max_texture_width; /**< The maximum texture width */
@@ -225,7 +225,7 @@ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(int width, int height, S
* \sa SDL_GetRenderDriver
* \sa SDL_GetRendererInfo
*/
-extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 flags);
+extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name, SDL_RendererFlags flags);
/**
* Create a 2D rendering context for a window, with the specified properties.
diff --git a/include/SDL3/SDL_stdinc.h b/include/SDL3/SDL_stdinc.h diff --git a/include/SDL3/SDL_stdinc.h b/include/SDL3/SDL_stdinc.h
index e6a387c31..46c225953 100644 index e6a387c31..8aafb96c8 100644
--- a/include/SDL3/SDL_stdinc.h --- a/include/SDL3/SDL_stdinc.h
+++ b/include/SDL3/SDL_stdinc.h +++ b/include/SDL3/SDL_stdinc.h
@@ -132,8 +132,8 @@ char *alloca(); @@ -132,8 +132,8 @@ char *alloca();
@ -13,3 +316,15 @@ index e6a387c31..46c225953 100644
typedef int SDL_bool; typedef int SDL_bool;
/** /**
@@ -192,8 +192,8 @@ typedef uint64_t Uint64;
* They can be converted between POSIX time_t values with SDL_NS_TO_SECONDS() and SDL_SECONDS_TO_NS(),
* and between Windows FILETIME values with SDL_TimeToWindows() and SDL_TimeFromWindows().
*/
-#define SDL_MAX_TIME SDL_MAX_SINT64
-#define SDL_MIN_TIME SDL_MIN_SINT64
+#define SDL_MAX_TIME (SDL_Time)SDL_MAX_SINT64
+#define SDL_MIN_TIME (SDL_Time)SDL_MIN_SINT64
typedef Sint64 SDL_Time;
/* @} *//* Basic data types */

View File

@ -142,8 +142,7 @@ namespace SDL
public partial struct SDL_CommonEvent public partial struct SDL_CommonEvent
{ {
[NativeTypeName("Uint32")] public SDL_EventType type;
public uint type;
[NativeTypeName("Uint32")] [NativeTypeName("Uint32")]
public uint reserved; public uint reserved;
@ -883,8 +882,7 @@ namespace SDL
public partial struct SDL_UserEvent public partial struct SDL_UserEvent
{ {
[NativeTypeName("Uint32")] public SDL_EventType type;
public uint type;
[NativeTypeName("Uint32")] [NativeTypeName("Uint32")]
public uint reserved; public uint reserved;
@ -908,8 +906,7 @@ namespace SDL
public partial struct SDL_Event public partial struct SDL_Event
{ {
[FieldOffset(0)] [FieldOffset(0)]
[NativeTypeName("Uint32")] public SDL_EventType type;
public uint type;
[FieldOffset(0)] [FieldOffset(0)]
public SDL_CommonEvent common; public SDL_CommonEvent common;
@ -1034,19 +1031,19 @@ namespace SDL
public static extern void SDL_PumpEvents(); public static extern void SDL_PumpEvents();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_PeepEvents(SDL_Event* events, int numevents, SDL_eventaction action, [NativeTypeName("Uint32")] uint minType, [NativeTypeName("Uint32")] uint maxType); public static extern int SDL_PeepEvents(SDL_Event* events, int numevents, SDL_eventaction action, SDL_EventType minType, SDL_EventType maxType);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_HasEvent([NativeTypeName("Uint32")] uint type); public static extern SDL_bool SDL_HasEvent(SDL_EventType type);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_HasEvents([NativeTypeName("Uint32")] uint minType, [NativeTypeName("Uint32")] uint maxType); public static extern SDL_bool SDL_HasEvents(SDL_EventType minType, SDL_EventType maxType);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_FlushEvent([NativeTypeName("Uint32")] uint type); public static extern void SDL_FlushEvent(SDL_EventType type);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_FlushEvents([NativeTypeName("Uint32")] uint minType, [NativeTypeName("Uint32")] uint maxType); public static extern void SDL_FlushEvents(SDL_EventType minType, SDL_EventType maxType);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_PollEvent(SDL_Event* @event); public static extern SDL_bool SDL_PollEvent(SDL_Event* @event);
@ -1076,10 +1073,10 @@ namespace SDL
public static extern void SDL_FilterEvents([NativeTypeName("SDL_EventFilter")] delegate* unmanaged[Cdecl]<IntPtr, SDL_Event*, int> filter, [NativeTypeName("void*")] IntPtr userdata); public static extern void SDL_FilterEvents([NativeTypeName("SDL_EventFilter")] delegate* unmanaged[Cdecl]<IntPtr, SDL_Event*, int> filter, [NativeTypeName("void*")] IntPtr userdata);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_SetEventEnabled([NativeTypeName("Uint32")] uint type, SDL_bool enabled); public static extern void SDL_SetEventEnabled(SDL_EventType type, SDL_bool enabled);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_EventEnabled([NativeTypeName("Uint32")] uint type); public static extern SDL_bool SDL_EventEnabled(SDL_EventType type);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("Uint32")] [return: NativeTypeName("Uint32")]

View File

@ -45,17 +45,16 @@ namespace SDL
public static partial class SDL3 public static partial class SDL3
{ {
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_Init([NativeTypeName("Uint32")] uint flags); public static extern int SDL_Init(SDL_InitFlags flags);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_InitSubSystem([NativeTypeName("Uint32")] uint flags); public static extern int SDL_InitSubSystem(SDL_InitFlags flags);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_QuitSubSystem([NativeTypeName("Uint32")] uint flags); public static extern void SDL_QuitSubSystem(SDL_InitFlags flags);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("Uint32")] public static extern SDL_InitFlags SDL_WasInit(SDL_InitFlags flags);
public static extern uint SDL_WasInit([NativeTypeName("Uint32")] uint flags);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_Quit(); public static extern void SDL_Quit();

View File

@ -69,10 +69,10 @@ namespace SDL
public static extern void SDL_LogSetAllPriority(SDL_LogPriority priority); public static extern void SDL_LogSetAllPriority(SDL_LogPriority priority);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogSetPriority(int category, SDL_LogPriority priority); public static extern void SDL_LogSetPriority(SDL_LogCategory category, SDL_LogPriority priority);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_LogPriority SDL_LogGetPriority(int category); public static extern SDL_LogPriority SDL_LogGetPriority(SDL_LogCategory category);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogResetPriorities(); public static extern void SDL_LogResetPriorities();
@ -81,34 +81,34 @@ namespace SDL
public static extern void SDL_Log([NativeTypeName("const char *")] byte* fmt, __arglist); public static extern void SDL_Log([NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogVerbose(int category, [NativeTypeName("const char *")] byte* fmt, __arglist); public static extern void SDL_LogVerbose(SDL_LogCategory category, [NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogDebug(int category, [NativeTypeName("const char *")] byte* fmt, __arglist); public static extern void SDL_LogDebug(SDL_LogCategory category, [NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogInfo(int category, [NativeTypeName("const char *")] byte* fmt, __arglist); public static extern void SDL_LogInfo(SDL_LogCategory category, [NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogWarn(int category, [NativeTypeName("const char *")] byte* fmt, __arglist); public static extern void SDL_LogWarn(SDL_LogCategory category, [NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogError(int category, [NativeTypeName("const char *")] byte* fmt, __arglist); public static extern void SDL_LogError(SDL_LogCategory category, [NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogCritical(int category, [NativeTypeName("const char *")] byte* fmt, __arglist); public static extern void SDL_LogCritical(SDL_LogCategory category, [NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogMessage(int category, SDL_LogPriority priority, [NativeTypeName("const char *")] byte* fmt, __arglist); public static extern void SDL_LogMessage(SDL_LogCategory category, SDL_LogPriority priority, [NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogMessageV(int category, SDL_LogPriority priority, [NativeTypeName("const char *")] byte* fmt, [NativeTypeName("va_list")] byte* ap); public static extern void SDL_LogMessageV(SDL_LogCategory category, SDL_LogPriority priority, [NativeTypeName("const char *")] byte* fmt, [NativeTypeName("va_list")] byte* ap);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_GetLogOutputFunction([NativeTypeName("SDL_LogOutputFunction *")] delegate* unmanaged[Cdecl]<IntPtr, int, SDL_LogPriority, byte*, void>* callback, [NativeTypeName("void **")] IntPtr* userdata); public static extern void SDL_GetLogOutputFunction([NativeTypeName("SDL_LogOutputFunction *")] delegate* unmanaged[Cdecl]<IntPtr, SDL_LogCategory, SDL_LogPriority, byte*, void>* callback, [NativeTypeName("void **")] IntPtr* userdata);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_SetLogOutputFunction([NativeTypeName("SDL_LogOutputFunction")] delegate* unmanaged[Cdecl]<IntPtr, int, SDL_LogPriority, byte*, void> callback, [NativeTypeName("void*")] IntPtr userdata); public static extern void SDL_SetLogOutputFunction([NativeTypeName("SDL_LogOutputFunction")] delegate* unmanaged[Cdecl]<IntPtr, SDL_LogCategory, SDL_LogPriority, byte*, void> callback, [NativeTypeName("void*")] IntPtr userdata);
[NativeTypeName("#define SDL_MAX_LOG_MESSAGE 4096")] [NativeTypeName("#define SDL_MAX_LOG_MESSAGE 4096")]
public const int SDL_MAX_LOG_MESSAGE = 4096; public const int SDL_MAX_LOG_MESSAGE = 4096;

View File

@ -48,8 +48,7 @@ namespace SDL
public unsafe partial struct SDL_MessageBoxButtonData public unsafe partial struct SDL_MessageBoxButtonData
{ {
[NativeTypeName("Uint32")] public SDL_MessageBoxButtonFlags flags;
public uint flags;
public int buttonID; public int buttonID;
@ -93,8 +92,7 @@ namespace SDL
public unsafe partial struct SDL_MessageBoxData public unsafe partial struct SDL_MessageBoxData
{ {
[NativeTypeName("Uint32")] public SDL_MessageBoxFlags flags;
public uint flags;
public SDL_Window* window; public SDL_Window* window;
@ -119,6 +117,6 @@ namespace SDL
public static extern int SDL_ShowMessageBox([NativeTypeName("const SDL_MessageBoxData *")] SDL_MessageBoxData* messageboxdata, int* buttonid); public static extern int SDL_ShowMessageBox([NativeTypeName("const SDL_MessageBoxData *")] SDL_MessageBoxData* messageboxdata, int* buttonid);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_ShowSimpleMessageBox([NativeTypeName("Uint32")] uint flags, [NativeTypeName("const char *")] byte* title, [NativeTypeName("const char *")] byte* message, SDL_Window* window); public static extern int SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, [NativeTypeName("const char *")] byte* title, [NativeTypeName("const char *")] byte* message, SDL_Window* window);
} }
} }

View File

@ -40,8 +40,7 @@ namespace SDL
[NativeTypeName("const char *")] [NativeTypeName("const char *")]
public byte* name; public byte* name;
[NativeTypeName("Uint32")] public SDL_RendererFlags flags;
public uint flags;
public int num_texture_formats; public int num_texture_formats;
@ -105,7 +104,7 @@ namespace SDL
public static extern int SDL_CreateWindowAndRenderer(int width, int height, SDL_WindowFlags window_flags, SDL_Window** window, SDL_Renderer** renderer); public static extern int SDL_CreateWindowAndRenderer(int width, int height, SDL_WindowFlags window_flags, SDL_Window** window, SDL_Renderer** renderer);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Renderer* SDL_CreateRenderer(SDL_Window* window, [NativeTypeName("const char *")] byte* name, [NativeTypeName("Uint32")] uint flags); public static extern SDL_Renderer* SDL_CreateRenderer(SDL_Window* window, [NativeTypeName("const char *")] byte* name, SDL_RendererFlags flags);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Renderer* SDL_CreateRendererWithProperties(SDL_PropertiesID props); public static extern SDL_Renderer* SDL_CreateRendererWithProperties(SDL_PropertiesID props);

View File

@ -595,11 +595,11 @@ namespace SDL
[NativeTypeName("#define SDL_MIN_UINT64 ((Uint64)(0x0000000000000000ull))")] [NativeTypeName("#define SDL_MIN_UINT64 ((Uint64)(0x0000000000000000ull))")]
public const ulong SDL_MIN_UINT64 = ((ulong)(0x0000000000000000UL)); public const ulong SDL_MIN_UINT64 = ((ulong)(0x0000000000000000UL));
[NativeTypeName("#define SDL_MAX_TIME SDL_MAX_SINT64")] [NativeTypeName("#define SDL_MAX_TIME (SDL_Time)SDL_MAX_SINT64")]
public const long SDL_MAX_TIME = ((long)(0x7FFFFFFFFFFFFFFFL)); public const SDL_Time SDL_MAX_TIME = (SDL_Time)((long)(0x7FFFFFFFFFFFFFFFL));
[NativeTypeName("#define SDL_MIN_TIME SDL_MIN_SINT64")] [NativeTypeName("#define SDL_MIN_TIME (SDL_Time)SDL_MIN_SINT64")]
public const long SDL_MIN_TIME = ((long)(~0x7FFFFFFFFFFFFFFFL)); public const SDL_Time SDL_MIN_TIME = (SDL_Time)((long)(~0x7FFFFFFFFFFFFFFFL));
[NativeTypeName("#define SDL_FLT_EPSILON 1.1920928955078125e-07F")] [NativeTypeName("#define SDL_FLT_EPSILON 1.1920928955078125e-07F")]
public const float SDL_FLT_EPSILON = 1.1920928955078125e-07F; public const float SDL_FLT_EPSILON = 1.1920928955078125e-07F;

View File

@ -9,7 +9,7 @@ namespace SDL
public static unsafe bool SDL_QuitRequested() public static unsafe bool SDL_QuitRequested()
{ {
SDL_PumpEvents(); SDL_PumpEvents();
return SDL_PeepEvents(null, 0, SDL_eventaction.SDL_PEEKEVENT, (uint)SDL_EventType.SDL_EVENT_QUIT, (uint)SDL_EventType.SDL_EVENT_QUIT) > 0; return SDL_PeepEvents(null, 0, SDL_eventaction.SDL_PEEKEVENT, SDL_EventType.SDL_EVENT_QUIT, SDL_EventType.SDL_EVENT_QUIT) > 0;
} }
} }
} }