Update bindings to 89c6bc5f5022e71433a9e4eb1a2edc6d79be71f2

This commit is contained in:
hwsmm 2024-09-21 20:50:09 +09:00
parent 75c49e289e
commit a65d0d7f6a
17 changed files with 222 additions and 126 deletions

2
External/SDL vendored

@ -1 +1 @@
Subproject commit 93bf53426840fd052da2aeb6d5a5a6f380f4c21a
Subproject commit 89c6bc5f5022e71433a9e4eb1a2edc6d79be71f2

102
External/SDL-bindings-fixes.patch vendored Normal file
View File

@ -0,0 +1,102 @@
diff --git a/include/SDL3/SDL.h b/include/SDL3/SDL.h
index 3698f6362..e43840cf1 100644
--- a/include/SDL3/SDL.h
+++ b/include/SDL3/SDL.h
@@ -28,6 +28,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_log.h b/include/SDL3/SDL_log.h
index 8feb9e0af..b66ae0422 100644
--- a/include/SDL3/SDL_log.h
+++ b/include/SDL3/SDL_log.h
@@ -471,7 +471,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogMessageV(int category,
*
* \since This datatype is available since SDL 3.0.0.
*/
-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_stdinc.h b/include/SDL3/SDL_stdinc.h
index 8818cda58..63210fe5e 100644
--- a/include/SDL3/SDL_stdinc.h
+++ b/include/SDL3/SDL_stdinc.h
@@ -51,9 +51,10 @@
#ifdef SDL_DEFINE_STDBOOL
#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
-#define bool uint8_t
-#define false 0
-#define true 1
+typedef uint8_t SDL_bool;
+#define bool SDL_bool
+#define false (SDL_bool)0
+#define true (SDL_bool)1
#endif
#else
#include <stdbool.h>
diff --git a/include/SDL3/SDL_rect.h b/include/SDL3/SDL_rect.h
index 8f9eee4df..e6bd7a131 100644
--- a/include/SDL3/SDL_rect.h
+++ b/include/SDL3/SDL_rect.h
@@ -154,7 +154,7 @@ SDL_FORCE_INLINE void SDL_RectToFRect(const SDL_Rect *rect, SDL_FRect *frect)
*/
SDL_FORCE_INLINE bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)
{
- return ( p && r && (p->x >= r->x) && (p->x < (r->x + r->w)) &&
+ return ( p != NULL && r != NULL && (p->x >= r->x) && (p->x < (r->x + r->w)) &&
(p->y >= r->y) && (p->y < (r->y + r->h)) ) ? true : false;
}
@@ -178,7 +178,7 @@ SDL_FORCE_INLINE bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)
*/
SDL_FORCE_INLINE bool SDL_RectEmpty(const SDL_Rect *r)
{
- return ((!r) || (r->w <= 0) || (r->h <= 0)) ? true : false;
+ return ((r == NULL) || (r->w <= 0) || (r->h <= 0)) ? true : false;
}
/**
@@ -202,7 +202,7 @@ SDL_FORCE_INLINE bool SDL_RectEmpty(const SDL_Rect *r)
*/
SDL_FORCE_INLINE bool SDL_RectsEqual(const SDL_Rect *a, const SDL_Rect *b)
{
- return (a && b && (a->x == b->x) && (a->y == b->y) &&
+ return (a != NULL && b != NULL && (a->x == b->x) && (a->y == b->y) &&
(a->w == b->w) && (a->h == b->h)) ? true : false;
}
@@ -319,7 +319,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetRectAndLineIntersection(const SDL_Rect *
*/
SDL_FORCE_INLINE bool SDL_PointInRectFloat(const SDL_FPoint *p, const SDL_FRect *r)
{
- return ( p && r && (p->x >= r->x) && (p->x <= (r->x + r->w)) &&
+ return ( p != NULL && r != NULL && (p->x >= r->x) && (p->x <= (r->x + r->w)) &&
(p->y >= r->y) && (p->y <= (r->y + r->h)) ) ? true : false;
}
@@ -343,7 +343,7 @@ SDL_FORCE_INLINE bool SDL_PointInRectFloat(const SDL_FPoint *p, const SDL_FRect
*/
SDL_FORCE_INLINE bool SDL_RectEmptyFloat(const SDL_FRect *r)
{
- return ((!r) || (r->w < 0.0f) || (r->h < 0.0f)) ? true : false;
+ return ((r == NULL) || (r->w < 0.0f) || (r->h < 0.0f)) ? true : false;
}
/**
@@ -373,7 +373,7 @@ SDL_FORCE_INLINE bool SDL_RectEmptyFloat(const SDL_FRect *r)
*/
SDL_FORCE_INLINE bool SDL_RectsEqualEpsilon(const SDL_FRect *a, const SDL_FRect *b, const float epsilon)
{
- return (a && b && ((a == b) ||
+ return (a != NULL && b != NULL && ((a == b) ||
((SDL_fabsf(a->x - b->x) <= epsilon) &&
(SDL_fabsf(a->y - b->y) <= epsilon) &&
(SDL_fabsf(a->w - b->w) <= epsilon) &&

View File

@ -1,48 +0,0 @@
diff --git a/include/SDL3/SDL.h b/include/SDL3/SDL.h
index 4e18f6382..d737c7a9a 100644
--- a/include/SDL3/SDL.h
+++ b/include/SDL3/SDL.h
@@ -28,6 +28,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_log.h b/include/SDL3/SDL_log.h
index 3c0e80f38..44f58add3 100644
--- a/include/SDL3/SDL_log.h
+++ b/include/SDL3/SDL_log.h
@@ -407,7 +407,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogMessageV(int category,
*
* \since This datatype is available since SDL 3.0.0.
*/
-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_stdinc.h b/include/SDL3/SDL_stdinc.h
index 5539f2a81..3155f3f31 100644
--- a/include/SDL3/SDL_stdinc.h
+++ b/include/SDL3/SDL_stdinc.h
@@ -194,7 +194,7 @@ void *alloca(size_t);
*
* \sa SDL_bool
*/
-#define SDL_FALSE false
+#define SDL_FALSE (SDL_bool)0
/**
* A boolean true.
@@ -203,7 +203,7 @@ void *alloca(size_t);
*
* \sa SDL_bool
*/
-#define SDL_TRUE true
+#define SDL_TRUE (SDL_bool)1
/**
* A boolean type: true or false.

View File

@ -33,6 +33,12 @@ namespace SDL
public int value;
}
public partial struct SDL_AtomicU32
{
[NativeTypeName("Uint32")]
public uint value;
}
public static unsafe partial class SDL3
{
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
@ -51,26 +57,37 @@ namespace SDL
public static extern void SDL_MemoryBarrierAcquireFunction();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_AtomicCompareAndSwap(SDL_AtomicInt* a, int oldval, int newval);
public static extern SDL_bool SDL_CompareAndSwapAtomicInt(SDL_AtomicInt* a, int oldval, int newval);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_AtomicSet(SDL_AtomicInt* a, int v);
public static extern int SDL_SetAtomicInt(SDL_AtomicInt* a, int v);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_AtomicGet(SDL_AtomicInt* a);
public static extern int SDL_GetAtomicInt(SDL_AtomicInt* a);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_AtomicAdd(SDL_AtomicInt* a, int v);
public static extern int SDL_AddAtomicInt(SDL_AtomicInt* a, int v);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_AtomicCompareAndSwapPointer([NativeTypeName("void **")] IntPtr* a, [NativeTypeName("void*")] IntPtr oldval, [NativeTypeName("void*")] IntPtr newval);
public static extern SDL_bool SDL_CompareAndSwapAtomicU32(SDL_AtomicU32* a, [NativeTypeName("Uint32")] uint oldval, [NativeTypeName("Uint32")] uint newval);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("Uint32")]
public static extern uint SDL_SetAtomicU32(SDL_AtomicU32* a, [NativeTypeName("Uint32")] uint v);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("Uint32")]
public static extern uint SDL_GetAtomicU32(SDL_AtomicU32* a);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_CompareAndSwapAtomicPointer([NativeTypeName("void **")] IntPtr* a, [NativeTypeName("void*")] IntPtr oldval, [NativeTypeName("void*")] IntPtr newval);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("void*")]
public static extern IntPtr SDL_AtomicSetPointer([NativeTypeName("void **")] IntPtr* a, [NativeTypeName("void*")] IntPtr v);
public static extern IntPtr SDL_SetAtomicPointer([NativeTypeName("void **")] IntPtr* a, [NativeTypeName("void*")] IntPtr v);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("void*")]
public static extern IntPtr SDL_AtomicGetPointer([NativeTypeName("void **")] IntPtr* a);
public static extern IntPtr SDL_GetAtomicPointer([NativeTypeName("void **")] IntPtr* a);
}
}

View File

@ -30,7 +30,7 @@ namespace SDL
public static partial class SDL3
{
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetCPUCount();
public static extern int SDL_GetNumLogicalCPUCores();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetCPUCacheLineSize();

View File

@ -100,6 +100,8 @@ namespace SDL
{
SDL_GPU_STOREOP_STORE,
SDL_GPU_STOREOP_DONT_CARE,
SDL_GPU_STOREOP_RESOLVE,
SDL_GPU_STOREOP_RESOLVE_AND_STORE,
}
public enum SDL_GPUIndexElementSize
@ -804,7 +806,7 @@ namespace SDL
public SDL_GPUColorTargetBlendState blend_state;
}
public unsafe partial struct SDL_GpuGraphicsPipelineTargetInfo
public unsafe partial struct SDL_GPUGraphicsPipelineTargetInfo
{
[NativeTypeName("const SDL_GPUColorTargetDescription *")]
public SDL_GPUColorTargetDescription* color_target_descriptions;
@ -842,7 +844,7 @@ namespace SDL
public SDL_GPUDepthStencilState depth_stencil_state;
public SDL_GpuGraphicsPipelineTargetInfo target_info;
public SDL_GPUGraphicsPipelineTargetInfo target_info;
public SDL_PropertiesID props;
}
@ -906,16 +908,23 @@ namespace SDL
public SDL_GPUStoreOp store_op;
public SDL_GPUTexture* resolve_texture;
[NativeTypeName("Uint32")]
public uint resolve_mip_level;
[NativeTypeName("Uint32")]
public uint resolve_layer;
public SDL_bool cycle;
public SDL_bool cycle_resolve_texture;
[NativeTypeName("Uint8")]
public byte padding1;
[NativeTypeName("Uint8")]
public byte padding2;
[NativeTypeName("Uint8")]
public byte padding3;
}
public unsafe partial struct SDL_GPUDepthStencilTargetInfo

View File

@ -329,6 +329,9 @@ namespace SDL
[NativeTypeName("#define SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK \"SDL_JOYSTICK_HIDAPI_STEAMDECK\"")]
public static ReadOnlySpan<byte> SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK => "SDL_JOYSTICK_HIDAPI_STEAMDECK"u8;
[NativeTypeName("#define SDL_HINT_JOYSTICK_HIDAPI_STEAM_HORI \"SDL_JOYSTICK_HIDAPI_STEAM_HORI\"")]
public static ReadOnlySpan<byte> SDL_HINT_JOYSTICK_HIDAPI_STEAM_HORI => "SDL_JOYSTICK_HIDAPI_STEAM_HORI"u8;
[NativeTypeName("#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH \"SDL_JOYSTICK_HIDAPI_SWITCH\"")]
public static ReadOnlySpan<byte> SDL_HINT_JOYSTICK_HIDAPI_SWITCH => "SDL_JOYSTICK_HIDAPI_SWITCH"u8;

View File

@ -62,9 +62,6 @@ namespace SDL
[return: NativeTypeName("const char *")]
public static extern byte* Unsafe_SDL_GetAppMetadataProperty([NativeTypeName("const char *")] byte* name);
[NativeTypeName("#define SDL_INIT_TIMER 0x00000001u")]
public const uint SDL_INIT_TIMER = 0x00000001U;
[NativeTypeName("#define SDL_INIT_AUDIO 0x00000010u")]
public const uint SDL_INIT_AUDIO = 0x00000010U;

View File

@ -54,7 +54,9 @@ namespace SDL
public enum SDL_LogPriority
{
SDL_LOG_PRIORITY_VERBOSE = 1,
SDL_LOG_PRIORITY_INVALID,
SDL_LOG_PRIORITY_TRACE,
SDL_LOG_PRIORITY_VERBOSE,
SDL_LOG_PRIORITY_DEBUG,
SDL_LOG_PRIORITY_INFO,
SDL_LOG_PRIORITY_WARN,
@ -83,6 +85,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_Log([NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogTrace(int category, [NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_LogVerbose(int category, [NativeTypeName("const char *")] byte* fmt, __arglist);

View File

@ -25,8 +25,6 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static SDL.SDL_Colorspace;
using static SDL.SDL_PixelFormat;
namespace SDL
{
@ -402,35 +400,5 @@ namespace SDL
[NativeTypeName("#define SDL_ALPHA_TRANSPARENT_FLOAT 0.0f")]
public const float SDL_ALPHA_TRANSPARENT_FLOAT = 0.0f;
[NativeTypeName("#define SDL_PIXELFORMAT_RGBA32 SDL_PIXELFORMAT_ABGR8888")]
public const SDL_PixelFormat SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888;
[NativeTypeName("#define SDL_PIXELFORMAT_ARGB32 SDL_PIXELFORMAT_BGRA8888")]
public const SDL_PixelFormat SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888;
[NativeTypeName("#define SDL_PIXELFORMAT_BGRA32 SDL_PIXELFORMAT_ARGB8888")]
public const SDL_PixelFormat SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888;
[NativeTypeName("#define SDL_PIXELFORMAT_ABGR32 SDL_PIXELFORMAT_RGBA8888")]
public const SDL_PixelFormat SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888;
[NativeTypeName("#define SDL_PIXELFORMAT_RGBX32 SDL_PIXELFORMAT_XBGR8888")]
public const SDL_PixelFormat SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_XBGR8888;
[NativeTypeName("#define SDL_PIXELFORMAT_XRGB32 SDL_PIXELFORMAT_BGRX8888")]
public const SDL_PixelFormat SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_BGRX8888;
[NativeTypeName("#define SDL_PIXELFORMAT_BGRX32 SDL_PIXELFORMAT_XRGB8888")]
public const SDL_PixelFormat SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_XRGB8888;
[NativeTypeName("#define SDL_PIXELFORMAT_XBGR32 SDL_PIXELFORMAT_RGBX8888")]
public const SDL_PixelFormat SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_RGBX8888;
[NativeTypeName("#define SDL_COLORSPACE_RGB_DEFAULT SDL_COLORSPACE_SRGB")]
public const SDL_Colorspace SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB;
[NativeTypeName("#define SDL_COLORSPACE_YUV_DEFAULT SDL_COLORSPACE_JPEG")]
public const SDL_Colorspace SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_JPEG;
}
}

View File

@ -75,7 +75,7 @@ namespace SDL
public static SDL_bool SDL_PointInRect([NativeTypeName("const SDL_Point *")] SDL_Point* p, [NativeTypeName("const SDL_Rect *")] SDL_Rect* r)
{
return ((p) != null && (r) != null && (p->x >= r->x) && (p->x < (r->x + r->w)) && (p->y >= r->y) && (p->y < (r->y + r->h))) ? (SDL_bool)(1) : (SDL_bool)(0);
return (p != null && r != null && (p->x >= r->x) && (p->x < (r->x + r->w)) && (p->y >= r->y) && (p->y < (r->y + r->h))) ? (SDL_bool)(1) : (SDL_bool)(0);
}
public static SDL_bool SDL_RectEmpty([NativeTypeName("const SDL_Rect *")] SDL_Rect* r)
@ -85,7 +85,7 @@ namespace SDL
public static SDL_bool SDL_RectsEqual([NativeTypeName("const SDL_Rect *")] SDL_Rect* a, [NativeTypeName("const SDL_Rect *")] SDL_Rect* b)
{
return ((a) != null && (b) != null && (a->x == b->x) && (a->y == b->y) && (a->w == b->w) && (a->h == b->h)) ? (SDL_bool)(1) : (SDL_bool)(0);
return (a != null && b != null && (a->x == b->x) && (a->y == b->y) && (a->w == b->w) && (a->h == b->h)) ? (SDL_bool)(1) : (SDL_bool)(0);
}
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
@ -105,7 +105,7 @@ namespace SDL
public static SDL_bool SDL_PointInRectFloat([NativeTypeName("const SDL_FPoint *")] SDL_FPoint* p, [NativeTypeName("const SDL_FRect *")] SDL_FRect* r)
{
return ((p) != null && (r) != null && (p->x >= r->x) && (p->x <= (r->x + r->w)) && (p->y >= r->y) && (p->y <= (r->y + r->h))) ? (SDL_bool)(1) : (SDL_bool)(0);
return (p != null && r != null && (p->x >= r->x) && (p->x <= (r->x + r->w)) && (p->y >= r->y) && (p->y <= (r->y + r->h))) ? (SDL_bool)(1) : (SDL_bool)(0);
}
public static SDL_bool SDL_RectEmptyFloat([NativeTypeName("const SDL_FRect *")] SDL_FRect* r)
@ -115,7 +115,7 @@ namespace SDL
public static SDL_bool SDL_RectsEqualEpsilon([NativeTypeName("const SDL_FRect *")] SDL_FRect* a, [NativeTypeName("const SDL_FRect *")] SDL_FRect* b, [NativeTypeName("const float")] float epsilon)
{
return ((a) != null && (b) != null && ((a == b) || ((SDL_fabsf(a->x - b->x) <= epsilon) && (SDL_fabsf(a->y - b->y) <= epsilon) && (SDL_fabsf(a->w - b->w) <= epsilon) && (SDL_fabsf(a->h - b->h) <= epsilon)))) ? (SDL_bool)(1) : (SDL_bool)(0);
return (a != null && b != null && ((a == b) || ((SDL_fabsf(a->x - b->x) <= epsilon) && (SDL_fabsf(a->y - b->y) <= epsilon) && (SDL_fabsf(a->w - b->w) <= epsilon) && (SDL_fabsf(a->h - b->h) <= epsilon)))) ? (SDL_bool)(1) : (SDL_bool)(0);
}
public static SDL_bool SDL_RectsEqualFloat([NativeTypeName("const SDL_FRect *")] SDL_FRect* a, [NativeTypeName("const SDL_FRect *")] SDL_FRect* b)

View File

@ -89,9 +89,6 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Environment* SDL_GetEnvironment();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_CleanupEnvironment();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Environment* SDL_CreateEnvironment(SDL_bool populated);
@ -112,6 +109,10 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_DestroyEnvironment(SDL_Environment* env);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_getenv", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* Unsafe_SDL_getenv([NativeTypeName("const char *")] byte* name);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_getenv_unsafe", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* Unsafe_SDL_getenv_unsafe([NativeTypeName("const char *")] byte* name);
@ -609,7 +610,7 @@ namespace SDL
public static SDL_bool SDL_size_mul_check_overflow([NativeTypeName("size_t")] nuint a, [NativeTypeName("size_t")] nuint b, [NativeTypeName("size_t *")] nuint* ret)
{
if (a != 0 && b > 0xffffffffffffffffUL / a)
if (a != 0 && unchecked(b > 0xffffffffffffffffUL / a))
{
return (SDL_bool)(0);
}
@ -620,7 +621,7 @@ namespace SDL
public static SDL_bool SDL_size_add_check_overflow([NativeTypeName("size_t")] nuint a, [NativeTypeName("size_t")] nuint b, [NativeTypeName("size_t *")] nuint* ret)
{
if (b > 0xffffffffffffffffUL - a)
if (b > unchecked(0xffffffffffffffffUL - a))
{
return (SDL_bool)(0);
}
@ -629,15 +630,18 @@ namespace SDL
return (SDL_bool)(1);
}
[NativeTypeName("#define __bool_true_false_are_defined 1")]
public const int __bool_true_false_are_defined = 1;
[NativeTypeName("#define false (SDL_bool)0")]
public const SDL_bool @false = (SDL_bool)(0);
[NativeTypeName("#define true (SDL_bool)1")]
public const SDL_bool @true = (SDL_bool)(1);
[NativeTypeName("#define SDL_SIZE_MAX SIZE_MAX")]
public const ulong SDL_SIZE_MAX = 0xffffffffffffffffUL;
[NativeTypeName("#define SDL_FALSE (SDL_bool)0")]
public const SDL_bool SDL_FALSE = (SDL_bool)(0);
[NativeTypeName("#define SDL_TRUE (SDL_bool)1")]
public const SDL_bool SDL_TRUE = (SDL_bool)(1);
[NativeTypeName("#define SDL_MAX_SINT8 ((Sint8)0x7F)")]
public const sbyte SDL_MAX_SINT8 = ((sbyte)(0x7F));
@ -698,25 +702,25 @@ namespace SDL
[NativeTypeName("#define SDL_PRIs64 \"lld\"")]
public static ReadOnlySpan<byte> SDL_PRIs64 => "lld"u8;
[NativeTypeName("#define SDL_PRIu64 \"llu\"")]
[NativeTypeName("#define SDL_PRIu64 PRIu64")]
public static ReadOnlySpan<byte> SDL_PRIu64 => "llu"u8;
[NativeTypeName("#define SDL_PRIx64 \"llx\"")]
[NativeTypeName("#define SDL_PRIx64 PRIx64")]
public static ReadOnlySpan<byte> SDL_PRIx64 => "llx"u8;
[NativeTypeName("#define SDL_PRIX64 \"llX\"")]
[NativeTypeName("#define SDL_PRIX64 PRIX64")]
public static ReadOnlySpan<byte> SDL_PRIX64 => "llX"u8;
[NativeTypeName("#define SDL_PRIs32 \"d\"")]
[NativeTypeName("#define SDL_PRIs32 PRId32")]
public static ReadOnlySpan<byte> SDL_PRIs32 => "d"u8;
[NativeTypeName("#define SDL_PRIu32 \"u\"")]
[NativeTypeName("#define SDL_PRIu32 PRIu32")]
public static ReadOnlySpan<byte> SDL_PRIu32 => "u"u8;
[NativeTypeName("#define SDL_PRIx32 \"x\"")]
[NativeTypeName("#define SDL_PRIx32 PRIx32")]
public static ReadOnlySpan<byte> SDL_PRIx32 => "x"u8;
[NativeTypeName("#define SDL_PRIX32 \"X\"")]
[NativeTypeName("#define SDL_PRIX32 PRIX32")]
public static ReadOnlySpan<byte> SDL_PRIX32 => "X"u8;
[NativeTypeName("#define SDL_INVALID_UNICODE_CODEPOINT 0xFFFD")]

View File

@ -6,9 +6,9 @@ namespace SDL
public unsafe partial class SDL3
{
[Macro]
public static int SDL_AtomicIncRef(SDL_AtomicInt* a) => SDL_AtomicAdd(a, 1);
public static int SDL_AtomicIncRef(SDL_AtomicInt* a) => SDL_AddAtomicInt(a, 1);
[Macro]
public static bool SDL_AtomicDecRef(SDL_AtomicInt* a) => SDL_AtomicAdd(a, -1) == 1;
public static bool SDL_AtomicDecRef(SDL_AtomicInt* a) => SDL_AddAtomicInt(a, -1) == 1;
}
}

View File

@ -9,7 +9,6 @@ namespace SDL
[Typedef]
public enum SDL_InitFlags : UInt32
{
SDL_INIT_TIMER = SDL3.SDL_INIT_TIMER,
SDL_INIT_AUDIO = SDL3.SDL_INIT_AUDIO,
SDL_INIT_VIDEO = SDL3.SDL_INIT_VIDEO,
SDL_INIT_JOYSTICK = SDL3.SDL_INIT_JOYSTICK,
@ -19,4 +18,8 @@ namespace SDL
SDL_INIT_SENSOR = SDL3.SDL_INIT_SENSOR,
SDL_INIT_CAMERA = SDL3.SDL_INIT_CAMERA,
}
public static partial class SDL3
{
}
}

View File

@ -133,5 +133,37 @@ namespace SDL
[Macro]
public static bool SDL_ISCOLORSPACE_FULL_RANGE(SDL_Colorspace X) => (SDL_COLORSPACERANGE(X) == SDL_COLOR_RANGE_FULL);
[Constant]
public static readonly SDL_PixelFormat SDL_PIXELFORMAT_RGBA32 = BitConverter.IsLittleEndian ? SDL_PIXELFORMAT_ABGR8888 : SDL_PIXELFORMAT_RGBA8888;
[Constant]
public static readonly SDL_PixelFormat SDL_PIXELFORMAT_ARGB32 = BitConverter.IsLittleEndian ? SDL_PIXELFORMAT_BGRA8888 : SDL_PIXELFORMAT_ARGB8888;
[Constant]
public static readonly SDL_PixelFormat SDL_PIXELFORMAT_BGRA32 = BitConverter.IsLittleEndian ? SDL_PIXELFORMAT_ARGB8888 : SDL_PIXELFORMAT_BGRA8888;
[Constant]
public static readonly SDL_PixelFormat SDL_PIXELFORMAT_ABGR32 = BitConverter.IsLittleEndian ? SDL_PIXELFORMAT_RGBA8888 : SDL_PIXELFORMAT_ABGR8888;
[Constant]
public static readonly SDL_PixelFormat SDL_PIXELFORMAT_RGBX32 = BitConverter.IsLittleEndian ? SDL_PIXELFORMAT_XBGR8888 : SDL_PIXELFORMAT_RGBX8888;
[Constant]
public static readonly SDL_PixelFormat SDL_PIXELFORMAT_XRGB32 = BitConverter.IsLittleEndian ? SDL_PIXELFORMAT_BGRX8888 : SDL_PIXELFORMAT_XRGB8888;
[Constant]
public static readonly SDL_PixelFormat SDL_PIXELFORMAT_BGRX32 = BitConverter.IsLittleEndian ? SDL_PIXELFORMAT_XRGB8888 : SDL_PIXELFORMAT_BGRX8888;
[Constant]
public static readonly SDL_PixelFormat SDL_PIXELFORMAT_XBGR32 = BitConverter.IsLittleEndian ? SDL_PIXELFORMAT_RGBX8888 : SDL_PIXELFORMAT_XBGR8888;
// FIXME: --language c doesn't put right types to below constants
[Constant]
public static readonly SDL_Colorspace SDL_COLORSPACE_RGB_DEFAULT = SDL_Colorspace.SDL_COLORSPACE_SRGB;
[Constant]
public static readonly SDL_Colorspace SDL_COLORSPACE_YUV_DEFAULT = SDL_Colorspace.SDL_COLORSPACE_SRGB;
}
}

View File

@ -8,8 +8,8 @@ namespace SDL
[Typedef]
public enum SDL_bool : byte
{
SDL_FALSE = SDL3.SDL_FALSE,
SDL_TRUE = SDL3.SDL_TRUE
SDL_FALSE = 0,
SDL_TRUE = 1
}
[Typedef]

View File

@ -142,7 +142,7 @@ def prepare_sdl_source():
"git",
"apply",
"--3way",
repository_root / "External" / "SDL-use-proper-types.patch"
repository_root / "External" / "SDL-bindings-fixes.patch"
], cwd = SDL_root)
def get_sdl_api_dump():
@ -229,6 +229,8 @@ base_command = [
"--methodClassName", "SDL3",
"--namespace", "SDL",
"--language", "c",
"--remap",
"void*=IntPtr",
"char=byte",
@ -236,6 +238,8 @@ base_command = [
"--define-macro",
"SDL_FUNCTION_POINTER_IS_VOID_POINTER",
"SDL_DEFINE_STDBOOL",
"NULL=0",
"--additional",
"--undefine-macro=_WIN32",