]>
Commit | Line | Data |
---|---|---|
1 | From 4d9e740dfd80df976d976e21a7e33fd9f8b3c362 Mon Sep 17 00:00:00 2001 | |
2 | From: Kostya Shishkov <kostya.shishkov@gmail.com> | |
3 | Date: Fri, 22 Nov 2019 17:47:54 +0100 | |
4 | Subject: [PATCH 1/4] remove not really needed dependencies | |
5 | ||
6 | --- | |
7 | Cargo.toml | 2 -- | |
8 | src/sdl/event.rs | 20 +++++++------------- | |
9 | src/sdl/lib.rs | 2 -- | |
10 | src/sdl/video.rs | 8 -------- | |
11 | 4 files changed, 7 insertions(+), 25 deletions(-) | |
12 | ||
13 | diff --git a/Cargo.toml b/Cargo.toml | |
14 | index b53c715..ddf8523 100644 | |
15 | --- a/Cargo.toml | |
16 | +++ b/Cargo.toml | |
17 | @@ -16,6 +16,4 @@ name = "sdl" | |
18 | path = "src/sdl/lib.rs" | |
19 | ||
20 | [dependencies] | |
21 | -num = "0.1.24" | |
22 | -rand = "0.3" | |
23 | libc = "0.1" | |
24 | diff --git a/src/sdl/event.rs b/src/sdl/event.rs | |
25 | index 17e2cff..12812f8 100644 | |
26 | --- a/src/sdl/event.rs | |
27 | +++ b/src/sdl/event.rs | |
28 | @@ -1,7 +1,6 @@ | |
29 | use std::mem; | |
30 | use libc::c_int; | |
31 | use std::slice; | |
32 | -use num::FromPrimitive; | |
33 | use std::ffi::CStr; | |
34 | use std::str; | |
35 | ||
36 | @@ -512,7 +511,7 @@ pub enum Key { | |
37 | Last, | |
38 | } | |
39 | ||
40 | -impl FromPrimitive for Key { | |
41 | +impl Key { | |
42 | fn from_i64(n: i64) -> Option<Key> { | |
43 | use self::Key::*; | |
44 | ||
45 | @@ -753,11 +752,11 @@ impl FromPrimitive for Key { | |
46 | }) | |
47 | } | |
48 | ||
49 | - fn from_u64(n: u64) -> Option<Key> { FromPrimitive::from_i64(n as i64) } | |
50 | + fn from_u64(n: u64) -> Option<Key> { Self::from_i64(n as i64) } | |
51 | } | |
52 | ||
53 | fn wrap_key(i: ll::SDLKey) -> Option<Key> { | |
54 | - FromPrimitive::from_usize(i as usize) | |
55 | + Key::from_u64(i as u64) | |
56 | } | |
57 | ||
58 | #[derive(PartialEq, Eq, Copy, Clone)] | |
59 | @@ -829,7 +828,7 @@ pub enum Mouse { | |
60 | WheelDown | |
61 | } | |
62 | ||
63 | -impl FromPrimitive for Mouse { | |
64 | +impl Mouse { | |
65 | fn from_i64(n: i64) -> Option<Mouse> { | |
66 | Some(match n { | |
67 | 1 => Mouse::Left, | |
68 | @@ -840,12 +839,10 @@ impl FromPrimitive for Mouse { | |
69 | _ => return None, | |
70 | }) | |
71 | } | |
72 | - | |
73 | - fn from_u64(n: u64) -> Option<Mouse> { FromPrimitive::from_i64(n as i64) } | |
74 | } | |
75 | ||
76 | fn wrap_mouse(bitflags: u8) -> Option<Mouse> { | |
77 | - FromPrimitive::from_u8(bitflags) | |
78 | + Mouse::from_i64(bitflags as i64) | |
79 | } | |
80 | ||
81 | #[derive(PartialEq, Eq, Copy, Clone)] | |
82 | @@ -903,7 +900,7 @@ fn wrap_event(raw: ll::SDL_Event) -> Event { | |
83 | let ty = if ty.is_null() { return Event::None; } | |
84 | else { *ty }; | |
85 | ||
86 | - let ty : EventType = match FromPrimitive::from_usize(ty as usize) { | |
87 | + let ty : EventType = match EventType::from_u64(ty as u64) { | |
88 | Some(ty) => ty, | |
89 | None => return Event::None | |
90 | }; | |
91 | @@ -1022,9 +1019,6 @@ pub enum EventType { | |
92 | impl EventType { | |
93 | pub fn get_state(&self) -> bool { get_event_state(*self) } | |
94 | pub fn set_state(&self, state: bool) { set_event_state(*self, state) } | |
95 | -} | |
96 | - | |
97 | -impl FromPrimitive for EventType { | |
98 | fn from_i64(n: i64) -> Option<EventType> { | |
99 | Some(match n as ll::SDL_EventType { | |
100 | ll::SDL_NOEVENT => EventType::None, | |
101 | @@ -1048,7 +1042,7 @@ impl FromPrimitive for EventType { | |
102 | }) | |
103 | } | |
104 | ||
105 | - fn from_u64(n: u64) -> Option<EventType> { FromPrimitive::from_i64(n as i64) } | |
106 | + fn from_u64(n: u64) -> Option<EventType> { Self::from_i64(n as i64) } | |
107 | } | |
108 | ||
109 | pub fn pump_events() { | |
110 | diff --git a/src/sdl/lib.rs b/src/sdl/lib.rs | |
111 | index cf04157..0f2a910 100644 | |
112 | --- a/src/sdl/lib.rs | |
113 | +++ b/src/sdl/lib.rs | |
114 | @@ -1,8 +1,6 @@ | |
115 | #![allow(raw_pointer_derive)] | |
116 | ||
117 | extern crate libc; | |
118 | -extern crate rand; | |
119 | -extern crate num; | |
120 | ||
121 | pub use sdl::*; | |
122 | ||
123 | diff --git a/src/sdl/video.rs b/src/sdl/video.rs | |
124 | index 3f7020a..64084f8 100644 | |
125 | --- a/src/sdl/video.rs | |
126 | +++ b/src/sdl/video.rs | |
127 | @@ -1,7 +1,6 @@ | |
128 | use std::mem; | |
129 | use libc::{c_int, c_float}; | |
130 | use std::ptr; | |
131 | -use rand::Rng; | |
132 | use std::slice; | |
133 | use std::ffi::CString; | |
134 | use std::path::Path; | |
135 | @@ -305,13 +304,6 @@ pub enum Color { | |
136 | RGBA(u8, u8, u8, u8) | |
137 | } | |
138 | ||
139 | -impl ::rand::Rand for Color { | |
140 | - fn rand<R: ::rand::Rng>(rng: &mut R) -> Color { | |
141 | - if rng.gen() { RGBA(rng.gen(), rng.gen(), rng.gen(), rng.gen()) } | |
142 | - else { RGB(rng.gen(), rng.gen(), rng.gen()) } | |
143 | - } | |
144 | -} | |
145 | - | |
146 | impl Color { | |
147 | pub fn from_mapped(bit: u32, fmt: *const ll::SDL_PixelFormat) -> Color { | |
148 | let mut r = 0; | |
149 | -- | |
150 | 1.7.9.5 | |
151 |