}
static void
-ndarray_dealloc(NDArrayObject *self)
+ndarray_dealloc(PyObject *op)
{
+ NDArrayObject *self = (NDArrayObject*)op;
if (self->head) {
if (ND_IS_CONSUMER(self)) {
Py_buffer *base = &self->head->base;
/**************************************************************************/
static int
-ndarray_getbuf(NDArrayObject *self, Py_buffer *view, int flags)
+ndarray_getbuf(PyObject *op, Py_buffer *view, int flags)
{
+ NDArrayObject *self = (NDArrayObject*)op;
ndbuf_t *ndbuf = self->head;
Py_buffer *base = &ndbuf->base;
int baseflags = ndbuf->flags;
}
static void
-ndarray_releasebuf(NDArrayObject *self, Py_buffer *view)
+ndarray_releasebuf(PyObject *op, Py_buffer *view)
{
+ NDArrayObject *self = (NDArrayObject*)op;
if (!ND_IS_CONSUMER(self)) {
ndbuf_t *ndbuf = view->internal;
if (--ndbuf->exports == 0 && ndbuf != self->head)
}
static PyBufferProcs ndarray_as_buffer = {
- (getbufferproc)ndarray_getbuf, /* bf_getbuffer */
- (releasebufferproc)ndarray_releasebuf /* bf_releasebuffer */
+ ndarray_getbuf, /* bf_getbuffer */
+ ndarray_releasebuf, /* bf_releasebuffer */
};
}
static PyObject *
-ndarray_get_flags(NDArrayObject *self, void *closure)
+ndarray_get_flags(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
return PyLong_FromLong(self->head->flags);
}
static PyObject *
-ndarray_get_offset(NDArrayObject *self, void *closure)
+ndarray_get_offset(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
ndbuf_t *ndbuf = self->head;
return PyLong_FromSsize_t(ndbuf->offset);
}
static PyObject *
-ndarray_get_obj(NDArrayObject *self, void *closure)
+ndarray_get_obj(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
Py_buffer *base = &self->head->base;
if (base->obj == NULL) {
}
static PyObject *
-ndarray_get_nbytes(NDArrayObject *self, void *closure)
+ndarray_get_nbytes(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
Py_buffer *base = &self->head->base;
return PyLong_FromSsize_t(base->len);
}
static PyObject *
-ndarray_get_readonly(NDArrayObject *self, void *closure)
+ndarray_get_readonly(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
Py_buffer *base = &self->head->base;
return PyBool_FromLong(base->readonly);
}
static PyObject *
-ndarray_get_itemsize(NDArrayObject *self, void *closure)
+ndarray_get_itemsize(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
Py_buffer *base = &self->head->base;
return PyLong_FromSsize_t(base->itemsize);
}
static PyObject *
-ndarray_get_format(NDArrayObject *self, void *closure)
+ndarray_get_format(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
Py_buffer *base = &self->head->base;
const char *fmt = base->format ? base->format : "";
return PyUnicode_FromString(fmt);
}
static PyObject *
-ndarray_get_ndim(NDArrayObject *self, void *closure)
+ndarray_get_ndim(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
Py_buffer *base = &self->head->base;
return PyLong_FromSsize_t(base->ndim);
}
static PyObject *
-ndarray_get_shape(NDArrayObject *self, void *closure)
+ndarray_get_shape(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
Py_buffer *base = &self->head->base;
return ssize_array_as_tuple(base->shape, base->ndim);
}
static PyObject *
-ndarray_get_strides(NDArrayObject *self, void *closure)
+ndarray_get_strides(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
Py_buffer *base = &self->head->base;
return ssize_array_as_tuple(base->strides, base->ndim);
}
static PyObject *
-ndarray_get_suboffsets(NDArrayObject *self, void *closure)
+ndarray_get_suboffsets(PyObject *op, void *closure)
{
+ NDArrayObject *self = (NDArrayObject*)op;
Py_buffer *base = &self->head->base;
return ssize_array_as_tuple(base->suboffsets, base->ndim);
}
static PyObject *
-ndarray_c_contig(PyObject *self, PyObject *dummy)
+ndarray_c_contig(PyObject *self, void *dummy)
{
NDArrayObject *nd = (NDArrayObject *)self;
int ret = PyBuffer_IsContiguous(&nd->head->base, 'C');
}
static PyObject *
-ndarray_fortran_contig(PyObject *self, PyObject *dummy)
+ndarray_fortran_contig(PyObject *self, void *dummy)
{
NDArrayObject *nd = (NDArrayObject *)self;
int ret = PyBuffer_IsContiguous(&nd->head->base, 'F');
}
static PyObject *
-ndarray_contig(PyObject *self, PyObject *dummy)
+ndarray_contig(PyObject *self, void *dummy)
{
NDArrayObject *nd = (NDArrayObject *)self;
int ret = PyBuffer_IsContiguous(&nd->head->base, 'A');
static PyGetSetDef ndarray_getset [] =
{
/* ndbuf */
- { "flags", (getter)ndarray_get_flags, NULL, NULL, NULL},
- { "offset", (getter)ndarray_get_offset, NULL, NULL, NULL},
+ { "flags", ndarray_get_flags, NULL, NULL, NULL},
+ { "offset", ndarray_get_offset, NULL, NULL, NULL},
/* ndbuf.base */
- { "obj", (getter)ndarray_get_obj, NULL, NULL, NULL},
- { "nbytes", (getter)ndarray_get_nbytes, NULL, NULL, NULL},
- { "readonly", (getter)ndarray_get_readonly, NULL, NULL, NULL},
- { "itemsize", (getter)ndarray_get_itemsize, NULL, NULL, NULL},
- { "format", (getter)ndarray_get_format, NULL, NULL, NULL},
- { "ndim", (getter)ndarray_get_ndim, NULL, NULL, NULL},
- { "shape", (getter)ndarray_get_shape, NULL, NULL, NULL},
- { "strides", (getter)ndarray_get_strides, NULL, NULL, NULL},
- { "suboffsets", (getter)ndarray_get_suboffsets, NULL, NULL, NULL},
- { "c_contiguous", (getter)ndarray_c_contig, NULL, NULL, NULL},
- { "f_contiguous", (getter)ndarray_fortran_contig, NULL, NULL, NULL},
- { "contiguous", (getter)ndarray_contig, NULL, NULL, NULL},
+ { "obj", ndarray_get_obj, NULL, NULL, NULL},
+ { "nbytes", ndarray_get_nbytes, NULL, NULL, NULL},
+ { "readonly", ndarray_get_readonly, NULL, NULL, NULL},
+ { "itemsize", ndarray_get_itemsize, NULL, NULL, NULL},
+ { "format", ndarray_get_format, NULL, NULL, NULL},
+ { "ndim", ndarray_get_ndim, NULL, NULL, NULL},
+ { "shape", ndarray_get_shape, NULL, NULL, NULL},
+ { "strides", ndarray_get_strides, NULL, NULL, NULL},
+ { "suboffsets", ndarray_get_suboffsets, NULL, NULL, NULL},
+ { "c_contiguous", ndarray_c_contig, NULL, NULL, NULL},
+ { "f_contiguous", ndarray_fortran_contig, NULL, NULL, NULL},
+ { "contiguous", ndarray_contig, NULL, NULL, NULL},
{NULL}
};
}
-static PyMethodDef ndarray_methods [] =
+static PyMethodDef ndarray_methods[] =
{
{ "tolist", ndarray_tolist, METH_NOARGS, NULL },
{ "tobytes", ndarray_tobytes, METH_NOARGS, NULL },
"ndarray", /* Name of this type */
sizeof(NDArrayObject), /* Basic object size */
0, /* Item size for varobject */
- (destructor)ndarray_dealloc, /* tp_dealloc */
+ ndarray_dealloc, /* tp_dealloc */
0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_as_number */
&ndarray_as_sequence, /* tp_as_sequence */
&ndarray_as_mapping, /* tp_as_mapping */
- (hashfunc)ndarray_hash, /* tp_hash */
+ ndarray_hash, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */