MACRO MACRO MACRO

This commit is contained in:
Quaternions 2024-09-02 18:35:37 -07:00
parent 83434a89c7
commit a6dc0c37ba

View File

@ -1,7 +1,7 @@
#[doc(hidden)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export(local_inner_macros)]
macro_rules! impl_wide_vector_operations_const { macro_rules! impl_wide_vector_operations_2arg_not_const_generic {
( $lhs:expr, $rhs:expr, ($struct: ident { $($field: ident), + }, $size: expr) ) => { ( ($lhs:expr, $rhs:expr), ($struct: ident { $($field: ident), + }, $size: expr) ) => {
impl $struct<fixed_wide::fixed::Fixed<{$lhs},{$lhs*32}>>{ impl $struct<fixed_wide::fixed::Fixed<{$lhs},{$lhs*32}>>{
paste::item!{ paste::item!{
#[inline] #[inline]
@ -18,16 +18,22 @@ macro_rules! impl_wide_vector_operations_const {
} }
} }
} }
/* }
impl<U:std::ops::Add<Output=U>,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> $struct<T> { }
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! impl_wide_vector_operations_1arg_not_const_generic {
( $n:expr, ($struct: ident { $($field: ident), + }, $size: expr) ) => {
impl $struct<fixed_wide::fixed::Fixed<{$n},{$n*32}>>{
paste::item!{
#[inline] #[inline]
pub fn wide_length_squared(&self) -> U { pub fn wide_length_squared(&self)->fixed_wide::fixed::Fixed<{$n*2},{$n*2*32}>{
$crate::sum_repeating!( $crate::sum_repeating!(
$( + self.$field.wide_mul(self.$field) ) + $( + self.$field.[<wide_mul_ $n _ $n>](self.$field) ) +
) )
} }
} }
*/ }
}; };
} }
#[doc(hidden)] #[doc(hidden)]
@ -36,10 +42,10 @@ macro_rules! do_macro_repeated{
( (
$macro:ident, $macro:ident,
$any:tt, $any:tt,
$(($x:expr, $y:expr)),* $($repeated:tt),*
)=>{ )=>{
$( $(
$crate::$macro!($x, $y, $any); $crate::$macro!($repeated, $any);
)* )*
}; };
} }
@ -64,11 +70,23 @@ macro_rules! do_macro_8x8{
}; };
} }
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! do_macro_8{
(
$macro:ident,
$any:tt
)=>{
$crate::do_macro_repeated!($macro, $any, 1,2,3,4,5,6,7,8);
};
}
#[doc(hidden)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export(local_inner_macros)]
macro_rules! impl_wide_vector_operations { macro_rules! impl_wide_vector_operations {
( $struct: ident { $($field: ident), + }, $size: expr ) => { ( $struct: ident { $($field: ident), + }, $size: expr ) => {
$crate::do_macro_8x8!(impl_wide_vector_operations_const,($struct { $($field), + }, $size)); $crate::do_macro_8!(impl_wide_vector_operations_1arg_not_const_generic,($struct { $($field), + }, $size));
$crate::do_macro_8x8!(impl_wide_vector_operations_2arg_not_const_generic,($struct { $($field), + }, $size));
}; };
} }