Marshaling refinements

This commit is contained in:
Jameson Ernst 2013-07-14 14:33:14 -07:00
parent b877b08553
commit 964f553e25

View file

@ -886,6 +886,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_UpdateWindowSurfaceRects( public static extern int SDL_UpdateWindowSurfaceRects(
IntPtr window, IntPtr window,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Rect[] rects, SDL_Rect[] rects,
int numrects int numrects
); );
@ -993,23 +994,23 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetRenderDrawBlendMode( public static extern int SDL_GetRenderDrawBlendMode(
IntPtr renderer, IntPtr renderer,
ref SDL_BlendMode blendMode out SDL_BlendMode blendMode
); );
/* renderer refers to an SDL_Renderer* */ /* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetRenderDrawColor( public static extern int SDL_GetRenderDrawColor(
IntPtr renderer, IntPtr renderer,
ref byte r, out byte r,
ref byte g, out byte g,
ref byte b, out byte b,
ref byte a out byte a
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetRenderDriverInfo( public static extern int SDL_GetRenderDriverInfo(
int index, int index,
ref SDL_RendererInfo info out SDL_RendererInfo info
); );
/* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */ /* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */
@ -1020,30 +1021,30 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetRendererInfo( public static extern int SDL_GetRendererInfo(
IntPtr renderer, IntPtr renderer,
ref SDL_RendererInfo info out SDL_RendererInfo info
); );
/* texture refers to an SDL_Texture* */ /* texture refers to an SDL_Texture* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetTextureAlphaMod( public static extern int SDL_GetTextureAlphaMod(
IntPtr texture, IntPtr texture,
ref byte alpha out byte alpha
); );
/* texture refers to an SDL_Texture* */ /* texture refers to an SDL_Texture* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetTextureBlendMode( public static extern int SDL_GetTextureBlendMode(
IntPtr texture, IntPtr texture,
ref SDL_BlendMode blendMode out SDL_BlendMode blendMode
); );
/* texture refers to an SDL_Texture* */ /* texture refers to an SDL_Texture* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetTextureColorMod( public static extern int SDL_GetTextureColorMod(
IntPtr texture, IntPtr texture,
ref byte r, out byte r,
ref byte g, out byte g,
ref byte b out byte b
); );
/* texture refers to an SDL_Texture*, pixels to a void* */ /* texture refers to an SDL_Texture*, pixels to a void* */
@ -1051,26 +1052,26 @@ namespace SDL2
public static extern int SDL_LockTexture( public static extern int SDL_LockTexture(
IntPtr texture, IntPtr texture,
ref SDL_Rect rect, ref SDL_Rect rect,
ref IntPtr pixels, out IntPtr pixels,
ref int pitch out int pitch
); );
/* texture refers to an SDL_Texture* */ /* texture refers to an SDL_Texture* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_QueryTexture( public static extern int SDL_QueryTexture(
IntPtr texture, IntPtr texture,
ref uint format, out uint format,
ref int access, out int access,
ref int w, out int w,
ref int h out int h
); );
/* texture refers to an SDL_Texture, pixels to a void* */ /* texture refers to an SDL_Texture, pixels to a void* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_QueryTexturePixels( public static extern int SDL_QueryTexturePixels(
IntPtr texture, IntPtr texture,
ref IntPtr pixels, out IntPtr pixels,
ref int pitch out int pitch
); );
/* renderer refers to an SDL_Renderer* */ /* renderer refers to an SDL_Renderer* */
@ -1112,6 +1113,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_RenderDrawLines( public static extern int SDL_RenderDrawLines(
IntPtr renderer, IntPtr renderer,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Point[] points, SDL_Point[] points,
int count int count
); );
@ -1128,6 +1130,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_RenderDrawPoints( public static extern int SDL_RenderDrawPoints(
IntPtr renderer, IntPtr renderer,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Point[] points, SDL_Point[] points,
int count int count
); );
@ -1143,6 +1146,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_RenderDrawRects( public static extern int SDL_RenderDrawRects(
IntPtr renderer, IntPtr renderer,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Rect[] rects, SDL_Rect[] rects,
int count int count
); );
@ -1158,6 +1162,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_RenderFillRects( public static extern int SDL_RenderFillRects(
IntPtr renderer, IntPtr renderer,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Rect[] rects, SDL_Rect[] rects,
int count int count
); );
@ -1166,7 +1171,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_RendererGetViewport( public static extern int SDL_RendererGetViewport(
IntPtr renderer, IntPtr renderer,
ref SDL_Rect rect out SDL_Rect rect
); );
/* renderer refers to an SDL_Renderer* */ /* renderer refers to an SDL_Renderer* */
@ -1647,7 +1652,7 @@ namespace SDL2
public struct SDL_Palette public struct SDL_Palette
{ {
public int ncolors; public int ncolors;
public SDL_Color[] colors; public IntPtr colors;
public int version; public int version;
public int refcount; public int refcount;
} }
@ -1686,7 +1691,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_CalculateGammaRamp( public static extern void SDL_CalculateGammaRamp(
float gamma, float gamma,
ref ushort ramp [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
ushort[] ramp
); );
/* format refers to an SDL_PixelFormat* */ /* format refers to an SDL_PixelFormat* */
@ -1708,9 +1714,9 @@ namespace SDL2
public static extern void SDL_GetRGB( public static extern void SDL_GetRGB(
uint pixel, uint pixel,
IntPtr format, IntPtr format,
ref byte r, out byte r,
ref byte g, out byte g,
ref byte b out byte b
); );
/* format refers to an SDL_PixelFormat* */ /* format refers to an SDL_PixelFormat* */
@ -1718,10 +1724,10 @@ namespace SDL2
public static extern void SDL_GetRGBA( public static extern void SDL_GetRGBA(
uint pixel, uint pixel,
IntPtr format, IntPtr format,
ref byte r, out byte r,
ref byte g, out byte g,
ref byte b, out byte b,
ref byte a out byte a
); );
/* format refers to an SDL_PixelFormat* */ /* format refers to an SDL_PixelFormat* */
@ -1755,17 +1761,18 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_bool SDL_PixelFormatEnumToMasks( public static extern SDL_bool SDL_PixelFormatEnumToMasks(
uint format, uint format,
ref int bpp, out int bpp,
ref uint Rmask, out uint Rmask,
ref uint Gmask, out uint Gmask,
ref uint Bmask, out uint Bmask,
ref uint Amask out uint Amask
); );
/* palette refers to an SDL_Palette* */ /* palette refers to an SDL_Palette* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_SetPaletteColors( public static extern int SDL_SetPaletteColors(
IntPtr palette, IntPtr palette,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct)]
SDL_Color[] colors, SDL_Color[] colors,
int firstcolor, int firstcolor,
int ncolors int ncolors
@ -1800,10 +1807,11 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_bool SDL_EnclosePoints( public static extern SDL_bool SDL_EnclosePoints(
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 1)]
SDL_Point[] points, SDL_Point[] points,
int count, int count,
ref SDL_Rect clip, ref SDL_Rect clip,
ref SDL_Rect result out SDL_Rect result
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -1816,7 +1824,7 @@ namespace SDL2
public static extern SDL_bool SDL_IntersectRect( public static extern SDL_bool SDL_IntersectRect(
ref SDL_Rect A, ref SDL_Rect A,
ref SDL_Rect B, ref SDL_Rect B,
ref SDL_Rect result out SDL_Rect result
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -1841,7 +1849,7 @@ namespace SDL2
public static extern void SDL_UnionRect( public static extern void SDL_UnionRect(
ref SDL_Rect A, ref SDL_Rect A,
ref SDL_Rect B, ref SDL_Rect B,
ref SDL_Rect result out SDL_Rect result
); );
#endregion #endregion
@ -1961,6 +1969,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_FillRects( public static extern int SDL_FillRects(
IntPtr dst, IntPtr dst,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Rect[] rects, SDL_Rect[] rects,
int count, int count,
uint color uint color
@ -1974,37 +1983,37 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_GetClipRect( public static extern void SDL_GetClipRect(
IntPtr surface, IntPtr surface,
ref SDL_Rect rect out SDL_Rect rect
); );
/* surface refers to an SDL_Surface* */ /* surface refers to an SDL_Surface* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetColorKey( public static extern int SDL_GetColorKey(
IntPtr surface, IntPtr surface,
ref uint key out uint key
); );
/* surface refers to an SDL_Surface* */ /* surface refers to an SDL_Surface* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetSurfaceAlphaMod( public static extern int SDL_GetSurfaceAlphaMod(
IntPtr surface, IntPtr surface,
ref byte alpha out byte alpha
); );
/* surface refers to an SDL_Surface* */ /* surface refers to an SDL_Surface* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetSurfaceBlendMode( public static extern int SDL_GetSurfaceBlendMode(
IntPtr surface, IntPtr surface,
ref SDL_BlendMode blendMode out SDL_BlendMode blendMode
); );
/* surface refers to an SDL_Surface* */ /* surface refers to an SDL_Surface* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetSurfaceColorMod( public static extern int SDL_GetSurfaceColorMod(
IntPtr surface, IntPtr surface,
ref byte r, out byte r,
ref byte g, out byte g,
ref byte b out byte b
); );
/* These are for SDL_LoadBMP, which is a macro in the SDL headers. */ /* These are for SDL_LoadBMP, which is a macro in the SDL headers. */
@ -2596,6 +2605,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_PeepEvents( public static extern int SDL_PeepEvents(
[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 1)]
SDL_Event[] events, SDL_Event[] events,
int numevents, int numevents,
SDL_eventaction action, SDL_eventaction action,
@ -2650,8 +2660,8 @@ namespace SDL2
/* userdata refers to a void* */ /* userdata refers to a void* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_bool SDL_GetEventFilter( public static extern SDL_bool SDL_GetEventFilter(
ref SDL_EventFilter filter, out SDL_EventFilter filter,
ref IntPtr userdata out IntPtr userdata
); );
/* userdata refers to a void* */ /* userdata refers to a void* */
@ -3298,7 +3308,7 @@ namespace SDL2
/* Return value is a pointer to a UInt8 array */ /* Return value is a pointer to a UInt8 array */
/* Numkeys returns the size of the array if non-null */ /* Numkeys returns the size of the array if non-null */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SDL_GetKeyboardState(ref int numkeys); public static extern IntPtr SDL_GetKeyboardState(out int numkeys);
/* Get the current key modifier state for the keyboard. */ /* Get the current key modifier state for the keyboard. */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -3520,8 +3530,8 @@ namespace SDL2
public static extern int SDL_JoystickGetBall( public static extern int SDL_JoystickGetBall(
IntPtr joystick, IntPtr joystick,
int ball, int ball,
ref int dx, out int dx,
ref int dy out int dy
); );
/* joystick refers to an SDL_Joystick* */ /* joystick refers to an SDL_Joystick* */
@ -4290,14 +4300,14 @@ namespace SDL2
IntPtr src, IntPtr src,
int freesrc, int freesrc,
ref SDL_AudioSpec spec, ref SDL_AudioSpec spec,
ref IntPtr audio_buf, out IntPtr audio_buf,
ref uint audio_len out uint audio_len
); );
public static SDL_AudioSpec SDL_LoadWAV( public static SDL_AudioSpec SDL_LoadWAV(
string file, string file,
ref SDL_AudioSpec spec, ref SDL_AudioSpec spec,
ref IntPtr audio_buf, out IntPtr audio_buf,
ref uint audio_len out uint audio_len
) { ) {
SDL_AudioSpec result; SDL_AudioSpec result;
IntPtr rwops = INTERNAL_SDL_RWFromFile(file, "rb"); IntPtr rwops = INTERNAL_SDL_RWFromFile(file, "rb");
@ -4305,8 +4315,8 @@ namespace SDL2
rwops, rwops,
1, 1,
ref spec, ref spec,
ref audio_buf, out audio_buf,
ref audio_len out audio_len
); );
result = (SDL_AudioSpec) Marshal.PtrToStructure( result = (SDL_AudioSpec) Marshal.PtrToStructure(
result_ptr, result_ptr,
@ -4324,7 +4334,9 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_MixAudio( public static extern void SDL_MixAudio(
[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)]
byte[] dst, byte[] dst,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)]
byte[] src, byte[] src,
uint len, uint len,
int volume int volume
@ -4333,7 +4345,9 @@ namespace SDL2
/* format refers to an SDL_AudioFormat */ /* format refers to an SDL_AudioFormat */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_MixAudioFormat( public static extern void SDL_MixAudioFormat(
[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)]
byte[] dst, byte[] dst,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)]
byte[] src, byte[] src,
ushort format, ushort format,
uint len, uint len,
@ -4343,7 +4357,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_OpenAudio( public static extern int SDL_OpenAudio(
ref SDL_AudioSpec desired, ref SDL_AudioSpec desired,
ref SDL_AudioSpec obtained out SDL_AudioSpec obtained
); );
/* uint refers to an SDL_AudioDeviceID */ /* uint refers to an SDL_AudioDeviceID */
@ -4353,7 +4367,7 @@ namespace SDL2
string device, string device,
int iscapture, int iscapture,
ref SDL_AudioSpec desired, ref SDL_AudioSpec desired,
ref SDL_AudioSpec obtained, out SDL_AudioSpec obtained,
int allowed_changes int allowed_changes
); );
@ -4375,6 +4389,8 @@ namespace SDL2
public static extern void SDL_UnlockAudioDevice(uint dev); public static extern void SDL_UnlockAudioDevice(uint dev);
#endregion #endregion
} }
} }