Skip to content

Commit

Permalink
Create an all_num_versions macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat-Lafon committed Nov 10, 2023
1 parent 76ad2fd commit c323947
Showing 1 changed file with 25 additions and 54 deletions.
79 changes: 25 additions & 54 deletions z3/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ macro_rules! impl_binary_op_bool {
};
}

macro_rules! all_num_versions {
($macro_id:ident, $ty:ty, $($rest:tt)*) => {
$macro_id!($ty, u64, from_u64, $($rest)*);
/* $macro_id!($ty, u32, from_u64, $($rest)*);
$macro_id!($ty, u16, from_u64, $($rest)*);
$macro_id!($ty, u8, from_u64, $($rest)*); */
$macro_id!($ty, i64, from_i64, $($rest)*);
$macro_id!($ty, i32, from_i64, $($rest)*);
$macro_id!($ty, i16, from_i64, $($rest)*);
$macro_id!($ty, i8, from_i64, $($rest)*);
}
}

macro_rules! impl_binary_op {
($ty:ty, $base_trait:ident, $assign_trait:ident, $base_fn:ident, $assign_fn:ident, $function:ident, $construct_constant:ident) => {
impl_binary_op_without_numbers!(
Expand All @@ -190,32 +203,10 @@ macro_rules! impl_binary_op {
$assign_fn,
$function
);
impl_binary_op_assign_number_raw!(
$ty,
u64,
from_u64,
$ty,
$base_trait,
$assign_trait,
$base_fn,
$assign_fn,
$function,
$construct_constant
);
impl_binary_op_number_raw!(
&$ty,
u64,
from_u64,
$ty,
$base_trait,
$base_fn,
$function,
$construct_constant
);
impl_binary_op_assign_number_raw!(

all_num_versions!(
impl_binary_op_assign_number_raw,
$ty,
i64,
from_i64,
$ty,
$base_trait,
$assign_trait,
Expand All @@ -224,10 +215,10 @@ macro_rules! impl_binary_op {
$function,
$construct_constant
);
impl_binary_op_number_raw!(

all_num_versions!(
impl_binary_op_number_raw,
&$ty,
i64,
from_i64,
$ty,
$base_trait,
$base_fn,
Expand Down Expand Up @@ -408,41 +399,21 @@ macro_rules! impl_binary_mult_op {
$base_fn,
$assign_fn
);
impl_binary_mult_op_assign_number_raw!(
$ty,
u64,
from_u64,
$ty,
$base_trait,
$assign_trait,
$base_fn,
$assign_fn,
$construct_constant
);
impl_binary_mult_op_number_raw!(
&$ty,
u64,
from_u64,
$ty,
$base_trait,
$base_fn,
$construct_constant
);
impl_binary_mult_op_assign_number_raw!(

all_num_versions!(
impl_binary_mult_op_assign_number_raw,
$ty,
i64,
from_i64,
$ty,
$base_trait,
$assign_trait,
$base_fn,
$assign_fn,
$construct_constant
);
impl_binary_mult_op_number_raw!(

all_num_versions!(
impl_binary_mult_op_number_raw,
&$ty,
i64,
from_i64,
$ty,
$base_trait,
$base_fn,
Expand Down

0 comments on commit c323947

Please sign in to comment.