diff options
author | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-10-16 12:52:32 +0200 |
---|---|---|
committer | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-10-16 12:52:40 +0200 |
commit | 09e164c02120f05c9364d5d9a8faad2ec0026425 (patch) | |
tree | 8125a545ab76708d2e99c2cbf4aa7d1231cdbf17 /modules/lang/c++/c_common.hpp | |
parent | 00689114da12f6ecdabcf47f6fe94ee80b7c8d15 (diff) |
Dangling changes
Diffstat (limited to 'modules/lang/c++/c_common.hpp')
-rw-r--r-- | modules/lang/c++/c_common.hpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/modules/lang/c++/c_common.hpp b/modules/lang/c++/c_common.hpp index 6999126..968c4c0 100644 --- a/modules/lang/c++/c_common.hpp +++ b/modules/lang/c++/c_common.hpp @@ -4,4 +4,53 @@ namespace saw { namespace lang { struct RemoteC {}; } + +namespace lang_c { +struct config { + std::string prefix; +}; + +struct transfer_binding_state { + struct info { + std::string type; + }; + + std::map<uint32_t, binding_state::info> hashes; + + struct transpiled_element { + uint32_t crc32; + std::string header; + std::string source; + }; + + std::vector<transfer_binding_state::transpiled_element> tp_elements; + + error_or<uint64_t> find_id_by_crc32(uint32_t hash){ + for(uint64_t iter = 0; iter < tp_elements.size(); ++iter){ + if(tp_elements.at(iter).crc32 == hash){ + return iter; + } + } + + return make_error<err::not_found>(); + } + + error_or<uint64_t> add_tp_element(uint32_t hash){ + uint64_t id{}; + + try { + language_binding_state::transpiled_element ele; + + ele.crc32 = hash; + + id = tp_elements.size(); + tp_elements.emplace_back(std::move(ele)); + }catch(const std::exception&){ + return make_error<err::out_of_memory>(); + } + + return id; + } +}; +} } |