#include <libsig_comp.h>
- /* avoid warnigs :) */
-#include <features.h>
-#undef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 200112L
-
#include <lib/python/python.h>
class PSignal
{
protected:
ePyObject m_list;
- bool *m_destroyed;
public:
PSignal();
~PSignal();
void callPython(SWIG_PYOBJECT(ePyObject) tuple);
- PyObject *get(bool steal=false);
+#ifndef SWIG
+ PyObject *getSteal(bool clear=false);
+#endif
+ PyObject *get();
};
inline PyObject *PyFrom(int v)
public:
R operator()()
{
- bool destroyed=false;
- m_destroyed = &destroyed;
if (m_list)
{
PyObject *pArgs = PyTuple_New(0);
callPython(pArgs);
Org_Py_DECREF(pArgs);
}
- if (!destroyed) {
- m_destroyed = 0;
- return Signal0<R>::operator()();
- }
+ return Signal0<R>::operator()();
}
};
public:
R operator()(V0 a0)
{
- bool destroyed=false;
- m_destroyed = &destroyed;
if (m_list)
{
PyObject *pArgs = PyTuple_New(1);
callPython(pArgs);
Org_Py_DECREF(pArgs);
}
- if (!destroyed) {
- m_destroyed = 0;
- return Signal1<R,V0>::operator()(a0);
- }
+ return Signal1<R,V0>::operator()(a0);
}
};
public:
R operator()(V0 a0, V1 a1)
{
- bool destroyed=false;
- m_destroyed = &destroyed;
if (m_list)
{
PyObject *pArgs = PyTuple_New(2);
callPython(pArgs);
Org_Py_DECREF(pArgs);
}
- if (!destroyed) {
- m_destroyed = 0;
- return Signal2<R,V0,V1>::operator()(a0, a1);
+ return Signal2<R,V0,V1>::operator()(a0, a1);
+ }
+};
+
+template <class R, class V0, class V1, class V2>
+class PSignal3: public PSignal, public Signal3<R,V0,V1,V2>
+{
+public:
+ R operator()(V0 a0, V1 a1, V2 a2)
+ {
+ if (m_list)
+ {
+ PyObject *pArgs = PyTuple_New(3);
+ PyTuple_SET_ITEM(pArgs, 0, PyFrom(a0));
+ PyTuple_SET_ITEM(pArgs, 1, PyFrom(a1));
+ PyTuple_SET_ITEM(pArgs, 2, PyFrom(a2));
+ callPython(pArgs);
+ Org_Py_DECREF(pArgs);
}
+ return Signal3<R,V0,V1,V2>::operator()(a0, a1, a2);
}
};