1 #ifndef __lib_python_connections_h
2 #define __lib_python_connections_h
4 #include <libsig_comp.h>
9 #define _POSIX_C_SOURCE 200112L
10 #include <lib/python/python.h>
19 m_list = PyList_New(0);
27 void callPython(PyObject *tuple)
29 int size = PyList_Size(m_list);
31 for (i=0; i<size; ++i)
33 PyObject *b = PyList_GET_ITEM(m_list, i);
34 ePython::call(b, tuple);
39 PyObject *get() { Py_INCREF(m_list); return m_list; }
42 inline PyObject *PyFrom(int v)
44 return PyInt_FromLong(v);
47 inline PyObject *PyFrom(const char *c)
49 return PyString_FromString(c);
53 class PSignal0: public PSignal, public Signal0<R>
58 PyObject *pArgs = PyTuple_New(0);
61 return Signal0<R>::operator()();
65 template <class R, class V0>
66 class PSignal1: public PSignal, public Signal1<R,V0>
71 PyObject *pArgs = PyTuple_New(1);
72 PyTuple_SET_ITEM(pArgs, 0, PyFrom(a0));
75 return Signal1<R,V0>::operator()(a0);
79 template <class R, class V0, class V1>
80 class PSignal2: public PSignal, public Signal2<R,V0,V1>
83 R operator()(V0 a0, V1 a1)
85 PyObject *pArgs = PyTuple_New(2);
86 PyTuple_SET_ITEM(pArgs, 0, PyFrom(a0));
87 PyTuple_SET_ITEM(pArgs, 1, PyFrom(a1));
90 return Signal2<R,V0,V1>::operator()(a0, a1);