@@ -218,8 +218,9 @@ ndarray_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
218
218
}
219
219
220
220
static void
221
- ndarray_dealloc (NDArrayObject * self )
221
+ ndarray_dealloc (PyObject * op )
222
222
{
223
+ NDArrayObject * self = (NDArrayObject * )op ;
223
224
if (self -> head ) {
224
225
if (ND_IS_CONSUMER (self )) {
225
226
Py_buffer * base = & self -> head -> base ;
@@ -1413,8 +1414,9 @@ ndarray_pop(PyObject *self, PyObject *dummy)
1413
1414
/**************************************************************************/
1414
1415
1415
1416
static int
1416
- ndarray_getbuf (NDArrayObject * self , Py_buffer * view , int flags )
1417
+ ndarray_getbuf (PyObject * op , Py_buffer * view , int flags )
1417
1418
{
1419
+ NDArrayObject * self = (NDArrayObject * )op ;
1418
1420
ndbuf_t * ndbuf = self -> head ;
1419
1421
Py_buffer * base = & ndbuf -> base ;
1420
1422
int baseflags = ndbuf -> flags ;
@@ -1530,8 +1532,9 @@ ndarray_getbuf(NDArrayObject *self, Py_buffer *view, int flags)
1530
1532
}
1531
1533
1532
1534
static void
1533
- ndarray_releasebuf (NDArrayObject * self , Py_buffer * view )
1535
+ ndarray_releasebuf (PyObject * op , Py_buffer * view )
1534
1536
{
1537
+ NDArrayObject * self = (NDArrayObject * )op ;
1535
1538
if (!ND_IS_CONSUMER (self )) {
1536
1539
ndbuf_t * ndbuf = view -> internal ;
1537
1540
if (-- ndbuf -> exports == 0 && ndbuf != self -> head )
@@ -1540,8 +1543,8 @@ ndarray_releasebuf(NDArrayObject *self, Py_buffer *view)
1540
1543
}
1541
1544
1542
1545
static PyBufferProcs ndarray_as_buffer = {
1543
- ( getbufferproc ) ndarray_getbuf , /* bf_getbuffer */
1544
- ( releasebufferproc ) ndarray_releasebuf /* bf_releasebuffer */
1546
+ ndarray_
8000
getbuf , /* bf_getbuffer */
1547
+ ndarray_releasebuf , /* bf_releasebuffer */
1545
1548
};
1546
1549
1547
1550
@@ -1998,21 +2001,24 @@ ssize_array_as_tuple(Py_ssize_t *array, Py_ssize_t len)
1998
2001
}
1999
2002
2000
2003
static PyObject *
2001
- ndarray_get_flags (NDArrayObject * self , void * closure )
2004
+ ndarray_get_flags (PyObject * op , void * closure )
2002
2005
{
2006
+ NDArrayObject * self = (NDArrayObject * )op ;
2003
2007
return PyLong_FromLong (self -> head -> flags );
2004
2008
}
2005
2009
2006
2010
static PyObject *
2007
- ndarray_get_offset (NDArrayObject * self , void * closure )
2011
+ ndarray_get_offset (PyObject * op , void * closure )
2008
2012
{
2013
+ NDArrayObject * self = (NDArrayObject * )op ;
2009
2014
ndbuf_t * ndbuf = self -> head ;
2010
2015
return PyLong_FromSsize_t (ndbuf -> offset );
2011
2016
}
2012
2017
2013
2018
static PyObject *
2014
- ndarray_get_obj (NDArrayObject * self , void * closure )
2019
+ ndarray_get_obj (PyObject * op , void * closure )
2015
2020
{
2021
+ NDArrayObject * self = (NDArrayObject * )op ;
2016
2022
Py_buffer * base = & self -> head -> base ;
2017
2023
2018
2024
if (base -> obj == NULL ) {
@@ -2022,64 +2028,72 @@ ndarray_get_obj(NDArrayObject *self, void *closure)
2022
2028
}
2023
2029
2024
2030
static PyObject *
2025
- ndarray_get_nbytes (NDArrayObject * self , void * closure )
2031
+ ndarray_get_nbytes (PyObject * op , void * closure )
2026
2032
{
2033
+ NDArrayObject * self = (NDArrayObject * )op ;
2027
2034
Py_buffer * base = & self -> head -> base ;
2028
2035
return PyLong_FromSsize_t (base -> len );
2029
2036
}
2030
2037
2031
2038
static PyObject *
2032
- ndarray_get_readonly (NDArrayObject * self , void * closure )
2039
+ ndarray_get_readonly (PyObject * op , void * closure )
2033
2040
{
2041
+ NDArrayObject * self = (NDArrayObject * )op ;
2034
2042
Py_buffer * base = & self -> head -> base ;
2035
2043
return PyBool_FromLong (base -> readonly );
2036
2044
}
2037
2045
2038
2046
static PyObject *
2039
- ndarray_get_itemsize (NDArrayObject * self , void * closure )
2047
+ ndarray_get_itemsize (PyObject * op , void * closure )
2040
2048
{
2049
+ NDArrayObject * self = (NDArrayObject * )op ;
2041
2050
Py_buffer * base = & self -> head -> base ;
2042
2051
return PyLong_FromSsize_t (base -> itemsize );
2043
2052
}
2044
2053
2045
2054
static PyObject *
2046
- ndarray_get_format (NDArrayObject * self , void * closure )
2055
+ ndarray_get_format (PyObject * op , void * closure )
2047
2056
{
2057
+ NDArrayObject * self = (NDArrayObject * )op ;
2048
2058
Py_buffer * base = & self -> head -> base ;
2049
2059
const char * fmt = base -> format ? base -> format : "" ;
2050
2060
return PyUnicode_FromString (fmt );
2051
2061
}
2052
2062
2053
2063
static PyObject *
2054
- ndarray_get_ndim (NDArrayObject * self , void * closure )
2064
+ ndarray_get_ndim (PyObject * op , void * closure )
2055
2065
{
2066
+ NDArrayObject * self = (NDArrayObject * )op ;
2056
2067
Py_buffer * base = & self -> head -> base ;
2057
2068
return PyLong_FromSsize_t (base -> ndim );
2058
2069
}
2059
2070
2060
2071
static PyObject *
2061
- ndarray_get_shape (NDArrayObject * self , void * closure )
2072
+ ndarray_get_shape (PyObject * op , void * closure )
2062
2073
{
2074
+ NDArrayObject * self = (NDArrayObject * )op ;
2063
2075
Py_buffer * base = & self -> head -> base ;
2064
2076
return ssize_array_as_tuple (base -> shape , base -> ndim );
2065
2077
}
2066
2078
2067
2079
static PyObject *
2068
- ndarray_get_strides (NDArrayObject * self , void * closure )
2080
+ ndarray_get_strides (PyObject * op , void * closure )
2069
2081
{
2082
+ NDArrayObject * self = (NDArrayObject * )op ;
2070
2083
Py_buffer * base = & self -> head -> base ;
2071
2084
return ssize_array_as_tuple (base -> strides , base -> ndim );
2072
2085
}
2073
2086
2074
2087
static PyObject *
2075
- ndarray_get_suboffsets (NDArrayObject * self , void * closure )
2088
+ ndarray_get_suboffsets (PyObject * op , void * closure )
2076
2089
{
2090
+ NDArrayObject * self = (NDArrayObject * )op ;
2077
2091
Py_buffer * base = & self -> head -> base ;
2078
2092
return ssize_array_as_tuple (base -> suboffsets , base -> ndim );
2079
2093
}
2080
2094
2081
2095
static PyObject *
2082
- ndarray_c_contig (PyObject * self , PyObject * dummy )
2096
+ ndarray_c_contig (PyObject * self , void * dummy )
2083
2097
{
2084
2098
NDArrayObject * nd = (NDArrayObject * )self ;
2085
2099
int ret = PyBuffer_IsContiguous (& nd -> head -> base , 'C' );
@@ -2093,7 +2107,7 @@ ndarray_c_contig(PyObject *self, PyObject *dummy)
2093
2107
}
2094
2108
2095
2109
static PyObject *
2096
- ndarray_fortran_contig (PyObject * self , PyObject * dummy )
2110
+ ndarray_fortran_contig (PyObject * self , void * dummy )
2097
2111
{
2098
2112
NDArrayObject * nd = (NDArrayObject * )self ;
2099
2113
int ret = PyBuffer_IsContiguous (& nd -> head -> base , 'F' );
@@ -2107,7 +2121,7 @@ ndarray_fortran_contig(PyObject *self, PyObject *dummy)
2107
2121
}
2108
2122
2109
2123
static PyObject *
2110
- ndarray_contig (PyObject * self , PyObject * dummy )
2124
+ ndarray_contig (PyObject * self , void * dummy )
2111
2125
{
2112
2126
NDArrayObject * nd = (NDArrayObject * )self ;
2113
2127
int ret = PyBuffer_IsContiguous (& nd -> head -> base , 'A' );
@@ -2124,21 +2138,21 @@ ndarray_contig(PyObject *self, PyObject *dummy)
2124
2138
static PyGetSetDef ndarray_getset [] =
2125
2139
{
2126
2140
/* ndbuf */
2127
- { "flags" , ( getter ) ndarray_get_flags , NULL , NULL , NULL },
2128
- { "offset" , ( getter ) ndarray_get_offset , NULL , NULL , NULL },
2141
+ { "flags" , ndarray_get_flags , NULL , NULL , NULL },
2142
+ { "offset" , ndarray_get_offset , NULL , NULL , NULL },
2129
2143
/* ndbuf.base */
2130
- { "obj" , ( getter ) ndarray_get_obj , NULL , NULL , NULL },
2131
- { "nbytes" , ( getter ) ndarray_get_nbytes , NULL , NULL , NULL },
2132
- { "readonly" , ( getter ) ndarray_get_readonly , NULL , NULL , NULL },
2133
- { "itemsize" , ( getter ) ndarray_get_itemsize , NULL , NULL , NULL },
2134
- { "format" , ( getter ) ndarray_get_format , NULL , NULL , NULL },
2135
- { "ndim" , ( getter ) ndarray_get_ndim , NULL , NULL , NULL },
2136
- { "shape" , ( getter ) ndarray_get_shape , NULL , NULL , NULL },
2137
- { "strides" , ( getter ) ndarray_get_strides , NULL , NULL , NULL },
2138
- { "suboffsets" , ( getter ) ndarray_get_suboffsets , NULL , NULL , NULL },
2139
- { "c_contiguous" , ( getter ) ndarray_c_contig , NULL , NULL , NULL },
2140
- { "f_contiguous" , ( getter ) ndarray_fortran_contig , NULL , NULL , NULL },
2141
- { "contiguous" , ( getter ) ndarray_contig , NULL , NULL , NULL },
2144
+ { "obj" , ndarray_get_obj , NULL , NULL , NULL },
2145
+ { "nbytes" , ndarray_get_nbytes , NULL , NULL , NULL },
2146
+ { "readonly" , ndarray_get_readonly , NULL , NULL , NULL },
2147
+ { "itemsize" , ndarray_get_itemsize , NULL , NULL , NULL },
2148
+ { "format" , ndarray_get_format , NULL , NULL , NULL },
2149
+ { "ndim" , ndarray_get_ndim , NULL , NULL , NULL },
2150
+ { "shape" , ndarray_get_shape , NULL , NULL , NULL },
2151
+ { "strides" , ndarray_get_strides , NULL , NULL , NULL },
2152
+ { "suboffsets" , ndarray_get_suboffsets , NULL , NULL , NULL },
2153
+ { "c_contiguous" , ndarray_c_contig , NULL , NULL , NULL },
2154
+ { "f_contiguous" , ndarray_fortran_contig , NULL , NULL , NULL },
2155
+ { "contiguous" , ndarray_contig , NULL , NULL , NULL },
2142
2156
{NULL }
2143
2157
};
2144
2158
@@ -2623,7 +2637,7 @@ ndarray_hash(PyObject *self)
2623
2637
}
2624
2638
2625
2639
2626
- static PyMethodDef ndarray_methods [] =
2640
+ static PyMethodDef ndarray_methods [] =
2627
2641
{
2628
2642
{ "tolist" , ndarray_tolist , METH_NOARGS , NULL },
2629
2643
{ "tobytes" , ndarray_tobytes , METH_NOARGS , NULL },
@@ -2639,7 +2653,7 @@ static PyTypeObject NDArray_Type = {
2639
2653
"ndarray" , /* Name of this type */
2640
2654
sizeof (NDArrayObject ), /* Basic object size */
2641
2655
0 , /* Item size for varobject */
2642
- ( destructor ) ndarray_dealloc , /* tp_dealloc */
2656
+ ndarray_dealloc , /* tp_dealloc */
2643
2657
0 , /* tp_vectorcall_offset */
2644
2658
0 , /* tp_getattr */
2645
2659
0 , /* tp_setattr */
@@ -2648,7 +2662,7 @@ static PyTypeObject NDArray_Type = {
2648
2662
0 , /* tp_as_number */
2649
2663
& ndarray_as_sequence , /* tp_as_sequence */
2650
2664
& ndarray_as_mapping , /* tp_as_mapping */
2651
- ( hashfunc ) ndarray_hash , /* tp_hash */
2665
+ ndarray_hash , /* tp_hash */
2652
2666
0 , /* tp_call */
2653
2667
0 , /* tp_str */
2654
2668
PyObject_GenericGetAttr , /* tp_getattro */
0 commit comments