|
1 | 1 | use std::mem::size_of;
|
2 | 2 | use std::os::raw::{c_int, c_long, c_longlong, c_short, c_uint, c_ulong, c_ulonglong, c_ushort};
|
3 | 3 |
|
4 |
| -use cfg_if::cfg_if; |
5 | 4 | use num_traits::{Bounded, Zero};
|
6 | 5 | use pyo3::{ffi, prelude::*, pyobject_native_type_core, types::PyType, AsPyPointer, PyNativeType};
|
7 | 6 |
|
@@ -219,36 +218,26 @@ macro_rules! impl_element_scalar {
|
219 | 218 | }
|
220 | 219 | }
|
221 | 220 | };
|
222 |
| - ($ty:ty, $npy_type:ident $(,#[$meta:meta])*) => { |
| 221 | + ($ty:ty => $npy_type:ident $(,#[$meta:meta])*) => { |
223 | 222 | impl_element_scalar!(@impl: $ty, NPY_TYPES::$npy_type $(,#[$meta])*);
|
224 | 223 | };
|
225 |
| - ($ty:ty $(,#[$meta:meta])*) => { |
226 |
| - impl_element_scalar!(@impl: $ty, npy_int_type::<$ty>() $(,#[$meta])*); |
| 224 | + ($($tys:ty),+) => { |
| 225 | + $(impl_element_scalar!(@impl: $tys, npy_int_type::<$tys>());)+ |
227 | 226 | };
|
228 | 227 | }
|
229 | 228 |
|
230 |
| -impl_element_scalar!(bool, NPY_BOOL); |
231 |
| -impl_element_scalar!(i8); |
232 |
| -impl_element_scalar!(i16); |
233 |
| -impl_element_scalar!(i32); |
234 |
| -impl_element_scalar!(i64); |
235 |
| -impl_element_scalar!(u8); |
236 |
| -impl_element_scalar!(u16); |
237 |
| -impl_element_scalar!(u32); |
238 |
| -impl_element_scalar!(u64); |
239 |
| -impl_element_scalar!(f32, NPY_FLOAT); |
240 |
| -impl_element_scalar!(f64, NPY_DOUBLE); |
241 |
| -impl_element_scalar!(Complex32, NPY_CFLOAT, |
| 229 | +impl_element_scalar!(bool => NPY_BOOL); |
| 230 | +impl_element_scalar!(i8, i16, i32, i64); |
| 231 | +impl_element_scalar!(u8, u16, u32, u64); |
| 232 | +impl_element_scalar!(f32 => NPY_FLOAT); |
| 233 | +impl_element_scalar!(f64 => NPY_DOUBLE); |
| 234 | +impl_element_scalar!(Complex32 => NPY_CFLOAT, |
242 | 235 | #[doc = "Complex type with `f32` components which maps to `np.csingle` (`np.complex64`)."]);
|
243 |
| -impl_element_scalar!(Complex64, NPY_CDOUBLE, |
| 236 | +impl_element_scalar!(Complex64 => NPY_CDOUBLE, |
244 | 237 | #[doc = "Complex type with `f64` components which maps to `np.cdouble` (`np.complex128`)."]);
|
245 | 238 |
|
246 |
| -cfg_if! { |
247 |
| - if #[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] { |
248 |
| - impl_element_scalar!(usize); |
249 |
| - impl_element_scalar!(isize); |
250 |
| - } |
251 |
| -} |
| 239 | +#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] |
| 240 | +impl_element_scalar!(usize, isize); |
252 | 241 |
|
253 | 242 | unsafe impl Element for PyObject {
|
254 | 243 | const IS_COPY: bool = false;
|
|
0 commit comments