1 #ifndef __lib_python_connections_h
2 #define __lib_python_connections_h
4 #include <libsig_comp.h>
9 #define _POSIX_C_SOURCE 200112L
11 #include <lib/python/python.h>
20 m_list = PyList_New(0);
28 void callPython(PyObject *tuple)
30 int size = PyList_Size(m_list);
32 for (i=0; i<size; ++i)
34 PyObject *b = PyList_GET_ITEM(m_list, i);
35 ePython::call(b, tuple);
40 PyObject *get() { Py_INCREF(m_list); return m_list; }
44 class PSignal0: public PSignal, public Signal0<R>
49 PyObject *pArgs = PyTuple_New(0);
52 return Signal0<R>::operator()();
56 template <class R, class V0>
57 class PSignal1: public PSignal, public Signal1<R,V0>
62 PyObject *pArgs = PyTuple_New(1);
63 PyTuple_SET_ITEM(pArgs, 0, PyInt_FromLong(a0));
66 return Signal1<R,V0>::operator()(a0);
70 template <class R, class V0>
71 class PSignal1Str: public PSignal, public Signal1<R,V0>
76 PyObject *pArgs = PyTuple_New(1);
77 PyTuple_SET_ITEM(pArgs, 0, PyString_FromString(a0));
80 return Signal1<R,V0>::operator()(a0);
84 template <class R, class V0, class V1>
85 class PSignal2: public PSignal, public Signal2<R,V0,V1>
88 R operator()(V0 a0, V1 a1)
90 PyObject *pArgs = PyTuple_New(2);
91 PyTuple_SET_ITEM(pArgs, 0, PyInt_FromLong(a0));
92 PyTuple_SET_ITEM(pArgs, 1, PyInt_FromLong(a1));
95 return Signal2<R,V0,V1>::operator()(a0, a1);