Skip to content

Commit

Permalink
Merge pull request #162 from Susko3/update-bindings
Browse files Browse the repository at this point in the history
Update bindings
  • Loading branch information
smoogipoo authored Oct 2, 2024
2 parents bccaf2f + 05c7ec0 commit 2738571
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 45 deletions.
2 changes: 1 addition & 1 deletion External/SDL
Submodule SDL updated 240 files
6 changes: 3 additions & 3 deletions SDL3-CS.Tests/MainCallbacksTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected virtual SDL_AppResult Event(SDL_Event e)
return SDL_AppResult.SDL_APP_CONTINUE;
}

protected virtual void Quit()
protected virtual void Quit(SDL_AppResult result)
{
}

Expand Down Expand Up @@ -93,11 +93,11 @@ private static SDL_AppResult AppEvent(IntPtr appState, SDL_Event* e)
}

[UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])]
private static void AppQuit(IntPtr appState)
private static void AppQuit(IntPtr appState, SDL_AppResult result)
{
using var objectHandle = new ObjectHandle<MainCallbacksTest>(appState, true);
if (objectHandle.GetTarget(out var target))
target.Quit();
target.Quit(result);
}
}
}
44 changes: 44 additions & 0 deletions SDL3-CS.Tests/TestInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using NUnit.Framework;

namespace SDL.Tests
{
[TestFixture]
public class TestInterface
{
[Test]
public unsafe void TestIOInterface()
{
SDL_IOStreamInterface iface;

SDL3.SDL_INIT_INTERFACE(out iface);

Assert.That(iface.version, Is.EqualTo(sizeof(SDL_IOStreamInterface)));
Assert.That(iface.size == null);
Assert.That(iface.seek == null);
Assert.That(iface.read == null);
Assert.That(iface.write == null);
Assert.That(iface.flush == null);
Assert.That(iface.close == null);
}

[Test]
public unsafe void TestIOInterfaceManual()
{
SDL_IOStreamInterface iface = new SDL_IOStreamInterface
{
version = (uint)sizeof(SDL_IOStreamInterface),
};

Assert.That(iface.version, Is.EqualTo(sizeof(SDL_IOStreamInterface)));
Assert.That(iface.size == null);
Assert.That(iface.seek == null);
Assert.That(iface.read == null);
Assert.That(iface.write == null);
Assert.That(iface.flush == null);
Assert.That(iface.close == null);
}
}
}
4 changes: 4 additions & 0 deletions SDL3-CS/SDL3/ClangSharp/SDL_clipboard.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,9 @@ public static unsafe partial class SDL3
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_HasClipboardData([NativeTypeName("const char *")] byte* mime_type);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("char **")]
public static extern byte** SDL_GetClipboardMimeTypes([NativeTypeName("size_t *")] nuint* num_mime_types);
}
}
9 changes: 8 additions & 1 deletion SDL3-CS/SDL3/ClangSharp/SDL_filesystem.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ public partial struct SDL_PathInfo
public SDL_Time access_time;
}

public enum SDL_EnumerationResult
{
SDL_ENUM_CONTINUE,
SDL_ENUM_SUCCESS,
SDL_ENUM_FAILURE,
}

public static unsafe partial class SDL3
{
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetBasePath", ExactSpelling = true)]
Expand All @@ -86,7 +93,7 @@ public static unsafe partial class SDL3

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_EnumerateDirectory([NativeTypeName("const char *")] byte* path, [NativeTypeName("SDL_EnumerateDirectoryCallback")] delegate* unmanaged[Cdecl]<IntPtr, byte*, byte*, int> callback, [NativeTypeName("void*")] IntPtr userdata);
public static extern SDLBool SDL_EnumerateDirectory([NativeTypeName("const char *")] byte* path, [NativeTypeName("SDL_EnumerateDirectoryCallback")] delegate* unmanaged[Cdecl]<IntPtr, byte*, byte*, SDL_EnumerationResult> callback, [NativeTypeName("void*")] IntPtr userdata);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("bool")]
Expand Down
37 changes: 25 additions & 12 deletions SDL3-CS/SDL3/ClangSharp/SDL_gpu.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,18 @@ public enum SDL_GPUTextureFormat
SDL_GPU_TEXTUREFORMAT_R16_UINT,
SDL_GPU_TEXTUREFORMAT_R16G16_UINT,
SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT,
SDL_GPU_TEXTUREFORMAT_R32_UINT,
SDL_GPU_TEXTUREFORMAT_R32G32_UINT,
SDL_GPU_TEXTUREFORMAT_R32G32B32A32_UINT,
SDL_GPU_TEXTUREFORMAT_R8_INT,
SDL_GPU_TEXTUREFORMAT_R8G8_INT,
SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT,
SDL_GPU_TEXTUREFORMAT_R16_INT,
SDL_GPU_TEXTUREFORMAT_R16G16_INT,
SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT,
SDL_GPU_TEXTUREFORMAT_R32_INT,
SDL_GPU_TEXTUREFORMAT_R32G32_INT,
SDL_GPU_TEXTUREFORMAT_R32G32B32A32_INT,
SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB,
SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB,
SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB,
Expand Down Expand Up @@ -745,14 +751,14 @@ public partial struct SDL_GPURasterizerState
[NativeTypeName("bool")]
public SDLBool enable_depth_bias;

[NativeTypeName("bool")]
public SDLBool enable_depth_clip;

[NativeTypeName("Uint8")]
public byte padding1;

[NativeTypeName("Uint8")]
public byte padding2;

[NativeTypeName("Uint8")]
public byte padding3;
}

public partial struct SDL_GPUMultisampleState
Expand Down Expand Up @@ -882,10 +888,10 @@ public unsafe partial struct SDL_GPUComputePipelineCreateInfo
public uint num_readonly_storage_buffers;

[NativeTypeName("Uint32")]
public uint num_writeonly_storage_textures;
public uint num_readwrite_storage_textures;

[NativeTypeName("Uint32")]
public uint num_writeonly_storage_buffers;
public uint num_readwrite_storage_buffers;

[NativeTypeName("Uint32")]
public uint num_uniform_buffers;
Expand Down Expand Up @@ -1008,7 +1014,7 @@ public unsafe partial struct SDL_GPUTextureSamplerBinding
public SDL_GPUSampler* sampler;
}

public unsafe partial struct SDL_GPUStorageBufferWriteOnlyBinding
public unsafe partial struct SDL_GPUStorageBufferReadWriteBinding
{
public SDL_GPUBuffer* buffer;

Expand All @@ -1025,7 +1031,7 @@ public unsafe partial struct SDL_GPUStorageBufferWriteOnlyBinding
public byte padding3;
}

public unsafe partial struct SDL_GPUStorageTextureWriteOnlyBinding
public unsafe partial struct SDL_GPUStorageTextureReadWriteBinding
{
public SDL_GPUTexture* texture;

Expand Down Expand Up @@ -1208,7 +1214,7 @@ public static unsafe partial class SDL3
public static extern void SDL_EndGPURenderPass(SDL_GPURenderPass* render_pass);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_GPUComputePass* SDL_BeginGPUComputePass(SDL_GPUCommandBuffer* command_buffer, [NativeTypeName("const SDL_GPUStorageTextureWriteOnlyBinding *")] SDL_GPUStorageTextureWriteOnlyBinding* storage_texture_bindings, [NativeTypeName("Uint32")] uint num_storage_texture_bindings, [NativeTypeName("const SDL_GPUStorageBufferWriteOnlyBinding *")] SDL_GPUStorageBufferWriteOnlyBinding* storage_buffer_bindings, [NativeTypeName("Uint32")] uint num_storage_buffer_bindings);
public static extern SDL_GPUComputePass* SDL_BeginGPUComputePass(SDL_GPUCommandBuffer* command_buffer, [NativeTypeName("const SDL_GPUStorageTextureReadWriteBinding *")] SDL_GPUStorageTextureReadWriteBinding* storage_texture_bindings, [NativeTypeName("Uint32")] uint num_storage_texture_bindings, [NativeTypeName("const SDL_GPUStorageBufferReadWriteBinding *")] SDL_GPUStorageBufferReadWriteBinding* storage_buffer_bindings, [NativeTypeName("Uint32")] uint num_storage_buffer_bindings);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_BindGPUComputePipeline(SDL_GPUComputePass* compute_pass, SDL_GPUComputePipeline* compute_pipeline);
Expand Down Expand Up @@ -1291,19 +1297,23 @@ public static unsafe partial class SDL3
public static extern SDL_GPUTextureFormat SDL_GetGPUSwapchainTextureFormat(SDL_GPUDevice* device, SDL_Window* window);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_GPUTexture* SDL_AcquireGPUSwapchainTexture(SDL_GPUCommandBuffer* command_buffer, SDL_Window* window, [NativeTypeName("Uint32 *")] uint* w, [NativeTypeName("Uint32 *")] uint* h);
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_AcquireGPUSwapchainTexture(SDL_GPUCommandBuffer* command_buffer, SDL_Window* window, SDL_GPUTexture** swapchain_texture, [NativeTypeName("Uint32 *")] uint* swapchain_texture_width, [NativeTypeName("Uint32 *")] uint* swapchain_texture_height);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_SubmitGPUCommandBuffer(SDL_GPUCommandBuffer* command_buffer);
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_SubmitGPUCommandBuffer(SDL_GPUCommandBuffer* command_buffer);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_GPUFence* SDL_SubmitGPUCommandBufferAndAcquireFence(SDL_GPUCommandBuffer* command_buffer);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_WaitForGPUIdle(SDL_GPUDevice* device);
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_WaitForGPUIdle(SDL_GPUDevice* device);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_WaitForGPUFences(SDL_GPUDevice* device, [NativeTypeName("bool")] SDLBool wait_all, [NativeTypeName("SDL_GPUFence *const *")] SDL_GPUFence** fences, [NativeTypeName("Uint32")] uint num_fences);
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_WaitForGPUFences(SDL_GPUDevice* device, [NativeTypeName("bool")] SDLBool wait_all, [NativeTypeName("SDL_GPUFence *const *")] SDL_GPUFence** fences, [NativeTypeName("Uint32")] uint num_fences);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("bool")]
Expand Down Expand Up @@ -1342,6 +1352,9 @@ public static unsafe partial class SDL3
[NativeTypeName("#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE (1u << 5)")]
public const uint SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE = (1U << 5);

[NativeTypeName("#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE (1u << 6)")]
public const uint SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE = (1U << 6);

[NativeTypeName("#define SDL_GPU_BUFFERUSAGE_VERTEX (1u << 0)")]
public const uint SDL_GPU_BUFFERUSAGE_VERTEX = (1U << 0);

Expand Down
11 changes: 7 additions & 4 deletions SDL3-CS/SDL3/ClangSharp/SDL_loadso.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ 3. This notice may not be removed or altered from any source distribution.

namespace SDL
{
public partial struct SDL_SharedObject
{
}

public static unsafe partial class SDL3
{
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("void*")]
public static extern IntPtr SDL_LoadObject([NativeTypeName("const char *")] byte* sofile);
public static extern SDL_SharedObject* SDL_LoadObject([NativeTypeName("const char *")] byte* sofile);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("SDL_FunctionPointer")]
public static extern IntPtr SDL_LoadFunction([NativeTypeName("void*")] IntPtr handle, [NativeTypeName("const char *")] byte* name);
public static extern IntPtr SDL_LoadFunction(SDL_SharedObject* handle, [NativeTypeName("const char *")] byte* name);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_UnloadObject([NativeTypeName("void*")] IntPtr handle);
public static extern void SDL_UnloadObject(SDL_SharedObject* handle);
}
}
2 changes: 1 addition & 1 deletion SDL3-CS/SDL3/ClangSharp/SDL_main.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public static unsafe partial class SDL3
public static extern int SDL_RunApp(int argc, [NativeTypeName("char *[]")] byte** argv, [NativeTypeName("SDL_main_func")] delegate* unmanaged[Cdecl]<int, byte**, int> mainFunction, [NativeTypeName("void*")] IntPtr reserved);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_EnterAppMainCallbacks(int argc, [NativeTypeName("char *[]")] byte** argv, [NativeTypeName("SDL_AppInit_func")] delegate* unmanaged[Cdecl]<IntPtr*, int, byte**, SDL_AppResult> appinit, [NativeTypeName("SDL_AppIterate_func")] delegate* unmanaged[Cdecl]<IntPtr, SDL_AppResult> appiter, [NativeTypeName("SDL_AppEvent_func")] delegate* unmanaged[Cdecl]<IntPtr, SDL_Event*, SDL_AppResult> appevent, [NativeTypeName("SDL_AppQuit_func")] delegate* unmanaged[Cdecl]<IntPtr, void> appquit);
public static extern int SDL_EnterAppMainCallbacks(int argc, [NativeTypeName("char *[]")] byte** argv, [NativeTypeName("SDL_AppInit_func")] delegate* unmanaged[Cdecl]<IntPtr*, int, byte**, SDL_AppResult> appinit, [NativeTypeName("SDL_AppIterate_func")] delegate* unmanaged[Cdecl]<IntPtr, SDL_AppResult> appiter, [NativeTypeName("SDL_AppEvent_func")] delegate* unmanaged[Cdecl]<IntPtr, SDL_Event*, SDL_AppResult> appevent, [NativeTypeName("SDL_AppQuit_func")] delegate* unmanaged[Cdecl]<IntPtr, SDL_AppResult, void> appquit);
}
}
30 changes: 30 additions & 0 deletions SDL3-CS/SDL3/ClangSharp/SDL_mutex.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/

using System;
using System.Runtime.InteropServices;

namespace SDL
Expand All @@ -43,6 +44,24 @@ public partial struct SDL_Condition
{
}

public enum SDL_InitStatus
{
SDL_INIT_STATUS_UNINITIALIZED,
SDL_INIT_STATUS_INITIALIZING,
SDL_INIT_STATUS_INITIALIZED,
SDL_INIT_STATUS_UNINITIALIZING,
}

public partial struct SDL_InitState
{
public SDL_AtomicInt status;

public SDL_ThreadID thread;

[NativeTypeName("void*")]
public IntPtr reserved;
}

public static unsafe partial class SDL3
{
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
Expand Down Expand Up @@ -126,5 +145,16 @@ public static unsafe partial class SDL3
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_WaitConditionTimeout(SDL_Condition* cond, SDL_Mutex* mutex, [NativeTypeName("Sint32")] int timeoutMS);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_ShouldInit(SDL_InitState* state);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_ShouldQuit(SDL_InitState* state);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_SetInitialized(SDL_InitState* state, [NativeTypeName("bool")] SDLBool initialized);
}
}
9 changes: 2 additions & 7 deletions SDL3-CS/SDL3/ClangSharp/SDL_pixels.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ 3. This notice may not be removed or altered from any source distribution.

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static SDL.SDL_Colorspace;

namespace SDL
{
Expand Down Expand Up @@ -255,6 +254,8 @@ public enum SDL_Colorspace : uint
SDL_COLORSPACE_BT709_FULL = 0x22100421U,
SDL_COLORSPACE_BT2020_LIMITED = 0x21102609U,
SDL_COLORSPACE_BT2020_FULL = 0x22102609U,
SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB,
SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_JPEG,
}

public partial struct SDL_Color
Expand Down Expand Up @@ -403,11 +404,5 @@ public static unsafe partial class SDL3

[NativeTypeName("#define SDL_ALPHA_TRANSPARENT_FLOAT 0.0f")]
public const float SDL_ALPHA_TRANSPARENT_FLOAT = 0.0f;

[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;
}
}
11 changes: 9 additions & 2 deletions SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public partial struct SDL_Renderer

public partial struct SDL_Texture
{
public SDL_PixelFormat format;

public int w;

public int h;

public int refcount;
}

public static unsafe partial class SDL3
Expand Down Expand Up @@ -203,11 +210,11 @@ public static unsafe partial class SDL3

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_SetRenderLogicalPresentation(SDL_Renderer* renderer, int w, int h, SDL_RendererLogicalPresentation mode, SDL_ScaleMode scale_mode);
public static extern SDLBool SDL_SetRenderLogicalPresentation(SDL_Renderer* renderer, int w, int h, SDL_RendererLogicalPresentation mode);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern SDLBool SDL_GetRenderLogicalPresentation(SDL_Renderer* renderer, int* w, int* h, SDL_RendererLogicalPresentation* mode, SDL_ScaleMode* scale_mode);
public static extern SDLBool SDL_GetRenderLogicalPresentation(SDL_Renderer* renderer, int* w, int* h, SDL_RendererLogicalPresentation* mode);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("bool")]
Expand Down
4 changes: 4 additions & 0 deletions SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ public static unsafe partial class SDL3
[return: NativeTypeName("Uint32")]
public static extern uint SDL_crc32([NativeTypeName("Uint32")] uint crc, [NativeTypeName("const void *")] IntPtr data, [NativeTypeName("size_t")] nuint len);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("Uint32")]
public static extern uint SDL_murmur3_32([NativeTypeName("const void *")] IntPtr data, [NativeTypeName("size_t")] nuint len, [NativeTypeName("Uint32")] uint seed);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("void*")]
public static extern IntPtr SDL_memcpy([NativeTypeName("void*")] IntPtr dst, [NativeTypeName("const void *")] IntPtr src, [NativeTypeName("size_t")] nuint len);
Expand Down
Loading

0 comments on commit 2738571

Please sign in to comment.