summaryrefslogtreecommitdiff
path: root/src/python/swig
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/swig')
-rw-r--r--src/python/swig/event.i4
-rw-r--r--src/python/swig/pyevent.cc8
-rw-r--r--src/python/swig/pyevent.hh5
3 files changed, 11 insertions, 6 deletions
diff --git a/src/python/swig/event.i b/src/python/swig/event.i
index 23bb31364..cc72794ed 100644
--- a/src/python/swig/event.i
+++ b/src/python/swig/event.i
@@ -71,6 +71,10 @@
}
}
+%typemap(out) PythonEvent* {
+ result->object = $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PythonEvent, SWIG_POINTER_NEW);
+}
+
%ignore EventQueue::schedule;
%ignore EventQueue::deschedule;
diff --git a/src/python/swig/pyevent.cc b/src/python/swig/pyevent.cc
index 6d80a00cd..d83d57cbf 100644
--- a/src/python/swig/pyevent.cc
+++ b/src/python/swig/pyevent.cc
@@ -34,10 +34,10 @@
#include "sim/async.hh"
#include "sim/eventq.hh"
-PythonEvent::PythonEvent(PyObject *obj, Priority priority)
- : Event(priority), object(obj)
+PythonEvent::PythonEvent(PyObject *code, Priority priority)
+ : Event(priority), eventCode(code)
{
- if (object == NULL)
+ if (code == NULL)
panic("Passed in invalid object");
}
@@ -49,7 +49,7 @@ void
PythonEvent::process()
{
PyObject *args = PyTuple_New(0);
- PyObject *result = PyObject_Call(object, args, NULL);
+ PyObject *result = PyObject_Call(eventCode, args, NULL);
Py_DECREF(args);
if (result) {
diff --git a/src/python/swig/pyevent.hh b/src/python/swig/pyevent.hh
index f34fbd996..f668c1d9a 100644
--- a/src/python/swig/pyevent.hh
+++ b/src/python/swig/pyevent.hh
@@ -37,9 +37,10 @@
class PythonEvent : public Event
{
private:
- PyObject *object;
-
+ PyObject *eventCode; // PyObject to call to perform event
public:
+ PyObject *object; // PyObject wrapping this PythonEvent
+
PythonEvent(PyObject *obj, Event::Priority priority);
~PythonEvent();