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>
21 void callPython(SWIG_PYOBJECT(ePyObject) tuple);
22 PyObject *get(bool steal=false);
25 inline PyObject *PyFrom(int v)
27 return PyInt_FromLong(v);
30 inline PyObject *PyFrom(const char *c)
32 return PyString_FromString(c);
36 class PSignal0: public PSignal, public Signal0<R>
42 m_destroyed = &destroyed;
45 PyObject *pArgs = PyTuple_New(0);
51 return Signal0<R>::operator()();
56 template <class R, class V0>
57 class PSignal1: public PSignal, public Signal1<R,V0>
63 m_destroyed = &destroyed;
66 PyObject *pArgs = PyTuple_New(1);
67 PyTuple_SET_ITEM(pArgs, 0, PyFrom(a0));
73 return Signal1<R,V0>::operator()(a0);
78 template <class R, class V0, class V1>
79 class PSignal2: public PSignal, public Signal2<R,V0,V1>
82 R operator()(V0 a0, V1 a1)
85 m_destroyed = &destroyed;
88 PyObject *pArgs = PyTuple_New(2);
89 PyTuple_SET_ITEM(pArgs, 0, PyFrom(a0));
90 PyTuple_SET_ITEM(pArgs, 1, PyFrom(a1));
96 return Signal2<R,V0,V1>::operator()(a0, a1);