diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2005-07-18 18:03:12 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2005-07-18 18:03:12 +0000 |
commit | 35a59e7dbce7f5cd6fb8c26e40fc66dfd8384cce (patch) | |
tree | cb2d24e74f150aa72822e468338e077211012dbb /externals/grill/py/source/py.cpp | |
parent | f29a360e5aaaeeb75ec191a4163905a8cf44212a (diff) |
python-like dotted module.function syntax
cleaned up float vs. int pyext tags
better definition of output values (atoms, lists, anythings)
multiply inlets for py (hot and cold inlets)
better exception handling and error message
fixes for atomic pyext._outlet messages
svn path=/trunk/; revision=3358
Diffstat (limited to 'externals/grill/py/source/py.cpp')
-rw-r--r-- | externals/grill/py/source/py.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/externals/grill/py/source/py.cpp b/externals/grill/py/source/py.cpp index da9459fe..4b7c2bdc 100644 --- a/externals/grill/py/source/py.cpp +++ b/externals/grill/py/source/py.cpp @@ -54,7 +54,7 @@ protected: private: - virtual bool callpy(PyObject *fun,PyObject *args); + virtual void callpy(PyObject *fun,PyObject *args); static void Setup(t_classid c); @@ -343,19 +343,12 @@ void pyobj::Unload() SetFunction(NULL); } -bool pyobj::callpy(PyObject *fun,PyObject *args) +void pyobj::callpy(PyObject *fun,PyObject *args) { PyObject *ret = PyObject_CallObject(fun,args); - if(ret == NULL) { - // function not found resp. arguments not matching - PyErr_Print(); - return false; - } - else { - if(!OutObject(this,0,ret) && PyErr_Occurred()) - PyErr_Print(); + if(ret) { + OutObject(this,0,ret); // exception might be raised here Py_DECREF(ret); - return true; } } @@ -397,7 +390,8 @@ bool pyobj::CbMethodResort(int n,const t_symbol *s,int argc,const t_atom *argv) // if n == 0, it's a pure bang pargs = MakePyArgs(n?s:NULL,argc,argv); - ret = gencall(function,pargs); // references are stolen + gencall(function,pargs); // references are stolen + ret = true; } else PyErr_SetString(PyExc_RuntimeError,"No function set"); @@ -408,7 +402,8 @@ bool pyobj::CbMethodResort(int n,const t_symbol *s,int argc,const t_atom *argv) PyObject *func = PyObject_GetAttrString(module,const_cast<char *>(GetString(s))); if(func) { PyObject *pargs = MakePyArgs(sym_list,argc,argv); - ret = gencall(func,pargs); + gencall(func,pargs); + ret = true; } } else |