aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/pybindings.cc1
-rw-r--r--common/pywrappers.h30
2 files changed, 31 insertions, 0 deletions
diff --git a/common/pybindings.cc b/common/pybindings.cc
index dad8e5c7..547d9b62 100644
--- a/common/pybindings.cc
+++ b/common/pybindings.cc
@@ -241,6 +241,7 @@ void init_python(const char *executable, bool first)
Py_Initialize();
if (first)
PyImport_ImportModule(TOSTRING(MODULE_NAME));
+ PyRun_SimpleString("from " TOSTRING(MODULE_NAME) " import *");
} catch (boost::python::error_already_set const &) {
// Parse and output the exception
std::string perror_str = parse_python_exception();
diff --git a/common/pywrappers.h b/common/pywrappers.h
index b564eb59..b9ed807d 100644
--- a/common/pywrappers.h
+++ b/common/pywrappers.h
@@ -250,6 +250,11 @@ template <typename Class, typename FuncT, FuncT fn, typename arg1_conv> struct f
}
template <typename WrapCls> static void def_wrap(WrapCls cls_, const char *name) { cls_.def(name, wrapped_fn); }
+
+ template <typename WrapCls, typename Ta> static void def_wrap(WrapCls cls_, const char *name, Ta a = arg("arg1"))
+ {
+ cls_.def(name, wrapped_fn, a);
+ }
};
// Two parameters, one return
@@ -267,6 +272,11 @@ template <typename Class, typename FuncT, FuncT fn, typename arg1_conv, typename
}
template <typename WrapCls> static void def_wrap(WrapCls cls_, const char *name) { cls_.def(name, wrapped_fn); }
+
+ template <typename WrapCls, typename Ta> static void def_wrap(WrapCls cls_, const char *name, const Ta &a)
+ {
+ cls_.def(name, wrapped_fn, a);
+ }
};
// Three parameters, no return
@@ -286,6 +296,11 @@ struct fn_wrapper_3a_v
}
template <typename WrapCls> static void def_wrap(WrapCls cls_, const char *name) { cls_.def(name, wrapped_fn); }
+
+ template <typename WrapCls, typename Ta> static void def_wrap(WrapCls cls_, const char *name, const Ta &a)
+ {
+ cls_.def(name, wrapped_fn, a);
+ }
};
// Four parameters, no return
@@ -309,6 +324,11 @@ struct fn_wrapper_4a_v
}
template <typename WrapCls> static void def_wrap(WrapCls cls_, const char *name) { cls_.def(name, wrapped_fn); }
+
+ template <typename WrapCls, typename Ta> static void def_wrap(WrapCls cls_, const char *name, const Ta &a)
+ {
+ cls_.def(name, wrapped_fn, a);
+ }
};
// Five parameters, no return
@@ -333,6 +353,11 @@ struct fn_wrapper_5a_v
}
template <typename WrapCls> static void def_wrap(WrapCls cls_, const char *name) { cls_.def(name, wrapped_fn); }
+
+ template <typename WrapCls, typename Ta> static void def_wrap(WrapCls cls_, const char *name, const Ta &a)
+ {
+ cls_.def(name, wrapped_fn, a);
+ }
};
// Six parameters, no return
@@ -358,6 +383,11 @@ struct fn_wrapper_6a_v
}
template <typename WrapCls> static void def_wrap(WrapCls cls_, const char *name) { cls_.def(name, wrapped_fn); }
+
+ template <typename WrapCls, typename Ta> static void def_wrap(WrapCls cls_, const char *name, const Ta &a)
+ {
+ cls_.def(name, wrapped_fn, a);
+ }
};
// Wrapped getter