[PD-cvs] externals/grill/py/source main.h, 1.43, 1.44 modmeth.cpp, 1.24, 1.25 py.cpp, 1.36, 1.37 pybase.cpp, 1.18, 1.19 pybase.h, 1.13, 1.14 pybuffer.cpp, 1.12, 1.13 pyext.cpp, 1.47, 1.48 pyext.h, 1.31, 1.32 pyprefix.h, 1.6, 1.7

Thomas Grill xovo at users.sourceforge.net
Fri Jul 6 23:44:58 CEST 2007


Update of /cvsroot/pure-data/externals/grill/py/source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18343/source

Modified Files:
	main.h modmeth.cpp py.cpp pybase.cpp pybase.h pybuffer.cpp 
	pyext.cpp pyext.h pyprefix.h 
Log Message:
adapting to new flext lockfree structures
much better detach method handling (one thread for all object instances)
use PyGILState_\*() functionality (enabled with PY_USE_GIL)
ooops, fixing typo
fixing numpy initialization quirks
pyext._init is now called after __init__
enabled use of inofficial PD functionality for search and help path access (#define PY_USE_INOFFICIAL)
added sketch for new pye (Python expression) object
buffer protocol adapted for Python 2.5


Index: pyprefix.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pyprefix.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pyprefix.h	7 Mar 2007 13:40:14 -0000	1.6
--- pyprefix.h	6 Jul 2007 21:44:56 -0000	1.7
***************
*** 3,7 ****
  py/pyext - python script object for PD and MaxMSP
  
! Copyright (c)2002-2005 Thomas Grill (gr at grrrr.org)
  For information on usage and redistribution, and for a DISCLAIMER OF ALL
  WARRANTIES, see the file, "license.txt," in this distribution.  
--- 3,7 ----
  py/pyext - python script object for PD and MaxMSP
  
! Copyright (c)2002-2007 Thomas Grill (gr at grrrr.org)
  For information on usage and redistribution, and for a DISCLAIMER OF ALL
  WARRANTIES, see the file, "license.txt," in this distribution.  
***************
*** 40,43 ****
--- 40,48 ----
  #include <string>
  
+ #ifdef PY_USE_INOFFICIAL
+ extern "C" {
+ #include <s_stuff.h>
+ }
+ #endif
  
  #endif

Index: pyext.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pyext.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** pyext.h	7 Mar 2007 13:40:14 -0000	1.31
--- pyext.h	6 Jul 2007 21:44:56 -0000	1.32
***************
*** 50,53 ****
--- 50,54 ----
  
      virtual bool Init();
+     virtual bool Finalize();
      virtual void Exit();
  

Index: modmeth.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/modmeth.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** modmeth.cpp	7 Mar 2007 13:40:14 -0000	1.24
--- modmeth.cpp	6 Jul 2007 21:44:56 -0000	1.25
***************
*** 24,27 ****
--- 24,30 ----
  	{ "_blocksize", pybase::py_blocksize, METH_NOARGS,"Get system block size" },
  
+ 	{ "_searchpaths", pybase::py_searchpaths, METH_NOARGS,"Get system search paths" },
+ 	{ "_helppaths", pybase::py_helppaths, METH_NOARGS,"Get system help paths" },
+ 
  #if FLEXT_SYS == FLEXT_SYS_PD
  	{ "_getvalue", pybase::py_getvalue, METH_VARARGS,"Get value of a 'value' object" },
***************
*** 52,56 ****
  ;
  
- 
  #ifdef FLEXT_THREADS
  void pybase::tick(void *)
--- 55,58 ----
***************
*** 112,115 ****
--- 114,145 ----
  }
  
+ PyObject *pybase::py_searchpaths(PyObject *self,PyObject *args)
+ {
+ #if FLEXT_SYS == FLEXT_SYS_PD && defined(PY_USE_INOFFICIAL)
+     PyObject *ret = PyList_New(0);
+     char *dir;
+     for(int i = 0; (dir = namelist_get(sys_searchpath,i)) != NULL; ++i)
+         PyList_Append(ret,PyString_FromString(dir));
+     return ret;
+ #else
+     Py_INCREF(Py_None);
+     return Py_None;
+ #endif
+ }
+ 
+ PyObject *pybase::py_helppaths(PyObject *self,PyObject *args)
+ {
+ #if FLEXT_SYS == FLEXT_SYS_PD && defined(PY_USE_INOFFICIAL)
+     PyObject *ret = PyList_New(0);
+     char *dir;
+     for(int i = 0; (dir = namelist_get(sys_helppath,i)) != NULL; ++i)
+         PyList_Append(ret,PyString_FromString(dir));
+     return ret;
+ #else
+     Py_INCREF(Py_None);
+     return Py_None;
+ #endif
+ }
+ 
  PyObject *pybase::py_send(PyObject *,PyObject *args)
  {

Index: pyext.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pyext.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** pyext.cpp	7 Mar 2007 13:40:14 -0000	1.47
--- pyext.cpp	6 Jul 2007 21:44:56 -0000	1.48
***************
*** 220,223 ****
--- 220,251 ----
  }
  
+ bool pyext::Finalize()
+ {
+ 	bool ok = true;
+ 	ThrState state = PyLockSys();
+ 
+ 	PyObject *init = PyObject_GetAttrString(pyobj,"_init"); // get ref
+ 	if(init) {
+ 		if(PyMethod_Check(init)) {
+ 			PyObject *res = PyObject_CallObject(init,NULL);
+ 			if(!res) {
+ 				// exception is set
+ 				ok = false;
+ 				// we want to know why __init__ failed...
+ 				PyErr_Print();
+ 			}
+ 			else
+ 				Py_DECREF(res);
+ 		}
+ 		Py_DECREF(init);
+ 	}
+ 	else
+ 		// __init__ has not been found - don't care
+ 		PyErr_Clear();
+ 
+ 	PyUnlock(state);
+     return ok && flext_dsp::Finalize(); 
+ }
+ 
  void pyext::Exit() 
  { 

Index: pybuffer.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pybuffer.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** pybuffer.cpp	10 Feb 2007 03:20:57 -0000	1.12
--- pybuffer.cpp	6 Jul 2007 21:44:56 -0000	1.13
***************
*** 187,191 ****
--- 187,196 ----
  
  // support the buffer protocol
+ 
+ #if PY_VERSION_HEX >= 0x02050000
+ static Py_ssize_t buffer_readbuffer(PyObject *obj, Py_ssize_t segment, void **ptrptr)
+ #else
  static int buffer_readbuffer(PyObject *obj, int segment, void **ptrptr)
+ #endif
  {
      flext::buffer *b = ((pySamplebuffer *)obj)->buf;
***************
*** 194,198 ****
--- 199,207 ----
  }
  
+ #if PY_VERSION_HEX >= 0x02050000
+ static Py_ssize_t buffer_writebuffer(PyObject *obj, Py_ssize_t segment, void **ptrptr)
+ #else
  static int buffer_writebuffer(PyObject *obj, int segment, void **ptrptr)
+ #endif
  {
      flext::buffer *b = ((pySamplebuffer *)obj)->buf;
***************
*** 201,205 ****
--- 210,218 ----
  }
  
+ #if PY_VERSION_HEX >= 0x02050000
+ static Py_ssize_t buffer_segcount(PyObject *obj, Py_ssize_t *lenp)
+ #else
  static int buffer_segcount(PyObject *obj, int *lenp)
+ #endif
  {
      flext::buffer *b = ((pySamplebuffer *)obj)->buf;
***************
*** 208,212 ****
--- 221,229 ----
  }
  
+ #if PY_VERSION_HEX >= 0x02050000
+ static Py_ssize_t buffer_charbuffer(PyObject *obj, Py_ssize_t segment, char **ptrptr)
+ #else
  static int buffer_charbuffer(PyObject *obj, int segment, const char **ptrptr)
+ #endif
  {
      flext::buffer *b = ((pySamplebuffer *)obj)->buf;

Index: main.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/main.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** main.h	19 Jul 2005 13:18:33 -0000	1.43
--- main.h	6 Jul 2007 21:44:56 -0000	1.44
***************
*** 29,33 ****
  
  class FifoEl
!     : public Fifo::Cell
  {
  public:
--- 29,33 ----
  
  class FifoEl
!     : public FifoCell
  {
  public:

Index: pybase.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pybase.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** pybase.h	7 Mar 2007 13:40:14 -0000	1.13
--- pybase.h	6 Jul 2007 21:44:56 -0000	1.14
***************
*** 109,113 ****
  	static PyObject *module_obj,*module_dict;
  	static PyObject *builtins_obj,*builtins_dict;
! 	static PyMethodDef func_tbl[];
  
  	static PyObject *py__doc__(PyObject *,PyObject *args);
--- 109,113 ----
  	static PyObject *module_obj,*module_dict;
  	static PyObject *builtins_obj,*builtins_dict;
! 	static PyMethodDef func_tbl[],attr_tbl[];
  
  	static PyObject *py__doc__(PyObject *,PyObject *args);
***************
*** 121,124 ****
--- 121,127 ----
  	static PyObject *py_blocksize(PyObject *,PyObject *args);
  
+ 	static PyObject *py_searchpaths(PyObject *,PyObject *args);
+ 	static PyObject *py_helppaths(PyObject *,PyObject *args);
+ 
  #if FLEXT_SYS == FLEXT_SYS_PD
  	static PyObject *py_getvalue(PyObject *,PyObject *args);

Index: pybase.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pybase.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** pybase.cpp	7 Mar 2007 13:40:14 -0000	1.18
--- pybase.cpp	6 Jul 2007 21:44:56 -0000	1.19
***************
*** 130,134 ****
  
  #ifdef FLEXT_DEBUG
! 	Py_DebugFlag = 1;
  //	Py_VerboseFlag = 1;
  #else
--- 130,134 ----
  
  #ifdef FLEXT_DEBUG
! //	Py_DebugFlag = 1;
  //	Py_VerboseFlag = 1;
  #else
***************
*** 200,203 ****
--- 200,212 ----
  
  	// -------------------------------------------------------------
+ #ifdef PY_USE_INOFFICIAL
+     // add PD paths
+ 
+     char *dir;
+     for(int i = 0; (dir = namelist_get(sys_searchpath,i)) != NULL; ++i) {
+         AddToPath(dir);
+     }
+ #endif
+ 	// -------------------------------------------------------------
  
  	FLEXT_SETUP(pyobj);

Index: py.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/py.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** py.cpp	7 Mar 2007 13:40:14 -0000	1.36
--- py.cpp	6 Jul 2007 21:44:56 -0000	1.37
***************
*** 189,192 ****
--- 189,193 ----
  pyobj::~pyobj() 
  {
+     ThrState state = PyLockSys();
      if(objects) {
          for(int i = 0; i < CntIn()-1; ++i) Py_DECREF(objects[i]);
***************
*** 194,198 ****
      }
      
-     ThrState state = PyLockSys();
  	Unregister(GetRegistry(REGNAME));
      Report();
--- 195,198 ----





More information about the Pd-cvs mailing list