aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source/pybuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/py/source/pybuffer.cpp')
-rw-r--r--externals/grill/py/source/pybuffer.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/externals/grill/py/source/pybuffer.cpp b/externals/grill/py/source/pybuffer.cpp
index 96f2efae..6e7e571b 100644
--- a/externals/grill/py/source/pybuffer.cpp
+++ b/externals/grill/py/source/pybuffer.cpp
@@ -178,6 +178,21 @@ static PyObject *buffer_item(pySamplebuffer *self, int i)
return ret;
}
+PyObject *NAFromBuffer(PyObject *buf,int c,int n)
+{
+#ifdef PY_NUMARRAY
+ if(nasupport) {
+ maybelong shape[2];
+ shape[0] = n;
+ shape[1] = c;
+ PyArrayObject *na = NA_NewAllFromBuffer(c == 1?1:2,shape,numtype,buf,0,0,NA_ByteOrder(),1,1);
+ return (PyObject *)na;
+ }
+ else
+#endif
+ return NULL;
+}
+
static PyObject *buffer_slice(pySamplebuffer *self,int ilow = 0,int ihigh = 1<<(sizeof(int)*8-2))
{
PyObject *ret;
@@ -191,10 +206,7 @@ static PyObject *buffer_slice(pySamplebuffer *self,int ilow = 0,int ihigh = 1<<(
if(ihigh < 0) ihigh += n;
if(ihigh > n) ihigh = n;
- maybelong shape[2];
- shape[0] = n;
- shape[1] = c;
- PyObject *nobj = (PyObject *)NA_NewAllFromBuffer(c == 1?1:2,shape,numtype,(PyObject *)self,0,0,NA_ByteOrder(),1,1);
+ PyObject *nobj = NAFromBuffer((PyObject *)self,c,n);
if(ilow != 0 || ihigh != n) {
ret = PySequence_GetSlice(nobj,ilow,ihigh);
Py_DECREF(nobj);
@@ -657,7 +669,7 @@ void initsamplebuffer()
import_libnumarray();
if(PyErr_Occurred())
// catch import error
- PyErr_Print();
+ PyErr_Clear();
else {
// numarray support ok
nasupport = true;