sdbus++: async: client: add generated method calls
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I47cf5bc96b545dfe3f917655b5b94db8dac9c101
diff --git a/example/calculator-client.cpp b/example/calculator-client.cpp
index 7c9eab2..78c8880 100644
--- a/example/calculator-client.cpp
+++ b/example/calculator-client.cpp
@@ -16,8 +16,7 @@
// been used to combine multiple interfaces into a single client-proxy.
{
- auto _ = co_await c.call<int64_t>(ctx, "Multiply", int64_t(7),
- int64_t(6));
+ auto _ = co_await c.multiply(ctx, 7, 6);
std::cout << "Should be 42: " << _ << std::endl;
}
@@ -27,7 +26,7 @@
}
{
- co_await c.call<>(ctx, "Clear");
+ co_await c.clear(ctx);
}
{
diff --git a/tools/meson.build b/tools/meson.build
index f7406c9..5890316 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -19,6 +19,7 @@
'sdbusplus/templates/interface.server.cpp.mako',
'sdbusplus/templates/interface.server.hpp.mako',
'sdbusplus/templates/method.md.mako',
+ 'sdbusplus/templates/method.client.hpp.mako',
'sdbusplus/templates/method.prototype.hpp.mako',
'sdbusplus/templates/property.md.mako',
'sdbusplus/templates/property.prototype.hpp.mako',
diff --git a/tools/sdbusplus/templates/interface.client.hpp.mako b/tools/sdbusplus/templates/interface.client.hpp.mako
index 8400a88..879e415 100644
--- a/tools/sdbusplus/templates/interface.client.hpp.mako
+++ b/tools/sdbusplus/templates/interface.client.hpp.mako
@@ -35,12 +35,9 @@
// indirectly through sdbusplus::async::client_t.
${interface.classname}() = delete;
- // To be replaced by generators...
- template <typename... Rs, typename... Ss>
- auto call(sdbusplus::async::context& ctx, auto& method, Ss&&... ss) const
- {
- return proxy.template call<Rs...>(ctx, method, std::forward<Ss>(ss)...);
- }
+ % for m in interface.methods:
+${m.render(loader, "method.client.hpp.mako", method=m, interface=interface)}
+ % endfor
// To be replaced by generators...
template <typename T>
diff --git a/tools/sdbusplus/templates/method.client.hpp.mako b/tools/sdbusplus/templates/method.client.hpp.mako
new file mode 100644
index 0000000..ca1c5a2
--- /dev/null
+++ b/tools/sdbusplus/templates/method.client.hpp.mako
@@ -0,0 +1,34 @@
+ /** @brief ${ method.name }
+ * ${ method.description.strip() }
+ % if len(method.parameters) != 0:
+ *
+ % for p in method.parameters:
+ * @param[in] ${p.camelCase} - ${p.description.strip()}
+ % endfor
+ % endif
+ % if len(method.returns) != 0:
+ *
+ % for r in method.returns:
+ * @return ${r.camelCase}[${r.cppTypeParam(interface.name)}] \
+- ${r.description.strip()}
+ % endfor
+ % endif
+ */
+ auto ${method.camelCase}(
+ sdbusplus::async::context& ctx\
+ % if len(method.parameters) != 0:
+,
+ % else:
+
+ % endif
+ ${method.get_parameters_str(interface)})
+ {
+ return proxy.template call<${method.returns_as_list(interface)}>(
+ ctx, "${method.name}"\
+ % if len(method.parameters) != 0:
+,
+ % else:
+
+ % endif
+ ${method.parameters_as_list()});
+ }