diff options
Diffstat (limited to 'src/pyutils.h')
-rw-r--r-- | src/pyutils.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pyutils.h b/src/pyutils.h new file mode 100644 index 00000000..4ff33f8f --- /dev/null +++ b/src/pyutils.h @@ -0,0 +1,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 |