From b0422b73d631eba91c1738534d13d3b51de913a9 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Tue, 24 May 2022 16:07:43 +0200 Subject: [PATCH] Remove dummy 0, store the crc32 there --- include/wrenpp/detail/module_and_name.hpp | 6 ++++-- src/class_manager.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) 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() };