Add friendly `string?` overloads to C `(const) char *` functions

This is done by adding a `Unsafe_` prefix to `(const) char *` (C# `byte*`) functions.
I am using `string?` instead of `ReadOnlyMemory<byte>?` because the returned pointer can
get invalidated and cause memory-safety issues.

The returned pointer is automatically freed if the return type is `char *`.
I've checked that the documentation for all functions (except in SDL_stdinc.h)
requires calling `SDL_free()` on the pointer.
This commit is contained in:
Susko3 2024-04-06 14:36:36 +02:00
parent c5e3181962
commit 91cef07624
26 changed files with 166 additions and 146 deletions

View File

@ -11,6 +11,9 @@ namespace SDL3.SourceGeneration
{
public static class Helper
{
/// <remarks>
/// Needs to match <c>unsafe_prefix</c> in generate_bindings.py.
/// </remarks>
public const string UnsafePrefix = "Unsafe_";
public static bool IsVoid(this TypeSyntax type) => type is PredefinedTypeSyntax predefined

View File

@ -46,13 +46,13 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetNumAudioDrivers();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetAudioDriver", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetAudioDriver(int index);
public static extern byte* Unsafe_SDL_GetAudioDriver(int index);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetCurrentAudioDriver", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetCurrentAudioDriver();
public static extern byte* Unsafe_SDL_GetCurrentAudioDriver();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_AudioDeviceID* SDL_GetAudioOutputDevices(int* count);
@ -60,9 +60,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_AudioDeviceID* SDL_GetAudioCaptureDevices(int* count);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetAudioDeviceName", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_GetAudioDeviceName(SDL_AudioDeviceID devid);
public static extern byte* Unsafe_SDL_GetAudioDeviceName(SDL_AudioDeviceID devid);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid, SDL_AudioSpec* spec, int* sample_frames);

View File

@ -56,13 +56,13 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetNumCameraDrivers();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetCameraDriver", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetCameraDriver(int index);
public static extern byte* Unsafe_SDL_GetCameraDriver(int index);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetCurrentCameraDriver", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetCurrentCameraDriver();
public static extern byte* Unsafe_SDL_GetCurrentCameraDriver();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_CameraDeviceID* SDL_GetCameraDevices(int* count);
@ -70,9 +70,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_CameraSpec* SDL_GetCameraDeviceSupportedFormats(SDL_CameraDeviceID devid, int* count);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetCameraDeviceName", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_GetCameraDeviceName(SDL_CameraDeviceID instance_id);
public static extern byte* Unsafe_SDL_GetCameraDeviceName(SDL_CameraDeviceID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_CameraPosition SDL_GetCameraDevicePosition(SDL_CameraDeviceID instance_id);

View File

@ -33,9 +33,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_SetClipboardText([NativeTypeName("const char *")] byte* text);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetClipboardText", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_GetClipboardText();
public static extern byte* Unsafe_SDL_GetClipboardText();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_HasClipboardText();
@ -43,9 +43,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_SetPrimarySelectionText([NativeTypeName("const char *")] byte* text);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetPrimarySelectionText", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_GetPrimarySelectionText();
public static extern byte* Unsafe_SDL_GetPrimarySelectionText();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_HasPrimarySelectionText();

View File

@ -42,9 +42,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_SetError([NativeTypeName("const char *")] byte* fmt, __arglist);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetError", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetError();
public static extern byte* Unsafe_SDL_GetError();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_ClearError();

View File

@ -67,17 +67,17 @@ namespace SDL
public static unsafe partial class SDL3
{
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetBasePath", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_GetBasePath();
public static extern byte* Unsafe_SDL_GetBasePath();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetPrefPath", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_GetPrefPath([NativeTypeName("const char *")] byte* org, [NativeTypeName("const char *")] byte* app);
public static extern byte* Unsafe_SDL_GetPrefPath([NativeTypeName("const char *")] byte* org, [NativeTypeName("const char *")] byte* app);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetUserFolder", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_GetUserFolder(SDL_Folder folder);
public static extern byte* Unsafe_SDL_GetUserFolder(SDL_Folder folder);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_CreateDirectory([NativeTypeName("const char *")] byte* path);

View File

@ -195,13 +195,13 @@ namespace SDL
[return: NativeTypeName("char **")]
public static extern byte** SDL_GetGamepadMappings(int* count);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadMappingForGUID", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_GetGamepadMappingForGUID([NativeTypeName("SDL_JoystickGUID")] SDL_GUID guid);
public static extern byte* Unsafe_SDL_GetGamepadMappingForGUID([NativeTypeName("SDL_JoystickGUID")] SDL_GUID guid);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadMapping", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_GetGamepadMapping(SDL_Gamepad* gamepad);
public static extern byte* Unsafe_SDL_GetGamepadMapping(SDL_Gamepad* gamepad);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_SetGamepadMapping(SDL_JoystickID instance_id, [NativeTypeName("const char *")] byte* mapping);
@ -215,13 +215,13 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_IsGamepad(SDL_JoystickID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadInstanceName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetGamepadInstanceName(SDL_JoystickID instance_id);
public static extern byte* Unsafe_SDL_GetGamepadInstanceName(SDL_JoystickID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadInstancePath", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetGamepadInstancePath(SDL_JoystickID instance_id);
public static extern byte* Unsafe_SDL_GetGamepadInstancePath(SDL_JoystickID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetGamepadInstancePlayerIndex(SDL_JoystickID instance_id);
@ -248,9 +248,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_GamepadType SDL_GetRealGamepadInstanceType(SDL_JoystickID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadInstanceMapping", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_GetGamepadInstanceMapping(SDL_JoystickID instance_id);
public static extern byte* Unsafe_SDL_GetGamepadInstanceMapping(SDL_JoystickID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Gamepad* SDL_OpenGamepad(SDL_JoystickID instance_id);
@ -267,13 +267,13 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_JoystickID SDL_GetGamepadInstanceID(SDL_Gamepad* gamepad);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetGamepadName(SDL_Gamepad* gamepad);
public static extern byte* Unsafe_SDL_GetGamepadName(SDL_Gamepad* gamepad);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadPath", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetGamepadPath(SDL_Gamepad* gamepad);
public static extern byte* Unsafe_SDL_GetGamepadPath(SDL_Gamepad* gamepad);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_GamepadType SDL_GetGamepadType(SDL_Gamepad* gamepad);
@ -303,9 +303,9 @@ namespace SDL
[return: NativeTypeName("Uint16")]
public static extern ushort SDL_GetGamepadFirmwareVersion(SDL_Gamepad* gamepad);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadSerial", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetGamepadSerial(SDL_Gamepad* gamepad);
public static extern byte* Unsafe_SDL_GetGamepadSerial(SDL_Gamepad* gamepad);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("Uint64")]
@ -338,16 +338,16 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_GamepadType SDL_GetGamepadTypeFromString([NativeTypeName("const char *")] byte* str);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadStringForType", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetGamepadStringForType(SDL_GamepadType type);
public static extern byte* Unsafe_SDL_GetGamepadStringForType(SDL_GamepadType type);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_GamepadAxis SDL_GetGamepadAxisFromString([NativeTypeName("const char *")] byte* str);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadStringForAxis", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
public static extern byte* Unsafe_SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_GamepadHasAxis(SDL_Gamepad* gamepad, SDL_GamepadAxis axis);
@ -359,9 +359,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_GamepadButton SDL_GetGamepadButtonFromString([NativeTypeName("const char *")] byte* str);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadStringForButton", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetGamepadStringForButton(SDL_GamepadButton button);
public static extern byte* Unsafe_SDL_GetGamepadStringForButton(SDL_GamepadButton button);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_GamepadHasButton(SDL_Gamepad* gamepad, SDL_GamepadButton button);
@ -415,13 +415,13 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_CloseGamepad(SDL_Gamepad* gamepad);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadAppleSFSymbolsNameForButton", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad* gamepad, SDL_GamepadButton button);
public static extern byte* Unsafe_SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad* gamepad, SDL_GamepadButton button);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGamepadAppleSFSymbolsNameForAxis", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad* gamepad, SDL_GamepadAxis axis);
public static extern byte* Unsafe_SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad* gamepad, SDL_GamepadAxis axis);
[NativeTypeName("#define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN")]
public static ReadOnlySpan<byte> SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN => "SDL.joystick.cap.mono_led"u8;

View File

@ -328,9 +328,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_HapticID* SDL_GetHaptics(int* count);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetHapticInstanceName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetHapticInstanceName(SDL_HapticID instance_id);
public static extern byte* Unsafe_SDL_GetHapticInstanceName(SDL_HapticID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Haptic* SDL_OpenHaptic(SDL_HapticID instance_id);
@ -341,9 +341,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_HapticID SDL_GetHapticInstanceID(SDL_Haptic* haptic);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetHapticName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetHapticName(SDL_Haptic* haptic);
public static extern byte* Unsafe_SDL_GetHapticName(SDL_Haptic* haptic);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_IsMouseHaptic();

View File

@ -49,9 +49,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void SDL_ResetHints();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetHint", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetHint([NativeTypeName("const char *")] byte* name);
public static extern byte* Unsafe_SDL_GetHint([NativeTypeName("const char *")] byte* name);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_GetHintBoolean([NativeTypeName("const char *")] byte* name, SDL_bool default_value);

View File

@ -125,13 +125,13 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_JoystickID* SDL_GetJoysticks(int* count);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetJoystickInstanceName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetJoystickInstanceName(SDL_JoystickID instance_id);
public static extern byte* Unsafe_SDL_GetJoystickInstanceName(SDL_JoystickID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetJoystickInstancePath", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetJoystickInstancePath(SDL_JoystickID instance_id);
public static extern byte* Unsafe_SDL_GetJoystickInstancePath(SDL_JoystickID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetJoystickInstancePlayerIndex(SDL_JoystickID instance_id);
@ -188,13 +188,13 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_PropertiesID SDL_GetJoystickProperties(SDL_Joystick* joystick);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetJoystickName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetJoystickName(SDL_Joystick* joystick);
public static extern byte* Unsafe_SDL_GetJoystickName(SDL_Joystick* joystick);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetJoystickPath", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetJoystickPath(SDL_Joystick* joystick);
public static extern byte* Unsafe_SDL_GetJoystickPath(SDL_Joystick* joystick);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetJoystickPlayerIndex(SDL_Joystick* joystick);
@ -222,9 +222,9 @@ namespace SDL
[return: NativeTypeName("Uint16")]
public static extern ushort SDL_GetJoystickFirmwareVersion(SDL_Joystick* joystick);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetJoystickSerial", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetJoystickSerial(SDL_Joystick* joystick);
public static extern byte* Unsafe_SDL_GetJoystickSerial(SDL_Joystick* joystick);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_JoystickType SDL_GetJoystickType(SDL_Joystick* joystick);

View File

@ -48,9 +48,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_KeyboardID* SDL_GetKeyboards(int* count);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetKeyboardInstanceName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetKeyboardInstanceName(SDL_KeyboardID instance_id);
public static extern byte* Unsafe_SDL_GetKeyboardInstanceName(SDL_KeyboardID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Window* SDL_GetKeyboardFocus();
@ -74,16 +74,16 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetScancodeName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetScancodeName(SDL_Scancode scancode);
public static extern byte* Unsafe_SDL_GetScancodeName(SDL_Scancode scancode);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Scancode SDL_GetScancodeFromName([NativeTypeName("const char *")] byte* name);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetKeyName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetKeyName(SDL_Keycode key);
public static extern byte* Unsafe_SDL_GetKeyName(SDL_Keycode key);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Keycode SDL_GetKeyFromName([NativeTypeName("const char *")] byte* name);

View File

@ -70,9 +70,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_MouseID* SDL_GetMice(int* count);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetMouseInstanceName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetMouseInstanceName(SDL_MouseID instance_id);
public static extern byte* Unsafe_SDL_GetMouseInstanceName(SDL_MouseID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_Window* SDL_GetMouseFocus();

View File

@ -80,9 +80,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_PenConnected(SDL_PenID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetPenName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetPenName(SDL_PenID instance_id);
public static extern byte* Unsafe_SDL_GetPenName(SDL_PenID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("Uint32")]

View File

@ -384,9 +384,9 @@ namespace SDL
public static unsafe partial class SDL3
{
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetPixelFormatName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetPixelFormatName(SDL_PixelFormatEnum format);
public static extern byte* Unsafe_SDL_GetPixelFormatName(SDL_PixelFormatEnum format);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_bool SDL_GetMasksForPixelFormatEnum(SDL_PixelFormatEnum format, int* bpp, [NativeTypeName("Uint32 *")] uint* Rmask, [NativeTypeName("Uint32 *")] uint* Gmask, [NativeTypeName("Uint32 *")] uint* Bmask, [NativeTypeName("Uint32 *")] uint* Amask);

View File

@ -29,8 +29,8 @@ namespace SDL
{
public static unsafe partial class SDL3
{
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetPlatform", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetPlatform();
public static extern byte* Unsafe_SDL_GetPlatform();
}
}

View File

@ -83,9 +83,9 @@ namespace SDL
[return: NativeTypeName("void*")]
public static extern IntPtr SDL_GetProperty(SDL_PropertiesID props, [NativeTypeName("const char *")] byte* name, [NativeTypeName("void*")] IntPtr default_value);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetStringProperty", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetStringProperty(SDL_PropertiesID props, [NativeTypeName("const char *")] byte* name, [NativeTypeName("const char *")] byte* default_value);
public static extern byte* Unsafe_SDL_GetStringProperty(SDL_PropertiesID props, [NativeTypeName("const char *")] byte* name, [NativeTypeName("const char *")] byte* default_value);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("Sint64")]

View File

@ -97,9 +97,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetNumRenderDrivers();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetRenderDriver", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetRenderDriver(int index);
public static extern byte* Unsafe_SDL_GetRenderDriver(int index);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_CreateWindowAndRenderer(int width, int height, SDL_WindowFlags window_flags, SDL_Window** window, SDL_Renderer** renderer);

View File

@ -48,9 +48,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_SensorID* SDL_GetSensors(int* count);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetSensorInstanceName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetSensorInstanceName(SDL_SensorID instance_id);
public static extern byte* Unsafe_SDL_GetSensorInstanceName(SDL_SensorID instance_id);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_SensorType SDL_GetSensorInstanceType(SDL_SensorID instance_id);
@ -67,9 +67,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_PropertiesID SDL_GetSensorProperties(SDL_Sensor* sensor);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetSensorName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetSensorName(SDL_Sensor* sensor);
public static extern byte* Unsafe_SDL_GetSensorName(SDL_Sensor* sensor);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_SensorType SDL_GetSensorType(SDL_Sensor* sensor);

View File

@ -73,9 +73,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetNumAllocations();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_getenv", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_getenv([NativeTypeName("const char *")] byte* name);
public static extern byte* Unsafe_SDL_getenv([NativeTypeName("const char *")] byte* name);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_setenv([NativeTypeName("const char *")] byte* name, [NativeTypeName("const char *")] byte* value, int overwrite);
@ -230,49 +230,49 @@ namespace SDL
[return: NativeTypeName("size_t")]
public static extern nuint SDL_strlcat([NativeTypeName("char *")] byte* dst, [NativeTypeName("const char *")] byte* src, [NativeTypeName("size_t")] nuint maxlen);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strdup", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strdup([NativeTypeName("const char *")] byte* str);
public static extern byte* Unsafe_SDL_strdup([NativeTypeName("const char *")] byte* str);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strndup", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strndup([NativeTypeName("const char *")] byte* str, [NativeTypeName("size_t")] nuint maxlen);
public static extern byte* Unsafe_SDL_strndup([NativeTypeName("const char *")] byte* str, [NativeTypeName("size_t")] nuint maxlen);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strrev", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strrev([NativeTypeName("char *")] byte* str);
public static extern byte* Unsafe_SDL_strrev([NativeTypeName("char *")] byte* str);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strupr", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strupr([NativeTypeName("char *")] byte* str);
public static extern byte* Unsafe_SDL_strupr([NativeTypeName("char *")] byte* str);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strlwr", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strlwr([NativeTypeName("char *")] byte* str);
public static extern byte* Unsafe_SDL_strlwr([NativeTypeName("char *")] byte* str);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strchr", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strchr([NativeTypeName("const char *")] byte* str, int c);
public static extern byte* Unsafe_SDL_strchr([NativeTypeName("const char *")] byte* str, int c);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strrchr", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strrchr([NativeTypeName("const char *")] byte* str, int c);
public static extern byte* Unsafe_SDL_strrchr([NativeTypeName("const char *")] byte* str, int c);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strstr", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strstr([NativeTypeName("const char *")] byte* haystack, [NativeTypeName("const char *")] byte* needle);
public static extern byte* Unsafe_SDL_strstr([NativeTypeName("const char *")] byte* haystack, [NativeTypeName("const char *")] byte* needle);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strnstr", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strnstr([NativeTypeName("const char *")] byte* haystack, [NativeTypeName("const char *")] byte* needle, [NativeTypeName("size_t")] nuint maxlen);
public static extern byte* Unsafe_SDL_strnstr([NativeTypeName("const char *")] byte* haystack, [NativeTypeName("const char *")] byte* needle, [NativeTypeName("size_t")] nuint maxlen);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strcasestr", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strcasestr([NativeTypeName("const char *")] byte* haystack, [NativeTypeName("const char *")] byte* needle);
public static extern byte* Unsafe_SDL_strcasestr([NativeTypeName("const char *")] byte* haystack, [NativeTypeName("const char *")] byte* needle);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_strtok_r", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_strtok_r([NativeTypeName("char *")] byte* s1, [NativeTypeName("const char *")] byte* s2, [NativeTypeName("char **")] byte** saveptr);
public static extern byte* Unsafe_SDL_strtok_r([NativeTypeName("char *")] byte* s1, [NativeTypeName("const char *")] byte* s2, [NativeTypeName("char **")] byte** saveptr);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("size_t")]
@ -282,29 +282,29 @@ namespace SDL
[return: NativeTypeName("size_t")]
public static extern nuint SDL_utf8strnlen([NativeTypeName("const char *")] byte* str, [NativeTypeName("size_t")] nuint bytes);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_itoa", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_itoa(int value, [NativeTypeName("char *")] byte* str, int radix);
public static extern byte* Unsafe_SDL_itoa(int value, [NativeTypeName("char *")] byte* str, int radix);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_uitoa", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_uitoa([NativeTypeName("unsigned int")] uint value, [NativeTypeName("char *")] byte* str, int radix);
public static extern byte* Unsafe_SDL_uitoa([NativeTypeName("unsigned int")] uint value, [NativeTypeName("char *")] byte* str, int radix);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_ltoa", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_ltoa([NativeTypeName("long")] int value, [NativeTypeName("char *")] byte* str, int radix);
public static extern byte* Unsafe_SDL_ltoa([NativeTypeName("long")] int value, [NativeTypeName("char *")] byte* str, int radix);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_ultoa", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_ultoa([NativeTypeName("unsigned long")] uint value, [NativeTypeName("char *")] byte* str, int radix);
public static extern byte* Unsafe_SDL_ultoa([NativeTypeName("unsigned long")] uint value, [NativeTypeName("char *")] byte* str, int radix);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_lltoa", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_lltoa([NativeTypeName("Sint64")] long value, [NativeTypeName("char *")] byte* str, int radix);
public static extern byte* Unsafe_SDL_lltoa([NativeTypeName("Sint64")] long value, [NativeTypeName("char *")] byte* str, int radix);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_ulltoa", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_ulltoa([NativeTypeName("Uint64")] ulong value, [NativeTypeName("char *")] byte* str, int radix);
public static extern byte* Unsafe_SDL_ulltoa([NativeTypeName("Uint64")] ulong value, [NativeTypeName("char *")] byte* str, int radix);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_atoi([NativeTypeName("const char *")] byte* str);
@ -512,9 +512,9 @@ namespace SDL
[return: NativeTypeName("size_t")]
public static extern nuint SDL_iconv([NativeTypeName("SDL_iconv_t")] SDL_iconv_data_t* cd, [NativeTypeName("const char **")] byte** inbuf, [NativeTypeName("size_t *")] nuint* inbytesleft, [NativeTypeName("char **")] byte** outbuf, [NativeTypeName("size_t *")] nuint* outbytesleft);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_iconv_string", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern byte* SDL_iconv_string([NativeTypeName("const char *")] byte* tocode, [NativeTypeName("const char *")] byte* fromcode, [NativeTypeName("const char *")] byte* inbuf, [NativeTypeName("size_t")] nuint inbytesleft);
public static extern byte* Unsafe_SDL_iconv_string([NativeTypeName("const char *")] byte* tocode, [NativeTypeName("const char *")] byte* fromcode, [NativeTypeName("const char *")] byte* inbuf, [NativeTypeName("size_t")] nuint inbytesleft);
public static int SDL_size_mul_overflow([NativeTypeName("size_t")] nuint a, [NativeTypeName("size_t")] nuint b, [NativeTypeName("size_t *")] nuint* ret)
{

View File

@ -61,19 +61,19 @@ namespace SDL
[SupportedOSPlatform("Android")]
public static extern void SDL_AndroidBackButton();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_AndroidGetInternalStoragePath", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
[SupportedOSPlatform("Android")]
public static extern byte* SDL_AndroidGetInternalStoragePath();
public static extern byte* Unsafe_SDL_AndroidGetInternalStoragePath();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[SupportedOSPlatform("Android")]
public static extern int SDL_AndroidGetExternalStorageState([NativeTypeName("Uint32 *")] uint* state);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_AndroidGetExternalStoragePath", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
[SupportedOSPlatform("Android")]
public static extern byte* SDL_AndroidGetExternalStoragePath();
public static extern byte* Unsafe_SDL_AndroidGetExternalStoragePath();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[SupportedOSPlatform("Android")]

View File

@ -52,10 +52,10 @@ namespace SDL
[SupportedOSPlatform("Windows")]
public static extern IntPtr SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_WinRTGetFSPathUTF8", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
[SupportedOSPlatform("Windows")]
public static extern byte* SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
public static extern byte* Unsafe_SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[SupportedOSPlatform("Windows")]

View File

@ -51,9 +51,9 @@ namespace SDL
[UnsupportedOSPlatform("windows")]
public static extern SDL_Thread* SDL_CreateThreadWithStackSize([NativeTypeName("SDL_ThreadFunction")] delegate* unmanaged[Cdecl]<IntPtr, int> fn, [NativeTypeName("const char *")] byte* name, [NativeTypeName("const size_t")] nuint stacksize, [NativeTypeName("void*")] IntPtr data);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetThreadName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetThreadName(SDL_Thread* thread);
public static extern byte* Unsafe_SDL_GetThreadName(SDL_Thread* thread);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_ThreadID SDL_GetCurrentThreadID();

View File

@ -51,9 +51,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_TouchID* SDL_GetTouchDevices(int* count);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetTouchDeviceName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetTouchDeviceName(SDL_TouchID touchID);
public static extern byte* Unsafe_SDL_GetTouchDeviceName(SDL_TouchID touchID);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_TouchDeviceType SDL_GetTouchDeviceType(SDL_TouchID touchID);

View File

@ -44,9 +44,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetVersion(SDL_Version* ver);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetRevision", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetRevision();
public static extern byte* Unsafe_SDL_GetRevision();
[NativeTypeName("#define SDL_MAJOR_VERSION 3")]
public const int SDL_MAJOR_VERSION = 3;

View File

@ -151,13 +151,13 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetNumVideoDrivers();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetVideoDriver", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetVideoDriver(int index);
public static extern byte* Unsafe_SDL_GetVideoDriver(int index);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetCurrentVideoDriver", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetCurrentVideoDriver();
public static extern byte* Unsafe_SDL_GetCurrentVideoDriver();
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_SystemTheme SDL_GetSystemTheme();
@ -171,9 +171,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern SDL_PropertiesID SDL_GetDisplayProperties(SDL_DisplayID displayID);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetDisplayName", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetDisplayName(SDL_DisplayID displayID);
public static extern byte* Unsafe_SDL_GetDisplayName(SDL_DisplayID displayID);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect* rect);
@ -263,9 +263,9 @@ namespace SDL
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_SetWindowTitle(SDL_Window* window, [NativeTypeName("const char *")] byte* title);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetWindowTitle", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern byte* SDL_GetWindowTitle(SDL_Window* window);
public static extern byte* Unsafe_SDL_GetWindowTitle(SDL_Window* window);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int SDL_SetWindowIcon(SDL_Window* window, SDL_Surface* icon);

View File

@ -18,6 +18,9 @@ import re
import subprocess
import sys
# Needs to match SDL3.SourceGeneration.Helper.UnsafePrefix
unsafe_prefix = "Unsafe_"
SDL_root = pathlib.Path("../../SDL")
SDL_include_root = SDL_root / "include"
SDL3_header_base = "SDL3" # base folder of header files
@ -282,6 +285,12 @@ def generate_platform_specific_headers(sdl_api, header: Header, platforms):
check_generated_functions(sdl_api, header, output_files)
def get_string_returning_functions(sdl_api):
for f in sdl_api:
if f["retval"] in ("const char*", "char*"):
yield f
def main():
sdl_api = get_sdl_api_dump()
@ -292,6 +301,14 @@ def main():
for type_name in typedefs:
base_command.append(typedef(type_name))
str_ret_funcs = list(get_string_returning_functions(sdl_api))
if str_ret_funcs:
base_command.append("--remap")
for func in str_ret_funcs:
name = func["name"]
# add unsafe prefix to `const char *` functions so that the source generator can make friendly overloads with the unprefixed name.
base_command.append(f"{name}={unsafe_prefix}{name}")
for header in headers:
output_file = run_clangsharp(base_command, header)
check_generated_functions(sdl_api, header, [output_file])