[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Adonthell-commits] CVS: adonthell/src/python callback.cc, 1.2, 1.3 call
From: |
Alexandre Courbot <address@hidden> |
Subject: |
[Adonthell-commits] CVS: adonthell/src/python callback.cc, 1.2, 1.3 callback.h, 1.2, 1.3 python.cc, 1.2, 1.3 python.h, 1.1.1.1, 1.2 |
Date: |
Mon, 28 Jul 2003 11:02:21 -0400 |
Update of /cvsroot/adonthell/adonthell/src/python
In directory subversions:/tmp/cvs-serv17798/src/python
Modified Files:
callback.cc callback.h python.cc python.h
Log Message:
FIXED Memory leak in the python callbacks
FIXED Uncatched errors in the python callbacks
REMOVED stupid debugging messages in surface_sdl::draw_line
CHANGED input callbacks to return booleans instead of integers
Index: callback.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/python/callback.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** callback.cc 24 Jul 2003 12:57:59 -0000 1.2
--- callback.cc 28 Jul 2003 15:02:19 -0000 1.3
***************
*** 41,45 ****
{
*((base::functor_0 *)this) = base::membertranslator_0<functor_0, void
(functor_0::*)()>(*this, &python::functor_0::run);
- Py_INCREF(callable);
}
--- 41,44 ----
Index: callback.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/python/callback.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** callback.h 24 Jul 2003 12:57:59 -0000 1.2
--- callback.h 28 Jul 2003 15:02:19 -0000 1.3
***************
*** 74,78 ****
{
*((base::functor_0ret<RT> *)this) =
base::membertranslator_0ret<RT, functor_0ret<RT>, void
(functor_0ret<RT>::*)()>(*this, &python::functor_0ret<RT>::run);
- Py_INCREF(callable);
}
--- 74,77 ----
***************
*** 109,113 ****
{
*((base::functor_1<P1>*)this) =
base::membertranslator_1<P1,functor_1<P1>,void (functor_1<P1>::*)(P1)>(*this,
&python::functor_1<P1>::run);
- Py_INCREF(callable);
}
--- 108,111 ----
***************
*** 130,134 ****
show_traceback();
! Py_XDECREF(pyargs);
Py_XDECREF(pyres);
}
--- 128,132 ----
show_traceback();
! Py_DECREF(pyargs);
Py_XDECREF(pyres);
}
***************
*** 148,152 ****
{
*((base::functor_1ret<P1, RT>*)this) =
base::membertranslator_1ret<P1,RT,functor_1ret<P1, RT>,RT (functor_1ret<P1,
RT>::*)(P1)>(*this, &python::functor_1ret<P1, RT>::run);
- Py_INCREF(callable);
}
--- 146,149 ----
***************
*** 164,171 ****
// The SetItem steals our reference to pyarg1
PyTuple_SetItem(pyargs, 0, pyarg1);
!
// We can finally call our function
pyres = PyObject_CallObject(callable, pyargs);
!
show_traceback();
--- 161,168 ----
// The SetItem steals our reference to pyarg1
PyTuple_SetItem(pyargs, 0, pyarg1);
!
// We can finally call our function
pyres = PyObject_CallObject(callable, pyargs);
!
show_traceback();
***************
*** 175,178 ****
--- 172,176 ----
{
retvalue = retrieve_instance<RT>(pyres);
+ show_traceback();
Py_XDECREF(pyres);
}
Index: python.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/python/python.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** python.cc 24 Jul 2003 12:57:59 -0000 1.2
--- python.cc 28 Jul 2003 15:02:19 -0000 1.3
***************
*** 28,34 ****
void show_traceback()
{
! if ( PyErr_Occurred() )
{
! PyErr_Print();
fflush (stderr);
}
--- 28,34 ----
void show_traceback()
{
! if (PyErr_Occurred ())
{
! PyErr_Print ();
fflush (stderr);
}
***************
*** 39,43 ****
Py_Initialize();
}
!
void cleanup()
{
--- 39,43 ----
Py_Initialize();
}
!
void cleanup()
{
***************
*** 53,57 ****
return run_string(buf);
}
!
bool run_string(const std::string & statements)
{
--- 53,57 ----
return run_string(buf);
}
!
bool run_string(const std::string & statements)
{
Index: python.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/python/python.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** python.h 18 Jul 2003 15:16:09 -0000 1.1.1.1
--- python.h 28 Jul 2003 15:02:19 -0000 1.2
***************
*** 122,125 ****
--- 122,142 ----
{
return PyInt_FromLong(arg);
+ show_traceback();
+ }
+
+ /**
+ * Specialized version of pass_instance which makes a Python boolean
+ * from a C++ one.
+ *
+ * @param arg the boolean to be passed to Python.
+ * @param own useless here.
+ *
+ * @return a Python object representing \e arg.
+ */
+ template <> inline
+ PyObject * pass_instance<bool>(bool arg, const ownership own)
+ {
+ return PyInt_FromLong((int)arg);
+ show_traceback();
}
***************
*** 137,140 ****
--- 154,158 ----
{
return PyString_FromString(arg.c_str());
+ show_traceback();
}
***************
*** 152,155 ****
--- 170,174 ----
{
return PyString_FromString((char *) arg);
+ show_traceback();
}
***************
*** 165,168 ****
--- 184,188 ----
PyObject_SetAttrString (obj, (char*)"thisown", n);
Py_DECREF(n);
+ show_traceback();
}
***************
*** 207,210 ****
--- 227,245 ----
{
return PyInt_AsLong(pyinstance);
+ show_traceback();
+ }
+
+ /**
+ * Retrieves the C++ value of a Python boolean.
+ *
+ * @param pyinstance The Python boolean to retrieve.
+ *
+ * @return C++ value of pyinstance.
+ */
+ template <> inline
+ bool retrieve_instance<bool>(PyObject * pyinstance)
+ {
+ return (bool)PyInt_AsLong(pyinstance);
+ show_traceback();
}
***************
*** 220,223 ****
--- 255,259 ----
{
return PyString_AsString(pyinstance);
+ show_traceback();
}
***************
*** 233,236 ****
--- 269,273 ----
{
return std::string(PyString_AsString(pyinstance));
+ show_traceback();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-commits] CVS: adonthell/src/python callback.cc, 1.2, 1.3 callback.h, 1.2, 1.3 python.cc, 1.2, 1.3 python.h, 1.1.1.1, 1.2,
Alexandre Courbot <address@hidden> <=