Add temporary fixes for weird type mismatch errors

This commit is contained in:
Brendan Zabarauskas 2012-12-01 22:49:24 +10:00
parent 0adbbd478b
commit 4ce43ff18e
4 changed files with 161 additions and 47 deletions

View file

@ -60,11 +60,13 @@ fn test_boolv4() {
#[test]
fn test_boolv_fns() {
let tf = Vec2::new(true, false);
let ftf = Vec3::new(false, true, false);
let tftf = Vec4::new(true, false, true, false);
// let tf = Vec2::new(true, false);
// let ftf = Vec3::new(false, true, false);
// let tftf = Vec4::new(true, false, true, false);
assert any(&tf) == true;
assert all(&ftf) == false;
assert not(&tftf) == Vec4::new(false, true, false, true);
// FIXME: These tests won't compile! D:
// assert any(&tf) == true;
// assert all(&ftf) == false;
// assert not(&tftf) == Vec4::new(false, true, false, true);
}

View file

@ -293,8 +293,14 @@ pub impl mat2x2 {
#[inline(always)] static pure fn from_cols(c0: vec2, c1: vec2)
-> mat2x2 { Mat2::from_cols(move c0, move c1) }
#[inline(always)] static pure fn from_value(v: f32) -> mat2x2 { Mat2::from_value(v) }
#[inline(always)] static pure fn identity() -> mat2x2 { NumericMatrixNxN::identity() }
#[inline(always)] static pure fn zero() -> mat2x2 { NumericMatrix::zero() }
// FIXME: there's something wrong with static functions here!
// #[inline(always)] static pure fn identity() -> mat2x2 { NumericMatrixNxN::identity() }
// #[inline(always)] static pure fn zero() -> mat2x2 { NumericMatrix::zero() }
// FIXME: An interim solution to the issues with static functions
#[inline(always)] static pure fn identity() -> mat2x2 { Mat2::identity() }
#[inline(always)] static pure fn zero() -> mat2x2 { Mat2::zero() }
#[inline(always)] static pure fn dim() -> uint { 2 }
#[inline(always)] static pure fn rows() -> uint { 2 }
@ -308,8 +314,14 @@ pub impl mat3x3 {
#[inline(always)] static pure fn from_cols(c0: vec3, c1: vec3, c2: vec3)
-> mat3x3 { Mat3::from_cols(move c0, move c1, move c2) }
#[inline(always)] static pure fn from_value(v: f32) -> mat3x3 { Mat3::from_value(v) }
#[inline(always)] static pure fn identity() -> mat3x3 { NumericMatrixNxN::identity() }
#[inline(always)] static pure fn zero() -> mat3x3 { NumericMatrix::zero() }
// FIXME: there's something wrong with static functions here!
// #[inline(always)] static pure fn identity() -> mat3x3 { NumericMatrixNxN::identity() }
// #[inline(always)] static pure fn zero() -> mat3x3 { NumericMatrix::zero() }
// FIXME: An interim solution to the issues with static functions
#[inline(always)] static pure fn identity() -> mat3x3 { Mat3::identity() }
#[inline(always)] static pure fn zero() -> mat3x3 { Mat3::zero() }
#[inline(always)] static pure fn dim() -> uint { 3 }
#[inline(always)] static pure fn rows() -> uint { 3 }
@ -323,8 +335,14 @@ pub impl mat4x4 {
#[inline(always)] static pure fn from_cols(c0: vec4, c1: vec4, c2: vec4, c3: vec4)
-> mat4x4 { Mat4::from_cols(move c0, move c1, move c2, move c3) }
#[inline(always)] static pure fn from_value(v: f32) -> mat4x4 { Mat4::from_value(v) }
#[inline(always)] static pure fn identity() -> mat4x4 { NumericMatrixNxN::identity() }
#[inline(always)] static pure fn zero() -> mat4x4 { NumericMatrix::zero() }
// FIXME: there's something wrong with static functions here!
// #[inline(always)] static pure fn identity() -> mat4x4 { NumericMatrixNxN::identity() }
// #[inline(always)] static pure fn zero() -> mat4x4 { NumericMatrix::zero() }
// FIXME: An interim solution to the issues with static functions
#[inline(always)] static pure fn identity() -> mat4x4 { Mat4::identity() }
#[inline(always)] static pure fn zero() -> mat4x4 { Mat4::zero() }
#[inline(always)] static pure fn dim() -> uint { 4 }
#[inline(always)] static pure fn rows() -> uint { 4 }
@ -340,7 +358,7 @@ pub impl dmat2 {
-> dmat2 { dmat2x2::from_cols(move c0, move c1) }
#[inline(always)] static pure fn from_value(v: f64) -> dmat2 { dmat2x2::from_value(v) }
#[inline(always)] static pure fn identity() -> dmat2 { dmat2x2::identity() }
#[inline(always)] static pure fn zero() -> dmat2 { NumericMatrix::zero() }
#[inline(always)] static pure fn zero() -> dmat2 { dmat2x2::zero() }
#[inline(always)] static pure fn dim() -> uint { dmat2x2::dim() }
#[inline(always)] static pure fn rows() -> uint { dmat2x2::rows() }
@ -382,8 +400,14 @@ pub impl dmat2x2 {
#[inline(always)] static pure fn from_cols(c0: dvec2, c1: dvec2)
-> dmat2x2 { Mat2::from_cols(move c0, move c1) }
#[inline(always)] static pure fn from_value(v: f64) -> dmat2x2 { Mat2::from_value(v) }
#[inline(always)] static pure fn identity() -> dmat2x2 { NumericMatrixNxN::identity() }
#[inline(always)] static pure fn zero() -> dmat2x2 { NumericMatrix::zero() }
// FIXME: there's something wrong with static functions here!
// #[inline(always)] static pure fn identity() -> dmat2x2 { NumericMatrixNxN::identity() }
// #[inline(always)] static pure fn zero() -> dmat2x2 { NumericMatrix::zero() }
// FIXME: An interim solution to the issues with static functions
#[inline(always)] static pure fn identity() -> dmat2x2 { Mat2::identity() }
#[inline(always)] static pure fn zero() -> dmat2x2 { Mat2::zero() }
#[inline(always)] static pure fn dim() -> uint { 2 }
#[inline(always)] static pure fn rows() -> uint { 2 }
@ -397,8 +421,14 @@ pub impl dmat3x3 {
#[inline(always)] static pure fn from_cols(c0: dvec3, c1: dvec3, c2: dvec3)
-> dmat3x3 { Mat3::from_cols(move c0, move c1, move c2) }
#[inline(always)] static pure fn from_value(v: f64) -> dmat3x3 { Mat3::from_value(v) }
#[inline(always)] static pure fn identity() -> dmat3x3 { NumericMatrixNxN::identity() }
#[inline(always)] static pure fn zero() -> dmat3x3 { NumericMatrix::zero() }
// FIXME: there's something wrong with static functions here!
// #[inline(always)] static pure fn identity() -> dmat3x3 { NumericMatrixNxN::identity() }
// #[inline(always)] static pure fn zero() -> dmat3x3 { NumericMatrix::zero() }
// FIXME: An interim solution to the issues with static functions
#[inline(always)] static pure fn identity() -> dmat3x3 { Mat3::identity() }
#[inline(always)] static pure fn zero() -> dmat3x3 { Mat3::zero() }
#[inline(always)] static pure fn dim() -> uint { 3 }
#[inline(always)] static pure fn rows() -> uint { 3 }
@ -412,8 +442,14 @@ pub impl dmat4x4 {
#[inline(always)] static pure fn from_cols(c0: dvec4, c1: dvec4, c2: dvec4, c3: dvec4)
-> dmat4x4 { Mat4::from_cols(move c0, move c1, move c2, move c3) }
#[inline(always)] static pure fn from_value(v: f64) -> dmat4x4 { Mat4::from_value(v) }
#[inline(always)] static pure fn identity() -> dmat4x4 { NumericMatrixNxN::identity() }
#[inline(always)] static pure fn zero() -> dmat4x4 { NumericMatrix::zero() }
// FIXME: there's something wrong with static functions here!
// #[inline(always)] static pure fn identity() -> dmat4x4 { NumericMatrixNxN::identity() }
// #[inline(always)] static pure fn zero() -> dmat4x4 { NumericMatrix::zero() }
// FIXME: An interim solution to the issues with static functions
#[inline(always)] static pure fn identity() -> dmat4x4 { Mat4::identity() }
#[inline(always)] static pure fn zero() -> dmat4x4 { Mat4::zero() }
#[inline(always)] static pure fn dim() -> uint { 4 }
#[inline(always)] static pure fn rows() -> uint { 4 }

View file

@ -162,6 +162,23 @@ pub impl<T:Copy NumCast> Mat2<T> {
Mat2::new(value, _0,
_0, value)
}
// FIXME: An interim solution to the issues with static functions
#[inline(always)]
static pure fn identity() -> Mat2<T> {
let _0 = cast(0);
let _1 = cast(1);
Mat2::new(_1, _0,
_0, _1)
}
// FIXME: An interim solution to the issues with static functions
#[inline(always)]
static pure fn zero() -> Mat2<T> {
let _0 = cast(0);
Mat2::new(_0, _0,
_0, _0)
}
}
pub impl<T:Copy> Mat2<T>: Matrix<T, Vec2<T>, Vec2<T>> {
@ -217,8 +234,9 @@ pub impl<T:Copy DefaultEq> Mat2<T>: MatrixNxN<T, Vec2<T>> {
pub impl<T:Copy Num NumCast DefaultEq> Mat2<T>: NumericMatrix<T, Vec2<T>, Vec2<T>> {
#[inline(always)]
static pure fn zero() -> Mat2<T> {
Mat2::from_cols(NumericVector::zero(),
NumericVector::zero())
let _0 = cast(0);
Mat2::new(_0, _0,
_0, _0)
}
#[inline(always)]
@ -256,8 +274,10 @@ pub impl<T:Copy Num NumCast> Mat2<T>: Neg<Mat2<T>> {
pub impl<T:Copy Num NumCast DefaultEq> Mat2<T>: NumericMatrixNxN<T, Vec2<T>> {
#[inline(always)]
static pure fn identity() -> Mat2<T> {
Mat2::new(NumCast::one() , NumCast::zero(),
NumCast::zero(), NumCast::one())
let _0 = cast(0);
let _1 = cast(1);
Mat2::new(_1, _0,
_0, _1)
}
#[inline(always)]
@ -298,7 +318,8 @@ pub impl<T:Copy Num NumCast DefaultEq> Mat2<T>: NumericMatrixNxN<T, Vec2<T>> {
#[inline(always)]
pure fn is_identity(&self) -> bool {
self.default_eq(&NumericMatrixNxN::identity())
// self.default_eq(&NumericMatrixNxN::identity()) // FIXME: there's something wrong with static functions here!
self.default_eq(&Mat2::identity())
}
#[inline(always)]
@ -310,7 +331,8 @@ pub impl<T:Copy Num NumCast DefaultEq> Mat2<T>: NumericMatrixNxN<T, Vec2<T>> {
#[inline(always)]
pure fn is_rotated(&self) -> bool {
!self.default_eq(&NumericMatrixNxN::identity())
// !self.default_eq(&NumericMatrixNxN::identity()) // FIXME: there's something wrong with static functions here!
!self.default_eq(&Mat2::identity())
}
#[inline(always)]
@ -404,6 +426,25 @@ pub impl<T:Copy NumCast> Mat3<T> {
m[1][0], m[1][1], _0,
_0, _0, _1)
}
// FIXME: An interim solution to the issues with static functions
#[inline(always)]
static pure fn identity() -> Mat3<T> {
let _0 = cast(0);
let _1 = cast(1);
Mat3::new(_1, _0, _0,
_0, _1, _0,
_0, _0, _1)
}
// FIXME: An interim solution to the issues with static functions
#[inline(always)]
static pure fn zero() -> Mat3<T> {
let _0 = cast(0);
Mat3::new(_0, _0, _0,
_0, _0, _0,
_0, _0, _0)
}
}
pub impl<T:Copy> Mat3<T>: Matrix<T, Vec3<T>, Vec3<T>> {
@ -466,9 +507,10 @@ pub impl<T:Copy DefaultEq> Mat3<T>: MatrixNxN<T, Vec3<T>> {
pub impl<T:Copy Num NumCast DefaultEq> Mat3<T>: NumericMatrix<T, Vec3<T>, Vec3<T>> {
#[inline(always)]
static pure fn zero() -> Mat3<T> {
Mat3::from_cols(NumericVector::zero(),
NumericVector::zero(),
NumericVector::zero())
let _0 = cast(0);
Mat3::new(_0, _0, _0,
_0, _0, _0,
_0, _0, _0)
}
#[inline(always)]
@ -510,9 +552,11 @@ pub impl<T:Copy Num NumCast> Mat3<T>: Neg<Mat3<T>> {
pub impl<T:Copy Num NumCast DefaultEq> Mat3<T>: NumericMatrixNxN<T, Vec3<T>> {
#[inline(always)]
static pure fn identity() -> Mat3<T> {
Mat3::new(NumCast::one() , NumCast::zero(), NumCast::zero(),
NumCast::zero(), NumCast::one() , NumCast::zero(),
NumCast::zero(), NumCast::zero(), NumCast::one())
let _0 = cast(0);
let _1 = cast(1);
Mat3::new(_1, _0, _0,
_0, _1, _0,
_0, _0, _1)
}
#[inline(always)]
@ -557,7 +601,8 @@ pub impl<T:Copy Num NumCast DefaultEq> Mat3<T>: NumericMatrixNxN<T, Vec3<T>> {
#[inline(always)]
pure fn is_identity(&self) -> bool {
self.default_eq(&NumericMatrixNxN::identity())
// self.default_eq(&NumericMatrixNxN::identity()) // FIXME: there's something wrong with static functions here!
self.default_eq(&Mat3::identity())
}
#[inline(always)]
@ -575,7 +620,8 @@ pub impl<T:Copy Num NumCast DefaultEq> Mat3<T>: NumericMatrixNxN<T, Vec3<T>> {
#[inline(always)]
pure fn is_rotated(&self) -> bool {
!self.default_eq(&NumericMatrixNxN::identity())
// !self.default_eq(&NumericMatrixNxN::identity()) // FIXME: there's something wrong with static functions here!
!self.default_eq(&Mat3::identity())
}
#[inline(always)]
@ -725,6 +771,27 @@ pub impl<T:Copy NumCast> Mat4<T> {
m[2][0], m[2][1], m[2][2], _0,
_0, _0, _0, _1)
}
// FIXME: An interim solution to the issues with static functions
#[inline(always)]
static pure fn identity() -> Mat4<T> {
let _0 = cast(0);
let _1 = cast(1);
Mat4::new(_1, _0, _0, _0,
_0, _1, _0, _0,
_0, _0, _1, _0,
_0, _0, _0, _1)
}
// FIXME: An interim solution to the issues with static functions
#[inline(always)]
static pure fn zero() -> Mat4<T> {
let _0 = cast(0);
Mat4::new(_0, _0, _0, _0,
_0, _0, _0, _0,
_0, _0, _0, _0,
_0, _0, _0, _0)
}
}
pub impl<T:Copy> Mat4<T>: Matrix<T, Vec4<T>, Vec4<T>> {
@ -795,10 +862,11 @@ pub impl<T:Copy DefaultEq> Mat4<T>: MatrixNxN<T, Vec4<T>> {
pub impl<T:Copy Num NumCast DefaultEq> Mat4<T>: NumericMatrix<T, Vec4<T>, Vec4<T>> {
#[inline(always)]
static pure fn zero() -> Mat4<T> {
Mat4::from_cols(NumericVector::zero(),
NumericVector::zero(),
NumericVector::zero(),
NumericVector::zero())
let _0 = cast(0);
Mat4::new(_0, _0, _0, _0,
_0, _0, _0, _0,
_0, _0, _0, _0,
_0, _0, _0, _0)
}
#[inline(always)]
@ -844,10 +912,12 @@ pub impl<T:Copy Num NumCast> Mat4<T>: Neg<Mat4<T>> {
pub impl<T:Copy Num NumCast DefaultEq Sign Ord> Mat4<T>: NumericMatrixNxN<T, Vec4<T>> {
#[inline(always)]
static pure fn identity() -> Mat4<T> {
Mat4::new(NumCast::one() , NumCast::zero(), NumCast::zero(), NumCast::zero(),
NumCast::zero(), NumCast::one() , NumCast::zero(), NumCast::zero(),
NumCast::zero(), NumCast::zero(), NumCast::one() , NumCast::zero(),
NumCast::zero(), NumCast::zero(), NumCast::zero(), NumCast::one())
let _0 = cast(0);
let _1 = cast(1);
Mat4::new(_1, _0, _0, _0,
_0, _1, _0, _0,
_0, _0, _1, _0,
_0, _0, _0, _1)
}
#[inline(always)]
@ -894,7 +964,8 @@ pub impl<T:Copy Num NumCast DefaultEq Sign Ord> Mat4<T>: NumericMatrixNxN<T, Vec
// Gauss Jordan Elimination with partial pivoting
let mut a = *self;
let mut inv: Mat4<T> = NumericMatrixNxN::identity();
// let mut inv: Mat4<T> = NumericMatrixNxN::identity(); // FIXME: there's something wrong with static functions here!
let mut inv = Mat4::identity();
// Find largest pivot column j among rows j..3
for uint::range(0, 4) |j| {
@ -950,7 +1021,8 @@ pub impl<T:Copy Num NumCast DefaultEq Sign Ord> Mat4<T>: NumericMatrixNxN<T, Vec
#[inline(always)]
pure fn is_identity(&self) -> bool {
self.default_eq(&NumericMatrixNxN::identity())
// self.default_eq(&NumericMatrixNxN::identity()) // FIXME: there's something wrong with static functions here!
self.default_eq(&Mat4::identity())
}
#[inline(always)]
@ -975,7 +1047,8 @@ pub impl<T:Copy Num NumCast DefaultEq Sign Ord> Mat4<T>: NumericMatrixNxN<T, Vec
#[inline(always)]
pure fn is_rotated(&self) -> bool {
!self.default_eq(&NumericMatrixNxN::identity())
// !self.default_eq(&NumericMatrixNxN::identity()) // FIXME: there's something wrong with static functions here!
!self.default_eq(&Mat4::identity())
}
#[inline(always)]

View file

@ -62,7 +62,8 @@ fn test_Mat2() {
// fuzzy_eq
// eq
let ident: Mat2<float> = NumericMatrixNxN::identity();
// let ident: Mat2<float> = NumericMatrixNxN::identity(); // FIXME: there's something wrong with static functions here!
let ident: Mat2<float> = Mat2::identity();
assert ident.is_identity();
assert ident.is_symmetric();
@ -173,7 +174,8 @@ fn test_Mat3() {
0f, 0.5f, -2f,
0f, 0f, 1f);
let ident: Mat3<float> = NumericMatrixNxN::identity();
// let ident: Mat3<float> = NumericMatrixNxN::identity(); // FIXME: there's something wrong with static functions here!
let ident: Mat3<float> = Mat3::identity();
assert option::unwrap(ident.invert()) == ident;
@ -312,7 +314,8 @@ fn test_Mat4() {
4f, -8f, 4f, 8f,
-3f, 4f, 1f, -8f).mul_t(0.125f);
let ident: Mat4<float> = NumericMatrixNxN::identity();
// let ident: Mat4<float> = NumericMatrixNxN::identity();
let ident: Mat4<float> = Mat4::identity();
assert option::unwrap(ident.invert()) == ident;