[PD-cvs] externals/grill/py/source clmeth.cpp, 1.18, 1.19 main.cpp, 1.33, 1.34 main.h, 1.38, 1.39 modmeth.cpp, 1.18, 1.19 py.cpp, 1.23, 1.24 pybuffer.cpp, 1.6, 1.7 pydsp.cpp, 1.3, 1.4 pyext.cpp, 1.32, 1.33

Thomas Grill xovo at users.sourceforge.net
Mon Apr 11 00:24:15 CEST 2005


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

Modified Files:
	clmeth.cpp main.cpp main.h modmeth.cpp py.cpp pybuffer.cpp 
	pydsp.cpp pyext.cpp 
Log Message:
added xcode project
cleaner error reporting
added generic numpy support (not working)
use lock count instead of message queuing to avoid py->py messaging deadlock
fixing strange gcc behavior
fixes for maxmsp
support for buffer objects (preliminary)
fixed reference count bug
use optimized version
updates for DSP processing
adjust pd and py files for correct argument passing
more optimizations
fixed numarray headers
little restructuring


Index: clmeth.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/clmeth.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** clmeth.cpp	7 Apr 2005 15:03:52 -0000	1.18
--- clmeth.cpp	10 Apr 2005 22:24:13 -0000	1.19
***************
*** 81,85 ****
  PyObject* pyext::pyext_setattr(PyObject *,PyObject *args)
  {
!     PyObject *self,*name,*val,*ret = NULL;
      if(!PyArg_ParseTuple(args, "OOO:test_foo", &self,&name,&val)) {
          // handle error
--- 81,85 ----
  PyObject* pyext::pyext_setattr(PyObject *,PyObject *args)
  {
!     PyObject *self,*name,*val;
      if(!PyArg_ParseTuple(args, "OOO:test_foo", &self,&name,&val)) {
          // handle error

Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/main.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** main.cpp	31 Mar 2005 03:54:10 -0000	1.33
--- main.cpp	10 Apr 2005 22:24:13 -0000	1.34
***************
*** 161,168 ****
  
  pybase::pybase()
!     : module(NULL),detach(0)
  #ifdef FLEXT_THREADS
      , shouldexit(false),thrcount(0),stoptick(0)
  #endif
  {
      PyThreadState *state = PyLockSys();
--- 161,169 ----
  
  pybase::pybase()
!     : module(NULL)
  #ifdef FLEXT_THREADS
      , shouldexit(false),thrcount(0),stoptick(0)
  #endif
+ 	, detach(0)
  {
      PyThreadState *state = PyLockSys();
***************
*** 245,249 ****
  				else {
  					// copy string before newline to temp buffer and post
! 					int l = nl-s;
  					if(l >= sizeof(buf)) l = sizeof buf-1;
  					strncpy(buf,s,l); // copy all but newline
--- 246,250 ----
  				else {
  					// copy string before newline to temp buffer and post
! 					unsigned int l = nl-s;
  					if(l >= sizeof(buf)) l = sizeof buf-1;
  					strncpy(buf,s,l); // copy all but newline

Index: modmeth.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/modmeth.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** modmeth.cpp	31 Mar 2005 03:54:11 -0000	1.18
--- modmeth.cpp	10 Apr 2005 22:24:13 -0000	1.19
***************
*** 20,23 ****
--- 20,24 ----
  #endif
  
+ 	{ "_arraysupport", pybase::py_arraysupport, METH_NOARGS,"Query Python array support" },
  	{ "_samplerate", pybase::py_samplerate, METH_NOARGS,"Get system sample rate" },
  	{ "_blocksize", pybase::py_blocksize, METH_NOARGS,"Get system block size" },

Index: pyext.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pyext.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** pyext.cpp	7 Apr 2005 15:03:53 -0000	1.32
--- pyext.cpp	10 Apr 2005 22:24:13 -0000	1.33
***************
*** 98,102 ****
  	// remember the this pointer
  	PyObject *th = PyLong_FromVoidPtr(this); 
! 	int ret = PyObject_SetAttrString(pyobj,"_this",th); // ref is taken
  }
  
--- 98,102 ----
  	// remember the this pointer
  	PyObject *th = PyLong_FromVoidPtr(this); 
! 	/*int ret =*/ PyObject_SetAttrString(pyobj,"_this",th); // ref is taken
  }
  
***************
*** 106,113 ****
  
  pyext::pyext(int argc,const t_atom *argv,bool sig):
! 	pyobj(NULL),pythr(NULL),
  	inlets(-1),outlets(-1),
      siginlets(0),sigoutlets(0),
! 	methname(NULL)
  { 
  #ifdef FLEXT_THREADS
--- 106,114 ----
  
  pyext::pyext(int argc,const t_atom *argv,bool sig):
! 	methname(NULL),
! 	pyobj(NULL),
  	inlets(-1),outlets(-1),
      siginlets(0),sigoutlets(0),
! 	pythr(NULL)
  { 
  #ifdef FLEXT_THREADS

Index: pybuffer.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pybuffer.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pybuffer.cpp	31 Mar 2005 03:54:11 -0000	1.6
--- pybuffer.cpp	10 Apr 2005 22:24:13 -0000	1.7
***************
*** 16,35 ****
  #if defined(PY_NUMERIC)
      #define PY_ARRAYS 1
- 
-     #if FLEXT_OS == FLEXT_OS_MAC
-     #include <Python/Numeric/arrayobject.h>
-     #else
-     #include <Numeric/arrayobject.h>
-     #endif
  #elif defined(PY_NUMARRAY)
      #define PY_ARRAYS 1
      #define NA
  
  #ifdef NA
      #if FLEXT_OS == FLEXT_OS_MAC
!     #include <Python/numarray/numarray.h>
      #else
!     #include <numarray/numarray.h>
      #endif
  #else
      #if FLEXT_OS == FLEXT_OS_MAC
--- 16,36 ----
  #if defined(PY_NUMERIC)
      #define PY_ARRAYS 1
  #elif defined(PY_NUMARRAY)
      #define PY_ARRAYS 1
      #define NA
+ #endif
+ 
+ #ifdef PY_ARRAYS
  
  #ifdef NA
      #if FLEXT_OS == FLEXT_OS_MAC
!     #include <Python/numarray/libnumarray.h>
      #else
!     #include <numarray/libnumarray.h>
      #endif
+ 
+ static NumarrayType numtype = tAny;
+ inline bool arrsupport() { return numtype != tAny; }
+ 
  #else
      #if FLEXT_OS == FLEXT_OS_MAC
***************
*** 38,56 ****
      #include <numarray/arrayobject.h>
      #endif
  #endif
  #endif
  
  
  #ifdef PY_ARRAYS
! 
! #ifdef NA
! static NumarrayType numtype = tAny;
! inline bool arrsupport() { return numtype != tAny; }
  #else
! static PyArray_TYPES numtype = PyArray_NOTYPE;
! inline bool arrsupport() { return numtype != PyArray_NOTYPE; }
! #endif
! 
  #endif
  
  
--- 39,60 ----
      #include <numarray/arrayobject.h>
      #endif
+ 
+ static PyArray_TYPES numtype = PyArray_NOTYPE;
+ inline bool arrsupport() { return numtype != PyArray_NOTYPE; }
  #endif
  #endif
  
  
+ PyObject *pybase::py_arraysupport(PyObject *self,PyObject *args)
+ {
+ 	PyObject *ret;
  #ifdef PY_ARRAYS
! 	ret = Py_True;
  #else
! 	ret = Py_False;
  #endif
+ 	Py_INCREF(ret);
+ 	return ret;
+ }
  
  
***************
*** 409,419 ****
  
  static PySequenceMethods buffer_as_seq = {
! 	(inquiry)buffer_length,			/* inquiry sq_length;             /* __len__ */
  	(binaryfunc)buffer_concat,          /* __add__ */
  	(intargfunc)buffer_repeat,          /* __mul__ */
! 	(intargfunc)buffer_item,			/* intargfunc sq_item;            /* __getitem__ */
! 	(intintargfunc)buffer_slice,		 /* intintargfunc sq_slice;        /* __getslice__ */
! 	(intobjargproc)buffer_ass_item,		/* intobjargproc sq_ass_item;     /* __setitem__ */
! 	(intintobjargproc)buffer_ass_slice,	/* intintobjargproc sq_ass_slice; /* __setslice__ */
  };
  
--- 413,423 ----
  
  static PySequenceMethods buffer_as_seq = {
! 	(inquiry)buffer_length,			/* inquiry sq_length;             __len__ */
  	(binaryfunc)buffer_concat,          /* __add__ */
  	(intargfunc)buffer_repeat,          /* __mul__ */
! 	(intargfunc)buffer_item,			/* intargfunc sq_item;            __getitem__ */
! 	(intintargfunc)buffer_slice,		 /* intintargfunc sq_slice;        __getslice__ */
! 	(intobjargproc)buffer_ass_item,		/* intobjargproc sq_ass_item;     __setitem__ */
! 	(intintobjargproc)buffer_ass_slice,	/* intintobjargproc sq_ass_slice; __setslice__ */
  };
  

Index: pydsp.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pydsp.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** pydsp.cpp	25 Mar 2005 04:54:17 -0000	1.3
--- pydsp.cpp	10 Apr 2005 22:24:13 -0000	1.4
***************
*** 48,55 ****
  	{ 
          dspfun = PyObject_GetAttrString(pyobj,"_dsp"); // get ref
! 	    if(dspfun && !PyMethod_Check(dspfun)) {
              Py_DECREF(dspfun);
  		    dspfun = NULL;
! 	    }
  	}
      return true;
--- 48,57 ----
  	{ 
          dspfun = PyObject_GetAttrString(pyobj,"_dsp"); // get ref
! 	    if(!dspfun)
! 			PyErr_Clear();
! 		else if(!PyMethod_Check(dspfun)) {
              Py_DECREF(dspfun);
  		    dspfun = NULL;
! 		}
  	}
      return true;
***************
*** 119,126 ****
          NewBuffers();
  
          if(dspfun) {
              PyObject *ret = PyObject_CallObject(dspfun,NULL);
!             if(ret)
                  Py_DECREF(ret);
              else {
  #ifdef FLEXT_DEBUG
--- 121,131 ----
          NewBuffers();
  
+ 		bool dodsp = true;
          if(dspfun) {
              PyObject *ret = PyObject_CallObject(dspfun,NULL);
!             if(ret) {
! 				dodsp = PyObject_IsTrue(ret);
                  Py_DECREF(ret);
+ 			}
              else {
  #ifdef FLEXT_DEBUG
***************
*** 136,144 ****
          // optimizations may be done there to assign the right _signal version
          Py_XDECREF(sigfun);
!         sigfun = PyObject_GetAttrString(pyobj,"_signal"); // get ref
! 	    if(sigfun && !PyMethod_Check(sigfun)) {
!             Py_DECREF(sigfun);
! 		    sigfun = NULL;
! 	    }
  
          PyUnlock(state);
--- 141,156 ----
          // optimizations may be done there to assign the right _signal version
          Py_XDECREF(sigfun);
! 		
! 		if(dodsp) {
! 			sigfun = PyObject_GetAttrString(pyobj,"_signal"); // get ref
! 			if(!sigfun)
! 				PyErr_Clear();
! 			else if(!PyMethod_Check(sigfun)) {
! 				Py_DECREF(sigfun);
! 				sigfun = NULL;
! 			}
! 		}
! 		else
! 			sigfun = NULL;
  
          PyUnlock(state);

Index: main.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/main.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** main.h	31 Mar 2005 03:54:11 -0000	1.38
--- main.h	10 Apr 2005 22:24:13 -0000	1.39
***************
*** 108,111 ****
--- 108,112 ----
  #endif
  
+ 	static PyObject *py_arraysupport(PyObject *,PyObject *args);
  	static PyObject *py_samplerate(PyObject *,PyObject *args);
  	static PyObject *py_blocksize(PyObject *,PyObject *args);

Index: py.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/py.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** py.cpp	7 Apr 2005 15:03:53 -0000	1.23
--- py.cpp	10 Apr 2005 22:24:13 -0000	1.24
***************
*** 123,127 ****
  
  pyobj::pyobj(int argc,const t_atom *argv):
! 	function(NULL),funname(NULL),withfunction(false)
  { 
  	AddInAnything(2);  
--- 123,127 ----
  
  pyobj::pyobj(int argc,const t_atom *argv):
! 	funname(NULL),function(NULL),withfunction(false)
  { 
  	AddInAnything(2);  





More information about the Pd-cvs mailing list