Fix index operator overloads

This commit is contained in:
Brendan Zabarauskas 2013-03-29 09:14:20 +11:00
parent ce0a6bcd02
commit 1342d52bfa
10 changed files with 18 additions and 18 deletions

View file

@ -380,10 +380,10 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
impl<T:Copy> Index<uint, Vec2<T>> for Mat2<T> {
#[inline(always)]
fn index(&self, i: uint) -> Vec2<T> {
fn index(&self, i: &uint) -> Vec2<T> {
unsafe { do buf_as_slice(
transmute::<*Mat2<T>, *Vec2<T>>(
to_unsafe_ptr(self)), 2) |slice| { slice[i] }
to_unsafe_ptr(self)), 2) |slice| { slice[*i] }
}
}
}

View file

@ -558,10 +558,10 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
impl<T:Copy> Index<uint, Vec3<T>> for Mat3<T> {
#[inline(always)]
fn index(&self, i: uint) -> Vec3<T> {
fn index(&self, i: &uint) -> Vec3<T> {
unsafe { do buf_as_slice(
transmute::<*Mat3<T>, *Vec3<T>>(
to_unsafe_ptr(self)), 3) |slice| { slice[i] }
to_unsafe_ptr(self)), 3) |slice| { slice[*i] }
}
}
}

View file

@ -501,10 +501,10 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
impl<T:Copy> Index<uint, Vec4<T>> for Mat4<T> {
#[inline(always)]
fn index(&self, i: uint) -> Vec4<T> {
fn index(&self, i: &uint) -> Vec4<T> {
unsafe { do buf_as_slice(
transmute::<*Mat4<T>, *Vec4<T>>(
to_unsafe_ptr(self)), 4) |slice| { slice[i] }
to_unsafe_ptr(self)), 4) |slice| { slice[*i] }
}
}
}

View file

@ -392,10 +392,10 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
impl<T:Copy> Index<uint, T> for Quat<T> {
#[inline(always)]
fn index(&self, i: uint) -> T {
fn index(&self, i: &uint) -> T {
unsafe { do buf_as_slice(
transmute::<*Quat<T>, *T>(
to_unsafe_ptr(self)), 4) |slice| { slice[i] }
to_unsafe_ptr(self)), 4) |slice| { slice[*i] }
}
}
}

View file

@ -99,7 +99,7 @@ pub impl Vec4: Index<uint, float> {
fn index(i: uint) -> float {
unsafe { do buf_as_slice(
transmute::<*Vec4, *float>(
to_unsafe_ptr(&self)), 4) |slice| { slice[i] }
to_unsafe_ptr(&self)), 4) |slice| { slice[*i] }
}
}
}
@ -191,7 +191,7 @@ pub impl Mat4: Index<uint, Vec4> {
fn index(i: uint) -> Vec4 {
unsafe { do buf_as_slice(
transmute::<*Mat4, *Vec4>(
to_unsafe_ptr(&self)), 4) |slice| { slice[i] }
to_unsafe_ptr(&self)), 4) |slice| { slice[*i] }
}
}
}

View file

@ -51,7 +51,7 @@ pub impl VecBufSlice: Index<uint, float> {
fn index(i: uint) -> float unsafe {
do vec::raw::buf_as_slice(
transmute::<*VecBufSlice, *float>(
to_unsafe_ptr(&self)), 4) |slice| { slice[i] }
to_unsafe_ptr(&self)), 4) |slice| { slice[*i] }
}
}

View file

@ -28,7 +28,7 @@ pub impl<T:Copy Num> Vec4<T> {
fn index(i: uint) -> T {
unsafe { do buf_as_slice(
transmute::<*Vec4<T>, *T>(
to_unsafe_ptr(&self)), 4) |slice| { slice[i] }
to_unsafe_ptr(&self)), 4) |slice| { slice[*i] }
}
}

View file

@ -68,8 +68,8 @@ impl<T> Vector2<T> for Vec2<T> {
impl<T:Copy + Eq> Index<uint, T> for Vec2<T> {
#[inline(always)]
fn index(&self, i: uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 2) |slice| { slice[i] } }
fn index(&self, i: &uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 2) |slice| { slice[*i] } }
}
}

View file

@ -70,8 +70,8 @@ impl<T> Vector3<T> for Vec3<T> {
impl<T:Copy + Eq> Index<uint, T> for Vec3<T> {
#[inline(always)]
fn index(&self, i: uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[i] } }
fn index(&self, i: &uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[*i] } }
}
}

View file

@ -68,8 +68,8 @@ impl<T> Vector4<T> for Vec4<T> {
impl<T:Copy + Eq> Index<uint, T> for Vec4<T> {
#[inline(always)]
fn index(&self, i: uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[i] } }
fn index(&self, i: &uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[*i] } }
}
}