From 4244c69184602efff78b77ea72a5da44b650b4ad Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Fri, 26 Jul 2024 14:06:16 +0200 Subject: reworks preparing for rpc translation --- modules/tools/c++/c_rpc_gen_iface.hpp | 113 -------------------------- modules/tools/c++/lang_bind/c_rpc.hpp | 7 ++ modules/tools/c++/lang_bind/c_rpc_base.hpp | 7 ++ modules/tools/c++/lang_bind/c_rpc_headers.hpp | 7 ++ 4 files changed, 21 insertions(+), 113 deletions(-) delete mode 100644 modules/tools/c++/c_rpc_gen_iface.hpp create mode 100644 modules/tools/c++/lang_bind/c_rpc.hpp create mode 100644 modules/tools/c++/lang_bind/c_rpc_base.hpp create mode 100644 modules/tools/c++/lang_bind/c_rpc_headers.hpp (limited to 'modules/tools') diff --git a/modules/tools/c++/c_rpc_gen_iface.hpp b/modules/tools/c++/c_rpc_gen_iface.hpp deleted file mode 100644 index d91af43..0000000 --- a/modules/tools/c++/c_rpc_gen_iface.hpp +++ /dev/null @@ -1,113 +0,0 @@ -#pragma once - -#include "c_gen_iface.hpp" - -namespace saw { -namespace binding { -/** - * Language Binding for RPC Interfaces - */ -struct RpcC {}; -} - -namespace impl { -template -struct lang_bind, binding::RpcC> { - using Schema = schema::Primitive; - - static error_or generate(const language_binding_conf& cfg, language_binding_state& state){ - constexpr uint32_t hash = schema_hash::apply(); - { - std::string hash_type_str = cfg.prefix + "_" + std::to_string(hash) + "_t"; - auto emp = state.hashes.emplace(std::make_pair(hash, hash_type_str)); - if(emp.second) { - /** - * We want this id to access the vector - */ - auto& tpe = state.tp_elements; - uint64_t id; - { - auto eoid = state.add_tp_element(hash); - if(eoid.is_error()){ - return std::move(eoid.get_error()); - } - id = eoid.get_value(); - } - { - auto eov = lang_bind_helper::append_string(tpe.at(id).header, "typedef "); - if(eov.is_error()){ - return eov; - } - } - { - auto eov = lang_bind_helper::append_string(tpe.at(id).header, c_primitive_string::value.view()); - if(eov.is_error()){ - return eov; - } - } - { - auto eov = lang_bind_helper::append_string(tpe.at(id).header, " "); - if(eov.is_error()){ - return eov; - } - } - { - auto eov = lang_bind_helper::append_string(tpe.at(id).header, hash_type_str); - if(eov.is_error()){ - return eov; - } - } - { - auto eov = lang_bind_helper::append_string(tpe.at(id).header, ";\n"); - if(eov.is_error()){ - return eov; - } - } - /** - * Translation in source - */ - { - auto eov = lang_bind_helper::append_string(tpe.at(id).source, "namespace {\n"); - if(eov.is_error()){ - return eov; - } - } - { - auto eov = lang_bind_helper::append_translation_func(tpe.at(id).source, cfg.prefix, true); - if(eov.is_error()){ - return eov; - } - } - { - auto eov = lang_bind_helper::append_string(tpe.at(id).source, " {\n\tcpp_output.set(*c_input);\n"); - if(eov.is_error()){ - return eov; - } - } - { - auto eov = lang_bind_helper::append_string(tpe.at(id).source, "\treturn void_t{};\n}\n"); - if(eov.is_error()){ - return eov; - } - } - { - auto eov = lang_bind_helper::append_translation_func(tpe.at(id).source, cfg.prefix, false); - if(eov.is_error()){ - return eov; - } - } - { - auto eov = lang_bind_helper::append_string(tpe.at(id).source, " {\n\t*c_output = cpp_output.get();\n\treturn void_t{};\n}\n}"); - if(eov.is_error()){ - return eov; - } - } - - } - } - - return void_t{};l - } -}; -} -} diff --git a/modules/tools/c++/lang_bind/c_rpc.hpp b/modules/tools/c++/lang_bind/c_rpc.hpp new file mode 100644 index 0000000..75c2f7c --- /dev/null +++ b/modules/tools/c++/lang_bind/c_rpc.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include "c_rpc_types.hpp" + +namespace saw { + +} diff --git a/modules/tools/c++/lang_bind/c_rpc_base.hpp b/modules/tools/c++/lang_bind/c_rpc_base.hpp new file mode 100644 index 0000000..cddae54 --- /dev/null +++ b/modules/tools/c++/lang_bind/c_rpc_base.hpp @@ -0,0 +1,7 @@ +#pragma once + +namespace saw { +namespace lang { +struct RpcC {}; +} +} diff --git a/modules/tools/c++/lang_bind/c_rpc_headers.hpp b/modules/tools/c++/lang_bind/c_rpc_headers.hpp new file mode 100644 index 0000000..931eb2c --- /dev/null +++ b/modules/tools/c++/lang_bind/c_rpc_headers.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include "c_rpc_base.hpp" + +namespace saw { + +} -- cgit v1.2.3