Update of /cvsroot/pure-data/externals/grill/py/source In directory sc8-pr-cvs1:/tmp/cvs-serv18443/source
Modified Files: py.cpp pyext.cpp pyext.h Log Message: ""
Index: py.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/py/source/py.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** py.cpp 14 Jan 2004 03:38:02 -0000 1.8 --- py.cpp 20 Jan 2004 03:38:46 -0000 1.9 *************** *** 112,124 **** // init script module if(argc >= 1) { - C dir[1024]; - GetModulePath(GetString(argv[0]),dir,sizeof(dir)); - // set script path - AddToPath(dir); - if(!IsString(argv[0])) post("%s - script name argument is invalid",thisName()); ! else ImportModule(GetString(argv[0])); }
--- 112,125 ---- // init script module if(argc >= 1) { if(!IsString(argv[0])) post("%s - script name argument is invalid",thisName()); ! else { ! C dir[1024]; ! GetModulePath(GetString(argv[0]),dir,sizeof(dir)); ! // set script path ! AddToPath(dir); ! ImportModule(GetString(argv[0])); + } }
*************** *** 209,213 **** { post(""); ! post("py %s - python script object, (C)2002-2004 Thomas Grill",PY__VERSION); #ifdef FLEXT_DEBUG post("DEBUG VERSION, compiled on " __DATE__ " " __TIME__); --- 210,214 ---- { post(""); ! post("%s %s - python script object, (C)2002-2004 Thomas Grill",thisName(),PY__VERSION); #ifdef FLEXT_DEBUG post("DEBUG VERSION, compiled on " __DATE__ " " __TIME__);
Index: pyext.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/py/source/pyext.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pyext.cpp 14 Jan 2004 03:38:02 -0000 1.13 --- pyext.cpp 20 Jan 2004 03:38:46 -0000 1.14 *************** *** 12,16 **** #include <flinternal.h>
- FLEXT_LIB_V("pyext pyx",pyext)
--- 12,15 ---- *************** *** 66,73 **** pyext::pyext(I argc,const t_atom *argv): pyobj(NULL),pythr(NULL), ! inlets(0),outlets(0), methname(NULL) { ! PY_LOCK
if(!pyextref++) { --- 65,74 ---- pyext::pyext(I argc,const t_atom *argv): pyobj(NULL),pythr(NULL), ! inlets(-1),outlets(-1), methname(NULL) { ! int apre = 0; ! ! PY_LOCK
if(!pyextref++) { *************** *** 110,115 **** }
// init script module ! if(argc >= 1) { char dir[1024];
--- 111,122 ---- }
+ if(argc >= apre+2 && CanbeInt(argv[apre]) && CanbeInt(argv[apre+1])) { + inlets = GetAInt(argv[apre]); + outlets = GetAInt(argv[apre+1]); + apre += 2; + } + // init script module ! if(argc > apre) { char dir[1024];
*************** *** 126,141 **** #pragma message("Adding current dir to path is not implemented") #endif
! GetModulePath(GetString(argv[0]),dir,sizeof(dir)); ! // add to path ! AddToPath(dir); ! ! if(!IsString(argv[0])) post("%s - script name argument is invalid",thisName()); else { SetArgs(0,NULL);
! ImportModule(GetString(argv[0])); } }
--- 133,151 ---- #pragma message("Adding current dir to path is not implemented") #endif + const t_atom &scr = argv[apre];
! if(!IsString(scr)) post("%s - script name argument is invalid",thisName()); else { + GetModulePath(GetString(scr),dir,sizeof(dir)); + // add to path + AddToPath(dir); + SetArgs(0,NULL);
! ImportModule(GetString(scr)); } + + ++apre; }
*************** *** 143,194 ****
// t_symbol *sobj = NULL; ! if(argc >= 2) { // object name ! if(!IsString(argv[1])) post("%s - object name argument is invalid",thisName()); else { ! methname = GetSymbol(argv[1]); }
! args(argc-2,argv+2); }
if(methname) { SetClssMeth();
! // now get number of inlets and outlets ! inlets = 1,outlets = 1;
! if(pyobj) { ! PyObject *res; ! res = PyObject_GetAttrString(pyobj,"_inlets"); // get ref ! if(res) { ! if(PyCallable_Check(res)) { ! PyObject *fres = PyEval_CallObject(res,NULL); ! Py_DECREF(res); ! res = fres; ! } ! if(PyInt_Check(res)) ! inlets = PyInt_AsLong(res); ! Py_DECREF(res); ! } ! else ! PyErr_Clear();
! res = PyObject_GetAttrString(pyobj,"_outlets"); // get ref ! if(res) { ! if(PyCallable_Check(res)) { ! PyObject *fres = PyEval_CallObject(res,NULL); ! Py_DECREF(res); ! res = fres; ! } ! if(PyInt_Check(res)) ! outlets = PyInt_AsLong(res); ! Py_DECREF(res); ! } ! else ! PyErr_Clear(); ! } }
PY_UNLOCK --- 153,209 ----
// t_symbol *sobj = NULL; ! if(argc > apre) { // object name ! if(!IsString(argv[apre])) post("%s - object name argument is invalid",thisName()); else { ! methname = GetSymbol(argv[apre]); }
! ++apre; }
+ if(argc > apre) args(argc-apre,argv+apre); + if(methname) { SetClssMeth();
! if(inlets < 0 && outlets < 0) { ! // now get number of inlets and outlets ! inlets = 1,outlets = 1;
! if(pyobj) { ! PyObject *res; ! res = PyObject_GetAttrString(pyobj,"_inlets"); // get ref ! if(res) { ! if(PyCallable_Check(res)) { ! PyObject *fres = PyEval_CallObject(res,NULL); ! Py_DECREF(res); ! res = fres; ! } ! if(PyInt_Check(res)) ! inlets = PyInt_AsLong(res); ! Py_DECREF(res); ! } ! else ! PyErr_Clear();
! res = PyObject_GetAttrString(pyobj,"_outlets"); // get ref ! if(res) { ! if(PyCallable_Check(res)) { ! PyObject *fres = PyEval_CallObject(res,NULL); ! Py_DECREF(res); ! res = fres; ! } ! if(PyInt_Check(res)) ! outlets = PyInt_AsLong(res); ! Py_DECREF(res); ! } ! else ! PyErr_Clear(); ! } ! } } + else inlets = outlets = 0;
PY_UNLOCK *************** *** 206,211 ****
ClearBinding(); - Unregister("_pyext"); Py_XDECREF(pyobj);
--- 221,227 ----
ClearBinding(); + Unregister("_pyext"); + Py_XDECREF(pyobj);
*************** *** 254,257 **** --- 270,274 ---- else Py_DECREF(res); + Py_DECREF(init); } *************** *** 381,390 **** { post(""); ! post("pyext %s - python script object, (C)2002-2004 Thomas Grill",PY__VERSION); #ifdef FLEXT_DEBUG post("DEBUG VERSION, compiled on " __DATE__ " " __TIME__); #endif
! post("Arguments: %s [script name] [class name] {args...}",thisName());
post("Inlet 1: messages to control the pyext object"); --- 398,407 ---- { post(""); ! post("%s %s - python class object, (C)2002-2004 Thomas Grill",thisName(),PY__VERSION); #ifdef FLEXT_DEBUG post("DEBUG VERSION, compiled on " __DATE__ " " __TIME__); #endif
! post("Arguments: %s {inlets outlets} [script name] [class name] {args...}",thisName());
post("Inlet 1: messages to control the pyext object"); *************** *** 560,564 **** return retv; } - - - --- 577,578 ----
Index: pyext.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/py/source/pyext.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** pyext.h 14 Jan 2004 03:38:02 -0000 1.12 --- pyext.h 20 Jan 2004 03:38:46 -0000 1.13 *************** *** 121,124 **** };
- #endif --- 121,123 ----