@@ -82,7 +82,7 @@ unsafe impl Send for PyArrayAPI {}
8282unsafe impl Sync for PyArrayAPI { }
8383
8484impl PyArrayAPI {
85- unsafe fn get < ' py > ( & self , py : Python < ' py > , offset : isize ) -> NonNull < * const c_void > {
85+ pub ( super ) unsafe fn get < ' py > ( & self , py : Python < ' py > , offset : isize ) -> NonNull < * const c_void > {
8686 let api = self
8787 . 0
8888 . get_or_try_init ( py, || get_numpy_api ( py, mod_name ( py) ?, CAPSULE_NAME ) )
@@ -374,81 +374,16 @@ impl PyArrayAPI {
374374 // Min v2.0 impl_api![365; _PyDataType_GetArrFuncs(descr: *const PyArray_Descr) -> *mut PyArray_ArrFuncs];
375375}
376376
377- // Define type objects associated with the NumPy API
378- macro_rules! impl_array_type {
379- ( $( ( $offset: expr, $tname: ident) ) ,* $( , ) ?) => {
380- /// All type objects exported by the NumPy API.
381- #[ allow( non_camel_case_types) ]
382- pub enum NpyTypes { $( $tname) ,* }
383-
384- impl PyArrayAPI {
385- /// Get a pointer of the type object associated with `ty`.
386- pub unsafe fn get_type_object<' py>( & self , py: Python <' py>, ty: NpyTypes ) -> * mut PyTypeObject {
387- match ty {
388- $( NpyTypes :: $tname => self . get( py, $offset) . read( ) as _ ) ,*
389- }
390- }
391- }
392- }
393- }
394-
395- impl_array_type ! {
396- // Slot 1 was never meaningfully used by NumPy
397- ( 2 , PyArray_Type ) ,
398- ( 3 , PyArrayDescr_Type ) ,
399- // Unused slot 4, was `PyArrayFlags_Type`
400- ( 5 , PyArrayIter_Type ) ,
401- ( 6 , PyArrayMultiIter_Type ) ,
402- // (7, NPY_NUMUSERTYPES) -> c_int,
403- ( 8 , PyBoolArrType_Type ) ,
404- // (9, _PyArrayScalar_BoolValues) -> *mut PyBoolScalarObject,
405- ( 10 , PyGenericArrType_Type ) ,
406- ( 11 , PyNumberArrType_Type ) ,
407- ( 12 , PyIntegerArrType_Type ) ,
408- ( 13 , PySignedIntegerArrType_Type ) ,
409- ( 14 , PyUnsignedIntegerArrType_Type ) ,
410- ( 15 , PyInexactArrType_Type ) ,
411- ( 16 , PyFloatingArrType_Type ) ,
412- ( 17 , PyComplexFloatingArrType_Type ) ,
413- ( 18 , PyFlexibleArrType_Type ) ,
414- ( 19 , PyCharacterArrType_Type ) ,
415- ( 20 , PyByteArrType_Type ) ,
416- ( 21 , PyShortArrType_Type ) ,
417- ( 22 , PyIntArrType_Type ) ,
418- ( 23 , PyLongArrType_Type ) ,
419- ( 24 , PyLongLongArrType_Type ) ,
420- ( 25 , PyUByteArrType_Type ) ,
421- ( 26 , PyUShortArrType_Type ) ,
422- ( 27 , PyUIntArrType_Type ) ,
423- ( 28 , PyULongArrType_Type ) ,
424- ( 29 , PyULongLongArrType_Type ) ,
425- ( 30 , PyFloatArrType_Type ) ,
426- ( 31 , PyDoubleArrType_Type ) ,
427- ( 32 , PyLongDoubleArrType_Type ) ,
428- ( 33 , PyCFloatArrType_Type ) ,
429- ( 34 , PyCDoubleArrType_Type ) ,
430- ( 35 , PyCLongDoubleArrType_Type ) ,
431- ( 36 , PyObjectArrType_Type ) ,
432- ( 37 , PyStringArrType_Type ) ,
433- ( 38 , PyUnicodeArrType_Type ) ,
434- ( 39 , PyVoidArrType_Type ) ,
435- ( 214 , PyTimeIntegerArrType_Type ) ,
436- ( 215 , PyDatetimeArrType_Type ) ,
437- ( 216 , PyTimedeltaArrType_Type ) ,
438- ( 217 , PyHalfArrType_Type ) ,
439- ( 218 , NpyIter_Type ) ,
440- }
441-
442377/// Checks that `op` is an instance of `PyArray` or not.
443378#[ allow( non_snake_case) ]
444379pub unsafe fn PyArray_Check < ' py > ( py : Python < ' py > , op : * mut PyObject ) -> c_int {
445- ffi:: PyObject_TypeCheck ( op, PY_ARRAY_API . get_type_object ( py, NpyTypes :: PyArray_Type ) )
380+ ffi:: PyObject_TypeCheck ( op, super :: get_type_object ( py, NpyTypes :: PyArray_Type ) )
446381}
447382
448383/// Checks that `op` is an exact instance of `PyArray` or not.
449384#[ allow( non_snake_case) ]
450385pub unsafe fn PyArray_CheckExact < ' py > ( py : Python < ' py > , op : * mut PyObject ) -> c_int {
451- ( ffi:: Py_TYPE ( op) == PY_ARRAY_API . get_type_object ( py, NpyTypes :: PyArray_Type ) ) as _
386+ ( ffi:: Py_TYPE ( op) == super :: get_type_object ( py, NpyTypes :: PyArray_Type ) ) as _
452387}
453388
454389#[ cfg( test) ]
0 commit comments