diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2004-01-22 03:38:37 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2004-01-22 03:38:37 +0000 |
commit | c970a0b61182435de534f39b32e8f29f5ef7b42f (patch) | |
tree | 96a819d9661a7cda1b55ecad0ca479002661336d /externals/grill/py/source/py.cpp | |
parent | f9b7710c9bf2b7d6574fb4c358b1c7ff8837719d (diff) |
""
svn path=/trunk/; revision=1285
Diffstat (limited to 'externals/grill/py/source/py.cpp')
-rw-r--r-- | externals/grill/py/source/py.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/externals/grill/py/source/py.cpp b/externals/grill/py/source/py.cpp index bfc32678..e9e7040d 100644 --- a/externals/grill/py/source/py.cpp +++ b/externals/grill/py/source/py.cpp @@ -1,8 +1,8 @@ /* -py/pyext - python script object for PD and MaxMSP +py/pyext - python script object for PD and Max/MSP -Copyright (c) 2002-2003 Thomas Grill (xovo@gmx.net) +Copyright (c) 2002-2004 Thomas Grill (xovo@gmx.net) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. @@ -23,9 +23,9 @@ public: protected: BL m_method_(I n,const t_symbol *s,I argc,const t_atom *argv); - V work(const t_symbol *s,I argc,const t_atom *argv); + BL work(const t_symbol *s,I argc,const t_atom *argv); - V m_bang() { work(sym_bang,0,NULL); } + V m_bang() { callwork(sym_bang,0,NULL); } V m_reload(); V m_reload_(I argc,const t_atom *argv); V m_set(I argc,const t_atom *argv); @@ -94,6 +94,8 @@ void pyobj::Setup(t_classid c) FLEXT_CADDMETHOD_(c,1,"int",m_py_int); FLEXT_CADDMETHOD(c,1,m_py_list); FLEXT_CADDMETHOD(c,1,m_py_any); + + FLEXT_CADDATTR_VAR1(c,"respond",respond); } pyobj::pyobj(I argc,const t_atom *argv): @@ -227,6 +229,8 @@ V pyobj::m_help() post("\treload. : reload with former arguments"); post("\tdoc: display module doc string"); post("\tdoc+: display function doc string"); + post("\tdir: dump module dictionary"); + post("\tdir+: dump function dictionary"); #ifdef FLEXT_THREADS post("\tdetach 0/1: detach threads"); post("\tstop {wait time (ms)}: stop threads"); @@ -271,9 +275,10 @@ V pyobj::Reload() } -V pyobj::work(const t_symbol *s,I argc,const t_atom *argv) +BL pyobj::work(const t_symbol *s,I argc,const t_atom *argv) { AtomList *rargs = NULL; + BL ret; ++thrcount; PY_LOCK @@ -287,9 +292,11 @@ V pyobj::work(const t_symbol *s,I argc,const t_atom *argv) Py_XDECREF(pArgs); Py_XDECREF(pValue); + ret = true; } else { post("%s: no function defined",thisName()); + ret = false; } PY_UNLOCK @@ -301,19 +308,24 @@ V pyobj::work(const t_symbol *s,I argc,const t_atom *argv) ToOutList(0,*rargs); delete rargs; } + + return ret; } V pyobj::callwork(const t_symbol *s,I argc,const t_atom *argv) { + BL ret = false; if(detach) { if(shouldexit) post("%s - New threads can't be launched now!",thisName()); - else - if(!FLEXT_CALLMETHOD_A(work,s,argc,argv)) - post("%s - Failed to launch thread!",thisName()); + else { + ret = FLEXT_CALLMETHOD_A(work,s,argc,argv); + if(!ret) post("%s - Failed to launch thread!",thisName()); + } } - else - work(s,argc,argv); + else + ret = work(s,argc,argv); + Respond(ret); } |