summaryrefslogtreecommitdiff
path: root/numpy/core/src/arrayobject.c
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-06-02 07:10:19 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-06-02 07:10:19 +0000
commitf116819dfb4d974e6c4878e3d40420b8b4a2951f (patch)
tree640fdb7b5fc20e94b096fc1fdbfa98b66d8260be /numpy/core/src/arrayobject.c
parentaba0c68744443f55e8c133343f23d0a9f62e4a0c (diff)
downloadnumpy-f116819dfb4d974e6c4878e3d40420b8b4a2951f.tar.gz
Updated NDARRAY_VERSION** Added RegisterCastFunc and moved RegisterDataType.
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r--numpy/core/src/arrayobject.c25
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
*/