Skip to content

Commit 3767eb2

Browse files
authored
Merge pull request #266 from Susko3/fix-SDL_mixer-friendly-overloads
Fix SDL_mixer friendly overloads not generating
2 parents 4988d55 + 3c21f68 commit 3767eb2

4 files changed

Lines changed: 46 additions & 4 deletions

File tree

SDL3-CS.SourceGeneration/UnfriendlyMethodFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class UnfriendlyMethodFinder : ISyntaxReceiver
1515
{
1616
public readonly Dictionary<string, List<GeneratedMethod>> Methods = new Dictionary<string, List<GeneratedMethod>>();
1717

18-
private static readonly string[] sdlPrefixes = ["SDL_", "TTF_", "IMG_", "Mix_"];
18+
private static readonly string[] sdlPrefixes = ["SDL_", "TTF_", "IMG_", "MIX_"];
1919

2020
/// <summary>
2121
/// Checks whether the method is from any SDL library.

SDL3-CS.Tests/TestMixer.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using NUnit.Framework;
5+
using static SDL.SDL3_mixer;
6+
using static SDL.SDL3;
7+
8+
namespace SDL.Tests
9+
{
10+
[TestFixture]
11+
public class TestMixer
12+
{
13+
[Test]
14+
public unsafe void TestBasic()
15+
{
16+
SDL_Init(0);
17+
18+
bool init = MIX_Init();
19+
20+
try
21+
{
22+
Assert.That(init, Is.True, SDL_GetError);
23+
Assert.That(MIX_Version(), Is.EqualTo(SDL_MIXER_VERSION));
24+
25+
Assume.That(MIX_GetNumAudioDecoders() > 0);
26+
string? name = MIX_GetAudioDecoder(0);
27+
Assert.That(name, Is.Not.Null, SDL_GetError);
28+
29+
Assume.That(@"C:\Windows\Media\Windows Logon.wav", Does.Exist);
30+
var decoder = MIX_CreateAudioDecoder(@"C:\Windows\Media\Windows Logon.wav", 0);
31+
Assert.That(decoder != null, SDL_GetError);
32+
MIX_DestroyAudioDecoder(decoder);
33+
}
34+
finally
35+
{
36+
MIX_Quit();
37+
SDL_Quit();
38+
}
39+
}
40+
}
41+
}

SDL3-CS/generate_bindings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ def run_clangsharp(command, header: Header):
312312
"--file", header.input_file(),
313313
"--output", header.output_file(),
314314
"--libraryPath", header.base,
315-
316315
"--methodClassName", header.base,
317316
]
318317

@@ -374,6 +373,8 @@ def get_string_returning_functions(sdl_api):
374373
yield "TTF_GetFontFamilyName"
375374
yield "TTF_GetFontStyleName"
376375

376+
yield "MIX_GetAudioDecoder"
377+
377378

378379
def should_skip(solo_headers: list[Header], header: Header):
379380
if len(solo_headers) == 0:

SDL3_mixer-CS/SDL3_mixer/ClangSharp/SDL_mixer.g.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ public static unsafe partial class SDL3_mixer
7979
[DllImport("SDL3_mixer", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
8080
public static extern int MIX_GetNumAudioDecoders();
8181

82-
[DllImport("SDL3_mixer", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
82+
[DllImport("SDL3_mixer", CallingConvention = CallingConvention.Cdecl, EntryPoint = "MIX_GetAudioDecoder", ExactSpelling = true)]
8383
[return: NativeTypeName("const char *")]
84-
public static extern byte* MIX_GetAudioDecoder(int index);
84+
public static extern byte* Unsafe_MIX_GetAudioDecoder(int index);
8585

8686
[DllImport("SDL3_mixer", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
8787
public static extern MIX_Mixer* MIX_CreateMixerDevice(SDL_AudioDeviceID devid, [NativeTypeName("const SDL_AudioSpec *")] SDL_AudioSpec* spec);

0 commit comments

Comments
 (0)