diff options
Diffstat (limited to 'externals/grill')
-rw-r--r-- | externals/grill/py/py.vcproj | 2 | ||||
-rw-r--r-- | externals/grill/py/readme.txt | 2 | ||||
-rw-r--r-- | externals/grill/py/source/main.cpp | 9 | ||||
-rw-r--r-- | externals/grill/py/source/main.h | 4 | ||||
-rw-r--r-- | externals/grill/py/source/modmeth.cpp | 61 | ||||
-rw-r--r-- | externals/grill/py/source/py.cpp | 2 | ||||
-rw-r--r-- | externals/grill/py/source/pyargs.cpp | 4 |
7 files changed, 74 insertions, 10 deletions
diff --git a/externals/grill/py/py.vcproj b/externals/grill/py/py.vcproj index a8c1eaf2..e4ba34b2 100644 --- a/externals/grill/py/py.vcproj +++ b/externals/grill/py/py.vcproj @@ -292,7 +292,7 @@ Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" - AdditionalDependencies="pd.lib pthreadVC.lib" + AdditionalDependencies="flext_ld.lib pd.lib pthreadVC.lib" OutputFile="$(outdir)/py.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" diff --git a/externals/grill/py/readme.txt b/externals/grill/py/readme.txt index 25a64365..6ec16e07 100644 --- a/externals/grill/py/readme.txt +++ b/externals/grill/py/readme.txt @@ -86,6 +86,8 @@ Version history: - ADD: better (and independent) handling of inlet and outlet count (as class variables or dynamically initialized in __init__) - FIX: many memory leaks associated to ***GetItem stuff (big thanks to sven!) - FIX: set "this" memory in object after reloading script +- ADD: _getvalue,_setvalue to access PD values +- FIX: don't shout when Python script returns PyNone 0.1.3: - FIX: class variables are now set atomic if parameter list has only 1 element 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; } |