Add a Container implementation for every vector.

This commit is contained in:
Sébastien Crozet 2013-09-08 17:26:31 +02:00
parent 57b89b38df
commit 992adb99f0
2 changed files with 18 additions and 0 deletions

View File

@ -45,6 +45,7 @@ vec_cast_impl!(Vec1, x)
indexable_impl!(Vec1, 1)
new_repeat_impl!(Vec1, val, x)
dim_impl!(Vec1, 1)
container_impl!(Vec1)
// (specialized) basis_impl!(Vec1, 1)
add_impl!(Vec1, x)
sub_impl!(Vec1, x)
@ -86,6 +87,7 @@ vec_cast_impl!(Vec2, x, y)
indexable_impl!(Vec2, 2)
new_repeat_impl!(Vec2, val, x, y)
dim_impl!(Vec2, 2)
container_impl!(Vec2)
// (specialized) basis_impl!(Vec2, 1)
add_impl!(Vec2, x, y)
sub_impl!(Vec2, x, y)
@ -129,6 +131,7 @@ vec_cast_impl!(Vec3, x, y, z)
indexable_impl!(Vec3, 3)
new_repeat_impl!(Vec3, val, x, y, z)
dim_impl!(Vec3, 3)
container_impl!(Vec3)
// (specialized) basis_impl!(Vec3, 1)
add_impl!(Vec3, x, y, z)
sub_impl!(Vec3, x, y, z)
@ -181,6 +184,7 @@ vec_cast_impl!(PVec3, x, y, z)
indexable_impl!(PVec3, 3)
new_repeat_impl!(PVec3, val, x, y, z, _unused)
dim_impl!(PVec3, 3)
container_impl!(PVec3)
// (specialized) basis_impl!(PVec3, 1)
add_impl!(PVec3, x, y, z)
sub_impl!(PVec3, x, y, z)
@ -228,6 +232,7 @@ vec_cast_impl!(Vec4, x, y, z, w)
indexable_impl!(Vec4, 4)
new_repeat_impl!(Vec4, val, x, y, z, w)
dim_impl!(Vec4, 4)
container_impl!(Vec4)
basis_impl!(Vec4, 4)
add_impl!(Vec4, x, y, z, w)
sub_impl!(Vec4, x, y, z, w)
@ -275,6 +280,7 @@ vec_cast_impl!(Vec5, x, y, z, w, a)
indexable_impl!(Vec5, 5)
new_repeat_impl!(Vec5, val, x, y, z, w, a)
dim_impl!(Vec5, 5)
container_impl!(Vec5)
basis_impl!(Vec5, 5)
add_impl!(Vec5, x, y, z, w, a)
sub_impl!(Vec5, x, y, z, w, a)
@ -324,6 +330,7 @@ vec_cast_impl!(Vec6, x, y, z, w, a, b)
indexable_impl!(Vec6, 6)
new_repeat_impl!(Vec6, val, x, y, z, w, a, b)
dim_impl!(Vec6, 6)
container_impl!(Vec6)
basis_impl!(Vec6, 6)
add_impl!(Vec6, x, y, z, w, a, b)
sub_impl!(Vec6, x, y, z, w, a, b)

View File

@ -181,6 +181,17 @@ macro_rules! dim_impl(
)
)
macro_rules! container_impl(
($t: ident) => (
impl<N> Container for $t<N> {
#[inline]
fn len(&self) -> uint {
Dim::dim(None::<$t<N>>)
}
}
)
)
macro_rules! basis_impl(
($t: ident, $dim: expr) => (
impl<N: Clone + Num + Algebraic + ApproxEq<N>> Basis for $t<N> {