7
static PyTypeObject PyUFunc_Type;
13
#if defined(PY_UFUNC_UNIQUE_SYMBOL)
14
#define PyUFunc_API PY_UFUNC_UNIQUE_SYMBOL
17
#if defined(NO_IMPORT) || defined(NO_IMPORT_UFUNC)
18
extern void **PyUFunc_API;
20
#if defined(PY_UFUNC_UNIQUE_SYMBOL)
23
static void **PyUFunc_API=NULL;
27
#define PyUFunc_Type (*(PyTypeObject *)PyUFunc_API[0])
34
PyObject *numpy = PyImport_ImportModule("numpy.core.umath");
35
PyObject *c_api = NULL;
37
if (numpy == NULL) return -1;
38
c_api = PyObject_GetAttrString(numpy, "_UFUNC_API");
39
if (c_api == NULL) {Py_DECREF(numpy); return -1;}
40
if (PyCObject_Check(c_api)) {
41
PyUFunc_API = (void **)PyCObject_AsVoidPtr(c_api);
45
if (PyUFunc_API == NULL) return -1;
49
#define import_ufunc import_umath
55
/* These pointers will be stored in the C-object for use in other
59
void *PyUFunc_API[] = {
60
(void *) &PyUFunc_Type,
65
def generate_api(output_dir):
66
ufunc_api_list = genapi.get_api_functions('UFUNC_API',
67
'ufunc_api_order.txt')
69
# API fixes for __arrayobject_api.h
72
nummulti = len(ufunc_api_list)
73
numtotal = fixed + nummulti
80
genapi.add_api_list(fixed, 'PyUFunc_API', ufunc_api_list,
81
module_list, extension_list, init_list)
84
fid = open(os.path.join(output_dir, '__ufunc_api.h'),'w')
85
s = h_template % ('\n'.join(module_list), '\n'.join(extension_list))
90
fid = open(os.path.join(output_dir, '__ufunc_api.c'),'w')
91
s = c_template % '\n'.join(init_list)