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/main.cpp9
-rw-r--r--externals/grill/py/source/main.h4
-rw-r--r--externals/grill/py/source/modmeth.cpp61
-rw-r--r--externals/grill/py/source/py.cpp2
-rw-r--r--externals/grill/py/source/pyargs.cpp4
5 files changed, 71 insertions, 9 deletions
diff --git a/externals/grill/py/source/main.cpp b/externals/grill/py/source/main.cpp
index 20e7a865..6a28acc9 100644
--- a/externals/grill/py/source/main.cpp
+++ b/externals/grill/py/source/main.cpp
@@ -21,15 +21,18 @@ V py::lib_setup()
{
post("");
post("py/pyext %s - python script objects, (C)2002-2004 Thomas Grill",PY__VERSION);
- post("");
+#ifdef FLEXT_DEBUG
+ post("DEBUG version compiled on %s %s",__DATE__,__TIME__);
+#endif
+ post("");
// -------------------------------------------------------------
Py_Initialize();
-#if 0 //def FLEXT_DEBUG
+#ifdef FLEXT_DEBUG
Py_DebugFlag = 1;
- Py_VerboseFlag = 1;
+// Py_VerboseFlag = 1;
#endif
#ifdef FLEXT_THREADS
diff --git a/externals/grill/py/source/main.h b/externals/grill/py/source/main.h
index bf0ca6cc..581efde5 100644
--- a/externals/grill/py/source/main.h
+++ b/externals/grill/py/source/main.h
@@ -115,6 +115,10 @@ protected:
static PyObject *py_blocksize(PyObject *,PyObject *args);
static PyObject *py_inchannels(PyObject *,PyObject *args);
static PyObject *py_outchannels(PyObject *,PyObject *args);
+#if FLEXT_SYS == FLEXT_SYS_PD
+ static PyObject *py_getvalue(PyObject *,PyObject *args);
+ static PyObject *py_setvalue(PyObject *,PyObject *args);
+#endif
// ----thread stuff ------------
diff --git a/externals/grill/py/source/modmeth.cpp b/externals/grill/py/source/modmeth.cpp
index 0fe0cc6a..ac95e01e 100644
--- a/externals/grill/py/source/modmeth.cpp
+++ b/externals/grill/py/source/modmeth.cpp
@@ -19,10 +19,15 @@ PyMethodDef py::func_tbl[] =
{ "_priority", py::py_priority, METH_VARARGS,"Set priority of current thread" },
#endif
- { "_samplerate", py::py_samplerate, 0,"Get system sample rate" },
- { "_blocksize", py::py_blocksize, 0,"Get system block size" },
- { "_inchannels", py::py_inchannels, 0,"Get number of audio in channels" },
- { "_outchannels", py::py_outchannels, 0,"Get number of audio out channels" },
+ { "_samplerate", py::py_samplerate, METH_NOARGS,"Get system sample rate" },
+ { "_blocksize", py::py_blocksize, METH_NOARGS,"Get system block size" },
+ { "_inchannels", py::py_inchannels, METH_NOARGS,"Get number of audio in channels" },
+ { "_outchannels", py::py_outchannels, METH_NOARGS,"Get number of audio out channels" },
+
+#if FLEXT_SYS == FLEXT_SYS_PD
+ { "_getvalue", py::py_getvalue, METH_VARARGS,"Get value of a 'value' object" },
+ { "_setvalue", py::py_setvalue, METH_VARARGS,"Set value of a 'value' object" },
+#endif
{NULL, NULL, 0, NULL} // sentinel
};
@@ -39,6 +44,8 @@ const C *py::py_doc =
"_blocksize(): Get current blocksize\n"
"_inchannels(): Get number of audio in channels\n"
"_outchannels(): Get number of audio out channels\n"
+ "_getvalue(name): Get value of a 'value' object\n"
+ "_setvalue(name,float): Set value of a 'value' object\n"
;
@@ -186,5 +193,51 @@ PyObject *py::py_priority(PyObject *self,PyObject *args)
}
#endif
+#if FLEXT_SYS == FLEXT_SYS_PD
+PyObject *py::py_getvalue(PyObject *self,PyObject *args)
+{
+ FLEXT_ASSERT(PyTuple_Check(args));
+
+ PyObject *ret;
+ PyObject *name = PyTuple_GetItem(args,0); // borrowed reference
+
+ if(name && PyString_Check(name)) {
+ const t_symbol *sym = MakeSymbol(PyString_AsString(name));
+
+ float f;
+ if(value_getfloat(const_cast<t_symbol *>(sym),&f)) {
+ post("py/pyext - Could not get value '%s'",GetString(sym));
+ Py_INCREF(ret = Py_None);
+ }
+ else
+ ret = PyFloat_FromDouble(f);
+ }
+ else {
+ post("py/pyext - Syntax: _getvalue [name]");
+ Py_INCREF(ret = Py_None);
+ }
+ return ret;
+}
+
+PyObject *py::py_setvalue(PyObject *self,PyObject *args)
+{
+ FLEXT_ASSERT(PyTuple_Check(args));
+
+ PyObject *name = PyTuple_GetItem(args,0); // borrowed reference
+ PyObject *val = PyTuple_GetItem(args,1); // borrowed reference
+ if(name && val && PyString_Check(name) && PyNumber_Check(val)) {
+ const t_symbol *sym = MakeSymbol(PyString_AsString(name));
+ float f = (float)PyFloat_AsDouble(val);
+
+ if(value_setfloat(const_cast<t_symbol *>(sym),f))
+ post("py/pyext - Could not set value '%s'",GetString(sym));
+ }
+ else
+ post("py/pyext - Syntax: _setvalue [name] [value]");
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#endif
diff --git a/externals/grill/py/source/py.cpp b/externals/grill/py/source/py.cpp
index 4690fb50..6883bfad 100644
--- a/externals/grill/py/source/py.cpp
+++ b/externals/grill/py/source/py.cpp
@@ -321,7 +321,7 @@ BL pyobj::work(const t_symbol *s,I argc,const t_atom *argv)
if(rargs) {
// call to outlet _outside_ the Mutex lock!
// otherwise (if not detached) deadlock will occur
- ToOutList(0,*rargs);
+ if(rargs->Count()) ToOutList(0,*rargs);
delete rargs;
}
diff --git a/externals/grill/py/source/pyargs.cpp b/externals/grill/py/source/pyargs.cpp
index 69e403b0..64bcf275 100644
--- a/externals/grill/py/source/pyargs.cpp
+++ b/externals/grill/py/source/pyargs.cpp
@@ -107,7 +107,9 @@ flext::AtomList *py::GetPyArgs(PyObject *pValue,PyObject **self)
rargc = PySequence_Size(pValue);
tp = sequ;
}
- else {
+ else if(pValue == Py_None)
+ Py_DECREF(pValue);
+ else {
rargc = 1;
tp = atom;
}