diff options
author | Pauli Virtanen <pav@iki.fi> | 2009-12-06 12:01:17 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2009-12-06 12:01:17 +0000 |
commit | b16616a553347358a8476e80b9db3a56c6362c2a (patch) | |
tree | 16b89842a01626b79a6dd935e9e592e655cedaad /numpy/numarray/_capi.c | |
parent | f4d788c18c0cb1bf37b4ef9a7f73af2aa47dfbf6 (diff) | |
download | numpy-b16616a553347358a8476e80b9db3a56c6362c2a.tar.gz |
3K: numarray: replace buffer APIs by dummy+error. Some ob_types.
Diffstat (limited to 'numpy/numarray/_capi.c')
-rw-r--r-- | numpy/numarray/_capi.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/numpy/numarray/_capi.c b/numpy/numarray/_capi.c index e51986981..373be3334 100644 --- a/numpy/numarray/_capi.c +++ b/numpy/numarray/_capi.c @@ -2,6 +2,7 @@ #define _libnumarray_MODULE #include "numpy/libnumarray.h" +#include "npy_config.h" #include <float.h> #if (defined(__unix__) || defined(unix)) && !defined(USG) @@ -55,7 +56,7 @@ getBuffer( PyObject *obj) { if (!obj) return PyErr_Format(PyExc_RuntimeError, "NULL object passed to getBuffer()"); - if (obj->ob_type->tp_as_buffer == NULL) { + if (((PyObject*)obj)->ob_type->tp_as_buffer == NULL) { return PyObject_CallMethod(obj, "__buffer__", NULL); } else { Py_INCREF(obj); /* Since CallMethod returns a new object when it @@ -88,6 +89,12 @@ isBuffer (PyObject *obj) static int getWriteBufferDataPtr(PyObject *buffobj, void **buff) { +#if defined(NPY_PY3K) +#warning XXX - needs implementation + PyErr_SetString(PyExc_RuntimeError, + "XXX: getWriteBufferDataPtr is not implemented"); + return -1; +#else int rval = -1; PyObject *buff2; if ((buff2 = getBuffer(buffobj))) @@ -98,6 +105,7 @@ getWriteBufferDataPtr(PyObject *buffobj, void **buff) Py_DECREF(buff2); } return rval; +#endif } /**********************************************************************/ @@ -118,6 +126,12 @@ isBufferWriteable (PyObject *buffobj) static int getReadBufferDataPtr(PyObject *buffobj, void **buff) { +#if defined(NPY_PY3K) +#warning XXX - needs implementation + PyErr_SetString(PyExc_RuntimeError, + "XXX: getWriteBufferDataPtr is not implemented"); + return -1; +#else int rval = -1; PyObject *buff2; if ((buff2 = getBuffer(buffobj))) { @@ -127,6 +141,7 @@ getReadBufferDataPtr(PyObject *buffobj, void **buff) Py_DECREF(buff2); } return rval; +#endif } /**********************************************************************/ @@ -134,6 +149,12 @@ getReadBufferDataPtr(PyObject *buffobj, void **buff) static int getBufferSize(PyObject *buffobj) { +#if defined(NPY_PY3K) +#warning XXX - needs implementation + PyErr_SetString(PyExc_RuntimeError, + "XXX: getWriteBufferDataPtr is not implemented"); + return -1; +#else Py_ssize_t size=0; PyObject *buff2; if ((buff2 = getBuffer(buffobj))) @@ -144,6 +165,7 @@ getBufferSize(PyObject *buffobj) else size = -1; return size; +#endif } @@ -901,7 +923,7 @@ cfunc_call(PyObject *self, PyObject *argsTuple, PyObject *NPY_UNUSED(argsDict)) } } -staticforward PyTypeObject CfuncType; +static PyTypeObject CfuncType; static void cfunc_dealloc(PyObject* self) @@ -986,8 +1008,9 @@ NA_new_cfunc(CfuncDescriptor *cfd) { CfuncObject* cfunc; - CfuncType.ob_type = &PyType_Type; /* Should be done once at init. - Do now since there is no init. */ + /* Should be done once at init. + Do now since there is no init. */ + ((PyObject*)&CfuncType)->ob_type = &PyType_Type; cfunc = PyObject_New(CfuncObject, &CfuncType); @@ -2439,7 +2462,11 @@ _setFromPythonScalarCore(PyArrayObject *a, long offset, PyObject*value, int entr "NA_setFromPythonScalar: len(string) must be 1."); return -1; } +#if defined(NPY_PY3K) + NA_set_Int64(a, offset, *PyBytes_AsString(value)); +#else NA_set_Int64(a, offset, *PyString_AsString(value)); +#endif } else { PyErr_Format(PyExc_TypeError, "NA_setFromPythonScalar: bad value type."); |