Apply UTF-8 marshaling to return values and removed extra wrapping layer

This commit is contained in:
Jameson Ernst 2013-06-25 22:12:29 -07:00
parent 1741030481
commit 1c6c04f2e2

View file

@ -158,17 +158,12 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_ClearHints();
[DllImport(nativeLibName, EntryPoint = "SDL_GetHint", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetHint(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetHint(
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
string name
);
public static string SDL_GetHint(string name)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetHint(name)
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_bool SDL_SetHint(
@ -194,12 +189,9 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_ClearError();
[DllImport(nativeLibName, EntryPoint = "SDL_GetError", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetError();
public static string SDL_GetError()
{
return Marshal.PtrToStringAnsi(INTERNAL_SDL_GetError());
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetError();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_SetError(
@ -417,14 +409,9 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
private static extern void SDL_GetVersion(ref SDL_version ver);
[DllImport(nativeLibName, EntryPoint = "SDL_GetRevision", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetRevision();
public static string SDL_GetRevision()
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetRevision()
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetRevision();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetRevisionNumber();
@ -593,14 +580,9 @@ namespace SDL2
ref SDL_DisplayMode mode
);
[DllImport(nativeLibName, EntryPoint = "SDL_GetCurrentVideoDriver", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetCurrentVideoDriver();
public static string SDL_GetCurrentVideoDriver()
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetCurrentVideoDriver()
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetCurrentVideoDriver();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetDesktopDisplayMode(
@ -632,16 +614,11 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetNumVideoDrivers();
[DllImport(nativeLibName, EntryPoint = "SDL_GetVideoDriver", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetVideoDriver(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetVideoDriver(
int index
);
public static string SDL_GetVideoDriver(int index)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetVideoDriver(index)
);
}
/* window refers to an SDL_Window* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -722,16 +699,11 @@ namespace SDL2
public static extern IntPtr SDL_GetWindowSurface(IntPtr window);
/* window refers to an SDL_Window* */
[DllImport(nativeLibName, EntryPoint = "SDL_GetWindowTitle", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetWindowTitle(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetWindowTitle(
IntPtr window
);
public static string SDL_GetWindowTitle(IntPtr window)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetWindowTitle(window)
);
}
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -1725,16 +1697,11 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_FreePalette(IntPtr palette);
[DllImport(nativeLibName, EntryPoint = "SDL_GetPixelFormatName", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetPixelFormatName(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetPixelFormatName(
uint format
);
public static string SDL_GetPixelFormatName(uint format)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetPixelFormatName(format)
);
}
/* format refers to an SDL_PixelFormat* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -2181,14 +2148,9 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_bool SDL_HasClipboardText();
[DllImport(nativeLibName, EntryPoint = "SDL_GetClipboardText", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetClipboardText();
public static string SDL_GetClipboardText(string name)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetClipboardText()
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetClipboardText();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_SetClipboardText(
@ -3357,15 +3319,9 @@ namespace SDL2
public static extern void SDL_GetScancodeFromKey(SDL_Keycode key);
/* Wrapper for SDL_GetScancodeName */
[DllImport(nativeLibName, EntryPoint="SDL_GetScancodeName", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetScancodeName(SDL_Scancode scancode);
/* Get a human-readable name for a scancode */
public static string SDL_GetScancodeName(SDL_Scancode scancode)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetScancodeName(scancode)
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetScancodeName(SDL_Scancode scancode);
/* Get a scancode from a human-readable name */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -3374,15 +3330,9 @@ namespace SDL2
);
/* Wrapper for SDL_GetKeyName */
[DllImport(nativeLibName, EntryPoint="SDL_GetKeyName", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetKeyName(SDL_Keycode key);
/* Get a human-readable name for a key */
public static string SDL_GetKeyName(SDL_Keycode key)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetKeyName(key)
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetKeyName(SDL_Keycode key);
/* Get a key code from a human-readable name */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -3593,27 +3543,17 @@ namespace SDL2
public static extern int SDL_JoystickIndex(IntPtr joystick);
/* joystick refers to an SDL_Joystick* */
[DllImport(nativeLibName, EntryPoint = "SDL_JoystickName", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_JoystickName(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string INTERNAL_SDL_JoystickName(
IntPtr joystick
);
public static string SDL_JoystickName(IntPtr joystick)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_JoystickName(joystick)
);
}
[DllImport(nativeLibName, EntryPoint = "SDL_JoystickNameForIndex", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_JoystickNameForIndex(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_JoystickNameForIndex(
int device_index
);
public static string SDL_JoystickNameForIndex(int device_index)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_JoystickNameForIndex(device_index)
);
}
/* joystick refers to an SDL_Joystick* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -3755,59 +3695,36 @@ namespace SDL2
);
[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMappingForGUID", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GameControllerMappingForGUID(
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GameControllerMappingForGUID(
SDL_JoystickGUID guid
);
public static string SDL_GameControllerMappingForGUID(
SDL_JoystickGUID guid
) {
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GameControllerMappingForGUID(guid)
);
}
/* gamecontroller refers to an SDL_GameController* */
[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMapping", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GameControllerMapping(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GameControllerMapping(
IntPtr gamecontroller
);
public static string SDL_GameControllerMapping(
IntPtr gamecontroller
) {
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GameControllerMapping(gamecontroller)
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_bool SDL_IsGameController(int joystick_index);
[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerNameForIndex", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GameControllerNameForIndex(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string INTERNAL_SDL_GameControllerNameForIndex(
int joystick_index
);
public static string SDL_GameControllerNameForIndex(int joystick_index)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GameControllerNameForIndex(joystick_index)
);
}
/* IntPtr refers to an SDL_GameController* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SDL_GameControllerOpen(int joystick_index);
/* gamecontroller refers to an SDL_GameController* */
[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerName", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GameControllerName(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GameControllerName(
IntPtr gamecontroller
);
public static string SDL_GameControllerName(IntPtr gamecontroller)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GameControllerName(gamecontroller)
);
}
/* gamecontroller refers to an SDL_GameController* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -3835,17 +3752,11 @@ namespace SDL2
string pchString
);
[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetStringForAxis", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GameControllerGetStringForAxis(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GameControllerGetStringForAxis(
SDL_GameControllerAxis axis
);
public static string SDL_GameControllerGetStringForAxis(
SDL_GameControllerAxis axis
) {
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GameControllerGetStringForAxis(axis)
);
}
/* gamecontroller refers to an SDL_GameController* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -3867,17 +3778,11 @@ namespace SDL2
string pchString
);
[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetStringForButton", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GameControllerGetStringForButton(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GameControllerGetStringForButton(
SDL_GameControllerButton button
);
public static string SDL_GameControllerGetStringForButton(
SDL_GameControllerButton button
) {
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GameControllerGetStringForButton(button)
);
}
/* gamecontroller refers to an SDL_GameController* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -4094,14 +3999,9 @@ namespace SDL2
public static extern int SDL_HapticIndex(IntPtr haptic);
/* haptic refers to an SDL_Haptic* */
[DllImport(nativeLibName, EntryPoint = "SDL_HapticName", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_HapticName(int device_index);
public static string SDL_HapticName(int device_index)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_HapticName(device_index)
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_HapticName(int device_index);
/* haptic refers to an SDL_Haptic* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -4353,19 +4253,12 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_FreeWAV(IntPtr audio_buf);
[DllImport(nativeLibName, EntryPoint = "SDL_GetAudioDeviceName", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetAudioDeviceName(
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetAudioDeviceName(
int index,
int iscapture
);
public static string SDL_GetAudioDeviceName(
int index,
int iscapture
) {
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetAudioDeviceName(index, iscapture)
);
}
/* dev refers to an SDL_AudioDeviceID */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -4373,26 +4266,16 @@ namespace SDL2
uint dev
);
[DllImport(nativeLibName, EntryPoint = "SDL_GetAudioDriver", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetAudioDriver(int index);
public static string SDL_GetAudioDriver(int index)
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetAudioDriver(index)
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetAudioDriver(int index);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_AudioStatus SDL_GetAudioStatus();
[DllImport(nativeLibName, EntryPoint = "SDL_GetCurrentAudioDriver", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_SDL_GetCurrentAudioDriver();
public static string SDL_GetCurrentAudioDriver()
{
return Marshal.PtrToStringAnsi(
INTERNAL_SDL_GetCurrentAudioDriver()
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
public static extern string SDL_GetCurrentAudioDriver();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetNumAudioDevices(int iscapture);