diff --git a/SDL3-CS/generate_bindings.py b/SDL3-CS/generate_bindings.py index 52addbf..9a784fc 100644 --- a/SDL3-CS/generate_bindings.py +++ b/SDL3-CS/generate_bindings.py @@ -221,7 +221,7 @@ def check_generated_functions(sdl_api, header, generated_file_paths): print(f"[⚠️ Warning] Function {name} not found in generated files:", *generated_file_paths) -defined_constant_regex = re.compile(r"\[Constant]\s*public (const|static readonly) \w+ (SDL_\w+) = ", re.MULTILINE) +defined_constant_regex = re.compile(r"\[Constant]\s*public (const|static readonly) \w+ (\w+_\w+) = ", re.MULTILINE) def get_manually_written_symbols(header): @@ -232,11 +232,10 @@ def get_manually_written_symbols(header): text = f.read() for match in defined_constant_regex.finditer(text): m = match.group(2) - assert m.startswith("SDL_") yield m -typedef_enum_regex = re.compile(r"\[Typedef]\s*public enum (SDL_\w+)", re.MULTILINE) +typedef_enum_regex = re.compile(r"\[Typedef]\s*public enum (\w+_\w+)", re.MULTILINE) def get_typedefs(): diff --git a/SDL3_image-CS/SDL3_image/ClangSharp/SDL_image.g.cs b/SDL3_image-CS/SDL3_image/ClangSharp/SDL_image.g.cs index 7be3e82..d182ae2 100644 --- a/SDL3_image-CS/SDL3_image/ClangSharp/SDL_image.g.cs +++ b/SDL3_image-CS/SDL3_image/ClangSharp/SDL_image.g.cs @@ -46,8 +46,7 @@ namespace SDL public static extern int IMG_Version(); [DllImport("SDL3_image", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [return: NativeTypeName("IMG_InitFlags")] - public static extern uint IMG_Init([NativeTypeName("IMG_InitFlags")] uint flags); + public static extern IMG_InitFlags IMG_Init(IMG_InitFlags flags); [DllImport("SDL3_image", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void IMG_Quit(); @@ -259,9 +258,6 @@ namespace SDL [NativeTypeName("#define SDL_IMAGE_MICRO_VERSION 0")] public const int SDL_IMAGE_MICRO_VERSION = 0; - [NativeTypeName("#define SDL_IMAGE_VERSION SDL_VERSIONNUM(SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_MICRO_VERSION)")] - public const int SDL_IMAGE_VERSION = ((3) * 1000000 + (1) * 1000 + (0)); - [NativeTypeName("#define IMG_INIT_JPG 0x00000001")] public const int IMG_INIT_JPG = 0x00000001; diff --git a/SDL3_image-CS/SDL3_image/SDL_image.cs b/SDL3_image-CS/SDL3_image/SDL_image.cs new file mode 100644 index 0000000..275bf23 --- /dev/null +++ b/SDL3_image-CS/SDL3_image/SDL_image.cs @@ -0,0 +1,25 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; + +namespace SDL +{ + [Flags] + [Typedef] + public enum IMG_InitFlags : int + { + IMG_INIT_JPG = SDL3_image.IMG_INIT_JPG, + IMG_INIT_PNG = SDL3_image.IMG_INIT_PNG, + IMG_INIT_TIF = SDL3_image.IMG_INIT_TIF, + IMG_INIT_WEBP = SDL3_image.IMG_INIT_WEBP, + IMG_INIT_JXL = SDL3_image.IMG_INIT_JXL, + IMG_INIT_AVIF = SDL3_image.IMG_INIT_AVIF, + } + + public static unsafe partial class SDL3_image + { + [Constant] + public static readonly int SDL_IMAGE_VERSION = SDL3.SDL_VERSIONNUM(SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_MICRO_VERSION); + } +} diff --git a/SDL3_ttf-CS/SDL3_ttf/ClangSharp/SDL_ttf.g.cs b/SDL3_ttf-CS/SDL3_ttf/ClangSharp/SDL_ttf.g.cs index 8134818..80e71eb 100644 --- a/SDL3_ttf-CS/SDL3_ttf/ClangSharp/SDL_ttf.g.cs +++ b/SDL3_ttf-CS/SDL3_ttf/ClangSharp/SDL_ttf.g.cs @@ -70,8 +70,7 @@ namespace SDL public partial struct TTF_SubString { - [NativeTypeName("TTF_SubStringFlags")] - public uint flags; + public TTF_SubStringFlags flags; public int offset; @@ -434,9 +433,6 @@ namespace SDL [NativeTypeName("#define SDL_TTF_MICRO_VERSION 0")] public const int SDL_TTF_MICRO_VERSION = 0; - [NativeTypeName("#define SDL_TTF_VERSION SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION)")] - public const int SDL_TTF_VERSION = ((3) * 1000000 + (0) * 1000 + (0)); - [NativeTypeName("#define TTF_PROP_FONT_CREATE_FILENAME_STRING \"SDL_ttf.font.create.filename\"")] public static ReadOnlySpan TTF_PROP_FONT_CREATE_FILENAME_STRING => "SDL_ttf.font.create.filename"u8; diff --git a/SDL3_ttf-CS/SDL3_ttf/SDL_ttf.cs b/SDL3_ttf-CS/SDL3_ttf/SDL_ttf.cs new file mode 100644 index 0000000..c1a9b08 --- /dev/null +++ b/SDL3_ttf-CS/SDL3_ttf/SDL_ttf.cs @@ -0,0 +1,23 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; + +namespace SDL +{ + [Flags] + [Typedef] + public enum TTF_SubStringFlags : int + { + TTF_SUBSTRING_TEXT_START = SDL3_ttf.TTF_SUBSTRING_TEXT_START, + TTF_SUBSTRING_LINE_START = SDL3_ttf.TTF_SUBSTRING_LINE_START, + TTF_SUBSTRING_LINE_END = SDL3_ttf.TTF_SUBSTRING_LINE_END, + TTF_SUBSTRING_TEXT_END = SDL3_ttf.TTF_SUBSTRING_TEXT_END, + } + + public static unsafe partial class SDL3_ttf + { + [Constant] + public static readonly int SDL_TTF_VERSION = SDL3.SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION); + } +}