Merge pull request #217 from Susko3/rework-sdl-interface

Rework SDL_INIT_INTERFACE and add missing interfaces
This commit is contained in:
Dan Balasescu 2025-06-23 22:27:15 +09:00 committed by GitHub
commit dddb17d34d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 51 additions and 8 deletions

View File

@ -51,7 +51,10 @@ namespace SDL
SDL_GPU_COLORCOMPONENT_A = (byte)SDL3.SDL_GPU_COLORCOMPONENT_A,
}
public static partial class SDL3
#pragma warning disable CS0618 // Type or member is obsolete
public partial struct SDL_GPURenderStateDesc : SDL3.ISDLInterface
#pragma warning restore CS0618 // Type or member is obsolete
{
uint SDL3.ISDLInterface.version { set => version = value; }
}
}

View File

@ -0,0 +1,12 @@
// 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.
namespace SDL
{
#pragma warning disable CS0618 // Type or member is obsolete
public partial struct SDL_IOStreamInterface : SDL3.ISDLInterface
#pragma warning restore CS0618 // Type or member is obsolete
{
uint SDL3.ISDLInterface.version { set => version = value; }
}
}

View File

@ -19,4 +19,11 @@ namespace SDL
return SDLArray.Create(array, count);
}
}
#pragma warning disable CS0618 // Type or member is obsolete
public partial struct SDL_VirtualJoystickDesc : SDL3.ISDLInterface
#pragma warning restore CS0618 // Type or member is obsolete
{
uint SDL3.ISDLInterface.version { set => version = value; }
}
}

View File

@ -46,18 +46,20 @@ namespace SDL
[Macro]
public static uint SDL_FOURCC(byte A, byte B, byte C, byte D) => (uint)((A << 0) | (B << 8) | (C << 16) | (D << 24));
[Macro]
public static unsafe void SDL_INIT_INTERFACE(out SDL_IOStreamInterface iface)
[Obsolete("Do not use.")] // used internally
public interface ISDLInterface
{
iface = default;
iface.version = (uint)sizeof(SDL_IOStreamInterface);
internal uint version { set; }
}
[Macro]
public static unsafe void SDL_INIT_INTERFACE(out SDL_StorageInterface iface)
public static unsafe void SDL_INIT_INTERFACE<T>(out T iface)
#pragma warning disable CS0618 // Type or member is obsolete
where T : unmanaged, ISDLInterface
#pragma warning restore CS0618 // Type or member is obsolete
{
iface = default;
iface.version = (uint)sizeof(SDL_StorageInterface);
iface.version = (uint)sizeof(T);
}
public static unsafe void SDL_free(void* mem) => SDL_free((IntPtr)mem);

View File

@ -7,6 +7,13 @@ using JetBrains.Annotations;
namespace SDL
{
#pragma warning disable CS0618 // Type or member is obsolete
public partial struct SDL_StorageInterface : SDL3.ISDLInterface
#pragma warning restore CS0618 // Type or member is obsolete
{
uint SDL3.ISDLInterface.version { set => version = value; }
}
public static partial class SDL3
{
/// <returns>

View File

@ -0,0 +1,12 @@
// 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.
namespace SDL
{
#pragma warning disable CS0618 // Type or member is obsolete
public partial struct TTF_TextEngine : SDL3.ISDLInterface
#pragma warning restore CS0618 // Type or member is obsolete
{
uint SDL3.ISDLInterface.version { set => version = value; }
}
}