diff options
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 5b51b5c15..9b08b6b35 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -1175,7 +1175,7 @@ PyArray_Return(PyArrayObject *mp) needs the userdecrs table and PyArray_NUMUSER variables defined in arratypes.inc */ -/*OBJECT_API +/*MULTIARRAY_API Register Data type Does not change the reference count of descr */ @@ -1209,6 +1209,29 @@ PyArray_RegisterDataType(PyArray_Descr *descr) return typenum; } +/*MULTIARRAY_API + Register Casting Function + Replaces any function currently stored. +*/ +static int +PyArray_RegisterCastFunc(PyArray_Descr *descr, int totype, + PyArray_VectorUnaryFunc *castfunc) +{ + PyObject *cobj; + int ret; + if (descr->f->castdict == NULL) { + descr->f->castdict = PyDict_New(); + } + key = PyInt_FromLong(totype); + if (PyErr_Occurred()) return -1; + cobj = PyCObject_FromVoidPtr((void *)castfunc); + if (cobj == NULL) {Py_DECREF(key); return -1;} + ret = PyDict_SetItem(descr->f->castdict, key, cobj); + Py_DECREF(key); + Py_DECREF(cobj); + return ret; +} + /*OBJECT_API To File */ |