From bd3b64fe32f2e0d6391c4397c22cf5e7edc35e24 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Thu, 22 Mar 2018 17:42:55 -0400 Subject: [PATCH] Fix for GetCallback function decls --- src/SDL2.cs | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index 49f5563..205bcb9 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -681,10 +681,31 @@ namespace SDL2 /* userdata refers to a void* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogGetOutputFunction( - out SDL_LogOutputFunction callback, + private static extern void SDL_LogGetOutputFunction( + out IntPtr callback, out IntPtr userdata ); + public static void SDL_LogGetOutputFunction( + out SDL_LogOutputFunction callback, + out IntPtr userdata + ) { + IntPtr result = IntPtr.Zero; + SDL_LogGetOutputFunction( + out result, + out userdata + ); + if (result != IntPtr.Zero) + { + callback = (SDL_LogOutputFunction) Marshal.GetDelegateForFunctionPointer( + result, + typeof(SDL_LogOutputFunction) + ); + } + else + { + callback = null; + } + } /* userdata refers to a void* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -4007,10 +4028,29 @@ namespace SDL2 /* userdata refers to a void* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern SDL_bool SDL_GetEventFilter( - out SDL_EventFilter filter, + private static extern SDL_bool SDL_GetEventFilter( + out IntPtr filter, out IntPtr userdata ); + public static SDL_bool SDL_GetEventFilter( + out SDL_EventFilter filter, + out IntPtr userdata + ) { + IntPtr result = IntPtr.Zero; + SDL_bool retval = SDL_GetEventFilter(out result, out userdata); + if (result != IntPtr.Zero) + { + filter = (SDL_EventFilter) Marshal.GetDelegateForFunctionPointer( + result, + typeof(SDL_EventFilter) + ); + } + else + { + filter = null; + } + return retval; + } /* userdata refers to a void* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]