From 9b39e0d94c73773d0dc4b11d9355798d941921e8 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sat, 30 Jul 2005 12:22:11 +0000 Subject: corrected Python object propagation (attribute "py") and adjusted help files path setting based on new flext functionality much better detach method handling (one thread for all object instances) svn path=/trunk/; revision=3389 --- externals/grill/py/source/py.cpp | 2 +- externals/grill/py/source/pyargs.cpp | 5 ++++- externals/grill/py/source/pybase.cpp | 36 ++++++++++++------------------------ externals/grill/py/source/pybase.h | 6 +----- externals/grill/py/source/pyext.cpp | 2 +- externals/grill/py/source/pyprefix.h | 4 ++-- 6 files changed, 21 insertions(+), 34 deletions(-) (limited to 'externals/grill/py') diff --git a/externals/grill/py/source/py.cpp b/externals/grill/py/source/py.cpp index caa759f2..4e1057e2 100644 --- a/externals/grill/py/source/py.cpp +++ b/externals/grill/py/source/py.cpp @@ -137,7 +137,7 @@ pyobj::pyobj(int argc,const t_atom *argv) // init script module if(argc) { - AddCurrentPath(thisCanvas()); + AddCurrentPath(this); const char *sn = GetAString(*argv); argv++,argc--; diff --git a/externals/grill/py/source/pyargs.cpp b/externals/grill/py/source/pyargs.cpp index d631903b..511baf2f 100644 --- a/externals/grill/py/source/pyargs.cpp +++ b/externals/grill/py/source/pyargs.cpp @@ -179,7 +179,10 @@ const t_symbol *pybase::GetPyArgs(AtomList &lst,PyObject *pValue,int offs) const t_symbol *sym = NULL; if(isseq(pValue)) { - int rargc = PySequence_Size(pValue); + // Python might crash here if pValue is no "real" sequence, but rather e.g. an instance + + int rargc = PySequence_Size(pValue); + if(rargc == 2) { // check if syntax is symbol/string, list -> anything message PyObject *s = PySequence_GetItem(pValue,0); diff --git a/externals/grill/py/source/pybase.cpp b/externals/grill/py/source/pybase.cpp index d569a84c..2457974f 100644 --- a/externals/grill/py/source/pybase.cpp +++ b/externals/grill/py/source/pybase.cpp @@ -433,20 +433,21 @@ void pybase::AddToPath(const char *dir) } } -void pybase::AddCurrentPath(t_canvas *cnv) +void pybase::AddCurrentPath(flext_base *o) { -#if FLEXT_SYS == FLEXT_SYS_PD - // add dir of current patch to path - AddToPath(GetString(canvas_getdir(cnv))); + char dir[1024]; + + // add dir of current patch to path + o->GetCanvasDir(dir,sizeof(dir)); + if(*dir) AddToPath(dir); + // add current dir to path +#if FLEXT_SYS == FLEXT_SYS_PD AddToPath(GetString(canvas_getcurrentdir())); -#elif FLEXT_SYS == FLEXT_SYS_MAX - char dir[1024]; - short path = patcher_myvol(cnv); - path_topathname(path,NULL,dir); - AddToPath(dir); -#else - #pragma message("Adding current dir to path is not implemented") +#elif FLEXT_SYS == FLEXT_SYS_MAX + short path = path_getdefault(); + path_topathname(path,NULL,dir); + AddToPath(dir); #endif } @@ -699,19 +700,6 @@ void pybase::erasethreads() } #endif -#if FLEXT_SYS == FLEXT_SYS_MAX -short pybase::patcher_myvol(t_patcher *x) -{ - t_box *w; - if (x->p_vol) - return x->p_vol; - else if (w = (t_box *)x->p_vnewobj) - return patcher_myvol(w->b_patcher); - else - return 0; -} -#endif - bool pybase::collect() { if(gcollect) { diff --git a/externals/grill/py/source/pybase.h b/externals/grill/py/source/pybase.h index 5fadb946..0da6d8fa 100644 --- a/externals/grill/py/source/pybase.h +++ b/externals/grill/py/source/pybase.h @@ -51,7 +51,7 @@ protected: AtomList args; - void AddCurrentPath(t_canvas *cnv); + void AddCurrentPath(flext_base *o); void GetModulePath(const char *mod,char *dir,int len); void AddToPath(const char *dir); void SetArgs(); @@ -153,10 +153,6 @@ protected: void exchandle(); -#if FLEXT_SYS == FLEXT_SYS_MAX - static short patcher_myvol(t_patcher *x); -#endif - static bool collect(); protected: diff --git a/externals/grill/py/source/pyext.cpp b/externals/grill/py/source/pyext.cpp index 48f4849f..00ff0cc4 100644 --- a/externals/grill/py/source/pyext.cpp +++ b/externals/grill/py/source/pyext.cpp @@ -143,7 +143,7 @@ pyext::pyext(int argc,const t_atom *argv,bool sig): // init script module if(argc) { - AddCurrentPath(thisCanvas()); + AddCurrentPath(this); const t_symbol *scr = GetASymbol(*argv); argv++,argc--; diff --git a/externals/grill/py/source/pyprefix.h b/externals/grill/py/source/pyprefix.h index 3841cdce..ac97cbde 100644 --- a/externals/grill/py/source/pyprefix.h +++ b/externals/grill/py/source/pyprefix.h @@ -20,8 +20,8 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include #endif -#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 500) -#error You need at least flext version 0.5.0 +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 501) +#error You need at least flext version 0.5.1 #endif #if FLEXT_OS == FLEXT_LINUX || FLEXT_OS == FLEXT_IRIX -- cgit v1.2.1