From b80758ff9830ee7bebbbbe23c60a8dd31c8dabfb Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Fri, 7 Aug 2009 13:18:56 +0000 Subject: Forward declare PyArrayIterObject To fix the neighborhood iterator, we need to be able to add a member to PyArrayIterObject which is a function pointer (which will do the padding-specific translation coordinates -> data pointer: poor man's polymorphism). As the function pointer takes an iter object as its first argument, we need to make a proper declaration of PyArrayIterObject, instead of using an anonymous struct as previously defined. I am not sure whether this may break the ABI or not, though. --- numpy/core/include/numpy/ndarrayobject.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'numpy') diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h index aa6c471f3..31e69fb6d 100644 --- a/numpy/core/include/numpy/ndarrayobject.h +++ b/numpy/core/include/numpy/ndarrayobject.h @@ -673,7 +673,18 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *); #define NPY_DISABLE_C_API #endif -typedef struct { +/***************************** + * Basic iterator object + *****************************/ + +/* FWD declaration */ +typedef struct PyArrayIterObject_tag PyArrayIterObject; + +/* type of the function which translates a set of coordinates to a pointer to + * the data */ +typedef char* (*npy_iter_get_dataptr_t)(PyArrayIterObject* iter, npy_intp*); + +struct PyArrayIterObject_tag { PyObject_HEAD int nd_m1; /* number of dimensions - 1 */ npy_intp index, size; @@ -685,7 +696,8 @@ typedef struct { PyArrayObject *ao; char *dataptr; /* pointer to current item*/ npy_bool contiguous; -} PyArrayIterObject; + npy_iter_get_dataptr_t translate; +} ; /* Iterator API */ @@ -933,6 +945,7 @@ typedef struct { PyArrayObject *ao; char *dataptr; /* pointer to current item*/ npy_bool contiguous; + npy_iter_get_dataptr_t translate; /* * New members -- cgit v1.2.1