summaryrefslogtreecommitdiff
path: root/src/pyutils.h
blob: 4ff33f8fdb803f78156e6b714ae25f18dfbbbd6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef _PY_UTILS_H
#define _PY_UTILS_H

template<class T, class TfromPy>
struct ObjFromPy {
  ObjFromPy() {
    boost::python::converter::registry::push_back
	  (&TfromPy::convertible,
	   &TfromPy::construct,
	   boost::python::type_id<T>());
  }
};

template<class T, class TtoPy, class TfromPy>
struct register_python_conversion {
  register_python_conversion() {
    boost::python::to_python_converter<T, TtoPy>();
    ObjFromPy<T, TfromPy>();
  }
};

#endif // _PY_UTILS_H