Update of /cvsroot/pure-data/externals/grill/py/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14249/source
Modified Files: py.cpp pyargs.cpp pybase.cpp pybase.h pymeth.cpp Log Message: oops, include libraries for editing the scripts some optimizations and py reload fix open editor for module file on "edit" message (or click) open editor for script under OS X added cygwin support
Index: pybase.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/py/source/pybase.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pybase.h 1 Aug 2005 11:58:01 -0000 1.7 --- pybase.h 11 Aug 2005 15:00:58 -0000 1.8 *************** *** 54,58 **** void AddCurrentPath(flext_base *o); void GetModulePath(const char *mod,char *dir,int len); - void AddToPath(const char *dir); void SetArgs();
--- 54,57 ---- *************** *** 149,153 **** }
- // virtual bool thrcall(void *data) = 0; virtual void callpy(PyObject *fun,PyObject *args) = 0;
--- 148,151 ---- *************** *** 169,177 **** static ThrCond qucond; static PyThreadState *pythrsys; - - static PyThreadState *FindThreadState(); - static void FreeThreadState(); - #else - static PyThreadState *FindThreadState() { return NULL; } #endif
--- 167,170 ---- *************** *** 183,190 **** public:
#ifdef FLEXT_THREADS ! ThrMutex mutex; ! inline void Lock() { mutex.Unlock(); } ! inline void Unlock() { mutex.Unlock(); }
// this is especially needed when one py/pyext object calls another one --- 176,184 ---- public:
+ static void AddToPath(const char *dir); + #ifdef FLEXT_THREADS ! static PyThreadState *FindThreadState(); ! static void FreeThreadState();
// this is especially needed when one py/pyext object calls another one *************** *** 210,218 **** if(old != pythrsys || !--lockcount) PyEval_ReleaseLock(); } - #else - inline void Lock() {} - inline void Unlock() {} - static PyThreadState *PyLock(PyThreadState * = NULL) { return NULL; } static PyThreadState *PyLockSys() { return NULL; } --- 204,208 ----
Index: pybase.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/py/source/pybase.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pybase.cpp 1 Aug 2005 11:58:01 -0000 1.7 --- pybase.cpp 11 Aug 2005 15:00:58 -0000 1.8 *************** *** 201,205 **** , pymsg(false) { ! PyThreadState *state = PyLockSys(); Py_INCREF(module_obj); PyUnlock(state); --- 201,205 ---- , pymsg(false) { ! PyThreadState *state = PyLock(); Py_INCREF(module_obj); PyUnlock(state); *************** *** 208,212 **** pybase::~pybase() { ! PyThreadState *state = PyLockSys(); Py_XDECREF(module_obj); PyUnlock(state); --- 208,212 ---- pybase::~pybase() { ! PyThreadState *state = PyLock(); Py_XDECREF(module_obj); PyUnlock(state); *************** *** 356,360 **** } } ! #elif FLEXT_OS == FLEXT_OS_LINUX #endif } --- 356,377 ---- } } ! #else ! // thanks to Tim Blechmann ! ! char *editor = getenv("EDITOR"); ! ! if(!editor || !strcmp(editor, "/usr/bin/nano") || !strcmp(editor, "/usr/bin/pico") || !strcmp(editor, "/usr/bin/vi")) { ! // no environment variable or console text editor found ... use idle instead (should have come with Python) ! editor = "idle"; ! } ! ! pid_t child = fork(); ! if(!child) { ! char cmd[80]; ! strcpy(cmd,editor); ! strcat(cmd," "); ! strcat(cmd,fname); ! execl("/bin/sh", "sh", "-c", cmd, (char *) NULL); ! } #endif } *************** *** 540,544 **** void pybase::Reload() { ! PyThreadState *state = PyLockSys();
PyObject *reg = GetRegistry(REGNAME); --- 557,561 ---- void pybase::Reload() { ! PyThreadState *state = PyLock();
PyObject *reg = GetRegistry(REGNAME); *************** *** 671,674 **** --- 688,692 ---- #if 0 // want to use that, but exception keeps a reference to the object + // might be a Python bug! PyErr_Print(); #else *************** *** 777,784 **** return true; } - - /* - PY_EXPORT PyThreadState *py_Lock(PyThreadState *st = NULL) { return pybase::PyLock(st?st:pybase::FindThreadState()); } - PY_EXPORT PyThreadState *py_LockSys() { return pybase::PyLockSys(); } - PY_EXPORT void py_Unlock(PyThreadState *st) { pybase::PyUnlock(st); } - */ --- 795,796 ----
Index: py.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/py/source/py.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** py.cpp 1 Aug 2005 11:58:01 -0000 1.33 --- py.cpp 11 Aug 2005 15:00:58 -0000 1.34 *************** *** 155,164 **** funnm = MakeSymbol(pt+1); *pt = 0; - - #if 0 - if(!*modnm) - // if module name is empty set it to __builtin__ - strcpy(modnm,"__builtin__"); - #endif }
--- 155,158 ---- *************** *** 338,342 **** void pyobj::Unload() { ! SetFunction(NULL); }
--- 332,337 ---- void pyobj::Unload() { ! // SetFunction(NULL); ! function = NULL; // just clear the PyObject, not the function name }
*************** *** 355,359 **** return flext_base::CbMethodResort(n,s,argc,argv);
! PyThreadState *state = PyLock();
bool ret = false; --- 350,354 ---- return flext_base::CbMethodResort(n,s,argc,argv);
! PyThreadState *state = PyLockSys();
bool ret = false;
Index: pymeth.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/py/source/pymeth.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pymeth.cpp 1 Aug 2005 11:58:01 -0000 1.5 --- pymeth.cpp 11 Aug 2005 15:00:58 -0000 1.6 *************** *** 367,371 **** return flext_base::CbMethodResort(n,s,argc,argv);
! PyThreadState *state = PyLock();
bool ret = false; --- 367,371 ---- return flext_base::CbMethodResort(n,s,argc,argv);
! PyThreadState *state = PyLockSys();
bool ret = false;
Index: pyargs.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/py/source/pyargs.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** pyargs.cpp 1 Aug 2005 11:58:01 -0000 1.22 --- pyargs.cpp 11 Aug 2005 15:00:58 -0000 1.23 *************** *** 19,23 **** return pySymbol_FromSymbol(flext::GetSymbol(at)); #if 1 ! else if(flext::CanbeInt(at) || flext::CanbeFloat(at)) { // if a number can be an integer... let it be an integer! int ival = flext::GetAInt(at); --- 19,23 ---- return pySymbol_FromSymbol(flext::GetSymbol(at)); #if 1 ! else if(flext::CanbeFloat(at)) { // if a number can be an integer... let it be an integer! int ival = flext::GetAInt(at);