macro macro
This commit is contained in:
parent
4017f33447
commit
1604888254
@ -20,6 +20,26 @@ macro_rules! impl_matrix {
|
|||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[macro_export(local_inner_macros)]
|
#[macro_export(local_inner_macros)]
|
||||||
|
macro_rules! impl_matrix_shim {
|
||||||
|
(
|
||||||
|
$matrix_info:tt,
|
||||||
|
()
|
||||||
|
) => {
|
||||||
|
$crate::impl_matrix!($matrix_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[macro_export(local_inner_macros)]
|
||||||
|
macro_rules! impl_matrices {
|
||||||
|
(
|
||||||
|
($($matrix_info:tt),+),
|
||||||
|
$vector_infos:tt
|
||||||
|
) => {
|
||||||
|
$crate::macro_repeated!(impl_matrix_shim,(),$($matrix_info),+);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[macro_export(local_inner_macros)]
|
||||||
macro_rules! impl_matrix_inner {
|
macro_rules! impl_matrix_inner {
|
||||||
(
|
(
|
||||||
($struct_outer: ident { $($field_outer: ident), + }, $vector_outer: ident { $($vector_field_outer: ident), + }, $size_outer: expr),
|
($struct_outer: ident { $($field_outer: ident), + }, $vector_outer: ident { $($vector_field_outer: ident), + }, $size_outer: expr),
|
||||||
|
@ -16,19 +16,21 @@ pub struct Matrix4<T> {
|
|||||||
pub w_axis: T,
|
pub w_axis: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
crate::impl_matrix!((Matrix2 { x_axis, y_axis }, Vector2 { x, y }, 2));
|
|
||||||
crate::impl_matrix!((Matrix3 { x_axis, y_axis, z_axis }, Vector3 { x, y, z }, 3));
|
|
||||||
crate::impl_matrix!((Matrix4 { x_axis, y_axis, z_axis, w_axis }, Vector4 { x, y, z, w }, 4));
|
|
||||||
|
|
||||||
crate::impl_extend!(Matrix2 { x_axis, y_axis }, Matrix3, z_axis);
|
crate::impl_extend!(Matrix2 { x_axis, y_axis }, Matrix3, z_axis);
|
||||||
crate::impl_extend!(Matrix3 { x_axis, y_axis, z_axis }, Matrix4, w_axis);
|
crate::impl_extend!(Matrix3 { x_axis, y_axis, z_axis }, Matrix4, w_axis);
|
||||||
|
//TODO: extend vertically
|
||||||
|
|
||||||
crate::impl_matrix_inner!((Matrix2 { x_axis, y_axis }, Vector2 { x, y }, 2), (Vector2 { x, y }, Matrix2 { x_axis, y_axis }, 2) );
|
crate::impl_matrices!(
|
||||||
crate::impl_matrix_inner!((Matrix2 { x_axis, y_axis }, Vector2 { x, y }, 2), (Vector3 { x, y, z }, Matrix3 { x_axis, y_axis, z_axis }, 3) );
|
//outer struct and equivalent vector
|
||||||
crate::impl_matrix_inner!((Matrix2 { x_axis, y_axis }, Vector2 { x, y }, 2), (Vector4 { x, y, z, w }, Matrix4 { x_axis, y_axis, z_axis, w_axis }, 4) );
|
(
|
||||||
crate::impl_matrix_inner!((Matrix3 { x_axis, y_axis, z_axis }, Vector3 { x, y, z }, 3), (Vector2 { x, y }, Matrix2 { x_axis, y_axis }, 2) );
|
(Matrix2 { x_axis, y_axis }, Vector2 { x, y }, 2),
|
||||||
crate::impl_matrix_inner!((Matrix3 { x_axis, y_axis, z_axis }, Vector3 { x, y, z }, 3), (Vector3 { x, y, z }, Matrix3 { x_axis, y_axis, z_axis }, 3) );
|
(Matrix3 { x_axis, y_axis, z_axis }, Vector3 { x, y, z }, 3),
|
||||||
crate::impl_matrix_inner!((Matrix3 { x_axis, y_axis, z_axis }, Vector3 { x, y, z }, 3), (Vector4 { x, y, z, w }, Matrix4 { x_axis, y_axis, z_axis, w_axis }, 4) );
|
(Matrix4 { x_axis, y_axis, z_axis, w_axis }, Vector4 { x, y, z, w }, 4)
|
||||||
crate::impl_matrix_inner!((Matrix4 { x_axis, y_axis, z_axis, w_axis }, Vector4 { x, y, z, w }, 4), (Vector2 { x, y }, Matrix2 { x_axis, y_axis }, 2) );
|
),
|
||||||
crate::impl_matrix_inner!((Matrix4 { x_axis, y_axis, z_axis, w_axis }, Vector4 { x, y, z, w }, 4), (Vector3 { x, y, z }, Matrix3 { x_axis, y_axis, z_axis }, 3) );
|
//inner struct and equivalent matrix
|
||||||
crate::impl_matrix_inner!((Matrix4 { x_axis, y_axis, z_axis, w_axis }, Vector4 { x, y, z, w }, 4), (Vector4 { x, y, z, w }, Matrix4 { x_axis, y_axis, z_axis, w_axis }, 4) );
|
(
|
||||||
|
(Vector2 { x, y }, Matrix2 { x_axis, y_axis }, 2),
|
||||||
|
(Vector3 { x, y, z }, Matrix3 { x_axis, y_axis, z_axis }, 3),
|
||||||
|
(Vector4 { x, y, z, w }, Matrix4 { x_axis, y_axis, z_axis, w_axis }, 4)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user