diff --git a/src/mat.rs b/src/mat.rs index 18b6764..faf50dc 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -586,27 +586,6 @@ impl ApproxEq for Mat2 { } } -macro_rules! mat2_type( - ($name:ident <$T:ty, $V:ty>) => ( - pub mod $name { - use vec::*; - use super::*; - #[inline(always)] pub fn new(c0r0: $T, c0r1: $T, c1r0: $T, c1r1: $T) - -> $name { BaseMat2::new(c0r0, c0r1, c1r0, c1r1) } - #[inline(always)] pub fn from_cols(c0: $V, c1: $V) - -> $name { BaseMat2::from_cols(c0, c1) } - #[inline(always)] pub fn from_value(v: $T) -> $name { BaseMat::from_value(v) } - #[inline(always)] pub fn identity() -> $name { BaseMat::identity() } - #[inline(always)] pub fn zero() -> $name { BaseMat::zero() } - #[inline(always)] pub fn from_angle(radians: $T) -> $name { BaseMat2::from_angle(radians) } - #[inline(always)] pub fn dim() -> uint { 2 } - #[inline(always)] pub fn rows() -> uint { 2 } - #[inline(always)] pub fn cols() -> uint { 2 } - #[inline(always)] pub fn size_of() -> uint { sys::size_of::<$name>() } - } - ) -) - // GLSL-style type aliases, corresponding to Section 4.1.6 of the [GLSL 4.30.6 specification] // (http://www.opengl.org/registry/doc/GLSLangSpec.4.30.6.pdf). @@ -615,18 +594,11 @@ pub type mat2 = Mat2; // a 2×2 double-precision floating-point matrix pub type dmat2 = Mat2; -mat2_type!(mat2) -mat2_type!(dmat2) - // Rust-style type aliases pub type Mat2f = Mat2; pub type Mat2f32 = Mat2; pub type Mat2f64 = Mat2; -mat2_type!(Mat2f) -mat2_type!(Mat2f32) -mat2_type!(Mat2f64) - /// A 3 x 3 column major matrix /// /// # Type parameters @@ -1170,55 +1142,16 @@ impl ApproxEq for Mat3 { } } -macro_rules! mat3_type( - ($name:ident <$T:ty, $V:ty>) => ( - pub mod $name { - use vec::*; - use super::*; - #[inline(always)] pub fn new(c0r0: $T, c0r1: $T, c0r2: $T, - c1r0: $T, c1r1: $T, c1r2: $T, - c2r0: $T, c2r1: $T, c2r2: $T) -> $name { - BaseMat3::new(c0r0, c0r1, c0r2, - c1r0, c1r1, c1r2, - c2r0, c2r1, c2r2) - } - #[inline(always)] pub fn from_cols(c0: $V, c1: $V, c2: $V) - -> $name { BaseMat3::from_cols(c0, c1, c2) } - #[inline(always)] pub fn from_value(v: $T) -> $name { BaseMat::from_value(v) } - #[inline(always)] pub fn identity() -> $name { BaseMat::identity() } - #[inline(always)] pub fn zero() -> $name { BaseMat::zero() } - #[inline(always)] pub fn from_angle_x(radians: $T) -> $name { BaseMat3::from_angle_x(radians) } - #[inline(always)] pub fn from_angle_y(radians: $T) -> $name { BaseMat3::from_angle_y(radians) } - #[inline(always)] pub fn from_angle_z(radians: $T) -> $name { BaseMat3::from_angle_z(radians) } - #[inline(always)] pub fn from_angle_xyz(radians_x: $T, radians_y: $T, radians_z: $T) -> $name { BaseMat3::from_angle_xyz(radians_x, radians_y, radians_z) } - #[inline(always)] pub fn from_angle_axis(radians: $T, axis: &$V) -> $name { BaseMat3::from_angle_axis(radians, axis) } - #[inline(always)] pub fn from_axes(x: $V, y: $V, z: $V) -> $name { BaseMat3::from_axes(x, y, z) } - #[inline(always)] pub fn look_at(dir: &$V, up: &$V) -> $name { BaseMat3::look_at(dir, up) } - #[inline(always)] pub fn dim() -> uint { 3 } - #[inline(always)] pub fn rows() -> uint { 3 } - #[inline(always)] pub fn cols() -> uint { 3 } - #[inline(always)] pub fn size_of() -> uint { sys::size_of::<$name>() } - } - ) -) - // a 3×3 single-precision floating-point matrix pub type mat3 = Mat3; // a 3×3 double-precision floating-point matrix pub type dmat3 = Mat3; -mat3_type!(mat3) -mat3_type!(dmat3) - // Rust-style type aliases pub type Mat3f = Mat3; pub type Mat3f32 = Mat3; pub type Mat3f64 = Mat3; -mat3_type!(Mat3f) -mat3_type!(Mat3f32) -mat3_type!(Mat3f64) - /// A 4 x 4 column major matrix /// /// # Type parameters @@ -1722,33 +1655,6 @@ impl ApproxEq for Mat4 { } } -macro_rules! mat4_type( - ($name:ident <$T:ty, $V:ty>) => ( - pub mod $name { - use vec::*; - use super::*; - #[inline(always)] pub fn new(c0r0: $T, c0r1: $T, c0r2: $T, c0r3: $T, - c1r0: $T, c1r1: $T, c1r2: $T, c1r3: $T, - c2r0: $T, c2r1: $T, c2r2: $T, c2r3: $T, - c3r0: $T, c3r1: $T, c3r2: $T, c3r3: $T) -> $name { - BaseMat4::new(c0r0, c0r1, c0r2, c0r3, - c1r0, c1r1, c1r2, c1r3, - c2r0, c2r1, c2r2, c2r3, - c3r0, c3r1, c3r2, c3r3) - } - #[inline(always)] pub fn from_cols(c0: $V, c1: $V, c2: $V, c3: $V) - -> $name { BaseMat4::from_cols(c0, c1, c2, c3) } - #[inline(always)] pub fn from_value(v: $T) -> $name { BaseMat::from_value(v) } - #[inline(always)] pub fn identity() -> $name { BaseMat::identity() } - #[inline(always)] pub fn zero() -> $name { BaseMat::zero() } - #[inline(always)] pub fn dim() -> uint { 4 } - #[inline(always)] pub fn rows() -> uint { 4 } - #[inline(always)] pub fn cols() -> uint { 4 } - #[inline(always)] pub fn size_of() -> uint { sys::size_of::<$name>() } - } - ) -) - // GLSL-style type aliases, corresponding to Section 4.1.6 of the [GLSL 4.30.6 specification] // (http://www.opengl.org/registry/doc/GLSLangSpec.4.30.6.pdf). @@ -1757,14 +1663,7 @@ pub type mat4 = Mat4; // a 4×4 double-precision floating-point matrix pub type dmat4 = Mat4; -mat4_type!(mat4) -mat4_type!(dmat4) - // Rust-style type aliases pub type Mat4f = Mat4; pub type Mat4f32 = Mat4; pub type Mat4f64 = Mat4; - -mat4_type!(Mat4f) -mat4_type!(Mat4f32) -mat4_type!(Mat4f64) diff --git a/src/quat.rs b/src/quat.rs index 3d87a06..087bb23 100644 --- a/src/quat.rs +++ b/src/quat.rs @@ -360,29 +360,6 @@ impl ApproxEq for Quat { } } -macro_rules! quat_type( - ($name:ident <$T:ty, $V:ty>) => ( - pub mod $name { - use vec::*; - use super::*; - #[inline(always)] pub fn new(w: $T, xi: $T, yj: $T, zk: $T) -> $name { Quat::new(w, xi, yj, zk) } - #[inline(always)] pub fn from_sv(s: $T, v: $V) -> $name { Quat::from_sv(s, v) } - #[inline(always)] pub fn identity() -> $name { Quat::identity() } - #[inline(always)] pub fn zero() -> $name { Quat::zero() } - #[inline(always)] pub fn from_angle_x(radians: $T) -> $name { Quat::from_angle_x(radians) } - #[inline(always)] pub fn from_angle_y(radians: $T) -> $name { Quat::from_angle_y(radians) } - #[inline(always)] pub fn from_angle_z(radians: $T) -> $name { Quat::from_angle_z(radians) } - #[inline(always)] pub fn from_angle_xyz(radians_x: $T, radians_y: $T, radians_z: $T) - -> $name { Quat::from_angle_xyz(radians_x, radians_y, radians_z) } - #[inline(always)] pub fn from_angle_axis(radians: $T, axis: &$V) -> $name { Quat::from_angle_axis(radians, axis) } - #[inline(always)] pub fn from_axes(x: $V, y: $V, z: $V) -> $name { Quat::from_axes(x, y, z) } - #[inline(always)] pub fn look_at(dir: &$V, up: &$V) -> $name { Quat::look_at(dir, up) } - #[inline(always)] pub fn dim() -> uint { 4 } - #[inline(always)] pub fn size_of() -> uint { sys::size_of::<$name>() } - } - ); -) - // GLSL-style type aliases for quaternions. These are not present in the GLSL // specification, but they roughly follow the same nomenclature. @@ -391,14 +368,7 @@ type quat = Quat; /// a double-precision floating-point quaternion type dquat = Quat; -quat_type!(quat) -quat_type!(dquat) - // Rust-style type aliases type Quatf = Quat; type Quatf32 = Quat; type Quatf64 = Quat; - -quat_type!(Quatf) -quat_type!(Quatf32) -quat_type!(Quatf64) diff --git a/src/vec.rs b/src/vec.rs index 12952ba..ab8aec0 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -681,31 +681,6 @@ impl BoolVec for Vec2 { } } -macro_rules! vec2_type( - ($name:ident ) => ( - pub mod $name { - use super::*; - #[inline(always)] pub fn new(x: bool, y: bool) -> $name { BaseVec2::new(x, y) } - #[inline(always)] pub fn from_value(v: bool) -> $name { BaseVec::from_value(v) } - #[inline(always)] pub fn dim() -> uint { 2 } - #[inline(always)] pub fn size_of() -> uint { sys::size_of::<$name>() } - } - ); - ($name:ident <$T:ty>) => ( - pub mod $name { - use super::*; - #[inline(always)] pub fn new(x: $T, y: $T) -> $name { BaseVec2::new(x, y) } - #[inline(always)] pub fn from_value(v: $T) -> $name { BaseVec::from_value(v) } - #[inline(always)] pub fn identity() -> $name { NumVec::identity() } - #[inline(always)] pub fn zero() -> $name { NumVec::zero() } - #[inline(always)] pub fn unit_x() -> $name { NumVec2::unit_x() } - #[inline(always)] pub fn unit_y() -> $name { NumVec2::unit_y() } - #[inline(always)] pub fn dim() -> uint { 2 } - #[inline(always)] pub fn size_of() -> uint { sys::size_of::<$name>() } - } - ); -) - // GLSL-style type aliases, corresponding to Section 4.1.5 of the [GLSL 4.30.6 specification] // (http://www.opengl.org/registry/doc/GLSLangSpec.4.30.6.pdf). @@ -720,12 +695,6 @@ pub type ivec2 = Vec2; // a two-component unsigned integer vector pub type uvec2 = Vec2; -vec2_type!(vec2) -vec2_type!(dvec2) -vec2_type!(bvec2) -vec2_type!(ivec2) -vec2_type!(uvec2) - // Rust-style type aliases pub type Vec2f = Vec2; pub type Vec2f32 = Vec2; @@ -742,21 +711,6 @@ pub type Vec2u32 = Vec2; pub type Vec2u64 = Vec2; pub type Vec2b = Vec2; -vec2_type!(Vec2f) -vec2_type!(Vec2f32) -vec2_type!(Vec2f64) -vec2_type!(Vec2i) -vec2_type!(Vec2i8) -vec2_type!(Vec2i16) -vec2_type!(Vec2i32) -vec2_type!(Vec2i64) -vec2_type!(Vec2u) -vec2_type!(Vec2u8) -vec2_type!(Vec2u16) -vec2_type!(Vec2u32) -vec2_type!(Vec2u64) -vec2_type!(Vec2b) - /// A 3-dimensional vector /// /// # Type parameters @@ -1083,32 +1037,6 @@ impl BoolVec for Vec3 { } } -macro_rules! vec3_type( - ($name:ident ) => ( - pub mod $name { - use super::*; - #[inline(always)] pub fn new(x: bool, y: bool, z: bool) -> $name { BaseVec3::new(x, y, z) } - #[inline(always)] pub fn from_value(v: bool) -> $name { BaseVec::from_value(v) } - #[inline(always)] pub fn dim() -> uint { 3 } - #[inline(always)] pub fn size_of() -> uint { sys::size_of::<$name>() } - } - ); - ($name:ident <$T:ty>) => ( - pub mod $name { - use super::*; - #[inline(always)] pub fn new(x: $T, y: $T, z: $T) -> $name { BaseVec3::new(x, y, z) } - #[inline(always)] pub fn from_value(v: $T) -> $name { BaseVec::from_value(v) } - #[inline(always)] pub fn identity() -> $name { NumVec::identity() } - #[inline(always)] pub fn zero() -> $name { NumVec::zero() } - #[inline(always)] pub fn unit_x() -> $name { NumVec3::unit_x() } - #[inline(always)] pub fn unit_y() -> $name { NumVec3::unit_y() } - #[inline(always)] pub fn unit_z() -> $name { NumVec3::unit_z() } - #[inline(always)] pub fn dim() -> uint { 3 } - #[inline(always)] pub fn size_of() -> uint { sys::size_of::<$name>() } - } - ); -) - // GLSL-style type aliases, corresponding to Section 4.1.5 of the [GLSL 4.30.6 specification] // (http://www.opengl.org/registry/doc/GLSLangSpec.4.30.6.pdf). @@ -1123,12 +1051,6 @@ pub type ivec3 = Vec3; // a three-component unsigned integer vector pub type uvec3 = Vec3; -vec3_type!(vec3) -vec3_type!(dvec3) -vec3_type!(bvec3) -vec3_type!(ivec3) -vec3_type!(uvec3) - // Rust-style type aliases pub type Vec3f = Vec3; pub type Vec3f32 = Vec3; @@ -1145,21 +1067,6 @@ pub type Vec3u32 = Vec3; pub type Vec3u64 = Vec3; pub type Vec3b = Vec3; -vec3_type!(Vec3f) -vec3_type!(Vec3f32) -vec3_type!(Vec3f64) -vec3_type!(Vec3i) -vec3_type!(Vec3i8) -vec3_type!(Vec3i16) -vec3_type!(Vec3i32) -vec3_type!(Vec3i64) -vec3_type!(Vec3u) -vec3_type!(Vec3u8) -vec3_type!(Vec3u16) -vec3_type!(Vec3u32) -vec3_type!(Vec3u64) -vec3_type!(Vec3b) - /// A 4-dimensional vector /// /// # Type parameters @@ -1485,33 +1392,6 @@ impl BoolVec for Vec4 { } } -macro_rules! vec4_type( - ($name:ident ) => ( - pub mod $name { - use super::*; - #[inline(always)] pub fn new(x: bool, y: bool, z: bool, w: bool) -> $name { BaseVec4::new(x, y, z, w) } - #[inline(always)] pub fn from_value(v: bool) -> $name { BaseVec::from_value(v) } - #[inline(always)] pub fn dim() -> uint { 4 } - #[inline(always)] pub fn size_of() -> uint { sys::size_of::<$name>() } - } - ); - ($name:ident <$T:ty>) => ( - pub mod $name { - use super::*; - #[inline(always)] pub fn new(x: $T, y: $T, z: $T, w: $T) -> $name { BaseVec4::new(x, y, z, w) } - #[inline(always)] pub fn from_value(v: $T) -> $name { BaseVec::from_value(v) } - #[inline(always)] pub fn identity() -> $name { NumVec::identity() } - #[inline(always)] pub fn zero() -> $name { NumVec::zero() } - #[inline(always)] pub fn unit_x() -> $name { NumVec4::unit_x() } - #[inline(always)] pub fn unit_y() -> $name { NumVec4::unit_y() } - #[inline(always)] pub fn unit_z() -> $name { NumVec4::unit_z() } - #[inline(always)] pub fn unit_w() -> $name { NumVec4::unit_w() } - #[inline(always)] pub fn dim() -> uint { 4 } - #[inline(always)] pub fn size_of() -> uint { sys::size_of::<$name>() } - } - ); -) - // GLSL-style type aliases, corresponding to Section 4.1.5 of the [GLSL 4.30.6 specification] // (http://www.opengl.org/registry/doc/GLSLangSpec.4.30.6.pdf). @@ -1526,12 +1406,6 @@ pub type ivec4 = Vec4; // a four-component unsigned integer vector pub type uvec4 = Vec4; -vec4_type!(vec4) -vec4_type!(dvec4) -vec4_type!(bvec4) -vec4_type!(ivec4) -vec4_type!(uvec4) - // Rust-style type aliases pub type Vec4f = Vec4; pub type Vec4f32 = Vec4; @@ -1547,18 +1421,3 @@ pub type Vec4u16 = Vec4; pub type Vec4u32 = Vec4; pub type Vec4u64 = Vec4; pub type Vec4b = Vec4; - -vec4_type!(Vec4f) -vec4_type!(Vec4f32) -vec4_type!(Vec4f64) -vec4_type!(Vec4i) -vec4_type!(Vec4i8) -vec4_type!(Vec4i16) -vec4_type!(Vec4i32) -vec4_type!(Vec4i64) -vec4_type!(Vec4u) -vec4_type!(Vec4u8) -vec4_type!(Vec4u16) -vec4_type!(Vec4u32) -vec4_type!(Vec4u64) -vec4_type!(Vec4b)