From 7c9c1771c13a05e35ae8b19a3d525ea57d7efdf9 Mon Sep 17 00:00:00 2001 From: Joshua DeSeno Date: Mon, 25 Aug 2014 12:16:48 +0900 Subject: [PATCH] Annotate all SDL structs --- src/sdl2/audio.rs | 2 ++ src/sdl2/controller.rs | 2 ++ src/sdl2/event.rs | 1 + src/sdl2/joystick.rs | 1 + src/sdl2/pixels.rs | 3 +++ src/sdl2/rect.rs | 2 ++ src/sdl2/render.rs | 3 +++ src/sdl2/rwops.rs | 2 ++ src/sdl2/surface.rs | 2 ++ src/sdl2/touch.rs | 1 + src/sdl2/version.rs | 1 + src/sdl2/video.rs | 2 ++ 12 files changed, 22 insertions(+) diff --git a/src/sdl2/audio.rs b/src/sdl2/audio.rs index 057eb609..d00f9cfa 100644 --- a/src/sdl2/audio.rs +++ b/src/sdl2/audio.rs @@ -43,6 +43,7 @@ pub mod ll { ::std::option::Option; + #[repr(C)] pub struct SDL_AudioSpec { pub freq: c_int, pub format: SDL_AudioFormat, @@ -59,6 +60,7 @@ pub mod ll { (arg1: *const SDL_AudioCVT, arg2: SDL_AudioFormat)>; #[allow(dead_code)] + #[repr(C)] pub struct SDL_AudioCVT { pub needed: c_int, pub src_format: SDL_AudioFormat, diff --git a/src/sdl2/controller.rs b/src/sdl2/controller.rs index 3fe40f0a..37073a06 100644 --- a/src/sdl2/controller.rs +++ b/src/sdl2/controller.rs @@ -17,12 +17,14 @@ pub mod ll { pub static SDL_CONTROLLER_BINDTYPE_HAT: SDL_GameControllerBindType = 3; #[allow(dead_code)] + #[repr(C)] pub struct SDL_GameControllerButtonBind { bindType: SDL_GameControllerBindType, value: SDL_GameControllerButtonBindData, } #[allow(dead_code)] + #[repr(C)] pub struct SDL_GameControllerButtonBindData { data: [c_uchar, ..8u], } diff --git a/src/sdl2/event.rs b/src/sdl2/event.rs index 7ef9f932..e8f965ef 100644 --- a/src/sdl2/event.rs +++ b/src/sdl2/event.rs @@ -309,6 +309,7 @@ pub mod ll { pub msg: *const SDL_SysWMmsg, } + #[repr(C)] pub struct SDL_Event { pub data: [uint8_t, ..56u], } diff --git a/src/sdl2/joystick.rs b/src/sdl2/joystick.rs index 8f895926..fefd8a2f 100644 --- a/src/sdl2/joystick.rs +++ b/src/sdl2/joystick.rs @@ -7,6 +7,7 @@ pub mod ll { pub type SDL_Joystick = c_void; #[allow(dead_code)] + #[repr(C)] pub struct SDL_JoystickGUID { data: [uint8_t, ..16u], } diff --git a/src/sdl2/pixels.rs b/src/sdl2/pixels.rs index 73ac6baf..b1e74e65 100644 --- a/src/sdl2/pixels.rs +++ b/src/sdl2/pixels.rs @@ -5,6 +5,7 @@ pub mod ll { use libc::{c_int, uint8_t, uint32_t}; //SDL_pixels.h + #[repr(C)] pub struct SDL_Color { pub r: uint8_t, pub g: uint8_t, @@ -12,6 +13,7 @@ pub mod ll { pub a: uint8_t, } + #[repr(C)] pub struct SDL_Palette { pub ncolors: c_int, pub colors: *const SDL_Color, @@ -20,6 +22,7 @@ pub mod ll { } #[allow(uppercase_variables)] + #[repr(C)] pub struct SDL_PixelFormat { pub format: SDL_PixelFormatFlag, pub palette: *const SDL_Palette, diff --git a/src/sdl2/rect.rs b/src/sdl2/rect.rs index ae6c0e67..7ba48ec5 100644 --- a/src/sdl2/rect.rs +++ b/src/sdl2/rect.rs @@ -7,6 +7,7 @@ use libc::c_int; /// A structure that defines a two dimensional point. #[deriving(PartialEq, Clone, Show)] +#[repr(C)] pub struct Point { pub x: i32, pub y: i32 @@ -14,6 +15,7 @@ pub struct Point { /// A structure that defines a rectangle, with the origin at the upper left. #[deriving(PartialEq, Clone, Show)] +#[repr(C)] pub struct Rect { pub x: i32, pub y: i32, diff --git a/src/sdl2/render.rs b/src/sdl2/render.rs index cd879fa1..d886fcc0 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -39,6 +39,7 @@ pub mod ll { SDL_RENDERER_TARGETTEXTURE = 0x00000008 } + #[repr(C)] pub struct SDL_RendererInfo { pub name: *const c_char, @@ -69,7 +70,9 @@ pub mod ll { SDL_FLIP_VERTICAL = 0x00000002 } + #[repr(C)] pub struct SDL_Renderer; + #[repr(C)] pub struct SDL_Texture; //SDL_blendmode.h diff --git a/src/sdl2/rwops.rs b/src/sdl2/rwops.rs index fedcdf76..3200f84a 100644 --- a/src/sdl2/rwops.rs +++ b/src/sdl2/rwops.rs @@ -10,6 +10,7 @@ pub mod ll { use libc::{c_int, int64_t, size_t}; #[allow(dead_code)] + #[repr(C)] struct SDL_RWops_Anon { data: [c_uchar, ..24], } @@ -21,6 +22,7 @@ pub mod ll { pub static RW_SEEK_END: c_int = 2; #[allow(dead_code)] + #[repr(C)] pub struct SDL_RWops { pub size: extern "C" fn(context: *const SDL_RWops) -> int64_t, pub seek: extern "C" fn(context: *const SDL_RWops, offset: int64_t, whence: c_int) -> int64_t, diff --git a/src/sdl2/surface.rs b/src/sdl2/surface.rs index 49d031ba..60bccfe2 100644 --- a/src/sdl2/surface.rs +++ b/src/sdl2/surface.rs @@ -28,8 +28,10 @@ pub mod ll { pub static SDL_DONTFREE: SDL_SurfaceFlag = 0x00000004; //SDL_surface.h + #[repr(C)] pub struct SDL_BlitMap; + #[repr(C)] pub struct SDL_Surface { pub flags: uint32_t, pub format: *const SDL_PixelFormat, diff --git a/src/sdl2/touch.rs b/src/sdl2/touch.rs index 2c37b63b..0abf5232 100644 --- a/src/sdl2/touch.rs +++ b/src/sdl2/touch.rs @@ -3,6 +3,7 @@ use std::ptr; pub type TouchDevice = ll::SDL_TouchID; #[deriving(PartialEq)] +#[repr(C)] pub struct Finger { id: TouchDevice, x: f32, diff --git a/src/sdl2/version.rs b/src/sdl2/version.rs index 91ea9bd1..dc9a90c1 100644 --- a/src/sdl2/version.rs +++ b/src/sdl2/version.rs @@ -9,6 +9,7 @@ use std::c_str::CString; #[allow(non_camel_case_types)] pub mod ll { use libc::{uint8_t, c_char, c_int}; + #[repr(C)] pub struct SDL_version { pub major: uint8_t, pub minor: uint8_t, diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index a2f1f63b..a041a5ac 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -23,8 +23,10 @@ pub mod ll { pub type SDL_bool = c_int; //SDL_video.h + #[repr(C)] pub struct SDL_Window; + #[repr(C)] pub struct SDL_DisplayMode { pub format: uint32_t, pub w: c_int,