Author: KirkMcDonald
Date: 2008-01-04 09:53:09 +0000 (Fri, 04 Jan 2008)
New Revision: 747
Modified:
trunk/pysoy/examples/collide_blocks.py
trunk/pysoy/include/py.pxd
trunk/pysoy/src/_core-common/_eventLoop.pxi
trunk/pysoy/src/_core-w32/soy._core.pxd
trunk/pysoy/src/_core-x11/soy._core.pxd
trunk/pysoy/src/actions/Callback.pxi
trunk/pysoy/src/actions/soy.actions.pyx
Log:
Some more callback progress (and a bunch of printfs).
Modified: trunk/pysoy/examples/collide_blocks.py
===================================================================
--- trunk/pysoy/examples/collide_blocks.py 2008-01-04 09:08:25 UTC (rev
746)
+++ trunk/pysoy/examples/collide_blocks.py 2008-01-04 09:53:09 UTC (rev
747)
@@ -28,6 +28,9 @@
key['V'] = soy.actions.Force(bks['teal'], 0, 0, 100)
key['q'] = soy.actions.Quit()
key[ 1 ] = soy.actions.Quit() # 9 = esc key
+def foo():
+ print 'foo!'
+key['p'] = soy.actions.Callback(foo)
wcn = soy.controllers.Window(win)
wcn['close'] = soy.actions.Quit()
Modified: trunk/pysoy/include/py.pxd
===================================================================
--- trunk/pysoy/include/py.pxd 2008-01-04 09:08:25 UTC (rev 746)
+++ trunk/pysoy/include/py.pxd 2008-01-04 09:53:09 UTC (rev 747)
@@ -37,6 +37,8 @@
void PyEval_ReleaseLock()
void PyEval_InitThreads()
+ object PyObject_CallObject(object, object)
+
cdef extern from "pythread.h" :
ctypedef void *PyThread_type_lock
void PyThread_init_thread()
Modified: trunk/pysoy/src/_core-common/_eventLoop.pxi
===================================================================
--- trunk/pysoy/src/_core-common/_eventLoop.pxi 2008-01-04 09:08:25 UTC (rev
746)
+++ trunk/pysoy/src/_core-common/_eventLoop.pxi 2008-01-04 09:53:09 UTC (rev
747)
@@ -18,6 +18,7 @@
# $Id$
cimport glib
+cimport py
cimport stdio
cimport soy.transports
@@ -26,8 +27,18 @@
cdef soy._datatypes.AsyncQueue _queue
_queue = soy._datatypes.AsyncQueue()
+cdef soy._datatypes.AsyncQueue _get_queue():
+ stdio.printf("_get_queue()\n")
+ return _queue
+
cdef void _eventLoop() :
cdef void* callb
while (1) :
callb = _queue._pop()
- stdio.printf("got callback: %p\n", callb)
+ stdio.printf("_eventloop: got callback: %p\n", callb)
+ stdio.printf("_eventloop: callback is callable? %d\n",
<int>hasattr((<object>callb), "__call__"))
+ # Now to get this working:
+ #(<object>callb)()
+ py.Py_DECREF(<object>callb)
+ stdio.printf("_eventloop: Reference count decremented\n")
+
Modified: trunk/pysoy/src/_core-w32/soy._core.pxd
===================================================================
--- trunk/pysoy/src/_core-w32/soy._core.pxd 2008-01-04 09:08:25 UTC (rev
746)
+++ trunk/pysoy/src/_core-w32/soy._core.pxd 2008-01-04 09:53:09 UTC (rev
747)
@@ -23,6 +23,7 @@
cimport ogg
cimport py
cimport stdio
+cimport soy._datatypes
cimport soy._internals
cimport soy.colors
cimport soy.textures
@@ -30,6 +31,8 @@
cdef void _sleep ( unsigned int )
cdef double _time ( )
+cdef soy._datatypes.AsyncQueue _get_queue ( )
+
cdef class Scene :
cdef ode.dWorldID _worldID
cdef ode.dSpaceID _spaceID
Modified: trunk/pysoy/src/_core-x11/soy._core.pxd
===================================================================
--- trunk/pysoy/src/_core-x11/soy._core.pxd 2008-01-04 09:08:25 UTC (rev
746)
+++ trunk/pysoy/src/_core-x11/soy._core.pxd 2008-01-04 09:53:09 UTC (rev
747)
@@ -24,6 +24,7 @@
cimport ogg
cimport py
cimport stdio
+cimport soy._datatypes
cimport soy._internals
cimport soy.colors
cimport soy.textures
@@ -31,6 +32,8 @@
cdef void _sleep ( unsigned int )
cdef double _time ( )
+cdef soy._datatypes.AsyncQueue _get_queue ( )
+
cdef class Scene :
cdef ode.dWorldID _worldID
cdef ode.dSpaceID _spaceID
Modified: trunk/pysoy/src/actions/Callback.pxi
===================================================================
--- trunk/pysoy/src/actions/Callback.pxi 2008-01-04 09:08:25 UTC (rev
746)
+++ trunk/pysoy/src/actions/Callback.pxi 2008-01-04 09:53:09 UTC (rev
747)
@@ -17,11 +17,21 @@
#
# $Id$
+cimport soy._core
+cimport soy._datatypes
+cimport py
+
cdef class Callback (Action) :
def __cinit__(self, callback) :
self._callback = callback
cdef void _perform(self, unsigned int _duration):
- # This is pseudo-code
- callback_queue.add(self._callback)
+ cdef soy._datatypes.AsyncQueue _queue
+ stdio.printf("Callback._perform\n")
+ py.Py_INCREF(self._callback)
+ stdio.printf("Callback._perform: Incremented reference count\n")
+ _queue = soy._core._get_queue()
+ stdio.printf("Callback._perform: Got queue: %p\n", <void *>_queue)
+ _queue._push(<void *>self._callback)
+ stdio.printf("Callback._perform: Done.\n")
Modified: trunk/pysoy/src/actions/soy.actions.pyx
===================================================================
--- trunk/pysoy/src/actions/soy.actions.pyx 2008-01-04 09:08:25 UTC (rev
746)
+++ trunk/pysoy/src/actions/soy.actions.pyx 2008-01-04 09:53:09 UTC (rev
747)
@@ -27,7 +27,7 @@
cimport stdio
include "Action.pxi"
-#include "Callback.pxi"
+include "Callback.pxi"
include "Force.pxi"
include "Quit.pxi"
include "Stdout.pxi"
_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn