[PD-cvs] externals/grill/py/source main.h,1.20,1.21 py.cpp,1.12,1.13 pyext.cpp,1.17,1.18 pyext.h,1.14,1.15

Thomas Grill xovo at users.sourceforge.net
Sat Aug 21 06:13:50 CEST 2004


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

Modified Files:
	main.h py.cpp pyext.cpp pyext.h 
Log Message:
 ""

Index: pyext.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pyext.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** pyext.h	21 Jun 2004 14:04:15 -0000	1.14
--- pyext.h	21 Aug 2004 04:13:48 -0000	1.15
***************
*** 68,71 ****
--- 68,72 ----
  	V ClearBinding();
  	BL MakeInstance();
+ 	BL DoInit();
  
  	AtomList args;

Index: main.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/main.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** main.h	22 Jun 2004 22:45:53 -0000	1.20
--- main.h	21 Aug 2004 04:13:48 -0000	1.21
***************
*** 30,34 ****
  #endif
  
! #define PY__VERSION "0.1.3"
  
  
--- 30,34 ----
  #endif
  
! #define PY__VERSION "0.1.4pre"
  
  

Index: pyext.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/pyext.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** pyext.cpp	22 Jun 2004 22:45:53 -0000	1.17
--- pyext.cpp	21 Aug 2004 04:13:48 -0000	1.18
***************
*** 168,178 ****
  		MakeInstance();
  
!         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)) {
--- 168,192 ----
  		MakeInstance();
  
!         if(pyobj) {
!             if(inlets >= 0) {
!                 // set number of inlets
! 			    PyObject *res = PyInt_FromLong(inlets);
!                 int ret = PyObject_SetAttrString(pyobj,"_inlets",res);
!                 FLEXT_ASSERT(!ret);
!             }
!             if(outlets >= 0) {
!                 // set number of outlets
! 			    PyObject *res = PyInt_FromLong(outlets);
! 			    int ret = PyObject_SetAttrString(pyobj,"_outlets",res);
!                 FLEXT_ASSERT(!ret);
!             }
  
!             DoInit(); // call __init__ constructor
!             // __init__ can override the number of inlets and outlets
! 
!             if(inlets < 0) {
! 		        // get number of inlets
! 		        inlets = 1;
! 			    PyObject *res = PyObject_GetAttrString(pyobj,"_inlets"); // get ref
  			    if(res) {
  				    if(PyCallable_Check(res)) {
***************
*** 187,192 ****
  			    else 
  				    PyErr_Clear();
! 
! 			    res = PyObject_GetAttrString(pyobj,"_outlets"); // get ref
  			    if(res) {
  				    if(PyCallable_Check(res)) {
--- 201,209 ----
  			    else 
  				    PyErr_Clear();
!             }
!             if(outlets < 0) {
!                 // get number of outlets
!                 outlets = 1;
! 			    PyObject *res = PyObject_GetAttrString(pyobj,"_outlets"); // get ref
  			    if(res) {
  				    if(PyCallable_Check(res)) {
***************
*** 201,211 ****
  			    else
  				    PyErr_Clear();
! 		    }
          }
  	}
!     else inlets = outlets = 0;
  
  	PY_UNLOCK
  	
  	AddInAnything(1+inlets);  
  	AddOutAnything(outlets);  
--- 218,231 ----
  			    else
  				    PyErr_Clear();
!             }
          }
  	}
!     else 
!         inlets = outlets = 0;
  
  	PY_UNLOCK
  	
+     FLEXT_ASSERT(inlets >= 0 && outlets >= 0);
+ 
  	AddInAnything(1+inlets);  
  	AddOutAnything(outlets);  
***************
*** 228,231 ****
--- 248,278 ----
  }
  
+ BL pyext::DoInit()
+ {
+ 	// remember the this pointer
+ 	PyObject *th = PyLong_FromVoidPtr(this); 
+ 	int ret = PyObject_SetAttrString(pyobj,"_this",th); // ref is taken
+ 
+ 	// call init now, after _this has been set, which is
+ 	// important for eventual callbacks from __init__ to c
+ 	PyObject *pargs = MakePyArgs(NULL,args.Count(),args.Atoms(),-1,true);
+ 	if(!pargs) PyErr_Print();
+ 
+ 	PyObject *init = PyObject_GetAttrString(pyobj,"__init__"); // get ref
+     if(init) {
+         if(PyCallable_Check(init)) {
+ 			PyObject *res = PyEval_CallObject(init,pargs);
+ 			if(!res)
+ 				PyErr_Print();
+ 			else
+ 				Py_DECREF(res);
+         }
+         Py_DECREF(init);
+ 	}
+     
+ 	Py_XDECREF(pargs);
+     return true;
+ }
+ 
  BL pyext::MakeInstance()
  {
***************
*** 241,272 ****
  			    pyobj = PyInstance_NewRaw(pref,NULL);
  
! 			    if(pyobj == NULL) 
! 				    PyErr_Print();
! 			    else {
! 				    // remember the this pointer
! 				    PyObject *th = PyLong_FromVoidPtr(this); 
! 				    int ret = PyObject_SetAttrString(pyobj,"_this",th); // ref is taken
! 
! 				    // call init now, after _this has been set, which is
! 				    // important for eventual callbacks from __init__ to c
! 				    PyObject *pargs = MakePyArgs(NULL,args.Count(),args.Atoms(),-1,true);
! 				    if (pargs == NULL) 
! 						PyErr_Print();
! 
! 				    PyObject *init;
! 				    init = PyObject_GetAttrString(pyobj,"__init__"); // get ref
!                     if(init) {
!                         if(PyCallable_Check(init)) {
! 					        PyObject *res = PyEval_CallObject(init,pargs);
! 					        if(!res)
! 						        PyErr_Print();
! 					        else
! 						        Py_DECREF(res);
!                         }
!                         Py_DECREF(init);
! 				    }
!     				
! 				    Py_XDECREF(pargs);
! 			    }
              }
              else
--- 288,292 ----
  			    pyobj = PyInstance_NewRaw(pref,NULL);
  
! 			    if(!pyobj) PyErr_Print();
              }
              else

Index: py.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/source/py.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** py.cpp	21 Jun 2004 14:04:15 -0000	1.12
--- py.cpp	21 Aug 2004 04:13:48 -0000	1.13
***************
*** 128,134 ****
--- 128,137 ----
  			AddToPath(GetString(canvas_getcurrentdir()));
  #elif FLEXT_SYS == FLEXT_SYS_MAX 
+ #if FLEXT_OS == FLEXT_OS_WIN
+ #else
  			short path = patcher_myvol(thisCanvas());
  			path_topathname(path,NULL,dir); 
  			AddToPath(dir);       
+ #endif
  #else 
  	        #pragma message("Adding current dir to path is not implemented")





More information about the Pd-cvs mailing list