diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-10-07 16:02:57 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-10-07 16:02:57 +0200 |
commit | 113ac3d202140491de9a8ad1e75dd96882a8857f (patch) | |
tree | 34425f2594d8ddfd9be88a044c32d6175c7f4fad /old/sdl-patches/0001-remove-not-really-needed-dependencies.patch | |
parent | 0036a7b08b18389e0d8683fe1422ffb861dd9327 (diff) | |
download | nihav-player-113ac3d202140491de9a8ad1e75dd96882a8857f.tar.gz |
move experimental code to old/
Diffstat (limited to 'old/sdl-patches/0001-remove-not-really-needed-dependencies.patch')
-rw-r--r-- | old/sdl-patches/0001-remove-not-really-needed-dependencies.patch | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/old/sdl-patches/0001-remove-not-really-needed-dependencies.patch b/old/sdl-patches/0001-remove-not-really-needed-dependencies.patch new file mode 100644 index 0000000..e1cf979 --- /dev/null +++ b/old/sdl-patches/0001-remove-not-really-needed-dependencies.patch @@ -0,0 +1,151 @@ +From 4d9e740dfd80df976d976e21a7e33fd9f8b3c362 Mon Sep 17 00:00:00 2001 +From: Kostya Shishkov <kostya.shishkov@gmail.com> +Date: Fri, 22 Nov 2019 17:47:54 +0100 +Subject: [PATCH 1/4] remove not really needed dependencies + +--- + Cargo.toml | 2 -- + src/sdl/event.rs | 20 +++++++------------- + src/sdl/lib.rs | 2 -- + src/sdl/video.rs | 8 -------- + 4 files changed, 7 insertions(+), 25 deletions(-) + +diff --git a/Cargo.toml b/Cargo.toml +index b53c715..ddf8523 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -16,6 +16,4 @@ name = "sdl" + path = "src/sdl/lib.rs" + + [dependencies] +-num = "0.1.24" +-rand = "0.3" + libc = "0.1" +diff --git a/src/sdl/event.rs b/src/sdl/event.rs +index 17e2cff..12812f8 100644 +--- a/src/sdl/event.rs ++++ b/src/sdl/event.rs +@@ -1,7 +1,6 @@ + use std::mem; + use libc::c_int; + use std::slice; +-use num::FromPrimitive; + use std::ffi::CStr; + use std::str; + +@@ -512,7 +511,7 @@ pub enum Key { + Last, + } + +-impl FromPrimitive for Key { ++impl Key { + fn from_i64(n: i64) -> Option<Key> { + use self::Key::*; + +@@ -753,11 +752,11 @@ impl FromPrimitive for Key { + }) + } + +- fn from_u64(n: u64) -> Option<Key> { FromPrimitive::from_i64(n as i64) } ++ fn from_u64(n: u64) -> Option<Key> { Self::from_i64(n as i64) } + } + + fn wrap_key(i: ll::SDLKey) -> Option<Key> { +- FromPrimitive::from_usize(i as usize) ++ Key::from_u64(i as u64) + } + + #[derive(PartialEq, Eq, Copy, Clone)] +@@ -829,7 +828,7 @@ pub enum Mouse { + WheelDown + } + +-impl FromPrimitive for Mouse { ++impl Mouse { + fn from_i64(n: i64) -> Option<Mouse> { + Some(match n { + 1 => Mouse::Left, +@@ -840,12 +839,10 @@ impl FromPrimitive for Mouse { + _ => return None, + }) + } +- +- fn from_u64(n: u64) -> Option<Mouse> { FromPrimitive::from_i64(n as i64) } + } + + fn wrap_mouse(bitflags: u8) -> Option<Mouse> { +- FromPrimitive::from_u8(bitflags) ++ Mouse::from_i64(bitflags as i64) + } + + #[derive(PartialEq, Eq, Copy, Clone)] +@@ -903,7 +900,7 @@ fn wrap_event(raw: ll::SDL_Event) -> Event { + let ty = if ty.is_null() { return Event::None; } + else { *ty }; + +- let ty : EventType = match FromPrimitive::from_usize(ty as usize) { ++ let ty : EventType = match EventType::from_u64(ty as u64) { + Some(ty) => ty, + None => return Event::None + }; +@@ -1022,9 +1019,6 @@ pub enum EventType { + impl EventType { + pub fn get_state(&self) -> bool { get_event_state(*self) } + pub fn set_state(&self, state: bool) { set_event_state(*self, state) } +-} +- +-impl FromPrimitive for EventType { + fn from_i64(n: i64) -> Option<EventType> { + Some(match n as ll::SDL_EventType { + ll::SDL_NOEVENT => EventType::None, +@@ -1048,7 +1042,7 @@ impl FromPrimitive for EventType { + }) + } + +- fn from_u64(n: u64) -> Option<EventType> { FromPrimitive::from_i64(n as i64) } ++ fn from_u64(n: u64) -> Option<EventType> { Self::from_i64(n as i64) } + } + + pub fn pump_events() { +diff --git a/src/sdl/lib.rs b/src/sdl/lib.rs +index cf04157..0f2a910 100644 +--- a/src/sdl/lib.rs ++++ b/src/sdl/lib.rs +@@ -1,8 +1,6 @@ + #![allow(raw_pointer_derive)] + + extern crate libc; +-extern crate rand; +-extern crate num; + + pub use sdl::*; + +diff --git a/src/sdl/video.rs b/src/sdl/video.rs +index 3f7020a..64084f8 100644 +--- a/src/sdl/video.rs ++++ b/src/sdl/video.rs +@@ -1,7 +1,6 @@ + use std::mem; + use libc::{c_int, c_float}; + use std::ptr; +-use rand::Rng; + use std::slice; + use std::ffi::CString; + use std::path::Path; +@@ -305,13 +304,6 @@ pub enum Color { + RGBA(u8, u8, u8, u8) + } + +-impl ::rand::Rand for Color { +- fn rand<R: ::rand::Rng>(rng: &mut R) -> Color { +- if rng.gen() { RGBA(rng.gen(), rng.gen(), rng.gen(), rng.gen()) } +- else { RGB(rng.gen(), rng.gen(), rng.gen()) } +- } +-} +- + impl Color { + pub fn from_mapped(bit: u32, fmt: *const ll::SDL_PixelFormat) -> Color { + let mut r = 0; +-- +1.7.9.5 + |