#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default)]
pub struct Scalar;
-impl Context for Scalar {
- type Bool = bool;
+macro_rules! impl_context {
+ (
+ impl Context for Scalar {
+ $(type $name:ident = $ty:ty;)*
+ #[vec]
+ $(type $vec_name:ident = $vec_ty:ty;)*
+ }
+ ) => {
+ impl Context for Scalar {
+ $(type $name = $ty;)*
+ $(type $vec_name = $vec_ty;)*
+ }
+
+ $(
+ impl Make for $ty {
+ type Prim = $ty;
+ type Context = Scalar;
+ fn ctx(self) -> Self::Context {
+ Scalar
+ }
+ fn make(_ctx: Self::Context, v: Self::Prim) -> Self {
+ v
+ }
+ }
+ )*
+ };
+}
- type U8 = u8;
+impl_context! {
+ impl Context for Scalar {
+ type Bool = bool;
- type I8 = i8;
+ type U8 = u8;
- type U16 = u16;
+ type I8 = i8;
- type I16 = i16;
+ type U16 = u16;
- type F16 = crate::f16::F16;
+ type I16 = i16;
- type U32 = u32;
+ type F16 = crate::f16::F16;
- type I32 = i32;
+ type U32 = u32;
- type F32 = f32;
+ type I32 = i32;
- type U64 = u64;
+ type F32 = f32;
- type I64 = i64;
+ type U64 = u64;
- type F64 = f64;
+ type I64 = i64;
- type VecBool = bool;
+ type F64 = f64;
- type VecU8 = u8;
+ #[vec]
- type VecI8 = i8;
+ type VecBool = bool;
- type VecU16 = u16;
+ type VecU8 = u8;
- type VecI16 = i16;
+ type VecI8 = i8;
- type VecF16 = crate::f16::F16;
+ type VecU16 = u16;
- type VecU32 = u32;
+ type VecI16 = i16;
- type VecI32 = i32;
+ type VecF16 = crate::f16::F16;
- type VecF32 = f32;
+ type VecU32 = u32;
- type VecU64 = u64;
+ type VecI32 = i32;
- type VecI64 = i64;
+ type VecF32 = f32;
- type VecF64 = f64;
-}
+ type VecU64 = u64;
-impl<T> Make<Scalar> for T {
- type Prim = T;
+ type VecI64 = i64;
- fn make(_ctx: Scalar, v: Self::Prim) -> Self {
- v
+ type VecF64 = f64;
}
}