From c23be53c09304046298c01e3035601e27890f994 Mon Sep 17 00:00:00 2001 From: Guillermo Galizzi Date: Fri, 9 Jan 2015 11:41:56 -0300 Subject: [PATCH 1/3] Changes to make it work with the 2015-01-09 Nightly box x to Box::new(x) and changed int/uint to isize/usize --- src/lib.rs | 184 ++++++++++++++++++++++++++--------------------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c28e32978..a54ba92e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,7 +36,7 @@ pub enum Console { } impl Console { - pub fn new(width: int, height: int) -> Console { + pub fn new(width: isize, height: isize) -> Console { assert!(width > 0 && height > 0); unsafe { Console::Offscreen( @@ -55,7 +55,7 @@ impl Console { } } - pub fn init_root(width: int, height: int, title: &str, fullscreen: bool) -> Console { + pub fn init_root(width: isize, height: isize, title: &str, fullscreen: bool) -> Console { assert!(width > 0 && height > 0); unsafe { let c_title = CString::from_slice(title.as_bytes()); @@ -68,10 +68,10 @@ impl Console { pub fn blit(source_console: &Console, - source_x: int, source_y: int, - source_width: int, source_height: int, + source_x: isize, source_y: isize, + source_width: isize, source_height: isize, destination_console: &mut Console, - destination_x: int, destination_y: int, + destination_x: isize, destination_y: isize, foreground_alpha: f32, background_alpha: f32) { assert!(source_x >= 0 && source_y >= 0 && source_width > 0 && source_height > 0 && @@ -93,15 +93,15 @@ impl Console { } } - pub fn width(&self) -> int { + pub fn width(&self) -> isize { unsafe { - ffi::TCOD_console_get_width(self.con()) as int + ffi::TCOD_console_get_width(self.con()) as isize } } - pub fn height(&self) -> int { + pub fn height(&self) -> isize { unsafe { - ffi::TCOD_console_get_height(self.con()) as int + ffi::TCOD_console_get_height(self.con()) as isize } } @@ -123,7 +123,7 @@ impl Console { } } - pub fn set_char_background(&mut self, x: int, y: int, + pub fn set_char_background(&mut self, x: isize, y: isize, color: Color, background_flag: BackgroundFlag) { assert!(x >= 0 && y >= 0); @@ -136,7 +136,7 @@ impl Console { } pub fn put_char(&mut self, - x: int, y: int, glyph: char, + x: isize, y: isize, glyph: char, background_flag: BackgroundFlag) { assert!(x >= 0 && y >= 0); unsafe { @@ -147,7 +147,7 @@ impl Console { } pub fn put_char_ex(&mut self, - x: int, y: int, glyph: char, + x: isize, y: isize, glyph: char, foreground: Color, background: Color) { assert!(x >= 0 && y >= 0); unsafe { @@ -164,7 +164,7 @@ impl Console { } pub fn print_ex(&mut self, - x: int, y: int, + x: isize, y: isize, background_flag: BackgroundFlag, alignment: TextAlignment, text: &str) { @@ -186,8 +186,8 @@ impl Console { } pub fn set_custom_font(font_path: ::std::path::Path, flags: FontFlags, - nb_char_horizontal: int, - nb_char_vertical: int) { + nb_char_horizontal: isize, + nb_char_vertical: isize) { unsafe { let path = CString::from_slice(font_path.as_vec()); ffi::TCOD_console_set_custom_font( @@ -264,21 +264,21 @@ pub struct Map { } impl Map { - pub fn new(width: int, height: int) -> Map { + pub fn new(width: isize, height: isize) -> Map { assert!(width > 0 && height > 0); unsafe { Map{tcod_map: ffi::TCOD_map_new(width as c_int, height as c_int)} } } - pub fn size(&self) -> (int, int) { + pub fn size(&self) -> (isize, isize) { unsafe { - (ffi::TCOD_map_get_width(self.tcod_map) as int, - ffi::TCOD_map_get_height(self.tcod_map) as int) + (ffi::TCOD_map_get_width(self.tcod_map) as isize, + ffi::TCOD_map_get_height(self.tcod_map) as isize) } } - pub fn set(&mut self, x: int, y: int, transparent: bool, walkable: bool) { + pub fn set(&mut self, x: isize, y: isize, transparent: bool, walkable: bool) { assert!(x >= 0 && y >= 0); unsafe { ffi::TCOD_map_set_properties(self.tcod_map, x as c_int, y as c_int, @@ -287,7 +287,7 @@ impl Map { } } - pub fn is_walkable(&self, x: int, y: int) -> bool { + pub fn is_walkable(&self, x: isize, y: isize) -> bool { assert!(x >= 0 && y >= 0); unsafe { ffi::TCOD_map_is_walkable(self.tcod_map, x as c_int, y as c_int) != 0 @@ -305,7 +305,7 @@ impl Drop for Map { enum PathInnerData<'a> { Map(Map), - Callback(Box+'a>, Box<(uint, uint)>), + Callback(Box+'a>, Box<(usize, usize)>), } // We need to wrap the pointer in a struct so that we can implement a @@ -330,34 +330,34 @@ pub struct AStarPath<'a>{ tcod_path: TCODPath, #[allow(dead_code)] inner: PathInnerData<'a>, - width: int, - height: int, + width: isize, + height: isize, } extern "C" fn c_path_callback(xf: c_int, yf: c_int, xt: c_int, yt: c_int, user_data: *mut c_void) -> c_float { unsafe { - let ptr: &(uint, uint) = &*(user_data as *const (uint, uint)); - let cb: &mut FnMut<((int, int), (int, int)), f32> = ::std::mem::transmute(*ptr); - cb.call_mut(((xf as int, yf as int), (xt as int, yt as int))) as c_float + let ptr: &(usize, usize) = &*(user_data as *const (usize, usize)); + let cb: &mut FnMut<((isize, isize), (isize, isize)), f32> = ::std::mem::transmute(*ptr); + cb.call_mut(((xf as isize, yf as isize), (xt as isize, yt as isize))) as c_float } } type TcodPathCb = extern "C" fn(c_int, c_int, c_int, c_int, *mut c_void) -> c_float; impl<'a> AStarPath<'a> { - pub fn new_from_callback f32>( - width: int, height: int, path_callback: T, + pub fn new_from_callback f32>( + width: isize, height: isize, path_callback: T, diagonal_cost: f32) -> AStarPath<'a> { - // Convert the closure to a trait object. This will turn it into a fat pointer: - let user_closure: Box> = box path_callback; + // Convert the closure to a trait object. This will turn it isizeo a fat pointer: + let user_closure: Box> = Box::new(path_callback); unsafe { - let fat_ptr: (uint, uint) = ::std::mem::transmute(&*user_closure); + let fat_ptr: (usize, usize) = ::std::mem::transmute(&*user_closure); // Allocate the fat pointer on the heap: - let mut ptr: Box<(uint, uint)> = box fat_ptr; + let mut ptr: Box<(usize, usize)> = Box::new(fat_ptr); // Create a pointer to the fat pointer. This well be passed as *void user_data: - let user_data_ptr: *mut (uint, uint) = &mut *ptr; + let user_data_ptr: *mut (usize, usize) = &mut *ptr; let tcod_path = ffi::TCOD_path_new_using_function(width as c_int, height as c_int, Some(c_path_callback as TcodPathCb), @@ -389,8 +389,8 @@ impl<'a> AStarPath<'a> { } pub fn find(&mut self, - from: (int, int), - to: (int, int)) -> bool { + from: (isize, isize), + to: (isize, isize)) -> bool { let (from_x, from_y) = from; let (to_x, to_y) = to; assert!(from_x >= 0 && from_y >= 0 && to_x >= 0 && to_y >= 0); @@ -410,13 +410,13 @@ impl<'a> AStarPath<'a> { AStarPathIterator{tcod_path: self.tcod_path.ptr, recalculate: true} } - pub fn walk_one_step(&mut self, recalculate_when_needed: bool) -> Option<(int, int)> { + pub fn walk_one_step(&mut self, recalculate_when_needed: bool) -> Option<(isize, isize)> { unsafe { let mut x: c_int = 0; let mut y: c_int = 0; match ffi::TCOD_path_walk(self.tcod_path.ptr, &mut x, &mut y, recalculate_when_needed as c_bool) != 0 { - true => Some((x as int, y as int)), + true => Some((x as isize, y as isize)), false => None, } } @@ -428,25 +428,25 @@ impl<'a> AStarPath<'a> { } } - pub fn origin(&self) -> (int, int) { + pub fn origin(&self) -> (isize, isize) { unsafe { let mut x: c_int = 0; let mut y: c_int = 0; ffi::TCOD_path_get_origin(self.tcod_path.ptr, &mut x, &mut y); - (x as int, y as int) + (x as isize, y as isize) } } - pub fn destination(&self) -> (int, int) { + pub fn destination(&self) -> (isize, isize) { unsafe { let mut x: c_int = 0; let mut y: c_int = 0; ffi::TCOD_path_get_destination(self.tcod_path.ptr, &mut x, &mut y); - (x as int, y as int) + (x as isize, y as isize) } } - pub fn get(&self, index: int) -> Option<(int, int)> { + pub fn get(&self, index: isize) -> Option<(isize, isize)> { if index < 0 || index >= self.len() { return None; } @@ -454,7 +454,7 @@ impl<'a> AStarPath<'a> { let mut x: c_int = 0; let mut y: c_int = 0; ffi::TCOD_path_get(self.tcod_path.ptr, index as c_int, &mut x, &mut y); - (Some((x as int, y as int))) + (Some((x as isize, y as isize))) } } @@ -464,9 +464,9 @@ impl<'a> AStarPath<'a> { } } - pub fn len(&self) -> int { + pub fn len(&self) -> isize { unsafe { - ffi::TCOD_path_size(self.tcod_path.ptr) as int + ffi::TCOD_path_size(self.tcod_path.ptr) as isize } } } @@ -487,22 +487,22 @@ pub struct DijkstraPath<'a> { tcod_path: TCODDijkstraPath, #[allow(dead_code)] inner: PathInnerData<'a>, - width: int, - height: int, + width: isize, + height: isize, } impl<'a> DijkstraPath<'a> { - pub fn new_from_callback f32>( - width: int, height: int, + pub fn new_from_callback f32>( + width: isize, height: isize, path_callback: T, diagonal_cost: f32) -> DijkstraPath<'a> { // NOTE: this is might be a bit confusing. See the // AStarPath::new_from_callback implementation comments. - let user_closure: Box> = box path_callback; + let user_closure: Box> = Box::new(path_callback); unsafe { - let fat_ptr: (uint, uint) = ::std::mem::transmute(&*user_closure); - let mut ptr: Box<(uint, uint)> = box fat_ptr; - let user_data_ptr: *mut (uint, uint) = &mut *ptr; + let fat_ptr: (usize, usize) = ::std::mem::transmute(&*user_closure); + let mut ptr: Box<(usize, usize)> = Box::new(fat_ptr); + let user_data_ptr: *mut (usize, usize) = &mut *ptr; let tcod_path = ffi::TCOD_dijkstra_new_using_function(width as c_int, height as c_int, Some(c_path_callback as TcodPathCb), @@ -530,7 +530,7 @@ impl<'a> DijkstraPath<'a> { } } - pub fn compute_grid(&mut self, root: (int, int)) { + pub fn compute_grid(&mut self, root: (isize, isize)) { let (x, y) = root; assert!(x >= 0 && y >= 0 && x < self.width && y < self.height); unsafe { @@ -538,7 +538,7 @@ impl<'a> DijkstraPath<'a> { } } - pub fn find(&mut self, destination: (int, int)) -> bool { + pub fn find(&mut self, destination: (isize, isize)) -> bool { let (x, y) = destination; if x >= 0 && y >= 0 && x < self.width && y < self.height { unsafe { @@ -553,19 +553,19 @@ impl<'a> DijkstraPath<'a> { DijkstraPathIterator{tcod_path: self.tcod_path.ptr} } - pub fn walk_one_step(&mut self) -> Option<(int, int)> { + pub fn walk_one_step(&mut self) -> Option<(isize, isize)> { unsafe { let mut x: c_int = 0; let mut y: c_int = 0; match ffi::TCOD_dijkstra_path_walk(self.tcod_path.ptr, &mut x, &mut y) != 0 { - true => Some((x as int, y as int)), + true => Some((x as isize, y as isize)), false => None, } } } - pub fn distance_from_root(&self, point: (int, int)) -> Option { + pub fn distance_from_root(&self, point: (isize, isize)) -> Option { let (x, y) = point; let result = unsafe { ffi::TCOD_dijkstra_get_distance(self.tcod_path.ptr, x as c_int, y as c_int) @@ -583,7 +583,7 @@ impl<'a> DijkstraPath<'a> { } } - pub fn get(&self, index: int) -> Option<(int, int)> { + pub fn get(&self, index: isize) -> Option<(isize, isize)> { if index < 0 || index >= self.len() { return None; } @@ -591,7 +591,7 @@ impl<'a> DijkstraPath<'a> { let mut x: c_int = 0; let mut y: c_int = 0; ffi::TCOD_dijkstra_get(self.tcod_path.ptr, index as c_int, &mut x, &mut y); - Some((x as int, y as int)) + Some((x as isize, y as isize)) } } @@ -601,9 +601,9 @@ impl<'a> DijkstraPath<'a> { } } - pub fn len(&self) -> int { + pub fn len(&self) -> isize { unsafe { - ffi::TCOD_dijkstra_size(self.tcod_path.ptr) as int + ffi::TCOD_dijkstra_size(self.tcod_path.ptr) as isize } } } @@ -614,15 +614,15 @@ pub struct AStarPathIterator<'a> { } impl<'a> Iterator for AStarPathIterator<'a> { - type Item = (int, int); + type Item = (isize, isize); - fn next(&mut self) -> Option<(int, int)> { + fn next(&mut self) -> Option<(isize, isize)> { unsafe { let mut x: c_int = 0; let mut y: c_int = 0; match ffi::TCOD_path_walk(self.tcod_path, &mut x, &mut y, self.recalculate as c_bool) != 0 { - true => Some((x as int, y as int)), + true => Some((x as isize, y as isize)), false => None, } } @@ -634,14 +634,14 @@ pub struct DijkstraPathIterator<'a> { } impl<'a> Iterator for DijkstraPathIterator<'a> { - type Item = (int, int); + type Item = (isize, isize); - fn next(&mut self) -> Option<(int, int)> { + fn next(&mut self) -> Option<(isize, isize)> { unsafe { let mut x: c_int = 0; let mut y: c_int = 0; match ffi::TCOD_dijkstra_path_walk(self.tcod_path, &mut x, &mut y) != 0 { - true => Some((x as int, y as int)), + true => Some((x as isize, y as isize)), false => None, } } @@ -652,9 +652,9 @@ impl<'a> Iterator for DijkstraPathIterator<'a> { #[repr(C)] #[derive(Copy)] pub enum Renderer { - GLSL = ffi::TCOD_RENDERER_GLSL as int, - OpenGL = ffi::TCOD_RENDERER_OPENGL as int, - SDL = ffi::TCOD_RENDERER_SDL as int, + GLSL = ffi::TCOD_RENDERER_GLSL as isize, + OpenGL = ffi::TCOD_RENDERER_OPENGL as isize, + SDL = ffi::TCOD_RENDERER_SDL as isize, } bitflags! { @@ -962,29 +962,29 @@ pub mod colors { #[repr(C)] #[derive(Copy)] pub enum TextAlignment { - Left = ffi::TCOD_LEFT as int, - Right = ffi::TCOD_RIGHT as int, - Center = ffi::TCOD_CENTER as int, + Left = ffi::TCOD_LEFT as isize, + Right = ffi::TCOD_RIGHT as isize, + Center = ffi::TCOD_CENTER as isize, } #[repr(C)] #[derive(Copy)] pub enum BackgroundFlag { - None = ffi::TCOD_BKGND_NONE as int, - Set = ffi::TCOD_BKGND_SET as int, - Multiply = ffi::TCOD_BKGND_MULTIPLY as int, - Lighten = ffi::TCOD_BKGND_LIGHTEN as int, - Darken = ffi::TCOD_BKGND_DARKEN as int, - Screen = ffi::TCOD_BKGND_SCREEN as int, - ColorDodge = ffi::TCOD_BKGND_COLOR_DODGE as int, - ColorBurn = ffi::TCOD_BKGND_COLOR_BURN as int, - Add = ffi::TCOD_BKGND_ADD as int, - AddA = ffi::TCOD_BKGND_ADDA as int, - Burn = ffi::TCOD_BKGND_BURN as int, - Overlay = ffi::TCOD_BKGND_OVERLAY as int, - Alph = ffi::TCOD_BKGND_ALPH as int, - Default = ffi::TCOD_BKGND_DEFAULT as int + None = ffi::TCOD_BKGND_NONE as isize, + Set = ffi::TCOD_BKGND_SET as isize, + Multiply = ffi::TCOD_BKGND_MULTIPLY as isize, + Lighten = ffi::TCOD_BKGND_LIGHTEN as isize, + Darken = ffi::TCOD_BKGND_DARKEN as isize, + Screen = ffi::TCOD_BKGND_SCREEN as isize, + ColorDodge = ffi::TCOD_BKGND_COLOR_DODGE as isize, + ColorBurn = ffi::TCOD_BKGND_COLOR_BURN as isize, + Add = ffi::TCOD_BKGND_ADD as isize, + AddA = ffi::TCOD_BKGND_ADDA as isize, + Burn = ffi::TCOD_BKGND_BURN as isize, + Overlay = ffi::TCOD_BKGND_OVERLAY as isize, + Alph = ffi::TCOD_BKGND_ALPH as isize, + Default = ffi::TCOD_BKGND_DEFAULT as isize } @@ -992,20 +992,20 @@ pub mod system { use libc::{c_int}; use ffi; - pub fn set_fps(fps: int) { + pub fn set_fps(fps: isize) { assert!(fps > 0); unsafe { ffi::TCOD_sys_set_fps(fps as c_int) } } - pub fn get_fps() -> int { + pub fn get_fps() -> isize { let mut result; unsafe { result = ffi::TCOD_sys_get_fps(); } assert!(result >= 0); - return result as int + return result as isize } pub fn get_last_frame_length() -> f32 { From ee4937d50fa83897d0d9f078ee6d5fd99f448b60 Mon Sep 17 00:00:00 2001 From: Guillermo Galizzi Date: Fri, 9 Jan 2015 12:38:29 -0300 Subject: [PATCH 2/3] Change u sufix to us --- tcod-sys/lib.rs | 140 ++++++++++++++++++++++++------------------------ 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/tcod-sys/lib.rs b/tcod-sys/lib.rs index bde0d5700..bdb4ca7a7 100644 --- a/tcod-sys/lib.rs +++ b/tcod-sys/lib.rs @@ -6,7 +6,7 @@ extern crate libc; pub type __int128_t = ::libc::c_void; pub type __uint128_t = ::libc::c_void; -pub type __builtin_va_list = [__va_list_tag; 1u]; +pub type __builtin_va_list = [__va_list_tag; 1us]; pub type __int8_t = ::libc::c_char; pub type __uint8_t = ::libc::c_uchar; pub type __int16_t = ::libc::c_short; @@ -20,10 +20,10 @@ pub type __darwin_natural_t = ::libc::c_uint; pub type __darwin_ct_rune_t = ::libc::c_int; #[repr(C)] pub struct __mbstate_t { - pub data: [u64; 16u], + pub data: [u64; 16us], } impl __mbstate_t { - pub fn __mbstate8(&mut self) -> *mut [::libc::c_char; 128u] { + pub fn __mbstate8(&mut self) -> *mut [::libc::c_char; 128us] { unsafe { ::std::mem::transmute(self) } } pub fn _mbstateL(&mut self) -> *mut ::libc::c_longlong { @@ -51,48 +51,48 @@ pub struct Struct___darwin_pthread_handler_rec { #[repr(C)] pub struct Struct__opaque_pthread_attr_t { pub __sig: ::libc::c_long, - pub __opaque: [::libc::c_char; 56u], + pub __opaque: [::libc::c_char; 56us], } #[repr(C)] pub struct Struct__opaque_pthread_cond_t { pub __sig: ::libc::c_long, - pub __opaque: [::libc::c_char; 40u], + pub __opaque: [::libc::c_char; 40us], } #[repr(C)] pub struct Struct__opaque_pthread_condattr_t { pub __sig: ::libc::c_long, - pub __opaque: [::libc::c_char; 8u], + pub __opaque: [::libc::c_char; 8us], } #[repr(C)] pub struct Struct__opaque_pthread_mutex_t { pub __sig: ::libc::c_long, - pub __opaque: [::libc::c_char; 56u], + pub __opaque: [::libc::c_char; 56us], } #[repr(C)] pub struct Struct__opaque_pthread_mutexattr_t { pub __sig: ::libc::c_long, - pub __opaque: [::libc::c_char; 8u], + pub __opaque: [::libc::c_char; 8us], } #[repr(C)] pub struct Struct__opaque_pthread_once_t { pub __sig: ::libc::c_long, - pub __opaque: [::libc::c_char; 8u], + pub __opaque: [::libc::c_char; 8us], } #[repr(C)] pub struct Struct__opaque_pthread_rwlock_t { pub __sig: ::libc::c_long, - pub __opaque: [::libc::c_char; 192u], + pub __opaque: [::libc::c_char; 192us], } #[repr(C)] pub struct Struct__opaque_pthread_rwlockattr_t { pub __sig: ::libc::c_long, - pub __opaque: [::libc::c_char; 16u], + pub __opaque: [::libc::c_char; 16us], } #[repr(C)] pub struct Struct__opaque_pthread_t { pub __sig: ::libc::c_long, pub __cleanup_stack: *mut Struct___darwin_pthread_handler_rec, - pub __opaque: [::libc::c_char; 1168u], + pub __opaque: [::libc::c_char; 1168us], } pub type __darwin_blkcnt_t = __int64_t; pub type __darwin_blksize_t = __int32_t; @@ -122,8 +122,8 @@ pub type __darwin_sigset_t = __uint32_t; pub type __darwin_suseconds_t = __int32_t; pub type __darwin_uid_t = __uint32_t; pub type __darwin_useconds_t = __uint32_t; -pub type __darwin_uuid_t = [::libc::c_uchar; 16u]; -pub type __darwin_uuid_string_t = [::libc::c_char; 37u]; +pub type __darwin_uuid_t = [::libc::c_uchar; 16us]; +pub type __darwin_uuid_string_t = [::libc::c_char; 37us]; pub type __darwin_nl_item = ::libc::c_int; pub type __darwin_wctrans_t = ::libc::c_int; pub type __darwin_wctype_t = __uint32_t; @@ -170,8 +170,8 @@ pub struct Struct___sFILE { pub _ub: Struct___sbuf, pub _extra: *mut Struct___sFILEX, pub _ur: ::libc::c_int, - pub _ubuf: [::libc::c_uchar; 3u], - pub _nbuf: [::libc::c_uchar; 1u], + pub _ubuf: [::libc::c_uchar; 3us], + pub _nbuf: [::libc::c_uchar; 1us], pub _lb: Struct___sbuf, pub _blksize: ::libc::c_int, pub _offset: fpos_t, @@ -216,13 +216,13 @@ pub struct _RuneRange { } #[repr(C)] pub struct _RuneCharClass { - pub __name: [::libc::c_char; 14u], + pub __name: [::libc::c_char; 14us], pub __mask: __uint32_t, } #[repr(C)] pub struct _RuneLocale { - pub __magic: [::libc::c_char; 8u], - pub __encoding: [::libc::c_char; 32u], + pub __magic: [::libc::c_char; 8us], + pub __encoding: [::libc::c_char; 32us], pub __sgetrune: ::std::option::Option ::libc::c_int>, pub __invalid_rune: __darwin_rune_t, - pub __runetype: [__uint32_t; 256u], - pub __maplower: [__darwin_rune_t; 256u], - pub __mapupper: [__darwin_rune_t; 256u], + pub __runetype: [__uint32_t; 256us], + pub __maplower: [__darwin_rune_t; 256us], + pub __mapupper: [__darwin_rune_t; 256us], pub __runetype_ext: _RuneRange, pub __maplower_ext: _RuneRange, pub __mapupper_ext: _RuneRange, @@ -300,7 +300,7 @@ pub type rsize_t = __darwin_size_t; pub type errno_t = ::libc::c_int; #[repr(C)] pub struct Struct_fd_set { - pub fds_bits: [__int32_t; 32u], + pub fds_bits: [__int32_t; 32us], } pub type fd_set = Struct_fd_set; pub type fd_mask = __int32_t; @@ -375,16 +375,16 @@ pub struct Struct___darwin_fp_status { pub type __darwin_fp_status_t = Struct___darwin_fp_status; #[repr(C)] pub struct Struct___darwin_mmst_reg { - pub __mmst_reg: [::libc::c_char; 10u], - pub __mmst_rsrv: [::libc::c_char; 6u], + pub __mmst_reg: [::libc::c_char; 10us], + pub __mmst_rsrv: [::libc::c_char; 6us], } #[repr(C)] pub struct Struct___darwin_xmm_reg { - pub __xmm_reg: [::libc::c_char; 16u], + pub __xmm_reg: [::libc::c_char; 16us], } #[repr(C)] pub struct Struct___darwin_i386_float_state { - pub __fpu_reserved: [::libc::c_int; 2u], + pub __fpu_reserved: [::libc::c_int; 2us], pub __fpu_fcw: Struct___darwin_fp_control, pub __fpu_fsw: Struct___darwin_fp_status, pub __fpu_ftw: __uint8_t, @@ -414,12 +414,12 @@ pub struct Struct___darwin_i386_float_state { pub __fpu_xmm5: Struct___darwin_xmm_reg, pub __fpu_xmm6: Struct___darwin_xmm_reg, pub __fpu_xmm7: Struct___darwin_xmm_reg, - pub __fpu_rsrv4: [::libc::c_char; 224u], + pub __fpu_rsrv4: [::libc::c_char; 224us], pub __fpu_reserved1: ::libc::c_int, } #[repr(C)] pub struct Struct___darwin_i386_avx_state { - pub __fpu_reserved: [::libc::c_int; 2u], + pub __fpu_reserved: [::libc::c_int; 2us], pub __fpu_fcw: Struct___darwin_fp_control, pub __fpu_fsw: Struct___darwin_fp_status, pub __fpu_ftw: __uint8_t, @@ -449,9 +449,9 @@ pub struct Struct___darwin_i386_avx_state { pub __fpu_xmm5: Struct___darwin_xmm_reg, pub __fpu_xmm6: Struct___darwin_xmm_reg, pub __fpu_xmm7: Struct___darwin_xmm_reg, - pub __fpu_rsrv4: [::libc::c_char; 224u], + pub __fpu_rsrv4: [::libc::c_char; 224us], pub __fpu_reserved1: ::libc::c_int, - pub __avx_reserved1: [::libc::c_char; 64u], + pub __avx_reserved1: [::libc::c_char; 64us], pub __fpu_ymmh0: Struct___darwin_xmm_reg, pub __fpu_ymmh1: Struct___darwin_xmm_reg, pub __fpu_ymmh2: Struct___darwin_xmm_reg, @@ -505,7 +505,7 @@ pub struct Struct___darwin_x86_thread_state64 { } #[repr(C)] pub struct Struct___darwin_x86_float_state64 { - pub __fpu_reserved: [::libc::c_int; 2u], + pub __fpu_reserved: [::libc::c_int; 2us], pub __fpu_fcw: Struct___darwin_fp_control, pub __fpu_fsw: Struct___darwin_fp_status, pub __fpu_ftw: __uint8_t, @@ -543,12 +543,12 @@ pub struct Struct___darwin_x86_float_state64 { pub __fpu_xmm13: Struct___darwin_xmm_reg, pub __fpu_xmm14: Struct___darwin_xmm_reg, pub __fpu_xmm15: Struct___darwin_xmm_reg, - pub __fpu_rsrv4: [::libc::c_char; 96u], + pub __fpu_rsrv4: [::libc::c_char; 96us], pub __fpu_reserved1: ::libc::c_int, } #[repr(C)] pub struct Struct___darwin_x86_avx_state64 { - pub __fpu_reserved: [::libc::c_int; 2u], + pub __fpu_reserved: [::libc::c_int; 2us], pub __fpu_fcw: Struct___darwin_fp_control, pub __fpu_fsw: Struct___darwin_fp_status, pub __fpu_ftw: __uint8_t, @@ -586,9 +586,9 @@ pub struct Struct___darwin_x86_avx_state64 { pub __fpu_xmm13: Struct___darwin_xmm_reg, pub __fpu_xmm14: Struct___darwin_xmm_reg, pub __fpu_xmm15: Struct___darwin_xmm_reg, - pub __fpu_rsrv4: [::libc::c_char; 96u], + pub __fpu_rsrv4: [::libc::c_char; 96us], pub __fpu_reserved1: ::libc::c_int, - pub __avx_reserved1: [::libc::c_char; 64u], + pub __avx_reserved1: [::libc::c_char; 64us], pub __fpu_ymmh0: Struct___darwin_xmm_reg, pub __fpu_ymmh1: Struct___darwin_xmm_reg, pub __fpu_ymmh2: Struct___darwin_xmm_reg, @@ -669,7 +669,7 @@ pub type ucontext_t = Struct___darwin_ucontext; pub type sigset_t = __darwin_sigset_t; #[repr(C)] pub struct Union_sigval { - pub data: [u64; 1u], + pub data: [u64; 1us], } impl Union_sigval { pub fn sival_int(&mut self) -> *mut ::libc::c_int { @@ -700,12 +700,12 @@ pub struct Struct___siginfo { pub si_addr: *mut ::libc::c_void, pub si_value: Union_sigval, pub si_band: ::libc::c_long, - pub __pad: [::libc::c_ulong; 7u], + pub __pad: [::libc::c_ulong; 7us], } pub type siginfo_t = Struct___siginfo; #[repr(C)] pub struct Union___sigaction_u { - pub data: [u64; 1u], + pub data: [u64; 1us], } impl Union___sigaction_u { pub fn __sa_handler(&mut self) -> @@ -800,7 +800,7 @@ pub struct Struct_rusage { pub type rusage_info_t = *mut ::libc::c_void; #[repr(C)] pub struct Struct_rusage_info_v0 { - pub ri_uuid: [uint8_t; 16u], + pub ri_uuid: [uint8_t; 16us], pub ri_user_time: uint64_t, pub ri_system_time: uint64_t, pub ri_pkg_idle_wkups: uint64_t, @@ -814,7 +814,7 @@ pub struct Struct_rusage_info_v0 { } #[repr(C)] pub struct Struct_rusage_info_v1 { - pub ri_uuid: [uint8_t; 16u], + pub ri_uuid: [uint8_t; 16us], pub ri_user_time: uint64_t, pub ri_system_time: uint64_t, pub ri_pkg_idle_wkups: uint64_t, @@ -834,7 +834,7 @@ pub struct Struct_rusage_info_v1 { } #[repr(C)] pub struct Struct_rusage_info_v2 { - pub ri_uuid: [uint8_t; 16u], + pub ri_uuid: [uint8_t; 16us], pub ri_user_time: uint64_t, pub ri_system_time: uint64_t, pub ri_pkg_idle_wkups: uint64_t, @@ -866,7 +866,7 @@ pub struct Struct_proc_rlimit_control_wakeupmon { } #[repr(C)] pub struct Union_wait { - pub data: [u32; 1u], + pub data: [u32; 1us], } impl Union_wait { pub fn w_status(&mut self) -> *mut ::libc::c_int { @@ -924,17 +924,17 @@ pub type Sint32 = int32_t; pub type Uint32 = uint32_t; pub type Sint64 = int64_t; pub type Uint64 = uint64_t; -pub type SDL_dummy_uint8 = [::libc::c_int; 1u]; -pub type SDL_dummy_sint8 = [::libc::c_int; 1u]; -pub type SDL_dummy_uint16 = [::libc::c_int; 1u]; -pub type SDL_dummy_sint16 = [::libc::c_int; 1u]; -pub type SDL_dummy_uint32 = [::libc::c_int; 1u]; -pub type SDL_dummy_sint32 = [::libc::c_int; 1u]; -pub type SDL_dummy_uint64 = [::libc::c_int; 1u]; -pub type SDL_dummy_sint64 = [::libc::c_int; 1u]; +pub type SDL_dummy_uint8 = [::libc::c_int; 1us]; +pub type SDL_dummy_sint8 = [::libc::c_int; 1us]; +pub type SDL_dummy_uint16 = [::libc::c_int; 1us]; +pub type SDL_dummy_sint16 = [::libc::c_int; 1us]; +pub type SDL_dummy_uint32 = [::libc::c_int; 1us]; +pub type SDL_dummy_sint32 = [::libc::c_int; 1us]; +pub type SDL_dummy_uint64 = [::libc::c_int; 1us]; +pub type SDL_dummy_sint64 = [::libc::c_int; 1us]; pub type SDL_DUMMY_ENUM = ::libc::c_uint; pub static DUMMY_ENUM_VALUE: ::libc::c_uint = 0; -pub type SDL_dummy_enum = [::libc::c_int; 1u]; +pub type SDL_dummy_enum = [::libc::c_int; 1us]; pub enum Struct__SDL_iconv_t { } pub type SDL_iconv_t = *mut Struct__SDL_iconv_t; pub type SDL_errorcode = ::libc::c_uint; @@ -979,7 +979,7 @@ pub struct Struct_SDL_RWops { } #[repr(C)] pub struct Union_Unnamed3 { - pub data: [u64; 3u], + pub data: [u64; 3us], } impl Union_Unnamed3 { pub fn stdio(&mut self) -> *mut Struct_Unnamed4 { @@ -1037,7 +1037,7 @@ pub struct Struct_SDL_AudioCVT { pub len_ratio: ::libc::c_double, pub filters: [::std::option::Option; 10u], + arg2: Uint16)>; 10us], pub filter_index: ::libc::c_int, } pub type SDL_AudioCVT = Struct_SDL_AudioCVT; @@ -1067,7 +1067,7 @@ pub struct Struct_SDL_CD { pub numtracks: ::libc::c_int, pub cur_track: ::libc::c_int, pub cur_frame: ::libc::c_int, - pub track: [SDL_CDtrack; 100u], + pub track: [SDL_CDtrack; 100us], } pub type SDL_CD = Struct_SDL_CD; pub type SDLKey = ::libc::c_uint; @@ -1464,7 +1464,7 @@ pub struct Struct_SDL_Cursor { pub hot_y: Sint16, pub data: *mut Uint8, pub mask: *mut Uint8, - pub save: [*mut Uint8; 2u], + pub save: [*mut Uint8; 2us], pub wm_cursor: *mut WMcursor, } pub type SDL_Cursor = Struct_SDL_Cursor; @@ -1620,7 +1620,7 @@ pub struct Struct_SDL_SysWMEvent { pub type SDL_SysWMEvent = Struct_SDL_SysWMEvent; #[repr(C)] pub struct Union_SDL_Event { - pub data: [u64; 3u], + pub data: [u64; 3us], } impl Union_SDL_Event { pub fn _type(&mut self) -> *mut Uint8 { @@ -2057,8 +2057,8 @@ pub struct TCOD_lex_t { pub nb_symbols: ::libc::c_int, pub nb_keywords: ::libc::c_int, pub flags: ::libc::c_int, - pub symbols: [[::libc::c_char; 5u]; 100u], - pub keywords: [[::libc::c_char; 20u]; 100u], + pub symbols: [[::libc::c_char; 5us]; 100us], + pub keywords: [[::libc::c_char; 20us]; 100us], pub simpleCmt: *const ::libc::c_char, pub cmtStart: *const ::libc::c_char, pub cmtStop: *const ::libc::c_char, @@ -2112,7 +2112,7 @@ pub const TCOD_TYPE_CUSTOM15: ::libc::c_uint = 39; pub const TCOD_TYPE_LIST: ::libc::c_uint = 1024; #[repr(C)] pub struct TCOD_value_t { - pub data: [u64; 2u], + pub data: [u64; 2us], } impl TCOD_value_t { pub fn b(&mut self) -> *mut _bool { @@ -2183,7 +2183,7 @@ pub struct TCOD_struct_int_t { #[repr(C)] pub struct TCOD_parser_int_t { pub structs: TCOD_list_t, - pub customs: [TCOD_parser_custom_t; 16u], + pub customs: [TCOD_parser_custom_t; 16us], pub fatal: _bool, pub props: TCOD_list_t, } @@ -2241,7 +2241,7 @@ extern "C" { pub static mut _CurrentRuneLocale: *mut _RuneLocale; pub static mut __mb_cur_max: ::libc::c_int; pub static mut suboptarg: *mut ::libc::c_char; - pub static mut TCOD_colors: [[TCOD_color_t; 8u]; 21u]; + pub static mut TCOD_colors: [[TCOD_color_t; 8us]; 21us]; pub static TCOD_black: TCOD_color_t; pub static TCOD_darkest_grey: TCOD_color_t; pub static TCOD_darker_grey: TCOD_color_t; @@ -2891,7 +2891,7 @@ extern "C" { pub fn ecvt(arg1: ::libc::c_double, arg2: ::libc::c_int, arg3: *mut ::libc::c_int, arg4: *mut ::libc::c_int) -> *mut ::libc::c_char; - pub fn erand48(arg1: [::libc::c_ushort; 3u]) -> ::libc::c_double; + pub fn erand48(arg1: [::libc::c_ushort; 3us]) -> ::libc::c_double; pub fn fcvt(arg1: ::libc::c_double, arg2: ::libc::c_int, arg3: *mut ::libc::c_int, arg4: *mut ::libc::c_int) -> *mut ::libc::c_char; @@ -2903,14 +2903,14 @@ extern "C" { pub fn grantpt(arg1: ::libc::c_int) -> ::libc::c_int; pub fn initstate(arg1: ::libc::c_uint, arg2: *mut ::libc::c_char, arg3: size_t) -> *mut ::libc::c_char; - pub fn jrand48(arg1: [::libc::c_ushort; 3u]) -> ::libc::c_long; + pub fn jrand48(arg1: [::libc::c_ushort; 3us]) -> ::libc::c_long; pub fn l64a(arg1: ::libc::c_long) -> *mut ::libc::c_char; - pub fn lcong48(arg1: [::libc::c_ushort; 7u]); + pub fn lcong48(arg1: [::libc::c_ushort; 7us]); pub fn lrand48() -> ::libc::c_long; pub fn mktemp(arg1: *mut ::libc::c_char) -> *mut ::libc::c_char; pub fn mkstemp(arg1: *mut ::libc::c_char) -> ::libc::c_int; pub fn mrand48() -> ::libc::c_long; - pub fn nrand48(arg1: [::libc::c_ushort; 3u]) -> ::libc::c_long; + pub fn nrand48(arg1: [::libc::c_ushort; 3us]) -> ::libc::c_long; pub fn posix_openpt(arg1: ::libc::c_int) -> ::libc::c_int; pub fn ptsname(arg1: ::libc::c_int) -> *mut ::libc::c_char; pub fn putenv(arg1: *mut ::libc::c_char) -> ::libc::c_int; @@ -2918,7 +2918,7 @@ extern "C" { pub fn rand_r(arg1: *mut ::libc::c_uint) -> ::libc::c_int; pub fn realpath(arg1: *const ::libc::c_char, arg2: *mut ::libc::c_char) -> *mut ::libc::c_char; - pub fn seed48(arg1: [::libc::c_ushort; 3u]) -> *mut ::libc::c_ushort; + pub fn seed48(arg1: [::libc::c_ushort; 3us]) -> *mut ::libc::c_ushort; pub fn setenv(arg1: *const ::libc::c_char, arg2: *const ::libc::c_char, arg3: ::libc::c_int) -> ::libc::c_int; pub fn setkey(arg1: *const ::libc::c_char); @@ -4166,7 +4166,7 @@ extern "C" { ::libc::c_float; pub fn TCOD_heightmap_get_normal(hm: *const TCOD_heightmap_t, x: ::libc::c_float, y: ::libc::c_float, - n: [::libc::c_float; 3u], + n: [::libc::c_float; 3us], waterLevel: ::libc::c_float); pub fn TCOD_heightmap_count_cells(hm: *const TCOD_heightmap_t, min: ::libc::c_float, @@ -4208,8 +4208,8 @@ extern "C" { hradius: ::libc::c_float, hheight: ::libc::c_float); pub fn TCOD_heightmap_dig_bezier(hm: *mut TCOD_heightmap_t, - px: [::libc::c_int; 4u], - py: [::libc::c_int; 4u], + px: [::libc::c_int; 4us], + py: [::libc::c_int; 4us], startRadius: ::libc::c_float, startDepth: ::libc::c_float, endRadius: ::libc::c_float, From 30e95483880a7349dc63f459a4870fb490e24f51 Mon Sep 17 00:00:00 2001 From: Tomas Sedovic Date: Fri, 9 Jan 2015 19:13:25 +0100 Subject: [PATCH 3/3] Fix the examples This temporarily renames int/uint to isize/usize to silence the warnings and uses `{:?}` instead of `{}` in println! (otherwise we'd have to impement String for our types). --- examples/astar-path-finding.rs | 8 ++++---- examples/dijkstra-path-finding.rs | 12 ++++++------ examples/minimal.rs | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/astar-path-finding.rs b/examples/astar-path-finding.rs index 23605c284..28cc98293 100644 --- a/examples/astar-path-finding.rs +++ b/examples/astar-path-finding.rs @@ -5,7 +5,7 @@ extern crate tcod; use tcod::AStarPath; fn create_path() -> AStarPath<'static> { - let chess_board: [[int; 8]; 8] = [ + let chess_board: [[isize; 8]; 8] = [ [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], @@ -16,10 +16,10 @@ fn create_path() -> AStarPath<'static> { [0, 1, 0, 1, 0, 1, 0, 1], ]; // Movement like in Checkers: you can only move to the square of the same colour - let can_move = move |&mut: from: (int, int), to: (int, int)| -> f32 { + let can_move = move |&mut: from: (isize, isize), to: (isize, isize)| -> f32 { let (fx, fy) = from; let (tx, ty) = to; - if chess_board[fy as uint][fx as uint] == chess_board[ty as uint][tx as uint] { + if chess_board[fy as usize][fx as usize] == chess_board[ty as usize][tx as usize] { 1.0 } else { 0.0 @@ -58,7 +58,7 @@ fn main() { // Walk the path (consuming it): for pos in path.walk() { - println!("Walking to {}", pos) + println!("Walking to {:?}", pos); } assert_eq!(path.len(), 0); diff --git a/examples/dijkstra-path-finding.rs b/examples/dijkstra-path-finding.rs index 029fdb3b7..580cc9c61 100644 --- a/examples/dijkstra-path-finding.rs +++ b/examples/dijkstra-path-finding.rs @@ -5,7 +5,7 @@ extern crate tcod; use tcod::DijkstraPath; fn create_path() -> DijkstraPath<'static> { - let chess_board: [[int; 8]; 8] = [ + let chess_board: [[isize; 8]; 8] = [ [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], @@ -16,10 +16,10 @@ fn create_path() -> DijkstraPath<'static> { [0, 1, 0, 1, 0, 1, 0, 1], ]; // Movement like in Checkers: you can only move to the square of the same colour - let can_move = move |&mut: from: (int, int), to: (int, int)| -> f32 { + let can_move = move |&mut: from: (isize, isize), to: (isize, isize)| -> f32 { let (fx, fy) = from; let (tx, ty) = to; - if chess_board[fy as uint][fx as uint] == chess_board[ty as uint][tx as uint] { + if chess_board[fy as usize][fx as usize] == chess_board[ty as usize][tx as usize] { 1.0 } else { 0.0 @@ -28,12 +28,12 @@ fn create_path() -> DijkstraPath<'static> { DijkstraPath::new_from_callback(8, 8, can_move, 1.0) } -fn walk_from(path: &mut DijkstraPath, origin: (int, int)) { +fn walk_from(path: &mut DijkstraPath, origin: (isize, isize)) { path.find(origin); path.reverse(); - println!("Starting from: {}", origin); + println!("Starting from: {:?}", origin); for pos in path.walk() { - println!("Walking to: {}", pos); + println!("Walking to: {:?}", pos); } println!("Arrived at the destination!\n"); } diff --git a/examples/minimal.rs b/examples/minimal.rs index 0a51f9400..66b01e9db 100644 --- a/examples/minimal.rs +++ b/examples/minimal.rs @@ -7,6 +7,6 @@ fn main() { while !Console::window_closed() { Console::flush(); let key = Console::wait_for_keypress(true); - println!("Pressed key: {}", key); + println!("Pressed key: {:?}", key); } }