diff options
Diffstat (limited to 'externals/grill/py/source')
-rw-r--r-- | externals/grill/py/source/clmeth.cpp | 27 | ||||
-rw-r--r-- | externals/grill/py/source/py.cpp | 6 | ||||
-rw-r--r-- | externals/grill/py/source/pyargs.cpp | 9 |
3 files changed, 28 insertions, 14 deletions
diff --git a/externals/grill/py/source/clmeth.cpp b/externals/grill/py/source/clmeth.cpp index 37ba257e..3d740bcb 100644 --- a/externals/grill/py/source/clmeth.cpp +++ b/externals/grill/py/source/clmeth.cpp @@ -167,15 +167,26 @@ PyObject *pyext::pyext_outlet(PyObject *,PyObject *args) pyext *ext = GetThis(self); PyObject *val; - - bool tp = - sz == 3 && - PySequence_Check( - val = PyTuple_GET_ITEM(args,2) // borrow reference - ); + bool tp; +#if 0 + if(sz == 3) { + val = PyTuple_GET_ITEM(args,2); // borrow reference + Py_INCREF(val); + tp = PySequence_Check(val); + } + else + tp = false; if(!tp) - val = PySequence_GetSlice(args,2,sz); // new ref + val = PySequence_GetSlice(args,2,sz); // new ref +#else + if(sz == 3) { + val = PyTuple_GET_ITEM(args,2); // borrow reference + Py_INCREF(val); + } + else + val = PySequence_GetSlice(args,2,sz); // new ref +#endif int o = PyInt_AsLong(outl); if(o >= 1 && o <= ext->Outlets()) { @@ -190,7 +201,7 @@ PyObject *pyext::pyext_outlet(PyObject *,PyObject *args) else PyErr_SetString(PyExc_ValueError,"pyext - _outlet: index out of range"); - if(!tp) Py_DECREF(val); + Py_DECREF(val); } else PyErr_SetString(PyExc_SyntaxError,"pyext - Syntax: _outlet(self,outlet,args...)"); diff --git a/externals/grill/py/source/py.cpp b/externals/grill/py/source/py.cpp index 7cb7fa97..da9459fe 100644 --- a/externals/grill/py/source/py.cpp +++ b/externals/grill/py/source/py.cpp @@ -125,7 +125,7 @@ pyobj::pyobj(int argc,const t_atom *argv) int inlets; if(argc && CanbeInt(*argv)) { inlets = GetAInt(*argv); - if(inlets < 1) inlets = 1; + if(inlets < 0) inlets = 1; argv++,argc--; } else @@ -352,7 +352,7 @@ bool pyobj::callpy(PyObject *fun,PyObject *args) return false; } else { - if(ret != Py_None && !OutObject(this,0,ret) && PyErr_Occurred()) + if(!OutObject(this,0,ret) && PyErr_Occurred()) PyErr_Print(); Py_DECREF(ret); return true; @@ -384,7 +384,7 @@ bool pyobj::CbMethodResort(int n,const t_symbol *s,int argc,const t_atom *argv) PyObject *pargs; - if(objects) { + if(objects || CntIn() == 1) { int inlets = CntIn()-1; pargs = PyTuple_New(inlets); for(int i = 0; i < inlets; ++i) { diff --git a/externals/grill/py/source/pyargs.cpp b/externals/grill/py/source/pyargs.cpp index 5c903f17..2957801d 100644 --- a/externals/grill/py/source/pyargs.cpp +++ b/externals/grill/py/source/pyargs.cpp @@ -130,12 +130,15 @@ const t_symbol *pybase::GetPyArgs(AtomList &lst,PyObject *pValue,int offs) { if(pValue == NULL) return false; + // output bang on None returned + if(pValue == Py_None) return sym_bang; + // analyze return value or tuple int rargc = 0; retval tp = nothing; - if(PyString_Check(pValue)) { + if(PyString_Check(pValue) || pySymbol_Check(pValue)) { rargc = 1; tp = atom; } @@ -143,8 +146,8 @@ const t_symbol *pybase::GetPyArgs(AtomList &lst,PyObject *pValue,int offs) rargc = PySequence_Size(pValue); tp = sequ; } - else if(pValue != Py_None) { - rargc = 1; + else { + rargc = 1; tp = atom; } // else |