aboutsummaryrefslogtreecommitdiff
path: root/externals/grill
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill')
-rw-r--r--externals/grill/py/build/gnumake-win-cygwin.inc2
-rw-r--r--externals/grill/py/build/nmake-win-msvc.inc1
-rw-r--r--externals/grill/py/source/py.cpp11
-rw-r--r--externals/grill/py/source/pyargs.cpp2
-rw-r--r--externals/grill/py/source/pybase.cpp32
-rw-r--r--externals/grill/py/source/pybase.h18
-rw-r--r--externals/grill/py/source/pymeth.cpp2
7 files changed, 33 insertions, 35 deletions
diff --git a/externals/grill/py/build/gnumake-win-cygwin.inc b/externals/grill/py/build/gnumake-win-cygwin.inc
index 39f590bf..70cfca17 100644
--- a/externals/grill/py/build/gnumake-win-cygwin.inc
+++ b/externals/grill/py/build/gnumake-win-cygwin.inc
@@ -1,7 +1,7 @@
DEFS += -DPY_EXPORTS
INCPATH += -I$(PYTHONPATH)/include
LIBPATH += -L$(PYTHONPATH)/libs
-LIBS += -lpython$(PYTHONVER)
+LIBS += -lpython$(PYTHONVER) -lshell32
ifdef PY_NUMARRAY
DEFS += -DPY_NUMARRAY
diff --git a/externals/grill/py/build/nmake-win-msvc.inc b/externals/grill/py/build/nmake-win-msvc.inc
index e9334065..0d4fa162 100644
--- a/externals/grill/py/build/nmake-win-msvc.inc
+++ b/externals/grill/py/build/nmake-win-msvc.inc
@@ -1,6 +1,7 @@
DEFS = $(DEFS) /DPY_EXPORTS
INCPATH=/I$(PYTHONPATH)\include
LIBPATH=/LIBPATH:$(PYTHONPATH)\libs
+LIBS=$(LIBS) shell32.lib
!ifdef PY_NUMARRAY
DEFS = $(DEFS) /DPY_NUMARRAY
diff --git a/externals/grill/py/source/py.cpp b/externals/grill/py/source/py.cpp
index c7111faa..3ef823a0 100644
--- a/externals/grill/py/source/py.cpp
+++ b/externals/grill/py/source/py.cpp
@@ -154,12 +154,6 @@ pyobj::pyobj(int argc,const t_atom *argv)
if(pt && *pt) {
funnm = MakeSymbol(pt+1);
*pt = 0;
-
-#if 0
- if(!*modnm)
- // if module name is empty set it to __builtin__
- strcpy(modnm,"__builtin__");
-#endif
}
if(*modnm) {
@@ -337,7 +331,8 @@ void pyobj::Load()
void pyobj::Unload()
{
- SetFunction(NULL);
+// SetFunction(NULL);
+ function = NULL; // just clear the PyObject, not the function name
}
void pyobj::callpy(PyObject *fun,PyObject *args)
@@ -354,7 +349,7 @@ bool pyobj::CbMethodResort(int n,const t_symbol *s,int argc,const t_atom *argv)
if(n == 0 && s != sym_bang)
return flext_base::CbMethodResort(n,s,argc,argv);
- PyThreadState *state = PyLock();
+ PyThreadState *state = PyLockSys();
bool ret = false;
diff --git a/externals/grill/py/source/pyargs.cpp b/externals/grill/py/source/pyargs.cpp
index d9a91e10..38cfbc54 100644
--- a/externals/grill/py/source/pyargs.cpp
+++ b/externals/grill/py/source/pyargs.cpp
@@ -18,7 +18,7 @@ static PyObject *MakePyAtom(const t_atom &at)
if(flext::IsSymbol(at))
return pySymbol_FromSymbol(flext::GetSymbol(at));
#if 1
- else if(flext::CanbeInt(at) || flext::CanbeFloat(at)) {
+ else if(flext::CanbeFloat(at)) {
// if a number can be an integer... let it be an integer!
int ival = flext::GetAInt(at);
double fval = flext::GetAFloat(at);
diff --git a/externals/grill/py/source/pybase.cpp b/externals/grill/py/source/pybase.cpp
index 69bead28..462cad62 100644
--- a/externals/grill/py/source/pybase.cpp
+++ b/externals/grill/py/source/pybase.cpp
@@ -200,14 +200,14 @@ pybase::pybase()
, detach(0)
, pymsg(false)
{
- PyThreadState *state = PyLockSys();
+ PyThreadState *state = PyLock();
Py_INCREF(module_obj);
PyUnlock(state);
}
pybase::~pybase()
{
- PyThreadState *state = PyLockSys();
+ PyThreadState *state = PyLock();
Py_XDECREF(module_obj);
PyUnlock(state);
}
@@ -355,7 +355,24 @@ void pybase::OpenEditor()
post("py/pyext - Couldn't launch editor");
}
}
-#elif FLEXT_OS == FLEXT_OS_LINUX
+#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
}
@@ -539,7 +556,7 @@ void pybase::Respond(bool b)
void pybase::Reload()
{
- PyThreadState *state = PyLockSys();
+ PyThreadState *state = PyLock();
PyObject *reg = GetRegistry(REGNAME);
@@ -670,6 +687,7 @@ void pybase::exchandle()
{
#if 0
// want to use that, but exception keeps a reference to the object
+ // might be a Python bug!
PyErr_Print();
#else
// must use that instead... clear the exception
@@ -776,9 +794,3 @@ bool pybase::collect()
}
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); }
-*/
diff --git a/externals/grill/py/source/pybase.h b/externals/grill/py/source/pybase.h
index f0ec5640..49eccbbc 100644
--- a/externals/grill/py/source/pybase.h
+++ b/externals/grill/py/source/pybase.h
@@ -53,7 +53,6 @@ protected:
void AddCurrentPath(flext_base *o);
void GetModulePath(const char *mod,char *dir,int len);
- void AddToPath(const char *dir);
void SetArgs();
bool OutObject(flext_base *ext,int o,PyObject *obj);
@@ -148,7 +147,6 @@ protected:
return true;
}
-// virtual bool thrcall(void *data) = 0;
virtual void callpy(PyObject *fun,PyObject *args) = 0;
void exchandle();
@@ -168,11 +166,6 @@ protected:
static PyFifo qufifo;
static ThrCond qucond;
static PyThreadState *pythrsys;
-
- static PyThreadState *FindThreadState();
- static void FreeThreadState();
-#else
- static PyThreadState *FindThreadState() { return NULL; }
#endif
static const t_symbol *sym_fint; // float or int symbol, depending on native number message type
@@ -182,10 +175,11 @@ protected:
public:
+ static void AddToPath(const char *dir);
+
#ifdef FLEXT_THREADS
- ThrMutex mutex;
- inline void Lock() { mutex.Unlock(); }
- inline void Unlock() { mutex.Unlock(); }
+ static PyThreadState *FindThreadState();
+ static void FreeThreadState();
// this is especially needed when one py/pyext object calls another one
// we don't want the message to be queued, but otoh we have to avoid deadlock
@@ -209,11 +203,7 @@ public:
PyThreadState *old = PyThreadState_Swap(st);
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; }
static void PyUnlock(PyThreadState *st) {}
diff --git a/externals/grill/py/source/pymeth.cpp b/externals/grill/py/source/pymeth.cpp
index 91ca2146..3bc90ee2 100644
--- a/externals/grill/py/source/pymeth.cpp
+++ b/externals/grill/py/source/pymeth.cpp
@@ -366,7 +366,7 @@ bool pymeth::CbMethodResort(int n,const t_symbol *s,int argc,const t_atom *argv)
if(n == 0 && s != sym_bang)
return flext_base::CbMethodResort(n,s,argc,argv);
- PyThreadState *state = PyLock();
+ PyThreadState *state = PyLockSys();
bool ret = false;