diff --git a/include/wrenpp/detail/module_and_name.hpp b/include/wrenpp/detail/module_and_name.hpp index 7dd3bbd..4b162a7 100644 --- a/include/wrenpp/detail/module_and_name.hpp +++ b/include/wrenpp/detail/module_and_name.hpp @@ -18,6 +18,7 @@ #pragma once #include "string_bt.hpp" +#include "crc32.hpp" #include #include #include @@ -131,11 +132,12 @@ namespace wren { template constexpr ModuleAndName make_module_and_name() { using dhandy::bt::string; + using StaticStorage = detail::ModuleAndNameStaticStorage; - constexpr const char* data = detail::ModuleAndNameStaticStorage::value.data(); + constexpr const char* data = StaticStorage::value.data(); constexpr std::uint16_t s1_len = static_cast(S1.size()); constexpr std::uint16_t s2_len = static_cast(S2.size()); - constexpr std::uint32_t hash = 0; //not implemented yet + constexpr std::uint32_t hash = crc32c(data, StaticStorage::value.size()); return ModuleAndName{data, hash, s1_len, s2_len}; } diff --git a/src/class_manager.cpp b/src/class_manager.cpp index 624c51a..0756f5c 100644 --- a/src/class_manager.cpp +++ b/src/class_manager.cpp @@ -16,6 +16,7 @@ */ #include "wrenpp/class_manager.hpp" +#include "wrenpp/detail/crc32.hpp" #include namespace wren { @@ -40,7 +41,7 @@ namespace wren { ClassNameOwning::operator ModuleAndName() const { return ModuleAndName{ this->raw_buffer(), - 0, //TODO: replace with hash + crc32c(this->raw_buffer(), this->raw_buffer_size()), this->module_name().size(), this->class_name().size() };