diff --git a/SDL3-CS/SDL-use-proper-types.patch b/SDL3-CS/SDL-use-proper-types.patch new file mode 100644 index 0000000..58ece12 --- /dev/null +++ b/SDL3-CS/SDL-use-proper-types.patch @@ -0,0 +1,15 @@ +diff --git a/include/SDL3/SDL_stdinc.h b/include/SDL3/SDL_stdinc.h +index e6a387c31..46c225953 100644 +--- a/include/SDL3/SDL_stdinc.h ++++ b/include/SDL3/SDL_stdinc.h +@@ -132,8 +132,8 @@ char *alloca(); + /** + * A boolean type. + */ +-#define SDL_FALSE 0 +-#define SDL_TRUE 1 ++#define SDL_FALSE (SDL_bool)0 ++#define SDL_TRUE (SDL_bool)1 + typedef int SDL_bool; + + /** diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_rect.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_rect.g.cs index c3dc263..4fb3d30 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_rect.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_rect.g.cs @@ -67,17 +67,17 @@ namespace SDL { public static SDL_bool SDL_PointInRect([NativeTypeName("const SDL_Point *")] SDL_Point* p, [NativeTypeName("const SDL_Rect *")] SDL_Rect* r) { - return ((p->x >= r->x) && (p->x < (r->x + r->w)) && (p->y >= r->y) && (p->y < (r->y + r->h))) ? 1 : 0; + return ((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) { - return ((r == null) || (r->w <= 0) || (r->h <= 0)) ? 1 : 0; + return ((r == null) || (r->w <= 0) || (r->h <= 0)) ? (SDL_bool)(1) : (SDL_bool)(0); } 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)) ? 1 : 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)] @@ -97,17 +97,17 @@ namespace SDL public static SDL_bool SDL_PointInRectFloat([NativeTypeName("const SDL_FPoint *")] SDL_FPoint* p, [NativeTypeName("const SDL_FRect *")] SDL_FRect* r) { - return ((p->x >= r->x) && (p->x < (r->x + r->w)) && (p->y >= r->y) && (p->y < (r->y + r->h))) ? 1 : 0; + return ((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) { - return ((r == null) || (r->w <= 0.0f) || (r->h <= 0.0f)) ? 1 : 0; + return ((r == null) || (r->w <= 0.0f) || (r->h <= 0.0f)) ? (SDL_bool)(1) : (SDL_bool)(0); } 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)))) ? 1 : 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) diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs index 577cbae..fe2bba7 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs @@ -541,11 +541,11 @@ namespace SDL [NativeTypeName("#define SDL_SIZE_MAX SIZE_MAX")] public const ulong SDL_SIZE_MAX = 0xffffffffffffffffUL; - [NativeTypeName("#define SDL_FALSE 0")] - public const int SDL_FALSE = 0; + [NativeTypeName("#define SDL_FALSE (SDL_bool)0")] + public const SDL_bool SDL_FALSE = (SDL_bool)(0); - [NativeTypeName("#define SDL_TRUE 1")] - public const int SDL_TRUE = 1; + [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)); diff --git a/SDL3-CS/generate_bindings.py b/SDL3-CS/generate_bindings.py index 7410dc7..8e34780 100644 --- a/SDL3-CS/generate_bindings.py +++ b/SDL3-CS/generate_bindings.py @@ -7,6 +7,7 @@ Generates C# bindings for SDL3 using ClangSharp. Prerequisites: - run `dotnet tool restore` (to install ClangSharpPInvokeGenerator) - https://github.com/libsdl-org/SDL checked out alongside this repository +- git apply `SDL-use-proper-types.patch` to SDL repo This script should be run manually. """