diff --git a/CMakeLists.txt b/CMakeLists.txt index 1552ff6..8af3c48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 5.2.41) +set(BLT_VERSION 5.2.42) set(BLT_TARGET BLT) diff --git a/include/blt/std/memory_util.h b/include/blt/std/memory_util.h index c2041a4..ede9020 100644 --- a/include/blt/std/memory_util.h +++ b/include/blt/std/memory_util.h @@ -201,18 +201,26 @@ namespace blt::mem static constexpr std::size_t make_storage_ones() { + #ifdef __EMSCRIPTEN__ + return ~static_cast(0); + #else std::size_t result = 0; for (std::size_t i = START_BIT; i < END_BIT; i++) result |= 1ul << i; return result; + #endif } static constexpr std::size_t make_ptr_ones() { + #ifdef __EMSCRIPTEN__ + return ~static_cast(0); + #else std::size_t result = 0; for (std::size_t i = 0; i < START_BIT; i++) result |= 1ul << i; return result; + #endif } bit_storage(): bits(0) @@ -263,16 +271,19 @@ namespace blt::mem pointer_storage& bit(const std::size_t index, const bool b) noexcept { + #ifndef __EMSCRIPTEN__ if (index >= bit_storage::END_BIT) return *this; ptr_bits &= ~(1ul << (bit_storage::START_BIT + index)); ptr_bits |= (static_cast(b) << (bit_storage::START_BIT + index)); + #endif return *this; } template, bool> = false> pointer_storage& storage(const T& type) { + #ifndef __EMSCRIPTEN__ static_assert(sizeof(T) <= sizeof(std::uintptr_t), "Type takes too many bits to be stored!"); static constexpr std::uintptr_t store_bits = (2 << (bit_storage::AVAILABLE_BITS - 1)) - 1; std::uintptr_t bit_store = 0; @@ -280,12 +291,15 @@ namespace blt::mem std::memcpy(&bit_store, &type, sizeof(T)); store.bits |= bit_store & store_bits; storage(store); + #endif return *this; } pointer_storage& storage(const bit_storage bits) noexcept { + #ifndef __EMSCRIPTEN__ ptr_bits = ((ptr_bits & PTR_ALL_ONES) | (static_cast(bits.bits) << bit_storage::START_BIT)); + #endif return *this; } diff --git a/libraries/parallel-hashmap b/libraries/parallel-hashmap index 8a889d3..154c634 160000 --- a/libraries/parallel-hashmap +++ b/libraries/parallel-hashmap @@ -1 +1 @@ -Subproject commit 8a889d3699b3c09ade435641fb034427f3fd12b6 +Subproject commit 154c63489e84d5569d3b466342a2ae8fd99e4734 diff --git a/src/blt/parse/argparse_v2.cpp b/src/blt/parse/argparse_v2.cpp index 5694868..503f991 100644 --- a/src/blt/parse/argparse_v2.cpp +++ b/src/blt/parse/argparse_v2.cpp @@ -313,7 +313,7 @@ namespace blt::argparse break; case action_t::COUNT: set_nargs(0); - as_type(); + as_type(); break; case action_t::EXTEND: set_nargs(nargs_t::ALL); @@ -1176,14 +1176,14 @@ namespace blt::argparse argument_parser_t parser; parser.add_flag("-a").set_action(action_t::STORE_TRUE); parser.add_flag("+b").set_action(action_t::STORE_FALSE); - parser.add_flag("/c").as_type().set_action(action_t::STORE); + parser.add_flag("/c").as_type().set_action(action_t::STORE); const std::vector args = {"./program", "-a", "+b", "/c", "42"}; const auto parsed_args = parser.parse(args); BLT_ASSERT(parsed_args.get("-a") == true && "Flag '-a' should store `true`"); BLT_ASSERT(parsed_args.get("+b") == false && "Flag '+b' should store `false`"); - BLT_ASSERT(parsed_args.get("/c") == 42 && "Flag '/c' should store the value 42"); + BLT_ASSERT(parsed_args.get("/c") == 42 && "Flag '/c' should store the value 42"); } // Test: Invalid flag prefixes @@ -1208,12 +1208,12 @@ namespace blt::argparse void test_compound_flags() { argument_parser_t parser; - parser.add_flag("-v").as_type().set_action(action_t::COUNT); + parser.add_flag("-v").set_action(action_t::COUNT); const std::vector args = {"./program", "-vvv"}; const auto parsed_args = parser.parse(args); - BLT_ASSERT(parsed_args.get("-v") == 3 && "Flag '-v' should count occurrences in compound form"); + BLT_ASSERT(parsed_args.get("-v") == 3 && "Flag '-v' should count occurrences in compound form"); } void test_combination_of_valid_and_invalid_flags()