Remove "owned" from Cursor, remove unsafe get_cursor() and get_default_cursor() functions

This commit is contained in:
Dan Spencer
2015-07-22 00:30:54 -06:00
parent 70e5700a79
commit b40fb52e94
2 changed files with 6 additions and 41 deletions
-11
View File
@@ -9,17 +9,6 @@ macro_rules! impl_raw_accessors(
)
);
macro_rules! impl_owned_accessors(
($(($t:ty, $owned:ident)),+) => (
$(
impl $t {
#[inline]
pub unsafe fn $owned(&self) -> bool { self.$owned }
}
)+
)
);
macro_rules! impl_raw_constructor(
($(($t:ty, $te:ident ($($r:ident:$rt:ty),+))),+) => (
$(
+6 -30
View File
@@ -25,17 +25,13 @@ pub enum SystemCursor {
}
pub struct Cursor {
raw: *mut ll::SDL_Cursor,
owned: bool
raw: *mut ll::SDL_Cursor
}
impl Drop for Cursor {
#[inline]
fn drop(&mut self) {
if self.owned {
unsafe {
ll::SDL_FreeCursor(self.raw);
}
}
unsafe { ll::SDL_FreeCursor(self.raw) };
}
}
@@ -50,7 +46,7 @@ impl Cursor {
if raw == ptr::null_mut() {
Err(get_error())
} else {
Ok(Cursor{ raw: raw, owned: true })
Ok(Cursor{ raw: raw })
}
}
}
@@ -63,7 +59,7 @@ impl Cursor {
if raw == ptr::null_mut() {
Err(get_error())
} else {
Ok(Cursor{ raw: raw, owned: true })
Ok(Cursor{ raw: raw })
}
}
}
@@ -75,7 +71,7 @@ impl Cursor {
if raw == ptr::null_mut() {
Err(get_error())
} else {
Ok(Cursor{ raw: raw, owned: true })
Ok(Cursor{ raw: raw })
}
}
}
@@ -188,26 +184,6 @@ pub fn get_relative_mouse_mode() -> bool {
unsafe { ll::SDL_GetRelativeMouseMode() == 1 }
}
pub fn get_cursor() -> Option<Cursor> {
let raw = unsafe { ll::SDL_GetCursor() };
if raw == ptr::null_mut() {
None
} else {
Some(Cursor { raw: raw, owned: false })
}
}
pub fn get_default_cursor() -> Option<Cursor> {
let raw = unsafe { ll::SDL_GetDefaultCursor() };
if raw == ptr::null_mut() {
None
} else {
Some(Cursor { raw: raw, owned: false })
}
}
pub fn is_cursor_showing() -> bool {
unsafe { ll::SDL_ShowCursor(ll::SDL_QUERY) == 1 }
}