added enums to ttf and image

This commit is contained in:
WizzardMaker 2024-12-03 15:36:08 +01:00
parent 957e29d137
commit 06fabcf8b0
5 changed files with 52 additions and 13 deletions

View File

@ -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():

View File

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

View File

@ -0,0 +1,25 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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);
}
}

View File

@ -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<byte> TTF_PROP_FONT_CREATE_FILENAME_STRING => "SDL_ttf.font.create.filename"u8;

View File

@ -0,0 +1,23 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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);
}
}