|
2 | 2 | //! |
3 | 3 | //! https://docs.scipy.org/doc/numpy/reference/c-api.array.html |
4 | 4 |
|
5 | | -use std::os::raw::*; |
6 | | -use std::ptr::null_mut; |
7 | 5 | use libc::FILE; |
8 | 6 | use std::ops::Deref; |
| 7 | +use std::os::raw::*; |
| 8 | +use std::ptr::null_mut; |
9 | 9 |
|
| 10 | +use cpython::{ObjectProtocol, PyModule, PyResult, Python, PythonObject}; |
10 | 11 | use pyffi; |
11 | 12 | use pyffi::{PyObject, PyTypeObject}; |
12 | | -use cpython::{Python, PythonObject, ObjectProtocol, PyResult, PyModule}; |
13 | 13 |
|
14 | 14 | use npyffi::*; |
15 | 15 |
|
@@ -48,8 +48,8 @@ impl PyArrayModule { |
48 | 48 | let numpy = py.import("numpy.core.multiarray")?; |
49 | 49 | let c_api = numpy.as_object().getattr(py, "_ARRAY_API")?; |
50 | 50 | let api = unsafe { |
51 | | - pyffi::PyCapsule_GetPointer(c_api.as_object().as_ptr(), null_mut()) as |
52 | | - *const *const c_void |
| 51 | + pyffi::PyCapsule_GetPointer(c_api.as_object().as_ptr(), null_mut()) |
| 52 | + as *const *const c_void |
53 | 53 | }; |
54 | 54 | Ok(Self { |
55 | 55 | numpy: numpy, |
@@ -331,45 +331,47 @@ impl PyArrayModule { |
331 | 331 | } |
332 | 332 | }} // impl_array_type!; |
333 | 333 |
|
334 | | -impl_array_type!((1, PyBigArray_Type), |
335 | | - (2, PyArray_Type), |
336 | | - (3, PyArrayDescr_Type), |
337 | | - (4, PyArrayFlags_Type), |
338 | | - (5, PyArrayIter_Type), |
339 | | - (6, PyArrayMultiIter_Type), |
340 | | - (7, NPY_NUMUSERTYPES), |
341 | | - (8, PyBoolArrType_Type), |
342 | | - (9, _PyArrayScalar_BoolValues), |
343 | | - (10, PyGenericArrType_Type), |
344 | | - (11, PyNumberArrType_Type), |
345 | | - (12, PyIntegerArrType_Type), |
346 | | - (13, PySignedIntegerArrType_Type), |
347 | | - (14, PyUnsignedIntegerArrType_Type), |
348 | | - (15, PyInexactArrType_Type), |
349 | | - (16, PyFloatingArrType_Type), |
350 | | - (17, PyComplexFloatingArrType_Type), |
351 | | - (18, PyFlexibleArrType_Type), |
352 | | - (19, PyCharacterArrType_Type), |
353 | | - (20, PyByteArrType_Type), |
354 | | - (21, PyShortArrType_Type), |
355 | | - (22, PyIntArrType_Type), |
356 | | - (23, PyLongArrType_Type), |
357 | | - (24, PyLongLongArrType_Type), |
358 | | - (25, PyUByteArrType_Type), |
359 | | - (26, PyUShortArrType_Type), |
360 | | - (27, PyUIntArrType_Type), |
361 | | - (28, PyULongArrType_Type), |
362 | | - (29, PyULongLongArrType_Type), |
363 | | - (30, PyFloatArrType_Type), |
364 | | - (31, PyDoubleArrType_Type), |
365 | | - (32, PyLongDoubleArrType_Type), |
366 | | - (33, PyCFloatArrType_Type), |
367 | | - (34, PyCDoubleArrType_Type), |
368 | | - (35, PyCLongDoubleArrType_Type), |
369 | | - (36, PyObjectArrType_Type), |
370 | | - (37, PyStringArrType_Type), |
371 | | - (38, PyUnicodeArrType_Type), |
372 | | - (39, PyVoidArrType_Type)); |
| 334 | +impl_array_type!( |
| 335 | + (1, PyBigArray_Type), |
| 336 | + (2, PyArray_Type), |
| 337 | + (3, PyArrayDescr_Type), |
| 338 | + (4, PyArrayFlags_Type), |
| 339 | + (5, PyArrayIter_Type), |
| 340 | + (6, PyArrayMultiIter_Type), |
| 341 | + (7, NPY_NUMUSERTYPES), |
| 342 | + (8, PyBoolArrType_Type), |
| 343 | + (9, _PyArrayScalar_BoolValues), |
| 344 | + (10, PyGenericArrType_Type), |
| 345 | + (11, PyNumberArrType_Type), |
| 346 | + (12, PyIntegerArrType_Type), |
| 347 | + (13, PySignedIntegerArrType_Type), |
| 348 | + (14, PyUnsignedIntegerArrType_Type), |
| 349 | + (15, PyInexactArrType_Type), |
| 350 | + (16, PyFloatingArrType_Type), |
| 351 | + (17, PyComplexFloatingArrType_Type), |
| 352 | + (18, PyFlexibleArrType_Type), |
| 353 | + (19, PyCharacterArrType_Type), |
| 354 | + (20, PyByteArrType_Type), |
| 355 | + (21, PyShortArrType_Type), |
| 356 | + (22, PyIntArrType_Type), |
| 357 | + (23, PyLongArrType_Type), |
| 358 | + (24, PyLongLongArrType_Type), |
| 359 | + (25, PyUByteArrType_Type), |
| 360 | + (26, PyUShortArrType_Type), |
| 361 | + (27, PyUIntArrType_Type), |
| 362 | + (28, PyULongArrType_Type), |
| 363 | + (29, PyULongLongArrType_Type), |
| 364 | + (30, PyFloatArrType_Type), |
| 365 | + (31, PyDoubleArrType_Type), |
| 366 | + (32, PyLongDoubleArrType_Type), |
| 367 | + (33, PyCFloatArrType_Type), |
| 368 | + (34, PyCDoubleArrType_Type), |
| 369 | + (35, PyCLongDoubleArrType_Type), |
| 370 | + (36, PyObjectArrType_Type), |
| 371 | + (37, PyStringArrType_Type), |
| 372 | + (38, PyUnicodeArrType_Type), |
| 373 | + (39, PyVoidArrType_Type) |
| 374 | +); |
373 | 375 |
|
374 | 376 | #[allow(non_snake_case)] |
375 | 377 | pub unsafe fn PyArray_Check(np: &PyArrayModule, op: *mut PyObject) -> c_int { |
|
0 commit comments