From e064ea0e5985b158ae02bb5fb6d01294eac18fe7 Mon Sep 17 00:00:00 2001 From: Colin Sherratt Date: Fri, 9 Jan 2015 16:16:39 -0700 Subject: [PATCH] int to isize --- benches/common/macros.rs | 8 ++++---- benches/construction.rs | 2 +- src/angle.rs | 10 +++++----- src/array.rs | 18 +++++++++--------- src/matrix.rs | 36 ++++++++++++++++++------------------ src/num.rs | 12 ++++++------ src/point.rs | 16 ++++++++-------- src/projection.rs | 10 +++++----- src/quaternion.rs | 10 +++++----- src/vector.rs | 10 +++++----- 10 files changed, 66 insertions(+), 66 deletions(-) diff --git a/benches/common/macros.rs b/benches/common/macros.rs index 7c36b75..9c48c73 100644 --- a/benches/common/macros.rs +++ b/benches/common/macros.rs @@ -17,7 +17,7 @@ macro_rules! bench_binop( ($name: ident, $t1: ty, $t2: ty, $binop: ident) => { #[bench] fn $name(bh: &mut Bencher) { - const LEN: uint = 1 << 13; + const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); @@ -40,7 +40,7 @@ macro_rules! bench_binop_deref( ($name: ident, $t1: ty, $t2: ty, $binop: ident) => { #[bench] fn $name(bh: &mut Bencher) { - const LEN: uint = 1 << 13; + const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); @@ -63,7 +63,7 @@ macro_rules! bench_unop( ($name: ident, $t: ty, $unop: ident) => { #[bench] fn $name(bh: &mut Bencher) { - const LEN: uint = 1 << 13; + const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); @@ -85,7 +85,7 @@ macro_rules! bench_construction( ($name: ident, $t: ty, $constructor: path [ $($args: ident: $types: ty),+ ]) => { #[bench] fn $name(bh: &mut Bencher) { - const LEN: uint = 1 << 13; + const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); diff --git a/benches/construction.rs b/benches/construction.rs index 159562d..ab382ae 100644 --- a/benches/construction.rs +++ b/benches/construction.rs @@ -27,7 +27,7 @@ use cgmath::{Quaternion, Basis2, Basis3, Vector3, Rotation2, Rotation3, Rad}; #[macro_use] mod macros; fn bench_from_axis_angle>(bh: &mut Bencher) { - const LEN: uint = 1 << 13; + const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); diff --git a/src/angle.rs b/src/angle.rs index dc54bb0..4fc3c35 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -150,10 +150,10 @@ pub trait Angle fn full_turn() -> Self; - #[inline] fn turn_div_2() -> Self { let full_turn: Self = Angle::full_turn(); full_turn.div_s(cast(2i).unwrap()) } - #[inline] fn turn_div_3() -> Self { let full_turn: Self = Angle::full_turn(); full_turn.div_s(cast(3i).unwrap()) } - #[inline] fn turn_div_4() -> Self { let full_turn: Self = Angle::full_turn(); full_turn.div_s(cast(4i).unwrap()) } - #[inline] fn turn_div_6() -> Self { let full_turn: Self = Angle::full_turn(); full_turn.div_s(cast(6i).unwrap()) } + #[inline] fn turn_div_2() -> Self { let full_turn: Self = Angle::full_turn(); full_turn.div_s(cast(2i8).unwrap()) } + #[inline] fn turn_div_3() -> Self { let full_turn: Self = Angle::full_turn(); full_turn.div_s(cast(3i8).unwrap()) } + #[inline] fn turn_div_4() -> Self { let full_turn: Self = Angle::full_turn(); full_turn.div_s(cast(4i8).unwrap()) } + #[inline] fn turn_div_6() -> Self { let full_turn: Self = Angle::full_turn(); full_turn.div_s(cast(6i8).unwrap()) } #[inline] fn equiv(&self, other: &Self) -> bool { self.normalize() == other.normalize() } } @@ -264,7 +264,7 @@ Angle for Rad { impl Angle for Deg { #[inline] fn from>(theta: A) -> Deg { theta.to_deg() } - #[inline] fn full_turn() -> Deg { deg(cast(360i).unwrap()) } + #[inline] fn full_turn() -> Deg { deg(cast(360i32).unwrap()) } } #[inline] pub fn sin(theta: Rad) -> S { theta.s.sin() } diff --git a/src/array.rs b/src/array.rs index f76e107..843d095 100644 --- a/src/array.rs +++ b/src/array.rs @@ -18,7 +18,7 @@ use std::ptr; use std::ops::*; /// An array containing elements of type `Element` -pub trait Array1: Index + IndexMut { +pub trait Array1: Index + IndexMut { /// Get the pointer to the first element of the array. fn ptr<'a>(&'a self) -> &'a Element { &(*self)[0] @@ -31,14 +31,14 @@ pub trait Array1: Index + IndexMut Element { + fn replace_elem(&mut self, i: usize, src: Element) -> Element { mem::replace(&mut (*self)[i], src) } @@ -49,7 +49,7 @@ pub trait Array1: Index + IndexMut+'static, Row: Array1, Element: Copy>: - Index + IndexMut { + Index + IndexMut { /// Get the pointer to the first element of the array. fn ptr<'a>(&'a self) -> &'a Element { &(*self)[0][0] @@ -62,25 +62,25 @@ pub trait Array2+'static, Row: Array1, Element: /// Swap two columns of this array. #[inline] - fn swap_cols(&mut self, a: uint, b: uint) { + fn swap_cols(&mut self, a: usize, b: usize) { unsafe { ptr::swap(&mut (*self)[a], &mut (*self)[b]) }; } /// Replace a column in the array. #[inline] - fn replace_col(&mut self, c: uint, src: Column) -> Column { + fn replace_col(&mut self, c: usize, src: Column) -> Column { mem::replace(&mut (*self)[c], src) } /// Get a row from this array by-value. - fn row(&self, r: uint) -> Row; + fn row(&self, r: usize) -> Row; /// Swap two rows of this array. - fn swap_rows(&mut self, a: uint, b: uint); + fn swap_rows(&mut self, a: usize, b: usize); /// Swap the values at index `a` and `b` #[inline] - fn swap_elems(&mut self, a: (uint, uint), b: (uint, uint)) { + fn swap_elems(&mut self, a: (usize, usize), b: (usize, usize)) { let (ac, ar) = a; let (bc, br) = b; unsafe { ptr::swap(&mut (*self)[ac][ar], &mut (*self)[bc][br]) }; diff --git a/src/matrix.rs b/src/matrix.rs index c259046..d44cb3a 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -531,33 +531,33 @@ impl FixedArray<[[S; 2]; 2]> for Matrix2 { } } -impl Index for Matrix2 { +impl Index for Matrix2 { type Output = Vector2; #[inline] - fn index<'a>(&'a self, i: &uint) -> &'a Vector2 { + fn index<'a>(&'a self, i: &usize) -> &'a Vector2 { FixedArray::from_fixed_ref(&self.as_fixed()[*i]) } } -impl IndexMut for Matrix2 { +impl IndexMut for Matrix2 { type Output = Vector2; #[inline] - fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut Vector2 { + fn index_mut<'a>(&'a mut self, i: &usize) -> &'a mut Vector2 { FixedArray::from_fixed_mut(&mut self.as_mut_fixed()[*i]) } } impl Array2, Vector2, S> for Matrix2 { #[inline] - fn row(&self, r: uint) -> Vector2 { + fn row(&self, r: usize) -> Vector2 { Vector2::new(self[0][r], self[1][r]) } #[inline] - fn swap_rows(&mut self, a: uint, b: uint) { + fn swap_rows(&mut self, a: usize, b: usize) { (&mut self[0]).swap_elems(a, b); (&mut self[1]).swap_elems(a, b); } @@ -615,34 +615,34 @@ impl FixedArray<[[S; 3]; 3]> for Matrix3 { } } -impl Index for Matrix3 { +impl Index for Matrix3 { type Output = Vector3; #[inline] - fn index<'a>(&'a self, i: &uint) -> &'a Vector3 { + fn index<'a>(&'a self, i: &usize) -> &'a Vector3 { FixedArray::from_fixed_ref(&self.as_fixed()[*i]) } } -impl IndexMut for Matrix3 { +impl IndexMut for Matrix3 { type Output = Vector3; #[inline] - fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut Vector3 { + fn index_mut<'a>(&'a mut self, i: &usize) -> &'a mut Vector3 { FixedArray::from_fixed_mut(&mut self.as_mut_fixed()[*i]) } } impl Array2, Vector3, S> for Matrix3 { #[inline] - fn row(&self, r: uint) -> Vector3 { + fn row(&self, r: usize) -> Vector3 { Vector3::new(self[0][r], self[1][r], self[2][r]) } #[inline] - fn swap_rows(&mut self, a: uint, b: uint) { + fn swap_rows(&mut self, a: usize, b: usize) { (&mut self[0]).swap_elems(a, b); (&mut self[1]).swap_elems(a, b); (&mut self[2]).swap_elems(a, b); @@ -704,27 +704,27 @@ impl FixedArray<[[S; 4]; 4]> for Matrix4 { } } -impl Index for Matrix4 { +impl Index for Matrix4 { type Output = Vector4; #[inline] - fn index<'a>(&'a self, i: &uint) -> &'a Vector4 { + fn index<'a>(&'a self, i: &usize) -> &'a Vector4 { FixedArray::from_fixed_ref(&self.as_fixed()[*i]) } } -impl IndexMut for Matrix4 { +impl IndexMut for Matrix4 { type Output = Vector4; #[inline] - fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut Vector4 { + fn index_mut<'a>(&'a mut self, i: &usize) -> &'a mut Vector4 { FixedArray::from_fixed_mut(&mut self.as_mut_fixed()[*i]) } } impl Array2, Vector4, S> for Matrix4 { #[inline] - fn row(&self, r: uint) -> Vector4 { + fn row(&self, r: usize) -> Vector4 { Vector4::new(self[0][r], self[1][r], self[2][r], @@ -732,7 +732,7 @@ impl Array2, Vector4, S> for Matrix4 { } #[inline] - fn swap_rows(&mut self, a: uint, b: uint) { + fn swap_rows(&mut self, a: usize, b: usize) { (&mut self[0]).swap_elems(a, b); (&mut self[1]).swap_elems(a, b); (&mut self[2]).swap_elems(a, b); diff --git a/src/num.rs b/src/num.rs index 41cd46a..b546e37 100644 --- a/src/num.rs +++ b/src/num.rs @@ -35,12 +35,12 @@ macro_rules! partial_ord_int ( ) ); -partial_ord_int!(int); +partial_ord_int!(isize); partial_ord_int!(i8); partial_ord_int!(i16); partial_ord_int!(i32); partial_ord_int!(i64); -partial_ord_int!(uint); +partial_ord_int!(usize); partial_ord_int!(u8); partial_ord_int!(u16); partial_ord_int!(u32); @@ -106,8 +106,8 @@ impl_basenum_int!(u8); impl_basenum_int!(u16); impl_basenum_int!(u32); impl_basenum_int!(u64); -impl_basenum_int!(int); -impl_basenum_int!(uint); +impl_basenum_int!(isize); +impl_basenum_int!(usize); macro_rules! impl_basenum_float ( @@ -150,12 +150,12 @@ impl BaseInt for i8 {} impl BaseInt for i16 {} impl BaseInt for i32 {} impl BaseInt for i64 {} -impl BaseInt for int {} +impl BaseInt for isize {} impl BaseInt for u8 {} impl BaseInt for u16 {} impl BaseInt for u32 {} impl BaseInt for u64 {} -impl BaseInt for uint {} +impl BaseInt for usize {} /// Base floating point types pub trait BaseFloat : BaseNum + Float + ApproxEq {} diff --git a/src/point.rs b/src/point.rs index 1e0744e..9782a36 100644 --- a/src/point.rs +++ b/src/point.rs @@ -135,18 +135,18 @@ impl FixedArray<[S; 2]> for Point2 { } } -impl Index for Point2 { +impl Index for Point2 { type Output = S; #[inline] - fn index<'a>(&'a self, i: &uint) -> &'a S { + fn index<'a>(&'a self, i: &usize) -> &'a S { &self.as_fixed()[*i] } } -impl IndexMut for Point2 { +impl IndexMut for Point2 { type Output = S; #[inline] - fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut S { + fn index_mut<'a>(&'a mut self, i: &usize) -> &'a mut S { &mut self.as_mut_fixed()[*i] } } @@ -291,20 +291,20 @@ impl FixedArray<[S; 3]> for Point3 { } } -impl Index for Point3 { +impl Index for Point3 { type Output = S; #[inline] - fn index<'a>(&'a self, i: &uint) -> &'a S { + fn index<'a>(&'a self, i: &usize) -> &'a S { &self.as_fixed()[*i] } } -impl IndexMut for Point3 { +impl IndexMut for Point3 { type Output = S; #[inline] - fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut S { + fn index_mut<'a>(&'a mut self, i: &usize) -> &'a mut S { &mut self.as_mut_fixed()[*i] } } diff --git a/src/projection.rs b/src/projection.rs index 51bf6a8..7dc9753 100644 --- a/src/projection.rs +++ b/src/projection.rs @@ -79,7 +79,7 @@ pub struct PerspectiveFov { impl> PerspectiveFov { pub fn to_perspective(&self) -> Perspective { - let angle = self.fovy.div_s(cast(2i).unwrap()); + let angle = self.fovy.div_s(cast(2i8).unwrap()); let ymax = self.near * tan(angle.to_rad()); let xmax = ymax * self.aspect; @@ -112,8 +112,8 @@ impl> ToMatrix4 for PerspectiveFov { assert!(self.far > zero(), "The far plane distance cannot be below zero, found: {:?}", self.far); assert!(self.far > self.near, "The far plane cannot be closer than the near plane, found: far: {:?}, near: {:?}", self.far, self.near); - let f = cot(self.fovy.div_s(cast(2i).unwrap()).to_rad()); - let two: S = cast(2i).unwrap(); + let f = cot(self.fovy.div_s(cast(2i8).unwrap()).to_rad()); + let two: S = cast(2i8).unwrap(); let c0r0 = f / self.aspect; let c0r1 = zero(); @@ -163,7 +163,7 @@ impl ToMatrix4 for Perspective { assert!(self.bottom <= self.top, "`bottom` cannot be greater than `top`, found: bottom: {:?} top: {:?}", self.bottom, self.top); assert!(self.near <= self.far, "`near` cannot be greater than `far`, found: near: {:?} far: {:?}", self.near, self.far); - let two: S = cast(2i).unwrap(); + let two: S = cast(2i8).unwrap(); let c0r0 = (two * self.near) / (self.right - self.left); let c0r1 = zero(); @@ -215,7 +215,7 @@ impl Projection for Ortho { impl ToMatrix4 for Ortho { fn to_matrix4(&self) -> Matrix4 { - let two: S = cast(2i).unwrap(); + let two: S = cast(2i8).unwrap(); let c0r0 = two / (self.right - self.left); let c0r1 = zero(); diff --git a/src/quaternion.rs b/src/quaternion.rs index 69c5013..6a2cd2e 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -50,21 +50,21 @@ impl Array1 for Quaternion { } } -impl Index for Quaternion { +impl Index for Quaternion { type Output = S; #[inline] - fn index<'a>(&'a self, i: &uint) -> &'a S { + fn index<'a>(&'a self, i: &usize) -> &'a S { let slice: &[S; 4] = unsafe { mem::transmute(self) }; &slice[*i] } } -impl IndexMut for Quaternion { +impl IndexMut for Quaternion { type Output = S; #[inline] - fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut S { + fn index_mut<'a>(&'a mut self, i: &usize) -> &'a mut S { let slice: &'a mut [S; 4] = unsafe { mem::transmute(self) }; &mut slice[*i] } @@ -112,7 +112,7 @@ impl Quaternion { #[inline] pub fn mul_v(&self, vec: &Vector3) -> Vector3 { let tmp = self.v.cross(vec).add_v(&vec.mul_s(self.s.clone())); - self.v.cross(&tmp).mul_s(cast(2i).unwrap()).add_v(vec) + self.v.cross(&tmp).mul_s(cast(2i8).unwrap()).add_v(vec) } /// The sum of this quaternion and `other` diff --git a/src/vector.rs b/src/vector.rs index 76fa4c2..f04ffc4 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -251,20 +251,20 @@ macro_rules! vec( } } - impl<$S: Copy> Index for $Self<$S> { + impl<$S: Copy> Index for $Self<$S> { type Output = S; #[inline] - fn index<'a>(&'a self, i: &uint) -> &'a $S { + fn index<'a>(&'a self, i: &usize) -> &'a $S { &self.as_fixed()[*i] } } - impl<$S: Copy> IndexMut for $Self<$S> { + impl<$S: Copy> IndexMut for $Self<$S> { type Output = S; #[inline] - fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut $S { + fn index_mut<'a>(&'a mut self, i: &usize) -> &'a mut $S { &mut self.as_mut_fixed()[*i] } } @@ -451,7 +451,7 @@ impl Vector4 { /// Create a `Vector3`, dropping the nth element #[inline] - pub fn truncate_n(&self, n: int)-> Vector3 { + pub fn truncate_n(&self, n: isize)-> Vector3 { match n { 0 => Vector3::new(self.y, self.z, self.w), 1 => Vector3::new(self.x, self.z, self.w),