Skip to content

Commit

Permalink
Moved function pointers to sub-structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
teoliphant committed Dec 10, 2005
1 parent 8f90681 commit b514d4c
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 138 deletions.
44 changes: 24 additions & 20 deletions scipy/base/include/scipy/arrayobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,27 +762,7 @@ typedef struct {
int len;
} PyArray_Dims;


typedef struct {
PyObject_HEAD
PyTypeObject *typeobj; /* the type object representing an
intance of this type */
char kind; /* kind for this type */
char type; /* unique-character representing this type */
char byteorder; /* '>' (big), '<' (little), '|'
(not-applicable), or '=' (native). */
int type_num; /* number representing this type */
int elsize; /* element size for this type */
int alignment; /* alignment needed for this type */
struct _arr_descr \
*subarray; /* Non-NULL if this type is
is an array (C-contiguous)
of some other type
*/
PyObject *fields; /* The fields dictionary for this type */
/* For statically defined descr this
is always Py_NotImplemented */

/* Functions to cast to all other standard types*/
PyArray_VectorUnaryFunc *cast[PyArray_NTYPES];

Expand Down Expand Up @@ -811,7 +791,31 @@ typedef struct {

/* Function to determine if data is zero or not */
PyArray_NonzeroFunc *nonzero;
} PyArray_ArrFuncs;


typedef struct {
PyObject_HEAD
PyTypeObject *typeobj; /* the type object representing an
intance of this type */
char kind; /* kind for this type */
char type; /* unique-character representing this type */
char byteorder; /* '>' (big), '<' (little), '|'
(not-applicable), or '=' (native). */
int type_num; /* number representing this type */
int elsize; /* element size for this type */
int alignment; /* alignment needed for this type */
struct _arr_descr \
*subarray; /* Non-NULL if this type is
is an array (C-contiguous)
of some other type
*/
PyObject *fields; /* The fields dictionary for this type */
/* For statically defined descr this
is always Py_NotImplemented */

PyArray_ArrFuncs *f; /* a table of functions specific for each
basic data descriptor */
} PyArray_Descr;

typedef struct _arr_descr {
Expand Down
8 changes: 4 additions & 4 deletions scipy/base/src/arraymethods.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ PyArray_Byteswap(PyArrayObject *self, Bool inplace)
PyArrayIterObject *it;

if (inplace) {
copyswapn = self->descr->copyswapn;
copyswapn = self->descr->f->copyswapn;

size = PyArray_SIZE(self);
if (PyArray_ISONESEGMENT(self)) {
Expand All @@ -376,7 +376,7 @@ PyArray_Byteswap(PyArrayObject *self, Bool inplace)

it = (PyArrayIterObject *)\
PyArray_IterNew((PyObject *)self);
copyswap = self->descr->copyswap;
copyswap = self->descr->f->copyswap;
while (it->index < it->size) {
copyswap(it->dataptr, NULL, 1,
self->descr->elsize);
Expand All @@ -403,7 +403,7 @@ PyArray_Byteswap(PyArrayObject *self, Bool inplace)
to begin with so just correct the flag in that case. */

if (self->flags & NOTSWAPPED) {
ret->descr->copyswapn(ret->data, NULL, size, 1,
ret->descr->f->copyswapn(ret->data, NULL, size, 1,
ret->descr->elsize);
ret->flags &= ~NOTSWAPPED;
}
Expand Down Expand Up @@ -502,7 +502,7 @@ static PyObject *
array_toscalar(PyArrayObject *self, PyObject *args) {
if (!PyArg_ParseTuple(args, "")) return NULL;
if (self->nd == 0 || PyArray_SIZE(self) == 1)
return self->descr->getitem(self->data, self);
return self->descr->f->getitem(self->data, self);
else {
PyErr_SetString(PyExc_ValueError, "can only convert an" \
" array of size 1 to Python scalar.");
Expand Down
Loading

0 comments on commit b514d4c

Please sign in to comment.