Merge pull request #542 from Machtan/master

Expose a C-like API for the sys crate (and remove redefinitions)
This commit is contained in:
Tony Aldridge
2016-10-07 12:23:54 +01:00
committed by GitHub
20 changed files with 57 additions and 47 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ name = "sdl2"
description = "SDL2 bindings for Rust"
repository = "https://github.com/AngryLawyer/rust-sdl2"
documentation = "http://angrylawyer.github.io/rust-sdl2/sdl2/"
version = "0.23.0"
version = "0.23.1"
license = "MIT"
authors = [ "Tony Aldridge <tony@angry-lawyer.com>" ]
keywords = ["SDL", "windowing", "graphics"]
+1 -1
View File
@@ -3,7 +3,7 @@
name = "sdl2-sys"
description = "Raw SDL2 bindings for Rust, used internally rust-sdl2"
repository = "https://github.com/AngryLawyer/rust-sdl2"
version = "0.23.0"
version = "0.23.1"
authors = ["Tony Aldridge <tony@angry-lawyer.com>"]
license = "MIT"
links = "SDL2"
+1 -2
View File
@@ -1,6 +1,5 @@
use libc::{c_int, c_char};
pub type SDL_bool = c_int;
use sdl::SDL_bool;
extern "C" {
pub fn SDL_SetClipboardText(text: *const c_char) -> c_int;
+1 -2
View File
@@ -3,8 +3,7 @@ use core::prelude::*;
use libc::{c_int, c_char, c_uchar, c_uint, c_void, int16_t, uint8_t};
use joystick::{SDL_Joystick, SDL_JoystickGUID};
use super::rwops::SDL_RWops;
pub type SDL_bool = c_int;
use sdl::SDL_bool;
pub type SDL_GameController = c_void;
+1 -2
View File
@@ -1,6 +1,5 @@
use libc::{c_int};
pub type SDL_bool = c_int;
use sdl::SDL_bool;
// SDL_cpuinfo.h
extern "C" {
+7 -7
View File
@@ -6,16 +6,16 @@ use gesture::SDL_GestureID;
use keyboard::SDL_Keysym;
use touch::SDL_FingerID;
use touch::SDL_TouchID;
use sdl::SDL_bool;
#[cfg(feature = "no_std")]
use core::prelude::*;
pub type SDL_bool = c_int;
// SDL_events.h
pub type SDL_EventState = uint8_t;
pub const SDL_DISABLE: SDL_EventState = 0;
pub const SDL_ENABLE: SDL_EventState = 1;
pub const SDL_QUERY: SDL_EventState = 0xFF;
pub type SDL_State = c_int;
pub const SDL_DISABLE: SDL_State = 0;
pub const SDL_ENABLE: SDL_State = 1;
pub const SDL_QUERY: SDL_State = -1;
pub type SDL_SysWMmsg = c_void;
@@ -466,6 +466,6 @@ extern "C" {
pub fn SDL_AddEventWatch(filter: SDL_EventFilter, userdata: *mut c_void);
pub fn SDL_DelEventWatch(filter: SDL_EventFilter, userdata: *mut c_void);
pub fn SDL_FilterEvents(filter: SDL_EventFilter, userdata: *mut c_void);
pub fn SDL_EventState(type_: uint32_t, state: SDL_EventState) -> SDL_EventState;
pub fn SDL_EventState(type_: uint32_t, state: SDL_State) -> SDL_State;
pub fn SDL_RegisterEvents(numevents: c_int) -> uint32_t;
}
+2 -3
View File
@@ -1,6 +1,5 @@
use libc::{c_int, c_char};
pub type SDL_bool = c_int;
use libc::c_char;
use sdl::SDL_bool;
#[derive(Copy, Clone)]
#[repr(C)]
+1 -2
View File
@@ -1,6 +1,5 @@
use libc::{c_int, c_char, c_void, int32_t, int16_t, int8_t, uint8_t};
pub type SDL_bool = c_int;
use sdl::SDL_bool;
pub type SDL_Joystick = c_void;
+1 -2
View File
@@ -4,8 +4,7 @@ use rect::SDL_Rect;
use video::SDL_Window;
use scancode::SDL_Scancode;
use keycode::{SDL_Keycode, SDL_Keymod};
pub type SDL_bool = c_int;
use sdl::SDL_bool;
// SDL_keyboard.h
#[derive(Copy, Clone)]
+26
View File
@@ -32,3 +32,29 @@ pub mod sdl;
pub mod timer;
pub mod version;
pub mod hint;
pub use scancode::*;
pub use keycode::*;
pub use audio::*;
pub use clipboard::*;
pub use controller::*;
pub use cpuinfo::*;
pub use event::*;
pub use filesystem::*;
pub use haptic::*;
pub use gesture::*;
pub use joystick::*;
pub use keyboard::*;
pub use messagebox::*;
pub use rect::*;
pub use pixels::*;
pub use render::*;
pub use rwops::*;
pub use surface::*;
pub use touch::*;
pub use video::*;
pub use mouse::*;
pub use sdl::*;
pub use timer::*;
pub use version::*;
pub use hint::*;
+4 -6
View File
@@ -1,8 +1,9 @@
use libc::{c_int, c_uint, c_void, uint8_t, uint32_t};
use surface::SDL_Surface;
use video::SDL_Window;
use sdl::SDL_bool;
use event::SDL_State;
pub type SDL_bool = c_int;
pub type SDL_Cursor = c_void;
pub type SDL_SystemCursor = c_uint;
@@ -20,10 +21,7 @@ pub const SDL_SYSTEM_CURSOR_NO: SDL_SystemCursor = 10;
pub const SDL_SYSTEM_CURSOR_HAND: SDL_SystemCursor = 11;
pub const SDL_NUM_SYSTEM_CURSORS: SDL_SystemCursor = 12;
pub type SDL_MouseState = c_int;
pub const SDL_DISABLE: SDL_MouseState = 0;
pub const SDL_ENABLE: SDL_MouseState = 1;
pub const SDL_QUERY: SDL_MouseState = -1;
pub const SDL_BUTTON_LEFT: u8 = 1;
pub const SDL_BUTTON_MIDDLE: u8 = 2;
@@ -54,5 +52,5 @@ extern "C" {
pub fn SDL_GetCursor() -> *mut SDL_Cursor;
pub fn SDL_GetDefaultCursor() -> *mut SDL_Cursor;
pub fn SDL_FreeCursor(cursor: *mut SDL_Cursor);
pub fn SDL_ShowCursor(toggle: SDL_MouseState) -> SDL_MouseState;
pub fn SDL_ShowCursor(toggle: SDL_State) -> SDL_State;
}
+1 -2
View File
@@ -1,6 +1,5 @@
use libc::{c_int, uint8_t, uint32_t};
pub type SDL_bool = c_int;
use sdl::SDL_bool;
//SDL_pixels.h
#[derive(Copy, Clone)]
+1 -2
View File
@@ -1,4 +1,5 @@
use libc::c_int;
use sdl::SDL_bool;
/// A structure that defines a two dimensional point.
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash)]
@@ -18,8 +19,6 @@ pub struct SDL_Rect {
pub h: c_int
}
pub type SDL_bool = c_int;
extern "C" {
pub fn SDL_HasIntersection(A: *const SDL_Rect, B: *const SDL_Rect) -> SDL_bool;
pub fn SDL_IntersectRect(A: *const SDL_Rect, B: *const SDL_Rect, result: *mut SDL_Rect) -> SDL_bool;
+1 -3
View File
@@ -1,11 +1,9 @@
use libc::{c_int, c_uint, c_char, c_void, c_float, c_double};
use libc::{uint8_t, uint32_t};
use rect::{SDL_Point, SDL_Rect};
use surface::SDL_Surface;
use video::SDL_Window;
pub type SDL_bool = c_int;
use sdl::SDL_bool;
//SDL_render.h
pub type SDL_RendererFlags = c_uint;
+1 -2
View File
@@ -1,5 +1,6 @@
use libc::{c_uchar, uint32_t, c_char, FILE, c_void};
use libc::{c_int, int64_t, size_t};
use sdl::SDL_bool;
#[allow(dead_code)]
#[repr(C)]
@@ -7,8 +8,6 @@ struct SDL_RWops_Anon {
data: [c_uchar; 24],
}
pub type SDL_bool = c_int;
pub static RW_SEEK_SET: c_int = 0;
pub static RW_SEEK_CUR: c_int = 1;
pub static RW_SEEK_END: c_int = 2;
+2 -3
View File
@@ -18,6 +18,8 @@ mod others {
extern {}
}
pub type SDL_bool = c_int;
pub type SDL_errorcode = c_uint;
pub const SDL_ENOMEM: SDL_errorcode = 0;
pub const SDL_EFREAD: SDL_errorcode = 1;
@@ -50,7 +52,4 @@ extern "C" {
pub fn SDL_QuitSubSystem(flags: SDL_InitFlag);
pub fn SDL_WasInit(flags: SDL_InitFlag) -> SDL_InitFlag;
pub fn SDL_Quit();
//SDL_timer.h
pub fn SDL_GetTicks() -> uint32_t;
}
+2 -3
View File
@@ -3,9 +3,8 @@ use pixels::SDL_Palette;
use rwops::SDL_RWops;
use rect::SDL_Rect;
use libc::{c_int, c_void, uint32_t, uint8_t};
pub use render::SDL_BlendMode;
pub type SDL_bool = c_int;
use render::SDL_BlendMode;
use sdl::SDL_bool;
pub type SDL_SurfaceFlag = uint32_t;
+1 -2
View File
@@ -1,12 +1,11 @@
use rect::SDL_Rect;
use surface::SDL_Surface;
use sdl::SDL_bool;
#[cfg(feature = "no_std")]
use core::prelude::*;
use libc::{c_void, c_int, c_float, c_char, uint16_t, uint32_t};
pub type SDL_bool = c_int;
//SDL_video.h
#[allow(missing_copy_implementations)]
#[repr(C)]
+1 -1
View File
@@ -210,7 +210,7 @@ impl MouseUtil {
}
pub fn is_cursor_showing(&self) -> bool {
unsafe { ll::SDL_ShowCursor(ll::SDL_QUERY) == 1 }
unsafe { ll::SDL_ShowCursor(::sys::SDL_QUERY) == 1 }
}
pub fn show_cursor(&self, show: bool) {
+1 -1
View File
@@ -453,7 +453,7 @@ impl SurfaceRef {
}
pub fn blend_mode(&self) -> BlendMode {
let mut mode: ll::SDL_BlendMode = 0;
let mut mode: ::sys::SDL_BlendMode = 0;
let result = unsafe {
ll::SDL_GetSurfaceBlendMode(self.raw(), &mut mode)
};