summaryrefslogtreecommitdiff
path: root/modules/tools
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-07-07 00:52:46 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-07-07 00:52:46 +0200
commitc3b6eebab7b2eea4575c85ada733ad294817b5cb (patch)
tree8d600b8d0ceddff0abdfdcdc017f283dfbe79148 /modules/tools
parent614d0bf07789457a97d194c4af9cc7393f871351 (diff)
Base for rpc translation
Diffstat (limited to 'modules/tools')
-rw-r--r--modules/tools/c++/c_gen_iface.hpp2
-rw-r--r--modules/tools/c++/c_rpc_gen_iface.hpp93
2 files changed, 93 insertions, 2 deletions
diff --git a/modules/tools/c++/c_gen_iface.hpp b/modules/tools/c++/c_gen_iface.hpp
index 7dffd04..b5b704d 100644
--- a/modules/tools/c++/c_gen_iface.hpp
+++ b/modules/tools/c++/c_gen_iface.hpp
@@ -478,7 +478,7 @@ struct lang_bind<schema::Primitive<T,L>, binding::SyncC> {
}
}
- return void_t{};
+ return void_t{};l
}
};
diff --git a/modules/tools/c++/c_rpc_gen_iface.hpp b/modules/tools/c++/c_rpc_gen_iface.hpp
index a4d0a6f..d91af43 100644
--- a/modules/tools/c++/c_rpc_gen_iface.hpp
+++ b/modules/tools/c++/c_rpc_gen_iface.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "c_gen_iface.hpp"
+
namespace saw {
namespace binding {
/**
@@ -14,8 +16,97 @@ struct lang_bind<schema::Primitive<T,L>, binding::RpcC> {
using Schema = schema::Primitive<T,L>;
static error_or<void> generate(const language_binding_conf& cfg, language_binding_state& state){
+ constexpr uint32_t hash = schema_hash<Schema>::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<Schema>::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<Schema>(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<Schema>(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 make_error<err::not_implemented>();
+ return void_t{};l
}
};
}