diff --git a/include/wrenpp/detail/module_and_name.hpp b/include/wrenpp/detail/module_and_name.hpp index 1db2bfe..4bf4341 100644 --- a/include/wrenpp/detail/module_and_name.hpp +++ b/include/wrenpp/detail/module_and_name.hpp @@ -52,9 +52,11 @@ namespace wren { //spits out. class ModuleAndName { friend bool detail::deep_equal(const ModuleAndName&, const ModuleAndName&) noexcept; + template + friend consteval ModuleAndName make_module_and_name() noexcept; public: constexpr ModuleAndName(); - constexpr ModuleAndName (const char* base, ModuleAndNameHashType hash, std::size_t mod_name_len, std::size_t class_name_len); + constexpr ModuleAndName (const char* base, std::size_t mod_name_len, std::size_t class_name_len); constexpr bool operator==(const ModuleAndName& other) const noexcept; constexpr bool operator!=(const ModuleAndName& other) const noexcept; @@ -67,9 +69,10 @@ namespace wren { constexpr std::string_view module_name() const noexcept { return {module_name_char(), m_mod_name_len}; } constexpr std::string_view class_name() const noexcept { return {class_name_char(), m_class_name_len}; } constexpr const char* buffer_address() const noexcept { return m_base; } - constexpr ModuleAndNameHashType hash() const noexcept { return m_hash; } private: + constexpr ModuleAndName (const char* base, ModuleAndNameHashType hash, std::size_t mod_name_len, std::size_t class_name_len); + constexpr std::size_t raw_buffer_size() const noexcept; const char* m_base; @@ -102,6 +105,10 @@ namespace wren { ModuleAndName(nullptr, 0, 0, 0) {} + constexpr ModuleAndName::ModuleAndName (const char* base, std::size_t mod_name_len, std::size_t class_name_len) : + ModuleAndName(base, crc32c(base, mod_name_len + class_name_len + 2), mod_name_len, class_name_len) + {} + constexpr ModuleAndName::ModuleAndName (const char* base, ModuleAndNameHashType hash, std::size_t mod_name_len, std::size_t class_name_len) : m_base(base), m_hash(hash), @@ -139,7 +146,7 @@ namespace wren { } template - consteval ModuleAndName make_module_and_name() { + consteval ModuleAndName make_module_and_name() noexcept { using dhandy::bt::string; using StaticStorage = detail::ModuleAndNameStaticStorage; diff --git a/include/wrenpp/detail/type_id.hpp b/include/wrenpp/detail/type_id.hpp index 591ebc1..a7ce1ea 100644 --- a/include/wrenpp/detail/type_id.hpp +++ b/include/wrenpp/detail/type_id.hpp @@ -20,12 +20,6 @@ #include namespace wren { - //template - //[[gnu::const]] - //inline constexpr std::uint32_t type_hash() { - // return crc32c(__PRETTY_FUNCTION__); - //} - //from: //https://codereview.stackexchange.com/questions/48594/unique-type-id-no-rtti class TypeID { diff --git a/src/class_manager.cpp b/src/class_manager.cpp index ae5d0ca..56004be 100644 --- a/src/class_manager.cpp +++ b/src/class_manager.cpp @@ -16,7 +16,6 @@ */ #include "wrenpp/class_manager.hpp" -#include "wrenpp/detail/crc32.hpp" #include namespace wren { @@ -41,7 +40,6 @@ namespace wren { ClassNameOwning::operator ModuleAndName() const { return ModuleAndName{ this->raw_buffer(), - crc32c(this->raw_buffer(), this->raw_buffer_size()), this->module_name().size(), this->class_name().size() }; diff --git a/src/dynafunc_maker.cpp b/src/dynafunc_maker.cpp index 5c863bb..18b7310 100644 --- a/src/dynafunc_maker.cpp +++ b/src/dynafunc_maker.cpp @@ -119,7 +119,7 @@ namespace wren { source_mem = &*dst.insert(it_found, std::move(new_entry)); } - return {source_mem->data(), 0, mod_name.size(), cls_name.size()}; + return {source_mem->data(), mod_name.size(), cls_name.size()}; } } //unnamed namespace