From 55fb3a9221ea91453573453288ecedb6ea79b7ba Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 7 Nov 2026 17:30:41 +0100 Subject: Creating out of source doc files --- modules/remote/c++/remote.hpp | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'modules/remote/c++/remote.hpp') diff --git a/modules/remote/c++/remote.hpp b/modules/remote/c++/remote.hpp index 83e6042..62d79c9 100644 --- a/modules/remote/c++/remote.hpp +++ b/modules/remote/c++/remote.hpp @@ -5,6 +5,7 @@ #include #include +#include #include @@ -99,6 +100,61 @@ struct tmpl_group_to_data_client_std_tuple, Encoding, Remote> { using type = std::tuple...>; }; } +/** + * Identifier of an interface function on the wire. + * + * Keyed on the member name instead of the member index, so reordering an + * interface doesn't silently rebind calls between versions. + */ +template +struct rpc_function_id { + static constexpr uint32_t value = hash_literal::apply(0u); +}; + +namespace impl { +/** + * Translates a runtime function id back into the compile time member name + * of an interface. + * + * Needed by every backend where the called function arrives as data instead + * of as a template argument. + */ +template +struct iface_dispatch { + static_assert(always_false, "Expecting an Interface Type"); +}; + +template +struct iface_dispatch...>> { + template + static Ret apply_ele(uint32_t func_id, Func& func){ + if constexpr ( i < sizeof...(Names) ){ + constexpr string_literal Lit = parameter_key_pack_type::literal; + + if(func_id == rpc_function_id::value){ + return func.template operator()(); + } + + return apply_ele(func_id, func); + } else { + (void) func_id; + (void) func; + return make_error("No interface member with this function id"); + } + } + + /** + * Calls func.operator()() for the member matching the id. + * The return type has to be provided, since there is no member to + * deduce it from if the id doesn't match anything. + */ + template + static Ret apply(uint32_t func_id, Func&& func){ + return apply_ele(func_id, func); + } +}; +} + template class i_rpc_server { protected: -- cgit v1.3.1