mirror of https://github.com/ppy/SDL3-CS.git
Add some missing macros
This commit is contained in:
parent
98930ae886
commit
05c7ec057c
|
|
@ -0,0 +1,44 @@
|
|||
// 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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,10 @@ namespace SDL
|
|||
|
||||
public static partial class SDL3
|
||||
{
|
||||
[Macro]
|
||||
public static SDL_AudioFormat SDL_DEFINE_AUDIO_FORMAT(UInt16 signed, UInt16 bigendian, UInt16 @float, UInt16 size) =>
|
||||
(SDL_AudioFormat)(((UInt16)(signed) << 15) | ((UInt16)(bigendian) << 12) | ((UInt16)(@float) << 8) | ((size) & (UInt16)SDL_AUDIO_MASK_BITSIZE));
|
||||
|
||||
[Constant]
|
||||
public static readonly SDL_AudioFormat SDL_AUDIO_S16 = BitConverter.IsLittleEndian ? SDL_AudioFormat.SDL_AUDIO_S16LE : SDL_AudioFormat.SDL_AUDIO_S16BE;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +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)
|
||||
{
|
||||
iface = default;
|
||||
iface.version = (uint)sizeof(SDL_IOStreamInterface);
|
||||
}
|
||||
|
||||
[Macro]
|
||||
public static unsafe void SDL_INIT_INTERFACE(out SDL_StorageInterface iface)
|
||||
{
|
||||
iface = default;
|
||||
iface.version = (uint)sizeof(SDL_StorageInterface);
|
||||
}
|
||||
|
||||
public static unsafe void SDL_free(void* mem) => SDL_free((IntPtr)mem);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue