Update of /cvsroot/pure-data/externals/grill/py/source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11003/source
Modified Files:
py.cpp pyargs.cpp pybase.cpp pybase.h pyext.cpp pyext.h
pymeth.cpp pyprefix.h
Log Message:
path setting based on new flext functionality
open editor for module file on "edit" message (or click)
open editor for script under OS X
Index: pyargs.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pyargs.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** pyargs.cpp 30 Jul 2005 12:22:11 -0000 1.21
--- pyargs.cpp 1 Aug 2005 11:58:01 -0000 1.22
***************
*** 176,180 ****
// analyze return value or tuple
- int rargc = 0;
const t_symbol *sym = NULL;
--- 176,179 ----
Index: pyprefix.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pyprefix.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pyprefix.h 30 Jul 2005 12:22:11 -0000 1.4
--- pyprefix.h 1 Aug 2005 11:58:01 -0000 1.5
***************
*** 15,18 ****
--- 15,22 ----
#include <flext.h>
+ // hack: must include math.h before Python.h (at least on OSX)
+ // otherwise some functions don't get defined
+ #include <math.h>
+
#if FLEXT_OS == FLEXT_OS_MAC
#include <Python/Python.h>
Index: pymeth.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pymeth.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pymeth.cpp 20 Jul 2005 08:11:18 -0000 1.4
--- pymeth.cpp 1 Aug 2005 11:58:01 -0000 1.5
***************
*** 103,107 ****
virtual bool CbMethodResort(int n,const t_symbol *s,int argc,const t_atom *argv);
- virtual void CbClick();
void m_help();
--- 103,106 ----
***************
*** 424,429 ****
}
- void pymeth::CbClick() { pybase::OpenEditor(); }
-
void pymeth::DumpOut(const t_symbol *sym,int argc,const t_atom *argv)
{
--- 423,426 ----
Index: pyext.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pyext.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** pyext.h 20 Jul 2005 08:11:18 -0000 1.27
--- pyext.h 1 Aug 2005 11:58:01 -0000 1.28
***************
*** 146,149 ****
--- 146,151 ----
FLEXT_CALLBACK(m_doc)
+ FLEXT_CALLBACK(CbClick)
+
#ifdef FLEXT_THREADS
FLEXT_CALLBACK_T(tick)
Index: pybase.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pybase.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pybase.h 30 Jul 2005 12:22:11 -0000 1.6
--- pybase.h 1 Aug 2005 11:58:01 -0000 1.7
***************
*** 125,130 ****
bool respond;
#ifdef FLEXT_THREADS
- bool shouldexit;
int thrcount;
int stoptick;
Timer stoptmr;
--- 125,130 ----
bool respond;
#ifdef FLEXT_THREADS
int thrcount;
+ bool shouldexit;
int stoptick;
Timer stoptmr;
Index: pybase.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pybase.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pybase.cpp 30 Jul 2005 12:22:11 -0000 1.6
--- pybase.cpp 1 Aug 2005 11:58:01 -0000 1.7
***************
*** 12,15 ****
--- 12,21 ----
#include <map>
+ #if FLEXT_OS == FLEXT_OS_WIN
+ #include <windows.h>
+ #elif FLEXT_OS == FLEXT_OS_MAC
+ #include <ApplicationServices/ApplicationServices.h>
+ #endif
+
static PyMethodDef StdOut_Methods[] =
{
***************
*** 296,300 ****
void pybase::OpenEditor()
{
! // this should once open the editor....
}
--- 302,361 ----
void pybase::OpenEditor()
{
! if(!module) return;
! const char *mname = PyModule_GetFilename(module);
! if(!mname) {
! PyErr_Clear();
! return;
! }
!
! char fname[1024];
! strcpy(fname,mname);
!
! // replacing .pyc or .pyo for source file name
! char *dt = strrchr(fname,'.');
! if(dt && !strncmp(dt,".py",2)) strcpy(dt,".py");
!
! // this should open the editor....
! #if FLEXT_OS == FLEXT_OS_WIN
! int err = (int)ShellExecute(NULL,"edit",fname,NULL,NULL,SW_SHOW);
! if(err == SE_ERR_NOASSOC) {
! // no association found - try notepad
! err = (int)ShellExecute(NULL,NULL,"notepad.exe",fname,NULL,SW_SHOW);
! }
! else if(err == ERROR_FILE_NOT_FOUND || err == SE_ERR_FNF)
! post("py/pyext - File not %s found",fname);
! else if(err <= 32)
! post("py/pyext - Unknown error opening %s",fname);
!
! #elif FLEXT_OS == FLEXT_OS_MAC
! FSRef ref;
! OSStatus err = FSPathMakeRef(fname,&ref,NULL);
! if(err)
! post("py/pyext - Error interpreting path %s",fname);
! else {
! FSRef editor;
! err = LSGetApplicationForItem(&ref,kLSRolesEditor,&editor,NULL);
! if(err) {
! // Can't find associated application... try Textedit
! err = FSPathMakeRef("/Applications/TextEdit.app",&editor,NULL);
! if(err)
! post("py/pyext - Can't find Textedit application");
! }
!
! if(!err) {
! LSLaunchFSRefSpec lspec;
! lspec.appRef = &editor;
! lspec.numDocs = 1;
! lspec.itemRefs = &ref;
! lspec.passThruParams = NULL;
! lspec.launchFlags = kLSLaunchDefaults;
! lspec.asyncRefCon = NULL;
! err = LSOpenFromRefSpec(&lspec,NULL);
! if(err)
! post("py/pyext - Couldn't launch editor");
! }
! }
! #elif FLEXT_OS == FLEXT_OS_LINUX
! #endif
}
Index: pyext.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pyext.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** pyext.cpp 30 Jul 2005 12:22:11 -0000 1.40
--- pyext.cpp 1 Aug 2005 11:58:01 -0000 1.41
***************
*** 42,45 ****
--- 42,47 ----
FLEXT_CADDMETHOD_(c,0,"set",m_set);
+ FLEXT_CADDMETHOD_(c,0,"edit",CbClick);
+
FLEXT_CADDATTR_VAR1(c,"py",pymsg);
FLEXT_CADDATTR_VAR1(c,"respond",respond);
***************
*** 100,104 ****
// remember the this pointer
PyObject *th = PyLong_FromVoidPtr(this);
! /*int ret =*/ PyObject_SetAttrString(pyobj,"_this",th); // ref is taken
}
--- 102,106 ----
// remember the this pointer
PyObject *th = PyLong_FromVoidPtr(this);
! PyObject_SetAttrString(pyobj,"_this",th); // ref is taken
}
Index: py.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/py.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** py.cpp 30 Jul 2005 12:22:11 -0000 1.32
--- py.cpp 1 Aug 2005 11:58:01 -0000 1.33
***************
*** 75,78 ****
--- 75,80 ----
FLEXT_CALLBACK(m_doc)
+ FLEXT_CALLBACK(CbClick)
+
#ifdef FLEXT_THREADS
FLEXT_CALLBACK_T(tick)
***************
*** 100,103 ****
--- 102,107 ----
FLEXT_CADDMETHOD_(c,0,"set",m_set);
+ FLEXT_CADDMETHOD_(c,0,"edit",CbClick);
+
FLEXT_CADDATTR_VAR1(c,"py",pymsg);
FLEXT_CADDATTR_VAR1(c,"respond",respond);