summaryrefslogtreecommitdiff
path: root/numpy/f2py
diff options
context:
space:
mode:
authorChris Kerr <debdepba@dasganma.tk>2014-11-10 14:18:37 +0000
committerChris Kerr <debdepba@dasganma.tk>2014-11-10 14:18:37 +0000
commit2129f5c5c0f52d4e428f406e1cbd7ce62bca4af8 (patch)
tree860fae44b1ab84577bd7355944e23514e9c75028 /numpy/f2py
parentc5463e8134d80e72d03d01d0e2427f47404b1c0b (diff)
downloadnumpy-2129f5c5c0f52d4e428f406e1cbd7ce62bca4af8.tar.gz
DEP: replaced arr->data with PyArray_DATA
Diffstat (limited to 'numpy/f2py')
-rw-r--r--numpy/f2py/cb_rules.py2
-rw-r--r--numpy/f2py/cfuncs.py98
-rw-r--r--numpy/f2py/rules.py2
-rw-r--r--numpy/f2py/src/fortranobject.c2
4 files changed, 52 insertions, 52 deletions
diff --git a/numpy/f2py/cb_rules.py b/numpy/f2py/cb_rules.py
index f3bf848a7..3f8edf3c8 100644
--- a/numpy/f2py/cb_rules.py
+++ b/numpy/f2py/cb_rules.py
@@ -384,7 +384,7 @@ cb_arg_rules=[
\t\t\tfprintf(stderr,\"rv_cb_arr is NULL\\n\");
\t\t\tgoto capi_fail;
\t\t}
-\t\tMEMCOPY(#varname_i#,rv_cb_arr->data,PyArray_NBYTES(rv_cb_arr));
+\t\tMEMCOPY(#varname_i#,PyArray_DATA(rv_cb_arr),PyArray_NBYTES(rv_cb_arr));
\t\tif (capi_tmp != (PyObject *)rv_cb_arr) {
\t\t\tPy_DECREF(rv_cb_arr);
\t\t}
diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py
index 650be9b16..393878734 100644
--- a/numpy/f2py/cfuncs.py
+++ b/numpy/f2py/cfuncs.py
@@ -316,35 +316,35 @@ cppmacros['pyobj_from_string1size']='#define pyobj_from_string1size(v,len) (PyUS
needs['TRYPYARRAYTEMPLATE']=['PRINTPYOBJERR']
cppmacros['TRYPYARRAYTEMPLATE']="""\
/* New SciPy */
-#define TRYPYARRAYTEMPLATECHAR case NPY_STRING: *(char *)(arr->data)=*v; break;
-#define TRYPYARRAYTEMPLATELONG case NPY_LONG: *(long *)(arr->data)=*v; break;
-#define TRYPYARRAYTEMPLATEOBJECT case NPY_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data); break;
+#define TRYPYARRAYTEMPLATECHAR case NPY_STRING: *(char *)(PyArray_DATA(arr))=*v; break;
+#define TRYPYARRAYTEMPLATELONG case NPY_LONG: *(long *)(PyArray_DATA(arr))=*v; break;
+#define TRYPYARRAYTEMPLATEOBJECT case NPY_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),PyArray_DATA(arr)); break;
#define TRYPYARRAYTEMPLATE(ctype,typecode) \\
PyArrayObject *arr = NULL;\\
if (!obj) return -2;\\
if (!PyArray_Check(obj)) return -1;\\
if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\"TRYPYARRAYTEMPLATE:\");PRINTPYOBJERR(obj);return 0;}\\
- if (arr->descr->type==typecode) {*(ctype *)(arr->data)=*v; return 1;}\\
+ if (arr->descr->type==typecode) {*(ctype *)(PyArray_DATA(arr))=*v; return 1;}\\
switch (arr->descr->type_num) {\\
- case NPY_DOUBLE: *(double *)(arr->data)=*v; break;\\
- case NPY_INT: *(int *)(arr->data)=*v; break;\\
- case NPY_LONG: *(long *)(arr->data)=*v; break;\\
- case NPY_FLOAT: *(float *)(arr->data)=*v; break;\\
- case NPY_CDOUBLE: *(double *)(arr->data)=*v; break;\\
- case NPY_CFLOAT: *(float *)(arr->data)=*v; break;\\
- case NPY_BOOL: *(npy_bool *)(arr->data)=(*v!=0); break;\\
- case NPY_UBYTE: *(unsigned char *)(arr->data)=*v; break;\\
- case NPY_BYTE: *(signed char *)(arr->data)=*v; break;\\
- case NPY_SHORT: *(short *)(arr->data)=*v; break;\\
- case NPY_USHORT: *(npy_ushort *)(arr->data)=*v; break;\\
- case NPY_UINT: *(npy_uint *)(arr->data)=*v; break;\\
- case NPY_ULONG: *(npy_ulong *)(arr->data)=*v; break;\\
- case NPY_LONGLONG: *(npy_longlong *)(arr->data)=*v; break;\\
- case NPY_ULONGLONG: *(npy_ulonglong *)(arr->data)=*v; break;\\
- case NPY_LONGDOUBLE: *(npy_longdouble *)(arr->data)=*v; break;\\
- case NPY_CLONGDOUBLE: *(npy_longdouble *)(arr->data)=*v; break;\\
- case NPY_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data, arr); break;\\
+ case NPY_DOUBLE: *(double *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_INT: *(int *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_LONG: *(long *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_FLOAT: *(float *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_CDOUBLE: *(double *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_CFLOAT: *(float *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_BOOL: *(npy_bool *)(PyArray_DATA(arr))=(*v!=0); break;\\
+ case NPY_UBYTE: *(unsigned char *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_BYTE: *(signed char *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_SHORT: *(short *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_USHORT: *(npy_ushort *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_UINT: *(npy_uint *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_ULONG: *(npy_ulong *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_LONGLONG: *(npy_longlong *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_ULONGLONG: *(npy_ulonglong *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_LONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_CLONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=*v; break;\\
+ case NPY_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),PyArray_DATA(arr), arr); break;\\
default: return -2;\\
};\\
return 1
@@ -352,36 +352,36 @@ cppmacros['TRYPYARRAYTEMPLATE']="""\
needs['TRYCOMPLEXPYARRAYTEMPLATE']=['PRINTPYOBJERR']
cppmacros['TRYCOMPLEXPYARRAYTEMPLATE']="""\
-#define TRYCOMPLEXPYARRAYTEMPLATEOBJECT case NPY_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),arr->data, arr); break;
+#define TRYCOMPLEXPYARRAYTEMPLATEOBJECT case NPY_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),PyArray_DATA(arr), arr); break;
#define TRYCOMPLEXPYARRAYTEMPLATE(ctype,typecode)\\
PyArrayObject *arr = NULL;\\
if (!obj) return -2;\\
if (!PyArray_Check(obj)) return -1;\\
if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\"TRYCOMPLEXPYARRAYTEMPLATE:\");PRINTPYOBJERR(obj);return 0;}\\
if (arr->descr->type==typecode) {\\
- *(ctype *)(arr->data)=(*v).r;\\
- *(ctype *)(arr->data+sizeof(ctype))=(*v).i;\\
+ *(ctype *)(PyArray_DATA(arr))=(*v).r;\\
+ *(ctype *)(PyArray_DATA(arr)+sizeof(ctype))=(*v).i;\\
return 1;\\
}\\
switch (arr->descr->type_num) {\\
- case NPY_CDOUBLE: *(double *)(arr->data)=(*v).r;*(double *)(arr->data+sizeof(double))=(*v).i;break;\\
- case NPY_CFLOAT: *(float *)(arr->data)=(*v).r;*(float *)(arr->data+sizeof(float))=(*v).i;break;\\
- case NPY_DOUBLE: *(double *)(arr->data)=(*v).r; break;\\
- case NPY_LONG: *(long *)(arr->data)=(*v).r; break;\\
- case NPY_FLOAT: *(float *)(arr->data)=(*v).r; break;\\
- case NPY_INT: *(int *)(arr->data)=(*v).r; break;\\
- case NPY_SHORT: *(short *)(arr->data)=(*v).r; break;\\
- case NPY_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\
- case NPY_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\
- case NPY_BOOL: *(npy_bool *)(arr->data)=((*v).r!=0 && (*v).i!=0); break;\\
- case NPY_USHORT: *(npy_ushort *)(arr->data)=(*v).r; break;\\
- case NPY_UINT: *(npy_uint *)(arr->data)=(*v).r; break;\\
- case NPY_ULONG: *(npy_ulong *)(arr->data)=(*v).r; break;\\
- case NPY_LONGLONG: *(npy_longlong *)(arr->data)=(*v).r; break;\\
- case NPY_ULONGLONG: *(npy_ulonglong *)(arr->data)=(*v).r; break;\\
- case NPY_LONGDOUBLE: *(npy_longdouble *)(arr->data)=(*v).r; break;\\
- case NPY_CLONGDOUBLE: *(npy_longdouble *)(arr->data)=(*v).r;*(npy_longdouble *)(arr->data+sizeof(npy_longdouble))=(*v).i;break;\\
- case NPY_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),arr->data, arr); break;\\
+ case NPY_CDOUBLE: *(double *)(PyArray_DATA(arr))=(*v).r;*(double *)(PyArray_DATA(arr)+sizeof(double))=(*v).i;break;\\
+ case NPY_CFLOAT: *(float *)(PyArray_DATA(arr))=(*v).r;*(float *)(PyArray_DATA(arr)+sizeof(float))=(*v).i;break;\\
+ case NPY_DOUBLE: *(double *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_LONG: *(long *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_FLOAT: *(float *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_INT: *(int *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_SHORT: *(short *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_UBYTE: *(unsigned char *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_BYTE: *(signed char *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_BOOL: *(npy_bool *)(PyArray_DATA(arr))=((*v).r!=0 && (*v).i!=0); break;\\
+ case NPY_USHORT: *(npy_ushort *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_UINT: *(npy_uint *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_ULONG: *(npy_ulong *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_LONGLONG: *(npy_longlong *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_ULONGLONG: *(npy_ulonglong *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_LONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=(*v).r; break;\\
+ case NPY_CLONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=(*v).r;*(npy_longdouble *)(PyArray_DATA(arr)+sizeof(npy_longdouble))=(*v).i;break;\\
+ case NPY_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),PyArray_DATA(arr), arr); break;\\
default: return -2;\\
};\\
return -1;
@@ -392,10 +392,10 @@ cppmacros['TRYCOMPLEXPYARRAYTEMPLATE']="""\
## \telse arr = (PyArrayObject *)PyArray_ContiguousFromObject(obj,typenum,0,0);\\
## \tif (arr) {\\
## \t\tif (arr->descr->type_num==NPY_OBJECT) {\\
-## \t\t\tif (!ctype ## _from_pyobj(v,(arr->descr->getitem)(arr->data),\"\"))\\
+## \t\t\tif (!ctype ## _from_pyobj(v,(arr->descr->getitem)(PyArray_DATA(arr)),\"\"))\\
## \t\t\tgoto capi_fail;\\
## \t\t} else {\\
-## \t\t\t(arr->descr->cast[typenum])(arr->data,1,(char*)v,1,1);\\
+## \t\t\t(arr->descr->cast[typenum])(PyArray_DATA(arr),1,(char*)v,1,1);\\
## \t\t}\\
## \t\tif ((PyObject *)arr != obj) { Py_DECREF(arr); }\\
## \t\treturn 1;\\
@@ -408,10 +408,10 @@ cppmacros['TRYCOMPLEXPYARRAYTEMPLATE']="""\
## \telse arr = (PyArrayObject *)PyArray_ContiguousFromObject(obj,typenum,0,0);\\
## \tif (arr) {\\
## \t\tif (arr->descr->type_num==NPY_OBJECT) {\\
-## \t\t\tif (!ctype ## _from_pyobj(v,(arr->descr->getitem)(arr->data),\"\"))\\
+## \t\t\tif (!ctype ## _from_pyobj(v,(arr->descr->getitem)(PyArray_DATA(arr)),\"\"))\\
## \t\t\tgoto capi_fail;\\
## \t\t} else {\\
-## \t\t\t(arr->descr->cast[typenum])((void *)(arr->data),1,(void *)(v),1,1);\\
+## \t\t\t(arr->descr->cast[typenum])((void *)(PyArray_DATA(arr)),1,(void *)(v),1,1);\\
## \t\t}\\
## \t\tif ((PyObject *)arr != obj) { Py_DECREF(arr); }\\
## \t\treturn 1;\\
@@ -592,7 +592,7 @@ cfuncs['try_pyarr_from_string']="""\
static int try_pyarr_from_string(PyObject *obj,const string str) {
\tPyArrayObject *arr = NULL;
\tif (PyArray_Check(obj) && (!((arr = (PyArrayObject *)obj) == NULL)))
-\t\t{ STRINGCOPYN(arr->data,str,PyArray_NBYTES(arr)); }
+\t\t{ STRINGCOPYN(PyArray_DATA(arr),str,PyArray_NBYTES(arr)); }
\treturn 1;
capi_fail:
\tPRINTPYOBJERR(obj);
@@ -625,7 +625,7 @@ fprintf(stderr,\"string_from_pyobj(str='%s',len=%d,inistr='%s',obj=%p)\\n\",(cha
\t\tif (*len == -1)
\t\t\t*len = (arr->descr->elsize)*PyArray_SIZE(arr);
\t\tSTRINGMALLOC(*str,*len);
-\t\tSTRINGCOPYN(*str,arr->data,*len+1);
+\t\tSTRINGCOPYN(*str,PyArray_DATA(arr),*len+1);
\t\treturn 1;
\t}
\tif (PyString_Check(obj)) {
diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py
index 06c3a3447..8a949e029 100644
--- a/numpy/f2py/rules.py
+++ b/numpy/f2py/rules.py
@@ -1047,7 +1047,7 @@ if (#varname#_capi==Py_None) {
\t\tif (!PyErr_Occurred())
\t\t\tPyErr_SetString(#modulename#_error,\"failed in converting #nth# `#varname#\' of #pyname# to C/Fortran array\" );
\t} else {
-\t\t#varname# = (#ctype# *)(capi_#varname#_tmp->data);
+\t\t#varname# = (#ctype# *)(PyArray_DATA(capi_#varname#_tmp));
""",
{hasinitvalue:[
{isintent_nothide:'\tif (#varname#_capi == Py_None) {'},
diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c
index 06c28cab6..d741b211a 100644
--- a/numpy/f2py/src/fortranobject.c
+++ b/numpy/f2py/src/fortranobject.c
@@ -361,7 +361,7 @@ fortran_setattr(PyFortranObject *fp, char *name, PyObject *v) {
if (s==-1)
s = PyArray_MultiplyList(arr->dimensions,PyArray_NDIM(arr));
if (s<0 ||
- (memcpy(fp->defs[i].data,arr->data,s*PyArray_ITEMSIZE(arr)))==NULL) {
+ (memcpy(fp->defs[i].data,PyArray_DATA(arr),s*PyArray_ITEMSIZE(arr)))==NULL) {
if ((PyObject*)arr!=v) {
Py_DECREF(arr);
}