Skip to content

Update to master #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/codegen/keycode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ struct Key {
code: uint,
ident: &'static str,
}
impl TotalOrd for Key {
fn cmp(&self, other: &Key) -> Ordering {
if self.code < other.code {
Less
} else if self.code > other.code {
Greater
} else { Equal }
}
}
impl TotalEq for Key {
fn equals(&self, other: &Key) -> bool {
if self.code == other.code {
true
} else { false }
}
}


fn Key(code: uint, ident: &'static str) -> Key {
Key { code: code, ident: ident }
Expand Down Expand Up @@ -265,7 +282,7 @@ pub fn generate(output_dir: &Path) {
Key(1073742106, "SleepKey"),
];

extra::sort::quick_sort(entries, |a, b| a.code <= b.code);
entries.sort();
unsafe {
longest_ident = entries.iter().map(|&key| key.ident().len()).max_by(|&i| i).unwrap();
}
Expand Down
3 changes: 2 additions & 1 deletion src/codegen/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#[feature(macro_rules)];
#[crate_id = "codegen#0.1"];

use std::os;
use std::io::buffered::BufferedWriter;
Expand All @@ -15,7 +16,7 @@ fn main() {
match args.len() {
0 => {
println("usage: codegen [keycode|scancode].rs destdir");
os::set_exit_status(1);
os::set_exit_status(1);
},
3 => {
let output_dir = GenericPath::new(args[2].clone());
Expand Down
18 changes: 17 additions & 1 deletion src/codegen/scancode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ struct ScanCode {
code: uint,
ident: &'static str,
}
impl TotalOrd for ScanCode {
fn cmp(&self, other: &ScanCode) -> Ordering {
if self.code < other.code {
Less
} else if self.code > other.code {
Greater
} else { Equal }
}
}
impl TotalEq for ScanCode {
fn equals(&self, other: &ScanCode) -> bool {
if self.code == other.code {
true
} else { false }
}
}

fn ScanCode(code: uint, ident: &'static str) -> ScanCode {
ScanCode { code: code, ident: ident }
Expand Down Expand Up @@ -272,7 +288,7 @@ pub fn generate(output_dir: &Path) {
ScanCode(512, "NumScanCode"),
];

extra::sort::quick_sort(entries, |a, b| a.code <= b.code);
entries.sort();
unsafe {
longest_ident = entries.iter().map(|&key| key.ident().len()).max_by(|&i| i).unwrap();
}
Expand Down
7 changes: 2 additions & 5 deletions src/sdl2/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#[link(name = "sdl2",
vers = "0.0.1",
uuid = "263e35b2-0727-11e3-b3dd-29219a890b3c",
url = "http://github.com/AngryLawyer/rust-sdl2")];
#[crate_id="sdl2"];
#[crate_id="sdl2#0.0.1"];
#[crate_type = "lib"];

#[desc = "SDL2 bindings"];
#[license = "MIT"];
Expand Down