mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 23:22:01 +00:00
Use a macro for numpy API definitions
This commit is contained in:
parent
f7143dc589
commit
ea2755ccdc
@ -55,11 +55,13 @@ public:
|
|||||||
void **api_ptr = (void **) (c ? PyCObject_AsVoidPtr(c.ptr()) : nullptr);
|
void **api_ptr = (void **) (c ? PyCObject_AsVoidPtr(c.ptr()) : nullptr);
|
||||||
#endif
|
#endif
|
||||||
API api;
|
API api;
|
||||||
api.PyArray_Type_ = (decltype(api.PyArray_Type_)) api_ptr[API_PyArray_Type];
|
#define DECL_NPY_API(Func) api.Func##_ = (decltype(api.Func##_)) api_ptr[API_##Func];
|
||||||
api.PyArray_DescrFromType_ = (decltype(api.PyArray_DescrFromType_)) api_ptr[API_PyArray_DescrFromType];
|
DECL_NPY_API(PyArray_Type);
|
||||||
api.PyArray_FromAny_ = (decltype(api.PyArray_FromAny_)) api_ptr[API_PyArray_FromAny];
|
DECL_NPY_API(PyArray_DescrFromType);
|
||||||
api.PyArray_NewCopy_ = (decltype(api.PyArray_NewCopy_)) api_ptr[API_PyArray_NewCopy];
|
DECL_NPY_API(PyArray_FromAny);
|
||||||
api.PyArray_NewFromDescr_ = (decltype(api.PyArray_NewFromDescr_)) api_ptr[API_PyArray_NewFromDescr];
|
DECL_NPY_API(PyArray_NewCopy);
|
||||||
|
DECL_NPY_API(PyArray_NewFromDescr);
|
||||||
|
#undef DECL_NPY_API
|
||||||
return api;
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user