From 8ac2ac31abb94663c66596ae2ceb55a6c778b972 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Mon, 12 Dec 2005 00:18:42 +0000 Subject: __str__ method for pyext, to enable print self calls added message bundle functionality (pyext.Bundle class) enable symbol binding for all callables (not only functions and methods) small optimizations and fixes enable optimization of Python code in reease build _isthreaded is now a data member instead of a method more safety for calls where association python-pd has already been removed fixes for pthreads V2 svn path=/trunk/; revision=4190 --- externals/grill/py/py.vcproj | 10 ++++++++-- externals/grill/py/readme.txt | 1 + externals/grill/py/source/clmeth.cpp | 4 ++-- externals/grill/py/source/modmeth.cpp | 32 ++++++++++++++++++++++++++------ externals/grill/py/source/pybase.cpp | 5 +++++ externals/grill/py/source/pybase.h | 1 + externals/grill/py/source/pyext.h | 4 ++-- externals/grill/py/source/pysymbol.cpp | 4 +++- 8 files changed, 48 insertions(+), 13 deletions(-) (limited to 'externals') diff --git a/externals/grill/py/py.vcproj b/externals/grill/py/py.vcproj index 50d989c8..25b2ec33 100644 --- a/externals/grill/py/py.vcproj +++ b/externals/grill/py/py.vcproj @@ -85,7 +85,7 @@ + + + + = 1 && o <= ext->Outlets()) { // offset outlet by signal outlets o += ext->sigoutlets; diff --git a/externals/grill/py/source/modmeth.cpp b/externals/grill/py/source/modmeth.cpp index 44299b0c..a611690f 100644 --- a/externals/grill/py/source/modmeth.cpp +++ b/externals/grill/py/source/modmeth.cpp @@ -118,6 +118,7 @@ PyObject *pybase::py_send(PyObject *,PyObject *args) ) { PyObject *val; +#if 0 bool tp = sz == 2 && PySequence_Check( @@ -126,28 +127,47 @@ PyObject *pybase::py_send(PyObject *,PyObject *args) if(!tp) val = PySequence_GetSlice(args,1,sz); // new ref +#else + if(sz == 2) { + val = PyTuple_GET_ITEM(args,1); // borrow reference + Py_INCREF(val); + } + else + val = PySequence_GetSlice(args,1,sz); // new ref +#endif AtomListStatic<16> lst; const t_symbol *sym = GetPyArgs(lst,val); + Py_DECREF(val); + if(sym) { bool ok = Forward(recv,sym,lst.Count(),lst.Atoms()); #ifdef FLEXT_DEBUG if(!ok) post("py/pyext - Receiver doesn't exist"); #endif + Py_INCREF(Py_None); + return Py_None; } - else if(PyErr_Occurred()) +/* + else if(PyErr_Occurred()) PyErr_Print(); else post("py/pyext - No data to send"); - - if(!tp) Py_DECREF(val); +*/ + else { + FLEXT_ASSERT(PyErr_Occurred()); + return NULL; + } } +/* else post("py/pyext - Send name is invalid"); - - Py_INCREF(Py_None); - return Py_None; +*/ + else { + PyErr_SetString(PyExc_ValueError,"py/pyext - Send name is invalid"); + return NULL; + } } #ifdef FLEXT_THREADS diff --git a/externals/grill/py/source/pybase.cpp b/externals/grill/py/source/pybase.cpp index bdc76099..f20328d8 100644 --- a/externals/grill/py/source/pybase.cpp +++ b/externals/grill/py/source/pybase.cpp @@ -94,6 +94,7 @@ const t_symbol *pybase::sym_response = NULL; void initsymbol(); void initsamplebuffer(); +void initbundle(); void pybase::lib_setup() { @@ -186,6 +187,10 @@ void pybase::lib_setup() initsamplebuffer(); PyModule_AddObject(module_obj,"Buffer",(PyObject *)&pySamplebuffer_Type); + // add message bundle type + initbundle(); + PyModule_AddObject(module_obj,"Bundle",(PyObject *)&pyBundle_Type); + // ------------------------------------------------------------- FLEXT_SETUP(pyobj); diff --git a/externals/grill/py/source/pybase.h b/externals/grill/py/source/pybase.h index 59a1d062..3645a7af 100644 --- a/externals/grill/py/source/pybase.h +++ b/externals/grill/py/source/pybase.h @@ -14,6 +14,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "main.h" #include "pysymbol.h" #include "pybuffer.h" +#include "pybundle.h" class pybase : public flext diff --git a/externals/grill/py/source/pyext.h b/externals/grill/py/source/pyext.h index 672fe5f1..4696c72c 100644 --- a/externals/grill/py/source/pyext.h +++ b/externals/grill/py/source/pyext.h @@ -44,6 +44,8 @@ public: int Inlets() const { return inlets; } int Outlets() const { return outlets; } + static pyext *GetThis(PyObject *self); + protected: virtual bool Init(); @@ -87,8 +89,6 @@ protected: virtual PyObject *GetSig(int ix,bool in); - static pyext *GetThis(PyObject *self); - private: static void Setup(t_classid); diff --git a/externals/grill/py/source/pysymbol.cpp b/externals/grill/py/source/pysymbol.cpp index be7d3139..502606af 100644 --- a/externals/grill/py/source/pysymbol.cpp +++ b/externals/grill/py/source/pysymbol.cpp @@ -36,8 +36,10 @@ static int symbol_init(PyObject *self, PyObject *args, PyObject *kwds) ((pySymbol *)self)->sym = pySymbol_AS_SYMBOL(arg); else if(PyString_Check(arg)) ((pySymbol *)self)->sym = flext::MakeSymbol(PyString_AS_STRING(arg)); - else + else { + PyErr_SetString(PyExc_TypeError,"string or symbol argument expected"); ret = -1; + } Py_DECREF(arg); return ret; -- cgit v1.2.1