nicer type_caster::load() calling conventions
diff --git a/example/example11.cpp b/example/example11.cpp
index 5a91ee2..466eed4 100644
--- a/example/example11.cpp
+++ b/example/example11.cpp
@@ -19,11 +19,25 @@
std::cout << endl;
}
-void call_kw_func(py::function f) {
+py::object call_kw_func(py::function f) {
py::tuple args = py::make_tuple(1234);
py::dict kwargs;
kwargs["y"] = py::cast(5678);
- f(*args, **kwargs);
+ return f(*args, **kwargs);
+}
+
+void args_function(py::args args) {
+ for (auto item : args)
+ std::cout << "got argument: " << item << std::endl;
+}
+
+void args_kwargs_function(py::args args, py::kwargs kwargs) {
+ for (auto item : args)
+ std::cout << "got argument: " << item << std::endl;
+ if (kwargs) {
+ for (auto item : kwargs)
+ std::cout << "got keyword argument: " << item.first << " -> " << item.second << std::endl;
+ }
}
void init_ex11(py::module &m) {
@@ -38,4 +52,7 @@
m.def("kw_func4", &kw_func4, py::arg("myList") = list);
m.def("call_kw_func", &call_kw_func);
+
+ m.def("args_function", &args_function);
+ m.def("args_kwargs_function", &args_kwargs_function);
}
diff --git a/example/example11.py b/example/example11.py
index 948b0fd..ff35be2 100755
--- a/example/example11.py
+++ b/example/example11.py
@@ -6,6 +6,7 @@
sys.path.append('.')
from example import kw_func, kw_func2, kw_func3, kw_func4, call_kw_func
+from example import args_function, args_kwargs_function
print(pydoc.render_doc(kw_func, "Help on %s"))
print(pydoc.render_doc(kw_func2, "Help on %s"))
@@ -32,6 +33,9 @@
print("Caught expected exception: " + str(e))
kw_func4()
-kw_func4(myList = [1, 2, 3])
+kw_func4(myList=[1, 2, 3])
call_kw_func(kw_func2)
+
+args_function('arg1_value', 'arg2_value', 3)
+args_kwargs_function('arg1_value', 'arg2_value', arg3='arg3_value', arg4=4)
diff --git a/example/example11.ref b/example/example11.ref
index 0ce066b..4c433b7 100644
--- a/example/example11.ref
+++ b/example/example11.ref
@@ -33,3 +33,10 @@
kw_func4: 13 17
kw_func4: 1 2 3
kw_func(x=1234, y=5678)
+got argument: arg1_value
+got argument: arg2_value
+got argument: 3
+got argument: arg1_value
+got argument: arg2_value
+got keyword argument: arg3 -> arg3_value
+got keyword argument: arg4 -> 4