mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
Merge pull request #377 from mvdnes/features
Fix Copy, plus reduce the used features
This commit is contained in:
@@ -42,7 +42,7 @@ pub struct SDL_AudioSpec {
|
||||
pub type SDL_AudioFilter =
|
||||
Option<extern "C" fn (arg1: *const SDL_AudioCVT, arg2: SDL_AudioFormat)>;
|
||||
#[allow(dead_code, missing_copy_implementations, raw_pointer_derive)]
|
||||
#[derive(Copy)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct SDL_AudioCVT {
|
||||
pub needed: c_int,
|
||||
|
||||
@@ -14,7 +14,7 @@ pub type SDL_bool = c_int;
|
||||
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 = -1;
|
||||
pub const SDL_QUERY: SDL_EventState = 0xFF;
|
||||
|
||||
pub type SDL_SysWMmsg = c_void;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ pub type SDL_FingerID = int64_t;
|
||||
pub type SDL_Finger = Finger;
|
||||
pub type TouchDevice = SDL_TouchID;
|
||||
|
||||
#[derive(PartialEq, Copy)]
|
||||
#[derive(PartialEq, Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct Finger {
|
||||
id: TouchDevice,
|
||||
|
||||
+1
-2
@@ -400,14 +400,13 @@ impl<'a, CB: 'a> DerefMut for AudioDeviceLockGuard<'a, CB> {
|
||||
fn deref_mut(&mut self) -> &mut CB { &mut self.device.userdata.callback }
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<'a, CB> Drop for AudioDeviceLockGuard<'a, CB> {
|
||||
fn drop(&mut self) {
|
||||
unsafe { ll::SDL_UnlockAudioDevice(self.device.device_id.id()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct AudioCVT {
|
||||
raw: ll::SDL_AudioCVT
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ pub fn get_event_state() -> bool {
|
||||
}
|
||||
|
||||
/// Possible return values for `add_mapping`
|
||||
#[derive(Copy)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum MappingStatus {
|
||||
Added = 1,
|
||||
Updated = 0,
|
||||
|
||||
@@ -255,7 +255,7 @@ impl Drop for Joystick {
|
||||
|
||||
/// Wrapper around a SDL_JoystickGUID, a globally unique identifier
|
||||
/// for a joystick.
|
||||
#[derive(Copy)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Guid {
|
||||
raw: ll::SDL_JoystickGUID,
|
||||
}
|
||||
@@ -321,7 +321,7 @@ impl Display for Guid {
|
||||
/// combinations make sense: 5 for instance would mean up and down at
|
||||
/// the same time... To simplify things I turn it into an enum which
|
||||
/// is how the SDL2 docs present it anyway (using macros).
|
||||
#[derive(Copy, Debug)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum HatState {
|
||||
Centered = 0,
|
||||
Up = 0x01,
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ use std::num::ToPrimitive;
|
||||
|
||||
use sys::keycode as ll;
|
||||
|
||||
#[derive(PartialEq, Eq, FromPrimitive, Debug, Copy)]
|
||||
#[derive(PartialEq, Eq, FromPrimitive, Debug, Copy, Clone)]
|
||||
pub enum KeyCode {
|
||||
Unknown = ll::SDLK_UNKNOWN as isize,
|
||||
Backspace = ll::SDLK_BACKSPACE as isize,
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
#![crate_name = "sdl2"]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#![feature(unsafe_destructor, optin_builtin_traits, std_misc, core)]
|
||||
#![feature(optin_builtin_traits, core)]
|
||||
#![cfg_attr(test, feature(std_misc))]
|
||||
|
||||
extern crate libc;
|
||||
#[macro_use]
|
||||
|
||||
+2
-6
@@ -51,7 +51,7 @@ use std::ptr;
|
||||
use libc::{c_int, uint32_t, c_double, c_void};
|
||||
use rect::Point;
|
||||
use rect::Rect;
|
||||
use std::cell::{RefCell, RefMut, BorrowState};
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::ffi::CStr;
|
||||
use std::num::FromPrimitive;
|
||||
use std::vec::Vec;
|
||||
@@ -266,10 +266,7 @@ impl Renderer {
|
||||
/// }
|
||||
/// ```
|
||||
pub fn drawer(&self) -> RenderDrawer {
|
||||
match self.drawer_borrow.borrow_state() {
|
||||
BorrowState::Unused => RenderDrawer::new(self.raw, self.drawer_borrow.borrow_mut()),
|
||||
_ => panic!("Renderer drawer already borrowed")
|
||||
}
|
||||
RenderDrawer::new(self.raw, self.drawer_borrow.borrow_mut())
|
||||
}
|
||||
|
||||
/// Unwraps the window or surface the rendering context was created from.
|
||||
@@ -862,7 +859,6 @@ pub struct Texture<'renderer> {
|
||||
_marker: PhantomData<&'renderer ()>
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<'renderer> Drop for Texture<'renderer> {
|
||||
fn drop(&mut self) {
|
||||
if self.owned {
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::num::ToPrimitive;
|
||||
|
||||
use sys::scancode as ll;
|
||||
|
||||
#[derive(PartialEq, Eq, FromPrimitive, Debug, Copy)]
|
||||
#[derive(PartialEq, Eq, FromPrimitive, Debug, Copy, Clone)]
|
||||
pub enum ScanCode {
|
||||
Unknown = ll::SDL_SCANCODE_UNKNOWN as isize,
|
||||
A = ll::SDL_SCANCODE_A as isize,
|
||||
|
||||
@@ -105,7 +105,6 @@ pub struct Subsystem<'sdl> {
|
||||
_marker: PhantomData<&'sdl Sdl>
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<'sdl> Drop for Subsystem<'sdl> {
|
||||
fn drop(&mut self) {
|
||||
unsafe { ll::SDL_QuitSubSystem(self.flags.bits()); }
|
||||
|
||||
@@ -54,7 +54,6 @@ impl<'a> Timer<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<'a> Drop for Timer<'a> {
|
||||
fn drop(&mut self) {
|
||||
let ret = unsafe { ll::SDL_RemoveTimer(self.raw) };
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ pub enum FullscreenType {
|
||||
FTDesktop = 0x00001001,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Copy)]
|
||||
#[derive(PartialEq, Copy, Clone)]
|
||||
pub enum WindowPos {
|
||||
PosUndefined,
|
||||
PosCentered,
|
||||
|
||||
Reference in New Issue
Block a user