aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/py/source')
-rw-r--r--externals/grill/py/source/modmeth.cpp36
-rw-r--r--externals/grill/py/source/pybase.h7
-rw-r--r--externals/grill/py/source/pybuffer.cpp2
3 files changed, 36 insertions, 9 deletions
diff --git a/externals/grill/py/source/modmeth.cpp b/externals/grill/py/source/modmeth.cpp
index a611690f..3d44d99e 100644
--- a/externals/grill/py/source/modmeth.cpp
+++ b/externals/grill/py/source/modmeth.cpp
@@ -2,7 +2,7 @@
py/pyext - python external object for PD and Max/MSP
-Copyright (c)2002-2005 Thomas Grill (gr@grrrr.org)
+Copyright (c)2002-2006 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
@@ -27,11 +27,15 @@ PyMethodDef pybase::func_tbl[] =
{ "_getvalue", pybase::py_getvalue, METH_VARARGS,"Get value of a 'value' object" },
{ "_setvalue", pybase::py_setvalue, METH_VARARGS,"Set value of a 'value' object" },
#endif
- {NULL, NULL, 0, NULL} // sentinel
+
+ { "_list", pybase::py_list, METH_VARARGS,"Make a list from arguments" },
+ { "_tuple", pybase::py_tuple, METH_VARARGS,"Make a tuple from arguments" },
+
+ {NULL, NULL, 0, NULL} // sentinel
};
const char *pybase::py_doc =
- "py/pyext - python external object for PD and Max/MSP, (C)2002-2005 Thomas Grill\n"
+ "py/pyext - python external object for PD and Max/MSP, (C)2002-2006 Thomas Grill\n"
"\n"
"This is the pyext module. Available function:\n"
"_send(args...): Send a message to a send symbol\n"
@@ -42,6 +46,9 @@ const char *pybase::py_doc =
"_blocksize(): Get current blocksize\n"
"_getvalue(name): Get value of a 'value' object\n"
"_setvalue(name,float): Set value of a 'value' object\n"
+
+ "_list(args...): Make a list from args\n"
+ "_tuple(args...): Make a tuple from args\n"
;
@@ -240,3 +247,26 @@ PyObject *pybase::py_setvalue(PyObject *self,PyObject *args)
return Py_None;
}
#endif
+
+PyObject *pybase::py_list(PyObject *,PyObject *args)
+{
+ // should always be a tuple
+ FLEXT_ASSERT(PyTuple_Check(args));
+
+ const int sz = PyTuple_GET_SIZE(args);
+ PyObject *ret = PyList_New(sz);
+ for(int i = 0; i < sz; ++i) {
+ PyObject *el = PyTuple_GET_ITEM(args,i);
+ Py_INCREF(el);
+ PyList_SET_ITEM(ret,i,el);
+ }
+ return ret;
+}
+
+PyObject *pybase::py_tuple(PyObject *,PyObject *args)
+{
+ // should always be a tuple
+ FLEXT_ASSERT(PyTuple_Check(args));
+ Py_INCREF(args);
+ return args;
+}
diff --git a/externals/grill/py/source/pybase.h b/externals/grill/py/source/pybase.h
index 6b661268..b5cc8220 100644
--- a/externals/grill/py/source/pybase.h
+++ b/externals/grill/py/source/pybase.h
@@ -119,11 +119,8 @@ protected:
static PyObject *py_setvalue(PyObject *,PyObject *args);
#endif
-#ifdef PY_NUMARRAY
- static void setupNumarray();
- static PyObject *py_import(PyObject *,PyObject *args);
- static PyObject *py_export(PyObject *,PyObject *args);
-#endif
+ static PyObject *py_list(PyObject *,PyObject *args);
+ static PyObject *py_tuple(PyObject *,PyObject *args);
// ----thread stuff ------------
diff --git a/externals/grill/py/source/pybuffer.cpp b/externals/grill/py/source/pybuffer.cpp
index afc35e45..15b64c6d 100644
--- a/externals/grill/py/source/pybuffer.cpp
+++ b/externals/grill/py/source/pybuffer.cpp
@@ -13,7 +13,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#undef PY_ARRAYS
-#if defined(PY_NUMERIC)
+#if defined(PY_NUMERIC) || defined(PY_NUMPY)
#define PY_ARRAYS 1
#elif defined(PY_NUMARRAY)
#define PY_ARRAYS 1