From 9eaa8759e024fc193ab5cca4447d63f4572b43f0 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sun, 4 Jan 2026 23:01:39 +0900 Subject: [PATCH 01/40] Initial refactor of String types. --- .../core/collections/natvis/string.natvis | 20 + .../public/ice/container/array.hxx | 24 +- .../public/ice/container/hashmap.hxx | 8 +- .../public/ice/container/impl/array_impl.inl | 36 +- .../ice/container/impl/hashmap_impl.inl | 86 ++-- .../public/ice/container/impl/queue_impl.inl | 102 ++-- .../public/ice/container/queue.hxx | 18 +- .../public/ice/container_types.hxx | 41 +- .../collections/public/ice/heap_string.hxx | 250 +++++++++ .../collections/public/ice/heap_varstring.hxx | 161 ++++++ .../code/core/collections/public/ice/sort.hxx | 48 +- .../code/core/collections/public/ice/span.hxx | 56 ++- .../collections/public/ice/static_string.hxx | 181 +++++++ .../core/collections/public/ice/string.hxx | 104 ++++ .../public/ice/string/editable_operations.hxx | 136 +++++ .../public/ice/string/heap_string.hxx | 123 ----- .../public/ice/string/heap_var_string.hxx | 4 +- .../public/ice/string/impl/heap_string.inl | 474 ------------------ .../ice/string/impl/heap_var_string.inl | 22 +- .../public/ice/string/impl/static_string.inl | 381 -------------- .../public/ice/string/impl/string.inl | 403 --------------- .../public/ice/string/impl/var_string.inl | 111 +--- .../public/ice/string/readonly_operations.hxx | 334 ++++++++++++ .../ice/string/resizable_operations.hxx | 39 ++ .../public/ice/string/static_string.hxx | 129 ----- .../collections/public/ice/string/string.hxx | 124 ----- .../public/ice/string/string_concepts.hxx | 77 +++ .../public/ice/string/var_string.hxx | 5 +- .../collections/public/ice/string_types.hxx | 211 +------- .../collections/public/ice/types/ncount.hxx | 264 ++++++++++ .../collections/public/ice/types/nindex.hxx | 198 ++++++++ .../core/collections/public/ice/varstring.hxx | 145 ++++++ .../core/collections/tests/test_array.cxx | 4 +- .../core/collections/tests/test_hashmap.cxx | 6 +- .../collections/tests/test_heap_string.cxx | 178 +++---- .../core/collections/tests/test_queue.cxx | 42 +- .../collections/tests/test_static_string.cxx | 86 ++-- .../tests/util_tracking_object.hxx | 14 +- source/code/core/core/public/ice/base.hxx | 2 +- .../code/core/core/public/ice/constants.hxx | 8 +- source/code/core/core/public/ice/types.hxx | 27 +- .../code/core/core/public/ice/types/ref.hxx | 36 ++ .../core/core/public/ice/types_extended.hxx | 9 +- source/code/core/core/public/ice/utility.hxx | 20 +- .../code/core/devui/private/devui_imgui.cxx | 18 +- .../core/devui/public/ice/devui_imgui.hxx | 8 +- .../memsys/private/mem_allocator_forward.cxx | 8 +- .../memsys/private/mem_allocator_snake.cxx | 16 +- .../public/ice/mem_allocator_forward.hxx | 2 +- .../memsys/public/ice/mem_allocator_snake.hxx | 2 +- .../code/core/memsys/public/ice/mem_data.hxx | 2 +- .../memsys/public/ice/mem_initializers.hxx | 22 +- .../code/core/memsys/public/ice/mem_utils.hxx | 10 +- .../core/modules/private/module_globals.cxx | 6 +- .../core/modules/private/module_native.cxx | 20 +- .../core/modules/private/module_register.cxx | 18 +- .../modules/public/ice/module_concepts.hxx | 2 +- .../modules/public/ice/module_negotiator.hxx | 6 +- .../core/modules/public/ice/module_query.hxx | 8 +- .../modules/public/ice/module_register.hxx | 4 +- .../core/tasks/private/task_native_thread.cxx | 8 +- .../core/tasks/private/task_native_thread.hxx | 4 +- source/code/core/tasks/private/task_queue.cxx | 10 +- .../tasks/private/task_scoped_container.cxx | 12 +- .../tasks/private/task_thread_pool_impl.cxx | 15 +- .../tasks/private/task_thread_pool_impl.hxx | 8 +- .../core/tasks/public/ice/task_container.hxx | 6 +- .../tasks/public/ice/task_debug_allocator.hxx | 2 +- .../code/core/tasks/public/ice/task_queue.hxx | 8 +- .../public/ice/task_scoped_container.hxx | 8 +- .../core/tasks/public/ice/task_thread.hxx | 4 +- .../tasks/public/ice/task_thread_pool.hxx | 10 +- .../utils/private/config/config_builder.cxx | 20 +- .../private/config/config_builder_utils.cxx | 6 +- .../private/config/config_builder_value.cxx | 2 +- .../utils/private/config/config_detail.cxx | 16 +- .../core/utils/private/config_getters.cxx | 8 +- .../code/core/utils/private/config_json.cxx | 6 +- source/code/core/utils/private/log.cxx | 2 +- source/code/core/utils/private/log_buffer.cxx | 4 +- source/code/core/utils/private/log_buffer.hxx | 4 +- .../code/core/utils/private/log_internal.cxx | 6 +- .../code/core/utils/private/log_internal.hxx | 2 +- source/code/core/utils/private/native_aio.cxx | 6 +- .../code/core/utils/private/native_file.cxx | 50 +- source/code/core/utils/private/params.cxx | 26 +- source/code/core/utils/private/path_utils.cxx | 91 ++-- .../code/core/utils/private/string_utils.cxx | 56 +-- .../public/ice/config/config_builder.hxx | 4 +- .../core/utils/public/ice/log_formatters.hxx | 18 +- .../code/core/utils/public/ice/native_aio.hxx | 6 +- .../code/core/utils/public/ice/path_utils.hxx | 6 +- .../core/utils/public/ice/string_utils.hxx | 49 +- source/code/core/utils/utils_tests.bff | 2 +- .../asset/tilemap/asset_tilemap_oven_tmx.cxx | 57 ++- .../framework_base/private/framework_main.cxx | 4 +- .../private/traits/trait_sprite_animator.cxx | 1 - .../private/traits/ui/game_ui_trait.cxx | 1 - .../private/ecs/ecs_archetype_index.cxx | 16 +- .../private/ecs/ecs_entity_operations.cxx | 12 +- .../engine/private/ecs/ecs_entity_storage.cxx | 12 +- .../private/engine_state_tracker_default.cxx | 6 +- .../private/engine_state_tracker_default.hxx | 4 +- .../engine/private/gfx/ice_gfx_graph.cxx | 10 +- .../private/gfx/ice_gfx_graph_runtime.cxx | 8 +- .../iceshard/engine/private/world_trait.cxx | 2 +- .../public/ice/ecs/ecs_archetype_detail.hxx | 6 +- .../engine/public/ice/ecs/ecs_data_block.hxx | 6 +- .../public/ice/ecs/ecs_entity_operations.hxx | 20 +- .../public/ice/ecs/ecs_entity_storage.hxx | 4 +- .../public/ice/ecs/ecs_query_awaitable.hxx | 4 +- .../public/ice/ecs/ecs_query_definition.hxx | 6 +- .../public/ice/ecs/ecs_query_details.hxx | 4 +- .../public/ice/ecs/ecs_query_operations.hxx | 34 +- .../public/ice/ecs/ecs_query_provider.hxx | 4 +- .../engine/public/ice/engine_data_storage.hxx | 10 +- .../public/ice/engine_state_tracker.hxx | 4 +- .../iceshard_gfx_image_storage_trait.cxx | 2 +- .../iceshard/private/iceshard_frame.cxx | 14 +- .../iceshard/private/iceshard_frame.hxx | 6 +- .../iceshard/private/iceshard_runner.hxx | 4 +- .../private/iceshard_task_executor.hxx | 4 +- .../private/iceshard_trait_context.cxx | 4 +- .../private/iceshard_world_manager.cxx | 6 +- .../iceshard_pipelines/private/asset_font.cxx | 6 +- .../private/pipeline_ui/ip_ui_asset.cxx | 42 +- .../pipeline_ui/ip_ui_oven_elements.cxx | 54 +- .../private/pipeline_ui/ip_ui_oven_page.cxx | 14 +- .../private/pipeline_ui/ip_ui_oven_utils.cxx | 119 ++--- .../imgui_module/private/imgui_system.cxx | 29 +- .../private/widgets/imgui_allocator_tree.cxx | 6 +- .../private/widgets/imgui_devui_manager.cxx | 6 +- .../private/widgets/imgui_logger.cxx | 1 - .../private/shader_tools_asl_utils.hxx | 4 +- .../private/shader_tools_glsl.cxx | 63 ++- .../private/shader_tools_wgsl.cxx | 44 +- .../vulkan_renderer/private/vk_device.cxx | 12 +- .../vulkan_renderer/private/vk_driver.cxx | 4 +- .../vulkan_renderer/private/vk_extensions.cxx | 12 +- .../vulkan_renderer/private/vk_extensions.hxx | 6 +- .../vulkan_renderer/private/vk_module.cxx | 6 +- .../vulkan_renderer/private/vk_queue.cxx | 4 +- .../vulkan_renderer/private/vk_swapchain.cxx | 2 +- .../application/private/app_info.cxx | 9 +- .../platform_linux/private/linux_storage.cxx | 4 +- .../win32_sdl2_platform_render_surface.cxx | 5 +- .../platform_win32/private/win32_storage.cxx | 34 +- .../platform_win32/private/win32_threads.cxx | 10 +- .../private/asset_shelve_devui.cxx | 12 +- .../asset_system/private/asset_storage.cxx | 10 +- .../asset_system/private/asset_storage.hxx | 1 - .../private/asset_storage_devui.cxx | 8 +- .../font_system/private/font_utils.cxx | 4 +- .../private/input_action_layer.cxx | 32 +- .../private/input_action_layer_builder.cxx | 46 +- .../private/input_action_script.cxx | 4 +- .../private/input_action_stack.cxx | 29 +- .../public/ice/input_action.hxx | 2 + .../public/ice/input_action_layer.hxx | 6 +- .../public/ice/input_action_stack.hxx | 6 +- .../input_system/private/input_controller.cxx | 4 +- .../input_system/private/input_keyboard.cxx | 4 +- .../private/input_touchscreen.cxx | 12 +- .../public/ice/input/input_device.hxx | 6 +- .../private/resource_filesystem_baked.cxx | 6 +- .../private/resource_filesystem_loose.cxx | 10 +- .../private/resource_filesystem_traverser.cxx | 13 +- .../private/resource_filesystem_writable.cxx | 4 +- .../private/resource_hailstorm_entry.cxx | 2 +- .../private/resource_hailstorm_entry.hxx | 2 +- .../private/resource_provider_custom.cxx | 24 +- .../private/resource_provider_custom.hxx | 4 +- .../private/resource_provider_filelist.cxx | 37 +- .../private/resource_provider_filelist.hxx | 6 +- .../private/resource_provider_filesystem.cxx | 34 +- .../private/resource_provider_filesystem.hxx | 6 +- .../resource_provider_filesystem_devui.cxx | 8 +- .../private/resource_provider_hailstorm.cxx | 10 +- .../resource_provider_hailstorm_devui.cxx | 4 +- .../private/resource_tracker.cxx | 20 +- .../private/resource_tracker.hxx | 6 +- .../private/resource_tracker_devui.cxx | 21 +- .../private/resource_writer_filesystem.cxx | 50 +- .../private/resource_writer_filesystem.hxx | 6 +- .../public/ice/resource_filter.hxx | 7 +- .../public/ice/resource_provider.hxx | 6 +- .../public/ice/resource_tracker.hxx | 4 +- .../resource_system/public/ice/uri.hxx | 66 +-- .../resource_system/resource_system_tests.bff | 2 +- .../tests/test_resource_meta.cxx | 4 +- source/code/test/private/game.cxx | 8 +- source/code/test/private/input_actions.cxx | 2 +- .../private/asset_compiler_app.cxx | 32 +- .../asset_compiler_resource_provider.cxx | 6 +- .../asset_compiler_resource_provider.hxx | 4 +- .../tools/hsc_packer/private/hsc_packer.cxx | 4 +- .../hsc_reader/private/hsc_reader_app.cxx | 2 +- source/code/tools/tool_base/private/tool.cxx | 2 +- 198 files changed, 3377 insertions(+), 3386 deletions(-) create mode 100644 source/code/core/collections/public/ice/heap_string.hxx create mode 100644 source/code/core/collections/public/ice/heap_varstring.hxx create mode 100644 source/code/core/collections/public/ice/static_string.hxx create mode 100644 source/code/core/collections/public/ice/string.hxx create mode 100644 source/code/core/collections/public/ice/string/editable_operations.hxx delete mode 100644 source/code/core/collections/public/ice/string/impl/heap_string.inl delete mode 100644 source/code/core/collections/public/ice/string/impl/static_string.inl delete mode 100644 source/code/core/collections/public/ice/string/impl/string.inl create mode 100644 source/code/core/collections/public/ice/string/readonly_operations.hxx create mode 100644 source/code/core/collections/public/ice/string/resizable_operations.hxx delete mode 100644 source/code/core/collections/public/ice/string/static_string.hxx create mode 100644 source/code/core/collections/public/ice/string/string_concepts.hxx create mode 100644 source/code/core/collections/public/ice/types/ncount.hxx create mode 100644 source/code/core/collections/public/ice/types/nindex.hxx create mode 100644 source/code/core/collections/public/ice/varstring.hxx create mode 100644 source/code/core/core/public/ice/types/ref.hxx diff --git a/source/code/core/collections/natvis/string.natvis b/source/code/core/collections/natvis/string.natvis index ca5c81cc..c2f4e93d 100644 --- a/source/code/core/collections/natvis/string.natvis +++ b/source/code/core/collections/natvis/string.natvis @@ -1,6 +1,26 @@ + + 0 <invalid> + {value} + + value + width + value * width + + + + + 0 <invalid> + {value} + + value + width + value * width + + + HeapString {{ { _data,s8 } }} diff --git a/source/code/core/collections/public/ice/container/array.hxx b/source/code/core/collections/public/ice/container/array.hxx index 3f80208b..254acd9e 100644 --- a/source/code/core/collections/public/ice/container/array.hxx +++ b/source/code/core/collections/public/ice/container/array.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -9,16 +9,16 @@ namespace ice::array { template - inline void set_capacity(ice::Array& arr, ice::ucount new_capacity) noexcept; + inline void set_capacity(ice::Array& arr, ice::u32 new_capacity) noexcept; template - inline void reserve(ice::Array& arr, ice::ucount min_capacity) noexcept; + inline void reserve(ice::Array& arr, ice::u32 min_capacity) noexcept; template - inline void grow(ice::Array& arr, ice::ucount min_capacity = 0) noexcept; + inline void grow(ice::Array& arr, ice::u32 min_capacity = 0) noexcept; template - inline void resize(ice::Array& arr, ice::ucount new_size) noexcept; + inline void resize(ice::Array& arr, ice::u32 new_size) noexcept; template inline void shrink(ice::Array& arr) noexcept; @@ -29,8 +29,8 @@ namespace ice::array template inline auto slice( ice::Array& arr, - ice::ucount from_idx = 0, - ice::ucount count = ice::ucount_max + ice::u32 from_idx = 0, + ice::u32 count = ice::u32_max ) noexcept -> ice::Span; template @@ -54,7 +54,7 @@ namespace ice::array inline void push_back(ice::Array& arr, ice::Span items, Type(*fn)(Source const&) noexcept) noexcept; template - inline void pop_back(ice::Array& arr, ice::ucount count = 1) noexcept; + inline void pop_back(ice::Array& arr, ice::u32 count = 1) noexcept; template inline auto begin(ice::Array& arr) noexcept -> typename ice::Array::Iterator; @@ -77,10 +77,10 @@ namespace ice::array template - inline auto count(ice::Array const& arr) noexcept -> ice::ucount; + inline auto count(ice::Array const& arr) noexcept -> ice::u32; template - inline auto capacity(ice::Array const& arr) noexcept -> ice::ucount; + inline auto capacity(ice::Array const& arr) noexcept -> ice::u32; template inline auto size_bytes(ice::Array const& arr) noexcept -> ice::usize; @@ -94,8 +94,8 @@ namespace ice::array template inline auto slice( ice::Array const& arr, - ice::ucount from_idx = 0, - ice::ucount count = ice::ucount_max + ice::u32 from_idx = 0, + ice::u32 count = ice::u32_max )noexcept -> ice::Span; template diff --git a/source/code/core/collections/public/ice/container/hashmap.hxx b/source/code/core/collections/public/ice/container/hashmap.hxx index edd7eb4c..e5350656 100644 --- a/source/code/core/collections/public/ice/container/hashmap.hxx +++ b/source/code/core/collections/public/ice/container/hashmap.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -13,7 +13,7 @@ namespace ice { template - inline void reserve(ice::HashMap& map, ice::ucount new_capacity) noexcept; + inline void reserve(ice::HashMap& map, ice::u32 new_capacity) noexcept; template inline void clear(ice::HashMap& map) noexcept; @@ -48,7 +48,7 @@ namespace ice template requires HashMapReadAccess - inline auto count(HashMapType const& map) noexcept -> ice::ucount; + inline auto count(HashMapType const& map) noexcept -> ice::u32; template requires HashMapReadAccess inline bool full(HashMapType const& map) noexcept; @@ -115,7 +115,7 @@ namespace ice template - inline auto count(ice::HashMap const& map, ice::u64 key) noexcept -> ice::ucount; + inline auto count(ice::HashMap const& map, ice::u64 key) noexcept -> ice::u32; template inline void get(ice::HashMap const& map, ice::u64 key, ice::Array& items) noexcept; diff --git a/source/code/core/collections/public/ice/container/impl/array_impl.inl b/source/code/core/collections/public/ice/container/impl/array_impl.inl index 356915c5..79608885 100644 --- a/source/code/core/collections/public/ice/container/impl/array_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/array_impl.inl @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT namespace ice @@ -145,14 +145,14 @@ namespace ice } template - inline auto Array::operator[](ice::ucount idx) noexcept -> Type& + inline auto Array::operator[](ice::u32 idx) noexcept -> Type& { // TODO: Assert return _data[idx]; } template - inline auto Array::operator[](ice::ucount idx) const noexcept -> Type const& + inline auto Array::operator[](ice::u32 idx) const noexcept -> Type const& { // TODO: Assert return _data[idx]; @@ -174,7 +174,7 @@ namespace ice { template - inline void set_capacity(ice::Array& arr, ice::ucount new_capacity) noexcept + inline void set_capacity(ice::Array& arr, ice::u32 new_capacity) noexcept { if (new_capacity == arr._capacity) { @@ -217,7 +217,7 @@ namespace ice } template - inline void reserve(ice::Array& arr, ice::ucount min_capacity) noexcept + inline void reserve(ice::Array& arr, ice::u32 min_capacity) noexcept { if (arr._capacity < min_capacity) { @@ -226,9 +226,9 @@ namespace ice } template - inline void grow(ice::Array& arr, ice::ucount min_capacity) noexcept + inline void grow(ice::Array& arr, ice::u32 min_capacity) noexcept { - ice::ucount new_capacity = arr._capacity * 2 + 4; + ice::u32 new_capacity = arr._capacity * 2 + 4; if (new_capacity < min_capacity) { new_capacity = min_capacity; @@ -237,7 +237,7 @@ namespace ice } template - inline void resize(ice::Array& arr, ice::ucount new_count) noexcept + inline void resize(ice::Array& arr, ice::u32 new_count) noexcept { if (arr._capacity < new_count) { @@ -246,7 +246,7 @@ namespace ice if (new_count > arr._count) { - ice::ucount const missing_items = new_count - arr._count; + ice::u32 const missing_items = new_count - arr._count; // Even for trivial logic we construct items so at least the default ctor is called. ice::mem_construct_n_at( @@ -257,7 +257,7 @@ namespace ice else if constexpr (Logic == ContainerLogic::Complex) { static_assert(Logic != ContainerLogic::Trivial); - ice::ucount const destroyed_items = arr._count - new_count; + ice::u32 const destroyed_items = arr._count - new_count; ice::mem_destruct_n_at( arr._data + new_count, @@ -350,13 +350,13 @@ namespace ice requires std::copy_constructible inline void push_back(ice::Array& arr, ice::Span items) noexcept { - ice::ucount const required_capacity = arr._count + ice::span::count(items); + ice::u32 const required_capacity = arr._count + ice::span::count(items); if (required_capacity > arr._capacity) { ice::array::grow(arr, required_capacity); } - ice::ucount const missing_items = required_capacity - arr._count; + ice::u32 const missing_items = required_capacity - arr._count; if constexpr (Logic == ContainerLogic::Complex) { ice::mem_copy_construct_n_at( @@ -380,13 +380,13 @@ namespace ice requires std::copy_constructible && (std::is_same_v == false) inline void push_back(ice::Array& arr, ice::Span items, Type(*fn)(Source const&) noexcept) noexcept { - ice::ucount const required_capacity = arr._count + ice::span::count(items); + ice::u32 const required_capacity = arr._count + ice::span::count(items); if (required_capacity > arr._capacity) { ice::array::grow(arr, required_capacity); } - ice::ucount const missing_items = required_capacity - arr._count; + ice::u32 const missing_items = required_capacity - arr._count; for (ice::u32 src_idx = 0; src_idx < missing_items; ++src_idx) { ice::array::push_back(arr, fn(items[src_idx])); @@ -394,7 +394,7 @@ namespace ice } template - inline void pop_back(ice::Array& arr, ice::ucount count /*= 1*/) noexcept + inline void pop_back(ice::Array& arr, ice::u32 count /*= 1*/) noexcept { count = ice::min(count, arr._count); if constexpr (Logic == ContainerLogic::Complex) @@ -453,13 +453,13 @@ namespace ice template - inline auto count(ice::Array const& arr) noexcept -> ice::ucount + inline auto count(ice::Array const& arr) noexcept -> ice::u32 { return arr._count; } template - inline auto capacity(ice::Array const& arr) noexcept -> ice::ucount + inline auto capacity(ice::Array const& arr) noexcept -> ice::u32 { return arr._capacity; } @@ -483,7 +483,7 @@ namespace ice } template - inline auto slice(ice::Array const& arr, ice::ucount from_idx, ice::ucount count) noexcept -> ice::Span + inline auto slice(ice::Array const& arr, ice::u32 from_idx, ice::u32 count) noexcept -> ice::Span { return ice::span::subspan(arr, from_idx, count); } diff --git a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl index d7420a1e..8f4c96f6 100644 --- a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT namespace ice @@ -11,31 +11,31 @@ namespace ice struct FindResult; - constexpr auto calc_storage_capacity(ice::ucount max_count) noexcept -> ice::ucount; + constexpr auto calc_storage_capacity(ice::u32 max_count) noexcept -> ice::u32; template - inline bool can_store_count(ice::HashMap const& map, ice::ucount expected_count) noexcept; + inline bool can_store_count(ice::HashMap const& map, ice::u32 expected_count) noexcept; template requires HashMapReadAccess inline auto find(HashMapType const& map, ice::u64 key) noexcept -> FindResult; template - inline auto make(ice::HashMap& map, ice::u64 key) noexcept -> ice::ucount; + inline auto make(ice::HashMap& map, ice::u64 key) noexcept -> ice::u32; template inline void erase(ice::HashMap& map, FindResult const fr) noexcept; template requires HashMapReadAccess - inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::ucount; + inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::u32; template - inline auto find_or_make(ice::HashMap& map, ice::u64 key, bool& found) noexcept -> ice::ucount; + inline auto find_or_make(ice::HashMap& map, ice::u64 key, bool& found) noexcept -> ice::u32; template inline void find_and_erase(ice::HashMap& map, ice::u64 key) noexcept; template - inline void rehash(ice::HashMap& map, ice::ucount new_capacity) noexcept; + inline void rehash(ice::HashMap& map, ice::u32 new_capacity) noexcept; template inline auto find(ice::HashMap& map, typename ice::HashMap::ConstIterator it) noexcept -> FindResult; @@ -217,22 +217,22 @@ namespace ice struct FindResult { - ice::ucount hash_i; - ice::ucount entry_prev; - ice::ucount entry_i; + ice::u32 hash_i; + ice::u32 entry_prev; + ice::u32 entry_i; }; - constexpr auto calc_storage_capacity(ice::ucount max_count) noexcept -> ice::ucount + constexpr auto calc_storage_capacity(ice::u32 max_count) noexcept -> ice::u32 { - return ice::ucount(max_count / Constant_HashMapMaxFill + 0.99f /* magic */); + return ice::u32(max_count / Constant_HashMapMaxFill + 0.99f /* magic */); } template - inline bool can_store_count(ice::HashMap const& map, ice::ucount expected_count) noexcept + inline bool can_store_count(ice::HashMap const& map, ice::u32 expected_count) noexcept { - ice::ucount const max_ucount = ice::ucount(map._capacity * Constant_HashMapMaxFill); - return max_ucount >= expected_count; + ice::u32 const max_u32 = ice::u32(map._capacity * Constant_HashMapMaxFill); + return max_u32 >= expected_count; } template requires HashMapReadAccess @@ -266,7 +266,7 @@ namespace ice } template - inline auto make(ice::HashMap& map, ice::u64 key) noexcept -> ice::ucount + inline auto make(ice::HashMap& map, ice::u64 key) noexcept -> ice::u32 { FindResult fr = ice::hashmap::detail::find(map, key); if (fr.hash_i == Constant_EndOfList) @@ -275,7 +275,7 @@ namespace ice } // The count is now the new index. - ice::ucount const index = map._count; + ice::u32 const index = map._count; // Set the key we are use to make the new entry. map._entries[index].key = key; @@ -366,13 +366,13 @@ namespace ice } template requires HashMapReadAccess - inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::ucount + inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::u32 { return ice::hashmap::detail::find(map, key).entry_i; } template - inline auto find_or_make(ice::HashMap& map, ice::u64 key, bool& found) noexcept -> ice::ucount + inline auto find_or_make(ice::HashMap& map, ice::u64 key, bool& found) noexcept -> ice::u32 { FindResult fr = ice::hashmap::detail::find(map, key); @@ -389,7 +389,7 @@ namespace ice } // The count is now the new index. - ice::ucount const index = map._count; + ice::u32 const index = map._count; // Set the key we are use to make the new entry. map._entries[index].key = key; @@ -417,32 +417,32 @@ namespace ice } template - inline void rehash(ice::HashMap& map, ice::ucount new_capacity) noexcept + inline void rehash(ice::HashMap& map, ice::u32 new_capacity) noexcept { using Entry = typename ice::HashMap::Entry; ICE_ASSERT_CORE(new_capacity * Constant_HashMapMaxFill >= map._count); - ice::ucount* new_hashes_ptr = nullptr; + ice::u32* new_hashes_ptr = nullptr; Entry* new_entries_ptr = nullptr; Type* new_value_ptr = nullptr; if (new_capacity > 0) { - ice::ucount const new_capacity_values = ice::ucount(new_capacity * Constant_HashMapMaxFill); + ice::u32 const new_capacity_values = ice::u32(new_capacity * Constant_HashMapMaxFill); ice::meminfo alloc_info = ice::meminfo_of * new_capacity; ice::usize const offset_entries = alloc_info += ice::meminfo_of * new_capacity_values; ice::usize const offset_values = alloc_info += ice::meminfo_of * new_capacity_values; ice::AllocResult const new_data = map._allocator->allocate(alloc_info); - new_hashes_ptr = reinterpret_cast(new_data.memory); + new_hashes_ptr = reinterpret_cast(new_data.memory); new_entries_ptr = reinterpret_cast(ice::ptr_add(new_data.memory, offset_entries)); new_value_ptr = reinterpret_cast(ice::ptr_add(new_data.memory, offset_values)); // Prepare hashes memory // TODO: memset? - for (ice::ucount& hashed_idx : ice::Span{ new_hashes_ptr, new_capacity }) + for (ice::u32& hashed_idx : ice::Span{ new_hashes_ptr, new_capacity }) { hashed_idx = Constant_EndOfList; } @@ -547,7 +547,7 @@ namespace ice //! //! \note Keep in mind, the number of valies a hashmap can store is lower than it's total capacity. template - inline void reserve(ice::HashMap& map, ice::ucount new_count) noexcept + inline void reserve(ice::HashMap& map, ice::u32 new_count) noexcept { ice::hashmap::detail::rehash(map, ice::hashmap::detail::calc_storage_capacity(new_count)); } @@ -561,7 +561,7 @@ namespace ice } map._count = 0; - for (ice::ucount hash_idx = 0; hash_idx < map._capacity; ++hash_idx) + for (ice::u32 hash_idx = 0; hash_idx < map._capacity; ++hash_idx) { // TODO: memset? map._hashes[hash_idx] = ice::hashmap::detail::Constant_EndOfList; @@ -584,7 +584,7 @@ namespace ice } bool found = false; - ice::ucount const index = ice::hashmap::detail::find_or_make(map, key, found); + ice::u32 const index = ice::hashmap::detail::find_or_make(map, key, found); if constexpr (Logic == ContainerLogic::Complex) { // If the index was found we need to destroy the previous value. @@ -618,7 +618,7 @@ namespace ice } bool found = false; - ice::ucount const index = ice::hashmap::detail::find_or_make(map, key, found); + ice::u32 const index = ice::hashmap::detail::find_or_make(map, key, found); if constexpr (Logic == ContainerLogic::Complex) { // If the index was found we need to destroy the previous value. @@ -651,7 +651,7 @@ namespace ice ice::hashmap::set(map, key, ice::forward(value)); } - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); ICE_ASSERT_CORE(index != ice::hashmap::detail::Constant_EndOfList); return *(map._data + index); } @@ -659,7 +659,7 @@ namespace ice template inline auto try_get(ice::HashMap& map, ice::u64 key) noexcept -> Type* { - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); return index == ice::hashmap::detail::Constant_EndOfList ? nullptr : map._data + index; @@ -680,7 +680,7 @@ namespace ice template requires HashMapReadAccess - inline auto count(HashMapType const& map) noexcept -> ice::ucount + inline auto count(HashMapType const& map) noexcept -> ice::u32 { return map._count; } @@ -688,7 +688,7 @@ namespace ice template requires HashMapReadAccess inline bool full(HashMapType const& map) noexcept { - ice::ucount const max_count = ice::ucount(map._capacity * ice::hashmap::detail::Constant_HashMapMaxFill); + ice::u32 const max_count = ice::u32(map._capacity * ice::hashmap::detail::Constant_HashMapMaxFill); ICE_ASSERT_CORE(max_count >= map._count); return max_count == map._count; @@ -715,7 +715,7 @@ namespace ice template requires HashMapReadAccess inline auto get(HashMapType const& map, ice::u64 key, typename HashMapType::ValueType const& fallback_value) noexcept -> typename HashMapType::ValueType const& { - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); return index == ice::hashmap::detail::Constant_EndOfList ? fallback_value : map._data[index]; @@ -724,7 +724,7 @@ namespace ice template requires HashMapReadAccess inline auto get(HashMapType const& map, ice::u64 key, std::nullptr_t) noexcept -> typename HashMapType::ValueType { - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); return index == ice::hashmap::detail::Constant_EndOfList ? nullptr : map._data[index]; @@ -733,7 +733,7 @@ namespace ice template requires HashMapReadAccess inline auto try_get(HashMapType const& map, ice::u64 key) noexcept -> typename HashMapType::ValueType const* { - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); return index == ice::hashmap::detail::Constant_EndOfList ? nullptr : map._data + index; @@ -767,7 +767,7 @@ namespace ice template inline auto memory(ice::HashMap& map) noexcept -> ice::Memory { - ice::ucount const capacity_values = ice::ucount(map._capacity * ice::hashmap::detail::Constant_HashMapMaxFill); + ice::u32 const capacity_values = ice::u32(map._capacity * ice::hashmap::detail::Constant_HashMapMaxFill); // TODO: Easier way to calculate the allocated size. ice::meminfo alloc_info = ice::meminfo_of * map._capacity; @@ -795,7 +795,7 @@ namespace ice ice::hashmap::detail::grow(map); } - ice::ucount const index = ice::hashmap::detail::make(map, key); + ice::u32 const index = ice::hashmap::detail::make(map, key); if constexpr (Logic == ContainerLogic::Complex) { // If the index is below the current map._count we need to destroy the previous value. @@ -827,7 +827,7 @@ namespace ice ice::hashmap::detail::grow(map); } - ice::ucount const index = ice::hashmap::detail::make(map, key); + ice::u32 const index = ice::hashmap::detail::make(map, key); if constexpr (Logic == ContainerLogic::Complex) { // If the index is below the current map._count we need to destroy the previous value. @@ -871,11 +871,11 @@ namespace ice } template - inline auto count(ice::HashMap const& map, ice::u64 key) noexcept -> ice::ucount + inline auto count(ice::HashMap const& map, ice::u64 key) noexcept -> ice::u32 { using ConstIterator = typename ice::HashMap::ConstIterator; - ice::ucount result = 0; + ice::u32 result = 0; ConstIterator it = ice::multi_hashmap::find_first(map, key); while (it._entry != nullptr) { @@ -903,7 +903,7 @@ namespace ice { using ConstIterator = typename ice::HashMap::ConstIterator; - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); if (index == ice::hashmap::detail::Constant_EndOfList) { return ConstIterator{ nullptr, nullptr }; @@ -924,7 +924,7 @@ namespace ice using ConstIterator = typename ice::HashMap::ConstIterator; - ice::ucount index = it._entry->next; + ice::u32 index = it._entry->next; while (index != ice::hashmap::detail::Constant_EndOfList) { if (map._entries[index].key == it._entry->key) diff --git a/source/code/core/collections/public/ice/container/impl/queue_impl.inl b/source/code/core/collections/public/ice/container/impl/queue_impl.inl index 044d40a9..1695156b 100644 --- a/source/code/core/collections/public/ice/container/impl/queue_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/queue_impl.inl @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT namespace ice @@ -8,10 +8,10 @@ namespace ice { template - inline void destroy_head_items(ice::Queue& queue, ice::ucount destroy_count) noexcept; + inline void destroy_head_items(ice::Queue& queue, ice::u32 destroy_count) noexcept; template - inline void destroy_tail_items(ice::Queue& queue, ice::ucount destroy_count) noexcept; + inline void destroy_tail_items(ice::Queue& queue, ice::u32 destroy_count) noexcept; template inline void copy_items_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept; @@ -76,10 +76,10 @@ namespace ice { if constexpr (Logic == ContainerLogic::Complex) { - ice::ucount const last_raw_idx = _offset + _count; + ice::u32 const last_raw_idx = _offset + _count; if (last_raw_idx > _capacity) { - ice::ucount const wrapped_count = last_raw_idx - _capacity; + ice::u32 const wrapped_count = last_raw_idx - _capacity; ice::mem_destruct_n_at(_data + _offset, _count - wrapped_count); // Destroyes elements at the end of the ring buffer [_offset, count_until_capacity) ice::mem_destruct_n_at(_data, wrapped_count); // Destroys wrapped tail elements [0, tail_size) } @@ -134,13 +134,13 @@ namespace ice } template - inline auto Queue::operator[](ice::ucount idx) noexcept -> Type& + inline auto Queue::operator[](ice::u32 idx) noexcept -> Type& { return _data[(idx + _offset) % _capacity]; } template - inline auto Queue::operator[](ice::ucount idx) const noexcept -> Type const& + inline auto Queue::operator[](ice::u32 idx) const noexcept -> Type const& { return _data[(idx + _offset) % _capacity]; } @@ -149,11 +149,11 @@ namespace ice { template - void destroy_head_items(ice::Queue& queue, ice::ucount destroy_count) noexcept + void destroy_head_items(ice::Queue& queue, ice::u32 destroy_count) noexcept { - ice::ucount const raw_end_idx = queue._offset + destroy_count; - ice::ucount const start_idx = queue._offset; - ice::ucount const end_idx = raw_end_idx % queue._capacity; + ice::u32 const raw_end_idx = queue._offset + destroy_count; + ice::u32 const start_idx = queue._offset; + ice::u32 const end_idx = raw_end_idx % queue._capacity; // We got a wrapped case if (start_idx > end_idx) @@ -168,11 +168,11 @@ namespace ice } template - void destroy_tail_items(ice::Queue& queue, ice::ucount destroy_count) noexcept + void destroy_tail_items(ice::Queue& queue, ice::u32 destroy_count) noexcept { - ice::ucount const raw_end_idx = queue._offset + queue._count; - ice::ucount const start_idx = (raw_end_idx - destroy_count) % queue._capacity; - ice::ucount const end_idx = raw_end_idx % queue._capacity; + ice::u32 const raw_end_idx = queue._offset + queue._count; + ice::u32 const start_idx = (raw_end_idx - destroy_count) % queue._capacity; + ice::u32 const end_idx = raw_end_idx % queue._capacity; // We got a wrapped case if (start_idx > end_idx) @@ -189,8 +189,8 @@ namespace ice template inline void copy_items_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept { - ice::ucount const start_idx = queue._offset; - ice::ucount const head_count = queue._capacity - start_idx; + ice::u32 const start_idx = queue._offset; + ice::u32 const head_count = queue._capacity - start_idx; ice::usize const head_size = ice::size_of * head_count; ice::mem_copy_construct_n_at(dest, queue._data + start_idx, head_count); @@ -203,8 +203,8 @@ namespace ice template inline void move_items_to_new_location(ice::Memory dest, ice::Queue& queue) noexcept { - ice::ucount const start_idx = queue._offset; - ice::ucount const head_count = queue._capacity - start_idx; + ice::u32 const start_idx = queue._offset; + ice::u32 const head_count = queue._capacity - start_idx; ice::usize const head_size = ice::size_of * head_count; ice::mem_move_construct_n_at(dest, queue._data + start_idx, head_count); @@ -223,8 +223,8 @@ namespace ice { ice::usize const total_size = ice::size_of * queue._count; - ice::ucount const head_count = std::min(queue._offset + queue._count, queue._capacity) - queue._offset; - ice::ucount const tail_count = queue._count - head_count; + ice::u32 const head_count = std::min(queue._offset + queue._count, queue._capacity) - queue._offset; + ice::u32 const tail_count = queue._count - head_count; ice::usize const head_size = ice::size_of * head_count; ice::usize const head_end_offset = ice::size_of * head_count; @@ -257,7 +257,7 @@ namespace ice { template - inline void set_capacity(ice::Queue& queue, ice::ucount new_capacity) noexcept + inline void set_capacity(ice::Queue& queue, ice::u32 new_capacity) noexcept { if (new_capacity == queue._capacity) { @@ -299,7 +299,7 @@ namespace ice } template - inline void reserve(ice::Queue& queue, ice::ucount min_capacity) noexcept + inline void reserve(ice::Queue& queue, ice::u32 min_capacity) noexcept { if (queue._capacity < min_capacity) { @@ -308,9 +308,9 @@ namespace ice } template - inline void grow(ice::Queue& queue, ice::ucount min_capacity /*= 0*/) noexcept + inline void grow(ice::Queue& queue, ice::u32 min_capacity /*= 0*/) noexcept { - ice::ucount new_capacity = queue._count * 2 + 4; + ice::u32 new_capacity = queue._count * 2 + 4; if (new_capacity < min_capacity) { new_capacity = min_capacity; @@ -319,7 +319,7 @@ namespace ice } template - inline void resize(ice::Queue& queue, ice::ucount new_count) noexcept + inline void resize(ice::Queue& queue, ice::u32 new_count) noexcept { if (queue._capacity < new_count) { @@ -329,11 +329,11 @@ namespace ice // Even for trivial logic we construct items so at least the default ctor is called. if (new_count > queue._count) { - ice::ucount const missing_items = new_count - queue._count; - ice::ucount const start_idx = (queue._offset + queue._count) % queue._capacity; + ice::u32 const missing_items = new_count - queue._count; + ice::u32 const start_idx = (queue._offset + queue._count) % queue._capacity; - ice::ucount const end_idx = ice::min(start_idx + missing_items, queue._capacity); - ice::ucount const wrapped_end_idx = missing_items - (end_idx - start_idx); + ice::u32 const end_idx = ice::min(start_idx + missing_items, queue._capacity); + ice::u32 const wrapped_end_idx = missing_items - (end_idx - start_idx); // Construct until we hit end of the queue buffer ice::mem_construct_n_at( @@ -389,7 +389,7 @@ namespace ice ice::queue::grow(queue); } - ice::ucount const item_idx = (queue._offset + queue._count) % queue._capacity; + ice::u32 const item_idx = (queue._offset + queue._count) % queue._capacity; if constexpr (Logic == ContainerLogic::Complex) { ice::mem_move_construct_at( @@ -414,7 +414,7 @@ namespace ice ice::queue::grow(queue); } - ice::ucount const item_idx = (queue._offset + queue._count) % queue._capacity; + ice::u32 const item_idx = (queue._offset + queue._count) % queue._capacity; if constexpr (Logic == ContainerLogic::Complex) { ice::mem_copy_construct_at( @@ -438,20 +438,20 @@ namespace ice requires std::copy_constructible inline void push_back(ice::Queue& queue, ice::Span items) noexcept { - ice::ucount const required_capacity = queue._count + ice::span::count(items); + ice::u32 const required_capacity = queue._count + ice::span::count(items); if (required_capacity > queue._capacity) { ice::queue::grow(queue, required_capacity); } - ice::ucount const span_count = ice::span::count(items); - ice::ucount const start_idx = (queue._offset + queue._count) % queue._capacity; - ice::ucount const end_idx = ice::min(queue._capacity, start_idx + span_count); + ice::u32 const span_count = ice::span::count(items); + ice::u32 const start_idx = (queue._offset + queue._count) % queue._capacity; + ice::u32 const end_idx = ice::min(queue._capacity, start_idx + span_count); // The space can we use before wrapping around the buffer. - ice::ucount const head_space = end_idx - start_idx; + ice::u32 const head_space = end_idx - start_idx; // The space after the wrapped buffer we still need to allocate. Can be 0. - ice::ucount const tail_space = span_count - head_space; + ice::u32 const tail_space = span_count - head_space; if constexpr (Logic == ContainerLogic::Complex) { @@ -569,7 +569,7 @@ namespace ice queue._offset = queue._capacity; } - ice::ucount const item_idx = queue._offset - 1; + ice::u32 const item_idx = queue._offset - 1; if constexpr (Logic == ContainerLogic::Complex) { ice::mem_copy_construct_at( @@ -594,14 +594,14 @@ namespace ice inline void push_front(ice::Queue& queue, ice::Span items) noexcept; template - inline auto take_front(ice::Queue& queue, ice::Span out_values) noexcept -> ice::ucount + inline auto take_front(ice::Queue& queue, ice::Span out_values) noexcept -> ice::u32 { - ice::ucount const taken_items = ice::min(ice::count(out_values), ice::count(queue)); + ice::u32 const taken_items = ice::min(ice::count(out_values), ice::count(queue)); // (offset, end][0, remaining) - ice::ucount const first_part = ice::min(queue._offset + taken_items, queue._capacity); - ice::ucount const second_part = (queue._offset + taken_items) - first_part; - ice::ucount const first_part_count = first_part - queue._offset; + ice::u32 const first_part = ice::min(queue._offset + taken_items, queue._capacity); + ice::u32 const second_part = (queue._offset + taken_items) - first_part; + ice::u32 const first_part_count = first_part - queue._offset; if constexpr (Logic == ContainerLogic::Complex) { @@ -619,7 +619,7 @@ namespace ice } template - inline void pop_front(ice::Queue& queue, ice::ucount count /*= 1*/) noexcept + inline void pop_front(ice::Queue& queue, ice::u32 count /*= 1*/) noexcept { if constexpr (Logic == ContainerLogic::Complex) { @@ -652,13 +652,13 @@ namespace ice template - inline auto count(ice::Queue const& queue) noexcept -> ice::ucount + inline auto count(ice::Queue const& queue) noexcept -> ice::u32 { return queue._count; } template - inline auto capacity(ice::Queue const& queue) noexcept -> ice::ucount + inline auto capacity(ice::Queue const& queue) noexcept -> ice::u32 { return queue._capacity; } @@ -701,8 +701,8 @@ namespace ice return; } - ice::ucount const first_part = ice::min(queue._offset + queue._count, queue._capacity); - ice::ucount const second_part = (queue._offset + queue._count) - first_part; + ice::u32 const first_part = ice::min(queue._offset + queue._count, queue._capacity); + ice::u32 const second_part = (queue._offset + queue._count) - first_part; for (ice::u32 idx = queue._offset; idx < first_part; ++idx) { @@ -723,8 +723,8 @@ namespace ice return; } - ice::ucount const first_part = ice::min(queue._offset + queue._count, queue._capacity); - ice::ucount const second_part = (queue._offset + queue._count) - first_part; + ice::u32 const first_part = ice::min(queue._offset + queue._count, queue._capacity); + ice::u32 const second_part = (queue._offset + queue._count) - first_part; if (second_part > 0) { diff --git a/source/code/core/collections/public/ice/container/queue.hxx b/source/code/core/collections/public/ice/container/queue.hxx index 7d8c4a1e..3d193a1b 100644 --- a/source/code/core/collections/public/ice/container/queue.hxx +++ b/source/code/core/collections/public/ice/container/queue.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -10,17 +10,17 @@ namespace ice::queue // TODO: Move to details (we don't need this, also makes no sense for this queue) template - inline void set_capacity(ice::Queue& queue, ice::ucount new_capacity) noexcept; + inline void set_capacity(ice::Queue& queue, ice::u32 new_capacity) noexcept; template - inline void reserve(ice::Queue& queue, ice::ucount min_capacity) noexcept; + inline void reserve(ice::Queue& queue, ice::u32 min_capacity) noexcept; template - inline void grow(ice::Queue& queue, ice::ucount min_capacity = 0) noexcept; + inline void grow(ice::Queue& queue, ice::u32 min_capacity = 0) noexcept; // TODO: Move to details (we don't need this, also makes no sense for this queue) template - inline void resize(ice::Queue& queue, ice::ucount new_count) noexcept; + inline void resize(ice::Queue& queue, ice::u32 new_count) noexcept; template inline void shrink(ice::Queue& queue) noexcept; @@ -45,7 +45,7 @@ namespace ice::queue inline void push_back(ice::Queue& queue, ice::Span items) noexcept; template - inline void pop_back(ice::Queue& queue, ice::ucount count = 1) noexcept; + inline void pop_back(ice::Queue& queue, ice::u32 count = 1) noexcept; template requires std::move_constructible @@ -64,7 +64,7 @@ namespace ice::queue inline void push_front(ice::Queue& queue, ice::Span items) noexcept; template - inline void pop_front(ice::Queue& queue, ice::ucount count = 1) noexcept; + inline void pop_front(ice::Queue& queue, ice::u32 count = 1) noexcept; template inline auto front(ice::Queue& queue) noexcept -> Type&; @@ -74,10 +74,10 @@ namespace ice::queue template - inline auto count(ice::Queue const& queue) noexcept -> ice::ucount; + inline auto count(ice::Queue const& queue) noexcept -> ice::u32; template - inline auto capacity(ice::Queue const& queue) noexcept -> ice::ucount; + inline auto capacity(ice::Queue const& queue) noexcept -> ice::u32; template inline auto size_bytes(ice::Queue const& queue) noexcept -> ice::usize; diff --git a/source/code/core/collections/public/ice/container_types.hxx b/source/code/core/collections/public/ice/container_types.hxx index 264245ed..07900073 100644 --- a/source/code/core/collections/public/ice/container_types.hxx +++ b/source/code/core/collections/public/ice/container_types.hxx @@ -1,9 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include +#include #include #include @@ -31,8 +32,8 @@ namespace ice using ConstReverseIterator = std::reverse_iterator; ice::Allocator* _allocator; - ice::ucount _capacity; - ice::ucount _count; + ice::u32 _capacity; + ice::u32 _count; Type* _data; inline explicit Array(ice::Allocator& alloc) noexcept; @@ -50,8 +51,8 @@ namespace ice inline auto operator=(Array const& other) noexcept -> Array& requires std::copy_constructible; - inline auto operator[](ice::ucount idx) noexcept -> Type&; - inline auto operator[](ice::ucount idx) const noexcept -> Type const&; + inline auto operator[](ice::u32 idx) noexcept -> Type&; + inline auto operator[](ice::u32 idx) const noexcept -> Type const&; inline operator ice::Span() noexcept; inline operator ice::Span() const noexcept; @@ -75,9 +76,9 @@ namespace ice using ValueType = Type; ice::Allocator* _allocator; - ice::ucount _capacity; - ice::ucount _count; - ice::ucount _offset; + ice::u32 _capacity; + ice::u32 _count; + ice::u32 _offset; Type* _data; inline explicit Queue(ice::Allocator& alloc) noexcept; @@ -90,8 +91,8 @@ namespace ice inline auto operator=(Queue const& other) noexcept -> Queue& requires std::copy_constructible; - auto operator[](ice::ucount idx) noexcept -> Type&; - auto operator[](ice::ucount idx) const noexcept -> Type const&; + auto operator[](ice::u32 idx) noexcept -> Type&; + auto operator[](ice::u32 idx) const noexcept -> Type const&; }; @@ -114,7 +115,7 @@ namespace ice struct Entry { ice::u64 key; - ice::ucount next; + ice::u32 next; }; struct ConstIterator @@ -145,10 +146,10 @@ namespace ice }; ice::Allocator* _allocator; - ice::ucount _capacity; - ice::ucount _count; + ice::u32 _capacity; + ice::u32 _count; - ice::ucount* _hashes; + ice::u32* _hashes; Entry* _entries; Type* _data; @@ -174,10 +175,10 @@ namespace ice using Entry = typename ice::HashMap::Entry; using ValueType = Type; - ice::ucount _capacity; - ice::ucount _count; + ice::u32 _capacity; + ice::u32 _count; - ice::ucount const* _hashes; + ice::u32 const* _hashes; Entry const* _entries; Type const* _data; }; @@ -186,9 +187,9 @@ namespace ice template concept HashMapReadAccess = requires(Type t) { { typename Type::Entry() } -> std::convertible_to; - { t._capacity } -> std::convertible_to; - { t._count } -> std::convertible_to; - { t._hashes } -> std::convertible_to; + { t._capacity } -> std::convertible_to; + { t._count } -> std::convertible_to; + { t._hashes } -> std::convertible_to; { t._entries } -> std::convertible_to; { t._data } -> std::convertible_to; }; diff --git a/source/code/core/collections/public/ice/heap_string.hxx b/source/code/core/collections/public/ice/heap_string.hxx new file mode 100644 index 00000000..fcbb37bd --- /dev/null +++ b/source/code/core/collections/public/ice/heap_string.hxx @@ -0,0 +1,250 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include +#include + +namespace ice +{ + + template requires ice::concepts::SupportedCharType + struct HeapString : ice::string::ResizableOperations + { + using CharType = CharT; + using ValueType = CharType; + using Iterator = CharType*; + using ReverseIterator = std::reverse_iterator; + using ConstIterator = CharType const*; + using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; + using StringType = ice::BasicString; + + ice::Allocator* _allocator; + ice::u32 _capacity; + ice::u32 _size; + ValueType* _data; + + inline explicit HeapString(ice::Allocator& allocator) noexcept; + inline HeapString(ice::Allocator& allocator, ice::BasicString string) noexcept; + inline ~HeapString() noexcept; + + inline HeapString(HeapString&& other) noexcept; + inline HeapString(HeapString const& other) noexcept; + + inline auto operator=(HeapString&& other) noexcept -> HeapString&; + inline auto operator=(HeapString const& other) noexcept -> HeapString&; + inline auto operator=(ice::BasicString str) noexcept -> HeapString&; + + inline operator ice::BasicString() const noexcept; + + template + inline auto data(this Self& self) noexcept -> ValueType* { return self._data; } + + inline auto size() const noexcept -> SizeType { return SizeType{ _size, sizeof(CharType) }; } + inline void resize(ice::ncount new_size) noexcept; + + inline auto capacity() const noexcept -> SizeType { return SizeType{ _capacity, sizeof(CharType) }; } + inline void set_capacity(ice::ncount new_capacity) noexcept; + + inline auto data_view() const noexcept -> ice::Data; + inline auto extract_memory() noexcept -> ice::Memory; + }; + + template requires ice::concepts::SupportedCharType + inline HeapString::HeapString(ice::Allocator& allocator) noexcept + : _allocator{ &allocator } + , _capacity{ 0 } + , _size{ 0 } + , _data{ nullptr } + { + } + + template requires ice::concepts::SupportedCharType + inline HeapString::HeapString(ice::Allocator& allocator, ice::BasicString value) noexcept + : _allocator{ &allocator } + , _capacity{ 0 } + , _size{ 0 } + , _data{ nullptr } + { + *this = value; + } + + template requires ice::concepts::SupportedCharType + inline HeapString::HeapString(HeapString&& other) noexcept + : _allocator{ other._allocator } + , _size{ ice::exchange(other._size, 0) } + , _capacity{ ice::exchange(other._capacity, 0) } + , _data{ ice::exchange(other._data, nullptr) } + { + } + + template requires ice::concepts::SupportedCharType + inline HeapString::HeapString(HeapString const& other) noexcept + : _allocator{ other._allocator } + , _capacity{ 0 } + , _size{ 0 } + , _data{ nullptr } + { + if (other._size > 0) + { + set_capacity(other.size() + 1); + + // TODO: We need actually very, VERY good tests for string manipulations... + ice::memcpy( + this->end(), + other.cbegin(), + other.size().bytes() + ); + + _size = other._size; + _data[_size] = CharType{ 0 }; + } + } + + template requires ice::concepts::SupportedCharType + inline HeapString::~HeapString() noexcept + { + _allocator->deallocate(this->memory_view()); + } + + template requires ice::concepts::SupportedCharType + inline auto HeapString::operator=(HeapString&& other) noexcept -> HeapString& + { + if (this != ice::addressof(other)) + { + set_capacity(0); + + _allocator = other._allocator; + _size = ice::exchange(other._size, 0); + _capacity = ice::exchange(other._capacity, 0); + _data = ice::exchange(other._data, nullptr); + } + return *this; + } + + template requires ice::concepts::SupportedCharType + inline auto HeapString::operator=(HeapString const& other) noexcept -> HeapString& + { + if (this != ice::addressof(other)) + { + this->clear(); + this->reserve(other.capacity()); + + if (other._size > 0) + { + ice::memcpy( + this->memory_view(), + other.data_view() + ); + } + + _size = other._size; + _data[_size] = CharType{ }; + } + return *this; + } + + template requires ice::concepts::SupportedCharType + inline auto HeapString::operator=(ice::BasicString str) noexcept -> HeapString& + { + auto const* const other_str_begin = str.begin(); + bool const part_of_this = other_str_begin >= this->begin() + && other_str_begin < this->end(); + ICE_ASSERT_CORE(part_of_this == false); + + if (!part_of_this) + { + set_capacity(str.size() + 1); + ice::memcpy( + this->memory_view(), + str.data_view() + ); + + _size = str.size().u32(); + _data[_size] = ValueType{ 0 }; + } + return *this; + } + + template requires ice::concepts::SupportedCharType + inline HeapString::operator ice::BasicString::CharType>() const noexcept + { + return ice::BasicString{ _data, _size }; + } + + template requires ice::concepts::SupportedCharType + inline void HeapString::resize(ice::ncount new_size) noexcept + { + if (new_size > 0 && new_size >= capacity()) + { + set_capacity(new_size + 1); + } + + _size = new_size.u32(); + if (_data != nullptr) + { + _data[_size] = CharType{ 0 }; + } + } + + template requires ice::concepts::SupportedCharType + inline void HeapString::set_capacity(ice::ncount new_capacity) noexcept + { + ice::u32 const new_capacity_u32 = new_capacity.u32(); + if (new_capacity_u32 == _capacity) + { + return; + } + + ValueType* new_data = nullptr; + if (new_capacity_u32 > 0) + { + ice::AllocResult new_buffer = _allocator->allocate(ice::meminfo_of * new_capacity); + + if (_size > 0) + { + ice::memcpy(new_buffer, this->data_view()); + } + + new_data = reinterpret_cast(new_buffer.memory); + } + + _allocator->deallocate(this->memory_view()); + _capacity = new_capacity_u32; + _data = new_data; + + if (new_capacity_u32 <= _size) + { + _size = ice::min(new_capacity_u32, new_capacity_u32 - 1); + } + + if (_data != nullptr) + { + _data[_size] = 0; + } + } + + template requires ice::concepts::SupportedCharType + inline auto HeapString::data_view() const noexcept -> ice::Data + { + return Data{ + .location = _data, + .size = size().bytes(), + .alignment = ice::align_of + }; + } + + template requires ice::concepts::SupportedCharType + inline auto HeapString::extract_memory() noexcept -> ice::Memory + { + _size = 0; // clear the size too + return { + ice::exchange(_data, nullptr), + ice::exchange(_capacity, 0), + ice::align_of + }; + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/heap_varstring.hxx b/source/code/core/collections/public/ice/heap_varstring.hxx new file mode 100644 index 00000000..b10a069c --- /dev/null +++ b/source/code/core/collections/public/ice/heap_varstring.hxx @@ -0,0 +1,161 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include +#include + +namespace ice +{ + + template + struct HeapVarString : ice::string::ResizableOperations + { + static_assert(sizeof(CharT) == 1, "Wider characters are not supported yet!"); + + using TypeTag = VarStringTag; + using CharType = CharT; + using ValueType = CharType; + using Iterator = CharType*; + using ReverseIterator = std::reverse_iterator; + using ConstIterator = CharType const*; + using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; + using StringType = ice::BasicString; + + ice::Allocator* _allocator; + ValueType* _data; + + inline explicit HeapVarString(ice::Allocator& alloc) noexcept; + inline HeapVarString(ice::Allocator& allocator, ice::BasicString string) noexcept; + inline ~HeapVarString() noexcept; + + inline HeapVarString(HeapVarString&& other) noexcept; + inline HeapVarString(HeapVarString const& other) noexcept; + + constexpr auto data() const noexcept -> ValueType*; + constexpr auto size() const noexcept -> SizeType; + + inline auto data_view() const noexcept -> ice::Data; + + inline operator ice::BasicString() const noexcept; + inline operator ice::VarStringBase() const noexcept; + }; + + namespace varstring + { + + inline auto allocate_exact(ice::Allocator& alloc, ice::ncount size, ice::usize& out_bytes) noexcept -> char* + { + if (size == 0_B) + { + return nullptr; + } + + // Allocate enough for: bytes + size + '\0' + ice::usize const final_size = calc_required_size(size) + 1_B; + ice::Memory const result = alloc.allocate(final_size); + out_bytes = write_size(result.location, size); + return reinterpret_cast(result.location); + } + + inline auto create(ice::Allocator& alloc, ice::String str) noexcept -> char* + { + ice::ncount const str_size = str.size(); + + ice::usize bytes = 0_B; + char* const data = allocate_exact(alloc, str_size, bytes); + if (data != nullptr) + { + ice::memcpy(data + bytes.value, str.begin(), str_size.bytes()); + data[bytes.value + str_size.native()] = '\0'; + } + return data; + } + + } // namespace string::detail + + template + inline HeapVarString::HeapVarString(ice::Allocator& alloc) noexcept + : _allocator{ ice::addressof(alloc) } + , _data{ nullptr } + { + } + + template + inline HeapVarString::HeapVarString(ice::Allocator& alloc, ice::BasicString string) noexcept + : _allocator{ ice::addressof(alloc) } + , _data{ ice::varstring::create(alloc, string) } + { + } + + template + inline HeapVarString::HeapVarString(ice::HeapVarString&& other) noexcept + : _allocator{ other._allocator } + , _data{ ice::exchange(other._data, nullptr) } + { + } + + template + inline HeapVarString::HeapVarString(ice::HeapVarString const& other) noexcept + : HeapVarString{ other._allocator, ice::String{ other } } + { + } + + template + inline HeapVarString::~HeapVarString() noexcept + { + if (_data != nullptr) + { + _allocator->deallocate(_data); + } + } + + template + inline constexpr auto HeapVarString::data() const noexcept -> ValueType* + { + return ice::varstring::read_data(_data); + } + + template + inline constexpr auto HeapVarString::size() const noexcept -> SizeType + { + return ice::varstring::read_size(_data); + } + + template + inline auto HeapVarString::data_view() const noexcept -> ice::Data + { + ice::usize bytes = 0_B; + ice::ncount const size = ice::varstring::read_size(_data, bytes); + + return { + .location = _data, + .size = { size.bytes() + bytes}, + .alignment = ice::ualign::b_1 + }; + } + + template + inline HeapVarString::operator ice::BasicString::CharType>() const noexcept + { + ice::usize bytes = 0; + ice::ncount const size = ice::varstring::read_size(_data, bytes); + if (size > 0) + { + return { _data + bytes.value, size }; + } + else + { + return {}; + } + } + + template + inline HeapVarString::operator ice::VarStringBase::CharType>() const noexcept + { + return _data; + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/sort.hxx b/source/code/core/collections/public/ice/sort.hxx index 1d904480..1f654602 100644 --- a/source/code/core/collections/public/ice/sort.hxx +++ b/source/code/core/collections/public/ice/sort.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -10,9 +10,9 @@ namespace ice { template - inline auto accumulate_over(ice::Span objects, Fn&& fn) noexcept -> ice::ucount + inline auto accumulate_over(ice::Span objects, Fn&& fn) noexcept -> ice::u32 { - ice::ucount result = 0; + ice::u32 result = 0; for (Type const& object : objects) { result += ice::forward(fn)(object); @@ -21,28 +21,28 @@ namespace ice } template requires (std::convertible_to) - constexpr auto lower_bound(ice::Span values, U const& value) noexcept -> ice::ucount; + constexpr auto lower_bound(ice::Span values, U const& value) noexcept -> ice::u32; template requires (std::convertible_to) - constexpr auto lower_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::ucount; + constexpr auto lower_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::u32; template requires (std::convertible_to) - constexpr auto upper_bound(ice::Span values, U const& value) noexcept -> ice::ucount; + constexpr auto upper_bound(ice::Span values, U const& value) noexcept -> ice::u32; template requires (std::convertible_to) - constexpr auto upper_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::ucount; + constexpr auto upper_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::u32; template requires (std::convertible_to) - constexpr bool binary_search(ice::Span values, U const& value, ice::ucount& out_index) noexcept; + constexpr bool binary_search(ice::Span values, U const& value, ice::u32& out_index) noexcept; template requires (std::convertible_to) - constexpr bool binary_search(ice::Span values, U const& value, Comp&& comp, ice::ucount& out_index) noexcept; + constexpr bool binary_search(ice::Span values, U const& value, Comp&& comp, ice::u32& out_index) noexcept; template requires (std::convertible_to) - constexpr bool search(ice::Span values, U const& value, ice::ucount& out_index) noexcept; + constexpr bool search(ice::Span values, U const& value, ice::u32& out_index) noexcept; template - constexpr bool search(ice::Span values, U const& value, Comp&& comp, ice::ucount& out_index) noexcept; + constexpr bool search(ice::Span values, U const& value, Comp&& comp, ice::u32& out_index) noexcept; template inline void sort(ice::Span span) noexcept; @@ -65,51 +65,51 @@ namespace ice template requires (std::convertible_to) - constexpr auto lower_bound(ice::Span values, U const& value) noexcept -> ice::ucount + constexpr auto lower_bound(ice::Span values, U const& value) noexcept -> ice::u32 { - return static_cast(std::lower_bound(ice::span::begin(values), ice::span::end(values), value) - ice::span::begin(values)); + return static_cast(std::lower_bound(ice::span::begin(values), ice::span::end(values), value) - ice::span::begin(values)); } template requires (std::convertible_to) - constexpr auto lower_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::ucount + constexpr auto lower_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::u32 { - return static_cast(std::lower_bound(ice::span::begin(values), ice::span::end(values), value, ice::forward(comp)) - ice::span::begin(values)); + return static_cast(std::lower_bound(ice::span::begin(values), ice::span::end(values), value, ice::forward(comp)) - ice::span::begin(values)); } template requires (std::convertible_to) - constexpr auto upper_bound(ice::Span values, U const& value) noexcept -> ice::ucount + constexpr auto upper_bound(ice::Span values, U const& value) noexcept -> ice::u32 { - return static_cast(std::upper_bound(ice::span::begin(values), ice::span::end(values), value) - ice::span::begin(values)); + return static_cast(std::upper_bound(ice::span::begin(values), ice::span::end(values), value) - ice::span::begin(values)); } template requires (std::convertible_to) - constexpr auto upper_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::ucount + constexpr auto upper_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::u32 { - return static_cast(std::upper_bound(ice::span::begin(values), ice::span::end(values), value, ice::forward(comp)) - ice::span::begin(values)); + return static_cast(std::upper_bound(ice::span::begin(values), ice::span::end(values), value, ice::forward(comp)) - ice::span::begin(values)); } template requires (std::convertible_to) - constexpr bool binary_search(ice::Span values, U const& predicate, ice::ucount& out_index) noexcept + constexpr bool binary_search(ice::Span values, U const& predicate, ice::u32& out_index) noexcept { out_index = ice::lower_bound(values, predicate); return (ice::count(values) != out_index) && (values[out_index] == predicate); } template requires (std::convertible_to) - constexpr bool binary_search(ice::Span values, U const& predicate, Comp&& comp, ice::ucount& out_index) noexcept + constexpr bool binary_search(ice::Span values, U const& predicate, Comp&& comp, ice::u32& out_index) noexcept { out_index = ice::lower_bound(values, predicate, ice::forward(comp)); return (ice::count(values) != out_index) && (values[out_index] == predicate); } template requires (std::convertible_to) - constexpr bool search(ice::Span values, U const& value, ice::ucount& out_index) noexcept + constexpr bool search(ice::Span values, U const& value, ice::u32& out_index) noexcept { return search(values, value, [](auto const& l, auto const& r) noexcept { return l == r; }, out_index); } template - constexpr bool search(ice::Span values, U const& value, Comp&& comp, ice::ucount& out_index) noexcept + constexpr bool search(ice::Span values, U const& value, Comp&& comp, ice::u32& out_index) noexcept { for (ice::u32 idx = 0; idx < ice::span::count(values); ++idx) { @@ -123,7 +123,7 @@ namespace ice } template - constexpr bool search_with(ice::Span values, Comp&& comp, ice::ucount& out_index, U const&... params) noexcept + constexpr bool search_with(ice::Span values, Comp&& comp, ice::u32& out_index, U const&... params) noexcept { for (ice::u32 idx = 0; idx < ice::span::count(values); ++idx) { diff --git a/source/code/core/collections/public/ice/span.hxx b/source/code/core/collections/public/ice/span.hxx index 938454ce..ca947e45 100644 --- a/source/code/core/collections/public/ice/span.hxx +++ b/source/code/core/collections/public/ice/span.hxx @@ -6,6 +6,7 @@ #include #include #include +#include #include // TODO: Introduce our own static array object. namespace ice @@ -20,28 +21,29 @@ namespace ice using ReverseIterator = std::reverse_iterator; using ConstIterator = Type const*; using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; - ice::ucount _count; + u64 _count; Type* _data; constexpr Span() noexcept; constexpr Span(ice::Span&& other) noexcept = default; constexpr Span(ice::Span const& other) noexcept = default; - constexpr Span(Type* location, ice::ucount count) noexcept; + constexpr Span(Type* location, u64 count) noexcept; constexpr Span(Type* from, Type* to) noexcept; - template + template constexpr Span(Type(&location)[Size]) noexcept; constexpr auto operator=(ice::Span&& other) noexcept -> ice::Span& = default; constexpr auto operator=(ice::Span const& other) noexcept -> ice::Span& = default; - constexpr auto operator[](ice::ucount idx) const noexcept -> Type&; + constexpr auto operator[](ice::u64 idx) const noexcept -> Type&; constexpr operator ice::Span() noexcept { return { _data, _count }; } constexpr operator ice::Span() const noexcept { return { _data, _count }; } }; - template Span(T(&)[Size]) noexcept -> Span; + template Span(T(&)[Size]) noexcept -> Span; template Span(ice::Span&&) noexcept -> Span; template Span(ice::Span const&) noexcept -> Span; template typename Container> Span(Container const&) noexcept -> Span; @@ -62,7 +64,7 @@ namespace ice constexpr auto data_view(ice::Span span) noexcept -> ice::Data; template - constexpr auto count(ice::Span span) noexcept -> ice::ucount; + constexpr auto count(ice::Span span) noexcept -> ice::u32; template constexpr auto size_bytes(ice::Span span) noexcept -> ice::usize; @@ -77,13 +79,13 @@ namespace ice constexpr auto back(ice::Span span) noexcept -> Type&; template - constexpr auto head(ice::Span span, ice::ucount count) noexcept -> ice::Span; + constexpr auto head(ice::Span span, ice::u64 count) noexcept -> ice::Span; template - constexpr auto tail(ice::Span span, ice::ucount from_idx) noexcept -> ice::Span; + constexpr auto tail(ice::Span span, ice::u64 from_idx) noexcept -> ice::Span; template - constexpr auto subspan(ice::Span span, ice::ucount from_idx, ice::ucount count = ice::ucount_max) noexcept -> ice::Span; + constexpr auto subspan(ice::Span span, ice::u64 from_idx, ice::u64 count = ice::u32_max) noexcept -> ice::Span; template constexpr auto subspan(ice::Span span, ice::ref32 ref) noexcept -> ice::Span; @@ -126,7 +128,7 @@ namespace ice template requires (std::is_trivially_copyable_v && !std::is_pointer_v) - inline auto read_span(ice::Data source, ice::ucount count, ice::Span& out_value) noexcept -> ice::Data + inline auto read_span(ice::Data source, ice::u64 count, ice::Span& out_value) noexcept -> ice::Data { ICE_ASSERT_CORE(source.alignment >= ice::align_of); out_value._count = count; @@ -149,7 +151,7 @@ namespace ice } template - constexpr Span::Span(Type* location, ice::ucount count) noexcept + constexpr Span::Span(Type* location, ice::u64 count) noexcept : _count{ count } , _data{ location } { @@ -157,13 +159,13 @@ namespace ice template constexpr Span::Span(Type* from, Type* to) noexcept - : _count{ static_cast(to - from) } + : _count{ static_cast(to - from) } , _data{ from } { } template - template + template constexpr Span::Span(Type(&location)[Size]) noexcept : _count{ Size } , _data{ location } @@ -171,7 +173,7 @@ namespace ice } template - constexpr auto Span::operator[](ice::ucount idx) const noexcept -> Type& + constexpr auto Span::operator[](ice::u64 idx) const noexcept -> Type& { // TODO: ASSERT return _data[idx]; @@ -209,9 +211,9 @@ namespace ice } template - constexpr auto count(ice::Span span) noexcept -> ice::ucount + constexpr auto count(ice::Span span) noexcept -> ice::u32 { - return span._count; + return u32(span._count); } template @@ -239,24 +241,24 @@ namespace ice } template - constexpr auto head(ice::Span span, ice::ucount count) noexcept -> ice::Span + constexpr auto head(ice::Span span, ice::u64 count) noexcept -> ice::Span { - ice::ucount const new_count = ice::min(count, span._count); + ice::u64 const new_count = ice::min(count, span._count); return { span._data, new_count }; } template - constexpr auto tail(ice::Span span, ice::ucount from_idx) noexcept -> ice::Span + constexpr auto tail(ice::Span span, ice::u64 from_idx) noexcept -> ice::Span { - ice::ucount const from_start = ice::min(from_idx, span._count); + ice::u64 const from_start = ice::min(from_idx, span._count); return { span._data + from_start, span._count - from_start }; } template - constexpr auto subspan(ice::Span span, ice::ucount from_idx, ice::ucount count) noexcept -> ice::Span + constexpr auto subspan(ice::Span span, ice::u64 from_idx, ice::u64 count) noexcept -> ice::Span { - ice::ucount const from_start = ice::min(from_idx, span._count); - ice::ucount const new_count = ice::min(span._count - from_start, count); + ice::u64 const from_start = ice::min(from_idx, span._count); + ice::u64 const new_count = ice::min(span._count - from_start, count); return { span._data + from_start, new_count }; } @@ -318,13 +320,13 @@ namespace ice template constexpr auto from_std(std::array& std_array) noexcept -> ice::Span { - return ice::Span{ std_array.data(), ice::ucount(std_array.size()) }; + return ice::Span{ std_array.data(), std_array.size() }; } template constexpr auto from_std_const(std::array const& std_array) noexcept -> ice::Span { - return ice::Span{ std_array.data(), ice::ucount(std_array.size()) }; + return ice::Span{ std_array.data(), std_array.size() }; } // TODO: Move to another location or rename? Not sure this is properly named @@ -339,7 +341,7 @@ namespace ice } template - constexpr auto from_memory(ice::Memory const& mem, ice::ucount count, ice::usize offset) noexcept -> ice::Span + constexpr auto from_memory(ice::Memory const& mem, ice::u64 count, ice::usize offset) noexcept -> ice::Span { static ice::meminfo minfo = ice::meminfo_of; @@ -351,7 +353,7 @@ namespace ice // TODO: Move to another location or rename? Not sure this is properly named template - constexpr auto from_data(ice::Data const& mem, ice::ucount count, ice::usize offset) noexcept -> ice::Span + constexpr auto from_data(ice::Data const& mem, ice::u64 count, ice::usize offset) noexcept -> ice::Span { static ice::meminfo constexpr minfo = ice::meminfo_of; diff --git a/source/code/core/collections/public/ice/static_string.hxx b/source/code/core/collections/public/ice/static_string.hxx new file mode 100644 index 00000000..63010dbd --- /dev/null +++ b/source/code/core/collections/public/ice/static_string.hxx @@ -0,0 +1,181 @@ +/// Copyright 2022 - 2026, Dandielo +/// SPDX-License-Identifier: MIT +#pragma once +#include +#include +#include + +namespace ice +{ + + template requires ice::concepts::SupportedCharType + struct StaticString : ice::string::MutableOperations + { + using CharType = CharT; + using ValueType = CharType; + using Iterator = CharType*; + using ReverseIterator = std::reverse_iterator; + using ConstIterator = CharType const*; + using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; + using StringType = ice::BasicString; + + SizeType::base_type _size; + ValueType _data[Capacity]; + + constexpr StaticString() noexcept; + template + constexpr StaticString(CharType const(&str_array)[Size]) noexcept; + constexpr StaticString(BasicString string) noexcept; + + constexpr auto operator=(StaticString const& other) noexcept -> StaticString&; + constexpr auto operator=(BasicString str) noexcept -> StaticString&; + + constexpr operator ice::BasicString() const noexcept; + + // ReadOnly+ Operations + template + constexpr auto data(this Self& self) noexcept { return self._data; } + constexpr auto size() const noexcept -> SizeType { return SizeType{ _size, sizeof(CharType) }; } + + // Mutable operations + constexpr void resize(ice::ncount new_size) noexcept; + constexpr auto capacity() const noexcept -> SizeType { return SizeType{ Capacity, sizeof(CharType) }; } + + // Data info + constexpr auto data_view() const noexcept -> ice::Data; + }; + + template requires ice::concepts::SupportedCharType + constexpr StaticString::StaticString() noexcept + : _size{ 0 } + , _data{ } + { + } + + template requires ice::concepts::SupportedCharType + template + constexpr StaticString::StaticString(CharType const(&str_array)[Size]) noexcept + : StaticString{ ice::BasicString{ str_array, Size } } + { + } + + template requires ice::concepts::SupportedCharType + constexpr StaticString::StaticString(ice::BasicString str) noexcept + : _size{ ice::min(Capacity - 1, str.size().u32()) } + , _data{ } + { + if (std::is_constant_evaluated()) + { + for (ice::u32 idx = 0; idx < _size; ++idx) + { + _data[idx] = str[idx]; + } + } + else if (str.not_empty()) + { + ice::memcpy(this->memory_view(), str.data_view()); + } + _data[_size] = ValueType{ 0 }; + } + + //template requires ice::concepts::SupportedCharType + //template + //constexpr StaticString::StaticString(StaticString const& other) noexcept + // : _size{ ice::min(Capacity - 1, ice::string::size(other)) } + // , _data{ } + //{ + // if (std::is_constant_evaluated()) + // { + // for (ice::ucount idx = 0; idx < _size; ++idx) + // { + // _data[idx] = other[idx]; + // } + // } + // else + // { + // ice::memcpy(ice::string::memory(*this), ice::string::data_view(other)); + // } + // _data[_size] = ValueType{ 0 }; + //} + + //template requires ice::concepts::SupportedCharType + //template + //constexpr auto StaticString::operator=(StaticString const& other) noexcept -> StaticString& + //{ + // if (this != &other) + // { + // ice::string::clear(*this); + + // if (other._size > 0) + // { + // ice::memcpy( + // ice::string::memory(*this), + // ice::string::data_view(other) + // ); + // } + + // _size = ice::min(Capacity - 1, other._size); + // _data[_size] = CharType{ }; + // } + // return *this; + //} + + template requires ice::concepts::SupportedCharType + constexpr auto StaticString::operator=(ice::BasicString other) noexcept -> StaticString& + { + CharType const* const other_str_begin = other.begin(); + bool const part_of_this = other_str_begin >= this->begin() + && other_str_begin < this->end(); + + if (!part_of_this) + { + this->clear(); + ice::memcpy(this->memory_view(), other.data_view()); + this->resize(ice::min(Capacity - 1, other.size())); + } + return *this; + } + + template requires ice::concepts::SupportedCharType + constexpr StaticString::operator ice::BasicString::CharType>() const noexcept + { + return ice::BasicString{ _data, _size }; + } + + template requires ice::concepts::SupportedCharType + constexpr void StaticString::resize(ice::ncount new_size) noexcept + { + _size = ice::min(Capacity - 1, new_size.u32()); + _data[_size] = CharType{ 0 }; + } + + //template + //constexpr bool operator==(ice::StaticString const& left, CharType const* right) noexcept + //{ + // return ice::BasicString{ left } == ice::BasicString{ right }; + //} + + //template + //constexpr bool operator==(ice::StaticString const& left, ice::BasicString right) noexcept + //{ + // return ice::BasicString{ left } == right; + //} + + //template + //constexpr bool operator==(ice::BasicString left, ice::StaticString const& right) noexcept + //{ + // return left == ice::BasicString{ right }; + //} + + template requires ice::concepts::SupportedCharType + constexpr auto StaticString::data_view() const noexcept -> ice::Data + { + return Data{ + .location = _data, + .size = size().bytes(), + .alignment = ice::align_of + }; + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/string.hxx b/source/code/core/collections/public/ice/string.hxx new file mode 100644 index 00000000..5291e166 --- /dev/null +++ b/source/code/core/collections/public/ice/string.hxx @@ -0,0 +1,104 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include + +namespace ice +{ + + template requires ice::concepts::SupportedCharType + struct BasicString : ice::string::ReadOnlyOperations + { + using CharType = CharT; + using ValueType = CharType const; + using ConstIterator = ValueType*; + using ConstReverseIterator = std::reverse_iterator; + using Iterator = ConstIterator; + using ReverseIterator = ConstReverseIterator; + using SizeType = ice::ncount; + using StringType = ice::BasicString; + + ValueType* _data = nullptr; + SizeType::base_type _count = 0; + + constexpr BasicString() noexcept = default; + + constexpr BasicString(BasicString&& other) noexcept = default; + constexpr BasicString(BasicString const& other) noexcept = default; + + constexpr auto operator=(BasicString&& other) noexcept -> BasicString& = default; + constexpr auto operator=(BasicString const& other) noexcept -> BasicString& = default; + + constexpr BasicString(ValueType* ptr_array_nt) noexcept + : _data{ ptr_array_nt } + , _count{ ice::string::detail::strptr_size(ptr_array_nt) } + { } + + constexpr BasicString(ValueType* ptr_array, ice::ncount count) noexcept + : _data{ ptr_array } + , _count{ count.native() } + { } + + constexpr BasicString(ValueType* ptr_array_begin, ValueType* ptr_array_end) noexcept + : _data{ ptr_array_begin } + , _count{ static_cast(ptr_array_end - ptr_array_begin) } + { } + + template + constexpr BasicString(ValueType(&char_array)[Size]) noexcept + : _data{ char_array } + , _count{ Size } + { } + + constexpr BasicString(std::basic_string_view string_view) noexcept + : _data{ string_view.data() } + , _count{ string_view.size() } + { } + + constexpr auto data() const noexcept -> ValueType* { return _data; } + constexpr auto size() const noexcept -> SizeType { return SizeType{ _count, sizeof(CharType) }; } + + constexpr auto data_view() const noexcept -> ice::Data; + + constexpr operator std::basic_string_view() const noexcept { return { _data, _count }; } + }; + + static_assert(ice::concepts::StringType>); + + + constexpr auto operator""_str(char const* buffer, size_t size) noexcept -> ice::BasicString + { + return ice::BasicString{ buffer, size }; + } + + using String = ice::BasicString; + using WString = ice::BasicString; + + template requires ice::concepts::RODataObject + constexpr auto string_from_data(T ro_data, ice::nindex offset, ice::ncount size) noexcept -> ice::BasicString + { + return ice::String{ + reinterpret_cast(ro_data.location) + offset, + ice::min(ro_data.size.value, size) + }; + } + + template requires ice::concepts::SupportedCharType + constexpr auto BasicString::data_view() const noexcept -> ice::Data + { + return Data{ + .location = _data, + .size = size().bytes(), + .alignment = ice::align_of + }; + } + + template requires ice::concepts::RODataObject + constexpr auto string_from_data(T ro_data) noexcept -> ice::BasicString + { + return ice::string_from_data(ro_data, 0, ro_data.size.value); + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/string/editable_operations.hxx b/source/code/core/collections/public/ice/string/editable_operations.hxx new file mode 100644 index 00000000..f2957a7d --- /dev/null +++ b/source/code/core/collections/public/ice/string/editable_operations.hxx @@ -0,0 +1,136 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice::string +{ + + using ice::concepts::MutableStringType; + + struct MutableOperations : ice::string::ReadOnlyOperations + { + template + inline void clear(this Self& self) noexcept + { + self.resize(0); + } + + template + inline void push_back(this Self& self, typename Self::CharType character) noexcept + { + ice::ncount new_size = self.size() + 1; + ice::ncount const capacity = self.capacity(); + + // Handle resizing if supported + if constexpr (ice::concepts::ResizableStringType) + { + if (new_size >= capacity) + { + self.grow(new_size); + } + } + else + { + ICE_ASSERT_CORE(new_size < capacity); + new_size = ice::min(new_size, capacity - 1); + } + + + self.resize(new_size); + self.data()[new_size - 1] = character; + } + + template + inline void push_back(this Self& self, typename Self::CharType const* cstr) noexcept + { + return self.push_back(ice::BasicString{ cstr }); + } + + template + inline void push_back(this Self& self, ice::StringType auto const& other) noexcept + { + if (other.not_empty()) + { + ice::ncount new_size = self.size() + other.size(); + ice::ncount const capacity = self.capacity(); + + // Handle resizing if supported + if constexpr (ice::concepts::ResizableStringType) + { + if (new_size + 1 >= capacity) + { + self.grow(new_size + 1); + } + } + else + { + ICE_ASSERT_CORE(new_size < capacity); + new_size = ice::min(new_size, capacity - 1); + } + + ice::memcpy( + self.end(), + other.cbegin(), + other.size().bytes() + ); + + self.resize(new_size); + } + } + + template + inline void pop_back(this Self& self, ice::ncount count = 1) noexcept + { + if (self.data() != nullptr) + { + ice::ncount const current_size = self.size(); + self.resize(current_size - ice::min(current_size, count)); + } + } + + // Iterators + + template + constexpr auto begin(this Self& self) noexcept -> typename Self::Iterator + { + return self.data(); + } + + template + constexpr auto end(this Self& self) noexcept -> typename Self::Iterator + { + return self.data() + self.size(); + } + + template + constexpr auto rbegin(this Self& self) noexcept -> typename Self::ReverseIterator + { + return typename Self::ReverseIterator{ self.data() + self.size() }; + } + + template + constexpr auto rend(this Self& self) noexcept -> typename Self::ReverseIterator + { + return typename Self::ReverseIterator{ self.data() }; + } + + // Operators + + template + constexpr auto operator[](this Self& self, ice::nindex index) noexcept -> typename Self::ValueType& + { + return self.data()[index.native()]; + } + + // Data Helpers + + template + constexpr auto memory_view(this Self& self) noexcept -> ice::Memory + { + return Memory{ .location = self.data(), .size = self.capacity(), .alignment = ice::align_of }; + } + }; + +} // namespace ice::string diff --git a/source/code/core/collections/public/ice/string/heap_string.hxx b/source/code/core/collections/public/ice/string/heap_string.hxx index c089734e..be3a4095 100644 --- a/source/code/core/collections/public/ice/string/heap_string.hxx +++ b/source/code/core/collections/public/ice/string/heap_string.hxx @@ -3,126 +3,3 @@ #pragma once #include -#include - -namespace ice::string -{ - - template - inline void set_capacity(ice::HeapString& str, ice::ucount new_capacity) noexcept; - - template - inline void reserve(ice::HeapString& str, ice::ucount min_capacity) noexcept; - - template - inline void grow(ice::HeapString& str, ice::ucount min_capacity = 0) noexcept; - - template - inline void resize(ice::HeapString& str, ice::ucount new_size) noexcept; - - template - inline void shrink(ice::HeapString& str) noexcept; - - template - inline void clear(ice::HeapString& str) noexcept; - - template - inline void push_back(ice::HeapString& str, CharType character) noexcept; - - template - inline void push_back(ice::HeapString& str, CharType const* cstr) noexcept; - - template - inline void push_back(ice::HeapString& str, ice::HeapString const& other) noexcept; - - template - inline void push_back(ice::HeapString& str, ice::BasicString cstr) noexcept; - - template - inline void pop_back(ice::HeapString& str, ice::ucount count = 1) noexcept; - - template - inline auto begin(ice::HeapString& str) noexcept -> typename ice::HeapString::Iterator; - - template - inline auto end(ice::HeapString& str) noexcept -> typename ice::HeapString::Iterator; - - template - inline auto rbegin(ice::HeapString& str) noexcept -> typename ice::HeapString::ReverseIterator; - - template - inline auto rend(ice::HeapString& str) noexcept -> typename ice::HeapString::ReverseIterator; - - - template - inline auto size(ice::HeapString const& str) noexcept -> ice::ucount; - - template - inline auto capacity(ice::HeapString const& str) noexcept -> ice::ucount; - - template - inline bool empty(ice::HeapString const& str) noexcept; - - template - inline bool any(ice::HeapString const& str) noexcept; - - template - inline auto begin(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstIterator; - - template - inline auto end(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstIterator; - - template - inline auto rbegin(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstReverseIterator; - - template - inline auto rend(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstReverseIterator; - - template - inline auto front(ice::HeapString const& str) noexcept -> typename ice::HeapString::ValueType; - - template - inline auto back(ice::HeapString const& str) noexcept -> typename ice::HeapString::ValueType; - - template - inline auto substr(ice::HeapString const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::BasicString; - - template - inline auto substr_clone(ice::HeapString const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::HeapString; - - template - inline auto find_first_of(ice::HeapString const& str, CharType character_value) noexcept -> ice::ucount; - - template - inline auto find_first_of(ice::HeapString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - template - inline auto find_last_of(ice::HeapString const& str, CharType character_value) noexcept -> ice::ucount; - - template - inline auto find_last_of(ice::HeapString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - - template - inline auto data_view(ice::HeapString const& str) noexcept -> ice::Data; - - template - inline auto memory(ice::HeapString& str) noexcept -> ice::Memory; - - //! \return Extracts the memory allocated by the heap string. - //! \note The 'size' member contains the 'capacity' of the heap string. - template - inline auto extract_memory(ice::HeapString& str) noexcept -> ice::Memory; - -} // namespace ice::string - -namespace ice -{ - - using ice::string::size; - using ice::string::begin; - using ice::string::end; - -} // namespace ice - -#include "impl/heap_string.inl" diff --git a/source/code/core/collections/public/ice/string/heap_var_string.hxx b/source/code/core/collections/public/ice/string/heap_var_string.hxx index 620d3155..0d7332e1 100644 --- a/source/code/core/collections/public/ice/string/heap_var_string.hxx +++ b/source/code/core/collections/public/ice/string/heap_var_string.hxx @@ -1,7 +1,8 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once +#if 0 #include #include @@ -44,3 +45,4 @@ namespace ice } // namespace ice #include "impl/heap_var_string.inl" +#endif diff --git a/source/code/core/collections/public/ice/string/impl/heap_string.inl b/source/code/core/collections/public/ice/string/impl/heap_string.inl deleted file mode 100644 index 85dd5b4c..00000000 --- a/source/code/core/collections/public/ice/string/impl/heap_string.inl +++ /dev/null @@ -1,474 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - - -namespace ice -{ - - template - inline HeapString::HeapString(ice::Allocator& allocator) noexcept - : _allocator{ &allocator } - , _capacity{ 0 } - , _size{ 0 } - , _data{ nullptr } - { - } - - template - inline HeapString::HeapString(ice::Allocator& allocator, ice::BasicString value) noexcept - : _allocator{ &allocator } - , _capacity{ 0 } - , _size{ 0 } - , _data{ nullptr } - { - *this = value; - } - - template - inline HeapString::HeapString(HeapString&& other) noexcept - : _allocator{ other._allocator } - , _size{ ice::exchange(other._size, 0) } - , _capacity{ ice::exchange(other._capacity, 0) } - , _data{ ice::exchange(other._data, nullptr) } - { - } - - template - inline HeapString::HeapString(HeapString const& other) noexcept - : _allocator{ other._allocator } - , _capacity{ 0 } - , _size{ 0 } - , _data{ nullptr } - { - if (other._size > 0) - { - ice::string::set_capacity(*this, other._size + 1); - - // TODO: We need actually very, VERY good tests for string manipulations... - ice::memcpy( - ice::string::end(*this), - ice::string::begin(other), - ice::size_of *ice::string::size(other) - ); - - _size = other._size; - _data[_size] = CharType{ 0 }; - } - } - - template - inline HeapString::~HeapString() noexcept - { - _allocator->deallocate(ice::string::memory(*this)); - } - - template - inline auto HeapString::operator=(HeapString&& other) noexcept -> HeapString& - { - if (this != &other) - { - ice::string::set_capacity(*this, 0); - - _allocator = other._allocator; - _size = ice::exchange(other._size, 0); - _capacity = ice::exchange(other._capacity, 0); - _data = ice::exchange(other._data, nullptr); - } - return *this; - } - - template - inline auto HeapString::operator=(HeapString const& other) noexcept -> HeapString& - { - if (this != &other) - { - ice::string::clear(*this); - ice::string::reserve(*this, other._capacity); - - if (other._size > 0) - { - ice::memcpy( - ice::string::memory(*this), - ice::string::data_view(other) - ); - } - - _size = other._size; - _data[_size] = CharType{ }; - } - return *this; - } - - template - inline auto HeapString::operator=(ice::BasicString str) noexcept -> HeapString& - { - auto const* const other_str_begin = ice::string::begin(str); - bool const part_of_this = other_str_begin >= ice::string::begin(*this) - && other_str_begin < ice::string::end(*this); - ICE_ASSERT_CORE(part_of_this == false); - - if (!part_of_this) - { - ice::string::set_capacity( - *this, - ice::string::size(str) + 1 - ); - - ice::memcpy( - ice::string::memory(*this), - ice::string::data_view(str) - ); - - _size = ice::string::size(str); - _data[_size] = ValueType{ 0 }; - } - return *this; - } - - template - inline bool operator==(ice::HeapString const& left, CharType const* right) noexcept - { - return ice::BasicString{ left } == ice::BasicString{ right }; - } - - template - inline bool operator==(ice::HeapString const& left, ice::BasicString right) noexcept - { - return ice::BasicString{ left } == right; - } - - template - inline bool operator==(ice::BasicString left, ice::HeapString const& right) noexcept - { - return left == ice::BasicString{ right }; - } - - template - inline auto HeapString::operator[](ice::ucount index) noexcept -> CharType& - { - return _data[index]; - } - - template - inline auto HeapString::operator[](ice::ucount index) const noexcept -> CharType const& - { - return _data[index]; - } - - template - inline HeapString::operator ice::BasicString() const noexcept - { - return { _data, _size }; - } - - namespace string - { - - template - inline void set_capacity(ice::HeapString& str, ice::ucount new_capacity) noexcept - { - using ValueType = typename HeapString::ValueType; - - if (new_capacity == str._capacity) - { - return; - } - - ValueType* new_data = nullptr; - if (new_capacity > 0) - { - ice::AllocResult new_buffer = str._allocator->allocate(ice::meminfo_of * new_capacity); - - if (str._size > 0) - { - ice::memcpy(new_buffer, ice::string::data_view(str)); - } - - new_data = reinterpret_cast(new_buffer.memory); - } - - str._allocator->deallocate(ice::string::memory(str)); - str._capacity = new_capacity; - str._data = new_data; - - if (new_capacity <= str._size) - { - str._size = ice::min(new_capacity, new_capacity - 1); - } - - if (str._data != nullptr) - { - str._data[str._size] = 0; - } - } - - template - inline void reserve(ice::HeapString& str, ice::ucount min_capacity) noexcept - { - if (min_capacity > str._capacity) - { - ice::string::set_capacity(str, min_capacity); - } - } - - template - inline void grow(ice::HeapString& str, ice::ucount min_capacity) noexcept - { - ice::ucount const new_capacity = ice::max(str._capacity * 2 + 8, min_capacity); - ice::string::set_capacity(str, new_capacity); - } - - template - inline void resize(ice::HeapString& str, ice::ucount new_size) noexcept - { - if (new_size > 0 && new_size >= str._capacity) - { - ice::string::set_capacity(str, new_size + 1); - } - - str._size = new_size; - if (str._data != nullptr) - { - str._data[str._size] = CharType{ 0 }; - } - } - - template - inline void shrink(ice::HeapString& str) noexcept - { - ice::string::set_capacity(str, str._size + 1); - } - - template - inline void clear(ice::HeapString& str) noexcept - { - ice::string::resize(str, 0); - } - - template - inline void push_back(ice::HeapString& str, CharType character) noexcept - { - if (str._size + 1 >= str._capacity) - { - ice::string::grow(str); - } - - str._data[str._size] = character; - str._size += 1; - str._data[str._size] = CharType{ 0 }; - } - - template - inline void push_back(ice::HeapString& str, CharType const* cstr) noexcept - { - return ice::string::push_back(str, ice::BasicString{ cstr }); - } - - template - inline void push_back(ice::HeapString& str, ice::HeapString const& other) noexcept - { - return ice::string::push_back(str, other.operator ice::BasicString()); - } - - template - inline void push_back(ice::HeapString& str, ice::BasicString other) noexcept - { - if (ice::string::empty(other) == false) - { - uint32_t const new_size = str._size + ice::string::size(other); - if (new_size + 1 >= str._capacity) - { - ice::string::grow(str, new_size + 1); - } - - ice::memcpy( - ice::string::end(str), - ice::string::begin(other), - ice::size_of * ice::string::size(other) - ); - str._size = new_size; - str._data[str._size] = 0; - } - } - - template - inline void pop_back(ice::HeapString& str, ice::ucount count) noexcept - { - if (str._data != nullptr) - { - str._size -= ice::min(str._size, count); - str._data[str._size] = CharType{ 0 }; - } - } - - template - inline auto begin(ice::HeapString& str) noexcept -> typename ice::HeapString::Iterator - { - return str._data; - } - - template - inline auto end(ice::HeapString& str) noexcept -> typename ice::HeapString::Iterator - { - return str._data + str._size; - } - - template - inline auto rbegin(ice::HeapString& str) noexcept -> typename ice::HeapString::ReverseIterator - { - return typename ice::HeapString::ReverseIterator{ str._data + str._size }; - } - - template - inline auto rend(ice::HeapString& str) noexcept -> typename ice::HeapString::ReverseIterator - { - return typename ice::HeapString::ReverseIterator{ str._data }; - } - - - template - inline auto size(ice::HeapString const& str) noexcept -> ice::ucount - { - return str._size; - } - - template - inline auto capacity(ice::HeapString const& str) noexcept -> ice::ucount - { - return str._capacity; - } - - template - inline bool empty(ice::HeapString const& str) noexcept - { - return str._size == 0; - } - - template - inline bool any(ice::HeapString const& str) noexcept - { - return str._size != 0; - } - - template - inline auto begin(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstIterator - { - return str._data; - } - - template - inline auto end(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstIterator - { - return str._data + str._size; - } - - template - inline auto rbegin(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstReverseIterator - { - return typename ice::HeapString::ConstReverseIterator{ str._data + str._size }; - } - - template - inline auto rend(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstReverseIterator - { - return typename ice::HeapString::ConstReverseIterator{ str._data }; - } - - template - inline auto front(ice::HeapString const& str) noexcept -> typename ice::HeapString::ValueType - { - return str._data[0]; - } - - template - inline auto back(ice::HeapString const& str) noexcept -> typename ice::HeapString::ValueType - { - return str._data[str._size - 1]; - } - - template - inline auto substr(ice::HeapString const& str, ice::ucount pos, ice::ucount len) noexcept -> ice::BasicString - { - return ice::string::substr(ice::BasicString{ str }, pos, len); - } - - template - inline auto substr_clone(ice::HeapString const& str, ice::ucount pos, ice::ucount len) noexcept -> ice::HeapString - { - if (pos >= str._size) - { - return ice::HeapString{ *str._allocator }; - } - - ice::ucount pos_end = str._size; - if (len != ice::String_NPos) - { - pos_end = ice::min(pos_end, pos + len); - } - - return ice::HeapString{ - *str._allocator, - ice::BasicString{ str._data + pos, str._data + pos_end } - }; - } - - template - inline auto find_first_of(ice::HeapString const& str, CharType character_value) noexcept -> uint32_t - { - return ice::string::find_first_of(ice::BasicString{ str }, character_value); - } - - template - inline auto find_first_of(ice::HeapString const& str, ice::BasicString character_values) noexcept -> uint32_t - { - return ice::string::find_first_of(ice::BasicString{ str }, character_values); - } - - template - inline auto find_last_of(ice::HeapString const& str, CharType character_value) noexcept -> uint32_t - { - return ice::string::find_last_of(ice::BasicString{ str }, character_value); - } - - template - inline auto find_last_of(ice::HeapString const& str, ice::BasicString character_values) noexcept -> uint32_t - { - return ice::string::find_last_of(ice::BasicString{ str }, character_values); - } - - - template - inline auto data_view(ice::HeapString const& str) noexcept -> ice::Data - { - return ice::Data{ - .location = str._data, - .size = ice::size_of * str._size, - .alignment = ice::align_of - }; - } - - template - inline auto memory(ice::HeapString& str) noexcept -> ice::Memory - { - return ice::Memory{ - .location = str._data, - .size = ice::size_of * str._capacity, - .alignment = ice::align_of - }; - } - - template - inline auto extract_memory(ice::HeapString& str) noexcept -> ice::Memory - { - ice::exchange(str._size, 0); - - return ice::Memory{ - .location = ice::exchange(str._data, nullptr), - .size = ice::size_of * ice::exchange(str._capacity, 0), - .alignment = ice::align_of - }; - } - - } // namespace string - -} // namespace ice diff --git a/source/code/core/collections/public/ice/string/impl/heap_var_string.inl b/source/code/core/collections/public/ice/string/impl/heap_var_string.inl index dda767c7..cc84f467 100644 --- a/source/code/core/collections/public/ice/string/impl/heap_var_string.inl +++ b/source/code/core/collections/public/ice/string/impl/heap_var_string.inl @@ -1,13 +1,14 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT namespace ice { - namespace string::detail +#if 0 + namespace varstring { - inline auto allocate_varstring_exact(ice::Allocator& alloc, ice::ucount size, ice::ucount& out_size_bytes) noexcept -> char* + inline auto allocate_exact(ice::Allocator& alloc, ice::ncount size, ice::ucount& out_size_bytes) noexcept -> char* { if (size == 0) { @@ -15,21 +16,21 @@ namespace ice } // Allocate enough for: bytes + size + '\0' - ice::ucount const final_size = ice::string::detail::calc_varstring_required_size(size) + 1; + ice::usize const final_size = calc_required_size(size) + 1_B; ice::Memory const result = alloc.allocate(ice::usize{ final_size }); - out_size_bytes = write_varstring_size(result.location, size); + out_size_bytes = write_size(result.location, size); return reinterpret_cast(result.location); } - inline auto create_varstring(ice::Allocator& alloc, ice::String str) noexcept -> char* + inline auto create(ice::Allocator& alloc, ice::String str) noexcept -> char* { - ice::ucount const str_size = ice::string::size(str); + ice::ncount const str_size = str.size(); - ice::ucount bytes = 0; - char* data = ice::string::detail::allocate_varstring_exact(alloc, str_size, bytes); + ice::u32 bytes = 0; + char* const data = allocate_exact(alloc, str_size.u32(), bytes); if (data != nullptr) { - ice::memcpy(data + bytes, ice::string::begin(str), str_size); + ice::memcpy(data + bytes, str.begin(), str_size.bytes()); data[bytes + str_size] = '\0'; } return data; @@ -186,5 +187,6 @@ namespace ice } } // namespace string +#endif } // namespace ice diff --git a/source/code/core/collections/public/ice/string/impl/static_string.inl b/source/code/core/collections/public/ice/string/impl/static_string.inl deleted file mode 100644 index a91d9276..00000000 --- a/source/code/core/collections/public/ice/string/impl/static_string.inl +++ /dev/null @@ -1,381 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - - -namespace ice -{ - - template - constexpr StaticString::StaticString() noexcept - : _size{ 0 } - , _data{ } - { - } - - template - template - constexpr StaticString::StaticString(CharType const(&str_arr)[ArraySize]) noexcept - : StaticString{ ice::BasicString{ str_arr } } - { - } - - template - constexpr StaticString::StaticString(ice::BasicString str) noexcept - : _size{ ice::min(Capacity - 1, ice::string::size(str)) } - , _data{ } - { - if (std::is_constant_evaluated()) - { - for (ice::ucount idx = 0; idx < _size; ++idx) - { - _data[idx] = str[idx]; - } - _data[_size] = ValueType{ 0 }; - } - else if (ice::string::any(str)) - { - ice::memcpy(ice::string::memory(*this), ice::string::data_view(str)); - _data[_size] = ValueType{ 0 }; - } - } - - template - template - constexpr StaticString::StaticString(StaticString const& other) noexcept - : _size{ ice::min(Capacity - 1, ice::string::size(other)) } - , _data{ } - { - if (std::is_constant_evaluated()) - { - for (ice::ucount idx = 0; idx < _size; ++idx) - { - _data[idx] = other[idx]; - } - } - else - { - ice::memcpy(ice::string::memory(*this), ice::string::data_view(other)); - } - _data[_size] = ValueType{ 0 }; - } - - template - template - constexpr auto StaticString::operator=(StaticString const& other) noexcept -> StaticString& - { - if (this != &other) - { - ice::string::clear(*this); - - if (other._size > 0) - { - ice::memcpy( - ice::string::memory(*this), - ice::string::data_view(other) - ); - } - - _size = ice::min(Capacity - 1, other._size); - _data[_size] = CharType{ }; - } - return *this; - } - - template - constexpr auto StaticString::operator=(ice::BasicString other) noexcept -> StaticString& - { - auto const* const other_str_begin = ice::string::begin(other); - bool const part_of_this = other_str_begin >= ice::string::begin(*this) - && other_str_begin < ice::string::end(*this); - - if (!part_of_this) - { - ice::string::clear(*this); - - ice::memcpy( - ice::string::memory(*this), - ice::string::data_view(other) - ); - - _size = ice::min(Capacity - 1, ice::string::size(other)); - _data[_size] = ValueType{ 0 }; - } - return *this; - } - - template - constexpr StaticString::operator ice::BasicString() const noexcept - { - return { _data, _size }; - } - - template - constexpr bool operator==(ice::StaticString const& left, CharType const* right) noexcept - { - return ice::BasicString{ left } == ice::BasicString{ right }; - } - - template - constexpr bool operator==(ice::StaticString const& left, ice::BasicString right) noexcept - { - return ice::BasicString{ left } == right; - } - - template - constexpr bool operator==(ice::BasicString left, ice::StaticString const& right) noexcept - { - return left == ice::BasicString{ right }; - } - - namespace string - { - - template - constexpr void resize(ice::StaticString& str, ice::ucount new_size) noexcept - { - // #todo assert(new_size < Capacity) - str._size = ice::min(Capacity - 1, new_size); - str._data[str._size] = CharType{ 0 }; - } - - template - constexpr void clear(ice::StaticString& str) noexcept - { - ice::string::resize(str, 0); - } - - template - constexpr void push_back(ice::StaticString& str, CharType character) noexcept - { - // #todo assert(new_size < Capacity) - if (str._size + 1 < Capacity) - { - str._data[str._size] = character; - str._size += 1; - str._data[str._size] = CharType{ 0 }; - } - } - - template - constexpr void push_back(ice::StaticString& str, CharType const* cstr) noexcept - { - return ice::string::push_back(str, ice::BasicString{ cstr }); - } - - template - constexpr void push_back(ice::StaticString& str, ice::BasicString other) noexcept - { - if (ice::string::empty(other) == false) - { - // #todo assert(new_size < Capacity) - ice::ucount const new_size = ice::min(Capacity - 1, ice::string::size(str) + ice::string::size(other)); - ice::ucount const copy_size = new_size - ice::string::size(str); - - if (copy_size > 0) - { - ice::memcpy( - ice::string::end(str), - ice::string::begin(other), - ice::size_of * copy_size - ); - str._size = new_size; - str._data[str._size] = 0; - } - } - } - - template - constexpr void push_back(ice::StaticString& str, ice::StaticString other) noexcept - { - push_back(str, ice::String{ other }); - } - - template - constexpr void pop_back(ice::StaticString& str, ice::ucount count) noexcept - { - str._size -= ice::min(count, str._size); - str._data[str._size] = CharType{ 0 }; - } - - template - constexpr auto begin(ice::StaticString& str) noexcept -> typename ice::StaticString::Iterator - { - return str._data; - } - - template - constexpr auto end(ice::StaticString& str) noexcept -> typename ice::StaticString::Iterator - { - return str._data + str._size; - } - - template - constexpr auto rbegin(ice::StaticString& str) noexcept -> typename ice::StaticString::ReverseIterator - { - return typename ice::HeapString::ReverseIterator{ str._data + str._size }; - } - - template - constexpr auto rend(ice::StaticString& str) noexcept -> typename ice::StaticString::ReverseIterator - { - return typename ice::HeapString::ReverseIterator{ str._data }; - } - - - template - constexpr auto size(ice::StaticString const& str) noexcept -> ice::ucount - { - return str._size; - } - - template - constexpr auto data(ice::StaticString const& str) noexcept -> typename ice::StaticString::ValueType const* - { - return str._data; - } - - template - constexpr auto capacity(ice::StaticString const& str) noexcept -> ice::ucount - { - return Capacity; - } - - template - constexpr bool empty(ice::StaticString const& str) noexcept - { - return str._size == 0; - } - - template - constexpr auto begin(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstIterator - { - return str._data; - } - - template - constexpr auto end(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstIterator - { - return str._data + str._size; - } - - template - constexpr auto rbegin(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstReverseIterator - { - return typename ice::HeapString::ConstReverseIterator{ str._data + str._size }; - } - - template - constexpr auto rend(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstReverseIterator - { - return typename ice::HeapString::ConstReverseIterator{ str._data }; - } - - template - constexpr auto front(ice::StaticString const& str) noexcept -> typename ice::StaticString::ValueType - { - return str._data[0]; - } - - template - constexpr auto back(ice::StaticString const& str) noexcept -> typename ice::StaticString::ValueType - { - return str._data[str._size - 1]; - } - - template - constexpr auto substr(ice::StaticString const& str, ice::ucount pos, ice::ucount len) noexcept -> ice::BasicString - { - return ice::string::substr(ice::BasicString{ str }, pos, len); - } - - template - constexpr auto substr_clone(ice::StaticString const& str, ice::ucount pos, ice::ucount len) noexcept -> ice::StaticString - { - if (pos >= str._size) - { - return ice::StaticString{ }; - } - - ice::ucount pos_end = str._size; - if (len != ice::String_NPos) - { - pos_end = ice::min(pos_end, pos + len); - } - - return ice::StaticString{ - ice::BasicString{ str._data + pos, str._data + pos_end } - }; - } - - template - constexpr auto find_first_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount - { - return ice::string::find_first_of(ice::BasicString{ str }, character_value); - } - - template - constexpr auto find_first_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount - { - return ice::string::find_first_of(ice::BasicString{ str }, character_values); - } - - template - constexpr auto find_last_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount - { - return ice::string::find_last_of(ice::BasicString{ str }, character_value); - } - - template - constexpr auto find_last_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount - { - return ice::string::find_last_of(ice::BasicString{ str }, character_values); - } - - template - constexpr auto find_first_not_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount - { - return ice::string::find_first_not_of(ice::BasicString{ str }, character_value); - } - - template - constexpr auto find_first_not_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount - { - return ice::string::find_first_not_of(ice::BasicString{ str }, character_values); - } - - template - constexpr auto find_last_not_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount - { - return ice::string::find_last_not_of(ice::BasicString{ str }, character_value); - } - - template - constexpr auto find_last_not_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount - { - return ice::string::find_last_not_of(ice::BasicString{ str }, character_values); - } - - - template - constexpr auto data_view(ice::StaticString const& str) noexcept -> ice::Data - { - return ice::Data{ - .location = str._data, - .size = ice::size_of * str._size, - .alignment = ice::align_of - }; - } - - template - constexpr auto memory(ice::StaticString& str) noexcept -> ice::Memory - { - return ice::Memory{ - .location = str._data, - .size = ice::size_of * Capacity, - .alignment = ice::align_of - }; - } - - } // namespace string - -} // namespace ice diff --git a/source/code/core/collections/public/ice/string/impl/string.inl b/source/code/core/collections/public/ice/string/impl/string.inl deleted file mode 100644 index 4aa17b5e..00000000 --- a/source/code/core/collections/public/ice/string/impl/string.inl +++ /dev/null @@ -1,403 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - - -namespace ice -{ - - constexpr auto operator""_str(char const* buffer, size_t size) noexcept -> ice::BasicString - { - return ice::BasicString{ buffer, ice::ucount(size) }; - } - - namespace string::detail - { - - template - constexpr auto strptr_size(CharType const* str) noexcept -> ice::ucount - { - ice::ucount result = 0; - if (str != nullptr) - { - CharType const* it = str; - while (*it != CharType{ 0 }) - { - it += 1; - } - - result = static_cast(it - str); - } - return result; - } - - } // namespace string::detail - - template - constexpr BasicString::BasicString(CharType const* str_ptr) noexcept - : BasicString{ str_ptr, ice::string::detail::strptr_size(str_ptr) } - { - } - - template - constexpr BasicString::BasicString(CharType const* str_beg, CharType const* str_end) noexcept - : BasicString{ str_beg, static_cast(str_end - str_beg) } - { - } - - template - constexpr BasicString::BasicString(CharType const* str_ptr, ice::ucount size) noexcept - : _data{ str_ptr } - , _size{ size } - { - } - - template - template - constexpr BasicString::BasicString(CharType const(&str_arr)[Size]) noexcept - : _data{ str_arr } - , _size{ Size } - { - } - - template - constexpr BasicString::BasicString(std::basic_string_view sv) noexcept - : _data{ sv.data() } - , _size{ ice::ucount(sv.size()) } - { - } - - template - constexpr auto BasicString::operator[](ice::ucount index) const noexcept -> CharType const& - { - return _data[index]; - } - - template - constexpr bool BasicString::operator==(BasicString other) const noexcept - { - if (_size == other._size) - { - if (_size == 0) - { - return true; - } - - ice::ucount idx = 0; - while (idx < _size && _data[idx] == other._data[idx]) - { - idx += 1; - } - return idx == _size; - } - return false; - } - - template - constexpr BasicString::operator std::basic_string_view() const noexcept - { - return { _data, _size }; - } - - namespace string - { - - template - constexpr auto size(ice::BasicString str) noexcept -> ice::ucount - { - return str._size; - } - - template - constexpr auto capacity(ice::BasicString str) noexcept -> ice::ucount - { - return ice::string::size(str); - } - - template - constexpr bool empty(ice::BasicString str) noexcept - { - return str._size == 0; - } - - template - constexpr bool any(ice::BasicString str) noexcept - { - return str._size != 0; - } - - template - constexpr auto begin(ice::BasicString str) noexcept -> typename ice::BasicString::ConstIterator - { - return str._data; - } - - template - constexpr auto end(ice::BasicString str) noexcept -> typename ice::BasicString::ConstIterator - { - return str._data + str._size; - } - - template - constexpr auto rbegin(ice::BasicString str) noexcept -> typename ice::BasicString::ConstReverseIterator - { - return typename ice::BasicString::ConstReverseIterator{ str._data + str._size }; - } - - template - constexpr auto rend(ice::BasicString str) noexcept -> typename ice::BasicString::ConstReverseIterator - { - return typename ice::BasicString::ConstReverseIterator{ str._data }; - } - - template - constexpr auto front(ice::BasicString str) noexcept -> typename ice::BasicString::ValueType - { - return str[0]; - } - - template - constexpr auto back(ice::BasicString str) noexcept -> typename ice::BasicString::ValueType - { - return str[str._size - 1]; - } - - template - constexpr auto substr(ice::BasicString str, ice::ucount pos, ice::ucount len) noexcept -> ice::BasicString - { - if (pos >= str._size) - { - return { }; - } - - if (len == ice::String_NPos) - { - return { str._data + pos, str._size - pos }; - } - else - { - return { str._data + pos, std::min(len, str._size - pos) }; - } - } - - template - constexpr auto substr(ice::BasicString str, ice::ref32 ref) noexcept -> ice::BasicString - { - return ice::string::substr(str, ref.offset, ref.size); - } - - template - constexpr auto starts_with(ice::BasicString str, ice::concepts::StringType auto prefix) noexcept - { - return ice::string::substr(str, 0, prefix._size) == prefix; - } - - - template - constexpr auto find_first_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto const* it = ice::string::begin(str) + start_idx; - auto const* const beg = it; - auto const* const end = ice::string::end(str); - - while (it < end && *it != character_value) - { - it += 1; - } - - return it >= end ? ice::String_NPos : start_idx + ice::ucount(it - beg); - } - - template - constexpr auto find_first_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto const* it = ice::string::begin(str) + start_idx; - auto const* const beg = it; - auto const* const it_end = ice::string::end(str); - - while (it < it_end && ice::string::find_first_of(character_values, *it) == ice::String_NPos) - { - it += 1; - } - - return it >= it_end ? ice::String_NPos : start_idx + ice::ucount(it - beg); - } - - template - constexpr auto find_last_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto it = ice::string::rbegin(str); - auto const it_end = ice::string::rend(str); - - while (it != it_end && start_idx > 0) - { - it += 1; - start_idx -= 1; - } - - while (it != it_end && *it != character_value) - { - it += 1; - } - - return it == it_end ? ice::String_NPos : ice::ucount(it_end - it) - 1; - } - - template - constexpr auto find_last_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto it = ice::string::rbegin(str); - auto const it_end = ice::string::rend(str); - - while (it != it_end && start_idx > 0) - { - it += 1; - start_idx -= 1; - } - - while (it != it_end && ice::string::find_first_of(character_values, *it) == ice::String_NPos) - { - it += 1; - } - - return it == it_end ? ice::String_NPos : ice::ucount(it_end - it) - 1; - } - - template - constexpr auto find_first_not_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto const* it = ice::string::begin(str) + start_idx; - auto const* const beg = it; - auto const* const end = ice::string::end(str); - - while (it < end && *it == character_value) - { - it += 1; - } - - return it >= end ? ice::String_NPos : start_idx + ice::ucount(it - beg); - } - - template - constexpr auto find_first_not_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto const* it = ice::string::begin(str) + start_idx; - auto const* const beg = it; - auto const* const it_end = ice::string::end(str); - - while (it < it_end && ice::string::find_first_of(character_values, *it) != ice::String_NPos) - { - it += 1; - } - - return it >= it_end ? ice::String_NPos : start_idx + ice::ucount(it - beg); - } - - template - constexpr auto find_last_not_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto it = ice::string::rbegin(str); - auto const end = ice::string::rend(str); - - while (it != end && start_idx > 0) - { - it += 1; - start_idx -= 1; - } - - while (it != end && *it == character_value) - { - it += 1; - } - - return it == end ? ice::String_NPos : ice::ucount(end - it) - 1; - } - - template - constexpr auto find_last_not_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto it = ice::string::rbegin(str); - auto const it_end = ice::string::rend(str); - - while (it != it_end && start_idx > 0) - { - it += 1; - start_idx -= 1; - } - - while (it != it_end && ice::string::find_first_of(character_values, *it) != ice::String_NPos) - { - it += 1; - } - - return it == it_end ? ice::String_NPos : ice::ucount(it_end - it) - 1; - } - - - template requires ice::concepts::RODataObject - constexpr auto from_data(T ro_data) noexcept -> ice::BasicString - { - return ice::string::from_data(ro_data, 0_B, static_cast(ro_data.size.value)); - } - - template requires ice::concepts::RODataObject - constexpr auto from_data(T ro_data, ice::usize offset, ice::ucount size) noexcept -> ice::String - { - return ice::String{ - reinterpret_cast(ro_data.location) + offset.value, - ice::min(static_cast(ro_data.size.value), size) - }; - } - - template - constexpr auto data_view(ice::BasicString str) noexcept -> typename ice::Data - { - return ice::Data{ - .location = str._data, - .size = ice::size_of * str._size, - .alignment = ice::align_of - }; - } - - template - constexpr auto meminfo(ice::BasicString str) noexcept -> ice::meminfo - { - return ice::meminfo{ - ice::meminfo_of * ice::string::size(str) - }; - } - - } // namespace string - -} // namespace ice diff --git a/source/code/core/collections/public/ice/string/impl/var_string.inl b/source/code/core/collections/public/ice/string/impl/var_string.inl index c57ad0be..9f1382ff 100644 --- a/source/code/core/collections/public/ice/string/impl/var_string.inl +++ b/source/code/core/collections/public/ice/string/impl/var_string.inl @@ -1,116 +1,14 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT namespace ice { - namespace string::detail - { - - inline auto calc_varstring_required_size(ice::ucount size) noexcept -> ice::ucount - { - ice::ucount bytes = 0; - while(size > 0x7f) - { - size >>= 7; - bytes += 1; - } - return (bytes + 1) + size; - } - - inline auto read_varstring_size(char const* data, ice::ucount& out_bytes) noexcept -> ice::ucount - { - ice::ucount result = 0; - if (data != nullptr) - { - ice::u8 const* var_byte = reinterpret_cast(data); - out_bytes = 1; - while(*var_byte & 0x80) - { - result += *var_byte; - result <<= 7; - var_byte += 1; - out_bytes += 1; - } - result += *var_byte; - } - return result; - } - - inline auto read_varstring_size(char const* data) noexcept -> ice::ucount - { - ice::ucount bytes; // Unused - return read_varstring_size(data, bytes); - } - - template - inline auto data_varstring(CharType const* data) noexcept -> CharType const* - { - ice::ucount bytes = 0; - if (data == nullptr || read_varstring_size(data, bytes) == 0) - { - return nullptr; - } - return data + bytes; - } - - inline auto write_varstring_size(void* data, ice::ucount size) noexcept -> ice::ucount - { - ice::ucount bytes = 0; - ice::u8* var_byte = reinterpret_cast(data); - while (size > 0x7f) - { - var_byte[bytes] = (size & 0x7f) | 0x80; - size >>= 7; - bytes += 1; - } - var_byte[bytes] = size & 0x7f; - return bytes + 1; - } - - } // namespace detail - - template - inline VarStringBase::VarStringBase() noexcept - : _data{ nullptr } - { } - - template - inline VarStringBase::VarStringBase(CharType const* str_ptr) noexcept - : _data{ str_ptr } - { - } - - template - inline auto VarStringBase::operator[](ice::ucount idx) noexcept -> CharType& - { - ice::ucount bytes = 0; - ice::ucount const size = read_varstring_size(_data, bytes); - ICE_ASSERT_CORE(size > idx); - return (_data + bytes + idx); - } - - template - inline auto VarStringBase::operator[](ice::ucount idx) const noexcept -> CharType const& - { - ice::ucount bytes = 0; - ice::ucount const size = read_varstring_size(_data, bytes); - ICE_ASSERT_CORE(size > idx); - return (_data + bytes + idx); - } - - template - inline VarStringBase::operator ice::BasicString() const noexcept - { - ice::u32 bytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(_data, bytes); - return { _data + bytes, size }; - } - namespace string { +#if 0 inline auto size(ice::string::VarStringType auto const& str) noexcept -> ice::ucount { return ice::string::detail::read_varstring_size(str._data); @@ -139,7 +37,9 @@ namespace ice ice::ucount const size = ice::string::detail::read_varstring_size(str._data, bytes); return str._data + bytes + size; } +#endif +#if 0 inline auto data_view(ice::string::VarStringType auto const& str) noexcept -> ice::Data { ice::ucount bytes = 0; @@ -169,9 +69,11 @@ namespace ice target.alignment = ice::ualign::b_1; return target; } +#endif } // namespace string +#if 0 namespace data { @@ -193,5 +95,6 @@ namespace ice } } // namespace data +#endif } // namespace ice diff --git a/source/code/core/collections/public/ice/string/readonly_operations.hxx b/source/code/core/collections/public/ice/string/readonly_operations.hxx new file mode 100644 index 00000000..9ea47395 --- /dev/null +++ b/source/code/core/collections/public/ice/string/readonly_operations.hxx @@ -0,0 +1,334 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include + +namespace ice::string +{ + + using ice::concepts::StringType; + + struct ReadOnlyOperations + { + template + constexpr bool is_empty(this Self const& self) noexcept + { + return self.size() == 0; + } + + template + constexpr bool not_empty(this Self const& self) noexcept + { + return self.size() > 0; + } + + template + inline auto front(this Self const& self) noexcept -> typename Self::CharType + { + return self.data()[0]; + } + + template + inline auto back(this Self const& self) noexcept -> typename Self::CharType + { + return self.data()[self.size() - 1]; + } + + template + constexpr auto substr( + this Self const& self, ice::nindex pos, ice::ncount len = {} + ) noexcept -> typename Self::StringType + { + ice::ncount const size = self.size(); + if (pos >= size) + { + return { }; + } + + if (len == ice::none_count) + { + return { self.data() + pos, size - pos }; + } + else + { + return { self.data() + pos, std::min(len, size - pos) }; + } + } + + template + constexpr auto substr( + this Self const& self, ice::ref32 ref + ) noexcept -> typename Self::StringType + { + return self.substr(ref.offset, ref.size); + } + + template + constexpr auto starts_with(this Self const& self, StringType auto prefix) noexcept + { + return self.substr(0, prefix.size()) == prefix; + } + + template + constexpr auto find_first_of( + this Self const& self, + typename Self::CharType character_value, + ice::nindex start = 0 + ) noexcept -> ice::nindex + { + auto const* it = self.cbegin() + start; + auto const* const beg = it; + auto const* const end = self.cend(); + + while (it < end && *it != character_value) + { + it += 1; + } + + return it >= end ? ice::nindex{} : ice::nindex{ start + (it - beg) }; + } + + template + constexpr auto find_first_of( + this Self const& self, + typename Self::StringType character_values, + ice::nindex start = 0 + ) noexcept -> ice::nindex + { + auto const* it = self.cbegin() + start; + auto const* const beg = it; + auto const* const it_end = self.cend(); + + while (it < it_end && character_values.find_first_of(*it) == none_index) + { + it += 1; + } + + return it >= it_end ? ice::nindex{} : ice::nindex{ start + (it - beg) }; + } + + template + constexpr auto find_last_of( + this Self const& self, + typename Self::CharType character_value, + ice::nindex start = 0 + ) noexcept -> ice::nindex + { + auto it = self.crbegin(); + auto const it_end = self.crend(); + + while (it != it_end && start > 0) + { + it += 1; + start -= 1; + } + + while (it != it_end && *it != character_value) + { + it += 1; + } + + return it == it_end ? ice::nindex{} : ice::nindex{ u64((it_end - it) - 1) }; + } + + template + constexpr auto find_last_of( + this Self const& self, + typename Self::StringType character_values, + ice::nindex start = 0 + ) noexcept -> ice::nindex + { + auto it = self.crbegin(); + auto const it_end = self.crend(); + + while (it != it_end && start > 0) + { + it += 1; + start -= 1; + } + + while (it != it_end && character_values.find_first_of(*it) == none_index) + { + it += 1; + } + + return it == it_end ? ice::nindex{} : ice::nindex{ u64((it_end - it) - 1) }; + } + + template + constexpr auto find_first_not_of( + this Self const& self, + typename Self::CharType character_value, + ice::nindex start_idx = 0 + ) noexcept -> ice::nindex + { + auto const* it = self.cbegin() + start_idx; + auto const* const beg = it; + auto const* const end = self.cend(); + + while (it < end && *it == character_value) + { + it += 1; + } + + return it >= end ? ice::nindex{} : start_idx + ice::nindex{ u64(it - beg) }; + } + + template + constexpr auto find_first_not_of( + this Self const& self, + typename Self::StringType character_values, + ice::nindex start_idx = 0 + ) noexcept -> ice::nindex + { + auto const* it = self.cbegin() + start_idx; + auto const* const beg = it; + auto const* const it_end = self.cend(); + + while (it < it_end && character_values.find_first_of(*it) != ice::none_index) + { + it += 1; + } + + return it >= it_end ? ice::nindex{} : start_idx + ice::nindex{ u64(it - beg) }; + } + + template + constexpr auto find_last_not_of( + this Self const& self, + typename Self::CharType character_value, + ice::nindex start_idx = 0 + ) noexcept -> ice::nindex + { + auto it = self.crbegin(); + auto const end = self.crend(); + + while (it != end && start_idx > 0) + { + it += 1; + start_idx -= 1; + } + + while (it != end && *it == character_value) + { + it += 1; + } + + return it == end ? ice::nindex{} : ice::nindex{ u64((end - it) - 1) }; + } + + template + constexpr auto find_last_not_of( + this Self const& self, + typename Self::StringType character_values, + ice::nindex start_idx = 0 + ) noexcept -> ice::nindex + { + auto it = self.crbegin(); + auto const it_end = self.crend(); + + while (it != it_end && start_idx > 0) + { + it += 1; + start_idx -= 1; + } + + while (it != it_end && character_values.find_first_of(*it) != ice::none_index) + { + it += 1; + } + + return it == it_end ? ice::nindex{} : ice::nindex{ (it_end - it) - 1 }; + } + + // Iterators + + template + constexpr auto cbegin(this Self const& self) noexcept -> typename Self::ConstIterator + { + return self.data(); + } + + template + constexpr auto cend(this Self const& self) noexcept -> typename Self::ConstIterator + { + return self.data() + self.size(); + } + + template + constexpr auto crbegin(this Self const& self) noexcept -> typename Self::ConstReverseIterator + { + return typename Self::ConstReverseIterator{ self.data() + self.size() }; + } + + template + constexpr auto crend(this Self const& self) noexcept -> typename Self::ConstReverseIterator + { + return typename Self::ConstReverseIterator{ self.data() }; + } + + template + constexpr auto begin(this Self const& self) noexcept -> typename Self::ConstIterator + { + return self.cbegin(); + } + + template + constexpr auto end(this Self const& self) noexcept -> typename Self::ConstIterator + { + return self.cend(); + } + + template + constexpr auto rbegin(this Self const& self) noexcept -> typename Self::ConstReverseIterator + { + return self.crbegin(); + } + + template + constexpr auto rend(this Self const& self) noexcept -> typename Self::ConstReverseIterator + { + return self.crend(); + } + + // Operators + + template + constexpr auto operator[](this Self const& self, ice::nindex index) noexcept -> typename Self::ValueType + { + return self.data()[index.native()]; + } + + template + constexpr bool operator==(this Self const& self, typename Self::StringType const& other) noexcept + { + ice::ncount const size = self.size(); + if (size == other.size()) + { + typename Self::ValueType const* self_data = self.data(); + typename Self::ValueType const* other_data = other.data(); + + ice::nindex::base_type idx = 0; + while (idx < size && self_data[idx] == other_data[idx]) + { + idx += 1; + } + return idx == size; + } + return false; + } + + // Data Helpers + + template + constexpr auto meminfo(this Self const& self) noexcept -> ice::meminfo + { + return ice::meminfo{ + ice::meminfo_of * self.size().native() + }; + } + }; + +} // namespace ice::string diff --git a/source/code/core/collections/public/ice/string/resizable_operations.hxx b/source/code/core/collections/public/ice/string/resizable_operations.hxx new file mode 100644 index 00000000..e920f5ce --- /dev/null +++ b/source/code/core/collections/public/ice/string/resizable_operations.hxx @@ -0,0 +1,39 @@ +/// Copyright 2025 - 2025, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice::string +{ + + using ice::concepts::ResizableStringType; + + struct ResizableOperations : ice::string::MutableOperations + { + // Capacity and Size Helpers + + template + inline void shrink(this Self& self) noexcept + { + self.set_capacity(self.size() + 1); + } + + template + inline void reserve(this Self& self, ice::ncount min_capacity) noexcept + { + if (min_capacity > self.capacity()) + { + self.set_capacity(min_capacity); + } + } + + template + inline void grow(this Self& self, ice::ncount min_capacity = none_count) noexcept + { + ice::ncount const new_capacity = ice::max(self.capacity() * 2 + 8, min_capacity); + self.set_capacity(new_capacity); + } + }; + +} // namespace ice::string diff --git a/source/code/core/collections/public/ice/string/static_string.hxx b/source/code/core/collections/public/ice/string/static_string.hxx deleted file mode 100644 index 2f86c590..00000000 --- a/source/code/core/collections/public/ice/string/static_string.hxx +++ /dev/null @@ -1,129 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -namespace ice::string -{ - - template - constexpr void set_capacity(ice::StaticString& str, ice::ucount new_capacity) noexcept = delete; - - template - constexpr void reserve(ice::StaticString& str, ice::ucount min_capacity) noexcept = delete; - - template - constexpr void grow(ice::StaticString& str, ice::ucount min_capacity) noexcept = delete; - - template - constexpr void resize(ice::StaticString& str, ice::ucount new_size) noexcept; - - template - constexpr void shrink(ice::StaticString& str) noexcept = delete; - - template - constexpr void clear(ice::StaticString& str) noexcept; - - template - constexpr void push_back(ice::StaticString& str, CharType character) noexcept; - - template - constexpr void push_back(ice::StaticString& str, CharType const* cstr) noexcept; - - template - constexpr void push_back(ice::StaticString& str, ice::BasicString cstr) noexcept; - - template - constexpr void pop_back(ice::StaticString& str, ice::ucount count) noexcept; - - template - constexpr auto begin(ice::StaticString& str) noexcept -> typename ice::StaticString::Iterator; - - template - constexpr auto end(ice::StaticString& str) noexcept -> typename ice::StaticString::Iterator; - - template - constexpr auto rbegin(ice::StaticString& str) noexcept -> typename ice::StaticString::ReverseIterator; - - template - constexpr auto rend(ice::StaticString& str) noexcept -> typename ice::StaticString::ReverseIterator; - - - template - constexpr auto size(ice::StaticString const& str) noexcept -> ice::ucount; - - template - constexpr auto capacity(ice::StaticString const& str) noexcept -> ice::ucount; - - template - constexpr bool empty(ice::StaticString const& str) noexcept; - - template - constexpr auto begin(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstIterator; - - template - constexpr auto end(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstIterator; - - template - constexpr auto rbegin(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstReverseIterator; - - template - constexpr auto rend(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstReverseIterator; - - template - constexpr auto front(ice::StaticString const& str) noexcept -> typename ice::StaticString::ValueType; - - template - constexpr auto back(ice::StaticString const& str) noexcept -> typename ice::StaticString::ValueType; - - template - constexpr auto substr(ice::StaticString const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::BasicString; - - template - constexpr auto substr_clone(ice::StaticString const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::StaticString; - - template - constexpr auto find_first_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount; - - template - constexpr auto find_first_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - template - constexpr auto find_last_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount; - - template - constexpr auto find_last_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - template - constexpr auto find_first_not_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount; - - template - constexpr auto find_first_not_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - template - constexpr auto find_last_not_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount; - - template - constexpr auto find_last_not_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - - template - constexpr auto data_view(ice::StaticString const& str) noexcept -> ice::Data; - - template - constexpr auto memory(ice::StaticString& str) noexcept -> ice::Memory; - -} // namespace ice::string - -namespace ice -{ - - using ice::string::size; - using ice::string::begin; - using ice::string::end; - -} // namespace ice - -#include "impl/static_string.inl" diff --git a/source/code/core/collections/public/ice/string/string.hxx b/source/code/core/collections/public/ice/string/string.hxx index 92fd0852..be3a4095 100644 --- a/source/code/core/collections/public/ice/string/string.hxx +++ b/source/code/core/collections/public/ice/string/string.hxx @@ -3,127 +3,3 @@ #pragma once #include - -namespace ice::string -{ - - template - constexpr auto size(ice::BasicString str) noexcept -> ice::ucount; - - template - constexpr auto capacity(ice::BasicString str) noexcept -> ice::ucount; - - template - constexpr bool empty(ice::BasicString str) noexcept; - - template - constexpr bool any(ice::BasicString str) noexcept; - - template - constexpr auto begin(ice::BasicString a) noexcept -> typename ice::BasicString::ConstIterator; - - template - constexpr auto end(ice::BasicString str) noexcept -> typename ice::BasicString::ConstIterator; - - template - constexpr auto rbegin(ice::BasicString a) noexcept -> typename ice::BasicString::ConstReverseIterator; - - template - constexpr auto rend(ice::BasicString str) noexcept -> typename ice::BasicString::ConstReverseIterator; - - template - constexpr auto front(ice::BasicString str) noexcept -> typename ice::BasicString::ValueType; - - template - constexpr auto back(ice::BasicString str) noexcept -> typename ice::BasicString::ValueType; - - template - constexpr auto substr(ice::BasicString str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::BasicString; - - template - constexpr auto substr(ice::BasicString str, ice::ref32 ref) noexcept -> ice::BasicString; - - template - constexpr auto starts_with(ice::BasicString str, ice::concepts::StringType auto prefix) noexcept; - - template - constexpr auto find_first_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_first_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_last_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_last_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_first_not_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_first_not_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_last_not_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_last_not_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - - template requires ice::concepts::RODataObject - constexpr auto from_data(T ro_data) noexcept -> ice::BasicString; - - template requires ice::concepts::RODataObject - constexpr auto from_data(T ro_data, ice::usize offset, ice::ucount size) noexcept -> ice::String; - - template - constexpr auto data_view(ice::BasicString str) noexcept -> typename ice::Data; - - template - constexpr auto meminfo(ice::BasicString str) noexcept -> ice::meminfo; - -} // namespace ice::string - -namespace ice -{ - - using ice::string::size; - using ice::string::begin; - using ice::string::end; - -} // namespace ice - -#include "impl/string.inl" diff --git a/source/code/core/collections/public/ice/string/string_concepts.hxx b/source/code/core/collections/public/ice/string/string_concepts.hxx new file mode 100644 index 00000000..b9ee83e9 --- /dev/null +++ b/source/code/core/collections/public/ice/string/string_concepts.hxx @@ -0,0 +1,77 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include + +namespace ice::concepts +{ + + template + concept SupportedCharType = std::is_same_v + //|| std::is_same_v + || std::is_same_v; + + template + concept SupportedSizeType = std::is_same_v; + + template + concept StringType = SupportedCharType + && SupportedSizeType + && requires(T const& t) + { + typename T::StringType; + typename T::ValueType; + typename T::ConstIterator; + typename T::ConstReverseIterator; + { t.data() } -> std::convertible_to; + { t.size() } -> std::convertible_to; + }; + + template + concept MutableStringType = StringType + && requires(T& t, typename T::SizeType size_value) + { + { t.data() } -> std::convertible_to; + { t.capacity() } -> std::convertible_to; + { t.resize(size_value) } -> std::convertible_to; + }; + + template + concept ResizableStringType = MutableStringType + && requires(T& t, typename T::SizeType capacity_value) + { + { t.set_capacity(capacity_value) } -> std::convertible_to; + }; + +} // namespace ice::concepts + +namespace ice::string::detail +{ + + template + constexpr auto strptr_size(CharType const* str) noexcept -> ice::ncount::base_type + { + ice::ncount::base_type result{}; + if (str != nullptr) + { + CharType const* it = str; + while (*it != CharType{ 0 }) + { + it += 1; + } + + result = static_cast(it - str); + } + return result; + } + +} // namespace string::detail + +namespace ice +{ + + using ice::concepts::StringType; + +} // namespace ice diff --git a/source/code/core/collections/public/ice/string/var_string.hxx b/source/code/core/collections/public/ice/string/var_string.hxx index da4d1dc5..15a74d56 100644 --- a/source/code/core/collections/public/ice/string/var_string.hxx +++ b/source/code/core/collections/public/ice/string/var_string.hxx @@ -1,10 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include +#if 0 namespace ice::string { @@ -124,3 +125,5 @@ namespace ice } // namespace ice #include "impl/var_string.inl" + +#endif diff --git a/source/code/core/collections/public/ice/string_types.hxx b/source/code/core/collections/public/ice/string_types.hxx index 50985f20..a090928a 100644 --- a/source/code/core/collections/public/ice/string_types.hxx +++ b/source/code/core/collections/public/ice/string_types.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -8,193 +8,14 @@ #include #include +#include +#include +#include +#include + namespace ice { - //! \brief Null position used by string iterator types. - static constexpr ice::ucount String_NPos = ice::ucount_max; - - //! \brief Constant string type. - template - struct BasicString - { - using SizeType = ice::ucount; - using ValueType = CharType const; - using ConstIterator = CharType const*; - using ConstReverseIterator = std::reverse_iterator; - - SizeType _size = 0; - ValueType* _data = nullptr; - - constexpr BasicString() noexcept = default; - constexpr BasicString(BasicString&& other) noexcept = default; - constexpr BasicString(BasicString const& other) noexcept = default; - - constexpr BasicString(CharType const* str_ptr) noexcept; - constexpr BasicString(CharType const* str_beg, CharType const* str_end) noexcept; - constexpr BasicString(CharType const* str_ptr, ice::ucount size) noexcept; - template - constexpr BasicString(CharType const(&str_arr)[Size]) noexcept; - constexpr BasicString(std::basic_string_view other) noexcept; - - constexpr auto operator=(BasicString&& other) noexcept -> BasicString& = default; - constexpr auto operator=(BasicString const& other) noexcept -> BasicString& = default; - - constexpr auto operator[](ice::ucount index) const noexcept -> CharType const&; - - constexpr bool operator==(BasicString other) const noexcept; - - constexpr operator std::basic_string_view() const noexcept; - }; - - constexpr auto operator""_str(char const* buffer, size_t size) noexcept -> ice::BasicString; - - //! \brief Constant string type. - using String = ice::BasicString; - using WString = ice::BasicString; - - - using VarStringTag = struct _tagVarString; - - template - struct VarStringBase - { - using TypeTag = VarStringTag; - using ValueType = CharType const; - using ConstIterator = CharType const*; - using ConstReverseIterator = std::reverse_iterator; - - ValueType* _data; - - inline VarStringBase() noexcept; - inline ~VarStringBase() noexcept = default; - - inline explicit VarStringBase(CharType const* data) noexcept; - - inline auto operator[](ice::ucount idx) noexcept -> CharType&; - inline auto operator[](ice::ucount idx) const noexcept -> CharType const&; - - inline operator ice::BasicString() const noexcept; - }; - - using VarString = VarStringBase; - using VarWString = VarStringBase; - - - //! \brief A heap allocated string object. - //! - //! \note Depending on the use case an allocator not related to system heap may be provided. - //! This is still a valid use case. - template - struct HeapString - { - using SizeType = ice::ucount; - using ValueType = CharType; - using Iterator = CharType*; - using ReverseIterator = std::reverse_iterator; - using ConstIterator = CharType const*; - using ConstReverseIterator = std::reverse_iterator; - - ice::Allocator* _allocator; - SizeType _capacity; - SizeType _size; - ValueType* _data; - - inline explicit HeapString(ice::Allocator& allocator) noexcept; - inline HeapString(ice::Allocator& allocator, ice::BasicString string) noexcept; - inline ~HeapString() noexcept; - - inline HeapString(HeapString&& other) noexcept; - inline HeapString(HeapString const& other) noexcept; - - inline auto operator=(HeapString&& other) noexcept -> HeapString&; - inline auto operator=(HeapString const& other) noexcept -> HeapString&; - inline auto operator=(ice::BasicString str) noexcept -> HeapString&; - - inline auto operator[](ice::ucount index) noexcept -> CharType&; - inline auto operator[](ice::ucount index) const noexcept -> CharType const&; - - inline operator ice::BasicString() const noexcept; - }; - - //! \brief A static capacity string object. - //! - //! \note Because the capacity is static some string operations are not implemented or may behave differently. - //! For example, assining a string of length 20 to a static static string of capacity 12, will drop the last 8 characers. - template - struct StaticString - { - using SizeType = ice::ucount; - using ValueType = CharType; - using Iterator = CharType*; - using ReverSeIterator = std::reverse_iterator; - using ConstIterator = CharType const*; - using ConstReverseIterator = std::reverse_iterator; - - static constexpr SizeType Constant_Capacity = Capacity; - - SizeType _size; - ValueType _data[Constant_Capacity]; - - constexpr StaticString() noexcept; - constexpr ~StaticString() noexcept = default; - - constexpr StaticString(ice::BasicString str) noexcept; - - template - constexpr StaticString(CharType const (&str_arr)[ArraySize]) noexcept; - - template - constexpr StaticString(ice::StaticString const& other) noexcept; - - template - constexpr auto operator=(ice::StaticString const& other) noexcept -> StaticString&; - constexpr auto operator=(ice::BasicString str) noexcept -> StaticString&; - - constexpr auto operator[](ice::ucount idx) noexcept -> CharType&; - constexpr auto operator[](ice::ucount idx) const noexcept -> CharType const&; - - constexpr operator ice::BasicString() const noexcept; - }; - - - template - struct HeapVarString - { - using TypeTag = VarStringTag; - using ValueType = CharType; - using Iterator = CharType*; - using ReverSeIterator = std::reverse_iterator; - using ConstIterator = CharType const*; - using ConstReverseIterator = std::reverse_iterator; - - ice::Allocator* _allocator; - ValueType* _data; - - inline explicit HeapVarString(ice::Allocator& alloc) noexcept; - inline HeapVarString(ice::Allocator& allocator, ice::BasicString string) noexcept; - inline ~HeapVarString() noexcept; - - inline HeapVarString(HeapVarString&& other) noexcept; - inline HeapVarString(HeapVarString const& other) noexcept; - - inline auto operator=(HeapVarString&& other) noexcept -> HeapVarString&; - inline auto operator=(HeapVarString const& other) noexcept -> HeapVarString&; - inline auto operator=(ice::BasicString str) noexcept -> HeapVarString&; - - template - inline auto operator=(ice::StaticString const& other) noexcept -> HeapVarString&; - - inline auto operator[](ice::ucount idx) noexcept -> CharType&; - inline auto operator[](ice::ucount idx) const noexcept -> CharType const&; - - inline operator ice::BasicString() const noexcept; - inline operator ice::VarStringBase() const noexcept; - }; - - static_assert(ice::TrivialContainerLogicAllowed); - static_assert(ice::TrivialContainerLogicAllowed); - } // namespace ice namespace ice @@ -202,35 +23,23 @@ namespace ice constexpr auto hash(ice::String value) noexcept -> ice::u64 { - return ice::hash(std::string_view{ value._data, value._size }); + return ice::hash(std::string_view{ value }); } constexpr auto hash32(ice::String value) noexcept -> ice::u32 { - return ice::hash32(std::string_view{ value._data, value._size }); + return ice::hash32(std::string_view{ value }); } constexpr auto stringid(ice::String value) noexcept -> ice::StringID { - return ice::stringid(value._data, value._size); + return ice::stringid(value.data(), value.size().u64()); } - template + template constexpr auto stringid(ice::StaticString value) noexcept -> ice::StringID { return ice::stringid(value._data, value._size); } } // namespace ice - -namespace ice::concepts -{ - - template - concept StringType = std::is_same_v, Type> - || std::is_same_v, Type> - && requires(Type t) { - { t._size } -> std::convertible_to; - }; - -} // namespace ice::concepts diff --git a/source/code/core/collections/public/ice/types/ncount.hxx b/source/code/core/collections/public/ice/types/ncount.hxx new file mode 100644 index 00000000..cca665ad --- /dev/null +++ b/source/code/core/collections/public/ice/types/ncount.hxx @@ -0,0 +1,264 @@ +/// Copyright 2025 - 2025, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice +{ + + struct ncount; + struct nindex; + + namespace concepts + { + + template + concept native_count_type = (std::is_arithmetic_v and not std::is_floating_point_v) + or std::is_same_v + or std::is_same_v; + + } // namespace concepts + + namespace detail + { + +#if ISP_ARCH_BITS == 64 + using ncount_base_type = u64; + using ncount_base_type_signed = i64; +#elif ISP_ARCH_BITS == 32 + using ncount_base_type = u32; + using ncount_base_type_signed = i32; +#else +# error Unhandled architecture! +#endif + + template< + typename BaseType = ncount_base_type, + typename BaseTypeSigned = ncount_base_type_signed> + struct ncount_base; + + template<> + struct ncount_base + { + using base_type = u64; + using base_type_signed = i64; + + base_type_signed value : 48 = 0; + base_type width : 16 = 0; + + constexpr ncount_base() noexcept = default; + constexpr ncount_base(base_type value) noexcept + : value{ static_cast(value) }, width{ 1 } + { } + constexpr explicit ncount_base(base_type value, base_type width) noexcept + : value{ static_cast(value) }, width{ width } + { } + }; + + template<> + struct ncount_base + { + using base_type = u32; + using base_type_signed = i32; + + base_type_signed value = 0; + base_type width = 0; + + constexpr ncount_base() noexcept = default; + constexpr ncount_base(base_type value) noexcept + : value{ static_cast(value) }, width{ 1 } + { } + constexpr explicit ncount_base(base_type value, base_type width) noexcept + : value{ static_cast(value) }, width{ width } + { } + }; + + constexpr auto ncount_min_value() noexcept -> ncount_base_type + { + return 0; + } + + constexpr auto ncount_max_value() noexcept -> ncount_base_type + { + if constexpr (ice::build::is_x64) + { + return 0x0000'7fff'ffff'ffff; + } + else + { + return std::numeric_limits::max(); + } + } + + } // namespace detail + + + struct ncount : protected ice::detail::ncount_base<> + { + using ncount_base<>::base_type; + using ncount_base<>::ncount_base; + + // Utility + constexpr auto u8() const noexcept { return static_cast(value); } + constexpr auto u16() const noexcept { return static_cast(value); } + constexpr auto u32() const noexcept { return static_cast(value); } + constexpr auto u64() const noexcept { return static_cast(value); } + constexpr auto native() const noexcept { return static_cast(value); } + constexpr auto bytes() const noexcept { return operator ice::usize(); } + + // Arithmetic + constexpr auto operator+(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount; + constexpr auto operator-(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount; + constexpr auto operator*(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount; + constexpr auto operator/(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount; + constexpr auto operator+=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount&; + constexpr auto operator-=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount&; + constexpr auto operator*=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount&; + constexpr auto operator/=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount&; + + // Increments + constexpr auto operator++(this ncount& self) noexcept -> ncount&; + constexpr auto operator++(this ncount& self, int) noexcept -> ncount; + constexpr auto operator--(this ncount& self) noexcept -> ncount&; + constexpr auto operator--(this ncount& self, int) noexcept -> ncount; + + // Comparison + constexpr bool operator==(this ncount self, ice::concepts::native_count_type auto other) noexcept; + constexpr auto operator<=>(this ncount self, ice::concepts::native_count_type auto other) noexcept; + + // type colapsing + constexpr explicit operator bool(this ncount self) noexcept; + constexpr operator ice::usize(this ncount self) noexcept; + constexpr operator base_type(this ncount self) noexcept; + constexpr explicit operator base_type_signed(this ncount self) noexcept; + }; + + struct ncount_invalid_t : ncount {}; + + static constexpr ice::ncount_invalid_t none_count{ }; + static constexpr ice::ncount ncount_max{ ice::detail::ncount_max_value() }; + static constexpr ice::ncount ncount_min{ ice::detail::ncount_min_value() }; + + static_assert(ice::size_of == 8_B); + + constexpr auto ncount::operator+(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount + { + return ncount{ static_cast(self.value + static_cast(other)), self.width }; + } + + constexpr auto ncount::operator-(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount + { + return ncount{ static_cast(self.value - static_cast(other)), self.width }; + } + + constexpr auto ncount::operator*(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount + { + return ncount{ static_cast(self.value * static_cast(other)), self.width }; + } + + constexpr auto ncount::operator/(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount + { + return ncount{ static_cast(self.value / static_cast(other)), self.width }; + } + + constexpr auto ncount::operator+=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount& + { + self.value += static_cast(other); + return self; + } + + constexpr auto ncount::operator-=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount& + { + self.value -= static_cast(other); + return self; + } + + constexpr auto ncount::operator*=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount& + { + self.value *= static_cast(other); + return self; + } + + constexpr auto ncount::operator/=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount& + { + self.value /= static_cast(other); + return self; + } + + constexpr auto ncount::operator++(this ncount& self) noexcept -> ncount& + { + self.value += 1; + return self; + } + + constexpr auto ncount::operator++(this ncount& self, int) noexcept -> ncount + { + const ncount old = self; + self.value += 1; + return old; + } + + constexpr auto ncount::operator--(this ncount& self) noexcept -> ncount& + { + self.value -= 1; + return self; + } + + constexpr auto ncount::operator--(this ncount& self, int) noexcept -> ncount + { + const ncount old = self; + self.value -= 1; + return old; + } + + constexpr bool ncount::operator==(this ncount self, ice::concepts::native_count_type auto other) noexcept + { + return self.value == static_cast(other); + } + + constexpr auto ncount::operator<=>(this ncount self, ice::concepts::native_count_type auto other) noexcept + { + return self.value <=> static_cast(other); + } + + constexpr ncount::operator bool(this ncount self) noexcept + { + return static_cast(self.value * self.width); + } + + constexpr ncount::operator ice::usize(this ncount self) noexcept + { + return ice::usize{ static_cast(self.value) * self.width }; + } + + constexpr ncount::operator ncount::base_type(this ncount self) noexcept + { + return std::max(self.value, 0); + } + + constexpr ncount::operator ncount::base_type_signed(this ncount self) noexcept + { + return self.value; + } + + // special operators + + constexpr bool operator==(ncount self, ncount_invalid_t) noexcept + { + return static_cast(self) == false; + } + + template requires (std::is_same_v || std::is_same_v) + constexpr auto operator+(CharType* char_ptr, ncount count) noexcept -> CharType* + { + return char_ptr + count.u64(); + } + + template requires (std::is_same_v || std::is_same_v) + constexpr auto operator+(CharType const* char_ptr, ncount count) noexcept -> CharType const* + { + return char_ptr + count.u64(); + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/types/nindex.hxx b/source/code/core/collections/public/ice/types/nindex.hxx new file mode 100644 index 00000000..01be4e14 --- /dev/null +++ b/source/code/core/collections/public/ice/types/nindex.hxx @@ -0,0 +1,198 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice +{ + + struct nindex : protected ice::detail::ncount_base<> + { + using ncount_base<>::base_type; + using ncount_base<>::ncount_base; + + constexpr nindex(ice::ncount count) noexcept + : nindex{ count.u64() } + { } + + // Helpers + constexpr bool is_valid(this nindex self) noexcept; + + constexpr auto value_or(this nindex self, ice::concepts::native_count_type auto fallback) noexcept -> ice::nindex; + + constexpr auto u8(this nindex self) noexcept { return static_cast(self.value * self.width); } + constexpr auto u16(this nindex self) noexcept { return static_cast(self.value * self.width); } + constexpr auto u32(this nindex self) noexcept { return static_cast(self.value * self.width); } + constexpr auto u64(this nindex self) noexcept { return static_cast(self.value * self.width); } + constexpr auto native(this nindex self) noexcept -> base_type { return static_cast(self.value * self.width); } + + // Arithmetic + constexpr auto operator+(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex; + constexpr auto operator-(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex; + constexpr auto operator*(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex; + constexpr auto operator/(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex; + constexpr auto operator+=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex&; + constexpr auto operator-=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex&; + constexpr auto operator*=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex&; + constexpr auto operator/=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex&; + + // Increments + constexpr auto operator++(this nindex& self) noexcept -> nindex&; + constexpr auto operator++(this nindex& self, int) noexcept -> nindex; + constexpr auto operator--(this nindex& self) noexcept -> nindex&; + constexpr auto operator--(this nindex& self, int) noexcept -> nindex; + + // Comparison + constexpr bool operator==(this nindex self, ice::concepts::native_count_type auto other) noexcept; + constexpr auto operator<=>(this nindex self, ice::concepts::native_count_type auto other) noexcept; + + // type colapsing + constexpr explicit operator bool(this nindex self) noexcept; + constexpr operator ice::isize(this nindex self) noexcept; + constexpr operator ice::ncount(this nindex self) noexcept; + constexpr operator base_type(this nindex self) noexcept; + constexpr explicit operator base_type_signed(this nindex self) noexcept; + }; + + struct nindex_invalid_t : nindex {}; + + static constexpr ice::nindex_invalid_t none_index{ }; + + static_assert(ice::size_of == 8_B); + + constexpr bool nindex::is_valid(this nindex self) noexcept + { + return self.width > 0; + } + + constexpr auto nindex::value_or(this nindex self, ice::concepts::native_count_type auto fallback) noexcept -> ice::nindex + { + return self.is_valid() ? self : nindex{ static_cast(fallback) }; + } + + constexpr auto nindex::operator+(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex + { + return nindex{ self.value + static_cast(other), self.width }; + } + + constexpr auto nindex::operator-(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex + { + return nindex{ self.value - static_cast(other), self.width }; + } + + constexpr auto nindex::operator*(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex + { + return nindex{ self.value * static_cast(other), self.width }; + } + + constexpr auto nindex::operator/(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex + { + return nindex{ self.value / static_cast(other), self.width }; + } + + constexpr auto nindex::operator+=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex& + { + self.value += static_cast(other); + return self; + } + + constexpr auto nindex::operator-=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex& + { + self.value -= static_cast(other); + return self; + } + + constexpr auto nindex::operator*=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex& + { + self.value *= static_cast(other); + return self; + } + + constexpr auto nindex::operator/=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex& + { + self.value /= static_cast(other); + return self; + } + + constexpr auto nindex::operator++(this nindex& self) noexcept -> nindex& + { + self.value += 1; + return self; + } + + constexpr auto nindex::operator++(this nindex& self, int) noexcept -> nindex + { + const nindex old = self; + self.value += 1; + return old; + } + + constexpr auto nindex::operator--(this nindex& self) noexcept -> nindex& + { + self.value -= 1; + return self; + } + + constexpr auto nindex::operator--(this nindex& self, int) noexcept -> nindex + { + const nindex old = self; + self.value -= 1; + return old; + } + + constexpr bool nindex::operator==(this nindex self, ice::concepts::native_count_type auto other) noexcept + { + return static_cast(self.value) == static_cast(other); + } + + constexpr auto nindex::operator<=>(this nindex self, ice::concepts::native_count_type auto other) noexcept + { + return static_cast(self.value) <=> static_cast(other); + } + + constexpr nindex::operator bool(this nindex self) noexcept + { + return static_cast(self.value * self.width); + } + + constexpr nindex::operator ice::isize(this nindex self) noexcept + { + return ice::isize{ static_cast(self.value * self.width) }; + } + + constexpr nindex::operator ice::ncount(this nindex self) noexcept + { + return ice::ncount{ static_cast(self.value), self.width }; + } + + constexpr nindex::operator nindex::base_type(this nindex self) noexcept + { + return std::max(self.value, 0); + } + + constexpr nindex::operator nindex::base_type_signed(this nindex self) noexcept + { + return std::max(self.value, 0); + } + + // special operators + + constexpr bool operator==(nindex self, nindex_invalid_t) noexcept + { + return self.is_valid() == false; + } + + template requires (std::is_same_v || std::is_same_v) + constexpr auto operator+(CharType* char_ptr, nindex index) noexcept -> CharType* + { + return char_ptr + index.u64(); + } + + template requires (std::is_same_v || std::is_same_v) + constexpr auto operator+(CharType const* char_ptr, nindex index) noexcept -> CharType const* + { + return char_ptr + index.u64(); + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/varstring.hxx b/source/code/core/collections/public/ice/varstring.hxx new file mode 100644 index 00000000..fb3a4026 --- /dev/null +++ b/source/code/core/collections/public/ice/varstring.hxx @@ -0,0 +1,145 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include +#include + +namespace ice +{ + + using VarStringTag = struct _tagVarString; + + template + struct VarStringBase : ice::string::ReadOnlyOperations + { + static_assert(sizeof(CharT) == 1, "Wider characters are not supported yet!"); + + using CharType = CharT; + using ValueType = CharType const; + using ConstIterator = ValueType*; + using ConstReverseIterator = std::reverse_iterator; + using Iterator = ConstIterator; + using ReverseIterator = ConstReverseIterator; + using SizeType = ice::ncount; + using StringType = ice::BasicString; + using TypeTag = VarStringTag; + + ValueType* _data; + + inline VarStringBase() noexcept; + inline ~VarStringBase() noexcept = default; + + inline explicit VarStringBase(CharType const* data) noexcept; + + constexpr auto data() const noexcept -> ValueType*; + constexpr auto size() const noexcept -> SizeType; + + inline operator ice::BasicString() const noexcept; + }; + + using VarString = VarStringBase; + //using VarWString = VarStringBase; + + namespace varstring + { + + inline auto calc_required_size(ice::ncount size) noexcept -> ice::usize + { + ice::ncount::base_type temp = size.native(); + ice::usize bytes = 0_B; + while (size > 0x7f) + { + temp >>= 7; + bytes += 1_B; + } + return size.bytes() + bytes + 1_B; + } + + inline auto read_size(char const* data, ice::usize& out_bytes) noexcept -> ice::ncount + { + ice::ncount::base_type result = 0; + if (data != nullptr) + { + ice::u8 const* var_byte = reinterpret_cast(data); + out_bytes = 1_B; + while (*var_byte & 0x80) + { + result += *var_byte; + result <<= 7; + var_byte += 1; + out_bytes += 1_B; + } + result += *var_byte; + } + return ice::ncount{ result, sizeof(char) }; + } + + inline auto read_size(char const* data) noexcept -> ice::ncount + { + ice::usize bytes; + return read_size(data, bytes); + } + + template + inline auto read_data(CharType* data) noexcept -> CharType* + { + ice::usize bytes = 0_B; + if (data == nullptr || read_size(data, bytes) == 0) + { + return nullptr; + } + return data + bytes.value; + } + + inline auto write_size(void* data, ice::ncount size) noexcept -> ice::ncount + { + ice::ncount::base_type temp = size; + ice::nindex byte = 0; + ice::u8* const var_byte = reinterpret_cast(data); + while (size > 0x7f) + { + var_byte[byte] = (size & 0x7f) | 0x80; + temp >>= 7; + byte += 1; + } + var_byte[byte] = size & 0x7f; + return byte + 1; + } + + } // namespace varstring + + template + inline VarStringBase::VarStringBase() noexcept + : _data{ nullptr } + { + } + + template + inline VarStringBase::VarStringBase(CharT const* str_ptr) noexcept + : _data{ str_ptr } + { + } + + template + inline constexpr auto VarStringBase::data() const noexcept -> ValueType* + { + return ice::varstring::read_data(_data); + } + + template + inline constexpr auto VarStringBase::size() const noexcept -> SizeType + { + return ice::varstring::read_size(_data); + } + + template + inline VarStringBase::operator ice::BasicString::CharType>() const noexcept + { + ice::usize bytes = 0; + ice::ncount const size = ice::varstring::read_size(_data, bytes); + return { _data + bytes.value, size }; + } + +} // namespace ice diff --git a/source/code/core/collections/tests/test_array.cxx b/source/code/core/collections/tests/test_array.cxx index 901f63a8..f724d1ff 100644 --- a/source/code/core/collections/tests/test_array.cxx +++ b/source/code/core/collections/tests/test_array.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -37,7 +37,7 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" AND_WHEN("we remove the object the destructor is called") { - ice::ucount dtor_val = 0; + ice::u32 dtor_val = 0; obj.data.test_dtor = &dtor_val; ice::array::pop_back(objects, 1); diff --git a/source/code/core/collections/tests/test_hashmap.cxx b/source/code/core/collections/tests/test_hashmap.cxx index 1790b749..753f4530 100644 --- a/source/code/core/collections/tests/test_hashmap.cxx +++ b/source/code/core/collections/tests/test_hashmap.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -33,7 +33,7 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] AND_THEN("replacing the object will call destructor") { - ice::ucount dtor_count = 0; + ice::u32 dtor_count = 0; obj->data.test_dtor = &dtor_count; ice::hashmap::set(test_hash, 0, Test_TrackingObject{ 69 }); @@ -75,7 +75,7 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] AND_THEN("replacing the objects will call destructors") { - ice::ucount dtor_count = 0; + ice::u32 dtor_count = 0; for (Test_TrackingObject& obj : ice::hashmap::values(test_hash)) { obj.data.test_dtor = &dtor_count; diff --git a/source/code/core/collections/tests/test_heap_string.cxx b/source/code/core/collections/tests/test_heap_string.cxx index d661e73c..b3674eeb 100644 --- a/source/code/core/collections/tests/test_heap_string.cxx +++ b/source/code/core/collections/tests/test_heap_string.cxx @@ -2,10 +2,12 @@ /// SPDX-License-Identifier: MIT #include -#include -#include +#include +#include #include +constexpr char const test[] = "Dandielo"; + SCENARIO("ice :: HeapString") { static constexpr ice::String test_string_value{ "test_string" }; @@ -17,29 +19,29 @@ SCENARIO("ice :: HeapString") ice::HeapString test_string{ alloc }; // Reserve some capacity for tests - ice::string::reserve(test_string, 10); + test_string.reserve(10); - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == 10); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == 10); + CHECK(test_string.is_empty()); THEN("Assigning a value") { test_string = test_string_value; - ice::ucount const saved_size = ice::string::size(test_string); - ice::ucount const saved_capacity = ice::string::capacity(test_string); + ice::ncount const saved_size = test_string.size(); + ice::ncount const saved_capacity = test_string.capacity(); - CHECK(ice::string::size(test_string) == ice::string::size(test_string_value)); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == test_string_value.size()); + CHECK(test_string.not_empty()); WHEN("Clearing the string") { - ice::string::clear(test_string); + test_string.clear(); - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.is_empty()); REQUIRE(test_string == ""); } @@ -48,35 +50,35 @@ SCENARIO("ice :: HeapString") { GIVEN("The value is zero") { - ice::string::resize(test_string, 0); + test_string.resize(0); - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.is_empty()); REQUIRE(test_string == ""); } GIVEN("A smaller value") { - ice::string::resize(test_string, 4); + test_string.resize(4); - CHECK(ice::string::size(test_string) == 4); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 4); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); REQUIRE(test_string == "test"); } GIVEN("A larger value") { - ice::string::resize(test_string, 100); + test_string.resize(100); - CHECK(ice::string::size(test_string) == 100); - CHECK(ice::string::capacity(test_string) > saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 100); + CHECK(test_string.capacity() > saved_capacity); + CHECK(test_string.not_empty()); - REQUIRE(ice::string::substr(test_string, 0, saved_size) == test_string_value); + REQUIRE(test_string.substr(0, saved_size) == test_string_value); } } @@ -84,22 +86,22 @@ SCENARIO("ice :: HeapString") { GIVEN("No minimal capacity") { - ice::string::grow(test_string); + test_string.grow(); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) > saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() > saved_capacity); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } GIVEN("A minimal capacity") { - ice::string::grow(test_string, 100); + test_string.grow(100); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) >= 100); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() >= 100); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } @@ -109,34 +111,34 @@ SCENARIO("ice :: HeapString") { GIVEN("The value is zero") { - ice::string::set_capacity(test_string, 0); + test_string.set_capacity(0); - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == 0); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == 0); + CHECK(test_string.is_empty()); REQUIRE(test_string == ""); } GIVEN("A smaller value") { - ice::string::set_capacity(test_string, 2); + test_string.set_capacity(2); - CHECK(ice::string::size(test_string) == 1); - CHECK(ice::string::capacity(test_string) == 2); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 1); + CHECK(test_string.capacity() == 2); + CHECK(test_string.not_empty()); - ice::string::resize(test_string, 1); + test_string.resize(1); REQUIRE(test_string == "t"); } GIVEN("A larger value") { - ice::string::set_capacity(test_string, 100); + test_string.set_capacity(100); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) == 100); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() == 100); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } @@ -146,33 +148,33 @@ SCENARIO("ice :: HeapString") { GIVEN("The value is zero") { - ice::string::reserve(test_string, 0); + test_string.reserve(0); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } GIVEN("A smaller value") { - ice::string::reserve(test_string, 2); + test_string.reserve(2); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } GIVEN("A larger value") { - ice::string::reserve(test_string, 100); + test_string.reserve(100); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) >= 100); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() >= 100); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } @@ -180,12 +182,12 @@ SCENARIO("ice :: HeapString") WHEN("Triming string memory") { - ice::string::shrink(test_string); + test_string.shrink(); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) <= saved_capacity); - CHECK(ice::string::capacity(test_string) == 12); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() <= saved_capacity); + CHECK(test_string.capacity() == 12); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } @@ -193,41 +195,41 @@ SCENARIO("ice :: HeapString") THEN("Modyfing the string") { - auto saved_capacity = ice::string::capacity(test_string); + ice::ncount const saved_capacity = test_string.capacity(); WHEN("Appending a character") { - ice::string::push_back(test_string, 'a'); + test_string.push_back('a'); - CHECK(ice::string::size(test_string) == 1); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 1); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); } THEN("Appending a string") { - ice::string::push_back(test_string, "string"); + test_string.push_back("string"); - CHECK(ice::string::size(test_string) == 6); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 6); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); } - ice::string::resize(test_string, 100); + test_string.resize(100); // Fill the new string with space characters. - std::memset(ice::string::begin(test_string), ' ', ice::string::size(test_string)); + std::memset(test_string.begin(), ' ', test_string.size()); ice::HeapString test_copy{ test_string }; // We cannot push back ourselfs, as this will remove the old buffer before it even gets copied - ice::string::push_back(test_string, test_copy); + test_string.push_back(test_copy); THEN("Resizing the string and appending itself") { - CHECK(ice::string::size(test_string) == 200); - CHECK(ice::string::capacity(test_string) >= 201); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 200); + CHECK(test_string.capacity() >= 201); + CHECK(test_string.not_empty()); } //THEN("Poping a single character") @@ -258,32 +260,32 @@ SCENARIO("ice :: HeapString") THEN("we can iterate over it") { - auto it = ice::string::begin(str); - auto const it_end = ice::string::end(str); + auto it = str.begin(); + auto const it_end = str.end(); - ice::ucount character_count = 0; + ice::ncount character_count = 0; while (it != it_end) { it += 1; character_count += 1; } - CHECK(character_count == ice::string::size(test_string_value)); + CHECK(character_count == test_string_value.size()); } THEN("we can reverse iterate over it") { - auto it = ice::string::rbegin(str); - auto const it_end = ice::string::rend(str); + auto it = str.rbegin(); + auto const it_end = str.rend(); - ice::ucount character_count = 0; + ice::ncount character_count = 0; while (it != it_end) { it += 1; character_count += 1; } - CHECK(character_count == ice::string::size(test_string_value)); + CHECK(character_count == test_string_value.size()); } } } diff --git a/source/code/core/collections/tests/test_queue.cxx b/source/code/core/collections/tests/test_queue.cxx index 7d33dabe..4df2ceb1 100644 --- a/source/code/core/collections/tests/test_queue.cxx +++ b/source/code/core/collections/tests/test_queue.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -23,9 +23,9 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" { queue::resize(test_queue, 5); - ice::ucount dtor_count = 0; + ice::u32 dtor_count = 0; Test_ObjectEvents events{}; - for (ice::ucount idx = 0; idx < queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) { test_queue[idx].gather_ctors(events); test_queue[idx].data.test_dtor = &dtor_count; @@ -67,9 +67,9 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" CHECK(test_object.value == 42); } - ice::ucount dtor_count = 0; + ice::u32 dtor_count = 0; Test_ObjectEvents events{}; - for (ice::ucount idx = 0; idx < queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) { test_queue[idx].gather_ctors(events); test_queue[idx].data.test_dtor = &dtor_count; @@ -90,8 +90,8 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" { queue::resize(test_queue, 7); - ice::ucount dtor_count = 0; - for (ice::ucount idx = 0; idx < queue::count(test_queue); ++idx) + ice::u32 dtor_count = 0; + for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) { test_queue[idx].data.test_dtor = &dtor_count; } @@ -111,7 +111,7 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" CHECK(test_queue._offset != 0); CHECK(test_queue._capacity < (test_queue._offset + test_queue._count)); - for (ice::ucount idx = 0; idx < queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) { test_queue[idx].data.test_dtor = &dtor_count; } @@ -183,7 +183,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod WHEN("we push 100 elements") { - for (ice::ucount i = 0; i < 100; ++i) + for (ice::u32 i = 0; i < 100; ++i) { queue::push_back(test_queue, 0xd00b); } @@ -197,12 +197,12 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod THEN("popping 50 front elements 'front' at once or one-by-one results in the same queue") { queue::pop_front(test_queue, 50); - for (ice::ucount idx = 0; idx < 50; ++idx) + for (ice::u32 idx = 0; idx < 50; ++idx) { queue::pop_front(test_copy); } - for (ice::ucount idx = 0; idx < ice::queue::count(test_copy); ++idx) + for (ice::u32 idx = 0; idx < ice::queue::count(test_copy); ++idx) { CHECK(test_queue[idx] == test_copy[idx]); } @@ -211,12 +211,12 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod THEN("popping from back 50 elements at once or one-by-one results in the same queue") { queue::pop_back(test_queue, 50); - for (ice::ucount idx = 0; idx < 50; ++idx) + for (ice::u32 idx = 0; idx < 50; ++idx) { queue::pop_back(test_copy); } - for (ice::ucount idx = 0; idx < ice::queue::count(test_copy); ++idx) + for (ice::u32 idx = 0; idx < ice::queue::count(test_copy); ++idx) { CHECK(test_queue[idx] == test_copy[idx]); } @@ -271,7 +271,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod AND_THEN("the queue matches test values2") { - for (ice::ucount idx = 0; idx < ice::queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < ice::queue::count(test_queue); ++idx) { CHECK(test_values2[idx] == test_queue[idx]); } @@ -287,7 +287,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod CHECK(test_queue._offset != 0); CHECK(queue::count(test_copy) == queue::count(test_queue)); - for (ice::ucount idx = 0; idx < ice::queue::count(test_copy); ++idx) + for (ice::u32 idx = 0; idx < ice::queue::count(test_copy); ++idx) { CHECK(test_queue[idx] == test_copy[idx]); } @@ -319,15 +319,15 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod THEN("Check if we iterate in the proper order over the queue") { - ice::ucount const queue_size = queue::count(test_queue); - for (ice::ucount i = 0; i < queue_size; ++i) + ice::u32 const queue_size = queue::count(test_queue); + for (ice::u32 i = 0; i < queue_size; ++i) { CHECK(test_queue[i] == test_values_2[i]); } WHEN("using 'for_each' we iterate as expected in succession") { - ice::ucount idx = 0; + ice::u32 idx = 0; ice::queue::for_each( test_queue, [&test_values_2, &idx](ice::i32 val) noexcept @@ -340,7 +340,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod WHEN("using 'for_each_reverse' we iterate as expected in reverse") { - ice::ucount idx = ice::count(test_values_2) - 1; + ice::u32 idx = ice::count(test_values_2) - 1; ice::queue::for_each_reverse( test_queue, [&test_values_2, &idx](ice::i32 val) noexcept @@ -355,7 +355,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod { if constexpr (ice::Allocator::HasDebugInformation) { - ice::ucount const alloc_count = alloc.allocation_total_count(); + ice::u32 const alloc_count = alloc.allocation_total_count(); queue::reserve(test_queue, 100); @@ -369,7 +369,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod // Check the queue is still in tact CHECK(queue_size == queue::count(test_queue)); - for (ice::ucount i = 0; i < queue_size; ++i) + for (ice::u32 i = 0; i < queue_size; ++i) { CHECK(test_queue[i] == test_values_2[i]); } diff --git a/source/code/core/collections/tests/test_static_string.cxx b/source/code/core/collections/tests/test_static_string.cxx index 77745693..f9fdca1e 100644 --- a/source/code/core/collections/tests/test_static_string.cxx +++ b/source/code/core/collections/tests/test_static_string.cxx @@ -2,11 +2,11 @@ /// SPDX-License-Identifier: MIT #include -#include +#include SCENARIO("ice :: StackString") { - static constexpr ice::ucount test_stack_string_capacity = 64u; + static constexpr ice::ncount test_stack_string_capacity = 64u; static constexpr ice::String test_string_value{ "test_string" }; GIVEN("A an empty String value") @@ -17,105 +17,103 @@ SCENARIO("ice :: StackString") // Reserve some capacity for tests //ice::string::reserve(test_string, 10); = deleted - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == test_stack_string_capacity); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == test_stack_string_capacity); + CHECK(test_string.is_empty()); THEN("Assigning a value") { test_string = test_string_value; - uint32_t const saved_size = ice::string::size(test_string); - uint32_t const saved_capacity = ice::string::capacity(test_string); + ice::ncount const saved_size = test_string.size(); + ice::ncount const saved_capacity = test_string.capacity(); - CHECK(ice::string::size(test_string) == ice::string::size(test_string_value)); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == test_string_value.size()); + CHECK(test_string.not_empty()); WHEN("Clearing the string") { + test_string.clear(); - ice::string::clear(test_string); - - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.is_empty()); REQUIRE(test_string == ""); } WHEN("Resizing the string") { - auto saved_capacity_2 = ice::string::capacity(test_string); + ice::ncount const saved_capacity_2 = test_string.capacity(); GIVEN("The value is zero") { - ice::string::resize(test_string, 0); + test_string.resize(0); - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == saved_capacity_2); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == saved_capacity_2); + CHECK(test_string.is_empty()); REQUIRE(test_string == ""); } GIVEN("A smaller value") { - ice::string::resize(test_string, 4); + test_string.resize(4); - CHECK(ice::string::size(test_string) == 4); - CHECK(ice::string::capacity(test_string) == saved_capacity_2); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 4); + CHECK(test_string.capacity() == saved_capacity_2); + CHECK(test_string.not_empty()); REQUIRE(test_string == "test"); } GIVEN("A larger value") { - ice::string::resize(test_string, 20); + test_string.resize(20); - CHECK(ice::string::size(test_string) == 20); - CHECK(ice::string::capacity(test_string) == saved_capacity_2); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 20); + CHECK(test_string.capacity() == saved_capacity_2); + CHECK(test_string.not_empty()); - REQUIRE(ice::string::substr(test_string, 0, saved_size) == test_string_value); + REQUIRE(test_string.substr(0, saved_size) == test_string_value); } } } THEN("Modyfing the string") { - uint32_t const saved_capacity = ice::string::capacity(test_string); - - ice::string::push_back(test_string, 'a'); + ice::ncount const saved_capacity = test_string.capacity(); + test_string.push_back('a'); WHEN("Appending a character") { - CHECK(ice::string::size(test_string) == 1); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 1); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); } - ice::string::push_back(test_string, "string"); + test_string.push_back("string"); THEN("Appending a string") { - CHECK(ice::string::size(test_string) == 7); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 7); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); } - ice::string::resize(test_string, 20); + test_string.resize(20); // Fill the new string with space characters. - memset(ice::string::begin(test_string), ' ', ice::string::size(test_string)); + memset(test_string.begin(), ' ', test_string.size()); - ice::string::push_back(test_string, test_string); + test_string.push_back(test_string); THEN("Resizing the string and appending itself") { - CHECK(ice::string::size(test_string) == 40); - CHECK(ice::string::capacity(test_string) == test_stack_string_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 40); + CHECK(test_string.capacity() == test_stack_string_capacity); + CHECK(test_string.not_empty()); } //ice::string::pop_back(test_string); diff --git a/source/code/core/collections/tests/util_tracking_object.hxx b/source/code/core/collections/tests/util_tracking_object.hxx index 2207e0dd..f52c4ba9 100644 --- a/source/code/core/collections/tests/util_tracking_object.hxx +++ b/source/code/core/collections/tests/util_tracking_object.hxx @@ -8,15 +8,15 @@ struct Test_ObjectEvents { - ice::ucount test_ctor; - ice::ucount test_ctor_def; - ice::ucount test_ctor_move; - ice::ucount test_ctor_copy; + ice::u32 test_ctor; + ice::u32 test_ctor_def; + ice::u32 test_ctor_move; + ice::u32 test_ctor_copy; - ice::ucount test_op_move; - ice::ucount test_op_copy; + ice::u32 test_op_move; + ice::u32 test_op_copy; - ice::ucount* test_dtor = nullptr; + ice::u32* test_dtor = nullptr; }; bool operator==(Test_ObjectEvents const& lhs, Test_ObjectEvents const& rhs) noexcept; diff --git a/source/code/core/core/public/ice/base.hxx b/source/code/core/core/public/ice/base.hxx index 35a9be6a..1ff2955f 100644 --- a/source/code/core/core/public/ice/base.hxx +++ b/source/code/core/core/public/ice/base.hxx @@ -121,7 +121,7 @@ namespace ice template using member_result_type_t = typename member_info::result_type; - template + template using member_arg_type_t = std::tuple_element_t::argument_types>; template diff --git a/source/code/core/core/public/ice/constants.hxx b/source/code/core/core/public/ice/constants.hxx index fad9d069..78e8e6fb 100644 --- a/source/code/core/core/public/ice/constants.hxx +++ b/source/code/core/core/public/ice/constants.hxx @@ -22,8 +22,8 @@ namespace ice constexpr ice::u32 const u32_min = std::numeric_limits::min(); constexpr ice::u64 const u64_min = std::numeric_limits::min(); - constexpr ice::ucount const ucount_min = std::numeric_limits::min(); - constexpr ice::icount const icount_min = std::numeric_limits::min(); + //constexpr ice::ncount const ncount_min = std::numeric_limits::min(); + //constexpr ice::nindex const nindex_min = std::numeric_limits::min(); // Max values constexpr ice::f32 const f32_max = std::numeric_limits::max(); @@ -37,8 +37,8 @@ namespace ice constexpr ice::u32 const u32_max = std::numeric_limits::max(); constexpr ice::u64 const u64_max = std::numeric_limits::max(); - constexpr ice::ucount const ucount_max = std::numeric_limits::max(); - constexpr ice::icount const icount_max = std::numeric_limits::max(); + //constexpr ice::ucount const ucount_max = std::numeric_limits::max(); + //constexpr ice::icount const icount_max = std::numeric_limits::max(); // Special floating point values constexpr ice::f32 const f32_inf = std::numeric_limits::infinity(); diff --git a/source/code/core/core/public/ice/types.hxx b/source/code/core/core/public/ice/types.hxx index 233a0f52..c75da0af 100644 --- a/source/code/core/core/public/ice/types.hxx +++ b/source/code/core/core/public/ice/types.hxx @@ -28,29 +28,10 @@ namespace ice using uptr = std::uintptr_t; - // Declaration of ref types - - //! \brief Holds 'offset' and 'size' fields (u32) to access data stored in a buffer-like object. - using ref32 = struct { ice::u32 offset; ice::u32 size; }; - - //! \brief Holds 'offset' and 'size' fields (u16) to access data stored in a buffer-like object. - struct ref16 - { - ice::u16 offset; - ice::u16 size; - - constexpr operator ice::ref32() const noexcept { return ref32{ offset, size }; } - }; - - //! \brief Holds 'offset' and 'size' fields (u8) to access data stored in a buffer-like object. - struct ref8 - { - ice::u8 offset; - ice::u8 size; - - constexpr operator ice::ref16() const noexcept { return ref16{ offset, size }; } - constexpr operator ice::ref32() const noexcept { return ref32{ offset, size }; } - }; + // Forward declaration of ref types + struct ref8; + struct ref16; + struct ref32; // Forward declaration of time-types struct Ts; diff --git a/source/code/core/core/public/ice/types/ref.hxx b/source/code/core/core/public/ice/types/ref.hxx new file mode 100644 index 00000000..cc9f57ef --- /dev/null +++ b/source/code/core/core/public/ice/types/ref.hxx @@ -0,0 +1,36 @@ +/// Copyright 2025 - 2025, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice +{ + + //! \brief Holds 'offset' and 'size' fields (u32) to access data stored in a buffer-like object. + struct ref32 + { + ice::u32 offset; + ice::u32 size; + }; + + //! \brief Holds 'offset' and 'size' fields (u16) to access data stored in a buffer-like object. + struct ref16 + { + ice::u16 offset; + ice::u16 size; + + constexpr operator ice::ref32() const noexcept { return { offset, size }; } + }; + + //! \brief Holds 'offset' and 'size' fields (u8) to access data stored in a buffer-like object. + struct ref8 + { + ice::u8 offset; + ice::u8 size; + + constexpr operator ice::ref16() const noexcept { return { offset, size }; } + constexpr operator ice::ref32() const noexcept { return { offset, size }; } + }; + +} // namespace ice diff --git a/source/code/core/core/public/ice/types_extended.hxx b/source/code/core/core/public/ice/types_extended.hxx index 807a8cc9..93e2e183 100644 --- a/source/code/core/core/public/ice/types_extended.hxx +++ b/source/code/core/core/public/ice/types_extended.hxx @@ -3,11 +3,4 @@ #pragma once #include - -namespace ice -{ - - using ucount = ice::u32; - using icount = ice::i32; - -} // namespace ice +#include diff --git a/source/code/core/core/public/ice/utility.hxx b/source/code/core/core/public/ice/utility.hxx index 6fbea2f1..5a21699e 100644 --- a/source/code/core/core/public/ice/utility.hxx +++ b/source/code/core/core/public/ice/utility.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -7,6 +7,24 @@ namespace ice { + // Const utlities (deducing-this helpers) + template + struct const_correct + { + using type = ValueT; + }; + + template + struct const_correct + { + using type = std::add_const_t; + }; + + template + using const_correct_t = typename ice::const_correct::type; + + // Tuple utilities + using std::tuple; template diff --git a/source/code/core/devui/private/devui_imgui.cxx b/source/code/core/devui/private/devui_imgui.cxx index e407f187..9cbeab09 100644 --- a/source/code/core/devui/private/devui_imgui.cxx +++ b/source/code/core/devui/private/devui_imgui.cxx @@ -27,14 +27,14 @@ namespace ice::detail if ((data->EventFlag & ImGuiInputTextFlags_CallbackResize) == ImGuiInputTextFlags_CallbackResize) { - ICE_ASSERT_CORE(ice::string::begin(*str) == data->Buf); - if (ice::string::capacity(*str) <= ice::ucount(data->BufTextLen)) + ICE_ASSERT_CORE(str->begin() == data->Buf); + if (str->capacity() <= data->BufTextLen) { - ice::string::grow(*str, data->BufSize); + str->grow(data->BufSize); } - ice::string::resize(*str, data->BufTextLen); - data->Buf = ice::string::begin(*str); + str->resize(data->BufTextLen); + data->Buf = str->begin(); } return 0; } @@ -61,12 +61,12 @@ namespace ImGui bool InputText(ice::String label, ice::HeapString<>& out_string, ImGuiInputTextFlags flags) noexcept { - ice::string::reserve(out_string, 1); + out_string.reserve(1); return ImGui::InputText( - ice::string::begin(label), - ice::string::begin(out_string), - ice::string::capacity(out_string), + label.begin(), + out_string.begin(), + out_string.capacity(), flags | ImGuiInputTextFlags_CallbackResize, ice::detail::textinput_heapstring_callback, ice::addressof(out_string) diff --git a/source/code/core/devui/public/ice/devui_imgui.hxx b/source/code/core/devui/public/ice/devui_imgui.hxx index 12721d00..4dbbaaea 100644 --- a/source/code/core/devui/public/ice/devui_imgui.hxx +++ b/source/code/core/devui/public/ice/devui_imgui.hxx @@ -22,17 +22,17 @@ namespace ImGui inline bool Begin(ice::String name, bool* inout_open = nullptr, ImGuiWindowFlags flags = 0) noexcept { - return ImGui::Begin(ice::string::begin(name), inout_open, flags); + return ImGui::Begin(name.begin(), inout_open, flags); } inline bool BeginListBox(ice::String label, ice::vec2f size = {}) noexcept { - return ImGui::BeginListBox(ice::string::begin(label), ImVec2{ size.x, size.y }); + return ImGui::BeginListBox(label.begin(), ImVec2{ size.x, size.y }); } inline void TextUnformatted(ice::String text) noexcept { - ImGui::TextUnformatted(ice::string::begin(text), ice::string::end(text)); + ImGui::TextUnformatted(text.begin(), text.end()); } inline bool Selectable( @@ -42,7 +42,7 @@ namespace ImGui ice::vec2f size = {} ) noexcept { - return ImGui::Selectable(ice::begin(label), selected, flags, ImVec2{ size.x, size.y }); + return ImGui::Selectable(label.begin(), selected, flags, ImVec2{ size.x, size.y }); } // Extensions diff --git a/source/code/core/memsys/private/mem_allocator_forward.cxx b/source/code/core/memsys/private/mem_allocator_forward.cxx index 72f6300a..5c3d694f 100644 --- a/source/code/core/memsys/private/mem_allocator_forward.cxx +++ b/source/code/core/memsys/private/mem_allocator_forward.cxx @@ -13,7 +13,7 @@ namespace ice void* _end; // Only used for tracking of deallocations, do not use to calculate pointers! - ice::ucount _alloc_count; + ice::u32 _alloc_count; MemoryBucket* _next; @@ -28,7 +28,7 @@ namespace ice static auto alloc_buckets( ice::Allocator& alloc, ice::ForwardAllocatorParams const& params, - ice::ucount count + ice::u32 count ) noexcept -> MemoryBucket*; }; @@ -79,7 +79,7 @@ namespace ice void ForwardAllocator::reset() noexcept { - ice::ucount skipped_bucket_count = 0; + ice::u32 skipped_bucket_count = 0; MemoryBucket* new_list = nullptr; while (_buckets != nullptr) @@ -208,7 +208,7 @@ namespace ice auto ForwardAllocator::MemoryBucket::alloc_buckets( ice::Allocator& alloc, ice::ForwardAllocatorParams const& params, - ice::ucount count + ice::u32 count ) noexcept -> MemoryBucket* { MemoryBucket* result = nullptr; diff --git a/source/code/core/memsys/private/mem_allocator_snake.cxx b/source/code/core/memsys/private/mem_allocator_snake.cxx index 1b289a72..091dc63b 100644 --- a/source/code/core/memsys/private/mem_allocator_snake.cxx +++ b/source/code/core/memsys/private/mem_allocator_snake.cxx @@ -23,9 +23,9 @@ namespace ice return reinterpret_cast(ice::ptr_add(entries, bucket_size * idx)); } - static auto count_entries(ice::usize block_size, ice::usize bucket_size) noexcept -> ice::ucount + static auto count_entries(ice::usize block_size, ice::usize bucket_size) noexcept -> ice::u32 { - return ice::ucount(block_size.value / bucket_size.value); + return ice::u32(block_size.value / bucket_size.value); } }; @@ -36,7 +36,7 @@ namespace ice { using Entry = ChainBlock::Entry; - Chain(ice::usize base_block_size, ice::ucount capacity, ice::usize base_size) noexcept + Chain(ice::usize base_block_size, ice::u32 capacity, ice::usize base_size) noexcept : _capacity{ capacity } , _count{ capacity } , block_size{ base_block_size + ice::size_of * Entry::count_entries(base_block_size, base_size) } @@ -113,13 +113,13 @@ namespace ice return false; } - ice::ucount const _capacity; - ice::ucount _count = 0; + ice::u32 const _capacity; + ice::u32 _count = 0; ice::usize const block_size; ice::usize const block_bucket_size; - ice::ucount const block_bucket_count; - ice::ucount const total_bucket_count; + ice::u32 const block_bucket_count; + ice::u32 const total_bucket_count; // NOTE: We run into false sharing here but for now it's not an issue. std::atomic_uint32_t allocated = 0; @@ -227,7 +227,7 @@ namespace ice _blocks = _backing_allocator.allocate(params.bucket_sizes.size() * params.chain_capacity); ice::memset(_blocks, 0, sizeof(ChainBlock) * params.bucket_sizes.size() * params.chain_capacity); - ice::ucount block_offset = 0; + ice::u32 block_offset = 0; for (ice::u32 chain_idx = 0; chain_idx < params.bucket_sizes.size(); ++chain_idx) { // Size is not a power of 2 diff --git a/source/code/core/memsys/public/ice/mem_allocator_forward.hxx b/source/code/core/memsys/public/ice/mem_allocator_forward.hxx index 6c4f04d2..9805db6f 100644 --- a/source/code/core/memsys/public/ice/mem_allocator_forward.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator_forward.hxx @@ -13,7 +13,7 @@ namespace ice ice::usize bucket_size = 1_KiB; //! \brief The number of empty buckets allocated. - ice::ucount min_bucket_count = 1; + ice::u32 min_bucket_count = 1; }; struct ForwardAllocator : public ice::Allocator diff --git a/source/code/core/memsys/public/ice/mem_allocator_snake.hxx b/source/code/core/memsys/public/ice/mem_allocator_snake.hxx index a294fe30..3ead2a97 100644 --- a/source/code/core/memsys/public/ice/mem_allocator_snake.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator_snake.hxx @@ -13,7 +13,7 @@ namespace ice static constexpr ice::usize Constant_DefaultBlockSizes[]{ 32_KiB }; static constexpr ice::usize Constant_DefaultBucketSizes[]{ 256_KiB }; - ice::ucount chain_capacity = 4; + ice::u32 chain_capacity = 4; std::span block_sizes = Constant_DefaultBlockSizes; diff --git a/source/code/core/memsys/public/ice/mem_data.hxx b/source/code/core/memsys/public/ice/mem_data.hxx index ac1d4d9e..f4dccddb 100644 --- a/source/code/core/memsys/public/ice/mem_data.hxx +++ b/source/code/core/memsys/public/ice/mem_data.hxx @@ -93,7 +93,7 @@ namespace ice return source; } - template + template requires (std::is_trivially_copyable_v && !std::is_pointer_v) inline auto read_raw_array(ice::Data source, T(&out_array)[Size]) noexcept -> ice::Data { diff --git a/source/code/core/memsys/public/ice/mem_initializers.hxx b/source/code/core/memsys/public/ice/mem_initializers.hxx index bea950c1..7364f85e 100644 --- a/source/code/core/memsys/public/ice/mem_initializers.hxx +++ b/source/code/core/memsys/public/ice/mem_initializers.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -30,11 +30,11 @@ namespace ice } template - auto mem_construct_n_at(ice::Memory memory, ice::ucount count) noexcept -> T* + auto mem_construct_n_at(ice::Memory memory, ice::u32 count) noexcept -> T* { // TODO: Assert (align + size) T* target_mem = reinterpret_cast(memory.location); - for (ice::ucount idx = 0; idx < count; ++idx) + for (ice::u32 idx = 0; idx < count; ++idx) { new (target_mem + idx) T{ }; } @@ -42,11 +42,11 @@ namespace ice } template - auto mem_move_construct_n_at(ice::Memory memory, T* objects, ice::ucount count) noexcept -> T* + auto mem_move_construct_n_at(ice::Memory memory, T* objects, ice::u32 count) noexcept -> T* { // TODO: Assert (align + size) T* target_mem = reinterpret_cast(memory.location); - for (ice::ucount idx = 0; idx < count; ++idx) + for (ice::u32 idx = 0; idx < count; ++idx) { new (target_mem + idx) T{ ice::move(objects[idx]) }; } @@ -54,9 +54,9 @@ namespace ice } template - auto mem_move_n_to(T* target_objects, T* objects, ice::ucount count) noexcept -> T* + auto mem_move_n_to(T* target_objects, T* objects, ice::u32 count) noexcept -> T* { - for (ice::ucount idx = 0; idx < count; ++idx) + for (ice::u32 idx = 0; idx < count; ++idx) { target_objects[idx] = ice::move(objects[idx]); } @@ -64,11 +64,11 @@ namespace ice } template - auto mem_copy_construct_n_at(ice::Memory memory, T const* objects, ice::ucount count) noexcept -> T* + auto mem_copy_construct_n_at(ice::Memory memory, T const* objects, ice::u32 count) noexcept -> T* { // TODO: Assert (align + size) T* target_mem = reinterpret_cast(memory.location); - for (ice::ucount idx = 0; idx < count; ++idx) + for (ice::u32 idx = 0; idx < count; ++idx) { new (target_mem + idx) T{ objects[idx] }; } @@ -84,9 +84,9 @@ namespace ice } template - void mem_destruct_n_at(T* location, ice::ucount count) noexcept + void mem_destruct_n_at(T* location, ice::u32 count) noexcept { - for (ice::ucount idx = 0; idx < count; ++idx) + for (ice::u32 idx = 0; idx < count; ++idx) { ice::mem_destruct_at(location + idx); } diff --git a/source/code/core/memsys/public/ice/mem_utils.hxx b/source/code/core/memsys/public/ice/mem_utils.hxx index 4f287c90..5767b0b5 100644 --- a/source/code/core/memsys/public/ice/mem_utils.hxx +++ b/source/code/core/memsys/public/ice/mem_utils.hxx @@ -9,18 +9,18 @@ namespace ice { - constexpr auto mem_max_capacity(ice::usize element_size, ice::usize memory_space) noexcept -> ice::ucount; + constexpr auto mem_max_capacity(ice::usize element_size, ice::usize memory_space) noexcept -> ice::u64; template - constexpr auto mem_max_capacity(ice::usize memory_space) noexcept -> ice::ucount; + constexpr auto mem_max_capacity(ice::usize memory_space) noexcept -> ice::u64; - constexpr auto mem_max_capacity(ice::usize element_size, ice::usize memory_space) noexcept -> ice::ucount + constexpr auto mem_max_capacity(ice::usize element_size, ice::usize memory_space) noexcept -> ice::u64 { - return static_cast(memory_space.value / element_size.value); + return ice::u64{ memory_space.value / element_size.value }; } template - constexpr auto mem_max_capacity(ice::usize memory_space) noexcept -> ice::ucount + constexpr auto mem_max_capacity(ice::usize memory_space) noexcept -> ice::u64 { return ice::mem_max_capacity(ice::size_of, memory_space); } diff --git a/source/code/core/modules/private/module_globals.cxx b/source/code/core/modules/private/module_globals.cxx index 478aa8a8..aaaf1fc3 100644 --- a/source/code/core/modules/private/module_globals.cxx +++ b/source/code/core/modules/private/module_globals.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -10,9 +10,9 @@ namespace ice auto load_global_modules( ice::Allocator& alloc, ice::ModuleRegister& modules_register - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { - ice::ucount loaded_modules = 0; + ice::u32 loaded_modules = 0; ice::ModulesEntry const* module_entry = Global_ModulesList; while(module_entry != nullptr) diff --git a/source/code/core/modules/private/module_native.cxx b/source/code/core/modules/private/module_native.cxx index 57e9ec35..204aeb08 100644 --- a/source/code/core/modules/private/module_native.cxx +++ b/source/code/core/modules/private/module_native.cxx @@ -12,22 +12,22 @@ namespace ice::native_module bool utf8_to_wide_append_module(ice::String path, ice::HeapString& out_str) noexcept { - ice::i32 const required_size = MultiByteToWideChar(CP_UTF8, 0, ice::string::begin(path), ice::string::size(path), NULL, 0); + ice::i32 const required_size = MultiByteToWideChar(CP_UTF8, 0, path.begin(), path.size().u32(), NULL, 0); if (required_size != 0) { - ice::u32 const current_size = ice::string::size(out_str); - ice::u32 const total_size = static_cast(required_size) + ice::string::size(out_str); - ice::string::resize(out_str, total_size); + ice::ncount const current_size = out_str.size(); + ice::ncount const total_size = current_size + required_size; + out_str.resize(total_size); [[maybe_unused]] ice::i32 const chars_written = MultiByteToWideChar( CP_UTF8, 0, - ice::string::begin(path), - ice::string::size(path), - ice::string::begin(out_str) + current_size, - ice::string::size(out_str) - current_size + path.begin(), + path.size().u32(), + out_str.begin() + current_size, + (out_str.size() - current_size).u32() ); } @@ -40,7 +40,7 @@ namespace ice::native_module ice::HeapString wide_path{ temp_alloc }; if (utf8_to_wide_append_module(path, wide_path)) { - return ice::native_module::ModuleHandle{ LoadLibraryExW(ice::string::begin(wide_path), NULL, NULL) }; + return ice::native_module::ModuleHandle{ LoadLibraryExW(wide_path.begin(), NULL, NULL) }; } return {}; } @@ -52,7 +52,7 @@ namespace ice::native_module auto module_find_address(ice::native_module::ModuleHandle const& module, ice::String symbol_name) noexcept -> void* { - return ::GetProcAddress(module.native(), ice::string::begin(symbol_name)); + return ::GetProcAddress(module.native(), symbol_name.begin()); } #elif ISP_UNIX diff --git a/source/code/core/modules/private/module_register.cxx b/source/code/core/modules/private/module_register.cxx index faeba98f..2c9ca0f8 100644 --- a/source/code/core/modules/private/module_register.cxx +++ b/source/code/core/modules/private/module_register.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -33,7 +33,7 @@ namespace ice static bool from_app(ModuleNegotiatorAPIContext*) noexcept; static bool get_module_api(ModuleNegotiatorAPIContext*, ice::StringID_Hash, ice::u32, ice::ModuleAPI*) noexcept; - static bool get_module_apis(ModuleNegotiatorAPIContext*, ice::StringID_Hash, ice::u32, ice::ModuleAPI*, ice::ucount*) noexcept; + static bool get_module_apis(ModuleNegotiatorAPIContext*, ice::StringID_Hash, ice::u32, ice::ModuleAPI*, ice::u32*) noexcept; static bool register_module(ModuleNegotiatorAPIContext*, ice::StringID_Hash, FnModuleSelectAPI*) noexcept; }; @@ -58,13 +58,13 @@ namespace ice auto api_count( ice::StringID_Arg name, ice::u32 version - ) const noexcept -> ice::ucount; + ) const noexcept -> ice::u32; bool query_apis( ice::StringID_Arg api_name, ice::u32 version, ice::ModuleAPI* out_array, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) const noexcept override; bool register_module( @@ -167,9 +167,9 @@ namespace ice auto DefaultModuleRegister::api_count( ice::StringID_Arg api_name, ice::u32 version - ) const noexcept -> ice::ucount + ) const noexcept -> ice::u32 { - ice::ucount result = 0; + ice::u32 result = 0; auto it = ice::multi_hashmap::find_first(_modules, ice::hash(api_name)); while (it != nullptr) { @@ -187,7 +187,7 @@ namespace ice ice::StringID_Arg api_name, ice::u32 version, ice::ModuleAPI* out_array, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) const noexcept { if (out_array == nullptr) @@ -204,7 +204,7 @@ namespace ice ice::u32 idx = 0; auto it = ice::multi_hashmap::find_first(_modules, ice::hash(api_name)); - ice::ucount const array_size = *inout_array_size; + ice::u32 const array_size = *inout_array_size; while (it != nullptr && idx < array_size) { ice::ModuleAPI api_ptr; @@ -237,7 +237,7 @@ namespace ice ice::StringID_Hash api_name, ice::u32 version, ice::ModuleAPI* out_api, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) noexcept { return ctx->module_register->query_apis(ice::StringID{ api_name }, version, out_api, inout_array_size); diff --git a/source/code/core/modules/public/ice/module_concepts.hxx b/source/code/core/modules/public/ice/module_concepts.hxx index d4c9d1ff..e974a7cc 100644 --- a/source/code/core/modules/public/ice/module_concepts.hxx +++ b/source/code/core/modules/public/ice/module_concepts.hxx @@ -30,7 +30,7 @@ namespace ice::concepts template concept ModuleNegotiator = requires(T const& t, ice::StringID_Arg id, ice::FnModuleSelectAPI* api) { - { t.query_apis(id, ice::u32{}, (ice::ModuleAPI*) nullptr, (ice::ucount*)nullptr) } -> std::convertible_to; + { t.query_apis(id, ice::u32{}, (ice::ModuleAPI*) nullptr, (ice::u32*)nullptr) } -> std::convertible_to; { t.register_api(id, api) } -> std::convertible_to; { t.from_app() } -> std::convertible_to; } && requires(T const& t, ice::ProcAPIQuickRegisterFunc func) { diff --git a/source/code/core/modules/public/ice/module_negotiator.hxx b/source/code/core/modules/public/ice/module_negotiator.hxx index 3558ba04..64af46f4 100644 --- a/source/code/core/modules/public/ice/module_negotiator.hxx +++ b/source/code/core/modules/public/ice/module_negotiator.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -29,7 +29,7 @@ namespace ice ice::StringID_Hash api_name, ice::u32 api_version, ice::ModuleAPI* out_array, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) noexcept; //! \brief Registers an API selector function for the given API name. @@ -63,7 +63,7 @@ namespace ice ice::StringID_Arg api_name, ice::u32 api_version, ice::ModuleAPI* out_array, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) const noexcept override; //! \brief Registers an API selector function with the given API name. diff --git a/source/code/core/modules/public/ice/module_query.hxx b/source/code/core/modules/public/ice/module_query.hxx index d5d51c55..7de86ae3 100644 --- a/source/code/core/modules/public/ice/module_query.hxx +++ b/source/code/core/modules/public/ice/module_query.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -36,7 +36,7 @@ namespace ice ice::StringID_Arg api_name, ice::u32 version, ice::ModuleAPI* out_array, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) const noexcept = 0; //! \brief Queries a single API for the given API struct. @@ -81,14 +81,14 @@ namespace ice template requires (ice::concepts::APIType) bool ModuleQuery::query_apis(ice::Array& out_apis) const noexcept { - ice::ucount num_apis = 0; + ice::u32 num_apis = 0; if (query_apis(Type::Constant_APIName, Type::Constant_APIVersion, nullptr, &num_apis)) { // ICE_LOG_IF( // num_apis > 10, // ice::LogSeverity::Warning, ice::LogTag::Engine, // "More than 10 APIs of type {} where queried ({}).\n" - // "Use 'query_apis(ice::StringID_Arg, ice::u32, ice::ModuleAPI*, ice::ucount*)' instead to avoid truncating results.", + // "Use 'query_apis(ice::StringID_Arg, ice::u32, ice::ModuleAPI*, ice::u32*)' instead to avoid truncating results.", // num_apis, Type::Constant_APIName // ); diff --git a/source/code/core/modules/public/ice/module_register.hxx b/source/code/core/modules/public/ice/module_register.hxx index eff77c4c..9c827e88 100644 --- a/source/code/core/modules/public/ice/module_register.hxx +++ b/source/code/core/modules/public/ice/module_register.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -62,7 +62,7 @@ namespace ice auto load_global_modules( ice::Allocator& alloc, ice::ModuleRegister& modules_register - ) noexcept -> ice::ucount; + ) noexcept -> ice::u32; //! \brief Creates a default module register. //! \param[in] alloc The allocator to use for the module register. diff --git a/source/code/core/tasks/private/task_native_thread.cxx b/source/code/core/tasks/private/task_native_thread.cxx index 226b48a1..bd3d4dee 100644 --- a/source/code/core/tasks/private/task_native_thread.cxx +++ b/source/code/core/tasks/private/task_native_thread.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "task_native_thread.hxx" @@ -81,7 +81,7 @@ namespace ice return _runtime._state == ThreadState::Active; } - auto NativeTaskThread::estimated_task_count() const noexcept -> ice::ucount + auto NativeTaskThread::estimated_task_count() const noexcept -> ice::u32 { return 0; } @@ -275,10 +275,10 @@ namespace ice if constexpr (ice::build::is_release == false) { - if (ice::string::any(info.debug_name)) + if (info.debug_name.not_empty()) { ice::StackAllocator<256_B> stack_alloc; - ice::ucount const wide_count = ice::utf8_to_wide_size(info.debug_name); + ice::u32 const wide_count = ice::utf8_to_wide_size(info.debug_name); ICE_ASSERT( ice::size_of *(wide_count + 1) < stack_alloc.Constant_InternalCapacity, "Thread debug name too long!" diff --git a/source/code/core/tasks/private/task_native_thread.hxx b/source/code/core/tasks/private/task_native_thread.hxx index 9f28e917..05d355bb 100644 --- a/source/code/core/tasks/private/task_native_thread.hxx +++ b/source/code/core/tasks/private/task_native_thread.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -75,7 +75,7 @@ namespace ice bool is_busy() const noexcept override; bool is_running() const noexcept override; - auto estimated_task_count() const noexcept -> ice::ucount override; + auto estimated_task_count() const noexcept -> ice::u32 override; auto queue() noexcept -> ice::TaskQueue & override; private: diff --git a/source/code/core/tasks/private/task_queue.cxx b/source/code/core/tasks/private/task_queue.cxx index e27fcadc..f9585881 100644 --- a/source/code/core/tasks/private/task_queue.cxx +++ b/source/code/core/tasks/private/task_queue.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -98,9 +98,9 @@ namespace ice return awaitable != nullptr; } - auto TaskQueue::process_all(void* result_value) noexcept -> ice::ucount + auto TaskQueue::process_all(void* result_value) noexcept -> ice::u32 { - ice::ucount processed = 0; + ice::u32 processed = 0; for (ice::TaskAwaitableBase* const awaitable : ice::linked_queue::consume(_awaitables)) { if (result_value != nullptr) @@ -133,9 +133,9 @@ namespace ice return processed; } - // auto TaskQueue::prepare_all(void *result_value) noexcept -> ice::ucount + // auto TaskQueue::prepare_all(void *result_value) noexcept -> ice::u32 // { - // return ice::ucount(); + // return ice::u32(); // } void TaskQueue::wait_any() noexcept diff --git a/source/code/core/tasks/private/task_scoped_container.cxx b/source/code/core/tasks/private/task_scoped_container.cxx index eb91e810..a9aab041 100644 --- a/source/code/core/tasks/private/task_scoped_container.cxx +++ b/source/code/core/tasks/private/task_scoped_container.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -22,11 +22,11 @@ namespace ice } auto ScopedTaskContainer::create_tasks( - ice::ucount count, + ice::u32 count, ice::ShardID shardid ) noexcept -> ice::Span> { - ice::ucount const new_count = ice::array::count(_tasks) + count; + ice::u32 const new_count = ice::array::count(_tasks) + count; if (new_count > ice::array::capacity(_tasks)) { @@ -44,9 +44,9 @@ namespace ice co_await ice::await_scheduled_on(_tasks, scheduler, resumer); } - auto ScopedTaskContainer::execute_tasks() noexcept -> ice::ucount + auto ScopedTaskContainer::execute_tasks() noexcept -> ice::u32 { - ice::ucount const result = ice::array::count(_tasks); + ice::u32 const result = ice::array::count(_tasks); if (result > 0) { _barrier.reset(static_cast(result)); @@ -56,7 +56,7 @@ namespace ice return result; } - auto ScopedTaskContainer::running_tasks() const noexcept -> ice::ucount + auto ScopedTaskContainer::running_tasks() const noexcept -> ice::u32 { return _barrier.value(); } diff --git a/source/code/core/tasks/private/task_thread_pool_impl.cxx b/source/code/core/tasks/private/task_thread_pool_impl.cxx index ce4d25fe..ed8e397b 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.cxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.cxx @@ -1,8 +1,7 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "task_thread_pool_impl.hxx" -#include #include #include @@ -19,11 +18,11 @@ namespace ice auto const result = fmt::vformat_to_n( raw_buffer, ice::count(raw_buffer), - fmt::string_view{format._data, format._size}, + fmt::string_view{ format.data(), format.size() }, fmt::make_format_args(std::forward(args)...) ); - out_string = ice::String{ raw_buffer, (ice::ucount) result.size }; + out_string = ice::String{ raw_buffer, (ice::u32) result.size }; } auto aio_thread_routine(void* userdata, ice::TaskQueue&) noexcept -> ice::u32 @@ -106,17 +105,17 @@ namespace ice ice::array::clear(_thread_pool); } - auto TaskThreadPoolImplementation::thread_count() const noexcept -> ice::ucount + auto TaskThreadPoolImplementation::thread_count() const noexcept -> ice::u32 { return ice::array::count(_thread_pool); } - auto TaskThreadPoolImplementation::managed_thread_count() const noexcept -> ice::ucount + auto TaskThreadPoolImplementation::managed_thread_count() const noexcept -> ice::u32 { return ice::array::count(_managed_threads) + ice::hashmap::count(_created_threads); } - auto TaskThreadPoolImplementation::estimated_task_count() const noexcept -> ice::ucount + auto TaskThreadPoolImplementation::estimated_task_count() const noexcept -> ice::u32 { return 0; // TODO: } @@ -134,7 +133,7 @@ namespace ice .exclusive_queue = false, .sort_by_priority = false, .stack_size = 0_B, // default - .debug_name = ice::String{ name_hint.data(), static_cast(name_hint.size()) } + .debug_name = ice::String{ name_hint.data(), static_cast(name_hint.size()) } }; ice::hashmap::set( diff --git a/source/code/core/tasks/private/task_thread_pool_impl.hxx b/source/code/core/tasks/private/task_thread_pool_impl.hxx index ec565c9c..39e0faf6 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.hxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -21,9 +21,9 @@ namespace ice ) noexcept; ~TaskThreadPoolImplementation() noexcept override; - auto thread_count() const noexcept -> ice::ucount override; - auto managed_thread_count() const noexcept -> ice::ucount override; - auto estimated_task_count() const noexcept -> ice::ucount override; + auto thread_count() const noexcept -> ice::u32 override; + auto managed_thread_count() const noexcept -> ice::u32 override; + auto estimated_task_count() const noexcept -> ice::u32 override; auto create_thread(ice::StringID name) noexcept -> ice::TaskThread& override; auto find_thread(ice::StringID name) noexcept -> ice::TaskThread* override; diff --git a/source/code/core/tasks/public/ice/task_container.hxx b/source/code/core/tasks/public/ice/task_container.hxx index d7d2909e..7af01f7a 100644 --- a/source/code/core/tasks/public/ice/task_container.hxx +++ b/source/code/core/tasks/public/ice/task_container.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -18,9 +18,9 @@ namespace ice virtual auto await_tasks_scheduled_on(ice::TaskScheduler& scheduler, ice::TaskScheduler& resumer) noexcept -> ice::Task<> = 0; - virtual auto execute_tasks() noexcept -> ice::ucount = 0; + virtual auto execute_tasks() noexcept -> ice::u32 = 0; - virtual auto running_tasks() const noexcept -> ice::ucount = 0; + virtual auto running_tasks() const noexcept -> ice::u32 = 0; virtual void wait_tasks() noexcept = 0; diff --git a/source/code/core/tasks/public/ice/task_debug_allocator.hxx b/source/code/core/tasks/public/ice/task_debug_allocator.hxx index e9b16ba3..b22e9001 100644 --- a/source/code/core/tasks/public/ice/task_debug_allocator.hxx +++ b/source/code/core/tasks/public/ice/task_debug_allocator.hxx @@ -23,7 +23,7 @@ namespace ice::detail { static auto pool() noexcept -> ice::String { - return ice::string::any(_allocator_pool) ? _allocator_pool : "Tasks"; + return _allocator_pool.not_empty() ? _allocator_pool : "Tasks"; } static auto allocator() noexcept -> ice::Allocator& diff --git a/source/code/core/tasks/public/ice/task_queue.hxx b/source/code/core/tasks/public/ice/task_queue.hxx index f3e8192d..d91d2961 100644 --- a/source/code/core/tasks/public/ice/task_queue.hxx +++ b/source/code/core/tasks/public/ice/task_queue.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -28,14 +28,14 @@ namespace ice auto consume() noexcept -> ice::LinkedQueueRange; bool process_one(void* result_value = nullptr) noexcept; - auto process_all(void* result_value = nullptr) noexcept -> ice::ucount; + auto process_all(void* result_value = nullptr) noexcept -> ice::u32; void wait_any() noexcept; template inline bool process_one(Value& result_value) noexcept; template - inline auto process_all(Value& result_value) noexcept -> ice::ucount; + inline auto process_all(Value& result_value) noexcept -> ice::u32; //! \brief Flags of task allowed to be pushed onto this queue. ice::TaskFlags const flags; @@ -51,7 +51,7 @@ namespace ice } template - inline auto TaskQueue::process_all(Value& result_value) noexcept -> ice::ucount + inline auto TaskQueue::process_all(Value& result_value) noexcept -> ice::u32 { return this->process_all(reinterpret_cast(&result_value)); } diff --git a/source/code/core/tasks/public/ice/task_scoped_container.hxx b/source/code/core/tasks/public/ice/task_scoped_container.hxx index bad6eabb..951dadee 100644 --- a/source/code/core/tasks/public/ice/task_scoped_container.hxx +++ b/source/code/core/tasks/public/ice/task_scoped_container.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -17,17 +17,17 @@ namespace ice //! \brief Create a new set of tasks and return the slice containing them. auto create_tasks( - ice::ucount count, + ice::u32 count, ice::ShardID shardid ) noexcept -> ice::Span> override; auto await_tasks_scheduled_on(ice::TaskScheduler& scheduler, ice::TaskScheduler& resumer) noexcept -> ice::Task<> override; //! \brief Execute all tasks that have been created. - auto execute_tasks() noexcept -> ice::ucount override; + auto execute_tasks() noexcept -> ice::u32 override; //! \brief Returns the number of tasks that are currently running. - auto running_tasks() const noexcept -> ice::ucount override; + auto running_tasks() const noexcept -> ice::u32 override; //! \brief Wait for all tasks to complete. void wait_tasks() noexcept override; diff --git a/source/code/core/tasks/public/ice/task_thread.hxx b/source/code/core/tasks/public/ice/task_thread.hxx index f13df652..7804239c 100644 --- a/source/code/core/tasks/public/ice/task_thread.hxx +++ b/source/code/core/tasks/public/ice/task_thread.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -53,7 +53,7 @@ namespace ice virtual bool is_busy() const noexcept = 0; virtual bool is_running() const noexcept = 0; - virtual auto estimated_task_count() const noexcept -> ice::ucount = 0; + virtual auto estimated_task_count() const noexcept -> ice::u32 = 0; virtual auto queue() noexcept -> ice::TaskQueue& = 0; }; diff --git a/source/code/core/tasks/public/ice/task_thread_pool.hxx b/source/code/core/tasks/public/ice/task_thread_pool.hxx index 7610c683..43aa7cb4 100644 --- a/source/code/core/tasks/public/ice/task_thread_pool.hxx +++ b/source/code/core/tasks/public/ice/task_thread_pool.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -14,7 +14,7 @@ namespace ice struct TaskThreadPoolCreateInfo { //! \brief The thread count of this thread pool. - ice::ucount thread_count = 0; + ice::u32 thread_count = 0; //! \brief The AIO port to be used for internal AIO threads. ice::native_aio::AIOPort aioport = nullptr; @@ -27,9 +27,9 @@ namespace ice { public: virtual ~TaskThreadPool() noexcept = default; - virtual auto thread_count() const noexcept -> ice::ucount = 0; - virtual auto managed_thread_count() const noexcept -> ice::ucount = 0; - virtual auto estimated_task_count() const noexcept -> ice::ucount = 0; + virtual auto thread_count() const noexcept -> ice::u32 = 0; + virtual auto managed_thread_count() const noexcept -> ice::u32 = 0; + virtual auto estimated_task_count() const noexcept -> ice::u32 = 0; //! \brief Creates an additonal thread with the given name (ID). //! diff --git a/source/code/core/utils/private/config/config_builder.cxx b/source/code/core/utils/private/config/config_builder.cxx index 8ef46a53..aa4b6024 100644 --- a/source/code/core/utils/private/config/config_builder.cxx +++ b/source/code/core/utils/private/config/config_builder.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -119,9 +119,9 @@ namespace ice } else if (entry->vtype == CONFIG_VALTYPE_STRING) { - ice::ucount bytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(entry->data.val_varstr->_data, bytes); - out_data_size += { bytes + size + 1 }; // +1 for '\0' + ice::usize bytes = 0_B; + ice::ncount const size = ice::varstring::read_size(entry->data.val_varstr->_data, bytes); + out_data_size += bytes + size.bytes() + 1_B; // +1 for '\0' } else if (entry->vtype >= CONFIG_VALTYPE_LARGE) { @@ -228,7 +228,7 @@ namespace ice else if (it_entry->vtype == CONFIG_VALTYPE_STRING) { ice::HeapVarString<> const& varstr = *config._entries[out_keyidx].data.val_varstr; - ice::Data const in_data = ice::string::data_view(varstr); + ice::Data const in_data = varstr.data_view(); // Set the '\0' character *(reinterpret_cast(out_data.memory.location) + (out_data.offset_strings - 1)) = '\0'; @@ -399,16 +399,16 @@ namespace ice // Reserve space to hold all keystring entries and build the string buffer. ice::array::resize(keyoffsets, ice::hashmap::count(keystrings)); - ice::u32 keystr_offset = 0; + ice::ncount keystr_offset = 0; for (CBKeyString const& keystr : ice::hashmap::values(keystrings)) { // Copy and advance the pointer - ice::memcpy(final_keystrings_mem, ice::string::data_view(keystr.value)); - final_keystrings_mem = ice::ptr_add(final_keystrings_mem, ice::string::data_view(keystr.value).size); + ice::memcpy(final_keystrings_mem, keystr.value.data_view()); + final_keystrings_mem = ice::ptr_add(final_keystrings_mem, keystr.value.size()); // Store the offset - keyoffsets[keystr.index] = keystr_offset; - keystr_offset += ice::string::size(keystr.value); + keyoffsets[keystr.index] = keystr_offset.u32(); + keystr_offset += keystr.value.size(); } // Build the new key and value arrays + copy large data. diff --git a/source/code/core/utils/private/config/config_builder_utils.cxx b/source/code/core/utils/private/config/config_builder_utils.cxx index df2384bf..626f092f 100644 --- a/source/code/core/utils/private/config/config_builder_utils.cxx +++ b/source/code/core/utils/private/config/config_builder_utils.cxx @@ -85,11 +85,11 @@ namespace ice::config::detail else { idx = ice::count(container._entries); - ice::u32 const offset = ice::string::size(container._keystrings); - ice::string::push_back(container._keystrings, key); + ice::ncount const offset = container._keystrings.size(); + container._keystrings.push_back(key); // Add the new entry - ice::array::push_back(container._entries, ConfigKey{ 0, CONFIG_KEYTYPE_STRING, CONFIG_VALTYPE_NONE, offset, ice::size(key) }); + ice::array::push_back(container._entries, ConfigKey{ 0, CONFIG_KEYTYPE_STRING, CONFIG_VALTYPE_NONE, offset.u32(), key.size().u32()}); // Return the entry result = ice::array::begin(container._entries) + idx; diff --git a/source/code/core/utils/private/config/config_builder_value.cxx b/source/code/core/utils/private/config/config_builder_value.cxx index d3983aa8..edf6b7cc 100644 --- a/source/code/core/utils/private/config/config_builder_value.cxx +++ b/source/code/core/utils/private/config/config_builder_value.cxx @@ -86,7 +86,7 @@ namespace ice auto ice::ConfigBuilderValue::operator[](ice::String key) noexcept -> ConfigBuilderValue { - ICE_ASSERT_CORE(ice::string::find_first_of(key, '.') == ice::String_NPos); + ICE_ASSERT_CORE(key.find_first_of('.') == ice::none_index); ConfigBuilderEntry* const entry = _idx == ice::u32_max ? _internal : (static_cast(_internal)->_entries._data + _idx); diff --git a/source/code/core/utils/private/config/config_detail.cxx b/source/code/core/utils/private/config/config_detail.cxx index 717070eb..0c62ea66 100644 --- a/source/code/core/utils/private/config/config_detail.cxx +++ b/source/code/core/utils/private/config/config_detail.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "config_detail.hxx" @@ -9,7 +9,7 @@ namespace ice::config::detail auto get_keyindex(ice::String key) noexcept -> ice::u32 { ice::u32 idx = 0; - char const* k = ice::string::begin(key); + char const* k = key.begin(); while(*k >= '0' && *k <= '9') { idx *= 10; @@ -101,7 +101,7 @@ namespace ice::config::detail } // The first element holds the size of the whole table - ice::ucount const table_size = ( config._keys->offset << 8) | config._keys->size; + ice::u32 const table_size = (config._keys->offset << 8) | config._keys->size; if (index >= table_size) // OutOfBounds? { return E_ConfigIndexOutOfBounds; @@ -131,11 +131,11 @@ namespace ice::config::detail Config finalcfg = config; // If this key has multiple parts recursively enter config search - ice::ucount key_split_location = ice::string::find_first_of(key, {".|"}); - while (key_split_location != ice::String_NPos && result) + ice::nindex key_split_location = key.find_first_of({".|"}); + while (key_split_location != ice::none_index && result) { bool const is_table = finalcfg._keys->type != CONFIG_KEYTYPE_STRING; - ice::String const keyval = ice::string::substr(key, 0, key_split_location); + ice::String const keyval = key.substr(0, key_split_location); if (is_table) { @@ -146,8 +146,8 @@ namespace ice::config::detail result = get_subconfig(finalcfg, keyval); } - key = ice::string::substr(key, key_split_location + 1); - key_split_location = ice::string::find_first_of(key, {".|"}); + key = key.substr(key_split_location + 1); + key_split_location = key.find_first_of({".|"}); } if (finalcfg._keys->type != CONFIG_KEYTYPE_STRING) [[unlikely]] diff --git a/source/code/core/utils/private/config_getters.cxx b/source/code/core/utils/private/config_getters.cxx index 29ad078d..7a9c7e2e 100644 --- a/source/code/core/utils/private/config_getters.cxx +++ b/source/code/core/utils/private/config_getters.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "config/config_detail.hxx" @@ -317,10 +317,10 @@ namespace ice::config::detail } char const* strdata = reinterpret_cast(config._data) + value->internal; - ice::ucount varbytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(strdata, varbytes); + ice::usize varbytes{}; + ice::ncount const size = ice::varstring::read_size(strdata, varbytes); - out_value = { strdata + varbytes, size }; + out_value = { strdata + varbytes.value, size }; return S_Ok; } diff --git a/source/code/core/utils/private/config_json.cxx b/source/code/core/utils/private/config_json.cxx index 6a40bdca..98414cdb 100644 --- a/source/code/core/utils/private/config_json.cxx +++ b/source/code/core/utils/private/config_json.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -51,7 +51,7 @@ namespace ice::config else if (value.IsDouble()) config_table = value.GetDouble(); break; case rapidjson::Type::kStringType: - config_table = ice::String{ value.GetString(), ice::ucount(value.GetStringLength()) }; + config_table = ice::String{ value.GetString(), value.GetStringLength() }; break; case rapidjson::Type::kArrayType: deserialize_json_array(value.GetArray(), config_table); @@ -96,7 +96,7 @@ namespace ice::config auto from_json(ice::ConfigBuilder& config_builder, ice::String json) noexcept -> ice::ErrorCode { rapidjson::Document doc; - if (doc.Parse(ice::string::begin(json),ice::string::size(json)).HasParseError() == false && doc.IsObject()) + if (doc.Parse(json.begin(), json.size()).HasParseError() == false && doc.IsObject()) { detail::deserialize_json_object(const_cast(doc).GetObject(), config_builder); return S_Ok; diff --git a/source/code/core/utils/private/log.cxx b/source/code/core/utils/private/log.cxx index 12c8791c..c2feea2c 100644 --- a/source/code/core/utils/private/log.cxx +++ b/source/code/core/utils/private/log.cxx @@ -95,7 +95,7 @@ namespace ice::detail ice::detail::local_time(), fmt_string(detail::severity_value[static_cast(severity)]), fmt_string(base_tag_name), - fmt_string(ice::string::empty(tag_name) || ice::string::empty(base_tag_name) ? "" : " | "), + fmt_string(tag_name.is_empty() || base_tag_name.is_empty() ? "" : " | "), fmt_string(tag_name) ); diff --git a/source/code/core/utils/private/log_buffer.cxx b/source/code/core/utils/private/log_buffer.cxx index 296c9a74..4f3e7001 100644 --- a/source/code/core/utils/private/log_buffer.cxx +++ b/source/code/core/utils/private/log_buffer.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "log_buffer.hxx" @@ -11,7 +11,7 @@ namespace ice::detail static_cast(buf).grow(capacity); } - LogMessageBuffer::LogMessageBuffer(ice::Allocator& alloc, ice::ucount initial_allocation) noexcept + LogMessageBuffer::LogMessageBuffer(ice::Allocator& alloc, ice::u32 initial_allocation) noexcept : fmt::detail::buffer{ internal_grow_fmt_buffer } , _allocator{ alloc } { diff --git a/source/code/core/utils/private/log_buffer.hxx b/source/code/core/utils/private/log_buffer.hxx index 7c0b8207..737ada5a 100644 --- a/source/code/core/utils/private/log_buffer.hxx +++ b/source/code/core/utils/private/log_buffer.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -12,7 +12,7 @@ namespace ice::detail class LogMessageBuffer final : public fmt::v11::detail::buffer { public: - LogMessageBuffer(ice::Allocator& alloc, ice::ucount initial_allocation) noexcept; + LogMessageBuffer(ice::Allocator& alloc, ice::u32 initial_allocation) noexcept; ~LogMessageBuffer() noexcept; void grow(size_t size) noexcept; diff --git a/source/code/core/utils/private/log_internal.cxx b/source/code/core/utils/private/log_internal.cxx index 9042647f..5fa60b89 100644 --- a/source/code/core/utils/private/log_internal.cxx +++ b/source/code/core/utils/private/log_internal.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "log_internal.hxx" @@ -32,7 +32,7 @@ namespace ice::detail auto LogState::register_sink(ice::LogSinkFn fn_sink, void* userdata) noexcept -> ice::LogSinkID { - ice::ucount const sinkidx = ice::count(_sinks); + ice::u32 const sinkidx = ice::count(_sinks); // Pottentially an error when sinks are added and remove all the time! // NOTE: Once added sinks should only be reset when a module was reloaded! ICE_ASSERT_CORE(sinkidx < 50); @@ -42,7 +42,7 @@ namespace ice::detail void LogState::unregister_sink(ice::LogSinkID sinkid) noexcept { - ice::ucount const sinkidx = static_cast(sinkid); + ice::u32 const sinkidx = static_cast(sinkid); if (ice::count(_sinks) > sinkidx) { // Just clear the values diff --git a/source/code/core/utils/private/log_internal.hxx b/source/code/core/utils/private/log_internal.hxx index 42362d35..f2f1e2b0 100644 --- a/source/code/core/utils/private/log_internal.hxx +++ b/source/code/core/utils/private/log_internal.hxx @@ -121,7 +121,7 @@ namespace ice::detail constexpr auto fmt_string(ice::String str) noexcept -> fmt::string_view { - return fmt_string(str._data, str._data + str._size); + return fmt_string(str.begin(), str.end()); } static constexpr ice::String severity_value[]{ diff --git a/source/code/core/utils/private/native_aio.cxx b/source/code/core/utils/private/native_aio.cxx index f9d84991..5b44a98f 100644 --- a/source/code/core/utils/private/native_aio.cxx +++ b/source/code/core/utils/private/native_aio.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "native_aio.hxx" @@ -543,11 +543,11 @@ namespace ice::native_aio auto aio_process_events( ice::native_aio::AIOPort port, ice::native_aio::AIOProcessLimits limits - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { ice::usize bytes; - ice::ucount num_completed = 0; + ice::u32 num_completed = 0; while(limits.events_max > num_completed) { ice::native_aio::AIORequest const* request = nullptr; diff --git a/source/code/core/utils/private/native_file.cxx b/source/code/core/utils/private/native_file.cxx index 067122d1..2a90a66e 100644 --- a/source/code/core/utils/private/native_file.cxx +++ b/source/code/core/utils/private/native_file.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "native_aio.hxx" @@ -83,7 +83,7 @@ namespace ice::native_file bool exists_file(ice::native_file::FilePath path) noexcept { IPT_ZONE_SCOPED; - DWORD const result = GetFileAttributesW(ice::string::begin(path)); + DWORD const result = GetFileAttributesW(path.begin()); return result != INVALID_FILE_ATTRIBUTES && (result == FILE_ATTRIBUTE_NORMAL || (result & (FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_READONLY)) != 0); @@ -97,7 +97,7 @@ namespace ice::native_file IPT_ZONE_SCOPED; ice::win32::FileHandle handle{ CreateFileW( - ice::string::begin(path), + path.begin(), translate_access(flags), translate_mode(flags), // FILE_SHARE_* NULL, // SECURITY ATTRIBS @@ -126,7 +126,7 @@ namespace ice::native_file ice::native_aio::aio_file_flags(port, flags); ice::win32::FileHandle result = ice::win32::FileHandle{ CreateFileW( - ice::string::begin(path), + path.begin(), translate_access(flags), translate_mode(flags), // FILE_SHARE_* NULL, // SECURITY ATTRIBS @@ -357,20 +357,20 @@ namespace ice::native_file ) noexcept { // Store for later information about the current state of dirpath - if (ice::string::back(dirpath) != L'/') + if (dirpath.back() != L'/') { - ice::string::push_back(dirpath, L'/'); + dirpath.push_back(L'/'); } - ice::u32 const size_dirpath = ice::string::size(dirpath); - ice::string::push_back(dirpath, L'*'); + ice::ncount const size_dirpath = dirpath.size(); + dirpath.push_back(L'*'); WIN32_FIND_DATA direntry; HANDLE const handle = FindFirstFileW( - ice::string::begin(dirpath), + dirpath.begin(), &direntry ); - ice::string::pop_back(dirpath); + dirpath.pop_back(); bool traverse_success = false; if (handle != INVALID_HANDLE_VALUE) @@ -391,7 +391,7 @@ namespace ice::native_file // Append the entry name to the path ice::native_file::FilePath const entry_name = (ice::wchar const*)direntry.cFileName; - ice::string::push_back(dirpath, entry_name); + dirpath.push_back(entry_name); // Call the callback for the next entry encountered... ice::native_file::TraverseAction const action = callback(basepath, dirpath, type, userdata); @@ -411,7 +411,7 @@ namespace ice::native_file } // Rollback the directory string to the base value - ice::string::resize(dirpath, size_dirpath); + dirpath.resize(size_dirpath); } while (FindNextFileW(handle, &direntry) != FALSE); FindClose(handle); @@ -427,8 +427,8 @@ namespace ice::native_file { ice::StackAllocator_1024 temp_alloc; ice::native_file::HeapFilePath dirpath{ temp_alloc }; - ice::string::reserve(dirpath, 256 * 2); // 512 bytes for paths - ice::string::push_back(dirpath, starting_dir); + dirpath.reserve(256 * 2); // 512 bytes for paths + dirpath.push_back(starting_dir); return traverse_directories_internal(dirpath, dirpath, callback, userdata); } @@ -437,14 +437,14 @@ namespace ice::native_file ) noexcept { // If zero, we failed, check why. - if (CreateDirectory(ice::string::begin(dirpath), NULL) == 0) + if (CreateDirectory(dirpath.begin(), NULL) == 0) { // Try the next path before retrying this path. if (GetLastError() == ERROR_PATH_NOT_FOUND) { // Remove the top-most the directory explicitly. - ice::ucount const dirslash = ice::string::find_last_of(ice::WString{ dirpath }, ice::WString{ L"\\/" }); - if (dirslash == ice::String_NPos) + ice::nindex const dirslash = dirpath.find_last_of(L"\\/"); + if (dirslash == ice::none_index) { return false; } @@ -460,7 +460,7 @@ namespace ice::native_file dirpath[dirslash] = '/'; // Try again to create the directory - return CreateDirectory(ice::string::begin(dirpath), NULL) != 0; + return CreateDirectory(dirpath.begin(), NULL) != 0; } // else it's either 'ERROR_ALREADY_EXISTS' so we continue. } @@ -488,7 +488,7 @@ namespace ice::native_file ice::String path_string ) noexcept { - ice::string::clear(out_filepath); + out_filepath.clear(); ice::utf8_to_wide_append(path_string, out_filepath); } @@ -497,7 +497,7 @@ namespace ice::native_file ice::HeapString<>& out_string ) noexcept { - ice::string::clear(out_string); + out_string.clear(); ice::wide_to_utf8_append(path, out_string); } @@ -507,11 +507,11 @@ namespace ice::native_file ) noexcept { // TODO: Think if maybe moving this to a different function is possible? - if (ice::string::any(path) && ice::string::back(path) != L'/' && ice::string::back(path) != L'\\') + if (path.not_empty() && path.back() != L'/' && path.back() != L'\\') { - if (ice::string::front(string) != '/' && ice::string::front(string) != '\\') + if (string.front() != '/' && string.front() != '\\') { - ice::string::push_back(path, L'/'); + path.push_back(L'/'); } } ice::utf8_to_wide_append(string, path); @@ -793,8 +793,8 @@ namespace ice::native_file else if (errno == ENOENT) { // Remove the top-most the directory explicitly. - ice::ucount const dirslash = ice::string::find_last_of(dirpath, ice::String{ "/" }); - if (dirslash == ice::String_NPos) + ice::nindex const dirslash = ice::string::find_last_of(dirpath, ice::String{ "/" }); + if (dirslash == ice::none_index) { return false; } diff --git a/source/code/core/utils/private/params.cxx b/source/code/core/utils/private/params.cxx index 93af4206..887d48d4 100644 --- a/source/code/core/utils/private/params.cxx +++ b/source/code/core/utils/private/params.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -20,14 +20,14 @@ namespace ice auto to_std(ice::String str) noexcept { - return std::string{ ice::string::begin(str), ice::string::end(str) }; + return std::string{ str.begin(), str.end() }; } auto to_std_or(ice::String str, std::string_view fallback) noexcept { - if (ice::string::any(str)) + if (str.not_empty()) { - return std::string{ ice::string::begin(str), ice::string::end(str) }; + return std::string{ str.begin(), str.end() }; } else { @@ -179,15 +179,15 @@ namespace ice opt->required(ice::has_any(definition.flags, PF::IsRequired)); opt->allow_extra_args(ice::has_all(definition.flags, PF::AllowExtraArgs)); // Arrays have one additional check - if (ice::string::any(definition.description)) + if (definition.description.not_empty()) { opt->description(to_std(definition.description)); } - if (ice::string::any(definition.group)) + if (definition.group.not_empty()) { opt->group(to_std(definition.group)); } - if (ice::string::any(definition.type_name)) + if (definition.type_name.not_empty()) { opt->type_name(to_std(definition.type_name)); } @@ -221,7 +221,7 @@ namespace ice opt->expected(definition.min, definition.max); } - if (ice::string::empty(definition.type_name)) + if (definition.type_name.is_empty()) { opt->type_name("VALUE"); } @@ -299,9 +299,7 @@ namespace ice { auto fn_callback = [&out_value](CLI::results_t const& results) noexcept { - std::string const& arg = results.front(); - out_value._data = arg.data(); - out_value._size = static_cast(arg.size()); + out_value = ice::String{ results.front() }; return true; }; params_setup(app.add_option(to_std(definition.name), ice::move(fn_callback)), definition); @@ -319,7 +317,7 @@ namespace ice auto fn_callback = [&out_value](CLI::results_t const& results) noexcept { std::string const& arg = results.front(); - ice::string::push_back(out_value, ice::String{ std::string_view{ arg } }); + out_value.push_back(ice::String{ std::string_view{ arg } }); return true; }; params_setup(app.add_option(to_std(definition.name), ice::move(fn_callback)), definition); @@ -338,7 +336,7 @@ namespace ice { for (std::string const& result : results) { - ice::array::push_back(out_values, { result.data(), static_cast(result.size()) }); + ice::array::push_back(out_values, { result.data(), static_cast(result.size()) }); } return true; }; @@ -380,7 +378,7 @@ namespace ice &alloc = params->_allocator ](CLI::results_t const& results) noexcept { - ice::ucount const result_count = (ice::ucount) std::min( + ice::u32 const result_count = (ice::u32) std::min( results.size(), std::max(typesize.y, 0) ); ice::StackAllocator * 8> stack_alloc; diff --git a/source/code/core/utils/private/path_utils.cxx b/source/code/core/utils/private/path_utils.cxx index fa8fb624..02eb43aa 100644 --- a/source/code/core/utils/private/path_utils.cxx +++ b/source/code/core/utils/private/path_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -28,15 +28,15 @@ namespace ice::path { if constexpr (ice::build::is_windows) { - if (ice::string::size(path) >= 3) + if (path.size() >= 3) { - return path[1] == Separators_Drive[0] && ice::string::find_first_of(Separators_Directory, path[2]) != ice::String_NPos; + return path[1] == Separators_Drive[0] && Separators_Directory.find_first_of(path[2]) != ice::none_index; } return false; } else { - return ice::string::any(path) && ice::string::front(path) == Separators_Directory[1]; + return path.not_empty() && path.front() == Separators_Directory[1]; } } @@ -46,45 +46,45 @@ namespace ice::path if constexpr (ice::build::is_windows) { // Only support single-letter drives - return ice::string::size(path) == 3 + return path.size() == 3 && path[1] == Separators_Drive[0] - && ice::string::find_first_of(Separators_Directory, path[2]) != ice::String_NPos; + && path.find_first_of(Separators_Directory, path[2]) != ice::none_index; } else { - return ice::string::size(path) == 1 && ice::string::front(path) == Separators_Directory[1]; + return path.size() == 1 && path.front() == Separators_Directory[1]; } } template constexpr auto extension(ice::BasicString str) noexcept -> ice::BasicString { - auto const separator_pos = ice::string::find_last_of(str, Separators_Dot); - return ice::string::substr(str, separator_pos == ice::String_NPos ? ice::string::size(str) : separator_pos); + ice::nindex const separator_pos = str.find_last_of(Separators_Dot); + return str.substr(separator_pos.value_or(str.size())); } template constexpr auto filename(ice::BasicString str) noexcept -> ice::BasicString { - auto const separator_pos = ice::string::find_last_of(str, Separators_Directory); - return ice::string::substr(str, separator_pos == ice::String_NPos ? 0 : separator_pos + 1); + ice::nindex const separator_pos = str.find_last_of(Separators_Directory) + 1; + return str.substr(separator_pos.value_or(0)); } template constexpr auto basename(ice::BasicString str) noexcept -> ice::BasicString { ice::BasicString const name = filename(str); - auto const extension_pos = ice::string::find_last_of(name, Separators_Dot); - return ice::string::substr(name, 0, extension_pos); + auto const extension_pos = name.find_last_of(Separators_Dot); + return name.substr(0, extension_pos); } template constexpr auto directory(ice::BasicString str) noexcept -> ice::BasicString { - auto const separator_pos = ice::string::find_last_of(str, Separators_Directory); - if (separator_pos == ice::String_NPos) + ice::nindex const separator_pos = str.find_last_of(Separators_Directory); + if (separator_pos == ice::none_index) { - return ice::string::substr(str, ice::string::size(str), separator_pos); + return str.substr(str.size(), separator_pos); } if constexpr (ice::build::is_windows) @@ -92,11 +92,11 @@ namespace ice::path if (separator_pos > 0 && str[separator_pos - 1] == ':') { // Keep the separator so we end up with C:/ - return ice::string::substr(str, 0, separator_pos + 1); + return str.substr(0, separator_pos + 1); } } - return ice::string::substr(str, 0, separator_pos); + return str.substr(0, separator_pos); } template @@ -109,23 +109,23 @@ namespace ice::path return left; } - if (auto last_char = ice::string::back(left); last_char != Separators_Directory[1]) + if (auto last_char = left.back(); last_char != Separators_Directory[1]) { if (last_char == Separators_Directory[0]) { - ice::string::pop_back(left); + left.pop_back(); } - ice::string::push_back(left, Separators_Directory[1]); + left.push_back(Separators_Directory[1]); } - if (ice::string::front(right) == Separators_Directory[1] || ice::string::front(right) == Separators_Directory[0]) + if (right.front() == Separators_Directory[1] || right.front() == Separators_Directory[0]) { - right = ice::string::substr(right, ice::string::find_first_not_of(right, Separators_Directory)); + right = right.substr(right.find_first_not_of(Separators_Directory)); } if (right != Separators_Dot) { - ice::string::push_back(left, right); + left.push_back(right); } return left; @@ -135,8 +135,8 @@ namespace ice::path auto normalize(ice::HeapString& path) noexcept -> ice::BasicString { bool const abs = detail::is_absolute(path); - CharType const* end = ice::string::end(path); - CharType* const beg = ice::string::begin(path); + CharType const* end = path.end(); + CharType* const beg = path.begin(); if (beg == end) { return path; @@ -177,10 +177,10 @@ namespace ice::path // Find starting position for next solve it = beg; - ice::ucount const begin = ice::string::find_first_of(path, Separators_Drive); - if (begin != ice::String_NPos) + ice::nindex const begin = path.find_first_of(Separators_Drive); + if (begin != ice::none_index) { - it += begin + 1; + it = it + begin + 1; } copy_to = it; @@ -214,46 +214,43 @@ namespace ice::path copy_to += 1; } - ice::string::resize( - path, - ice::ucount(copy_to - beg) - ); + path.resize(copy_to - beg); return path; } template auto replace_filename(ice::HeapString& str, ice::BasicString name) noexcept -> ice::BasicString { - auto const separator_pos = ice::string::find_last_of(str, Separators_Directory); - if (separator_pos != ice::String_NPos) + auto const separator_pos = str.find_last_of(Separators_Directory); + if (separator_pos != ice::none_index) { - ice::string::resize(str, separator_pos + 1); + str.resize(separator_pos + 1); } else { - ice::string::clear(str); + str.clear(); } - ice::string::push_back(str, name); + str.push_back(name); return str; } template auto replace_extension(ice::HeapString& str, ice::BasicString extension) noexcept -> ice::BasicString { - auto const separator_pos = ice::string::find_last_of(str, Separators_Dot[0]); - if (separator_pos != ice::String_NPos) + auto const separator_pos = str.find_last_of(Separators_Dot[0]); + if (separator_pos != ice::none_index) { - ice::string::resize(str, separator_pos); + str.resize(separator_pos); } - if (ice::string::empty(extension) == false) + if (str.not_empty()) { - if (ice::string::front(extension) != Separators_Dot[0]) + if (extension.front() != Separators_Dot[0]) { - ice::string::push_back(str, Separators_Dot[0]); + str.push_back(Separators_Dot[0]); } - ice::string::push_back(str, extension); + str.push_back(extension); } return str; } @@ -262,7 +259,7 @@ namespace ice::path bool is_absolute(ice::String path) noexcept { return detail::is_absolute(path); } bool is_absolute_root(ice::String path) noexcept { return detail::is_absolute_root(path); } - auto length(ice::String path) noexcept -> ice::ucount { return ice::string::size(path); } + auto length(ice::String path) noexcept -> ice::u32 { return path.size().u32(); } auto extension(ice::String path) noexcept -> ice::String { return detail::extension(path); } auto filename(ice::String path) noexcept -> ice::String { return detail::filename(path); } auto basename(ice::String path) noexcept -> ice::String { return detail::basename(path); } @@ -274,7 +271,7 @@ namespace ice::path bool is_absolute(ice::WString path) noexcept { return detail::is_absolute(path); } bool is_absolute_root(ice::WString path) noexcept { return detail::is_absolute_root(path); } - auto length(ice::WString path) noexcept -> ice::ucount { return ice::string::size(path); } + auto length(ice::WString path) noexcept -> ice::u32 { return path.size().u32(); } auto extension(ice::WString path) noexcept -> ice::WString { return detail::extension(path); } auto filename(ice::WString path) noexcept -> ice::WString { return detail::filename(path); } auto basename(ice::WString path) noexcept -> ice::WString { return detail::basename(path); } diff --git a/source/code/core/utils/private/string_utils.cxx b/source/code/core/utils/private/string_utils.cxx index f3c0d61d..4951a481 100644 --- a/source/code/core/utils/private/string_utils.cxx +++ b/source/code/core/utils/private/string_utils.cxx @@ -17,8 +17,8 @@ namespace ice { #if ISP_WINDOWS ice::u32 const comp_result = check_case == CaseSensitive::Yes - ? strncmp(ice::string::begin(left), ice::string::begin(right), count) - : strnicmp(ice::string::begin(left), ice::string::begin(right), count); + ? strncmp(left.begin(), right.begin(), count) + : strnicmp(left.begin(), right.begin(), count); #elif ISP_UNIX ice::u32 const comp_result = check_case == CaseSensitive::Yes ? strncmp(ice::string::begin(left), ice::string::begin(right), count) @@ -34,11 +34,11 @@ namespace ice ice::CaseSensitive check_case /*= CaseSensitive::No*/ ) noexcept -> ice::CompareResult { - ice::u32 const max_size = ice::min(ice::size(left), ice::size(right)); + ice::ncount const max_size = ice::min(left.size(), right.size()); #if ISP_WINDOWS ice::u32 const comp_result = check_case == CaseSensitive::Yes - ? strncmp(ice::string::begin(left), ice::string::begin(right), max_size) - : strnicmp(ice::string::begin(left), ice::string::begin(right), max_size); + ? strncmp(left.begin(), right.begin(), max_size) + : strnicmp(left.begin(), right.begin(), max_size); #elif ISP_UNIX ice::u32 const comp_result = check_case == CaseSensitive::Yes ? strncmp(ice::string::begin(left), ice::string::begin(right), max_size) @@ -56,8 +56,8 @@ namespace ice ice::i32 const chars_written = MultiByteToWideChar( CP_UTF8, 0, - ice::string::begin(utf8_str), - ice::string::size(utf8_str), + utf8_str.begin(), + utf8_str.size().u32(), nullptr, 0 ); @@ -74,28 +74,28 @@ namespace ice ) noexcept { #if ISP_WINDOWS - ice::i32 const required_size = MultiByteToWideChar( + ice::ncount const required_size = MultiByteToWideChar( CP_UTF8, 0, - ice::string::begin(utf8_str), - ice::string::size(utf8_str), + utf8_str.begin(), + utf8_str.size().u32(), NULL, 0 ); if (required_size != 0) { - ice::u32 const current_size = ice::string::size(out_str); - ice::u32 const total_size = static_cast(required_size) + ice::string::size(out_str); - ice::string::resize(out_str, total_size); + ice::ncount const current_size = out_str.size(); + ice::ncount const total_size = required_size + out_str.size(); + out_str.resize(total_size); - ice::i32 const chars_written = MultiByteToWideChar( + ice::ncount const chars_written = MultiByteToWideChar( CP_UTF8, 0, - ice::string::begin(utf8_str), - ice::string::size(utf8_str), - ice::string::begin(out_str) + current_size, - ice::string::size(out_str) - current_size + utf8_str.begin(), + utf8_str.size().u32(), + out_str.begin() + current_size, + out_str.size().u32() - current_size.u32() ); ICE_ASSERT( @@ -132,8 +132,8 @@ namespace ice ice::i32 const required_size = WideCharToMultiByte( CP_UTF8, 0, - ice::string::begin(path), - ice::string::size(path), + path.begin(), + path.size().u32(), NULL, 0, NULL, @@ -152,20 +152,20 @@ namespace ice ) noexcept { #if ISP_WINDOWS - ice::i32 const required_size = wide_to_utf8_size(path); + ice::ncount const required_size = wide_to_utf8_size(path); if (required_size != 0) { - ice::u32 const current_size = ice::string::size(out_str); - ice::u32 const total_size = static_cast(required_size) + ice::string::size(out_str); - ice::string::resize(out_str, total_size); + ice::ncount const current_size = out_str.size(); + ice::ncount const total_size = required_size + out_str.size(); + out_str.resize(total_size); ice::i32 const chars_written = WideCharToMultiByte( CP_UTF8, 0, - ice::string::begin(path), - ice::string::size(path), - ice::string::begin(out_str) + current_size, - ice::string::size(out_str) - current_size, + path.begin(), + path.size().u32(), + out_str.begin() + current_size, + out_str.size().u32() - current_size.u32(), NULL, NULL ); diff --git a/source/code/core/utils/public/ice/config/config_builder.hxx b/source/code/core/utils/public/ice/config/config_builder.hxx index 9dbfa9f0..7b3cfd23 100644 --- a/source/code/core/utils/public/ice/config/config_builder.hxx +++ b/source/code/core/utils/public/ice/config/config_builder.hxx @@ -1,10 +1,10 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include namespace ice { diff --git a/source/code/core/utils/public/ice/log_formatters.hxx b/source/code/core/utils/public/ice/log_formatters.hxx index 72de9b49..70f73fff 100644 --- a/source/code/core/utils/public/ice/log_formatters.hxx +++ b/source/code/core/utils/public/ice/log_formatters.hxx @@ -15,7 +15,7 @@ struct fmt::formatter> : public fmt::formatter constexpr auto format(ice::BasicString value, FormatContext& ctx) const noexcept { - return fmt::formatter>::format({ value._data, value._size }, ctx); + return fmt::formatter>::format(value, ctx); } }; @@ -82,6 +82,22 @@ struct fmt::formatter> } }; +template<> +struct fmt::formatter +{ + template + constexpr auto parse(ParseContext& ctx) + { + return ctx.begin(); + } + + template + constexpr auto format(ice::ncount value, FormatContext& ctx) const noexcept + { + return fmt::format_to(ctx.out(), "{}", value.native()); + } +}; + template<> struct fmt::formatter { diff --git a/source/code/core/utils/public/ice/native_aio.hxx b/source/code/core/utils/public/ice/native_aio.hxx index d05c9aa4..d9bfd2ae 100644 --- a/source/code/core/utils/public/ice/native_aio.hxx +++ b/source/code/core/utils/public/ice/native_aio.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -11,7 +11,7 @@ namespace ice::native_aio struct AIOPortInfo { - ice::ucount worker_limit = 1; + ice::u32 worker_limit = 1; ice::String debug_name; }; @@ -68,6 +68,6 @@ namespace ice::native_aio auto aio_process_events( ice::native_aio::AIOPort port, ice::native_aio::AIOProcessLimits limits = {} - ) noexcept -> ice::ucount; + ) noexcept -> ice::u32; } // namespace ice::native_aio diff --git a/source/code/core/utils/public/ice/path_utils.hxx b/source/code/core/utils/public/ice/path_utils.hxx index e347ee7d..52e14067 100644 --- a/source/code/core/utils/public/ice/path_utils.hxx +++ b/source/code/core/utils/public/ice/path_utils.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -16,7 +16,7 @@ namespace ice::path bool is_absolute_root(ice::String path) noexcept; //! \return The lenght of the path. - auto length(ice::String path) noexcept -> ice::ucount; + auto length(ice::String path) noexcept -> ice::u32; //! \return The last extension part (with the dot character) or empty string if no extension was found. auto extension(ice::String path) noexcept -> ice::String; @@ -59,7 +59,7 @@ namespace ice::path bool is_absolute(ice::WString path) noexcept; bool is_absolute_root(ice::WString path) noexcept; - auto length(ice::WString path) noexcept -> ice::ucount; + auto length(ice::WString path) noexcept -> ice::u32; auto extension(ice::WString path) noexcept -> ice::WString; auto filename(ice::WString path) noexcept -> ice::WString; auto basename(ice::WString path) noexcept -> ice::WString; diff --git a/source/code/core/utils/public/ice/string_utils.hxx b/source/code/core/utils/public/ice/string_utils.hxx index 9486898b..49f5c4db 100644 --- a/source/code/core/utils/public/ice/string_utils.hxx +++ b/source/code/core/utils/public/ice/string_utils.hxx @@ -3,7 +3,6 @@ #pragma once #include -#include #include #include #include @@ -19,7 +18,7 @@ namespace ice template constexpr void push_format( - ice::HeapString& str, + ice::string::ResizableStringType auto& str, fmt::format_string format, Args&&... args ) noexcept; @@ -74,8 +73,8 @@ namespace ice if constexpr (std::is_integral_v) { fc_res = std::from_chars( - ice::string::begin(str), - ice::string::end(str), + str.begin(), + str.end(), out_value ); } @@ -86,8 +85,8 @@ namespace ice // We don't try to handle errors in this version. fc_res.ec = std::errc{}; char* ptr_end = nullptr; // Why the hell is this a char ptr? - out_value = strtof(ice::string::begin(str), &ptr_end); - ICE_ASSERT_CORE(ice::ptr_distance(ice::string::begin(str), ptr_end).value <= ice::size(str)); + out_value = strtof(str.begin(), &ptr_end); + ICE_ASSERT_CORE(ice::ptr_distance(str.begin(), ptr_end).value <= str.size()); fc_res.ptr = ptr_end; #else fc_res = std::from_chars( @@ -110,7 +109,7 @@ namespace ice return { .ec = res, - .remaining = ice::String{ fc_res.ptr, ice::string::end(str) } + .remaining = ice::String{ fc_res.ptr, str.end() } }; } @@ -186,20 +185,19 @@ namespace ice template constexpr void push_format( - ice::HeapString& str, + ice::string::ResizableStringType auto& str, fmt::format_string format, Args&&... args ) noexcept { - ice::u32 const size = ice::u32(fmt::formatted_size(format, ice::forward(args)...)); - ice::u32 const new_size = ice::string::size(str) + size; - if (new_size + 1 >= str._capacity) + ice::ncount const pushed_size = fmt::formatted_size(format, ice::forward(args)...); + ice::ncount const final_size = str.size() + pushed_size; + if (final_size + 1 >= str.capacity()) { - ice::string::grow(str, new_size + 1); + str.grow(final_size + 1); } - fmt::format_to_n(ice::string::end(str), size, format, ice::forward(args)...); - str._size += size; - str._data[str._size] = '\0'; + fmt::format_to_n(str.end(), pushed_size, format, ice::forward(args)...); + str.resize(final_size); } template @@ -209,31 +207,30 @@ namespace ice Args&&... args ) noexcept { - ice::u32 const size = ice::u32(fmt::formatted_size(format, ice::forward(args)...)); - ice::u32 new_size = ice::string::size(str) + size; - if (new_size + 1 >= Capacity) + ice::ncount const pushed_size = fmt::formatted_size(format, ice::forward(args)...); + ice::ncount const final_size = str.size() + pushed_size; + if (final_size + 1 >= Capacity) { - new_size = Capacity - 1; + final_size = Capacity - 1; } - fmt::format_to_n(ice::string::end(str), new_size, format, ice::forward(args)...); - str._size += new_size; - str._data[str._size] = '\0'; + fmt::format_to_n(str.end(), final_size, format, ice::forward(args)...); + str.resize(final_size); } template constexpr auto for_each_split(ice::String contents, ice::String separator, Fn&& fn) noexcept -> ice::u32 { ice::u32 count = 0; - while(ice::string::any(contents)) + while(contents.not_empty()) { count += 1; - ice::ucount const separator_pos = ice::string::find_first_of(contents, separator); - ice::String const line = ice::string::substr(contents, 0, separator_pos); + ice::nindex const separator_pos = contents.find_first_of(separator); + ice::String const line = contents.substr(0, separator_pos); if (ice::forward(fn)(line) == false) { break; } - contents = ice::string::substr(contents, separator_pos + 1); + contents = contents.substr(separator_pos + 1); } return count; } diff --git a/source/code/core/utils/utils_tests.bff b/source/code/core/utils/utils_tests.bff index e97f6afe..21bd0ba4 100644 --- a/source/code/core/utils/utils_tests.bff +++ b/source/code/core/utils/utils_tests.bff @@ -29,7 +29,7 @@ .UnitTests = [ - .Enabled = true + .Enabled = false ] ] .Projects + .Project diff --git a/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx b/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx index 9d2190bc..d2a14316 100644 --- a/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx +++ b/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_tilemap.hxx" @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -141,14 +140,14 @@ namespace ice Fn&& tileid_callback ) noexcept { - ice::String csv_data{ node_data->value(), ice::ucount(node_data->value_size()) }; + ice::String csv_data{ node_data->value(), ice::u32(node_data->value_size()) }; - ice::u32 beg = 0; - ice::u32 end = ice::string::find_first_of(csv_data, ','); - while (end != ice::String_NPos) + ice::nindex beg = 0; + ice::nindex end = csv_data.find_first_of(','); + while (end != ice::none_index) { - char const* val_beg = ice::string::begin(csv_data) + beg; - char const* val_end = ice::string::begin(csv_data) + end; + char const* val_beg = csv_data.begin() + beg; + char const* val_end = csv_data.begin() + end; while (std::isdigit(*val_beg) == false && val_beg != val_end) { @@ -162,12 +161,12 @@ namespace ice } beg = end + 1; - end = ice::string::find_first_of(csv_data, ',', beg); + end = csv_data.find_first_of(',', beg); } { - char const* val_beg = ice::string::begin(csv_data) + beg; - char const* val_end = ice::string::begin(csv_data) + node_data->value_size(); + char const* val_beg = csv_data.begin() + beg; + char const* val_end = csv_data.begin() + node_data->value_size(); while (std::isdigit(*val_beg) == false && val_beg != val_end) { @@ -188,14 +187,14 @@ namespace ice Fn&& point_callback ) noexcept { - char const* const data = ice::string::begin(points); + char const* const data = points.begin(); - ice::u32 beg = 0; - ice::u32 end = ice::string::find_first_of(points, ' '); - while (end != ice::String_NPos) + ice::nindex beg = 0; + ice::nindex end = points.find_first_of(' '); + while (end != ice::none_index) { char const* val_beg = data + beg; - char const* val_delim = data + ice::string::find_first_of(points, ',', beg); + char const* val_delim = data + points.find_first_of(',', beg); char const* val_end = data + end; while (std::isdigit(*val_beg) == false && val_beg != val_end) @@ -213,13 +212,13 @@ namespace ice } beg = end + 1; - end = ice::string::find_first_of(points, ' ', beg); + end = points.find_first_of(' ', beg); } { char const* val_beg = data + beg; - char const* val_delim = data + ice::string::find_first_of(points, ',', beg); - char const* val_end = data + ice::string::size(points); + char const* val_delim = data + points.find_first_of(',', beg); + char const* val_end = data + points.size(); while (std::isdigit(*val_beg) == false && val_beg != val_end) { @@ -875,8 +874,8 @@ namespace ice } ice::String origin = ice::resource_path(image_res); - ice::String name = ice::string::substr(origin, 0, ice::string::find_last_of(origin, '.')); - total_tileset_assets_size += ice::string::size(name) + 1; + ice::String name = origin.substr(0, origin.find_last_of('.').u32()); + total_tileset_assets_size += name.size().u32() + 1; } total_tilemap_bytes += total_tileset_assets_size; @@ -929,24 +928,24 @@ namespace ice image_res = resource_tracker.find_resource({ ice::Scheme_URN, ice::resource_path(image_res) }); ice::String origin = ice::resource_path(image_res); - ice::String name = ice::string::substr(origin, 0, ice::string::find_last_of(origin, '.')); - char const* tileset_asset_str = ice::string::begin(name); - ice::u32 const tileset_asset_len = ice::string::size(name); + ice::String name = origin,substr(0, origin.find_last_of('.')); + char const* tileset_asset_str = name.begin(); + ice::ncount const tileset_asset_len = name.size(); ice::memcpy( tileset_assets, tileset_asset_str, - tileset_asset_len + tileset_asset_len.bytes() ); tilesets[idx].element_size = tilemap_info.tileset_info[idx].element_size; ice::u32* asset_loc = reinterpret_cast(&tilesets[idx].asset);// = ice::String{ tileset_assets, tileset_asset_len }; asset_loc[0] = asset_str_offset; - asset_loc[1] = tileset_asset_len; + asset_loc[1] = tileset_asset_len.u32(); tileset_assets += tileset_asset_len; - asset_str_offset += tileset_asset_len; + asset_str_offset += tileset_asset_len.u32(); } if (result == true) @@ -1058,7 +1057,7 @@ namespace ice { if (node != nullptr) { - return ice::String{ node->name(), ice::ucount(node->name_size()) }; + return ice::String{ node->name(), ice::u32(node->name_size()) }; } return { }; } @@ -1068,7 +1067,7 @@ namespace ice { if (attrib != nullptr) { - out_value = ice::String{ attrib->value(), ice::ucount(attrib->value_size()) }; + out_value = ice::String{ attrib->value(), ice::u32(attrib->value_size()) }; return true; } return false; diff --git a/source/code/framework/framework_base/private/framework_main.cxx b/source/code/framework/framework_base/private/framework_main.cxx index 5da6a90e..e1fb2fce 100644 --- a/source/code/framework/framework_base/private/framework_main.cxx +++ b/source/code/framework/framework_base/private/framework_main.cxx @@ -338,8 +338,8 @@ auto ice_setup( ice::path::join(config.dev_dirs.assets, "../source/data"); ice::path::normalize(config.dev_dirs.shaders); ice::path::normalize(config.dev_dirs.assets); - ice::string::push_back(config.dev_dirs.shaders, '/'); - ice::string::push_back(config.dev_dirs.assets, '/'); + config.dev_dirs.shaders.push_back('/'); + config.dev_dirs.assets.push_back('/'); ice::array::push_back(resource_paths, config.dev_dirs.assets); ice::array::push_back(resource_paths, config.dev_dirs.shaders); } diff --git a/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx b/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx index 43ad5ed0..155c168e 100644 --- a/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx +++ b/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx @@ -14,7 +14,6 @@ #include #include #include -#include #include namespace ice diff --git a/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx b/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx index 792f7b2c..e9f4aa97 100644 --- a/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx +++ b/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx @@ -37,7 +37,6 @@ #include #include -#include #include #include #include diff --git a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx index 9c59b973..a17baf41 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -121,12 +121,12 @@ namespace ice::ecs ice::usize& offset_values_out ) noexcept -> ice::meminfo { - ice::ucount const component_count = ice::span::count(info.component_identifiers); + ice::u32 const component_count = ice::span::count(info.component_identifiers); ice::meminfo result = ice::meminfo_of; - offset_name_out = result += ice::meminfo_of * (ice::string::size(name) + 1); + offset_name_out = result += ice::meminfo_of * (name.size() + 1); offset_ids_out = result += ice::meminfo_of * component_count; - offset_values_out = result += ice::meminfo_of * component_count * 3; // 3 = size, alignment, offset + offset_values_out = result += ice::meminfo_of * component_count * 3; // 3 = size, alignment, offset return result; } @@ -227,7 +227,7 @@ namespace ice::ecs { // Copy archetype name ice::memset(mem_archetype_name, 0); - ice::memcpy(mem_archetype_name, ice::string::data_view(archetype_info.name)); + ice::memcpy(mem_archetype_name, archetype_info.name.data_view()); // Copy the component idnetifiers ice::memcpy(mem_component_data, ice::span::data_view(archetype_info.component_identifiers)); @@ -255,7 +255,7 @@ namespace ice::ecs ); } - data_header->archetype_name = ice::String{ (char const*) mem_archetype_name.location, ice::size(archetype_info.name) }; + data_header->archetype_name = ice::String{ (char const*) mem_archetype_name.location, archetype_info.name.size() }; data_header->archetype_identifier = archetype_info.identifier; data_header->archetype_info.data_block_filter = data_block_filter; data_header->archetype_info.component_identifiers = ice::Span{ component_identifiers, component_count }; @@ -267,7 +267,7 @@ namespace ice::ecs // We need now to calculate the number of entities that we can store in the remaining memory. // Additionally calculate the offets each component array will be located at. { - ice::ucount const component_entity_count_max = ice::ecs::detail::calculate_entity_count_for_space( + ice::u32 const component_entity_count_max = ice::ecs::detail::calculate_entity_count_for_space( data_header->archetype_info, data_block_pool->provided_block_size() ); @@ -303,7 +303,7 @@ namespace ice::ecs ice::hashmap::set(_archetype_index, ice::hash(archetype_info.identifier), archetype_index); // Save the 'index' for the given name - if (ice::string::any(data_header->archetype_name)) + if (data_header->archetype_name.not_empty()) { ice::hashmap::set(_archetype_names_index, ice::hash(data_header->archetype_name), archetype_index); } diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx index 71d52834..1919e342 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -323,8 +323,8 @@ namespace ice::ecs return Result{ *this }; } - ice::ucount const entity_count = mode == 2 ? index_create_count : ice::count(entities); - ice::ucount const component_count = ice::count(component_info.names); + ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); + ice::u32 const component_count = ice::count(component_info.names); ice::meminfo additional_data_size = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; additional_data_size += ice::meminfo_of * entity_count; @@ -398,7 +398,7 @@ namespace ice::ecs ice::memcpy(operation_data, data.location, data.size); // Save the offset - offsets_ptr[component_idx] = ice::ucount(ice::ptr_distance(data_beg, operation_data).value); + offsets_ptr[component_idx] = ice::u32(ice::ptr_distance(data_beg, operation_data).value); operation_data = ice::ptr_add(operation_data, data.size); component_idx += 1; @@ -408,7 +408,7 @@ namespace ice::ecs operation->entities = entities_ptr; operation->entity_count = entity_count; operation->component_data = component_info_ptr; - operation->component_data_size = ice::ucount(ice::ptr_distance(component_info_ptr, operation_data).value); + operation->component_data_size = ice::u32(ice::ptr_distance(component_info_ptr, operation_data).value); operation->filter_data = filter_ptr; if (mode == 2) @@ -424,7 +424,7 @@ namespace ice::ecs { if (mode != 0) { - ice::ucount const entity_count = mode == 2 ? index_create_count : ice::count(entities); + ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); ice::meminfo required_memory = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; required_memory += ice::meminfo_of * entity_count; diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx index 6fb2eb71..6ce2abc8 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -331,7 +331,7 @@ namespace ice::ecs ice::ecs::detail::DataBlock* archetype_block = nullptr; ice::u32 archetype_block_index = ice::u32_max; - ice::ucount dtor_count = 0; + ice::u32 dtor_count = 0; ice::ecs::detail::EntityDestructor const* dtors[5]; ice::u32 dtor_components_sizes[10]; ice::u32 dtor_components_offsets[10]; @@ -546,7 +546,7 @@ namespace ice::ecs } // namespace detail - static constexpr ice::ucount Constant_InitialEntityCount = 1024 * 32; + static constexpr ice::u32 Constant_InitialEntityCount = 1024 * 32; EntityStorage::EntityStorage( ice::Allocator& alloc, @@ -1112,10 +1112,10 @@ namespace ice::ecs auto EntityStorage::query_data_slots( ice::Span requested, ice::Span out_data_slots - ) const noexcept -> ice::ucount + ) const noexcept -> ice::u32 { ice::u32 idx = 0; - ice::ucount valid = 0; + ice::u32 valid = 0; for (ice::ecs::Entity entity : requested) { ice::ecs::EntityInfo const entity_info = ice::ecs::entity_info(entity); @@ -1153,7 +1153,7 @@ namespace ice::ecs IPT_ZONE_SCOPED; ice::StackAllocator<512_B> archetypes_alloc{}; ice::Array archetypes{ archetypes_alloc }; - ice::array::reserve(archetypes, ice::mem_max_capacity(archetypes_alloc.Constant_InternalCapacity)); + ice::array::reserve(archetypes, (u32) ice::mem_max_capacity(archetypes_alloc.Constant_InternalCapacity)); _archetype_index.find_archetypes(archetypes, query_info, query_tags); ice::u32 const prev_archetype_count = ice::count(out_instance_infos); diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index d0e6c791..05e51a89 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "engine_state_tracker_default.hxx" @@ -163,13 +163,13 @@ namespace ice auto EngineStateTracker_Default::update_states( ice::ShardContainer const& shards, ice::ShardContainer& out_shards - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { ice::StackAllocator<512_B> temp_alloc; ice::ShardContainer temp_shards{ temp_alloc }; ice::array::reserve( temp_shards._data, - ice::mem_max_capacity( + (u32)ice::mem_max_capacity( ice::size_of, decltype(temp_alloc)::Constant_InternalCapacity ) diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx index 0f19d6cb..24b51468 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -58,7 +58,7 @@ namespace ice auto update_states( ice::ShardContainer const& shards, ice::ShardContainer& out_shards - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; void collect_pending_state( ice::Shard trigger_shard, diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx index e0d2dfc5..bc7daf9a 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "ice_gfx_graph.hxx" @@ -90,7 +90,7 @@ namespace ice::gfx { if (ice::hashmap::has(_objects, ice::hash(pass.name)) == false) { - ice::ucount res_count = 0; + ice::u32 res_count = 0; for (ice::gfx::GfxGraphStage const& stage : pass.stages) { res_count += ice::count(stage.depth_stencil) + ice::count(stage.inputs) + ice::count(stage.outputs); @@ -130,7 +130,7 @@ namespace ice::gfx ice::vec2u extent = swapchain.extent(); - ice::ucount const count_images = ice::count(resources); + ice::u32 const count_images = ice::count(resources); ice::array::clear(out_images); ice::array::reserve(out_images, count_images); @@ -373,10 +373,10 @@ namespace ice::gfx return false; } - ice::ucount const fb_idx = _context.next_frame(); + ice::u32 const fb_idx = _context.next_frame(); // TODO: Can we do this differently? - if (fb_idx == ice::ucount_max) + if (fb_idx == ice::u32_max) { return false; } diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx index 9d9e4187..158f6671 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "ice_gfx_graph_runtime.hxx" @@ -381,9 +381,9 @@ namespace ice::gfx ice::Array barriers{ alloc }; postprocess_snapshots(snapshots, barriers); - ice::ucount max_images = 0; - ice::ucount current_images = 0; - ice::ucount removed_images = 0; + ice::u32 max_images = 0; + ice::u32 current_images = 0; + ice::u32 removed_images = 0; for (GfxGraphSnapshot const snapshot : snapshots) { if (snapshot.event & GfxSnapshotEvent::MaskPass) diff --git a/source/code/iceshard/engine/private/world_trait.cxx b/source/code/iceshard/engine/private/world_trait.cxx index d448cacc..f63b315c 100644 --- a/source/code/iceshard/engine/private/world_trait.cxx +++ b/source/code/iceshard/engine/private/world_trait.cxx @@ -44,7 +44,7 @@ namespace ice void Trait::send(ice::ShardID shardid, ice::String value, SendMode mode) noexcept { - this->send(shardid | ice::string::begin(value), mode); + this->send(shardid | value.begin(), mode); } void Trait::send(ice::ShardID shardid, ice::Asset asset, SendMode mode) noexcept diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx index eefecbd8..5b1a4a53 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -117,13 +117,13 @@ namespace ice::ecs::detail return result; } - constexpr auto calculate_entity_count_for_space(ice::ecs::detail::ArchetypeInstanceInfo const& arch, ice::usize space) noexcept -> ice::ucount + constexpr auto calculate_entity_count_for_space(ice::ecs::detail::ArchetypeInstanceInfo const& arch, ice::usize space) noexcept -> ice::u32 { ice::u32 const component_size_sum = ice::accumulate(arch.component_sizes, 0); ice::u32 const component_alignment_sum = ice::accumulate(arch.component_alignments, 0); ice::usize const available_block_size = { ice::usize::subtract(space, arch.data_block_filter.data_size).value - component_alignment_sum }; - return ice::ucount(available_block_size.value) / component_size_sum; + return ice::u32(available_block_size.value) / component_size_sum; } } // namespace ice::ecs diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_data_block.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_data_block.hxx index 32590bf7..c8e1a853 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_data_block.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_data_block.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -13,12 +13,12 @@ namespace ice::ecs::detail //! \brief Maximum number of entities this specific data-block can hold. This value can change depending on the block size. //! //! \note It is important to remember that a block is not able to hold more than `ice::ecs::Constant_MaxBlockEntityIndex` entities. - ice::ucount block_entity_count_max = 0; + ice::u32 block_entity_count_max = 0; //! \brief Current number of entities in the block. //! //! \note The `EntityStorage` ensures that all entities are always stored one after another inside blocks without empty data locations. - ice::ucount block_entity_count = 0; + ice::u32 block_entity_count = 0; //! \brief Size of the available data to be used for entity components. ice::usize block_data_size = 0_B; diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx index 3dcb789c..7397dcbf 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -82,7 +82,7 @@ namespace ice::ecs ice::ecs::EntityOperations& operations, ice::ecs::Archetype archetype, ice::ecs::EntityIndex& index, - ice::ucount entity_count + ice::u32 entity_count ) noexcept; ~OperationBuilder() noexcept; @@ -241,7 +241,7 @@ namespace ice::ecs ice::ecs::EntityOperations& operations, ice::ecs::Archetype archetype, ice::ecs::EntityIndex& index, - ice::ucount entity_count + ice::u32 entity_count ) noexcept : operations{ operations } , archetype{ archetype } @@ -270,7 +270,7 @@ namespace ice::ecs inline auto EntityOperations::create( ice::ecs::concepts::ArchetypeRef auto ref, - ice::ucount count + ice::u32 count ) noexcept -> ice::ecs::OperationBuilder { return OperationBuilder{ *this, this->get_archetype(ref), _entities, count }; @@ -335,8 +335,8 @@ namespace ice::ecs .offsets = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_alignments), 1) }; - ice::ucount const entity_count = mode == 2 ? index_create_count : ice::count(entities); - ice::ucount constexpr component_count = sizeof...(Components); + ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); + ice::u32 constexpr component_count = sizeof...(Components); ice::meminfo additional_data_size = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; additional_data_size += ice::meminfo_of * entity_count; @@ -444,7 +444,7 @@ namespace ice::ecs operation->entities = entities_ptr; operation->entity_count = entity_count; operation->component_data = component_info_ptr; - operation->component_data_size = ice::ucount(ice::ptr_distance(component_info_ptr, component_info_ptr).value); + operation->component_data_size = ice::u32(ice::ptr_distance(component_info_ptr, component_info_ptr).value); operation->filter_data = filter_ptr; if (mode == 2) @@ -477,8 +477,8 @@ namespace ice::ecs .offsets = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_alignments), 1) }; - ice::ucount const entity_count = mode == 2 ? index_create_count : ice::count(entities); - ice::ucount constexpr component_count = sizeof...(Components); + ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); + ice::u32 constexpr component_count = sizeof...(Components); ice::meminfo additional_data_size = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; additional_data_size += ice::meminfo_of * entity_count; @@ -585,7 +585,7 @@ namespace ice::ecs operation->entities = entities_ptr; operation->entity_count = entity_count; operation->component_data = component_info_ptr; - operation->component_data_size = ice::ucount(ice::ptr_distance(component_info_ptr, component_info_ptr).value); + operation->component_data_size = ice::u32(ice::ptr_distance(component_info_ptr, component_info_ptr).value); operation->filter_data = filter_ptr; if (mode == 2) diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx index 35b8fd28..75182aa0 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -52,7 +52,7 @@ namespace ice::ecs auto query_data_slots( ice::Span requested, ice::Span out_data_slots - ) const noexcept -> ice::ucount override; + ) const noexcept -> ice::u32 override; bool query_archetype_block( ice::ecs::Archetype archetype, diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_awaitable.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_awaitable.hxx index fae9c6f0..6d7f95b7 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_awaitable.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_awaitable.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -74,7 +74,7 @@ namespace ice::ecs inline auto entity_count( ice::ecs::QueryObject const& query, ice::ecs::detail::DataBlockFilter::QueryFilter filter - ) noexcept -> ice::ucount; + ) noexcept -> ice::u32; } // namespace query diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_definition.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_definition.hxx index 5298d1bc..681eb60f 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_definition.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_definition.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -15,7 +15,7 @@ namespace ice::ecs template struct QueryDefinition { - static constexpr ice::ucount Constant_ComponentCount = sizeof...(QueryComponents); + static constexpr ice::u32 Constant_ComponentCount = sizeof...(QueryComponents); static constexpr ice::StaticArray Constant_Requirements = ice::ecs::detail::QueryRequirements::Constant_Requirements; @@ -51,7 +51,7 @@ namespace ice::ecs template struct QueryTagsDefinition { - static constexpr ice::ucount Constant_TagCount = sizeof...(Tags); + static constexpr ice::u32 Constant_TagCount = sizeof...(Tags); static constexpr ice::StaticArray Constant_Tags = ice::ecs::detail::QueryTags::Constant_Tags; }; diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx index 07516903..e1b82b4b 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -121,7 +121,7 @@ namespace ice::ecs::detail using QueryEntityIteratorSignature = void (typename QueryIteratorArgument::EntityIteratorArg...); template - using QueryBlockTupleResult = std::tuple::BlockIteratorArg...>; + using QueryBlockTupleResult = std::tuple::BlockIteratorArg...>; template using QueryEntityTupleResult = std::tuple::BlockIteratorArg...>; diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx index 271b3ca2..0fb5b796 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -16,7 +16,7 @@ namespace ice::ecs { public: template - inline auto entity_count(this Self&& self) noexcept -> ice::ucount; + inline auto entity_count(this Self&& self) noexcept -> ice::u32; template inline auto for_entity(this Self&& self, ice::ecs::Entity entity) noexcept -> typename ice::clear_type_t::ResultType; @@ -32,7 +32,7 @@ namespace ice::ecs public: template - inline auto block_count(this Self&& self) noexcept -> ice::ucount; + inline auto block_count(this Self&& self) noexcept -> ice::u32; template inline auto for_each_block(this Self&& self) noexcept -> ice::Generator::BlockResultType>; @@ -85,7 +85,7 @@ namespace ice::ecs RefType const& ref = std::get(in_tuple); - static constexpr ice::ucount component_count = sizeof...(SubQueryTypes); + static constexpr ice::u32 component_count = sizeof...(SubQueryTypes); ice::ecs::EntityDataSlot const slotinfo = provider.query_data_slot(ref->entity); ice::u32 arch_idx = 0; @@ -172,7 +172,7 @@ namespace ice::ecs using QueryTypeTuple = std::tuple; using SubQueryTypeTuple = std::tuple; - static constexpr ice::ucount component_count = sizeof...(SubQueryTypes); + static constexpr ice::u32 component_count = sizeof...(SubQueryTypes); void* helper_pointer_array[component_count]{ nullptr }; auto const invoke_for_entity = [&]( @@ -271,12 +271,12 @@ namespace ice::ecs inline auto entity_count( ice::ecs::QueryObject const& query, ice::ecs::detail::DataBlockFilter::QueryFilter filter - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { // On a query with multiple parts we only want to check the blocks of the main part. ice::Span const blocks_to_check = ice::array::slice(query.archetype_data_blocks, 0, query.archetype_count_for_part[0]); - ice::ucount result = 0; + ice::u32 result = 0; for (ice::ecs::detail::DataBlock const* const head_block : blocks_to_check) { // We don't want to count the head-block since it never contains actual entity data. @@ -296,12 +296,12 @@ namespace ice::ecs template inline auto block_count( ice::ecs::QueryObject const& query - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { // On a query with multiple parts we only want to check the blocks of the main part. ice::Span const blocks_to_check = ice::array::slice(query.archetype_data_blocks, 0, query.archetype_count_for_part[0]); - ice::ucount result = 0; + ice::u32 result = 0; for (ice::ecs::detail::DataBlock const* const head_block : blocks_to_check) { // We don't want to count the head-block since it never contains actual entity data. @@ -322,7 +322,7 @@ namespace ice::ecs bool allow_failure ) noexcept -> typename ice::ecs::QueryObject::ResultType { - static constexpr ice::ucount component_count = MainPart::ComponentCount; + static constexpr ice::u32 component_count = MainPart::ComponentCount; ice::ecs::EntityDataSlot const slotinfo = query.provider->query_data_slot(entity); ice::u32 arch_idx = 0; @@ -402,7 +402,7 @@ namespace ice::ecs QueryObjectOwner ) noexcept -> ice::Generator::ResultType> { - static constexpr ice::ucount component_count = MainPart::ComponentCount; + static constexpr ice::u32 component_count = MainPart::ComponentCount; void* helper_pointer_array[component_count]{ nullptr }; @@ -437,7 +437,7 @@ namespace ice::ecs } } - ice::ucount entity_idx = 0; + ice::u32 entity_idx = 0; while (entity_idx < block->block_entity_count) { if constexpr (sizeof...(RefParts) == 0) @@ -472,7 +472,7 @@ namespace ice::ecs ) noexcept { using Definition = typename ice::ecs::QueryObject::Definition; - static constexpr ice::ucount component_count = MainPart::ComponentCount; + static constexpr ice::u32 component_count = MainPart::ComponentCount; void* helper_pointer_array[component_count]{ nullptr }; @@ -546,7 +546,7 @@ namespace ice::ecs { static_assert(sizeof...(RefParts) == 0, "'for_each_block' only supports basic queries with no entity references!"); - static constexpr ice::ucount component_count = MainPart::ComponentCount; + static constexpr ice::u32 component_count = MainPart::ComponentCount; void* helper_pointer_array[component_count]{ nullptr }; @@ -595,7 +595,7 @@ namespace ice::ecs ) noexcept { static_assert(sizeof...(RefParts) == 0, "'for_each_block' only supports basic queries with no entity references!"); - static constexpr ice::ucount component_count = MainPart::ComponentCount; + static constexpr ice::u32 component_count = MainPart::ComponentCount; void* helper_pointer_array[component_count]{ nullptr }; @@ -643,13 +643,13 @@ namespace ice::ecs } // namespace query template - inline auto TraitQueryOperations::entity_count(this Self&& self) noexcept -> ice::ucount + inline auto TraitQueryOperations::entity_count(this Self&& self) noexcept -> ice::u32 { return ice::ecs::query::entity_count(self.query_object(), self.filter_object()); } template - inline auto TraitQueryOperations::block_count(this Self&& self) noexcept -> ice::ucount + inline auto TraitQueryOperations::block_count(this Self&& self) noexcept -> ice::u32 { return ice::ecs::query::block_count(self.query_object()); } diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx index f5cef37d..51dda7e5 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -37,7 +37,7 @@ namespace ice::ecs virtual auto query_data_slots( ice::Span requested, ice::Span out_data_slots - ) const noexcept -> ice::ucount = 0; + ) const noexcept -> ice::u32 = 0; virtual bool query_archetype_block( ice::ecs::Archetype archetype, diff --git a/source/code/iceshard/engine/public/ice/engine_data_storage.hxx b/source/code/iceshard/engine/public/ice/engine_data_storage.hxx index dd5e1a7b..cb8b674f 100644 --- a/source/code/iceshard/engine/public/ice/engine_data_storage.hxx +++ b/source/code/iceshard/engine/public/ice/engine_data_storage.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -25,13 +25,13 @@ namespace ice inline auto store(ice::StringID_Arg name) noexcept -> T&; template requires (std::is_trivially_destructible_v>) - inline auto store(ice::StringID_Arg name, ice::ucount size) noexcept -> ice::Span; + inline auto store(ice::StringID_Arg name, ice::u32 size) noexcept -> ice::Span; template requires (std::is_trivially_destructible_v) inline auto read_or_store(ice::StringID_Arg name) noexcept -> T&; template requires (std::is_trivially_destructible_v>) - inline auto read_or_store(ice::StringID_Arg name, ice::ucount size) noexcept -> ice::Span; + inline auto read_or_store(ice::StringID_Arg name, ice::u32 size) noexcept -> ice::Span; template inline auto read(ice::StringID_Arg name) noexcept -> T&; @@ -49,7 +49,7 @@ namespace ice } template requires (std::is_trivially_destructible_v>) - inline auto DataStorage::store(ice::StringID_Arg name, ice::ucount size) noexcept -> ice::Span + inline auto DataStorage::store(ice::StringID_Arg name, ice::u32 size) noexcept -> ice::Span { ice::meminfo minfo = ice::meminfo_of>; ice::usize const offset = minfo += ice::meminfo_of * size; @@ -70,7 +70,7 @@ namespace ice } template requires (std::is_trivially_destructible_v>) - inline auto DataStorage::read_or_store(ice::StringID_Arg name, ice::ucount size) noexcept -> ice::Span + inline auto DataStorage::read_or_store(ice::StringID_Arg name, ice::u32 size) noexcept -> ice::Span { if (this->has(name)) { diff --git a/source/code/iceshard/engine/public/ice/engine_state_tracker.hxx b/source/code/iceshard/engine/public/ice/engine_state_tracker.hxx index 4a2516bc..1ca17154 100644 --- a/source/code/iceshard/engine/public/ice/engine_state_tracker.hxx +++ b/source/code/iceshard/engine/public/ice/engine_state_tracker.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -40,7 +40,7 @@ namespace ice virtual auto update_states( ice::ShardContainer const& shards, ice::ShardContainer& out_shards - ) noexcept -> ice::ucount = 0; + ) noexcept -> ice::u32 = 0; }; auto create_state_tracker( diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx index 007cae75..175ab3e4 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx @@ -51,7 +51,7 @@ namespace ice::gfx ice::String const preview = selected < 0 ? "" : ice::stringid_hint(images[selected].asset.name()); - if (ImGui::BeginCombo("Loaded Image", ice::string::begin(preview))) + if (ImGui::BeginCombo("Loaded Image", preview.begin())) { if (ImGui::Selectable("##empty")) { diff --git a/source/code/iceshard/iceshard/private/iceshard_frame.cxx b/source/code/iceshard/iceshard/private/iceshard_frame.cxx index b22eff31..5cd61750 100644 --- a/source/code/iceshard/iceshard/private/iceshard_frame.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_frame.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_frame.hxx" @@ -82,12 +82,12 @@ namespace ice } } - auto IceshardEngineFrame::execute_tasks() noexcept -> ice::ucount + auto IceshardEngineFrame::execute_tasks() noexcept -> ice::u32 { - ice::ucount total_count = 0; + ice::u32 total_count = 0; for (TaskGroup& group : _task_groups) { - ice::ucount const current_count = ice::count(group.tasks); + ice::u32 const current_count = ice::count(group.tasks); // Only reset the barrier if we actual have tasks to execute. if (current_count > 0) @@ -104,12 +104,12 @@ namespace ice return total_count; } - auto IceshardEngineFrame::running_tasks() const noexcept -> ice::ucount + auto IceshardEngineFrame::running_tasks() const noexcept -> ice::u32 { - ice::ucount result = 0; + ice::u32 result = 0; for (TaskGroup const& group : _task_groups) { - result += ice::ucount(group.barrier->is_set() == false); + result += ice::u32(group.barrier->is_set() == false); } return result; } diff --git a/source/code/iceshard/iceshard/private/iceshard_frame.hxx b/source/code/iceshard/iceshard/private/iceshard_frame.hxx index aa1fbf48..38a3a304 100644 --- a/source/code/iceshard/iceshard/private/iceshard_frame.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_frame.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -37,8 +37,8 @@ namespace ice auto create_tasks(ice::u32 count, ice::ShardID id) noexcept -> ice::Span> override; auto await_tasks_scheduled_on(ice::TaskScheduler& scheduler, ice::TaskScheduler& resumer) noexcept -> ice::Task<> override; - auto execute_tasks() noexcept -> ice::ucount override; - auto running_tasks() const noexcept -> ice::ucount override; + auto execute_tasks() noexcept -> ice::u32 override; + auto running_tasks() const noexcept -> ice::u32 override; void wait_tasks() noexcept override; auto extract_tasks() noexcept -> ice::Array> override; diff --git a/source/code/iceshard/iceshard/private/iceshard_runner.hxx b/source/code/iceshard/iceshard/private/iceshard_runner.hxx index 37ad19dc..cd0eedb2 100644 --- a/source/code/iceshard/iceshard/private/iceshard_runner.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_runner.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -111,7 +111,7 @@ namespace ice void execute_all() noexcept { - ice::ucount const num_tasks = ice::array::count(_pending_tasks); + ice::u32 const num_tasks = ice::array::count(_pending_tasks); _running_tasks.fetch_add(num_tasks, std::memory_order_relaxed); for (ice::Task<>& pending_task : _pending_tasks) diff --git a/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx b/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx index ab9a24fa..7ff033cf 100644 --- a/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -34,7 +34,7 @@ namespace ice private: ice::Allocator& _allocator; - ice::ucount _task_count; + ice::u32 _task_count; ice::Array, ice::ContainerLogic::Complex> _tasks; ice::ManualResetBarrier _sync_sem; }; diff --git a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx index 0a20c8bd..8a1538a6 100644 --- a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_world.hxx" @@ -46,7 +46,7 @@ namespace ice void IceshardTraitContext::send(ice::detail::TraitEvent event) noexcept { - ice::ucount idx = 0; + ice::u32 idx = 0; if (event.mode == TraitSendMode::Replace && ice::search(ice::Span{ _events }, event, detail::is_same_event, idx)) { _events[idx] = event; diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx index 6bc0870c..e23834af 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_world_manager.hxx" @@ -81,10 +81,10 @@ namespace ice IceshardWorldManager::~IceshardWorldManager() noexcept { - ice::ucount active_worlds = 0; + ice::u32 active_worlds = 0; for (Entry const& entry : _worlds) { - active_worlds += ice::ucount(entry.is_active); + active_worlds += ice::u32(entry.is_active); } ICE_ASSERT( diff --git a/source/code/modules/iceshard_pipelines/private/asset_font.cxx b/source/code/modules/iceshard_pipelines/private/asset_font.cxx index ab7f3d05..82abfc0f 100644 --- a/source/code/modules/iceshard_pipelines/private/asset_font.cxx +++ b/source/code/modules/iceshard_pipelines/private/asset_font.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_font.hxx" @@ -57,10 +57,10 @@ namespace ice gfx_font->atlases = { gfx_atlas, 1 }; gfx_font->ranges = { gfx_glyph_range, 1 }; - gfx_font->glyphs = { font_glyphs, ice::ucount(glyphs.size()) }; + gfx_font->glyphs = { font_glyphs, ice::u32(glyphs.size()) }; gfx_glyph_range->type = ice::GlyphRangeType::Explicit; - gfx_glyph_range->glyph_count = ice::ucount(glyphs.size()); + gfx_glyph_range->glyph_count = ice::u32(glyphs.size()); gfx_glyph_range->glyph_index = 0; gfx_glyph_range->glyph_atlas = 0; diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx index bc6df30f..35b6504d 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -56,10 +56,10 @@ namespace ice ice::UIRawInfo const& raw_info ) noexcept -> ice::UISizeInfo { - ice::u32 const count_elements = ice::count(raw_info.elements); - ice::u32 const count_shards = ice::count(raw_info.shards); - ice::u32 const count_resources = ice::count(raw_info.resources); - ice::u32 const count_styles = ice::count(raw_info.styles); + ice::u32 const count_elements = u32(ice::count(raw_info.elements)); + ice::u32 const count_shards = u32(ice::count(raw_info.shards)); + ice::u32 const count_resources = u32(ice::count(raw_info.resources)); + ice::u32 const count_styles = u32(ice::count(raw_info.styles)); ice::u32 count_fonts = 0; ice::u32 count_actions = 0; @@ -81,7 +81,7 @@ namespace ice if (button_data->text.data_type == ice::ui::DataSource::ValueConstant) { count_constants += 1; - additional_data_size += ice::string::size(button_data->text.data_source); + additional_data_size += button_data->text.data_source.size().u32(); } } else if (element.type == ElementType::Label) @@ -90,7 +90,7 @@ namespace ice if (label_data->text.data_type == ice::ui::DataSource::ValueConstant) { count_constants += 1; - additional_data_size += ice::string::size(label_data->text.data_source); + additional_data_size += label_data->text.data_source.size().u32(); } } } @@ -100,7 +100,7 @@ namespace ice if (resource.type == ice::ui::ResourceType::Font) { count_fonts += 1; - additional_data_size += ice::string::size(resource.font_data.font_name); + additional_data_size += resource.font_data.font_name.size().u32(); } } @@ -191,17 +191,17 @@ namespace ice { out_ref.source_i = constants.idx; - ice::ucount const text_size = ice::string::size(raw_data_ref.data_source); + ice::ncount const text_size = raw_data_ref.data_source.size(); constants.data[constants.idx].offset = constants.data_storage_offset; - constants.data[constants.idx].size = text_size; + constants.data[constants.idx].size = text_size.u32(); ice::memcpy( constants.data_storage, - ice::string::begin(raw_data_ref.data_source), - text_size + raw_data_ref.data_source.begin(), + text_size.bytes() ); constants.data_storage = ice::ptr_add(constants.data_storage, { text_size }); - constants.data_storage_offset += text_size; + constants.data_storage_offset += text_size.u32(); constants.idx += 1; } else if (out_ref.source == DataSource::ValueResource) @@ -223,7 +223,7 @@ namespace ice static auto store_span_info = [base_ptr = result.location](auto& span_value) noexcept { void* span_address = std::addressof(span_value); - ice::u32 const span_size = ice::count(span_value); + ice::u32 const span_size = ice::u32(ice::count(span_value)); ice::u32 const span_offset = ice::u32(ice::ptr_distance(base_ptr, ice::span::data(span_value)).value); ice::u32* values = reinterpret_cast(span_address); @@ -279,8 +279,8 @@ namespace ice auto const find_font_idx = [&raw_info](ice::String font_name) noexcept -> ice::u16 { ice::u16 font_idx = 0; - ice::u32 idx = 0; - ice::u32 const count = ice::count(raw_info.resources); + ice::u64 idx = 0; + ice::u64 const count = ice::count(raw_info.resources); for (; idx < count; ++idx) { if (raw_info.resources[idx].type == ResourceType::Font) @@ -298,7 +298,7 @@ namespace ice auto const find_shard_idx = [&raw_info](ice::String resource_name) noexcept -> ice::u16 { ice::u16 idx = 0; - ice::u32 const count = ice::count(raw_info.shards); + ice::u64 const count = ice::count(raw_info.shards); for (; idx < count; ++idx) { if (raw_info.shards[idx].ui_name == resource_name) @@ -424,7 +424,7 @@ namespace ice for (ice::RawResource const& resource : raw_info.resources) { // TODO: Force it to ? - resources[idx_res].id = ice::stringid(std::string_view{ resource.ui_name._data, resource.ui_name._size }); + resources[idx_res].id = ice::stringid(resource.ui_name); resources[idx_res].type = resource.type; resources[idx_res].type_data = resource.type_data; @@ -433,9 +433,9 @@ namespace ice fonts[idx_font].resource_i = idx_res; fonts[idx_font].font_size = resource.font_data.font_size; fonts[idx_font].font_name_offset = additional_data_offset; - fonts[idx_font].font_name_size = ice::string::size(resource.font_data.font_name); + fonts[idx_font].font_name_size = resource.font_data.font_name.size().u32(); - ice::memcpy(additional_data, ice::string::begin(resource.font_data.font_name), fonts[idx_font].font_name_size); + ice::memcpy(additional_data, resource.font_data.font_name.begin(), fonts[idx_font].font_name_size); additional_data = ice::ptr_add(additional_data, { fonts[idx_font].font_name_size }); additional_data_offset += fonts[idx_font].font_name_size; @@ -447,7 +447,7 @@ namespace ice } void* aligned_ptr = ice::align_to(additional_data, ice::ualign::b_4).value; - additional_data_offset += ice::ucount(ice::ptr_distance(additional_data, aligned_ptr).value); + additional_data_offset += ice::u32(ice::ptr_distance(additional_data, aligned_ptr).value); additional_data = aligned_ptr; ice::u32 idx_style = 0; diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx index 8c57ea9a..2277aa04 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "ip_ui_oven_elements.hxx" @@ -15,27 +15,27 @@ namespace ice bool trim(ice::String& inout_str, char character) noexcept { - ice::ucount const left_bracket = ice::string::find_first_not_of(inout_str, character); - ice::ucount const right_bracket = ice::string::find_last_not_of(inout_str, character); - if (left_bracket == ice::String_NPos && right_bracket == ice::String_NPos) + ice::nindex const left_bracket = inout_str.find_first_not_of(character); + ice::nindex const right_bracket = inout_str.find_last_not_of(character); + if (left_bracket == ice::none_index && right_bracket == ice::none_index) { return false; } - inout_str = ice::string::substr(inout_str, left_bracket, (right_bracket - left_bracket) + 1); + inout_str = inout_str.substr(left_bracket, (right_bracket - left_bracket) + 1); return true; } bool remove_brackets(ice::String& inout_str) noexcept { - ice::ucount const left_bracket = ice::string::find_first_of(inout_str, '{'); - ice::ucount const right_bracket = ice::string::find_last_of(inout_str, '}'); - if (left_bracket == ice::String_NPos || right_bracket == ice::String_NPos) + ice::nindex const left_bracket = inout_str.find_first_of('{'); + ice::nindex const right_bracket = inout_str.find_last_of('}'); + if (left_bracket == ice::none_index || right_bracket == ice::none_index) { return false; } - inout_str = ice::string::substr(inout_str, left_bracket + 1, (right_bracket - left_bracket) - 1); + inout_str = inout_str.substr(left_bracket + 1, (right_bracket - left_bracket) - 1); return true; } @@ -44,12 +44,12 @@ namespace ice ice::RawAction& out_action ) noexcept { - ice::ucount const type_end = ice::string::find_first_of(inout_str, ' '); + ice::nindex const type_end = inout_str.find_first_of(' '); bool result = false; - if (type_end != ice::String_NPos) + if (type_end != ice::none_index) { - ice::String const action_type = ice::string::substr(inout_str, 0, type_end); + ice::String const action_type = inout_str.substr(0, type_end); if (action_type == RawAction::Constant_ActionType_Shard) { out_action.action_type = ice::ui::ActionType::Shard; @@ -67,14 +67,14 @@ namespace ice result = out_action.action_type != ice::ui::ActionType::None; if (result) { - inout_str = ice::string::substr(inout_str, type_end + 1); + inout_str = inout_str.substr(type_end + 1); - ice::ucount const action_value_end = ice::string::find_first_of(inout_str, ",} "_str); - out_action.action_value = ice::string::substr(inout_str, 0, action_value_end); - result = ice::string::empty(out_action.action_value) == false; + ice::nindex const action_value_end = inout_str.find_first_of(",} "_str); + out_action.action_value = inout_str.substr(0, action_value_end); + result = out_action.action_value.not_empty(); // Move to the next expected token. - inout_str = ice::string::substr(inout_str, action_value_end + 1); + inout_str = inout_str.substr(action_value_end + 1); } } return result; @@ -87,18 +87,18 @@ namespace ice if (remove_brackets(str)) { - ice::ucount const type_end = ice::string::find_first_of(str, ' '); - ice::String const data_type = ice::string::substr(str, 0, type_end); + ice::nindex const type_end = str.find_first_of(' '); + ice::String const data_type = str.substr(0, type_end); if (data_type == RawAction::Constant_ActionDataType_Resource) { out_action.data_type = ice::ui::DataSource::ValueResource; - out_action.data_source = ice::string::substr(str, type_end + 1); + out_action.data_source = str.substr(type_end + 1); } else if (data_type == RawAction::Constant_ActionDataType_Property) { out_action.data_type = ice::ui::DataSource::ValueProperty; - out_action.data_source = ice::string::substr(str, type_end + 1); + out_action.data_source = str.substr(type_end + 1); } ice::trim(out_action.data_source, ' '); } @@ -110,15 +110,15 @@ namespace ice out_action.data.data_source = {}; bool result = true; - ice::ucount const data_start = ice::string::find_first_of(inout_str, '='); - if (data_start != ice::String_NPos) + ice::nindex const data_start = inout_str.find_first_of('='); + if (data_start != ice::none_index) { - ice::ucount const data_arg_start = ice::string::find_last_of(inout_str, " ,"_str, data_start); + ice::nindex const data_arg_start = inout_str.find_last_of(" ,"_str, data_start); [[maybe_unused]] - ice::String const data_arg = ice::string::substr(inout_str, data_arg_start + 1, (data_start - data_arg_start) - 1); + ice::String const data_arg = inout_str.substr(data_arg_start + 1, (data_start - data_arg_start) - 1); - inout_str = ice::string::substr(inout_str, data_start + 1); + inout_str = inout_str.substr(data_start + 1); if (remove_brackets(inout_str)) { ICE_ASSERT(false, "TODO!"); // Was here before memsys refactor. Needs a ticket! @@ -249,7 +249,7 @@ namespace ice ICE_ASSERT( action_parse_result != false, "Failed to parse action value '{}'", - ice::String{ attribute->value(), ice::ucount(attribute->value_size()) } + ice::String{ attribute->value(), attribute->value_size() } ); } diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx index cea1a3c2..b5a5bad3 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "ip_ui_oven_page.hxx" @@ -47,7 +47,7 @@ namespace ice using ice::ui::ElementState; ElementState result = ElementState::None; - if (ice::string::empty(element_state)) + if (element_state.is_empty()) { result |= ElementState::Any; } @@ -187,13 +187,13 @@ namespace ice { res.type = ResourceType::String; } - else if (ice::string::starts_with(type_str, Constant_UIResourceType_String)) + else if (type_str.starts_with(Constant_UIResourceType_String)) { - ice::ucount const arrval_beg = ice::string::find_first_of(type_str, '['); - ice::ucount const arrval_end = ice::string::find_last_of(type_str, ']'); + ice::nindex const arrval_beg = type_str.find_first_of('['); + ice::nindex const arrval_end = type_str.find_last_of(']'); if (arrval_beg < arrval_end) { - ice::String arrval_str = ice::string::substr(type_str, arrval_beg + 1, (arrval_end - arrval_beg) - 1); + ice::String arrval_str = type_str.substr(arrval_beg + 1, (arrval_end - arrval_beg) - 1); if (ice::from_chars(arrval_str, res.type_data)) { res.type = ResourceType::String; @@ -257,7 +257,7 @@ namespace ice ice::RawShard { .ui_name = ice::xml_value(uiref), - .shard_name = ice::shardid(ice::String{ attr_name->value(), ice::ucount(attr_name->value_size()) }) + .shard_name = ice::shardid(ice::String{ attr_name->value(), attr_name->value_size() }) } ); } diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx index aabe7666..83ce97e1 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "ip_ui_oven_utils.hxx" @@ -16,31 +16,20 @@ namespace ice ice::String name ) noexcept -> rapidxml_ns::xml_node const* { - if (ice::string::any(ns)) + if (ns.not_empty()) { - if (ice::string::any(name)) + if (name.not_empty()) { - return parent->first_node_ns( - ice::string::begin(ns), - ice::string::size(ns), - ice::string::begin(name), - ice::string::size(name) - ); + return parent->first_node_ns(ns.begin(), ns.size(), name.begin(), name.size()); } else { - return parent->first_node_ns( - ice::string::begin(ns), - ice::string::size(ns) - ); + return parent->first_node_ns(ns.begin(), ns.size()); } } else { - return parent->first_node( - ice::string::begin(name), - ice::string::size(name) - ); + return parent->first_node(name.begin(), name.size()); } } @@ -50,30 +39,30 @@ namespace ice ice::String name ) noexcept -> rapidxml_ns::xml_node const* { - if (ice::string::any(ns)) + if (ns.not_empty()) { - if (ice::string::any(name)) + if (name.not_empty()) { return parent->next_sibling_ns( - ice::string::begin(ns), - ice::string::size(ns), - ice::string::begin(name), - ice::string::size(name) + ns.begin(), + ns.size(), + name.begin(), + name.size() ); } else { return parent->next_sibling_ns( - ice::string::begin(ns), - ice::string::size(ns) + ns.begin(), + ns.size() ); } } else { return parent->next_sibling( - ice::string::begin(name), - ice::string::size(name) + name.begin(), + name.size() ); } } @@ -84,8 +73,8 @@ namespace ice ) noexcept -> rapidxml_ns::xml_attribute const* { return node->first_attribute( - ice::string::begin(name), - ice::string::size(name) + name.begin(), + name.size() ); } @@ -95,8 +84,8 @@ namespace ice ) noexcept -> rapidxml_ns::xml_attribute const* { return attrib->next_attribute( - ice::string::begin(name), - ice::string::size(name) + name.begin(), + name.size() ); } @@ -104,35 +93,35 @@ namespace ice rapidxml_ns::xml_node const* node ) noexcept -> ice::String { - return { node->local_name(), ice::ucount(node->local_name_size()) }; + return { node->local_name(), node->local_name_size() }; } auto xml_name( rapidxml_ns::xml_attribute const* attrib ) noexcept -> ice::String { - return { attrib->name(), ice::ucount(attrib->name_size()) }; + return { attrib->name(), attrib->name_size() }; } auto xml_value( rapidxml_ns::xml_node const* node ) noexcept -> ice::String { - return { node->value(), ice::ucount(node->value_size()) }; + return { node->value(), node->value_size() }; } auto xml_value( rapidxml_ns::xml_attribute const* attrib ) noexcept -> ice::String { - return attrib == nullptr ? "" : ice::String{ attrib->value(), ice::ucount(attrib->value_size()) }; + return attrib == nullptr ? "" : ice::String{ attrib->value(), attrib->value_size() }; } auto xml_value_noutf8( rapidxml_ns::xml_attribute const* attrib ) noexcept -> ice::String { - return attrib == nullptr ? "" : ice::String{ attrib->value(), ice::ucount(attrib->value_size()) }; + return attrib == nullptr ? "" : ice::String{ attrib->value(), attrib->value_size() }; } void parse_element_size( @@ -143,13 +132,13 @@ namespace ice { using ice::ui::ElementFlags; - ice::ucount const separator = ice::string::find_first_of(value, ','); + ice::nindex const separator = value.find_first_of(','); bool valid_values = true; - if (separator != ice::String_NPos) + if (separator != ice::none_index) { - ice::String left = ice::string::substr(value, 0, separator); - ice::String right = ice::string::substr(value, separator + 1); + ice::String left = value.substr(0, separator); + ice::String right = value.substr(separator + 1); if (ice::from_chars(left, left, out_size.width) == false) { @@ -200,7 +189,7 @@ namespace ice } ICE_ASSERT( - valid_values || ice::string::empty(value), + valid_values || value.is_empty(), "Invalid value in 'size' attribute! Valid values are: {}, {}, .", ice::Constant_UIAttributeKeyword_Auto, ice::Constant_UIAttributeKeyword_Stretch @@ -215,13 +204,13 @@ namespace ice { using ice::ui::ElementFlags; - ice::ucount const separator = ice::string::find_first_of(value, ','); + ice::nindex const separator = value.find_first_of(','); bool valid_values = true; - if (separator != ice::String_NPos) + if (separator != ice::none_index) { - ice::String left = ice::string::substr(value, 0, separator); - ice::String right = ice::string::substr(value, separator + 1); + ice::String left = value.substr(0, separator); + ice::String right = value.substr(separator + 1); if (ice::from_chars(left, left, out_pos.x) == false) { @@ -268,7 +257,7 @@ namespace ice } ICE_ASSERT( - valid_values || ice::string::empty(value), + valid_values || value.is_empty(), "Invalid value in 'position' attribute! Valid values are: {}, .", ice::Constant_UIAttributeKeyword_Auto ); @@ -282,17 +271,17 @@ namespace ice { using ice::ui::ElementFlags; - ice::ucount const sep1 = ice::string::find_first_of(value, ',', 0); - ice::ucount const sep2 = ice::string::find_first_of(value, ',', sep1 + 1); - ice::ucount const sep3 = ice::string::find_first_of(value, ',', sep2 + 1); + ice::nindex const sep1 = value.find_first_of(',', 0); + ice::nindex const sep2 = value.find_first_of(',', sep1 + 1); + ice::nindex const sep3 = value.find_first_of(',', sep2 + 1); bool valid_values = true; - if (sep3 != ice::String_NPos && sep2 != ice::String_NPos && sep1 != ice::String_NPos) + if (sep3 != ice::none_index && sep2 != ice::none_index && sep1 != ice::none_index) { - ice::String first = ice::string::substr(value, 0, sep1); - ice::String second = ice::string::substr(value, sep1 + 1, (sep2 - sep1) - 1); - ice::String third = ice::string::substr(value, sep2 + 1, (sep3 - sep2) - 1); - ice::String fourth = ice::string::substr(value, sep3 + 1); + ice::String first = value.substr(0, sep1); + ice::String second = value.substr(sep1 + 1, (sep2 - sep1) - 1); + ice::String third = value.substr(sep2 + 1, (sep3 - sep2) - 1); + ice::String fourth = value.substr(sep3 + 1); if (ice::from_chars(first, first, out_offset.left) == false) { @@ -339,10 +328,10 @@ namespace ice } } } - else if (sep1 != ice::String_NPos) + else if (sep1 != ice::none_index) { - ice::String first = ice::string::substr(value, 0, sep1); - ice::String second = ice::string::substr(value, sep1 + 1); + ice::String first = value.substr(0, sep1); + ice::String second = value.substr(sep1 + 1); if (ice::from_chars(first, first, out_offset.left) == false) { @@ -396,7 +385,7 @@ namespace ice } ICE_ASSERT( - valid_values || ice::string::empty(value), + valid_values || value.is_empty(), "Invalid value in 'padding' / 'margin' attribute! Valid values are: {}, .", ice::Constant_UIAttributeKeyword_Auto ); @@ -409,22 +398,22 @@ namespace ice { using ice::ui::ElementFlags; - ice::ucount const sep1 = ice::string::find_first_of(value, ',', 0); - ice::ucount const sep2 = ice::string::find_first_of(value, ',', sep1 + 1); + ice::nindex const sep1 = value.find_first_of(',', 0); + ice::nindex const sep2 = value.find_first_of(',', sep1 + 1); bool valid_values = false; - if (sep1 != ice::String_NPos && sep2 != ice::String_NPos) + if (sep1 != ice::none_index && sep2 != ice::none_index) { - ice::String first = ice::string::substr(value, 0, sep1); - ice::String second = ice::string::substr(value, sep1 + 1, (sep2 - sep1) - 1); - ice::String third = ice::string::substr(value, sep2 + 1); + ice::String first = value.substr(0, sep1); + ice::String second = value.substr(sep1 + 1, (sep2 - sep1) - 1); + ice::String third = value.substr(sep2 + 1); ice::from_chars(first, out_color.red); ice::from_chars(second, out_color.green); ice::from_chars(third, out_color.blue); valid_values = true; } - else if (sep1 == ice::String_NPos && sep2 == ice::String_NPos) + else if (sep1 == ice::none_index && sep2 == ice::none_index) { ice::from_chars(value, out_color.red); out_color.green = out_color.red; diff --git a/source/code/modules/imgui_module/private/imgui_system.cxx b/source/code/modules/imgui_module/private/imgui_system.cxx index d402b98d..740f7f59 100644 --- a/source/code/modules/imgui_module/private/imgui_system.cxx +++ b/source/code/modules/imgui_module/private/imgui_system.cxx @@ -7,7 +7,6 @@ #include #include -#include #include #if ISP_WINDOWS @@ -22,22 +21,22 @@ namespace ice::devui void build_mainmenu(ice::StaticString<32>& temp, ice::String path, ice::String name, bool& state) noexcept { - ice::ucount const separator_pos = ice::string::find_first_of(path, '/'); - if (separator_pos != ice::String_NPos) + ice::nindex const separator_pos = path.find_first_of('/'); + if (separator_pos != ice::none_index) { - temp = ice::string::substr(path, 0, separator_pos); + temp = path.substr(0, separator_pos); - if (ImGui::BeginMenu(ice::string::begin(temp))) + if (ImGui::BeginMenu(temp.begin())) { - build_mainmenu(temp, ice::string::substr(path, separator_pos + 1), name, state); + build_mainmenu(temp, path.substr(separator_pos + 1), name, state); ImGui::EndMenu(); } } else { - if (ImGui::BeginMenu(ice::string::begin(path))) + if (ImGui::BeginMenu(path.begin())) { - ImGui::MenuItem(ice::string::begin(name), nullptr, &state); + ImGui::MenuItem(name.begin(), nullptr, &state); ImGui::EndMenu(); } } @@ -48,20 +47,20 @@ namespace ice::devui void ImGuiWidgetFrame::mainmenu(ice::DevUIWidgetInfo const& widget, ice::DevUIWidgetState& state) noexcept { - ice::ucount const separator_pos = ice::string::find_first_of(widget.category, '/'); - if (separator_pos == ice::String_NPos) + ice::nindex const separator_pos = widget.category.find_first_of('/'); + if (separator_pos == ice::none_index) { - ImGui::MenuItem(ice::string::begin(widget.name), nullptr, &state.active); + ImGui::MenuItem(widget.name.begin(), nullptr, &state.active); return; } ice::StaticString<32> helper; - detail::build_mainmenu(helper, ice::string::substr(widget.category, separator_pos + 1), widget.name, state.active); + detail::build_mainmenu(helper, widget.category.substr(separator_pos + 1), widget.name, state.active); } bool ImGuiWidgetFrame::begin(ice::DevUIWidgetInfo const& widget, ice::DevUIWidgetState& state) noexcept { - return ImGui::Begin(ice::string::begin(widget.name), &state.active); + return ImGui::Begin(widget.name.begin(), &state.active); } void ImGuiWidgetFrame::end() noexcept @@ -144,12 +143,12 @@ namespace ice::devui { for (ice::String category : _menu_categories) { - if (ImGui::BeginMenu(ice::string::begin(category))) + if (ImGui::BeginMenu(category.begin())) { for (auto const& runtime : _widget_manager.widgets()) { ice::DevUIWidgetInfo const& info = runtime->widget->widget_info; - if (ice::string::starts_with(info.category, category) && runtime->widget->build_mainmenu(runtime->state)) + if (info.category.starts_with(category) && runtime->widget->build_mainmenu(runtime->state)) { _widget_frame.mainmenu(info, runtime->state); } diff --git a/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx b/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx index ee779b86..6e78c12c 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_allocator_tree.hxx" @@ -56,13 +56,13 @@ namespace ice::devui { if (ImGui::TableNextColumn()) { - ice::ucount const current_count = allocator.allocation_count(); + ice::u32 const current_count = allocator.allocation_count(); ImGui::Text(current_count == Allocator::CountNotTracked ? "- not tracked -" : "%d", current_count); } if (ImGui::TableNextColumn()) { - ice::ucount const total_count = allocator.allocation_total_count(); + ice::u32 const total_count = allocator.allocation_total_count(); ImGui::Text(total_count == Allocator::CountNotTracked ? "- not tracked -" : "%d", total_count); } diff --git a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx index c0d9499d..5ec6ee0b 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_devui_manager.hxx" @@ -11,7 +11,7 @@ namespace ImGui { void StringUnformatted(ice::String str) noexcept { - TextUnformatted(ice::string::begin(str), ice::string::end(str)); + TextUnformatted(str.begin(), str.end()); } } // namespace ImGui @@ -42,7 +42,7 @@ namespace ice::devui }; ice::DevUIWidgetState const* owner_state = nullptr; - ice::ucount owner_idx = 0; + ice::u32 owner_idx = 0; if (ice::search(ice::Span{ _widgets }, owning_widget, fn_compare, owner_idx)) { owner_state = ice::addressof(_widgets[owner_idx]->state); diff --git a/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx b/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx index c20e249a..58cf5201 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx @@ -10,7 +10,6 @@ #include #include #include -#include #include #include diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx b/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx index c7f8dd05..63e73506 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -48,7 +48,7 @@ namespace ice constexpr auto arc_str(arctic::String str) noexcept -> ice::String { - return ice::String{ str.data(), static_cast(str.size()) }; + return ice::String{ str.data(), static_cast(str.size()) }; } constexpr auto arc_hash(arctic::String str) noexcept -> ice::u64 diff --git a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx index ecf4d2f2..a10d2fd3 100644 --- a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "shader_tools_glsl.hxx" @@ -115,9 +115,9 @@ namespace ice syntax::Atom const& atom = node.to().data(); if (atom.is_parenthized) { - ice::string::push_back(result, "("); + result.push_back("("); generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, ")"); + result.push_back(")"); } else { @@ -130,7 +130,7 @@ namespace ice generate_expression(result, subs, func, arg, node.child()); if (node.sibling()) { - ice::string::push_back(result, ", "); + result.push_back(", "); } break; } @@ -156,12 +156,12 @@ namespace ice ice::string::push_format(result, "{}(", node.to().data().name.value); // Call children groups generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, ")"); + result.push_back(")"); break; case SyntaxEntity::E_IndexOperator: - ice::string::push_back(result, "["); + result.push_back("["); generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, "]"); + result.push_back("]"); break; default: break; @@ -191,7 +191,7 @@ namespace ice if (SyntaxNode assignnode = typenode.sibling(); assignnode) { - ice::string::push_back(result, " = "); + result.push_back(" = "); generate_expression(result, subs, func, arg, assignnode.child()); } @@ -210,17 +210,17 @@ namespace ice while (fnentry) { - ice::string::push_back(result, " "); + result.push_back(" "); if (SyntaxNode var = fnentry.to(); var) { generate_variable(result, subs, func, arg, ret, var); - ice::string::push_back(result, ";\n"); + result.push_back(";\n"); } else if (SyntaxNode exp = fnentry.to(); exp) { generate_expression(result, subs, func, arg, exp.child()); - ice::string::push_back(result, ";\n"); + result.push_back(";\n"); } fnentry = fnentry.sibling<>(); } @@ -261,7 +261,7 @@ namespace ice ice::string::push_format(result, " {} {};\n", type.name.value, member.data().name.value); member = member.sibling(); } - ice::string::push_back(result, "};\n\n"); + result.push_back("};\n\n"); } // Generate function definitions @@ -291,7 +291,7 @@ namespace ice member = member.sibling(); } - ice::string::push_back(result, "\n"); + result.push_back("\n"); member = shader._outputs.child(); while (member) @@ -308,7 +308,7 @@ namespace ice member = member.sibling(); } - ice::string::push_back(result, "\n"); + result.push_back("\n"); // Generate uniforms for (SyntaxNode variable : shader._uniforms) @@ -342,7 +342,7 @@ namespace ice { ice::string::push_format(result, "[{}]", vartype.size_array.value); } - ice::string::push_back(result, ";\n\n"); + result.push_back(";\n\n"); } else { @@ -382,7 +382,7 @@ namespace ice ice::string::push_format(result, "in {} _a_inputs, ", shader._inputs.data().name.value, arg.data().name.value); ice::string::push_format(result, "out {} _a_outputs) {{\n", shader._outputs.data().name.value, shader._mainfunc.data().name.value); generate_function(result, subs, shader._mainfunc.data(), arg.data(), ret.data(), body.child<>()); - ice::string::push_back(result, "}\n"); + result.push_back("}\n"); ice::string::push_format(result, "\nvoid {}() {{\n", "main"); // GLSL requires 'main' as the function name ice::string::push_format(result, " {0} inputs = {0}(", shader._inputs.data().name.value); @@ -395,7 +395,7 @@ namespace ice { if (builtin == "position") { - ice::string::push_back(result, "gl_FragCoord, "); + result.push_back("gl_FragCoord, "); } } else @@ -404,9 +404,9 @@ namespace ice } member = member.sibling(); } - ice::string::pop_back(result, 2); + result.pop_back(2); } - ice::string::push_back(result, ");\n"); + result.push_back(");\n"); ice::string::push_format(result, " {} outputs;\n", shader._outputs.data().name.value); ice::string::push_format(result, " asl_proxy_{}(inputs, outputs);\n", shader._mainfunc.data().name.value); { @@ -428,7 +428,7 @@ namespace ice member = member.sibling(); } } - ice::string::push_back(result, "}\n"); + result.push_back("}\n"); return result; }; @@ -517,7 +517,7 @@ namespace ice ); // Failed to transpile - if (ice::string::empty(out_result)) + if (out_result.is_empty()) { co_return E_FailedToTranspileASLShaderToGLSL; } @@ -527,10 +527,7 @@ namespace ice { out_entry_point = "main"; - co_return ice::String{ - (char const*)result.data.location, - (ice::ucount)result.data.size.value - }; + co_return ice::string_from_data(result.data); } } @@ -547,7 +544,7 @@ namespace ice ice::String const path = ice::resource_origin(source); ice::String const ext = ice::path::extension(path); - bool const is_vertex_shader = ice::string::substr(path, ice::string::size(path) - (4 + ice::size(ext)), ice::size(ext)) == "vert"; + bool const is_vertex_shader = path.substr(path.size() - (4 + ext.size()), ext.size()) == "vert"; ice::render::ShaderStageFlags const shader_stage = is_vertex_shader ? ice::render::ShaderStageFlags::VertexStage @@ -579,11 +576,11 @@ namespace ice shaderc::Compiler compiler{}; shaderc::SpvCompilationResult const spv_result = compiler.CompileGlslToSpv( - ice::string::begin(glsl_source), - ice::string::size(glsl_source), + glsl_source.begin(), + glsl_source.size(), is_vertex_shader ? shaderc_shader_kind::shaderc_vertex_shader : shaderc_shader_kind::shaderc_fragment_shader, - ice::string::begin(path), - ice::string::begin(entry_point), + path.begin(), + entry_point.begin(), compile_options ); @@ -608,11 +605,11 @@ namespace ice else { // Keep the string size so we can adjust the memory block result - ice::ucount const string_size = ice::size(transpiled_result); - result_mem = ice::string::extract_memory(transpiled_result); + ice::ncount const string_size = transpiled_result.size(); + result_mem = transpiled_result.extract_memory(); // Ensure memory size is equal to string size not its capacity. - result_mem.size.value = string_size; + result_mem.size = string_size; } // Unload resource before continuing diff --git a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx index 10c1c67c..24788601 100644 --- a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "shader_tools_wgsl.hxx" @@ -108,9 +108,9 @@ namespace ice syntax::Atom const& atom = node.to().data(); if (atom.is_parenthized) { - ice::string::push_back(result, "("); + result.push_back("("); generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, ")"); + result.push_back(")"); } else { @@ -123,7 +123,7 @@ namespace ice generate_expression(result, subs, func, arg, node.child()); if (node.sibling()) { - ice::string::push_back(result, ", "); + result.push_back(", "); } break; } @@ -149,12 +149,12 @@ namespace ice ice::string::push_format(result, "{}(", node.to().data().name.value); // Call children groups generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, ")"); + result.push_back(")"); break; case SyntaxEntity::E_IndexOperator: - ice::string::push_back(result, "["); + result.push_back("["); generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, "]"); + result.push_back("]"); break; default: break; @@ -184,7 +184,7 @@ namespace ice if (SyntaxNode assignnode = typenode.sibling(); assignnode) { - ice::string::push_back(result, " = "); + result.push_back(" = "); generate_expression(result, subs, func, arg, assignnode.child()); } @@ -203,17 +203,17 @@ namespace ice while (fnentry) { - ice::string::push_back(result, " "); + result.push_back(" "); if (SyntaxNode var = fnentry.to(); var) { generate_variable(result, subs, func, arg, ret, var); - ice::string::push_back(result, ";\n"); + result.push_back(";\n"); } else if (SyntaxNode exp = fnentry.to(); exp) { generate_expression(result, subs, func, arg, exp.child()); - ice::string::push_back(result, ";\n"); + result.push_back(";\n"); } fnentry = fnentry.sibling<>(); } @@ -262,7 +262,7 @@ namespace ice } else { - ice::string::push_back(result, " "); + result.push_back(" "); } wgsl::generate_type(result, member.data().name.value, type); @@ -270,7 +270,7 @@ namespace ice //ice::string::push_format(result, " {} {};\n", type.name.value, member.data().name.value); member = member.sibling(); } - ice::string::push_back(result, "};\n\n"); + result.push_back("};\n\n"); ICE_LOG_IF( is_uniform && is_inout, @@ -320,7 +320,7 @@ namespace ice } } - ice::string::push_back(result, "\n"); + result.push_back("\n"); // Generate shader main SyntaxNode arg = shader._mainfunc.child(); @@ -339,8 +339,8 @@ namespace ice ice::string::push_format(result, " var out: {};\n", shader._outputs.data().name.value); ice::hashmap::set(subs, detail::arc_hash(shader._mainfunc.data().name.value), arctic::String{ "out" }); generate_function(result, subs, shader._mainfunc.data(), arg.data(), ret.data(), body.child()); - ice::string::push_back(result, " return out;\n"); - ice::string::push_back(result, "}\n"); + result.push_back(" return out;\n"); + result.push_back("}\n"); return result; }; @@ -419,7 +419,7 @@ namespace ice ); // Failed to transpile - if (ice::string::empty(out_result)) + if (out_result.is_empty()) { co_return E_FailedToTranspileASLShaderToWGSL; } @@ -429,7 +429,7 @@ namespace ice { co_return ice::String{ (char const*) result.data.location, - (ice::ucount) result.data.size.value + (ice::u32) result.data.size.value }; } } @@ -447,7 +447,7 @@ namespace ice ice::String const path = ice::resource_origin(source); ice::String const ext = ice::path::extension(path); - bool const is_vertex_shader = ice::string::substr(path, ice::string::size(path) - (4 + ice::size(ext)), ice::size(ext)) == "vert"; + bool const is_vertex_shader = path.substr(path.size() - (4 + ext.size()), ext.size()) == "vert"; ice::render::ShaderStageFlags const shader_stage = is_vertex_shader ? ice::render::ShaderStageFlags::VertexStage @@ -475,13 +475,13 @@ namespace ice sctx.shader_main = entry_point; sctx.shader_type = static_cast(shader_stage); - ice::ucount const string_size = ice::size(transpiled_result); - ice::Memory memory = ice::string::extract_memory(transpiled_result); + ice::ncount const string_size = transpiled_result.size(); + ice::Memory memory = transpiled_result.extract_memory(); // Set the memory size to the final string size. Add '1' if the results has to be "compiled". // The added '1' is there because WebGPU shader loading functions to accept a size, so we need to ensure the loaded // data is '0' terminated. Returning memory with that '0' character ensure it's valid when loaded into memory. - memory.size.value = string_size + ice::u32(sctx.stage == ice::ShaderStage::Compiled); + memory.size = string_size + ice::u32(sctx.stage == ice::ShaderStage::Compiled); // Move the memory from the heapstring to Memory co_return ResourceCompilerResult{ .result = memory }; diff --git a/source/code/modules/vulkan_renderer/private/vk_device.cxx b/source/code/modules/vulkan_renderer/private/vk_device.cxx index eb153449..ab661716 100644 --- a/source/code/modules/vulkan_renderer/private/vk_device.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_device.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_device.hxx" @@ -656,9 +656,9 @@ namespace ice::render::vk shader_stage.flags = 0; shader_stage.stage = native_enum_value(info.shaders[stage_idx].stage); shader_stage.module = native_handle(info.shaders[stage_idx].shader); - if (ice::string::any(info.shaders[stage_idx].entry_point)) + if (info.shaders[stage_idx].entry_point.not_empty()) { - shader_stage.pName = ice::string::begin(info.shaders[stage_idx].entry_point); + shader_stage.pName = info.shaders[stage_idx].entry_point.begin(); } else { @@ -910,12 +910,12 @@ namespace ice::render::vk ice::Span update_infos ) noexcept { - ice::ucount const update_count = ice::count(update_infos); + ice::u32 const update_count = ice::count(update_infos); - ice::ucount update_offset = 0; + ice::u32 update_offset = 0; while(update_offset < update_count) { - ice::ucount const current_update_count = ice::min(update_count - update_offset, 16u); + ice::u32 const current_update_count = ice::min(update_count - update_offset, 16u); // We map up to 16 pointers at one time so VMA does not continously call vkMap and vkUnmap for each object entry. void* data_pointers[16]; diff --git a/source/code/modules/vulkan_renderer/private/vk_driver.cxx b/source/code/modules/vulkan_renderer/private/vk_driver.cxx index 80c71f03..6120b6d4 100644 --- a/source/code/modules/vulkan_renderer/private/vk_driver.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_driver.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_driver.hxx" @@ -371,7 +371,7 @@ namespace ice::render::vk ice::array::push_back(queue_create_infos, queue_create_info); } - ice::ucount count_extensions = 0; + ice::u32 count_extensions = 0; ice::Array extension_names{ _allocator }; Extension const device_extensions = extensions_gather_names(extension_names, count_extensions, _vk_physical_device); ICE_ASSERT_CORE(ice::has_all(device_extensions, Extension::VkD_Swapchain)); diff --git a/source/code/modules/vulkan_renderer/private/vk_extensions.cxx b/source/code/modules/vulkan_renderer/private/vk_extensions.cxx index 3fb0b6b4..f67fb0bd 100644 --- a/source/code/modules/vulkan_renderer/private/vk_extensions.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_extensions.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_extensions.hxx" @@ -31,7 +31,7 @@ namespace ice::render::vk { ExtensionTarget::VmaExtension, Extension::Vma_MemoryBudget, VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT, "" }, }; - auto gather_instance_layers(ice::Array& out_names, ice::ucount& out_count) noexcept -> Extension + auto gather_instance_layers(ice::Array& out_names, ice::u32& out_count) noexcept -> Extension { Extension result = Extension::None; @@ -67,7 +67,7 @@ namespace ice::render::vk return result; } - auto gather_instance_extensions(ice::Array& out_names, ice::ucount& out_count) noexcept -> Extension + auto gather_instance_extensions(ice::Array& out_names, ice::u32& out_count) noexcept -> Extension { Extension result = Extension::None; @@ -103,7 +103,7 @@ namespace ice::render::vk return result; } - auto gather_device_extensions(ice::Array& out_names, ice::ucount& out_count, VkPhysicalDevice physical_device) noexcept -> Extension + auto gather_device_extensions(ice::Array& out_names, ice::u32& out_count, VkPhysicalDevice physical_device) noexcept -> Extension { Extension result = Extension::None; @@ -139,7 +139,7 @@ namespace ice::render::vk return result; } - auto extensions_gather_names(ice::Array& out_names, ice::ucount& out_count, ExtensionTarget target) noexcept -> Extension + auto extensions_gather_names(ice::Array& out_names, ice::u32& out_count, ExtensionTarget target) noexcept -> Extension { switch(target) { @@ -152,7 +152,7 @@ namespace ice::render::vk } } - auto extensions_gather_names(ice::Array& out_names, ice::ucount &out_count, VkPhysicalDevice physical_device) noexcept -> Extension + auto extensions_gather_names(ice::Array& out_names, ice::u32 &out_count, VkPhysicalDevice physical_device) noexcept -> Extension { return gather_device_extensions(out_names, out_count, physical_device); } diff --git a/source/code/modules/vulkan_renderer/private/vk_extensions.hxx b/source/code/modules/vulkan_renderer/private/vk_extensions.hxx index ae267243..bfbc100b 100644 --- a/source/code/modules/vulkan_renderer/private/vk_extensions.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_extensions.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -56,13 +56,13 @@ namespace ice::render::vk auto extensions_gather_names( ice::Array& out_names, - ice::ucount& out_count, + ice::u32& out_count, ExtensionTarget target ) noexcept -> Extension; auto extensions_gather_names( ice::Array& out_names, - ice::ucount& out_count, + ice::u32& out_count, VkPhysicalDevice physical_device ) noexcept -> Extension; diff --git a/source/code/modules/vulkan_renderer/private/vk_module.cxx b/source/code/modules/vulkan_renderer/private/vk_module.cxx index 554f69cc..e12dbab9 100644 --- a/source/code/modules/vulkan_renderer/private/vk_module.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_module.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -23,11 +23,11 @@ namespace ice::render::vk app_info.engineVersion = 1; app_info.apiVersion = VK_API_VERSION_1_3; - ice::ucount layer_count = 0; + ice::u32 layer_count = 0; ice::Array names{ alloc }; Extension extensions = extensions_gather_names(names, layer_count, ExtensionTarget::InstanceLayer); - ice::ucount extension_count = 0; + ice::u32 extension_count = 0; extensions |= extensions_gather_names(names, extension_count, ExtensionTarget::InstanceExtension); ICE_ASSERT_CORE(ice::has_all(extensions, Extension::VkI_Surface)); ICE_ASSERT_CORE(ice::has_any(extensions, Extension::VkI_AndroidSurface | Extension::VkI_Win32Surface)); diff --git a/source/code/modules/vulkan_renderer/private/vk_queue.cxx b/source/code/modules/vulkan_renderer/private/vk_queue.cxx index a8e37ebf..8c401b41 100644 --- a/source/code/modules/vulkan_renderer/private/vk_queue.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_queue.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_queue.hxx" @@ -139,7 +139,7 @@ namespace ice::render::vk VkCommandBuffer vk_temp_buffers[16]; ICE_ASSERT_CORE(ice::count(buffers) < 16); - ice::ucount count = 0; + ice::u32 count = 0; for (ice::render::CommandBuffer handle : buffers) { vk_temp_buffers[count] = VulkanCommandBuffer::native(handle)->buffer; diff --git a/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx b/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx index 7b075bc5..d6177f3f 100644 --- a/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx @@ -126,7 +126,7 @@ namespace ice::render::vk // TODO: Can we do this differently? if (result != VK_SUCCESS) { - return ice::ucount_max; + return ice::u32_max; } //ICE_ASSERT( diff --git a/source/code/platforms/application/private/app_info.cxx b/source/code/platforms/application/private/app_info.cxx index bea93d8c..05a72ff9 100644 --- a/source/code/platforms/application/private/app_info.cxx +++ b/source/code/platforms/application/private/app_info.cxx @@ -4,7 +4,6 @@ #include #include #include -#include #include namespace ice::app @@ -26,8 +25,8 @@ namespace ice::app static ice::StaticString<256> app_location = []() noexcept { ice::StaticString<256, ice::wchar> location_wide{ L"" }; - DWORD const path_size = GetModuleFileNameW(NULL, ice::string::begin(location_wide), ice::string::capacity(location_wide)); - ice::string::resize(location_wide, path_size); + DWORD const path_size = GetModuleFileNameW(NULL, location_wide.begin(), location_wide.capacity().u32()); + location_wide.resize(path_size); ice::StackAllocator_1024 stack_alloc; ice::HeapString<> location_utf8{ stack_alloc }; @@ -50,8 +49,8 @@ namespace ice::app static ice::StaticString<256> working_dir = []() noexcept { ice::StaticString<256, ice::wchar> location_wide{ L"" }; - DWORD const path_size = GetCurrentDirectoryW(ice::string::capacity(location_wide), ice::string::begin(location_wide)); - ice::string::resize(location_wide, path_size); + DWORD const path_size = GetCurrentDirectoryW(location_wide.capacity().u32(), location_wide.begin()); + location_wide.resize(path_size); ice::StackAllocator_1024 stack_alloc; ice::HeapString<> location_utf8{ stack_alloc }; diff --git a/source/code/platforms/platform_linux/private/linux_storage.cxx b/source/code/platforms/platform_linux/private/linux_storage.cxx index 91e8d239..5e8d5b04 100644 --- a/source/code/platforms/platform_linux/private/linux_storage.cxx +++ b/source/code/platforms/platform_linux/private/linux_storage.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "linux_storage.hxx" @@ -45,7 +45,7 @@ namespace ice::platform::linux } ice::ucount const idassignment = ice::string::find_first_of(line, '='); - if (idassignment == ice::String_NPos) + if (idassignment == ice::none_index) { ICE_LOG(LogSeverity::Warning, LogTag::Core, "Improperly formatted line: {}", line); return true; diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx index b8798365..bbc9e927 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx @@ -3,7 +3,6 @@ #include "win32_sdl2_platform_render_surface.hxx" #include -#include #include #include @@ -46,7 +45,7 @@ namespace ice::platform::win32::sdl2 using ice::render::RenderDriverAPI; ice::i32 creation_flags = SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE; ice::StaticString<64> window_title{ surface_params.window_title }; - if (ice::string::empty(window_title)) + if (window_title.is_empty()) { if (surface_params.driver == RenderDriverAPI::Vulkan) { @@ -61,7 +60,7 @@ namespace ice::platform::win32::sdl2 } _window = SDL_CreateWindow( - ice::string::data(window_title), + window_title.data(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, surface_params.dimensions.x, diff --git a/source/code/platforms/platform_win32/private/win32_storage.cxx b/source/code/platforms/platform_win32/private/win32_storage.cxx index ee064c63..914ee54d 100644 --- a/source/code/platforms/platform_win32/private/win32_storage.cxx +++ b/source/code/platforms/platform_win32/private/win32_storage.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "win32_storage.hxx" @@ -17,7 +17,7 @@ namespace ice::platform::win32 { - static constexpr ice::ucount Constant_AppNameReservedLength = 24; + static constexpr ice::u32 Constant_AppNameReservedLength = 24; namespace detail { @@ -27,15 +27,15 @@ namespace ice::platform::win32 PWSTR path; if (SHGetKnownFolderPath(known_path_guid, KF_FLAG_CREATE, NULL, &path) == S_OK) { - ice::ucount const path_len = ice::ucount(lstrlenW(path)); + ice::u32 const path_len = ice::u32(lstrlenW(path)); // Reserve additional space for the app name, so we don't need to resize buffers if that happens. - ice::string::reserve(out_path, path_len + Constant_AppNameReservedLength); - ice::wide_to_utf8_append({ path, ice::ucount(lstrlenW(path)) }, out_path); - ice::string::push_back(out_path, '\\'); - if (ice::string::any(appname)) + out_path.reserve(path_len + Constant_AppNameReservedLength); + ice::wide_to_utf8_append({ path, ice::u32(lstrlenW(path)) }, out_path); + out_path.push_back('\\'); + if (appname.not_empty()) { - ice::string::push_back(out_path, appname); - ice::string::push_back(out_path, '\\'); + out_path.push_back(appname); + out_path.push_back('\\'); } ice::path::normalize(out_path); CoTaskMemFree(path); @@ -46,9 +46,9 @@ namespace ice::platform::win32 { ice::StackAllocator<512_B> temp_alloc; ice::HeapString temp_paths{ temp_alloc }; - ice::string::reserve(temp_paths, 256); + temp_paths.reserve(256); ice::utf8_to_wide_append(path, temp_paths); - return CreateDirectoryW(ice::string::begin(temp_paths), NULL); + return CreateDirectoryW(temp_paths.begin(), NULL); } } // namespace detail @@ -104,11 +104,11 @@ namespace ice::platform::win32 void win32::Win32Storage::reload_paths(ice::String appname) noexcept { - ice::string::clear(_save_location); - ice::string::clear(_cache_location); - ice::string::clear(_temp_location); - ice::string::clear(_pictures_location); - ice::string::clear(_other_location); + _save_location.clear(); + _cache_location.clear(); + _temp_location.clear(); + _pictures_location.clear(); + _other_location.clear(); detail::get_known_path(_save_location, FOLDERID_SavedGames, appname); detail::get_known_path(_cache_location, FOLDERID_LocalAppData, appname); @@ -123,7 +123,7 @@ namespace ice::platform::win32 WCHAR tempbuff[256]; // GetTempPathW already returns a path ending with a slash character. DWORD const len = GetTempPathW(256, tempbuff); - ice::wide_to_utf8_append({ tempbuff, ice::ucount(len) }, _temp_location); + ice::wide_to_utf8_append({ tempbuff, ice::u32(len) }, _temp_location); ice::path::normalize(_temp_location); } diff --git a/source/code/platforms/platform_win32/private/win32_threads.cxx b/source/code/platforms/platform_win32/private/win32_threads.cxx index 5ba5e38d..02793fcb 100644 --- a/source/code/platforms/platform_win32/private/win32_threads.cxx +++ b/source/code/platforms/platform_win32/private/win32_threads.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "win32_threads.hxx" @@ -9,7 +9,7 @@ namespace ice::platform::win32 { - auto get_num_cores(ice::Allocator& alloc) noexcept -> ice::ucount + auto get_num_cores(ice::Allocator& alloc) noexcept -> ice::u32 { DWORD byte_size = 0; GetLogicalProcessorInformationEx(RelationProcessorCore, nullptr, &byte_size); @@ -24,7 +24,7 @@ namespace ice::platform::win32 ); ICE_ASSERT_CORE(result == TRUE); - ice::ucount num_procs = 0; + ice::u32 num_procs = 0; ice::usize byte_size_processed = 0_B; for (; byte_size_processed.value < byte_size;) { @@ -68,8 +68,8 @@ namespace ice::platform::win32 , _threads{ } , _aioport{ ice::native_aio::aio_open(alloc, { .worker_limit = 2, .debug_name = "ice.aio-port" }) } { - ice::ucount const hw_concurrency = ice::min(get_num_cores(alloc), 8u); - ice::ucount tp_size = ice::max(hw_concurrency, 2u); // min 2 task threads + ice::u32 const hw_concurrency = ice::min(get_num_cores(alloc), 8u); + ice::u32 tp_size = ice::max(hw_concurrency, 2u); // min 2 task threads for (ice::Shard const option : params) { diff --git a/source/code/systems/asset_system/private/asset_shelve_devui.cxx b/source/code/systems/asset_system/private/asset_shelve_devui.cxx index 351fe2e2..1d7263a1 100644 --- a/source/code/systems/asset_system/private/asset_shelve_devui.cxx +++ b/source/code/systems/asset_system/private/asset_shelve_devui.cxx @@ -5,8 +5,7 @@ #include #include -#include -#undef assert +#include namespace ice { @@ -46,7 +45,7 @@ namespace ice { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::TextUnformatted(ice::string::begin(entry->debug_name), ice::string::end(entry->debug_name)); + ImGui::TextUnformatted(entry->debug_name.cbegin(), entry->debug_name.cend()); if (ImGui::TableNextColumn()) // Status { @@ -54,16 +53,13 @@ namespace ice "Invalid", "Unknown", "Exists", "Raw", "Baked", "Loaded", "Runtime" }; - ImGui::TextUnformatted( - ice::string::begin(Constant_StateNames[static_cast(entry->state())]), - ice::string::end(Constant_StateNames[static_cast(entry->state())]) - ); + ImGui::TextUnformatted(Constant_StateNames[static_cast(entry->state())]); } if (ImGui::TableNextColumn()) // Resource { ice::ResourceHandle const handle = ice::asset_data_resource(entry->_data); ice::String const origin = handle != nullptr ? handle->origin() : "???"; - ImGui::TextUnformatted(ice::string::begin(origin), ice::string::end(origin)); + ImGui::TextUnformatted(origin); } } diff --git a/source/code/systems/asset_system/private/asset_storage.cxx b/source/code/systems/asset_system/private/asset_storage.cxx index 0ebb7900..455f6410 100644 --- a/source/code/systems/asset_system/private/asset_storage.cxx +++ b/source/code/systems/asset_system/private/asset_storage.cxx @@ -45,13 +45,13 @@ namespace ice ice::ResourceHandle resource; ice::u32 ext_idx = 0; - ice::u32 const ext_count = ice::count(definition.resource_extensions); - ice::u32 const temp_name_len = ice::size(temp_name); + ice::u32 const ext_count = ice::u32(ice::count(definition.resource_extensions)); + ice::u32 const temp_name_len = temp_name.size().u32(); while (resource == nullptr && ext_idx < ext_count) { ice::String const extension = definition.resource_extensions[ext_idx++]; - ice::string::resize(temp_name, temp_name_len); - ice::string::push_back(temp_name, extension); + temp_name.resize(temp_name_len); + temp_name.push_back(extension); ice::URI const uri{ Scheme_URN, temp_name }; resource = resource_tracker.find_resource(uri, ice::ResourceFlags::None); @@ -241,7 +241,7 @@ namespace ice , _devui_widget{ } { ice::Span categories = _asset_archive->categories(); - ice::hashmap::reserve(_asset_shelves, ice::count(categories)); + ice::hashmap::reserve(_asset_shelves, ice::u32(ice::count(categories))); ice::Array> shelves{ _allocator }; for (ice::AssetCategory_Arg category : categories) diff --git a/source/code/systems/asset_system/private/asset_storage.hxx b/source/code/systems/asset_system/private/asset_storage.hxx index 74020572..7764f494 100644 --- a/source/code/systems/asset_system/private/asset_storage.hxx +++ b/source/code/systems/asset_system/private/asset_storage.hxx @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/source/code/systems/asset_system/private/asset_storage_devui.cxx b/source/code/systems/asset_system/private/asset_storage_devui.cxx index 3739b598..15aabd0f 100644 --- a/source/code/systems/asset_system/private/asset_storage_devui.cxx +++ b/source/code/systems/asset_system/private/asset_storage_devui.cxx @@ -5,9 +5,7 @@ #include "asset_storage_devui.hxx" #include #include - -#include -#undef assert +#include namespace ice { @@ -73,14 +71,14 @@ namespace ice { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::TextUnformatted(ice::string::begin(category.name), ice::string::end(category.name)); + ImGui::TextUnformatted(category.name); ice::AssetCategoryDefinition const& def = _storage._asset_archive->find_definition(category); if (ImGui::TableNextColumn()) { for (ice::String ext : def.resource_extensions) { - ImGui::TextUnformatted(ice::string::begin(ext), ice::string::end(ext)); ImGui::SameLine(); + ImGui::TextUnformatted(ext); ImGui::SameLine(); } } diff --git a/source/code/systems/font_system/private/font_utils.cxx b/source/code/systems/font_system/private/font_utils.cxx index 32ba6db2..45c4143b 100644 --- a/source/code/systems/font_system/private/font_utils.cxx +++ b/source/code/systems/font_system/private/font_utils.cxx @@ -74,8 +74,8 @@ namespace ice ice::u32& out_glyph_count ) noexcept -> ice::vec2f { - char const* text_it = ice::string::begin(text); - char const* const text_end = ice::string::end(text); + char const* text_it = text.begin(); + char const* const text_end = text.end(); ice::f32 last_advance_offset = 0.f; diff --git a/source/code/systems/input_action_system/private/input_action_layer.cxx b/source/code/systems/input_action_system/private/input_action_layer.cxx index 4793db15..01a39532 100644 --- a/source/code/systems/input_action_system/private/input_action_layer.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT @@ -35,7 +35,7 @@ namespace ice }; template - auto load_field_from_data(ice::Span& out_span, ice::Data data, ice::usize offset, ice::ucount count) noexcept + auto load_field_from_data(ice::Span& out_span, ice::Data data, ice::usize offset, ice::u32 count) noexcept { out_span = ice::span::from_data(data, count, offset); return ice::span::data_view(out_span).size; @@ -61,12 +61,12 @@ namespace ice offset += load_field_from_data(result.constants, data, offset, header.count_constants); ICE_ASSERT_CORE(offset == ice::usize{ header.offset_strings }); - result.strings = ice::string::from_data( + result.strings = ice::string_from_data( data, - ice::usize{ header.offset_strings }, - ice::ucount( data.size.value - header.offset_strings ) + header.offset_strings, + data.size.value - header.offset_strings ); - result.name = ice::string::substr(result.strings, 0, header.size_name); + result.name = result.strings.substr(0, header.size_name); return result; } @@ -108,7 +108,7 @@ namespace ice auto source_name(ice::InputActionSourceInputInfo const& source) const noexcept -> ice::String override { - return ice::string::substr(_strings, source.name); + return _strings.substr(source.name); } auto actions() const noexcept -> ice::Span override @@ -118,10 +118,10 @@ namespace ice auto action_name(ice::InputActionInfo const& action) const noexcept -> ice::String override { - return ice::string::substr(_strings, action.name); + return _strings.substr(action.name); } - auto load_constants(ice::Span constants_span) const noexcept -> ice::ucount override + auto load_constants(ice::Span constants_span) const noexcept -> ice::u32 override { ICE_ASSERT_CORE(ice::count(constants_span) >= Constant_CountInputActionConstants); for (ice::InputActionConstantInfo const constant : _constants) @@ -135,7 +135,7 @@ namespace ice auto process_inputs( ice::Span input_events, ice::Span source_values - ) const noexcept -> ice::ucount override + ) const noexcept -> ice::u32 override { IPT_ZONE_SCOPED; @@ -145,8 +145,8 @@ namespace ice return ev.identifier == id; }; - ice::ucount count_processed = 0; - ice::ucount const count_events = ice::count(input_events); + ice::u32 count_processed = 0; + ice::u32 const count_events = ice::count(input_events); // Reset the temporary events. for (ice::InputActionSourceInputInfo const& src : _sources) @@ -165,7 +165,7 @@ namespace ice ice::InputActionSource* const values = source_values[src.storage_offset]; ice::u32 const count_values = 1 + ice::u32(src.type == InputActionSourceType::Axis2d); - ice::ucount event_index = 0; + ice::u32 event_index = 0; if (ice::search(input_events, src.input, comp_event_id, event_index) == false) { // Reset any event that was a key-release event previously @@ -253,7 +253,7 @@ namespace ice for (ice::InputActionInfo const& action : _actions) { - ice::String const action_name = ice::string::substr(_strings, action.name); + ice::String const action_name = _strings.substr(action.name); ice::InputActionRuntime* const runtime = ice::hashmap::try_get(actions, ice::hash(action_name)); // TODO: Check if we need this @@ -273,7 +273,7 @@ namespace ice if (cond.source.source_index != InputActionIndex::SelfIndex) { ice::InputActionInfo const checked_action_info = _actions[cond.source.source_index]; - ice::String const checked_action_name = ice::string::substr(_strings, checked_action_info.name); + ice::String const checked_action_name = _strings.substr(checked_action_info.name); checked_action = ice::hashmap::try_get(actions, ice::hash(checked_action_name)); } ICE_ASSERT_CORE(checked_action != nullptr); @@ -373,7 +373,7 @@ namespace ice for (ice::InputActionInfo const& action : _actions) { - ice::String const action_name = ice::string::substr(_strings, action.name); + ice::String const action_name = _strings.substr(action.name); ice::InputActionRuntime* const runtime = ice::hashmap::try_get(actions, ice::hash(action_name)); // Handles 'Toggle'. We only activate of the first press, which is `state == 1`. diff --git a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx index 254f57e4..9e06b95c 100644 --- a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_action_internal_types.hxx" @@ -17,7 +17,7 @@ namespace ice auto parse_source(ice::String source) noexcept -> std::tuple { ice::u8 read_from = 0; - ice::ucount source_size = ice::size(source); + ice::ncount source_size = source.size(); // We want to parse the following cases: (.[xyz]) if (source_size > 1 && source[source_size - 2] == '.') { @@ -25,7 +25,7 @@ namespace ice read_from = source[source_size + 1] - 'x'; ICE_ASSERT_CORE(read_from >= 0 && read_from < 3); } - return { ice::string::substr(source, 0, source_size), read_from }; + return { source.substr(0, source_size), read_from }; } } // namespace detail @@ -266,8 +266,8 @@ namespace ice ice::Array final_actions{ _allocator }; // Insert layer name as the first string - ice::string::push_back(strings, _name); - ice::string::push_back(strings, '\0'); + strings.push_back(_name); + strings.push_back('\0'); // Prepare data of all sources for (Internal const& source : _sources) @@ -276,7 +276,7 @@ namespace ice { ice::array::push_back(final_sources, InputActionSourceInputInfo{ - .name = { ice::u16(ice::size(strings)), ice::u16(ice::size(source.name)) }, + .name = { strings.size().u16(), source.name.size().u16() }, .input = ice::input::InputID::Invalid, .type = source.type, .storage_offset = count_storage_values, @@ -289,7 +289,7 @@ namespace ice { ice::array::push_back(final_sources, InputActionSourceInputInfo{ - .name = { ice::u16(ice::size(strings)), ice::u16(ice::size(source.name)) }, + .name = { strings.size().u16(), source.name.size().u16() }, .input = input_event, .type = source.type, .storage_offset = count_storage_values, @@ -297,7 +297,7 @@ namespace ice } ); } - ice::string::push_back(strings, source.name); + strings.push_back(source.name); // ice::string::push_back(strings, '\0'); switch(source.type) @@ -314,14 +314,14 @@ namespace ice auto find_source_storage_index = [&strings, &final_sources](ice::String source_name) noexcept -> ice::u16 { - ice::ucount idx_found = ice::ucount_max; + ice::u32 idx_found = ice::u32_max; bool const found = ice::search( ice::array::slice(final_sources), source_name, [&strings](ice::InputActionSourceInputInfo const& source, ice::String expected) noexcept { - ice::String const source_name = ice::string::substr( - strings, source.name.offset, source.name.size + ice::String const source_name = strings.substr( + source.name.offset, source.name.size ); return expected == source_name; }, @@ -335,14 +335,14 @@ namespace ice auto find_action_storage_index = [&strings, &final_actions](ice::String source_name) noexcept -> ice::u16 { - ice::ucount idx_found = ice::ucount_max; + ice::u32 idx_found = ice::u32_max; bool const found = ice::search( ice::array::slice(final_actions), source_name, [&strings](ice::InputActionInfo const& action, ice::String expected) noexcept { - ice::String const source_name = ice::string::substr( - strings, action.name.offset, action.name.size + ice::String const source_name = strings.substr( + action.name.offset, action.name.size ); return expected == source_name; }, @@ -404,7 +404,7 @@ namespace ice if (condition.from_action) { // If we are empty, it's a "self reference" - if (ice::string::any(condition.source)) + if (condition.source.not_empty()) { source_index.source_index = find_action_storage_index(condition.source); source_index.source_axis = condition.axis; @@ -442,7 +442,7 @@ namespace ice ice::array::push_back(final_actions, InputActionInfo{ - .name = { ice::u16(ice::size(strings)), ice::u16(ice::size(action.name)) }, + .name = { strings.size().u16(), action.name.size().u16() }, .type = action.type, .behavior = action.behavior, .conditions = { condition_offset, condition_count }, @@ -450,7 +450,7 @@ namespace ice } ); - ice::string::push_back(strings, action.name); + strings.push_back(action.name); modifier_offset += modifier_count; condition_offset += ice::exchange(condition_count, ice::u16_0); @@ -466,7 +466,7 @@ namespace ice } ice::InputActionLayerInfoHeader final_info{ - .size_name = ice::u8(ice::size(_name)), + .size_name = _name.size().u8(), .count_constants = ice::u8(ice::count(final_constants)), .count_sources = ice::u16(ice::count(final_sources)), .count_actions = ice::u16(ice::count(final_actions)), @@ -485,7 +485,7 @@ namespace ice ice::usize const offset_modifiers = minfo_layer += ice::array::meminfo(final_modifiers); ice::usize const offset_constant_values = minfo_layer += ice::meminfo_of * ice::count(final_constant_values); ice::usize const offset_constants = minfo_layer += ice::array::meminfo(final_constants); - ice::usize const offset_strings = minfo_layer += ice::string::meminfo(ice::String{strings}); + ice::usize const offset_strings = minfo_layer += strings.meminfo(); final_info.offset_strings = ice::u32(offset_strings.value); ice::Memory const final_memory = alloc.allocate(minfo_layer); @@ -497,7 +497,7 @@ namespace ice ice::memcpy(ice::ptr_add(final_memory, offset_modifiers), ice::array::data_view(final_modifiers)); ice::memcpy(ice::ptr_add(final_memory, offset_constant_values), ice::array::data_view(final_constant_values)); ice::memcpy(ice::ptr_add(final_memory, offset_constants), ice::array::data_view(final_constants)); - ice::memcpy(ice::ptr_add(final_memory, offset_strings), ice::string::data_view(strings)); + ice::memcpy(ice::ptr_add(final_memory, offset_strings), strings.data_view()); return ice::create_input_action_layer(alloc, final_memory); } @@ -673,13 +673,13 @@ namespace ice ice::String target_axis /*= ".x"*/ ) noexcept -> Action& { - ICE_ASSERT_CORE(ice::size(target_axis) >= 2 && target_axis[0] == '.'); - if (ice::size(target_axis) < 2 || target_axis[0] != '.') + ICE_ASSERT_CORE(target_axis.size() >= 2 && target_axis[0] == '.'); + if (target_axis.size() < 2 || target_axis[0] != '.') { return *this; } - for (char axis_component : ice::string::substr(target_axis, 1, 3)) + for (char axis_component : target_axis.substr(1, 3)) { ICE_ASSERT_CORE(axis_component >= 'x' && axis_component <= 'z'); // .xyz diff --git a/source/code/systems/input_action_system/private/input_action_script.cxx b/source/code/systems/input_action_system/private/input_action_script.cxx index a546ee68..31481c6c 100644 --- a/source/code/systems/input_action_system/private/input_action_script.cxx +++ b/source/code/systems/input_action_system/private/input_action_script.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_action_script.hxx" @@ -68,7 +68,7 @@ namespace ice::asl .location = location }; - ice::ucount idx; + ice::u32 idx; ice::asl::TokenDefinition const needle{ .value = word.value }; if (ice::binary_search(ice::span::from_std_const(Constant_TokenDefinitions), needle, idx)) { diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index dd15f768..a83c67bf 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -1,11 +1,10 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include #include #include -#include #include #include #include @@ -38,7 +37,7 @@ namespace ice auto registered_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount override; + ) const noexcept -> ice::u32 override; auto register_layer( ice::InputActionLayer const* layer @@ -47,7 +46,7 @@ namespace ice auto active_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount override; + ) const noexcept -> ice::u32 override; void push_layer( ice::InputActionLayer const* layer @@ -135,7 +134,7 @@ namespace ice auto SimpleInputActionStack::registered_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount + ) const noexcept -> ice::u32 { for (StackLayer const& layer : _layers) { @@ -154,7 +153,7 @@ namespace ice return E_NullPointer; } - ice::ucount layer_idx; + ice::u32 layer_idx; if (ice::search(ice::Span{ _layers }, layer, compare_layers, layer_idx)) { return S_LayerAlreadyRegistered; @@ -170,7 +169,7 @@ namespace ice // Go through each resource and set the indices ice::u64 prev_name_hash = 0; ice::Span sources = layer->sources(); - ice::ucount const count_sources = ice::count(sources); + ice::u32 const count_sources = ice::count(sources); for (ice::u32 idx = 0; idx < count_sources; ++idx) { ice::InputActionSourceInputInfo const& source = sources[idx]; @@ -234,7 +233,7 @@ namespace ice // Create the final name with the prefix and store it so the pointer reimains valid. // #TODO: Consider using refs instead? ice::HeapString<> final_name = _idprefix; - ice::string::push_back(final_name, action_name); + final_name.push_back(action_name); ice::hashmap::set(_action_names, action_name_hash, ice::move(final_name)); ice::HeapString<> const* final_name_ptr = ice::hashmap::try_get(_action_names, action_name_hash); @@ -255,7 +254,7 @@ namespace ice auto SimpleInputActionStack::active_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount + ) const noexcept -> ice::u32 { auto it = ice::array::rbegin(_layers_active); auto const end = ice::array::rend(_layers_active); @@ -272,7 +271,7 @@ namespace ice ice::InputActionLayer const* layer ) noexcept { - ice::ucount idx; + ice::u32 idx; if (ice::search(ice::Span{ _layers }, layer, compare_layers, idx) == false) { // #TODO: Create a proper error return value. @@ -293,7 +292,7 @@ namespace ice ice::InputActionLayer const* layer ) noexcept { - ice::ucount idx; + ice::u32 idx; if (ice::search(ice::Span{ _layers }, layer, compare_layers, idx)) { // We just cut anything below this index, because we want to pop everything up to this layer @@ -305,13 +304,13 @@ namespace ice auto SimpleInputActionStack::action(ice::String action_name) const noexcept -> ice::Expected { ice::InputActionRuntime const* action = ice::hashmap::try_get(_actions, ice::hash(action_name)); - if (action == nullptr && ice::string::starts_with(action_name, _idprefix)) + if (action == nullptr && action_name.starts_with(_idprefix)) { // Try again after removing the prefix action = ice::hashmap::try_get( _actions, ice::hash( - ice::string::substr(action_name, ice::size(_idprefix)) + action_name.substr(_idprefix.size()) ) ); } @@ -404,7 +403,7 @@ namespace ice IPT_ZONE_SCOPED; using Iterator = ice::Array::ConstReverseIterator; - ice::ucount remaining_events = ice::count(events); + ice::u32 remaining_events = ice::count(events); ice::Array events_copy{ _allocator, events }; ice::Array source_values{ _allocator }; @@ -420,7 +419,7 @@ namespace ice ice::array::push_back(source_values, ice::addressof(_sources_runtime_values[offset])); } - ice::ucount const processed_events = layer.layer->process_inputs( + ice::u32 const processed_events = layer.layer->process_inputs( ice::array::slice(events_copy, 0, remaining_events), source_values ); diff --git a/source/code/systems/input_action_system/public/ice/input_action.hxx b/source/code/systems/input_action_system/public/ice/input_action.hxx index f9151b10..1f232e49 100644 --- a/source/code/systems/input_action_system/public/ice/input_action.hxx +++ b/source/code/systems/input_action_system/public/ice/input_action.hxx @@ -9,6 +9,8 @@ namespace ice { + static constexpr auto ab = ice::String{ "asd" }; + static constexpr ice::AssetCategory AssetCategory_InputActionsScript = ice::make_asset_category("ice/input_actions/script"); } // namespace ice diff --git a/source/code/systems/input_action_system/public/ice/input_action_layer.hxx b/source/code/systems/input_action_system/public/ice/input_action_layer.hxx index ff4912d0..2f867296 100644 --- a/source/code/systems/input_action_system/public/ice/input_action_layer.hxx +++ b/source/code/systems/input_action_system/public/ice/input_action_layer.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -43,7 +43,7 @@ namespace ice //! \note The span needs to hold at least `ice::Constant_CountInputActionConstants` number of entries. //! \param[in,out] constants_span The span into which individual constant values will be loaded. //! \returns Number of loaded constants or `0` if no constants are defined in this layer. - virtual auto load_constants(ice::Span constants_span) const noexcept -> ice::ucount = 0; + virtual auto load_constants(ice::Span constants_span) const noexcept -> ice::u32 = 0; //! \brief Updates all layer sources based on the input events passed. //! \param[in,out] events List of input events to be processed. If an event was processed it will be swapped with an @@ -53,7 +53,7 @@ namespace ice virtual auto process_inputs( ice::Span events, ice::Span source_values - ) const noexcept -> ice::ucount = 0; + ) const noexcept -> ice::u32 = 0; //! \brief Runs updates on all defined actions by this layer. //! \param[in] executor Executor object with context data, used to execute conditions, steps and modifiers. diff --git a/source/code/systems/input_action_system/public/ice/input_action_stack.hxx b/source/code/systems/input_action_system/public/ice/input_action_stack.hxx index 8dae781f..2663e4ed 100644 --- a/source/code/systems/input_action_system/public/ice/input_action_stack.hxx +++ b/source/code/systems/input_action_system/public/ice/input_action_stack.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -26,7 +26,7 @@ namespace ice virtual auto registered_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount = 0; + ) const noexcept -> ice::u32 = 0; virtual auto register_layer( ice::InputActionLayer const* layer @@ -35,7 +35,7 @@ namespace ice virtual auto active_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount = 0; + ) const noexcept -> ice::u32 = 0; virtual void push_layer( ice::InputActionLayer const* layer diff --git a/source/code/systems/input_system/private/input_controller.cxx b/source/code/systems/input_system/private/input_controller.cxx index f50ef4e6..2b5af9b5 100644 --- a/source/code/systems/input_system/private/input_controller.cxx +++ b/source/code/systems/input_system/private/input_controller.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_devices.hxx" @@ -109,7 +109,7 @@ namespace ice::input if (input != InputID::Invalid) { - ice::ucount const control_index = input_identifier_value(input); + ice::u32 const control_index = input_identifier_value(input); ICE_ASSERT_CORE(control_index < ice::array::count(_controls)); detail::ControlState control = _controls[control_index]; diff --git a/source/code/systems/input_system/private/input_keyboard.cxx b/source/code/systems/input_system/private/input_keyboard.cxx index 70e3de4f..2bd63e67 100644 --- a/source/code/systems/input_system/private/input_keyboard.cxx +++ b/source/code/systems/input_system/private/input_keyboard.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_devices.hxx" @@ -122,7 +122,7 @@ namespace ice::input break; } - ice::ucount const control_index = detail::input_control_index(input); + ice::u32 const control_index = detail::input_control_index(input); ICE_ASSERT_CORE(control_index < ice::array::count(_controls)); detail::ControlState control = _controls[control_index]; diff --git a/source/code/systems/input_system/private/input_touchscreen.cxx b/source/code/systems/input_system/private/input_touchscreen.cxx index 680bc341..88dd11a1 100644 --- a/source/code/systems/input_system/private/input_touchscreen.cxx +++ b/source/code/systems/input_system/private/input_touchscreen.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_devices.hxx" @@ -12,7 +12,7 @@ namespace ice::input { //! \brief Maximum number of pointers supported on a touchscreen device. - static constexpr ice::ucount Constant_MaxPointerCount = 6; + static constexpr ice::u32 Constant_MaxPointerCount = 6; static constexpr ice::input::detail::ControlConfig Constant_TouchControlConfig { .button_click_threshold = Constant_TouchScreenClickThreshold, @@ -27,12 +27,12 @@ namespace ice::input ice::input::DeviceHandle device ) noexcept; - auto max_count() const noexcept -> ice::ucount override + auto max_count() const noexcept -> ice::u32 override { return Constant_MaxPointerCount; } - auto count() const noexcept -> ice::ucount override + auto count() const noexcept -> ice::u32 override { return _pointer_count; } @@ -48,7 +48,7 @@ namespace ice::input void on_publish(ice::Array& events_out) noexcept override; private: - ice::ucount _pointer_count; + ice::u32 _pointer_count; ice::input::DeviceHandle _pointers[Constant_MaxPointerCount]; ice::vec2f _positions[Constant_MaxPointerCount]; @@ -169,7 +169,7 @@ namespace ice::input event.value_type = InputValueType::AxisFloat; - ice::ucount remaining = _pointer_count; + ice::u32 remaining = _pointer_count; for (ice::u32 idx = 0; idx < max_count() && remaining > 0; ++idx) { if (_pointers[idx] == DeviceHandle::Invalid) continue; diff --git a/source/code/systems/input_system/public/ice/input/input_device.hxx b/source/code/systems/input_system/public/ice/input/input_device.hxx index 9b7d7ba9..b9c10a00 100644 --- a/source/code/systems/input_system/public/ice/input/input_device.hxx +++ b/source/code/systems/input_system/public/ice/input/input_device.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -21,10 +21,10 @@ namespace ice::input //! \note In some cases, like a touch screen, a single touch pointer is seen as a single device. //! Multi touch is implemented using this value. //! \note A total of 15 different devices of the same type can be handled based on engine limits. - virtual auto max_count() const noexcept -> ice::ucount { return 1u; } + virtual auto max_count() const noexcept -> ice::u32 { return 1u; } //! \return Number of currently connected devices. - virtual auto count() const noexcept -> ice::ucount { return 1u; } + virtual auto count() const noexcept -> ice::u32 { return 1u; } //! \return Handle to a connected device. //! \note After accessing a handle, the user is still required to check if the handle valid. diff --git a/source/code/systems/resource_system/private/resource_filesystem_baked.cxx b/source/code/systems/resource_system/private/resource_filesystem_baked.cxx index 4b01cee5..50fcfedc 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_baked.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_baked.cxx @@ -114,7 +114,7 @@ namespace ice auto BakedFileResource::name() const noexcept -> ice::String { - return ice::string::substr(_uri.path(), 1); + return _uri.path().substr(1); } auto BakedFileResource::origin() const noexcept -> ice::String @@ -202,7 +202,7 @@ namespace ice IPT_ZONE_TEXT_STR(utf8_file_path); ice::HeapString<> utf8_uri{ alloc }; - ice::string::push_back(utf8_uri, uri_base); + utf8_uri.push_back(uri_base); char temp[128]; read = ice::native_file::read_file( @@ -210,7 +210,7 @@ namespace ice ); ICE_ASSERT_CORE(read >= 0_B); - ice::string::push_back(utf8_uri, { temp, header.name_size }); + utf8_uri.push_back(ice::String{ temp, header.name_size }); return ice::create_resource_object( alloc, diff --git a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx index d2eb7efe..197571ed 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx @@ -53,7 +53,7 @@ namespace ice ice::native_file::path_from_string(native_filepath, filepath); if (readmeta) { - ice::string::push_back(native_filepath, ISP_PATH_LITERAL(".isrm")); + native_filepath.push_back(ISP_PATH_LITERAL(".isrm")); } IPT_MESSAGE_STR(filepath); @@ -82,7 +82,7 @@ namespace ice ice::native_file::path_from_string(native_filepath, filepath); if (readmeta) { - ice::string::push_back(native_filepath, ISP_PATH_LITERAL(".isrm")); + native_filepath.push_back(ISP_PATH_LITERAL(".isrm")); } ice::native_file::File handle = ice::native_file::open_file(native_filepath); @@ -117,7 +117,7 @@ namespace ice ice::Memory metafile_data = alloc.allocate(meta_size); if (ice::native_file::read_file(meta_handle, meta_size, metafile_data) > 0_B) { - if (ice::config::from_json(out_metadata, ice::string::from_data(metafile_data))) + if (ice::config::from_json(out_metadata, ice::string_from_data(metafile_data))) { // return the memory, we won't release it out_memory = metafile_data; @@ -323,8 +323,8 @@ namespace ice // TODO: Decide how to handle the basepath naming. bool const remove_slash = utf8_file_path[ice::path::length(base_path)] == '/'; - ice::String utf8_origin_name = ice::string::substr(utf8_file_path, ice::path::length(base_path) + remove_slash); - ice::String utf8_uri_path = ice::string::substr(utf8_file_path, ice::path::length(uri_base_path)); + ice::String const utf8_origin_name = utf8_file_path.substr(ice::path::length(base_path) + remove_slash); + ice::String const utf8_uri_path = utf8_file_path.substr(ice::path::length(uri_base_path)); IPT_ZONE_SCOPED_NAMED("stage: create_resource"); main_resource = ice::create_resource_object( diff --git a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx index b3cb6985..90bbc92c 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx @@ -7,7 +7,6 @@ #include #include #include -#include #include #include @@ -51,9 +50,9 @@ namespace ice ice::native_file::FilePath const uribase = ice::path::directory(base_path); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; - ice::string::reserve(metafile, 512); - ice::string::push_back(metafile, file_path); - ice::string::push_back(metafile, ISP_PATH_LITERAL(".isrm")); + metafile.reserve(512); + metafile.push_back(file_path); + metafile.push_back(ISP_PATH_LITERAL(".isrm")); resource = _callbacks.create_loose_resource( base_path, @@ -104,9 +103,9 @@ namespace ice ice::native_file::FilePath const uribase = ice::path::directory(base_path); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; - ice::string::reserve(metafile, 512); - ice::string::push_back(metafile, file_path); - ice::string::push_back(metafile, ISP_PATH_LITERAL(".isrm")); + metafile.reserve(512); + metafile.push_back(file_path); + metafile.push_back(ISP_PATH_LITERAL(".isrm")); resource = _callbacks.create_loose_resource( base_path, diff --git a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx index 4239875e..1149fb8c 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx @@ -268,8 +268,8 @@ namespace ice // TODO: Decide how to handle the basepath naming. bool const remove_slash = utf8_file_path[ice::path::length(base_path)] == '/'; - ice::String utf8_origin_name = ice::string::substr(utf8_file_path, ice::path::length(base_path) + remove_slash); - ice::String utf8_uri_path = ice::string::substr(utf8_file_path, ice::path::length(uri_base_path)); + ice::String const utf8_origin_name = utf8_file_path.substr(ice::path::length(base_path) + remove_slash); + ice::String const utf8_uri_path = utf8_file_path.substr(ice::path::length(uri_base_path)); IPT_ZONE_SCOPED_NAMED("stage: create_writable_resource"); main_resource = ice::create_resource_object( diff --git a/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx b/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx index 038539fb..b6dbb86e 100644 --- a/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx +++ b/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx @@ -29,7 +29,7 @@ namespace ice { ice::usize const filesize = ice::native_file::sizeof_file(handle); ICE_ASSERT( - filesize.value < ice::ucount_max, + filesize.value < ice::u32_max, "Trying to load file larger than supported!" ); diff --git a/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx b/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx index 7130addb..1d4871e2 100644 --- a/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx +++ b/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx @@ -24,7 +24,7 @@ namespace ice virtual auto name() const noexcept -> ice::String override { - return ice::string::substr(_uri.path(), ice::string::find_first_of(_uri.path(), '.') + 5); + return _uri.path().substr(_uri.path().find_first_of('.') + 5); } virtual auto origin() const noexcept -> ice::String override { return _uri.path(); } diff --git a/source/code/systems/resource_system/private/resource_provider_custom.cxx b/source/code/systems/resource_system/private/resource_provider_custom.cxx index dffc22fc..13b93ebf 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.cxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_provider_custom.hxx" @@ -42,9 +42,9 @@ namespace ice ice::native_file::FilePath const uribase = ice::path::directory(base_path); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; - ice::string::reserve(metafile, 512); - ice::string::push_back(metafile, file_path); - ice::string::push_back(metafile, ISP_PATH_LITERAL(".isrm")); + metafile.reserve(512); + metafile.push_back(file_path); + metafile.push_back(ISP_PATH_LITERAL(".isrm")); ice::FileSystemResource* const resource = create_resources_from_loose_files( _allocator, @@ -73,7 +73,7 @@ namespace ice auto CustomResourceProvider::collect( ice::Array& out_changes - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { IPT_ZONE_SCOPED; @@ -135,17 +135,13 @@ namespace ice ice::Resource const* root_resource ) const noexcept -> ice::Resource const* { - ice::u32 const origin_size = ice::string::size(root_resource->origin()); + ice::ncount const origin_size = root_resource->origin().size(); ice::HeapString<> predicted_path{ _allocator }; - ice::string::reserve(predicted_path, origin_size + ice::string::size(relative_uri.path())); - - predicted_path = ice::string::substr( - root_resource->origin(), - 0, - origin_size - ice::string::size( - ice::path::filename(root_resource->name()) - ) + predicted_path.reserve(origin_size + relative_uri.path().size()); + + predicted_path = root_resource->origin().substr( + 0, origin_size - ice::path::filename(root_resource->name()).size() ); ice::path::join(predicted_path, relative_uri.path()); diff --git a/source/code/systems/resource_system/private/resource_provider_custom.hxx b/source/code/systems/resource_system/private/resource_provider_custom.hxx index c1116e70..15456f89 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.hxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -43,7 +43,7 @@ namespace ice auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; auto refresh( ice::Array& out_changes diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index 45fa1950..44068419 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_provider_filelist.hxx" @@ -43,14 +43,15 @@ namespace ice _named_allocator, entry.path ); - ICE_ASSERT_CORE(ice::string::starts_with((ice::native_file::FilePath)file_path, (ice::native_file::FilePath)base_path)); + ice::native_file::FilePath const file_path_str = file_path; + ICE_ASSERT_CORE(file_path_str.starts_with((ice::native_file::FilePath)base_path)); } - ice::ucount const basepath_size = ice::string::empty(entry.basepath) - ? ice::string::size(entry.path) - ice::string::size(ice::path::filename(entry.path)) - : ice::string::size(entry.basepath); + ice::ncount const basepath_size = entry.basepath.is_empty() + ? entry.path.size() - ice::path::filename(entry.path).size() + : entry.basepath.size(); - ice::array::push_back(_file_paths, { .path = file_path, .basepath_size = basepath_size, }); + ice::array::push_back(_file_paths, { .path = file_path, .basepath_size = basepath_size.u32() }); } } @@ -94,9 +95,9 @@ namespace ice ice::native_file::FilePath const uribase = ice::path::directory(base_path); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; - ice::string::reserve(metafile, 512); - ice::string::push_back(metafile, file_path); - ice::string::push_back(metafile, ISP_PATH_LITERAL(".isrm")); + metafile.reserve(512); + metafile.push_back(file_path); + metafile.push_back(ISP_PATH_LITERAL(".isrm")); resource = create_resources_from_loose_files( _named_allocator, @@ -134,7 +135,7 @@ namespace ice for (ice::FileListEntry const& entry : _file_paths) { create_resource_from_file( - ice::string::substr(entry.path, 0, entry.basepath_size), + entry.path.substr(0, entry.basepath_size), entry.path ); } @@ -142,7 +143,7 @@ namespace ice auto FileListResourceProvider::collect( ice::Array& out_changes - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { IPT_ZONE_SCOPED; @@ -225,17 +226,13 @@ namespace ice ice::Resource const* root_resource ) const noexcept -> ice::Resource const* { - ice::u32 const origin_size = ice::string::size(root_resource->origin()); + ice::ncount const origin_size = root_resource->origin().size(); ice::HeapString<> predicted_path{ (ice::Allocator&) _data_allocator }; - ice::string::reserve(predicted_path, origin_size + ice::string::size(relative_uri.path())); - - predicted_path = ice::string::substr( - root_resource->origin(), - 0, - origin_size - ice::string::size( - ice::path::filename(root_resource->name()) - ) + predicted_path.reserve(origin_size + relative_uri.path().size()); + + predicted_path = root_resource->origin().substr( + 0, origin_size - ice::path::filename(root_resource->name()).size() ); ice::path::join(predicted_path, relative_uri.path()); diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.hxx b/source/code/systems/resource_system/private/resource_provider_filelist.hxx index c1c1af8f..3e14c78a 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.hxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -25,7 +25,7 @@ namespace ice struct FileListEntry { ice::native_file::HeapFilePath path; - ice::ucount basepath_size; + ice::u32 basepath_size; }; class FileListResourceProvider; @@ -58,7 +58,7 @@ namespace ice auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; auto refresh( ice::Array& out_changes diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx index cbaec23b..b91ba569 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_provider_filesystem.hxx" @@ -57,9 +57,9 @@ namespace ice auto FileSystemResourceProvider::filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) noexcept -> ice::TaskExpected + ) noexcept -> ice::TaskExpected { - ice::ucount collected = 0; + ice::u32 collected = 0; for (ice::FileSystemResource const* resource : _resources) { if (filter.allows_resource(resource)) @@ -83,7 +83,7 @@ namespace ice ice::Memory metadata_mem{}; if (reinterpret_cast(metadata_data.location)[0] == '{') { - metadata = ice::config::from_json(_named_allocator, ice::string::from_data(metadata_data), metadata_mem); + metadata = ice::config::from_json(_named_allocator, ice::string_from_data(metadata_data), metadata_mem); } else { @@ -108,7 +108,7 @@ namespace ice auto FileSystemResourceProvider::collect( ice::Array& out_changes - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { IPT_ZONE_SCOPED; @@ -149,25 +149,25 @@ namespace ice "Trying to find resource for URI that is not handled by this provider." ); - if (ice::string::any(uri.host()) && _virtual_hostname != uri.host()) + if (uri.host().not_empty() && _virtual_hostname != uri.host()) { return nullptr; } ice::FileSystemResource* found_resource = nullptr; - ice::u32 const origin_size = ice::string::size(uri.path()); + ice::ncount const origin_size = uri.path().size(); ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; for (ice::native_file::FilePath base_path : _base_paths) { - ice::string::resize(predicted_path, 0); - ice::string::reserve(predicted_path, origin_size + ice::string::size(base_path)); + predicted_path.resize(0); + predicted_path.reserve(origin_size + base_path.size()); ice::native_file::path_to_string(base_path, predicted_path); // Remove one directory if neccessary, because it's may be the common value of the base path and the uri path. // Note: This is because if a base path like 'dir/subdir' is provided the uri is created against 'dir/' // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' - if (ice::string::back(base_path) != '/') + if (base_path.back() != '/') { ice::path::join(predicted_path, ".."); } @@ -215,17 +215,13 @@ namespace ice ice::Resource const* root_resource ) const noexcept -> ice::Resource const* { - ice::u32 const origin_size = ice::string::size(root_resource->origin()); + ice::ncount const origin_size = root_resource->origin().size(); ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; - ice::string::reserve(predicted_path, origin_size + ice::string::size(relative_uri.path())); - - predicted_path = ice::string::substr( - root_resource->origin(), - 0, - origin_size - ice::string::size( - ice::path::filename(root_resource->name()) - ) + predicted_path.reserve(origin_size + relative_uri.path().size()); + + predicted_path = root_resource->origin().substr( + 0, origin_size - ice::path::filename(root_resource->name()).size() ); ice::path::join(predicted_path, relative_uri.path()); diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.hxx b/source/code/systems/resource_system/private/resource_provider_filesystem.hxx index f5c4fe90..7ca268ad 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.hxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -47,11 +47,11 @@ namespace ice auto filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) noexcept -> ice::TaskExpected override; + ) noexcept -> ice::TaskExpected override; auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; auto refresh( ice::Array& out_changes diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx index d8eb8fc4..d02f0e4e 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx @@ -25,7 +25,7 @@ namespace ice { if (ImGui::BeginMenu("Resource Providers", true)) { - ImGui::MenuItem(ice::string::begin(widget_info.name), nullptr, &state.active); + ImGui::MenuItem(widget_info.name.begin(), nullptr, &state.active); ImGui::EndMenu(); } return false; @@ -84,7 +84,7 @@ namespace ice ice::u32 idx = 1; // We start with '1' since the first entry are the headers. for (ice::FileSystemResource* const res : ice::hashmap::values(_resources)) { - if (strstr(ice::string::begin(res->name()), _filter) == nullptr) + if (strstr(res->name().begin(), _filter) == nullptr) { continue; } @@ -100,11 +100,11 @@ namespace ice continue; } - ImGui::TextUnformatted(ice::string::begin(res->name()), ice::string::end(res->name())); + ImGui::TextUnformatted(res->name()); if (ImGui::TableNextColumn()) { - ImGui::TextUnformatted(ice::string::begin(res->origin()), ice::string::end(res->origin())); + ImGui::TextUnformatted(res->origin()); } if (ImGui::TableNextColumn()) diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx index 2415aa4b..d78dddec 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_aio_request.hxx" @@ -268,10 +268,10 @@ namespace ice } ice::HeapString<> prefix{ _allocator, _packname }; - ice::string::push_back(prefix, "/"); + prefix.push_back("/"); ice::usize::base_type const size_extended_paths = hailstorm::v1::prefixed_resource_paths_size( - _pack.paths, (ice::ucount)_pack.resources.size(), ice::String{ prefix } + _pack.paths, (ice::u32)_pack.resources.size(), ice::String{ prefix } ); // We allocate enough memory to keep all original paths prefixed with the resource file name and a slash. @@ -293,7 +293,7 @@ namespace ice bool const prefixing_success = v1::prefix_resource_paths( _pack.paths, - { resptr, (ice::ucount)_pack.resources.size() }, + { resptr, (ice::u32)_pack.resources.size() }, { _paths_memory.location, _paths_memory.size.value, (size_t)_paths_memory.alignment }, ice::String{ prefix } ); @@ -415,7 +415,7 @@ namespace ice ) noexcept -> ice::TaskExpected { hailstorm::HailstormResource const& hsres = static_cast(resource)->_handle; - if (ice::string::size(fragment) && fragment == "meta") + if (fragment.not_empty() && fragment == "meta") { co_return co_await _loaders[hsres.meta_chunk]->request_slice(hsres.meta_offset, hsres.meta_size, _aioport); } diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx index 094f7c5f..e1dff74a 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx @@ -96,7 +96,7 @@ namespace ice { if (ImGui::BeginMenu("Resource Providers", true)) { - ImGui::MenuItem(ice::string::begin(widget_info.name), nullptr, &state.active); + ImGui::MenuItem(widget_info.name.begin(), nullptr, &state.active); ImGui::EndMenu(); } return false; @@ -223,7 +223,7 @@ namespace ice void HailStormResourceProvider::DevUI::build_resources_table() noexcept { - ice::u32 const pack_name_size = ice::string::size(_name) + 1; + ice::u32 const pack_name_size = _name.size().u32() + 1; ice::u32 const entry_count = 20; ice::u32 const entry_size = static_cast(ImGui::GetTextLineHeightWithSpacing()); diff --git a/source/code/systems/resource_system/private/resource_tracker.cxx b/source/code/systems/resource_system/private/resource_tracker.cxx index b6262904..effd05b4 100644 --- a/source/code/systems/resource_system/private/resource_tracker.cxx +++ b/source/code/systems/resource_system/private/resource_tracker.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_tracker.hxx" @@ -153,7 +153,7 @@ namespace ice ice::ResourceProvider& provider, ice::ResourceFilter const& filter, ice::Array& out_uris - ) const noexcept -> ice::TaskExpected + ) const noexcept -> ice::TaskExpected { co_return co_await provider.filter_resource_uris(filter, out_uris); } @@ -161,9 +161,9 @@ namespace ice auto ResourceTrackerImplementation::filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) const noexcept -> ice::TaskExpected + ) const noexcept -> ice::TaskExpected { - ice::ucount collected = 0; + ice::u32 collected = 0; for (ice::UniquePtr const& provider : _resource_providers) { static constexpr ice::String const keywords[]{ "blocked", "allowed" }; @@ -346,7 +346,7 @@ namespace ice return; } - ice::ucount const new_count = ice::hashmap::count(_resources) + ice::array::count(out_resources); + ice::u32 const new_count = ice::hashmap::count(_resources) + ice::array::count(out_resources); ICE_ASSERT( new_count <= _info.predicted_resource_count, "Maximum resource capacity of {} entiries reached!", @@ -473,15 +473,15 @@ namespace ice { if constexpr (ice::build::is_windows) { - ice::string::push_back(result, ".dll"); + result.push_back(".dll"); } else { // On unix we expect the library to be prepended with 'lib' and appended with '.so' - ice::string::clear(result); - ice::string::push_back(result, "lib"); - ice::string::push_back(result, name); - ice::string::push_back(result, ".so"); + result.clear(); + result.push_back("lib"); + result.push_back(name); + result.push_back(".so"); } } diff --git a/source/code/systems/resource_system/private/resource_tracker.hxx b/source/code/systems/resource_system/private/resource_tracker.hxx index 9853a290..90732735 100644 --- a/source/code/systems/resource_system/private/resource_tracker.hxx +++ b/source/code/systems/resource_system/private/resource_tracker.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -153,12 +153,12 @@ namespace ice ice::ResourceProvider& provider, ice::ResourceFilter const& filter, ice::Array& out_uris - ) const noexcept -> ice::TaskExpected; + ) const noexcept -> ice::TaskExpected; auto filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) const noexcept -> ice::TaskExpected override; + ) const noexcept -> ice::TaskExpected override; auto set_resource( diff --git a/source/code/systems/resource_system/private/resource_tracker_devui.cxx b/source/code/systems/resource_system/private/resource_tracker_devui.cxx index 93f1630d..e6a3531b 100644 --- a/source/code/systems/resource_system/private/resource_tracker_devui.cxx +++ b/source/code/systems/resource_system/private/resource_tracker_devui.cxx @@ -6,10 +6,7 @@ #include #include -#include - -#include -#undef assert +#include namespace ice { @@ -79,12 +76,12 @@ namespace ice { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::TextUnformatted(ice::string::begin(handle->name()), ice::string::end(handle->name())); + ImGui::TextUnformatted(handle->name()); if (ImGui::TableNextColumn()) { detail::status_flags_string(ice::internal_status(handle), temp_str); - ImGui::Text(ice::string::begin(temp_str), ice::string::end(temp_str)); + ImGui::TextUnformatted(temp_str); } } @@ -96,28 +93,28 @@ namespace ice { using enum ice::ResourceStatus; - ice::string::clear(out_str); + out_str.clear(); if (ice::has_all(flags, Available)) { - ice::string::push_back(out_str, "Available | "); + out_str.push_back("Available | "); } if (ice::has_all(flags, Loading)) { - ice::string::push_back(out_str, "Loading | "); + out_str.push_back("Loading | "); } if (ice::has_all(flags, Loaded)) { - ice::string::push_back(out_str, "Loaded | "); + out_str.push_back("Loaded | "); } if (ice::has_all(flags, Unloading)) { - ice::string::push_back(out_str, "Unloading | "); + out_str.push_back("Unloading | "); } if (flags == Invalid) { out_str = ice::String{ "Invalid | " }; } - ice::string::pop_back(out_str, 3); + out_str.pop_back(3); } } // namespace ice diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx index cbfeeaf0..c6303aad 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_writer_filesystem.hxx" @@ -52,9 +52,9 @@ namespace ice auto FileSystemResourceWriter::filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) noexcept -> ice::TaskExpected + ) noexcept -> ice::TaskExpected { - ice::ucount collected = 0; + ice::u32 collected = 0; for (ice::FileSystemResource const* resource : _resources) { if (filter.allows_resource(resource)) @@ -78,7 +78,7 @@ namespace ice ice::Memory metadata_mem{}; if (reinterpret_cast(metadata_data.location)[0] == '{') { - metadata = ice::config::from_json(_named_allocator, ice::string::from_data(metadata_data), metadata_mem); + metadata = ice::config::from_json(_named_allocator, ice::string_from_data(metadata_data), metadata_mem); } else { @@ -103,7 +103,7 @@ namespace ice auto FileSystemResourceWriter::collect( ice::Array& out_changes - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { IPT_ZONE_SCOPED; @@ -144,22 +144,22 @@ namespace ice "Trying to find resource for URI that is not handled by this provider." ); - if (ice::string::any(uri.host()) && _virtual_hostname != uri.host()) + if (uri.host().not_empty() && _virtual_hostname != uri.host()) { return nullptr; } - ice::u32 const origin_size = ice::string::size(uri.path()); + ice::ncount const origin_size = uri.path().size(); ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; - ice::string::resize(predicted_path, 0); - ice::string::reserve(predicted_path, origin_size + ice::string::size(_base_path)); + predicted_path.resize(0); + predicted_path.reserve(origin_size + _base_path.size()); ice::native_file::path_to_string(_base_path, predicted_path); // Remove one directory if neccessary, because it's may be the common value of the base path and the uri path. // Note: This is because if a base path like 'dir/subdir' is provided the uri is created against 'dir/' // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' - if (ice::string::back(_base_path) != '/') + if (_base_path.back() != '/') { ice::path::join(predicted_path, ".."); } @@ -201,17 +201,13 @@ namespace ice ice::Resource const* root_resource ) const noexcept -> ice::Resource const* { - ice::u32 const origin_size = ice::string::size(root_resource->origin()); + ice::ncount const origin_size = root_resource->origin().size(); ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; - ice::string::reserve(predicted_path, origin_size + ice::string::size(relative_uri.path())); - - predicted_path = ice::string::substr( - root_resource->origin(), - 0, - origin_size - ice::string::size( - ice::path::filename(root_resource->name()) - ) + predicted_path.reserve(origin_size + relative_uri.path().size()); + + predicted_path = root_resource->origin().substr( + 0, origin_size - ice::path::filename(root_resource->name()).size() ); ice::path::join(predicted_path, relative_uri.path()); @@ -240,23 +236,23 @@ namespace ice co_return existing; } - ice::ucount predicted_path_len = 0; + ice::ncount predicted_path_len = 0; ice::native_file::HeapFilePath predicted_metapath{ (ice::Allocator&)_named_allocator }; ICE_ASSERT_CORE(flags != ResourceCreationFlags::Append); // TODO // TODO: move into a utility function { - ice::u32 const origin_size = ice::string::size(uri.path()); + ice::ncount const origin_size = uri.path().size(); - ice::string::resize(predicted_metapath, 0); - ice::string::reserve(predicted_metapath, origin_size + ice::string::size(_base_path)); + predicted_metapath.resize(0); + predicted_metapath.reserve(origin_size + _base_path.size()); ice::path::join(predicted_metapath, _base_path); // Remove one directory if neccessary, because it's may be the common value of the base path and the uri path. // Note: This is because if a base path like 'dir/subdir' is provided the uri is created against 'dir/' // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' - if (ice::string::back(_base_path) != '/') + if (_base_path.back() != '/') { ice::path::join(predicted_metapath, ISP_PATH_LITERAL("..")); } @@ -265,8 +261,8 @@ namespace ice // Metapath is the actuall file path + .isrm, so we just save the lenght before the appending // to have access to both paths. - predicted_path_len = ice::string::size(predicted_metapath); - ice::string::push_back(predicted_metapath, ISP_PATH_LITERAL(".isrm")); + predicted_path_len = predicted_metapath.size(); + predicted_metapath.push_back(ISP_PATH_LITERAL(".isrm")); // Create the final directory // #TODO: Research if checking for existance improves performance. @@ -278,7 +274,7 @@ namespace ice _base_path, ice::path::directory(_base_path), predicted_metapath, - ice::string::substr(predicted_metapath, 0, predicted_path_len) + predicted_metapath.substr(0, predicted_path_len) ); if (register_resource(new_resource) != S_Ok) diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.hxx b/source/code/systems/resource_system/private/resource_writer_filesystem.hxx index 4be6ef51..7fcc0968 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.hxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -46,11 +46,11 @@ namespace ice auto filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) noexcept -> ice::TaskExpected override; + ) noexcept -> ice::TaskExpected override; auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; auto refresh( ice::Array& out_changes diff --git a/source/code/systems/resource_system/public/ice/resource_filter.hxx b/source/code/systems/resource_system/public/ice/resource_filter.hxx index 144aba56..3459fef4 100644 --- a/source/code/systems/resource_system/public/ice/resource_filter.hxx +++ b/source/code/systems/resource_system/public/ice/resource_filter.hxx @@ -1,3 +1,6 @@ +/// Copyright 2025 - 2025, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include #include @@ -39,14 +42,14 @@ namespace ice bool allows_hostname(ice::String hostname) const noexcept override { - return ice::string::empty(_hostname) || hostname == _hostname; + return _hostname.is_empty() || hostname == _hostname; } bool allows_resource( ice::Resource const* resource ) const noexcept override { - return ice::string::empty(_extension) || ice::path::extension(resource->origin()) == _extension; + return _extension.is_empty() || ice::path::extension(resource->origin()) == _extension; } private: diff --git a/source/code/systems/resource_system/public/ice/resource_provider.hxx b/source/code/systems/resource_system/public/ice/resource_provider.hxx index a726bd09..e553dd7c 100644 --- a/source/code/systems/resource_system/public/ice/resource_provider.hxx +++ b/source/code/systems/resource_system/public/ice/resource_provider.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -35,14 +35,14 @@ namespace ice virtual auto filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) noexcept -> ice::TaskExpected + ) noexcept -> ice::TaskExpected { co_return 0; } virtual auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { return 0; } diff --git a/source/code/systems/resource_system/public/ice/resource_tracker.hxx b/source/code/systems/resource_system/public/ice/resource_tracker.hxx index 55b07998..01f1a765 100644 --- a/source/code/systems/resource_system/public/ice/resource_tracker.hxx +++ b/source/code/systems/resource_system/public/ice/resource_tracker.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -85,7 +85,7 @@ namespace ice virtual auto filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) const noexcept -> ice::TaskExpected = 0; + ) const noexcept -> ice::TaskExpected = 0; virtual auto set_resource( diff --git a/source/code/systems/resource_system/public/ice/uri.hxx b/source/code/systems/resource_system/public/ice/uri.hxx index de5817c8..1bc65cba 100644 --- a/source/code/systems/resource_system/public/ice/uri.hxx +++ b/source/code/systems/resource_system/public/ice/uri.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -79,12 +79,12 @@ namespace ice constexpr bool get_scheme_size(ice::String raw_uri, ice::u8& out_size) noexcept { - ice::ucount const scheme_end = ice::string::find_first_of(raw_uri, ':'); - if (scheme_end != ice::String_NPos) + ice::nindex const scheme_end = raw_uri.find_first_of(':'); + if (scheme_end.is_valid()) { - out_size = static_cast(scheme_end + 1); + out_size = scheme_end.u8() + 1; } - return scheme_end != ice::String_NPos; + return scheme_end.is_valid(); } constexpr bool get_authority_sizes( @@ -97,39 +97,39 @@ namespace ice { if (uri[0] == '/' && uri[1] == '/') { - ice::ucount const authority_end = ice::string::find_first_of(uri, '/', 2); - ICE_ASSERT_CORE(authority_end != ice::String_NPos); - if (authority_end == ice::String_NPos) + ice::nindex const authority_end = uri.find_first_of('/', 2); + ICE_ASSERT_CORE(authority_end.is_valid()); + if (authority_end.is_valid() == false) { return false; } - out_authority = static_cast(authority_end); + out_authority = authority_end.u8(); - ice::ucount offset = 0; - ice::String const authority_uri = ice::string::substr(uri, 2, authority_end - 2); - ice::ucount const authority_user = ice::string::find_first_of(authority_uri, '@', offset); - if (authority_user != ice::String_NPos) + ice::nindex offset = 0; + ice::String const authority_uri = uri.substr(2, authority_end.u32() - 2); + ice::nindex const authority_user = authority_uri.find_first_of('@', offset); + if (authority_user.is_valid()) { // Include the '@' character in the size, since it can be easily removed in the 'userinfo()' method // and helps with calculations. - offset = out_user = static_cast(authority_user - offset) + 1; + offset = out_user = (authority_user - offset).u8() + 1; } - ice::ucount const authority_port = ice::string::find_first_of(authority_uri, ':', offset); - if (authority_port != ice::String_NPos) + ice::nindex const authority_port = authority_uri.find_first_of(':', offset); + if (authority_port.is_valid()) { // If we have a port set the length of host to up to the ':' character - out_host = static_cast(authority_port - offset); + out_host = (authority_port - offset).u8(); // After that it's the 'port' value (without the ':') character // Because the host needs to exist we can always add +1, and keep the port size the actual size. - out_port = static_cast(ice::size(authority_uri) - (authority_port + 1)); + out_port = (authority_uri.size() - (authority_port + 1)).u8(); } else { // The rest of the authority string is the host - out_host = static_cast(ice::size(authority_uri) - offset); + out_host = (authority_uri.size() - offset).u8(); } } return true; @@ -142,34 +142,34 @@ namespace ice ice::u8& out_fragment ) noexcept { - ice::ucount path_separator = ice::string::find_first_of(uri, ice::String{ "?#" }); - if (path_separator == ice::String_NPos) + ice::nindex path_separator = uri.find_first_of("?#"); + if (path_separator == none_index) { - out_path = static_cast(ice::size(uri)); + out_path = uri.size().u8(); return out_path > 0; } // We continue after assigning path length - out_path = static_cast(path_separator); + out_path = path_separator.u8(); // Do we have a query? if (uri[path_separator] == '?') { // Get the next separator if necessary - path_separator = ice::string::find_last_of(uri, '#'); - if (path_separator == ice::String_NPos) + path_separator = uri.find_last_of('#'); + if (path_separator == none_index) { // We take te remaining query with the starting '?' character - out_query = static_cast(ice::size(uri) - out_path); + out_query = (uri.size() - out_path).u8(); return true; } // The everything up to '#' including the '?' character. - out_query = static_cast(path_separator - out_path); + out_query = (path_separator - out_path).u8(); } // Take everything remaining including the '#' character. - out_fragment = static_cast(ice::size(uri) - path_separator); + out_fragment = (uri.size() - path_separator).u8(); return true; } @@ -195,7 +195,7 @@ namespace ice } constexpr URI::URI(ice::String uri_raw) noexcept - : _uri{ ice::string::begin(uri_raw) } + : _uri{ uri_raw.begin() } , _forced_scheme{ } , _scheme{ } , _authority{ } @@ -212,11 +212,11 @@ namespace ice _scheme = scheme_size; } detail::get_authority_sizes( - ice::string::substr(uri_raw, _scheme), + uri_raw.substr(_scheme), _authority, _userinfo, _host, _port ); detail::get_path_query_fragment_sizes( - ice::string::substr(uri_raw, _scheme + _authority), + uri_raw.substr(_scheme + _authority), _path, _query, _fragment ); } @@ -300,7 +300,7 @@ namespace ice constexpr auto URI::userinfo() const noexcept -> ice::String { - return ice::String{ _uri + _scheme + 2 /* removes '//' */, ice::ucount(_userinfo - (_userinfo != 0)) }; + return ice::String{ _uri + _scheme + 2 /* removes '//' */, ice::u32(_userinfo - (_userinfo != 0)) }; } constexpr auto URI::host() const noexcept -> ice::String @@ -316,7 +316,7 @@ namespace ice // Helpers constexpr auto operator""_uri(char const* raw_uri, std::size_t length) noexcept -> ice::URI { - return URI{ ice::String{ raw_uri, ice::ucount(length) } }; + return URI{ ice::String{ raw_uri, length } }; } } // namespace ice diff --git a/source/code/systems/resource_system/resource_system_tests.bff b/source/code/systems/resource_system/resource_system_tests.bff index 9e048925..c6d15ab2 100644 --- a/source/code/systems/resource_system/resource_system_tests.bff +++ b/source/code/systems/resource_system/resource_system_tests.bff @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT .Project = diff --git a/source/code/systems/resource_system/tests/test_resource_meta.cxx b/source/code/systems/resource_system/tests/test_resource_meta.cxx index 147960a0..6430ffb5 100644 --- a/source/code/systems/resource_system/tests/test_resource_meta.cxx +++ b/source/code/systems/resource_system/tests/test_resource_meta.cxx @@ -14,7 +14,7 @@ namespace Catch { static std::string convert(ice::String const& value) { - return StringMaker::convert({ value._data, value._size }); + return StringMaker::convert(value); } }; } @@ -59,6 +59,8 @@ SCENARIO("resource_system 'ice/resource_meta.hxx'", "[resource][metadata]") REQUIRE(meta._data != nullptr); ice::String meta_name; + meta_name == "asd"; + CHECK(ice::config::get(meta, "name", meta_name)); CHECK(meta_name == "foo"); diff --git a/source/code/test/private/game.cxx b/source/code/test/private/game.cxx index 844a2231..839c2960 100644 --- a/source/code/test/private/game.cxx +++ b/source/code/test/private/game.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "game.hxx" @@ -156,7 +156,7 @@ struct TestTrait : public ice::Trait update.engine.entity_index().destroy_many(_my_entity); query().tags().for_each_block( - [&](ice::ucount count, ice::ecs::Entity const* entities) noexcept + [&](ice::u32 count, ice::ecs::Entity const* entities) noexcept { _ops->destroy({ entities, count }); } @@ -173,9 +173,9 @@ struct TestTrait : public ice::Trait ice::Array> tasks{ update.frame.allocator() }; ice::array::reserve(tasks, q.block_count()); - q.for_each_block([&](ice::ucount count, C1* c1p, C2* c2p) noexcept + q.for_each_block([&](ice::u32 count, C1* c1p, C2* c2p) noexcept { - ice::array::push_back(tasks, [](ice::ucount count, C1* c1p, C2* c2p) noexcept -> ice::Task<> + ice::array::push_back(tasks, [](ice::u32 count, C1* c1p, C2* c2p) noexcept -> ice::Task<> { IPT_ZONE_SCOPED_NAMED("block for-each"); for (ice::u32 idx = 0; idx < count; ++idx) diff --git a/source/code/test/private/input_actions.cxx b/source/code/test/private/input_actions.cxx index 60362b32..8fd1709e 100644 --- a/source/code/test/private/input_actions.cxx +++ b/source/code/test/private/input_actions.cxx @@ -60,7 +60,7 @@ namespace ice ice::Data const data = co_await script[AssetState::Raw]; if (data.location != nullptr) { - _layers = ice::parse_input_action_layer(_allocator, ice::string::from_data(data)); + _layers = ice::parse_input_action_layer(_allocator, ice::string_from_data(data)); } diff --git a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx index 5e0373f3..ac2dfd99 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -46,7 +46,7 @@ class AssetCompilerApp : public ice::tool::ToolApp { ice::array::push_back( self._params, - ice::shard(results[0], ice::string::begin(results[1])) + ice::shard(results[0], results[1].begin()) ); } if (ice::count(results) == 1) @@ -149,7 +149,7 @@ class AssetCompilerApp : public ice::tool::ToolApp } ICE_LOG_IF( - Param_Verbose && (_output_std == false && ice::string::empty(_output)), + Param_Verbose && (_output_std == false && _output.is_empty()), ice::LogSeverity::Retail, ice::LogTag::Tool, "No output was selected, please use '-o,--output' or '--stdout'!" ); @@ -160,7 +160,7 @@ class AssetCompilerApp : public ice::tool::ToolApp { .predicted_resource_count = 10'000, .io_dedicated_threads = 0 } ); - if (ice::string::empty(_asset_basepath)) + if (_asset_basepath.is_empty()) { _asset_basepath = ice::app::workingdir(); } @@ -194,7 +194,7 @@ class AssetCompilerApp : public ice::tool::ToolApp ); ice::HeapString<> uristr{ _allocator, "file://" }; - ice::string::push_back(uristr, input_resource->uri().path()); + uristr.push_back(input_resource->uri().path()); ice::ResourceHandle res = resource_tracker->find_resource(ice::URI{ uristr }); if (res == nullptr) @@ -221,7 +221,7 @@ class AssetCompilerApp : public ice::tool::ToolApp continue; } - ice::ucount out_idx = 0; + ice::u32 out_idx = 0; if (ice::search(compiler.fn_supported_resources(_params), res_ext, out_idx)) { resource_compiler = &compiler; @@ -264,7 +264,7 @@ class AssetCompilerApp : public ice::tool::ToolApp return 1; } - ice::ucount out_idx = 0; + ice::u32 out_idx = 0; if (ice::search(resource_compiler->fn_supported_resources(_params), res_ext, out_idx) == false) { ICE_LOG(ice::LogSeverity::Critical, ice::LogTag::Tool, "Resource compiler for resource '{}' is not available.", res->name()); @@ -281,25 +281,25 @@ class AssetCompilerApp : public ice::tool::ToolApp } // If no name was provided use the input name and replace the extension is needed - if (ice::string::empty(final_asset_name)) + if (final_asset_name.is_empty()) { final_asset_name = input_resource->name(); // Replace the extension if a result extension is provided. - if (ice::string::any(result_extension)) + if (result_extension.not_empty()) { ice::path::replace_extension(final_asset_name, result_extension); } } // If asset name has no extension, attach the result extension - else if (ice::string::empty(ice::path::extension(final_asset_name))) + else if (ice::path::extension(final_asset_name).is_empty()) { ice::path::replace_extension(final_asset_name, result_extension); } // Warn if the final extension is different than what the resource compiler expects. ICE_LOG_IF( - ice::string::any(result_extension) && ice::path::extension(final_asset_name) != result_extension, + result_extension.not_empty() && ice::path::extension(final_asset_name) != result_extension, ice::LogSeverity::Warning, ice::LogTag::Tool, "Asset compiler result extension '{}' differs from provided asset name extension {}!", result_extension, ice::path::extension(final_asset_name) @@ -381,13 +381,13 @@ class AssetCompilerApp : public ice::tool::ToolApp return 1; } - if (ice::string::any(_output)) + if (_output.not_empty()) { ice::Memory const final_meta_data = meta.finalize(_allocator); // Calc meta offset ice::AlignResult const meta_offset = ice::align_to( - (ice::u32)sizeof(ice::ResourceFormatHeader) + ice::string::size(final_asset_name) + 1, + (ice::u32)sizeof(ice::ResourceFormatHeader) + final_asset_name.size().u32() + 1, ice::ualign::b_8 ); @@ -395,7 +395,7 @@ class AssetCompilerApp : public ice::tool::ToolApp ice::ResourceFormatHeader const rfh{ .magic = ice::Constant_ResourceFormatMagic, .version = ice::Constant_ResourceFormatVersion, - .name_size = ice::string::size(final_asset_name), + .name_size = final_asset_name.size().u32(), .meta_offset = meta_offset.value, .meta_size = static_cast(final_meta_data.size.value), .offset = (ice::u32)(meta_offset.value + final_meta_data.size.value), @@ -409,7 +409,7 @@ class AssetCompilerApp : public ice::tool::ToolApp char const filler[8]{ 0 }; ice::Data const file_parts[]{ ice::data_view(rfh), // Header - ice::string::data_view(final_asset_name), // Name + final_asset_name.data_view(), // Name ice::Data{ &filler, 1, ice::ualign::b_1 }, ice::Data{ &filler, meta_offset.padding, ice::ualign::b_1 }, ice::data_view(final_meta_data), // Metadata @@ -430,7 +430,7 @@ class AssetCompilerApp : public ice::tool::ToolApp if (_output_std) { - fmt::println("{}", ice::String{ (char const*)final_asset_data.location, (ice::ucount)final_asset_data.size.value }); + fmt::println("{}", ice::String{ (char const*)final_asset_data.location, (ice::u32)final_asset_data.size.value }); } _allocator.deallocate(final_asset_data); diff --git a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx index 7527a88e..9b69e3a0 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_compiler_resource_provider.hxx" @@ -18,7 +18,7 @@ AssetCompilerResource::AssetCompilerResource( { ice::native_file::HeapFilePath metapath{ _allocator }; ice::native_file::path_from_string(metapath, _path); - ice::string::push_back(metapath, ISP_PATH_LITERAL(".isrm")); + metapath.push_back(ISP_PATH_LITERAL(".isrm")); if (auto metafile = ice::native_file::open_file(metapath, ice::native_file::FileOpenFlags::Read); file) { @@ -98,7 +98,7 @@ AssetCompilerResourceProvider::~AssetCompilerResourceProvider() noexcept auto AssetCompilerResourceProvider::collect( ice::Array& out_changes -) noexcept -> ice::ucount +) noexcept -> ice::u32 { return 0; } diff --git a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx index 3e274233..e06b09d3 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -46,7 +46,7 @@ public: auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; auto refresh( ice::Array& out_changes diff --git a/source/code/tools/hsc_packer/private/hsc_packer.cxx b/source/code/tools/hsc_packer/private/hsc_packer.cxx index 23cefb4b..75cd699b 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -152,7 +152,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp ice::Memory configmem; ice::Config const config = ice::config::from_json( _allocator, - ice::String{ (char const*)filemem.location, (ice::ucount)filemem.size.value }, + ice::String{ (char const*)filemem.location, (ice::u32)filemem.size.value }, configmem ); diff --git a/source/code/tools/hsc_reader/private/hsc_reader_app.cxx b/source/code/tools/hsc_reader/private/hsc_reader_app.cxx index 8e1e110f..b0627fa5 100644 --- a/source/code/tools/hsc_reader/private/hsc_reader_app.cxx +++ b/source/code/tools/hsc_reader/private/hsc_reader_app.cxx @@ -20,7 +20,7 @@ bool ParamRange::param_parse_results(ParamRange& range, ice::Span ice::native_file::HeapFilePath searched_utf8_path{ global_allocator(), path }; if (ice::path::is_absolute(path) == false) { - ice::string::clear(searched_utf8_path); + searched_utf8_path.clear(); ice::path::join(searched_utf8_path, ice::tool::path_current_directory()); ice::path::join(searched_utf8_path, path); } From 1a5677e07434d4b1aa8e936e5e47f05c68a7a7d9 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sun, 4 Jan 2026 23:23:22 +0900 Subject: [PATCH 02/40] Removal of old includes. --- .../code/core/collections/public/ice/span.hxx | 2 +- .../collections/public/ice/static_string.hxx | 6 + .../core/collections/public/ice/string.hxx | 36 +++- .../public/ice/string/heap_string.hxx | 5 - .../public/ice/string/heap_var_string.hxx | 48 ----- .../ice/string/impl/heap_var_string.inl | 192 ------------------ .../public/ice/string/impl/var_string.inl | 100 --------- .../ice/string/resizable_operations.hxx | 2 +- .../collections/public/ice/string/string.hxx | 5 - .../public/ice/string/var_string.hxx | 129 ------------ .../collections/public/ice/string_types.hxx | 31 --- .../collections/public/ice/types/ncount.hxx | 2 +- .../collections/tests/test_heap_string.cxx | 2 +- .../collections/tests/test_static_string.cxx | 2 +- .../tests/util_tracking_object.hxx | 2 +- source/code/core/core/public/ice/base.hxx | 2 +- .../code/core/core/public/ice/constants.hxx | 2 +- source/code/core/core/public/ice/profiler.hxx | 2 +- source/code/core/core/public/ice/types.hxx | 2 +- .../code/core/core/public/ice/types/ref.hxx | 2 +- .../core/core/public/ice/types_extended.hxx | 2 +- .../code/core/devui/private/devui_imgui.cxx | 4 +- .../core/devui/public/ice/devui_context.hxx | 4 +- .../core/devui/public/ice/devui_imgui.hxx | 4 +- .../core/devui/public/ice/devui_module.hxx | 4 +- .../core/devui/public/ice/devui_widget.hxx | 4 +- .../memsys/private/mem_allocator_forward.cxx | 2 +- .../memsys/private/mem_allocator_snake.cxx | 2 +- .../public/ice/mem_allocator_forward.hxx | 2 +- .../memsys/public/ice/mem_allocator_snake.hxx | 2 +- .../memsys/public/ice/mem_allocator_utils.hxx | 2 +- .../code/core/memsys/public/ice/mem_data.hxx | 2 +- .../code/core/memsys/public/ice/mem_utils.hxx | 2 +- .../core/modules/private/module_native.cxx | 4 +- .../core/modules/private/module_native.hxx | 4 +- .../core/modules/private/module_register.cxx | 2 +- .../modules/public/ice/module_concepts.hxx | 2 +- .../tasks/private/task_thread_pool_impl.cxx | 2 +- .../core/tasks/public/ice/impl/task_utils.inl | 2 +- .../tasks/public/ice/task_debug_allocator.hxx | 2 +- .../public/ice/task_expected_promise.hxx | 2 +- .../code/core/tasks/public/ice/task_utils.hxx | 2 +- source/code/core/utils/private/assert.cxx | 4 +- .../utils/private/config/config_builder.cxx | 4 +- .../private/config/config_builder_types.hxx | 6 +- .../private/config/config_builder_utils.cxx | 4 +- .../private/config/config_builder_value.cxx | 2 +- .../core/utils/private/config_getters.cxx | 2 +- source/code/core/utils/private/log.cxx | 4 +- .../code/core/utils/private/log_internal.cxx | 2 +- .../code/core/utils/private/log_internal.hxx | 2 +- source/code/core/utils/private/params.cxx | 4 +- source/code/core/utils/private/path_utils.cxx | 4 +- .../code/core/utils/private/string_utils.cxx | 2 +- .../public/ice/config/config_details.hxx | 4 +- .../code/core/utils/public/ice/expected.hxx | 2 +- source/code/core/utils/public/ice/log.hxx | 4 +- .../core/utils/public/ice/log_formatters.hxx | 2 +- .../code/core/utils/public/ice/log_sink.hxx | 4 +- source/code/core/utils/public/ice/log_tag.hxx | 4 +- .../code/core/utils/public/ice/native_aio.hxx | 2 +- .../core/utils/public/ice/params_types.hxx | 4 +- .../code/core/utils/public/ice/path_utils.hxx | 2 +- .../core/utils/public/ice/string_utils.hxx | 6 +- source/code/core/utils/utils_tests.bff | 2 +- .../framework_base/private/framework_main.cxx | 4 +- .../private/traits/trait_sprite_animator.cxx | 2 +- .../private/traits/ui/game_ui_trait.cxx | 2 +- .../iceshard/engine/private/world_trait.cxx | 2 +- .../public/ice/action/action_trigger.hxx | 4 +- .../engine/public/ice/ecs/ecs_concepts.hxx | 4 +- .../public/ice/engine_asset_categories.hxx | 2 +- .../iceshard_gfx_image_storage_trait.cxx | 2 +- .../iceshard_gfx_image_storage_trait.hxx | 2 +- .../private/pipeline_ui/ip_ui_oven.hxx | 4 +- .../imgui_module/private/imgui_system.cxx | 4 +- .../imgui_module/private/imgui_trait.cxx | 2 +- .../private/widgets/imgui_allocator_tree.cxx | 2 +- .../private/widgets/imgui_logger.cxx | 4 +- .../private/shader_tools_glsl.hxx | 4 +- .../private/shader_tools_wgsl.cxx | 2 +- .../private/shader_tools_wgsl.hxx | 4 +- .../vulkan_renderer/private/vk_swapchain.cxx | 2 +- .../vulkan_renderer/private/vk_utility.hxx | 2 +- .../application/private/app_info.cxx | 2 +- .../platform/public/ice/platform_event.hxx | 4 +- .../public/ice/platform_render_surface.hxx | 4 +- .../platform/public/ice/platform_storage.hxx | 4 +- .../platform_android/private/android_app.cxx | 4 +- .../private/linux_sdl2_utils.cxx | 2 +- .../platform_linux/private/linux_storage.hxx | 4 +- .../win32_sdl2_platform_render_surface.cxx | 2 +- .../private/win32_sdl2_utils.cxx | 2 +- .../platform_win32/private/win32_storage.hxx | 4 +- .../asset_system/private/asset_data.hxx | 2 +- .../private/asset_request_awaitable.cxx | 2 +- .../asset_system/private/asset_shelve.cxx | 4 +- .../private/asset_shelve_devui.cxx | 2 +- .../asset_system/private/asset_storage.cxx | 2 +- .../asset_system/private/asset_storage.hxx | 2 +- .../private/asset_storage_devui.cxx | 2 +- .../public/ice/asset_category.hxx | 4 +- .../public/ice/asset_category_archive.hxx | 2 +- .../font_system/private/font_utils.cxx | 2 +- .../font_system/public/ice/font_utils.hxx | 4 +- .../private/input_action_layer_builder.cxx | 2 +- .../private/input_action_stack.cxx | 2 +- .../public/ice/input_action.hxx | 2 +- .../public/ice/input_action_types.hxx | 4 +- .../public/ice/render/render_pipeline.hxx | 2 +- .../public/ice/render/render_profiler.hxx | 4 +- .../private/resource_dynlib.hxx | 4 +- .../private/resource_filesystem_baked.cxx | 2 +- .../private/resource_filesystem_baked.hxx | 4 +- .../private/resource_filesystem_loose.cxx | 2 +- .../private/resource_filesystem_loose.hxx | 4 +- .../private/resource_filesystem_traverser.cxx | 4 +- .../private/resource_filesystem_writable.cxx | 2 +- .../private/resource_filesystem_writable.hxx | 4 +- .../private/resource_hailstorm_entry.cxx | 2 +- .../private/resource_hailstorm_entry.hxx | 2 +- .../private/resource_provider_dynlib.cxx | 4 +- .../resource_provider_filesystem_devui.cxx | 2 +- .../private/resource_provider_hailstorm.hxx | 4 +- .../resource_provider_hailstorm_devui.cxx | 4 +- .../resource_provider_hailstorm_devui.hxx | 4 +- .../private/resource_tracker.hxx | 2 +- .../private/resource_tracker_devui.cxx | 2 +- .../resource_system/public/ice/resource.hxx | 2 +- .../public/ice/resource_filter.hxx | 2 +- .../public/ice/resource_tracker.hxx | 2 +- .../public/ice/resource_types.hxx | 2 +- .../resource_system/public/ice/uri.hxx | 2 +- .../tests/test_resource_meta.cxx | 2 +- .../ui_system/public/ice/ui_action.hxx | 4 +- .../ui_system/public/ice/ui_button.hxx | 4 +- source/code/test/private/input_actions.cxx | 2 +- .../asset_compiler_resource_provider.cxx | 2 +- .../hsc_packer/private/hsc_packer_app.hxx | 6 +- .../hsc_reader/private/hsc_reader_app.cxx | 2 +- .../hsc_reader/private/hsc_reader_app.hxx | 4 +- source/code/tools/tool_base/private/tool.cxx | 4 +- .../code/tools/tool_base/private/tool_app.cxx | 4 +- 143 files changed, 223 insertions(+), 711 deletions(-) delete mode 100644 source/code/core/collections/public/ice/string/heap_string.hxx delete mode 100644 source/code/core/collections/public/ice/string/heap_var_string.hxx delete mode 100644 source/code/core/collections/public/ice/string/impl/heap_var_string.inl delete mode 100644 source/code/core/collections/public/ice/string/impl/var_string.inl delete mode 100644 source/code/core/collections/public/ice/string/string.hxx delete mode 100644 source/code/core/collections/public/ice/string/var_string.hxx diff --git a/source/code/core/collections/public/ice/span.hxx b/source/code/core/collections/public/ice/span.hxx index ca947e45..6ce8059f 100644 --- a/source/code/core/collections/public/ice/span.hxx +++ b/source/code/core/collections/public/ice/span.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/collections/public/ice/static_string.hxx b/source/code/core/collections/public/ice/static_string.hxx index 63010dbd..e82e746d 100644 --- a/source/code/core/collections/public/ice/static_string.hxx +++ b/source/code/core/collections/public/ice/static_string.hxx @@ -178,4 +178,10 @@ namespace ice }; } + template + constexpr auto stringid(ice::StaticString value) noexcept -> ice::StringID + { + return ice::stringid(value._data, value._size); + } + } // namespace ice diff --git a/source/code/core/collections/public/ice/string.hxx b/source/code/core/collections/public/ice/string.hxx index 5291e166..04b77832 100644 --- a/source/code/core/collections/public/ice/string.hxx +++ b/source/code/core/collections/public/ice/string.hxx @@ -2,6 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once +#include #include #include @@ -73,6 +74,16 @@ namespace ice return ice::BasicString{ buffer, size }; } + template requires ice::concepts::SupportedCharType + constexpr auto BasicString::data_view() const noexcept -> ice::Data + { + return Data{ + .location = _data, + .size = size().bytes(), + .alignment = ice::align_of + }; + } + using String = ice::BasicString; using WString = ice::BasicString; @@ -85,20 +96,25 @@ namespace ice }; } - template requires ice::concepts::SupportedCharType - constexpr auto BasicString::data_view() const noexcept -> ice::Data - { - return Data{ - .location = _data, - .size = size().bytes(), - .alignment = ice::align_of - }; - } - template requires ice::concepts::RODataObject constexpr auto string_from_data(T ro_data) noexcept -> ice::BasicString { return ice::string_from_data(ro_data, 0, ro_data.size.value); } + constexpr auto hash(ice::String value) noexcept -> ice::u64 + { + return ice::hash(std::string_view{ value }); + } + + constexpr auto hash32(ice::String value) noexcept -> ice::u32 + { + return ice::hash32(std::string_view{ value }); + } + + constexpr auto stringid(ice::String value) noexcept -> ice::StringID + { + return ice::stringid(value.data(), value.size().u64()); + } + } // namespace ice diff --git a/source/code/core/collections/public/ice/string/heap_string.hxx b/source/code/core/collections/public/ice/string/heap_string.hxx deleted file mode 100644 index be3a4095..00000000 --- a/source/code/core/collections/public/ice/string/heap_string.hxx +++ /dev/null @@ -1,5 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include diff --git a/source/code/core/collections/public/ice/string/heap_var_string.hxx b/source/code/core/collections/public/ice/string/heap_var_string.hxx deleted file mode 100644 index 0d7332e1..00000000 --- a/source/code/core/collections/public/ice/string/heap_var_string.hxx +++ /dev/null @@ -1,48 +0,0 @@ -/// Copyright 2024 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#if 0 -#include -#include - -namespace ice::string -{ - - template - inline void clear(ice::HeapVarString& str) noexcept; - - template - inline auto begin(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::Iterator; - - template - inline auto end(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::Iterator; - - template - inline auto cbegin(ice::HeapVarString const& str) noexcept -> typename ice::HeapVarString::ConstIterator; - - template - inline auto cend(ice::HeapVarString const& str) noexcept -> typename ice::HeapVarString::ConstIterator; - - template - inline auto rbegin(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::ReverseIterator; - - template - inline auto rend(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::ReverseIterator; - - template - inline auto deserialize(ice::HeapVarString& str, ice::Data data) noexcept -> ice::Data; - -} // namespace ice::string - -namespace ice -{ - - // using ice::string::size; - // using ice::string::begin; - // using ice::string::end; - -} // namespace ice - -#include "impl/heap_var_string.inl" -#endif diff --git a/source/code/core/collections/public/ice/string/impl/heap_var_string.inl b/source/code/core/collections/public/ice/string/impl/heap_var_string.inl deleted file mode 100644 index cc84f467..00000000 --- a/source/code/core/collections/public/ice/string/impl/heap_var_string.inl +++ /dev/null @@ -1,192 +0,0 @@ -/// Copyright 2024 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -namespace ice -{ - -#if 0 - namespace varstring - { - - inline auto allocate_exact(ice::Allocator& alloc, ice::ncount size, ice::ucount& out_size_bytes) noexcept -> char* - { - if (size == 0) - { - return nullptr; - } - - // Allocate enough for: bytes + size + '\0' - ice::usize const final_size = calc_required_size(size) + 1_B; - ice::Memory const result = alloc.allocate(ice::usize{ final_size }); - out_size_bytes = write_size(result.location, size); - return reinterpret_cast(result.location); - } - - inline auto create(ice::Allocator& alloc, ice::String str) noexcept -> char* - { - ice::ncount const str_size = str.size(); - - ice::u32 bytes = 0; - char* const data = allocate_exact(alloc, str_size.u32(), bytes); - if (data != nullptr) - { - ice::memcpy(data + bytes, str.begin(), str_size.bytes()); - data[bytes + str_size] = '\0'; - } - return data; - } - - } // namespace string::detail - - template - inline HeapVarString::HeapVarString(ice::Allocator& alloc) noexcept - : _allocator{ ice::addressof(alloc) } - , _data{ nullptr } - { - } - - template - inline HeapVarString::HeapVarString(ice::Allocator& alloc, ice::BasicString string) noexcept - : _allocator{ ice::addressof(alloc) } - , _data{ ice::string::detail::create_varstring(alloc, string) } - { - } - - template - inline HeapVarString::HeapVarString(ice::HeapVarString&& other) noexcept - : _allocator{ other._allocator } - , _data{ ice::exchange(other._data, nullptr) } - { - } - - template - inline HeapVarString::HeapVarString(ice::HeapVarString const& other) noexcept - : HeapVarString{ other._allocator, ice::String{ other } } - { - } - - template - inline HeapVarString::~HeapVarString() noexcept - { - if (_data != nullptr) - { - _allocator->deallocate(_data); - } - } - - template - inline auto HeapVarString::operator=(ice::BasicString str) noexcept -> HeapVarString& - { - if (_data != nullptr) - { - _allocator->deallocate(_data); - } - - _data = ice::string::detail::create_varstring(*_allocator, str); - return *this; - } - - template - inline bool operator==(ice::HeapVarString const& left, CharType const* right) noexcept - { - return ice::BasicString{ left } == ice::BasicString{ right }; - } - - template - inline bool operator==(ice::HeapVarString const& left, ice::BasicString right) noexcept - { - return ice::BasicString{ left } == right; - } - - template - inline bool operator==(ice::BasicString left, ice::HeapVarString const& right) noexcept - { - return left == ice::BasicString{ right }; - } - - template - inline HeapVarString::operator ice::BasicString() const noexcept - { - ice::ucount bytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(_data, bytes); - if (size > 0) - { - return { _data + bytes, size }; - } - else - { - return {}; - } - } - - template - inline HeapVarString::operator ice::VarStringBase() const noexcept - { - return _data; - } - - namespace string - { - - template - inline void clear(ice::HeapVarString& str) noexcept - { - str._allocator->deallocate(ice::exchange(str._data, nullptr)); - } - - template - inline auto begin(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::Iterator - { - return ice::string::detail::data_varstring(str._data); - } - - template - inline auto end(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::Iterator - { - ice::ucount bytes; - ice::ucount const size = ice::string::detail::read_varstring_size(str._data, bytes); - return str._data + bytes + size; - } - - template - inline auto cbegin(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::ConstIterator - { - return ice::string::detail::data_varstring(str._data); - } - - template - inline auto cend(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::ConstIterator - { - ice::ucount bytes; - ice::ucount const size = ice::string::detail::read_varstring_size(str._data, bytes); - return str._data + bytes + size; - } - - template - auto deserialize(ice::HeapVarString& str, ice::Data data) noexcept -> ice::Data - { - ICE_ASSERT_CORE(data.size >= 2_B); // 1 byte for size + 1 for a single character - ice::string::clear(str); // Clear the current contents - - ice::ucount bytes; - ice::ucount const size = ice::string::detail::read_varstring_size( - reinterpret_cast(data.location), bytes - ); - if (size > 0) - { - char* const new_str = ice::string::detail::allocate_varstring_exact(*str._allocator, size, bytes); - if (new_str != nullptr) - { - ice::memcpy(new_str + bytes, ice::ptr_add(data.location, ice::usize{ bytes }), size); - new_str[bytes + size] = '\0'; - } - str._data = new_str; // Assign the new allocated data - } - - return ice::ptr_add(data, { bytes + size }); - } - - } // namespace string -#endif - -} // namespace ice diff --git a/source/code/core/collections/public/ice/string/impl/var_string.inl b/source/code/core/collections/public/ice/string/impl/var_string.inl deleted file mode 100644 index 9f1382ff..00000000 --- a/source/code/core/collections/public/ice/string/impl/var_string.inl +++ /dev/null @@ -1,100 +0,0 @@ -/// Copyright 2024 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - - -namespace ice -{ - - namespace string - { - -#if 0 - inline auto size(ice::string::VarStringType auto const& str) noexcept -> ice::ucount - { - return ice::string::detail::read_varstring_size(str._data); - } - - inline auto capacity(ice::string::VarStringType auto const& str) noexcept -> ice::ucount - { - return ice::string::size(str); - } - - inline bool empty(ice::string::VarStringType auto const& str) noexcept - { - return str._data == nullptr || str._data[0] == '\0'; - } - - template - inline auto begin(StringType const& str) noexcept -> typename StringType::ConstIterator - { - return ice::string::detail::data_varstring(str._data); - } - - template - inline auto end(StringType const& str) noexcept -> typename StringType::ConstIterator - { - ice::ucount bytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(str._data, bytes); - return str._data + bytes + size; - } -#endif - -#if 0 - inline auto data_view(ice::string::VarStringType auto const& str) noexcept -> ice::Data - { - ice::ucount bytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(str._data, bytes); - - return { - .location = str._data, - .size = { size + bytes }, - .alignment = ice::ualign::b_1 - }; - } - - auto serialize(ice::string::VarStringType auto const& str, ice::Memory target) noexcept -> ice::Memory - { - ice::ucount const size = ice::string::size(str); - ICE_ASSERT_CORE( - ice::string::detail::calc_varstring_required_size(size) <= target.size.value - ); - - ice::ucount const sizebytes = ice::string::detail::write_varstring_size(target.location, size); - target.location = ice::ptr_add(target.location, ice::usize{ sizebytes }); - target.size.value -= sizebytes; - - ice::memcpy(target.location, str._data + sizebytes, size); - target.location = ice::ptr_add(target.location, ice::usize{ size }); - target.size.value -= size; - target.alignment = ice::ualign::b_1; - return target; - } -#endif - - } // namespace string - -#if 0 - namespace data - { - - template - inline auto read_varstring(ice::Data data, ice::VarStringBase& out_str) noexcept -> ice::Data - { - ICE_ASSERT_CORE(data.size >= 2_B); // 1 byte for size + 1 for a single character - - char const* const rawstr = reinterpret_cast(data.location); - - ice::ucount bytes; - ice::ucount const size = ice::string::detail::read_varstring_size(rawstr, bytes); - if (size > 0) - { - out_str._data = rawstr; - } - - return ice::ptr_add(data, { bytes + size }); - } - - } // namespace data -#endif - -} // namespace ice diff --git a/source/code/core/collections/public/ice/string/resizable_operations.hxx b/source/code/core/collections/public/ice/string/resizable_operations.hxx index e920f5ce..53f3fe69 100644 --- a/source/code/core/collections/public/ice/string/resizable_operations.hxx +++ b/source/code/core/collections/public/ice/string/resizable_operations.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/collections/public/ice/string/string.hxx b/source/code/core/collections/public/ice/string/string.hxx deleted file mode 100644 index be3a4095..00000000 --- a/source/code/core/collections/public/ice/string/string.hxx +++ /dev/null @@ -1,5 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include diff --git a/source/code/core/collections/public/ice/string/var_string.hxx b/source/code/core/collections/public/ice/string/var_string.hxx deleted file mode 100644 index 15a74d56..00000000 --- a/source/code/core/collections/public/ice/string/var_string.hxx +++ /dev/null @@ -1,129 +0,0 @@ -/// Copyright 2022 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -#if 0 -namespace ice::string -{ - - template - concept VarStringType = requires(T t) { - typename T::ConstIterator; - std::is_same_v; - { t._data } -> std::convertible_to; - }; - - template - inline void set_capacity(ice::HeapVarString& str, ice::ucount new_capacity) noexcept; - - template - inline void reserve(ice::HeapVarString& str, ice::ucount min_capacity) noexcept; - - template - inline void grow(ice::HeapVarString& str, ice::ucount min_capacity = 0) noexcept; - - template - inline void resize(ice::HeapVarString& str, ice::ucount new_size) noexcept; - - template - inline void shrink(ice::HeapVarString& str) noexcept; - - template - inline void clear(ice::HeapVarString& str) noexcept; - - template - inline void push_back(ice::HeapVarString& str, CharType character) noexcept; - - template - inline void push_back(ice::HeapVarString& str, CharType const* cstr) noexcept; - - template - inline void push_back(ice::HeapVarString& str, ice::HeapVarString const& other) noexcept; - - template - inline void push_back(ice::HeapVarString& str, ice::BasicString cstr) noexcept; - - template - inline void pop_back(ice::HeapVarString& str, ice::ucount count = 1) noexcept; - - - inline auto size(ice::string::VarStringType auto const& str) noexcept -> ice::ucount; - - inline auto capacity(ice::string::VarStringType auto const& str) noexcept -> ice::ucount; - - inline bool empty(ice::string::VarStringType auto const& str) noexcept; - - template - inline auto begin(StringType const& str) noexcept -> typename StringType::ConstIterator; - - template - inline auto end(StringType const& str) noexcept -> typename StringType::ConstIterator; - - template - inline auto rbegin(ice::VarStringBase const& str) noexcept -> typename ice::VarStringBase::ConstReverseIterator; - - template - inline auto rend(ice::VarStringBase const& str) noexcept -> typename ice::VarStringBase::ConstReverseIterator; - - template - inline auto front(ice::VarStringBase const& str) noexcept -> typename ice::VarStringBase::ValueType; - - template - inline auto back(ice::VarStringBase const& str) noexcept -> typename ice::VarStringBase::ValueType; - - template - inline auto substr(ice::VarStringBase const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::BasicString; - - template - inline auto substr_clone(ice::VarStringBase const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::VarStringBase; - - template - inline auto find_first_of(ice::VarStringBase const& str, CharType character_value) noexcept -> ice::ucount; - - template - inline auto find_first_of(ice::VarStringBase const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - template - inline auto find_last_of(ice::VarStringBase const& str, CharType character_value) noexcept -> ice::ucount; - - template - inline auto find_last_of(ice::VarStringBase const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - - inline auto data_view(ice::string::VarStringType auto const& str) noexcept -> ice::Data; - - template - inline auto memory(ice::VarStringBase& str) noexcept -> ice::Memory; - - //! \return Extracts the memory allocated by the heap string. - //! \note The 'size' member contains the 'capacity' of the heap string. - template - inline auto extract_memory(ice::VarStringBase& str) noexcept -> ice::Memory; - - inline auto serialize(ice::string::VarStringType auto const& str, ice::Memory target) noexcept -> ice::Memory; - -} // namespace ice::string - -namespace ice::data -{ - - template - inline auto read_varstring(ice::Data data, ice::VarStringBase& out_str) noexcept -> ice::Data; - -} // namespace ice::data - -namespace ice -{ - - using ice::string::size; - using ice::string::begin; - using ice::string::end; - -} // namespace ice - -#include "impl/var_string.inl" - -#endif diff --git a/source/code/core/collections/public/ice/string_types.hxx b/source/code/core/collections/public/ice/string_types.hxx index a090928a..f92fb75a 100644 --- a/source/code/core/collections/public/ice/string_types.hxx +++ b/source/code/core/collections/public/ice/string_types.hxx @@ -12,34 +12,3 @@ #include #include #include - -namespace ice -{ - -} // namespace ice - -namespace ice -{ - - constexpr auto hash(ice::String value) noexcept -> ice::u64 - { - return ice::hash(std::string_view{ value }); - } - - constexpr auto hash32(ice::String value) noexcept -> ice::u32 - { - return ice::hash32(std::string_view{ value }); - } - - constexpr auto stringid(ice::String value) noexcept -> ice::StringID - { - return ice::stringid(value.data(), value.size().u64()); - } - - template - constexpr auto stringid(ice::StaticString value) noexcept -> ice::StringID - { - return ice::stringid(value._data, value._size); - } - -} // namespace ice diff --git a/source/code/core/collections/public/ice/types/ncount.hxx b/source/code/core/collections/public/ice/types/ncount.hxx index cca665ad..ae72d477 100644 --- a/source/code/core/collections/public/ice/types/ncount.hxx +++ b/source/code/core/collections/public/ice/types/ncount.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/collections/tests/test_heap_string.cxx b/source/code/core/collections/tests/test_heap_string.cxx index b3674eeb..b44a0310 100644 --- a/source/code/core/collections/tests/test_heap_string.cxx +++ b/source/code/core/collections/tests/test_heap_string.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/core/collections/tests/test_static_string.cxx b/source/code/core/collections/tests/test_static_string.cxx index f9fdca1e..b9b82db7 100644 --- a/source/code/core/collections/tests/test_static_string.cxx +++ b/source/code/core/collections/tests/test_static_string.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/core/collections/tests/util_tracking_object.hxx b/source/code/core/collections/tests/util_tracking_object.hxx index f52c4ba9..4fccea28 100644 --- a/source/code/core/collections/tests/util_tracking_object.hxx +++ b/source/code/core/collections/tests/util_tracking_object.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/core/public/ice/base.hxx b/source/code/core/core/public/ice/base.hxx index 1ff2955f..65edee89 100644 --- a/source/code/core/core/public/ice/base.hxx +++ b/source/code/core/core/public/ice/base.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/core/public/ice/constants.hxx b/source/code/core/core/public/ice/constants.hxx index 78e8e6fb..133d9b67 100644 --- a/source/code/core/core/public/ice/constants.hxx +++ b/source/code/core/core/public/ice/constants.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/core/public/ice/profiler.hxx b/source/code/core/core/public/ice/profiler.hxx index 593cc0d5..0f6e9312 100644 --- a/source/code/core/core/public/ice/profiler.hxx +++ b/source/code/core/core/public/ice/profiler.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/core/public/ice/types.hxx b/source/code/core/core/public/ice/types.hxx index c75da0af..a4d5bc26 100644 --- a/source/code/core/core/public/ice/types.hxx +++ b/source/code/core/core/public/ice/types.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/core/public/ice/types/ref.hxx b/source/code/core/core/public/ice/types/ref.hxx index cc9f57ef..37d78509 100644 --- a/source/code/core/core/public/ice/types/ref.hxx +++ b/source/code/core/core/public/ice/types/ref.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/core/public/ice/types_extended.hxx b/source/code/core/core/public/ice/types_extended.hxx index 93e2e183..c453cc0b 100644 --- a/source/code/core/core/public/ice/types_extended.hxx +++ b/source/code/core/core/public/ice/types_extended.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/devui/private/devui_imgui.cxx b/source/code/core/devui/private/devui_imgui.cxx index 9cbeab09..a4661be9 100644 --- a/source/code/core/devui/private/devui_imgui.cxx +++ b/source/code/core/devui/private/devui_imgui.cxx @@ -1,8 +1,8 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include +#include #include namespace ice::detail diff --git a/source/code/core/devui/public/ice/devui_context.hxx b/source/code/core/devui/public/ice/devui_context.hxx index e1b668dc..be62b0f5 100644 --- a/source/code/core/devui/public/ice/devui_context.hxx +++ b/source/code/core/devui/public/ice/devui_context.hxx @@ -1,11 +1,11 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include +#include #include namespace ice diff --git a/source/code/core/devui/public/ice/devui_imgui.hxx b/source/code/core/devui/public/ice/devui_imgui.hxx index 4dbbaaea..f37d59de 100644 --- a/source/code/core/devui/public/ice/devui_imgui.hxx +++ b/source/code/core/devui/public/ice/devui_imgui.hxx @@ -1,8 +1,8 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include diff --git a/source/code/core/devui/public/ice/devui_module.hxx b/source/code/core/devui/public/ice/devui_module.hxx index dbabea72..593402f1 100644 --- a/source/code/core/devui/public/ice/devui_module.hxx +++ b/source/code/core/devui/public/ice/devui_module.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include namespace ice::api diff --git a/source/code/core/devui/public/ice/devui_widget.hxx b/source/code/core/devui/public/ice/devui_widget.hxx index 73767e9d..0afb6d8e 100644 --- a/source/code/core/devui/public/ice/devui_widget.hxx +++ b/source/code/core/devui/public/ice/devui_widget.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/core/memsys/private/mem_allocator_forward.cxx b/source/code/core/memsys/private/mem_allocator_forward.cxx index 5c3d694f..d39d29df 100644 --- a/source/code/core/memsys/private/mem_allocator_forward.cxx +++ b/source/code/core/memsys/private/mem_allocator_forward.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/core/memsys/private/mem_allocator_snake.cxx b/source/code/core/memsys/private/mem_allocator_snake.cxx index 091dc63b..83488b6d 100644 --- a/source/code/core/memsys/private/mem_allocator_snake.cxx +++ b/source/code/core/memsys/private/mem_allocator_snake.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/core/memsys/public/ice/mem_allocator_forward.hxx b/source/code/core/memsys/public/ice/mem_allocator_forward.hxx index 9805db6f..b06b6cc3 100644 --- a/source/code/core/memsys/public/ice/mem_allocator_forward.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator_forward.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/memsys/public/ice/mem_allocator_snake.hxx b/source/code/core/memsys/public/ice/mem_allocator_snake.hxx index 3ead2a97..57ad88d4 100644 --- a/source/code/core/memsys/public/ice/mem_allocator_snake.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator_snake.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/memsys/public/ice/mem_allocator_utils.hxx b/source/code/core/memsys/public/ice/mem_allocator_utils.hxx index b78ff5b3..c614a874 100644 --- a/source/code/core/memsys/public/ice/mem_allocator_utils.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator_utils.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/memsys/public/ice/mem_data.hxx b/source/code/core/memsys/public/ice/mem_data.hxx index f4dccddb..73c544d9 100644 --- a/source/code/core/memsys/public/ice/mem_data.hxx +++ b/source/code/core/memsys/public/ice/mem_data.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/memsys/public/ice/mem_utils.hxx b/source/code/core/memsys/public/ice/mem_utils.hxx index 5767b0b5..80433319 100644 --- a/source/code/core/memsys/public/ice/mem_utils.hxx +++ b/source/code/core/memsys/public/ice/mem_utils.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/modules/private/module_native.cxx b/source/code/core/modules/private/module_native.cxx index 204aeb08..2e69033c 100644 --- a/source/code/core/modules/private/module_native.cxx +++ b/source/code/core/modules/private/module_native.cxx @@ -1,8 +1,8 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "module_native.hxx" -#include +#include #include namespace ice::native_module diff --git a/source/code/core/modules/private/module_native.hxx b/source/code/core/modules/private/module_native.hxx index 7ebcec4f..29876085 100644 --- a/source/code/core/modules/private/module_native.hxx +++ b/source/code/core/modules/private/module_native.hxx @@ -1,9 +1,9 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice::native_module { diff --git a/source/code/core/modules/private/module_register.cxx b/source/code/core/modules/private/module_register.cxx index 2c9ca0f8..7ce5ba92 100644 --- a/source/code/core/modules/private/module_register.cxx +++ b/source/code/core/modules/private/module_register.cxx @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/core/modules/public/ice/module_concepts.hxx b/source/code/core/modules/public/ice/module_concepts.hxx index e974a7cc..5558d7c8 100644 --- a/source/code/core/modules/public/ice/module_concepts.hxx +++ b/source/code/core/modules/public/ice/module_concepts.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/tasks/private/task_thread_pool_impl.cxx b/source/code/core/tasks/private/task_thread_pool_impl.cxx index ed8e397b..111ed7d4 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.cxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include "task_thread_pool_impl.hxx" -#include +#include #include namespace ice diff --git a/source/code/core/tasks/public/ice/impl/task_utils.inl b/source/code/core/tasks/public/ice/impl/task_utils.inl index 37d010ee..15f4cc5c 100644 --- a/source/code/core/tasks/public/ice/impl/task_utils.inl +++ b/source/code/core/tasks/public/ice/impl/task_utils.inl @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT diff --git a/source/code/core/tasks/public/ice/task_debug_allocator.hxx b/source/code/core/tasks/public/ice/task_debug_allocator.hxx index b22e9001..03873b9d 100644 --- a/source/code/core/tasks/public/ice/task_debug_allocator.hxx +++ b/source/code/core/tasks/public/ice/task_debug_allocator.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/tasks/public/ice/task_expected_promise.hxx b/source/code/core/tasks/public/ice/task_expected_promise.hxx index ba11b4cc..fcd09f0a 100644 --- a/source/code/core/tasks/public/ice/task_expected_promise.hxx +++ b/source/code/core/tasks/public/ice/task_expected_promise.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/tasks/public/ice/task_utils.hxx b/source/code/core/tasks/public/ice/task_utils.hxx index 830cc3ff..8750e3a1 100644 --- a/source/code/core/tasks/public/ice/task_utils.hxx +++ b/source/code/core/tasks/public/ice/task_utils.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/utils/private/assert.cxx b/source/code/core/utils/private/assert.cxx index c66c6c23..275f8870 100644 --- a/source/code/core/utils/private/assert.cxx +++ b/source/code/core/utils/private/assert.cxx @@ -1,8 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include +#include #include #include diff --git a/source/code/core/utils/private/config/config_builder.cxx b/source/code/core/utils/private/config/config_builder.cxx index aa4b6024..6ac9b211 100644 --- a/source/code/core/utils/private/config/config_builder.cxx +++ b/source/code/core/utils/private/config/config_builder.cxx @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include #include "config_builder.hxx" diff --git a/source/code/core/utils/private/config/config_builder_types.hxx b/source/code/core/utils/private/config/config_builder_types.hxx index a3ba78d9..838f8eb4 100644 --- a/source/code/core/utils/private/config/config_builder_types.hxx +++ b/source/code/core/utils/private/config/config_builder_types.hxx @@ -1,11 +1,11 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include "config_internal.hxx" #include -#include -#include +#include +#include #include namespace ice::config::detail diff --git a/source/code/core/utils/private/config/config_builder_utils.cxx b/source/code/core/utils/private/config/config_builder_utils.cxx index 626f092f..8d40af56 100644 --- a/source/code/core/utils/private/config/config_builder_utils.cxx +++ b/source/code/core/utils/private/config/config_builder_utils.cxx @@ -1,8 +1,8 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "config_builder_utils.hxx" -#include +#include namespace ice::config::detail { diff --git a/source/code/core/utils/private/config/config_builder_value.cxx b/source/code/core/utils/private/config/config_builder_value.cxx index edf6b7cc..7424d732 100644 --- a/source/code/core/utils/private/config/config_builder_value.cxx +++ b/source/code/core/utils/private/config/config_builder_value.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "config_builder.hxx" diff --git a/source/code/core/utils/private/config_getters.cxx b/source/code/core/utils/private/config_getters.cxx index 7a9c7e2e..1a18fb95 100644 --- a/source/code/core/utils/private/config_getters.cxx +++ b/source/code/core/utils/private/config_getters.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include "config/config_detail.hxx" -#include +#include namespace ice::config::detail { diff --git a/source/code/core/utils/private/log.cxx b/source/code/core/utils/private/log.cxx index c2feea2c..fd4ef953 100644 --- a/source/code/core/utils/private/log.cxx +++ b/source/code/core/utils/private/log.cxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include -#include +#include #include #include "log_internal.hxx" diff --git a/source/code/core/utils/private/log_internal.cxx b/source/code/core/utils/private/log_internal.cxx index 5fa60b89..97cfa018 100644 --- a/source/code/core/utils/private/log_internal.cxx +++ b/source/code/core/utils/private/log_internal.cxx @@ -3,7 +3,7 @@ #include "log_internal.hxx" #include -#include +#include namespace ice::detail { diff --git a/source/code/core/utils/private/log_internal.hxx b/source/code/core/utils/private/log_internal.hxx index f2f1e2b0..b292ae53 100644 --- a/source/code/core/utils/private/log_internal.hxx +++ b/source/code/core/utils/private/log_internal.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/utils/private/params.cxx b/source/code/core/utils/private/params.cxx index 887d48d4..42110f1a 100644 --- a/source/code/core/utils/private/params.cxx +++ b/source/code/core/utils/private/params.cxx @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/source/code/core/utils/private/path_utils.cxx b/source/code/core/utils/private/path_utils.cxx index 02eb43aa..187249b8 100644 --- a/source/code/core/utils/private/path_utils.cxx +++ b/source/code/core/utils/private/path_utils.cxx @@ -2,8 +2,8 @@ /// SPDX-License-Identifier: MIT #include -#include -#include +#include +#include #include namespace ice::path diff --git a/source/code/core/utils/private/string_utils.cxx b/source/code/core/utils/private/string_utils.cxx index 4951a481..4310361c 100644 --- a/source/code/core/utils/private/string_utils.cxx +++ b/source/code/core/utils/private/string_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/core/utils/public/ice/config/config_details.hxx b/source/code/core/utils/public/ice/config/config_details.hxx index 77fd421a..85874c32 100644 --- a/source/code/core/utils/public/ice/config/config_details.hxx +++ b/source/code/core/utils/public/ice/config/config_details.hxx @@ -1,9 +1,9 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/core/utils/public/ice/expected.hxx b/source/code/core/utils/public/ice/expected.hxx index 5c57a25f..245953e0 100644 --- a/source/code/core/utils/public/ice/expected.hxx +++ b/source/code/core/utils/public/ice/expected.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/utils/public/ice/log.hxx b/source/code/core/utils/public/ice/log.hxx index 0071d6a8..8b518817 100644 --- a/source/code/core/utils/public/ice/log.hxx +++ b/source/code/core/utils/public/ice/log.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #include #include diff --git a/source/code/core/utils/public/ice/log_formatters.hxx b/source/code/core/utils/public/ice/log_formatters.hxx index 70f73fff..de13f69b 100644 --- a/source/code/core/utils/public/ice/log_formatters.hxx +++ b/source/code/core/utils/public/ice/log_formatters.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/utils/public/ice/log_sink.hxx b/source/code/core/utils/public/ice/log_sink.hxx index 043722fb..3d674511 100644 --- a/source/code/core/utils/public/ice/log_sink.hxx +++ b/source/code/core/utils/public/ice/log_sink.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/core/utils/public/ice/log_tag.hxx b/source/code/core/utils/public/ice/log_tag.hxx index 4df6d1a5..e05c11ce 100644 --- a/source/code/core/utils/public/ice/log_tag.hxx +++ b/source/code/core/utils/public/ice/log_tag.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/core/utils/public/ice/native_aio.hxx b/source/code/core/utils/public/ice/native_aio.hxx index d9bfd2ae..8287f346 100644 --- a/source/code/core/utils/public/ice/native_aio.hxx +++ b/source/code/core/utils/public/ice/native_aio.hxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once -#include +#include namespace ice::native_aio { diff --git a/source/code/core/utils/public/ice/params_types.hxx b/source/code/core/utils/public/ice/params_types.hxx index 6222659d..21a1096e 100644 --- a/source/code/core/utils/public/ice/params_types.hxx +++ b/source/code/core/utils/public/ice/params_types.hxx @@ -1,10 +1,10 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include #include diff --git a/source/code/core/utils/public/ice/path_utils.hxx b/source/code/core/utils/public/ice/path_utils.hxx index 52e14067..88cbb648 100644 --- a/source/code/core/utils/public/ice/path_utils.hxx +++ b/source/code/core/utils/public/ice/path_utils.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include namespace ice::path { diff --git a/source/code/core/utils/public/ice/string_utils.hxx b/source/code/core/utils/public/ice/string_utils.hxx index 49f5c4db..7caeff63 100644 --- a/source/code/core/utils/public/ice/string_utils.hxx +++ b/source/code/core/utils/public/ice/string_utils.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include -#include +#include +#include #include #include #include diff --git a/source/code/core/utils/utils_tests.bff b/source/code/core/utils/utils_tests.bff index 21bd0ba4..991c00bf 100644 --- a/source/code/core/utils/utils_tests.bff +++ b/source/code/core/utils/utils_tests.bff @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT .Project = diff --git a/source/code/framework/framework_base/private/framework_main.cxx b/source/code/framework/framework_base/private/framework_main.cxx index e1fb2fce..e0783f46 100644 --- a/source/code/framework/framework_base/private/framework_main.cxx +++ b/source/code/framework/framework_base/private/framework_main.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include diff --git a/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx b/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx index 155c168e..f94d9d2b 100644 --- a/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx +++ b/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "trait_sprite_animator.hxx" diff --git a/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx b/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx index e9f4aa97..c8613c87 100644 --- a/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx +++ b/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "render_ui_trait.hxx" diff --git a/source/code/iceshard/engine/private/world_trait.cxx b/source/code/iceshard/engine/private/world_trait.cxx index f63b315c..73e9d1bb 100644 --- a/source/code/iceshard/engine/private/world_trait.cxx +++ b/source/code/iceshard/engine/private/world_trait.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/iceshard/engine/public/ice/action/action_trigger.hxx b/source/code/iceshard/engine/public/ice/action/action_trigger.hxx index 586637f9..307f9fb6 100644 --- a/source/code/iceshard/engine/public/ice/action/action_trigger.hxx +++ b/source/code/iceshard/engine/public/ice/action/action_trigger.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -10,7 +10,7 @@ namespace ice::action { - using ActionTriggerHandler = bool ( + using ActionTriggerHandler = bool( ice::Shard const& user_shard, ice::Shard const& event_shard, ice::Tns stage_time_elapsed diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_concepts.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_concepts.hxx index 52c6e019..9c80474b 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_concepts.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_concepts.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice::ecs { diff --git a/source/code/iceshard/engine/public/ice/engine_asset_categories.hxx b/source/code/iceshard/engine/public/ice/engine_asset_categories.hxx index 2322da57..1bd96cfb 100644 --- a/source/code/iceshard/engine/public/ice/engine_asset_categories.hxx +++ b/source/code/iceshard/engine/public/ice/engine_asset_categories.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx index 175ab3e4..3888bc45 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_gfx_image_storage_trait.hxx" diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx index 8418cd5e..95d903aa 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx index f2e68ae7..fc77acd2 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include "ip_ui_oven_types.hxx" -#include +#include #include #include diff --git a/source/code/modules/imgui_module/private/imgui_system.cxx b/source/code/modules/imgui_module/private/imgui_system.cxx index 740f7f59..f2af2b35 100644 --- a/source/code/modules/imgui_module/private/imgui_system.cxx +++ b/source/code/modules/imgui_module/private/imgui_system.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_system.hxx" @@ -7,7 +7,7 @@ #include #include -#include +#include #if ISP_WINDOWS #include diff --git a/source/code/modules/imgui_module/private/imgui_trait.cxx b/source/code/modules/imgui_module/private/imgui_trait.cxx index 1fc0581c..e62e9095 100644 --- a/source/code/modules/imgui_module/private/imgui_trait.cxx +++ b/source/code/modules/imgui_module/private/imgui_trait.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_trait.hxx" diff --git a/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx b/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx index 6e78c12c..129f4d8c 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx @@ -3,7 +3,7 @@ #include "imgui_allocator_tree.hxx" #include -#include +#include #include #include diff --git a/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx b/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx index 58cf5201..bc909e7c 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_logger.hxx" @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include diff --git a/source/code/modules/shader_tools/private/shader_tools_glsl.hxx b/source/code/modules/shader_tools/private/shader_tools_glsl.hxx index a1e6edf0..85f371d2 100644 --- a/source/code/modules/shader_tools/private/shader_tools_glsl.hxx +++ b/source/code/modules/shader_tools/private/shader_tools_glsl.hxx @@ -1,10 +1,10 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #if ISP_WINDOWS || ISP_LINUX diff --git a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx index 24788601..0e3a10bc 100644 --- a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx @@ -6,7 +6,7 @@ #if ISP_WINDOWS || ISP_LINUX || ISP_WEBAPP #include #include -#include +#include #include #include #include diff --git a/source/code/modules/shader_tools/private/shader_tools_wgsl.hxx b/source/code/modules/shader_tools/private/shader_tools_wgsl.hxx index 9334d27c..e524ec7d 100644 --- a/source/code/modules/shader_tools/private/shader_tools_wgsl.hxx +++ b/source/code/modules/shader_tools/private/shader_tools_wgsl.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #if ISP_WINDOWS || ISP_LINUX || ISP_WEBAPP #include diff --git a/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx b/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx index d6177f3f..dcda147c 100644 --- a/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_swapchain.hxx" diff --git a/source/code/modules/vulkan_renderer/private/vk_utility.hxx b/source/code/modules/vulkan_renderer/private/vk_utility.hxx index 205ffe4b..1a4cf583 100644 --- a/source/code/modules/vulkan_renderer/private/vk_utility.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_utility.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/platforms/application/private/app_info.cxx b/source/code/platforms/application/private/app_info.cxx index 05a72ff9..d6cc3190 100644 --- a/source/code/platforms/application/private/app_info.cxx +++ b/source/code/platforms/application/private/app_info.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/platforms/platform/public/ice/platform_event.hxx b/source/code/platforms/platform/public/ice/platform_event.hxx index 799153ea..a61e5e3e 100644 --- a/source/code/platforms/platform/public/ice/platform_event.hxx +++ b/source/code/platforms/platform/public/ice/platform_event.hxx @@ -1,11 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include +#include namespace ice::platform { diff --git a/source/code/platforms/platform/public/ice/platform_render_surface.hxx b/source/code/platforms/platform/public/ice/platform_render_surface.hxx index d6c400d4..239ec28d 100644 --- a/source/code/platforms/platform/public/ice/platform_render_surface.hxx +++ b/source/code/platforms/platform/public/ice/platform_render_surface.hxx @@ -1,9 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #include diff --git a/source/code/platforms/platform/public/ice/platform_storage.hxx b/source/code/platforms/platform/public/ice/platform_storage.hxx index 91ed9482..d83c3240 100644 --- a/source/code/platforms/platform/public/ice/platform_storage.hxx +++ b/source/code/platforms/platform/public/ice/platform_storage.hxx @@ -1,9 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include namespace ice::platform diff --git a/source/code/platforms/platform_android/private/android_app.cxx b/source/code/platforms/platform_android/private/android_app.cxx index d3138fd3..f8a06630 100644 --- a/source/code/platforms/platform_android/private/android_app.cxx +++ b/source/code/platforms/platform_android/private/android_app.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "android_app.hxx" @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/platforms/platform_linux/private/linux_sdl2_utils.cxx b/source/code/platforms/platform_linux/private/linux_sdl2_utils.cxx index c7786940..8a7fb1cc 100644 --- a/source/code/platforms/platform_linux/private/linux_sdl2_utils.cxx +++ b/source/code/platforms/platform_linux/private/linux_sdl2_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "linux_sdl2_utils.hxx" diff --git a/source/code/platforms/platform_linux/private/linux_storage.hxx b/source/code/platforms/platform_linux/private/linux_storage.hxx index 877093f8..77fa09ac 100644 --- a/source/code/platforms/platform_linux/private/linux_storage.hxx +++ b/source/code/platforms/platform_linux/private/linux_storage.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #include diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx index bbc9e927..ed1140de 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "win32_sdl2_platform_render_surface.hxx" diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_utils.cxx b/source/code/platforms/platform_win32/private/win32_sdl2_utils.cxx index 6874a6e3..10637a02 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_utils.cxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "win32_sdl2_utils.hxx" diff --git a/source/code/platforms/platform_win32/private/win32_storage.hxx b/source/code/platforms/platform_win32/private/win32_storage.hxx index b87737f8..03c40a50 100644 --- a/source/code/platforms/platform_win32/private/win32_storage.hxx +++ b/source/code/platforms/platform_win32/private/win32_storage.hxx @@ -1,9 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #if ISP_WINDOWS diff --git a/source/code/systems/asset_system/private/asset_data.hxx b/source/code/systems/asset_system/private/asset_data.hxx index 3f657706..d6dfa65f 100644 --- a/source/code/systems/asset_system/private/asset_data.hxx +++ b/source/code/systems/asset_system/private/asset_data.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/asset_system/private/asset_request_awaitable.cxx b/source/code/systems/asset_system/private/asset_request_awaitable.cxx index accb49c9..f1355731 100644 --- a/source/code/systems/asset_system/private/asset_request_awaitable.cxx +++ b/source/code/systems/asset_system/private/asset_request_awaitable.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_request_awaitable.hxx" diff --git a/source/code/systems/asset_system/private/asset_shelve.cxx b/source/code/systems/asset_system/private/asset_shelve.cxx index f955deb3..7cdc60eb 100644 --- a/source/code/systems/asset_system/private/asset_shelve.cxx +++ b/source/code/systems/asset_system/private/asset_shelve.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_shelve.hxx" @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include namespace ice diff --git a/source/code/systems/asset_system/private/asset_shelve_devui.cxx b/source/code/systems/asset_system/private/asset_shelve_devui.cxx index 1d7263a1..ae6c620d 100644 --- a/source/code/systems/asset_system/private/asset_shelve_devui.cxx +++ b/source/code/systems/asset_system/private/asset_shelve_devui.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_shelve_devui.hxx" diff --git a/source/code/systems/asset_system/private/asset_storage.cxx b/source/code/systems/asset_system/private/asset_storage.cxx index 455f6410..5e4cb30e 100644 --- a/source/code/systems/asset_system/private/asset_storage.cxx +++ b/source/code/systems/asset_system/private/asset_storage.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_storage.hxx" diff --git a/source/code/systems/asset_system/private/asset_storage.hxx b/source/code/systems/asset_system/private/asset_storage.hxx index 7764f494..ad039ef3 100644 --- a/source/code/systems/asset_system/private/asset_storage.hxx +++ b/source/code/systems/asset_system/private/asset_storage.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/asset_system/private/asset_storage_devui.cxx b/source/code/systems/asset_system/private/asset_storage_devui.cxx index 15aabd0f..d7c98bf1 100644 --- a/source/code/systems/asset_system/private/asset_storage_devui.cxx +++ b/source/code/systems/asset_system/private/asset_storage_devui.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_entry.hxx" diff --git a/source/code/systems/asset_system/public/ice/asset_category.hxx b/source/code/systems/asset_system/public/ice/asset_category.hxx index fb028648..56cf7998 100644 --- a/source/code/systems/asset_system/public/ice/asset_category.hxx +++ b/source/code/systems/asset_system/public/ice/asset_category.hxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include #include diff --git a/source/code/systems/asset_system/public/ice/asset_category_archive.hxx b/source/code/systems/asset_system/public/ice/asset_category_archive.hxx index 79d614ea..8e9934d7 100644 --- a/source/code/systems/asset_system/public/ice/asset_category_archive.hxx +++ b/source/code/systems/asset_system/public/ice/asset_category_archive.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/font_system/private/font_utils.cxx b/source/code/systems/font_system/private/font_utils.cxx index 45c4143b..bfdc8350 100644 --- a/source/code/systems/font_system/private/font_utils.cxx +++ b/source/code/systems/font_system/private/font_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/systems/font_system/public/ice/font_utils.hxx b/source/code/systems/font_system/public/ice/font_utils.hxx index ad40edb4..cd4b902f 100644 --- a/source/code/systems/font_system/public/ice/font_utils.hxx +++ b/source/code/systems/font_system/public/ice/font_utils.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx index 9e06b95c..88d40b54 100644 --- a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace ice diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index a83c67bf..404eb24e 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/input_action_system/public/ice/input_action.hxx b/source/code/systems/input_action_system/public/ice/input_action.hxx index 1f232e49..43766bc6 100644 --- a/source/code/systems/input_action_system/public/ice/input_action.hxx +++ b/source/code/systems/input_action_system/public/ice/input_action.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/input_action_system/public/ice/input_action_types.hxx b/source/code/systems/input_action_system/public/ice/input_action_types.hxx index 37ad1a17..158305a3 100644 --- a/source/code/systems/input_action_system/public/ice/input_action_types.hxx +++ b/source/code/systems/input_action_system/public/ice/input_action_types.hxx @@ -1,8 +1,8 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include #include diff --git a/source/code/systems/render_system/public/ice/render/render_pipeline.hxx b/source/code/systems/render_system/public/ice/render/render_pipeline.hxx index c4c3ca22..4c559f80 100644 --- a/source/code/systems/render_system/public/ice/render/render_pipeline.hxx +++ b/source/code/systems/render_system/public/ice/render/render_pipeline.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/render_system/public/ice/render/render_profiler.hxx b/source/code/systems/render_system/public/ice/render/render_profiler.hxx index adb66460..93f6bd8e 100644 --- a/source/code/systems/render_system/public/ice/render/render_profiler.hxx +++ b/source/code/systems/render_system/public/ice/render/render_profiler.hxx @@ -1,9 +1,9 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include namespace ice::render::detail diff --git a/source/code/systems/resource_system/private/resource_dynlib.hxx b/source/code/systems/resource_system/private/resource_dynlib.hxx index d2200507..a94e2dad 100644 --- a/source/code/systems/resource_system/private/resource_dynlib.hxx +++ b/source/code/systems/resource_system/private/resource_dynlib.hxx @@ -1,11 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include +#include #include namespace ice diff --git a/source/code/systems/resource_system/private/resource_filesystem_baked.cxx b/source/code/systems/resource_system/private/resource_filesystem_baked.cxx index 50fcfedc..52e39d71 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_baked.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_baked.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_filesystem_baked.hxx" diff --git a/source/code/systems/resource_system/private/resource_filesystem_baked.hxx b/source/code/systems/resource_system/private/resource_filesystem_baked.hxx index bb275e98..ebe67860 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_baked.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_baked.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include diff --git a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx index 197571ed..396ecb3b 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_filesystem_loose.hxx" diff --git a/source/code/systems/resource_system/private/resource_filesystem_loose.hxx b/source/code/systems/resource_system/private/resource_filesystem_loose.hxx index 795a3d39..0e261a36 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_loose.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_loose.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include "resource_filesystem.hxx" diff --git a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx index 90bbc92c..6fecc306 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_filesystem_traverser.hxx" @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include diff --git a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx index 1149fb8c..8a9aed08 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_filesystem_writable.hxx" diff --git a/source/code/systems/resource_system/private/resource_filesystem_writable.hxx b/source/code/systems/resource_system/private/resource_filesystem_writable.hxx index b026af6d..1c9021ae 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_writable.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_writable.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include "resource_filesystem.hxx" diff --git a/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx b/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx index b6dbb86e..eb317cde 100644 --- a/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx +++ b/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx b/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx index 1d4871e2..7a6279ef 100644 --- a/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx +++ b/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx index b5c66842..4378cf56 100644 --- a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx +++ b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include #include -#include +#include #include #include diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx index d02f0e4e..693b157f 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_provider_filesystem_devui.hxx" diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx index b4e316e7..ded6b32a 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx index e1dff74a..3fc4d473 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx @@ -1,8 +1,8 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_provider_hailstorm_devui.hxx" -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.hxx b/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.hxx index c5cbb08a..d4d30b9f 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.hxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.hxx @@ -1,10 +1,10 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include "resource_provider_hailstorm.hxx" -#include +#include #include namespace ice diff --git a/source/code/systems/resource_system/private/resource_tracker.hxx b/source/code/systems/resource_system/private/resource_tracker.hxx index 90732735..88b8e4b2 100644 --- a/source/code/systems/resource_system/private/resource_tracker.hxx +++ b/source/code/systems/resource_system/private/resource_tracker.hxx @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_tracker_devui.cxx b/source/code/systems/resource_system/private/resource_tracker_devui.cxx index e6a3531b..03e1524e 100644 --- a/source/code/systems/resource_system/private/resource_tracker_devui.cxx +++ b/source/code/systems/resource_system/private/resource_tracker_devui.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_internal.hxx" diff --git a/source/code/systems/resource_system/public/ice/resource.hxx b/source/code/systems/resource_system/public/ice/resource.hxx index c08e3de4..8c639218 100644 --- a/source/code/systems/resource_system/public/ice/resource.hxx +++ b/source/code/systems/resource_system/public/ice/resource.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/resource_system/public/ice/resource_filter.hxx b/source/code/systems/resource_system/public/ice/resource_filter.hxx index 3459fef4..d537f535 100644 --- a/source/code/systems/resource_system/public/ice/resource_filter.hxx +++ b/source/code/systems/resource_system/public/ice/resource_filter.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/resource_system/public/ice/resource_tracker.hxx b/source/code/systems/resource_system/public/ice/resource_tracker.hxx index 01f1a765..78fb0e2d 100644 --- a/source/code/systems/resource_system/public/ice/resource_tracker.hxx +++ b/source/code/systems/resource_system/public/ice/resource_tracker.hxx @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/public/ice/resource_types.hxx b/source/code/systems/resource_system/public/ice/resource_types.hxx index e0c396c5..5d3aa3d1 100644 --- a/source/code/systems/resource_system/public/ice/resource_types.hxx +++ b/source/code/systems/resource_system/public/ice/resource_types.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/resource_system/public/ice/uri.hxx b/source/code/systems/resource_system/public/ice/uri.hxx index 1bc65cba..f6465499 100644 --- a/source/code/systems/resource_system/public/ice/uri.hxx +++ b/source/code/systems/resource_system/public/ice/uri.hxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include namespace ice diff --git a/source/code/systems/resource_system/tests/test_resource_meta.cxx b/source/code/systems/resource_system/tests/test_resource_meta.cxx index 6430ffb5..e0e64fa5 100644 --- a/source/code/systems/resource_system/tests/test_resource_meta.cxx +++ b/source/code/systems/resource_system/tests/test_resource_meta.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/systems/ui_system/public/ice/ui_action.hxx b/source/code/systems/ui_system/public/ice/ui_action.hxx index 504978cb..0993055d 100644 --- a/source/code/systems/ui_system/public/ice/ui_action.hxx +++ b/source/code/systems/ui_system/public/ice/ui_action.hxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include namespace ice::ui diff --git a/source/code/systems/ui_system/public/ice/ui_button.hxx b/source/code/systems/ui_system/public/ice/ui_button.hxx index 7c7bf3e4..f9fb1439 100644 --- a/source/code/systems/ui_system/public/ice/ui_button.hxx +++ b/source/code/systems/ui_system/public/ice/ui_button.hxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include #include diff --git a/source/code/test/private/input_actions.cxx b/source/code/test/private/input_actions.cxx index 8fd1709e..d18bde2b 100644 --- a/source/code/test/private/input_actions.cxx +++ b/source/code/test/private/input_actions.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_actions.hxx" diff --git a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx index 9b69e3a0..9d14e2a7 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include "asset_compiler_resource_provider.hxx" -#include +#include #include AssetCompilerResource::AssetCompilerResource( diff --git a/source/code/tools/hsc_packer/private/hsc_packer_app.hxx b/source/code/tools/hsc_packer/private/hsc_packer_app.hxx index bd7c4780..2b16f585 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer_app.hxx +++ b/source/code/tools/hsc_packer/private/hsc_packer_app.hxx @@ -1,12 +1,12 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/source/code/tools/hsc_reader/private/hsc_reader_app.cxx b/source/code/tools/hsc_reader/private/hsc_reader_app.cxx index b0627fa5..c37f6c6e 100644 --- a/source/code/tools/hsc_reader/private/hsc_reader_app.cxx +++ b/source/code/tools/hsc_reader/private/hsc_reader_app.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "hsc_reader_app.hxx" diff --git a/source/code/tools/hsc_reader/private/hsc_reader_app.hxx b/source/code/tools/hsc_reader/private/hsc_reader_app.hxx index ed9bf7fa..0c8268b8 100644 --- a/source/code/tools/hsc_reader/private/hsc_reader_app.hxx +++ b/source/code/tools/hsc_reader/private/hsc_reader_app.hxx @@ -1,10 +1,10 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include #include diff --git a/source/code/tools/tool_base/private/tool.cxx b/source/code/tools/tool_base/private/tool.cxx index 8ff66207..d4c7b6e7 100644 --- a/source/code/tools/tool_base/private/tool.cxx +++ b/source/code/tools/tool_base/private/tool.cxx @@ -1,10 +1,10 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include #include -#include +#include #include #include #include diff --git a/source/code/tools/tool_base/private/tool_app.cxx b/source/code/tools/tool_base/private/tool_app.cxx index 83f20c56..2edb08bc 100644 --- a/source/code/tools/tool_base/private/tool_app.cxx +++ b/source/code/tools/tool_base/private/tool_app.cxx @@ -1,9 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include -#include +#include #include namespace ice::tool From 4f67fb74b467284d187ff1e1a48aa9c6e44a50a1 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Mon, 5 Jan 2026 00:32:41 +0900 Subject: [PATCH 03/40] Refactor 'ncount_base<>' into 'nvalue'. Optimized the generated asembly of the 'nvalue' type. Improved the inital API shared across 'ncount' and 'nindex'. More to come. --- .../collections/public/ice/types/ncount.hxx | 194 ++++++------------ .../collections/public/ice/types/nindex.hxx | 133 ++++++------ .../collections/public/ice/types/nvalue.hxx | 104 ++++++++++ source/code/core/core/public/ice/profiler.hxx | 10 +- 4 files changed, 229 insertions(+), 212 deletions(-) create mode 100644 source/code/core/collections/public/ice/types/nvalue.hxx diff --git a/source/code/core/collections/public/ice/types/ncount.hxx b/source/code/core/collections/public/ice/types/ncount.hxx index ae72d477..18759e26 100644 --- a/source/code/core/collections/public/ice/types/ncount.hxx +++ b/source/code/core/collections/public/ice/types/ncount.hxx @@ -3,6 +3,7 @@ #pragma once #include +#include namespace ice { @@ -10,112 +11,25 @@ namespace ice struct ncount; struct nindex; - namespace concepts + struct ncount : public ice::nvalue { + using nvalue::base_type; + using nvalue::base_signed_type; - template - concept native_count_type = (std::is_arithmetic_v and not std::is_floating_point_v) - or std::is_same_v - or std::is_same_v; - - } // namespace concepts - - namespace detail - { - -#if ISP_ARCH_BITS == 64 - using ncount_base_type = u64; - using ncount_base_type_signed = i64; -#elif ISP_ARCH_BITS == 32 - using ncount_base_type = u32; - using ncount_base_type_signed = i32; -#else -# error Unhandled architecture! -#endif - - template< - typename BaseType = ncount_base_type, - typename BaseTypeSigned = ncount_base_type_signed> - struct ncount_base; - - template<> - struct ncount_base - { - using base_type = u64; - using base_type_signed = i64; - - base_type_signed value : 48 = 0; - base_type width : 16 = 0; - - constexpr ncount_base() noexcept = default; - constexpr ncount_base(base_type value) noexcept - : value{ static_cast(value) }, width{ 1 } - { } - constexpr explicit ncount_base(base_type value, base_type width) noexcept - : value{ static_cast(value) }, width{ width } - { } - }; - - template<> - struct ncount_base - { - using base_type = u32; - using base_type_signed = i32; - - base_type_signed value = 0; - base_type width = 0; - - constexpr ncount_base() noexcept = default; - constexpr ncount_base(base_type value) noexcept - : value{ static_cast(value) }, width{ 1 } - { } - constexpr explicit ncount_base(base_type value, base_type width) noexcept - : value{ static_cast(value) }, width{ width } - { } - }; - - constexpr auto ncount_min_value() noexcept -> ncount_base_type - { - return 0; - } - - constexpr auto ncount_max_value() noexcept -> ncount_base_type - { - if constexpr (ice::build::is_x64) - { - return 0x0000'7fff'ffff'ffff; - } - else - { - return std::numeric_limits::max(); - } - } - - } // namespace detail - - - struct ncount : protected ice::detail::ncount_base<> - { - using ncount_base<>::base_type; - using ncount_base<>::ncount_base; - - // Utility - constexpr auto u8() const noexcept { return static_cast(value); } - constexpr auto u16() const noexcept { return static_cast(value); } - constexpr auto u32() const noexcept { return static_cast(value); } - constexpr auto u64() const noexcept { return static_cast(value); } - constexpr auto native() const noexcept { return static_cast(value); } - constexpr auto bytes() const noexcept { return operator ice::usize(); } + constexpr ncount() noexcept = default; + constexpr ncount(nvalue value) noexcept; + constexpr ncount(base_type value) noexcept; + constexpr ncount(base_type value, base_type width) noexcept; // Arithmetic - constexpr auto operator+(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount; - constexpr auto operator-(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount; - constexpr auto operator*(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount; - constexpr auto operator/(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount; - constexpr auto operator+=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount&; - constexpr auto operator-=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount&; - constexpr auto operator*=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount&; - constexpr auto operator/=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount&; + constexpr auto operator+(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount; + constexpr auto operator-(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount; + constexpr auto operator*(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount; + constexpr auto operator/(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount; + constexpr auto operator+=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount&; + constexpr auto operator-=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount&; + constexpr auto operator*=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount&; + constexpr auto operator/=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount&; // Increments constexpr auto operator++(this ncount& self) noexcept -> ncount&; @@ -124,16 +38,28 @@ namespace ice constexpr auto operator--(this ncount& self, int) noexcept -> ncount; // Comparison - constexpr bool operator==(this ncount self, ice::concepts::native_count_type auto other) noexcept; - constexpr auto operator<=>(this ncount self, ice::concepts::native_count_type auto other) noexcept; + constexpr bool operator==(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept; + constexpr auto operator<=>(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept; // type colapsing constexpr explicit operator bool(this ncount self) noexcept; constexpr operator ice::usize(this ncount self) noexcept; constexpr operator base_type(this ncount self) noexcept; - constexpr explicit operator base_type_signed(this ncount self) noexcept; + constexpr explicit operator base_signed_type(this ncount self) noexcept; }; + constexpr ncount::ncount(nvalue value) noexcept + : nvalue{ value } + { } + + constexpr ncount::ncount(base_type value) noexcept + : nvalue{ 1, static_cast(value) } + { } + + inline constexpr ncount::ncount(base_type value, base_type width) noexcept + : nvalue{ width, static_cast(value) } + { } + struct ncount_invalid_t : ncount {}; static constexpr ice::ncount_invalid_t none_count{ }; @@ -142,104 +68,104 @@ namespace ice static_assert(ice::size_of == 8_B); - constexpr auto ncount::operator+(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount + constexpr auto ncount::operator+(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount { - return ncount{ static_cast(self.value + static_cast(other)), self.width }; + return ncount{ static_cast(self._value + static_cast(other)), self._width }; } - constexpr auto ncount::operator-(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount + constexpr auto ncount::operator-(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount { - return ncount{ static_cast(self.value - static_cast(other)), self.width }; + return ncount{ static_cast(self._value - static_cast(other)), self._width }; } - constexpr auto ncount::operator*(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount + constexpr auto ncount::operator*(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount { - return ncount{ static_cast(self.value * static_cast(other)), self.width }; + return ncount{ static_cast(self._value * static_cast(other)), self._width }; } - constexpr auto ncount::operator/(this ncount self, ice::concepts::native_count_type auto other) noexcept -> ncount + constexpr auto ncount::operator/(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount { - return ncount{ static_cast(self.value / static_cast(other)), self.width }; + return ncount{ static_cast(self._value / static_cast(other)), self._width }; } - constexpr auto ncount::operator+=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount& + constexpr auto ncount::operator+=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount& { - self.value += static_cast(other); + self._value += static_cast(other); return self; } - constexpr auto ncount::operator-=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount& + constexpr auto ncount::operator-=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount& { - self.value -= static_cast(other); + self._value -= static_cast(other); return self; } - constexpr auto ncount::operator*=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount& + constexpr auto ncount::operator*=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount& { - self.value *= static_cast(other); + self._value *= static_cast(other); return self; } - constexpr auto ncount::operator/=(this ncount& self, ice::concepts::native_count_type auto other) noexcept -> ncount& + constexpr auto ncount::operator/=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount& { - self.value /= static_cast(other); + self._value /= static_cast(other); return self; } constexpr auto ncount::operator++(this ncount& self) noexcept -> ncount& { - self.value += 1; + self._value += 1; return self; } constexpr auto ncount::operator++(this ncount& self, int) noexcept -> ncount { const ncount old = self; - self.value += 1; + self._value += 1; return old; } constexpr auto ncount::operator--(this ncount& self) noexcept -> ncount& { - self.value -= 1; + self._value -= 1; return self; } constexpr auto ncount::operator--(this ncount& self, int) noexcept -> ncount { const ncount old = self; - self.value -= 1; + self._value -= 1; return old; } - constexpr bool ncount::operator==(this ncount self, ice::concepts::native_count_type auto other) noexcept + constexpr bool ncount::operator==(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept { - return self.value == static_cast(other); + return self._value == static_cast(other); } - constexpr auto ncount::operator<=>(this ncount self, ice::concepts::native_count_type auto other) noexcept + constexpr auto ncount::operator<=>(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept { - return self.value <=> static_cast(other); + return self._value <=> static_cast(other); } constexpr ncount::operator bool(this ncount self) noexcept { - return static_cast(self.value * self.width); + return static_cast(self._value * self._width); } constexpr ncount::operator ice::usize(this ncount self) noexcept { - return ice::usize{ static_cast(self.value) * self.width }; + return ice::usize{ static_cast(self._value) * self._width }; } constexpr ncount::operator ncount::base_type(this ncount self) noexcept { - return std::max(self.value, 0); + return std::max(self._value, 0); } - constexpr ncount::operator ncount::base_type_signed(this ncount self) noexcept + constexpr ncount::operator ncount::base_signed_type(this ncount self) noexcept { - return self.value; + return self._value; } // special operators diff --git a/source/code/core/collections/public/ice/types/nindex.hxx b/source/code/core/collections/public/ice/types/nindex.hxx index 01be4e14..cc47abc6 100644 --- a/source/code/core/collections/public/ice/types/nindex.hxx +++ b/source/code/core/collections/public/ice/types/nindex.hxx @@ -7,35 +7,26 @@ namespace ice { - struct nindex : protected ice::detail::ncount_base<> + struct nindex : public ice::nvalue { - using ncount_base<>::base_type; - using ncount_base<>::ncount_base; + using nvalue::base_type; + using nvalue::base_signed_type; - constexpr nindex(ice::ncount count) noexcept - : nindex{ count.u64() } - { } + constexpr nindex() noexcept = default; + constexpr nindex(nvalue value) noexcept; + constexpr nindex(base_type value) noexcept; + constexpr nindex(base_type value, base_type width) noexcept; - // Helpers - constexpr bool is_valid(this nindex self) noexcept; - - constexpr auto value_or(this nindex self, ice::concepts::native_count_type auto fallback) noexcept -> ice::nindex; - - constexpr auto u8(this nindex self) noexcept { return static_cast(self.value * self.width); } - constexpr auto u16(this nindex self) noexcept { return static_cast(self.value * self.width); } - constexpr auto u32(this nindex self) noexcept { return static_cast(self.value * self.width); } - constexpr auto u64(this nindex self) noexcept { return static_cast(self.value * self.width); } - constexpr auto native(this nindex self) noexcept -> base_type { return static_cast(self.value * self.width); } // Arithmetic - constexpr auto operator+(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex; - constexpr auto operator-(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex; - constexpr auto operator*(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex; - constexpr auto operator/(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex; - constexpr auto operator+=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex&; - constexpr auto operator-=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex&; - constexpr auto operator*=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex&; - constexpr auto operator/=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex&; + constexpr auto operator+(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex; + constexpr auto operator-(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex; + constexpr auto operator*(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex; + constexpr auto operator/(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex; + constexpr auto operator+=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex&; + constexpr auto operator-=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex&; + constexpr auto operator*=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex&; + constexpr auto operator/=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex&; // Increments constexpr auto operator++(this nindex& self) noexcept -> nindex&; @@ -44,136 +35,132 @@ namespace ice constexpr auto operator--(this nindex& self, int) noexcept -> nindex; // Comparison - constexpr bool operator==(this nindex self, ice::concepts::native_count_type auto other) noexcept; - constexpr auto operator<=>(this nindex self, ice::concepts::native_count_type auto other) noexcept; + constexpr bool operator==(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept; + constexpr auto operator<=>(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept; // type colapsing constexpr explicit operator bool(this nindex self) noexcept; constexpr operator ice::isize(this nindex self) noexcept; - constexpr operator ice::ncount(this nindex self) noexcept; constexpr operator base_type(this nindex self) noexcept; - constexpr explicit operator base_type_signed(this nindex self) noexcept; + constexpr explicit operator base_signed_type(this nindex self) noexcept; }; - struct nindex_invalid_t : nindex {}; + constexpr nindex::nindex(nvalue value) noexcept + : nvalue{ value } + { } - static constexpr ice::nindex_invalid_t none_index{ }; + constexpr nindex::nindex(base_type value) noexcept + : nvalue{ 1, static_cast(value) } + { } - static_assert(ice::size_of == 8_B); + constexpr nindex::nindex(base_type value, base_type width) noexcept + : nvalue{ width, static_cast(value) } + { } - constexpr bool nindex::is_valid(this nindex self) noexcept - { - return self.width > 0; - } + struct nindex_invalid_t : nindex { }; - constexpr auto nindex::value_or(this nindex self, ice::concepts::native_count_type auto fallback) noexcept -> ice::nindex - { - return self.is_valid() ? self : nindex{ static_cast(fallback) }; - } + static constexpr ice::nindex_invalid_t none_index{ }; + + static_assert(ice::size_of == 8_B); - constexpr auto nindex::operator+(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex + constexpr auto nindex::operator+(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex { - return nindex{ self.value + static_cast(other), self.width }; + return nindex{ self._value + static_cast(other), self._width }; } - constexpr auto nindex::operator-(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex + constexpr auto nindex::operator-(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex { - return nindex{ self.value - static_cast(other), self.width }; + return nindex{ self._value - static_cast(other), self._width }; } - constexpr auto nindex::operator*(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex + constexpr auto nindex::operator*(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex { - return nindex{ self.value * static_cast(other), self.width }; + return nindex{ self._value * static_cast(other), self._width }; } - constexpr auto nindex::operator/(this nindex self, ice::concepts::native_count_type auto other) noexcept -> nindex + constexpr auto nindex::operator/(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex { - return nindex{ self.value / static_cast(other), self.width }; + return nindex{ self._value / static_cast(other), self._width }; } - constexpr auto nindex::operator+=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex& + constexpr auto nindex::operator+=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex& { - self.value += static_cast(other); + self._value += static_cast(other); return self; } - constexpr auto nindex::operator-=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex& + constexpr auto nindex::operator-=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex& { - self.value -= static_cast(other); + self._value -= static_cast(other); return self; } - constexpr auto nindex::operator*=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex& + constexpr auto nindex::operator*=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex& { - self.value *= static_cast(other); + self._value *= static_cast(other); return self; } - constexpr auto nindex::operator/=(this nindex& self, ice::concepts::native_count_type auto other) noexcept -> nindex& + constexpr auto nindex::operator/=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex& { - self.value /= static_cast(other); + self._value /= static_cast(other); return self; } constexpr auto nindex::operator++(this nindex& self) noexcept -> nindex& { - self.value += 1; + self._value += 1; return self; } constexpr auto nindex::operator++(this nindex& self, int) noexcept -> nindex { const nindex old = self; - self.value += 1; + self._value += 1; return old; } constexpr auto nindex::operator--(this nindex& self) noexcept -> nindex& { - self.value -= 1; + self._value -= 1; return self; } constexpr auto nindex::operator--(this nindex& self, int) noexcept -> nindex { const nindex old = self; - self.value -= 1; + self._value -= 1; return old; } - constexpr bool nindex::operator==(this nindex self, ice::concepts::native_count_type auto other) noexcept + constexpr bool nindex::operator==(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept { - return static_cast(self.value) == static_cast(other); + return static_cast(self._value) == static_cast(other); } - constexpr auto nindex::operator<=>(this nindex self, ice::concepts::native_count_type auto other) noexcept + constexpr auto nindex::operator<=>(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept { - return static_cast(self.value) <=> static_cast(other); + return static_cast(self._value) <=> static_cast(other); } constexpr nindex::operator bool(this nindex self) noexcept { - return static_cast(self.value * self.width); + return static_cast(self._value * self._width); } constexpr nindex::operator ice::isize(this nindex self) noexcept { - return ice::isize{ static_cast(self.value * self.width) }; - } - - constexpr nindex::operator ice::ncount(this nindex self) noexcept - { - return ice::ncount{ static_cast(self.value), self.width }; + return ice::isize{ static_cast(self._value * self._width) }; } constexpr nindex::operator nindex::base_type(this nindex self) noexcept { - return std::max(self.value, 0); + return std::max(self._value, 0); } - constexpr nindex::operator nindex::base_type_signed(this nindex self) noexcept + constexpr nindex::operator nindex::base_signed_type(this nindex self) noexcept { - return std::max(self.value, 0); + return std::max(self._value, 0); } // special operators diff --git a/source/code/core/collections/public/ice/types/nvalue.hxx b/source/code/core/collections/public/ice/types/nvalue.hxx new file mode 100644 index 00000000..12c0c919 --- /dev/null +++ b/source/code/core/collections/public/ice/types/nvalue.hxx @@ -0,0 +1,104 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice +{ + + struct nvalue; + + namespace detail + { + + using nvalue_base_utype = ice::usize::base_type; + using nvalue_base_stype = ice::isize::base_type; + + // utilities + + consteval auto ncount_min_value() noexcept -> ice::detail::nvalue_base_utype; + consteval auto ncount_max_value() noexcept -> ice::detail::nvalue_base_utype; + + // Sanity Checks + + static_assert(sizeof(ice::detail::nvalue_base_utype) == sizeof(size_t)); + static_assert(sizeof(ice::detail::nvalue_base_stype) == sizeof(size_t)); + + } // namespace detail + + struct ncount; + struct nindex; + + namespace concepts + { + + template + concept NValueCompatibleType = (std::is_arithmetic_v and not std::is_floating_point_v) + or std::is_same_v + or std::is_same_v + or std::is_same_v; + + } // namespace concepts + +#if ISP_ARCH_BITS == 64 +#define ICE_NVALUE_VALUE_MAX 0x0000'7fff'ffff'ffff +#define ICE_NVALUE_VALUE_FIELD_BITS : 48 +#define ICE_NVALUE_WIDTH_FIELD_BITS : 16 + + static_assert(sizeof(ice::detail::nvalue_base_utype) == 8); + static_assert(sizeof(ice::detail::nvalue_base_stype) == 8); +#elif ISP_ARCH_BITS == 32 +#define ICE_NVALUE_VALUE_MAX 0xffff'ffff +#define ICE_NVALUE_VALUE_FIELD_BITS +#define ICE_NVALUE_WIDTH_FIELD_BITS + + static_assert(sizeof(ice::detail::nvalue_base_utype) == 4); + static_assert(sizeof(ice::detail::nvalue_base_stype) == 4); +#else +# error Unhandled architecture! +#endif + + consteval auto detail::ncount_min_value() noexcept -> ice::detail::nvalue_base_utype + { + return 0; + } + + consteval auto detail::ncount_max_value() noexcept -> ice::detail::nvalue_base_utype + { + return ICE_NVALUE_VALUE_MAX; + } + + struct nvalue + { + using base_type = ice::detail::nvalue_base_utype; + using base_signed_type = ice::detail::nvalue_base_stype; + + // NOTE: The '_width' needs to be defined BEFORE value. So the high-bits (that are accessed less frequently) contain + // the '_width' field and the low-bits contain the '_value' field. + // This is to ensure that the compiler does not need to shift the '_value' part every time an operation is done. + ice::detail::nvalue_base_utype _width ICE_NVALUE_WIDTH_FIELD_BITS; + ice::detail::nvalue_base_stype _value ICE_NVALUE_VALUE_FIELD_BITS; + + // Checks if the value is valid. (_width > 0) + template + constexpr bool is_valid(this Self self) noexcept { return self._width > 0; } + + template + constexpr auto value_or(this Self self, ice::concepts::NValueCompatibleType auto fallback) noexcept + { + return self.is_valid() ? static_cast>(self.native()) : fallback; + } + + // NOTE: In most cases we will use '_width' as a validation field instead of actually using it's value. + // I may come in handy for some operations (ncount -> usize) but it's purpose is to define a concrete 'invalid' state. + constexpr auto native() const noexcept { return static_cast(_value * (_width != 0)); } + constexpr auto u8() const noexcept { return static_cast(native()); } + constexpr auto u16() const noexcept { return static_cast(native()); } + constexpr auto u32() const noexcept { return static_cast(native()); } + constexpr auto u64() const noexcept { return static_cast(native()); } + + constexpr auto bytes() const noexcept -> ice::usize { return { static_cast(_value) * _width }; } + }; + +} // namespace ice diff --git a/source/code/core/core/public/ice/profiler.hxx b/source/code/core/core/public/ice/profiler.hxx index 0f6e9312..6d4147fe 100644 --- a/source/code/core/core/public/ice/profiler.hxx +++ b/source/code/core/core/public/ice/profiler.hxx @@ -23,18 +23,18 @@ # define IPT_ZONE_SCOPED ZoneScoped # define IPT_ZONE_SCOPED_NAMED( ... ) ZoneScopedN( __VA_ARGS__ ) -# define IPT_ZONE_NAME_STR( str ) ZoneName( ice::string::begin(str), ice::string::size(str) ) +# define IPT_ZONE_NAME_STR( str ) ZoneName( str.begin(), str.size() ) # define IPT_ZONE_TEXT( txt, size ) ZoneText( txt, size ) -# define IPT_ZONE_TEXT_STR( str ) IPT_ZONE_TEXT( ice::string::begin(str), ice::string::size(str) ) +# define IPT_ZONE_TEXT_STR( str ) IPT_ZONE_TEXT( str.begin(), str.size() ) # define IPT_ALLOC( ptr, size ) TracyAlloc( ptr, size ) # define IPT_DEALLOC( ptr ) TracyFree( ptr ) -# define IPT_ALLOC_POOL( ptr, size, name ) TracyAllocN( ptr, size, ice::string::begin(name) ) -# define IPT_DEALLOC_POOL( ptr, name ) TracyFreeN( ptr, ice::string::begin(name) ) +# define IPT_ALLOC_POOL( ptr, size, name ) TracyAllocN( ptr, size, name.begin() ) +# define IPT_DEALLOC_POOL( ptr, name ) TracyFreeN( ptr, name.begin() ) # define IPT_MESSAGE( txt ) TracyMessage( txt, ice::count(txt) ) -# define IPT_MESSAGE_STR( txt ) TracyMessage( ice::string::begin(txt), ice::string::size(txt) ) +# define IPT_MESSAGE_STR( txt ) TracyMessage( txt.begin(), txt.size() ) # if defined(TRACY_FIBERS) From a2f17f47cc632c98db6cca1f3f71435e209b2b6d Mon Sep 17 00:00:00 2001 From: Dandielo Date: Tue, 6 Jan 2026 23:34:31 +0900 Subject: [PATCH 04/40] Final implementation of the 'nvalue' and derived types. #ICE-204 comment Additional functionality might be added later. --- .../public/ice/string/readonly_operations.hxx | 4 +- .../ice/string/resizable_operations.hxx | 2 +- .../collections/public/ice/types/ncount.hxx | 175 +++------------- .../collections/public/ice/types/nindex.hxx | 170 ++------------- .../collections/public/ice/types/nvalue.hxx | 193 +++++++++++++++++- .../resource_system/public/ice/uri.hxx | 2 +- 6 files changed, 236 insertions(+), 310 deletions(-) diff --git a/source/code/core/collections/public/ice/string/readonly_operations.hxx b/source/code/core/collections/public/ice/string/readonly_operations.hxx index 9ea47395..99ba603a 100644 --- a/source/code/core/collections/public/ice/string/readonly_operations.hxx +++ b/source/code/core/collections/public/ice/string/readonly_operations.hxx @@ -47,7 +47,7 @@ namespace ice::string return { }; } - if (len == ice::none_count) + if (len == ice::ncount_none) { return { self.data() + pos, size - pos }; } @@ -298,7 +298,7 @@ namespace ice::string template constexpr auto operator[](this Self const& self, ice::nindex index) noexcept -> typename Self::ValueType { - return self.data()[index.native()]; + return self.data()[index]; } template diff --git a/source/code/core/collections/public/ice/string/resizable_operations.hxx b/source/code/core/collections/public/ice/string/resizable_operations.hxx index 53f3fe69..25fc10e4 100644 --- a/source/code/core/collections/public/ice/string/resizable_operations.hxx +++ b/source/code/core/collections/public/ice/string/resizable_operations.hxx @@ -29,7 +29,7 @@ namespace ice::string } template - inline void grow(this Self& self, ice::ncount min_capacity = none_count) noexcept + inline void grow(this Self& self, ice::ncount min_capacity = ncount_none) noexcept { ice::ncount const new_capacity = ice::max(self.capacity() * 2 + 8, min_capacity); self.set_capacity(new_capacity); diff --git a/source/code/core/collections/public/ice/types/ncount.hxx b/source/code/core/collections/public/ice/types/ncount.hxx index 18759e26..8ab48501 100644 --- a/source/code/core/collections/public/ice/types/ncount.hxx +++ b/source/code/core/collections/public/ice/types/ncount.hxx @@ -8,51 +8,40 @@ namespace ice { - struct ncount; - struct nindex; + struct ncount_invalid_t; struct ncount : public ice::nvalue { using nvalue::base_type; using nvalue::base_signed_type; + // support for allocation sizes + constexpr auto bytes(this ncount self) noexcept -> ice::usize; + constexpr ncount() noexcept = default; constexpr ncount(nvalue value) noexcept; constexpr ncount(base_type value) noexcept; constexpr ncount(base_type value, base_type width) noexcept; - // Arithmetic - constexpr auto operator+(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount; - constexpr auto operator-(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount; - constexpr auto operator*(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount; - constexpr auto operator/(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount; - constexpr auto operator+=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount&; - constexpr auto operator-=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount&; - constexpr auto operator*=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount&; - constexpr auto operator/=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount&; - - // Increments - constexpr auto operator++(this ncount& self) noexcept -> ncount&; - constexpr auto operator++(this ncount& self, int) noexcept -> ncount; - constexpr auto operator--(this ncount& self) noexcept -> ncount&; - constexpr auto operator--(this ncount& self, int) noexcept -> ncount; - - // Comparison - constexpr bool operator==(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept; - constexpr auto operator<=>(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept; - - // type colapsing - constexpr explicit operator bool(this ncount self) noexcept; - constexpr operator ice::usize(this ncount self) noexcept; - constexpr operator base_type(this ncount self) noexcept; - constexpr explicit operator base_signed_type(this ncount self) noexcept; + // special operators + constexpr bool operator==(this ncount self, ncount_invalid_t) noexcept; + + // implicit type conversions + constexpr operator ice::usize(this ncount self) noexcept { return self.bytes(); } }; - constexpr ncount::ncount(nvalue value) noexcept + struct ncount_invalid_t : ncount {}; + + inline constexpr auto ncount::bytes(this ncount self) noexcept -> ice::usize + { + return { static_cast(self._value) * self._width }; + } + + inline constexpr ncount::ncount(nvalue value) noexcept : nvalue{ value } { } - constexpr ncount::ncount(base_type value) noexcept + inline constexpr ncount::ncount(base_type value) noexcept : nvalue{ 1, static_cast(value) } { } @@ -60,131 +49,13 @@ namespace ice : nvalue{ width, static_cast(value) } { } - struct ncount_invalid_t : ncount {}; - - static constexpr ice::ncount_invalid_t none_count{ }; - static constexpr ice::ncount ncount_max{ ice::detail::ncount_max_value() }; - static constexpr ice::ncount ncount_min{ ice::detail::ncount_min_value() }; - - static_assert(ice::size_of == 8_B); - - constexpr auto ncount::operator+(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount - { - return ncount{ static_cast(self._value + static_cast(other)), self._width }; - } - - constexpr auto ncount::operator-(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount - { - return ncount{ static_cast(self._value - static_cast(other)), self._width }; - } - - constexpr auto ncount::operator*(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount - { - return ncount{ static_cast(self._value * static_cast(other)), self._width }; - } - - constexpr auto ncount::operator/(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount - { - return ncount{ static_cast(self._value / static_cast(other)), self._width }; - } - - constexpr auto ncount::operator+=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount& - { - self._value += static_cast(other); - return self; - } - - constexpr auto ncount::operator-=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount& - { - self._value -= static_cast(other); - return self; - } - - constexpr auto ncount::operator*=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount& - { - self._value *= static_cast(other); - return self; - } - - constexpr auto ncount::operator/=(this ncount& self, ice::concepts::NValueCompatibleType auto other) noexcept -> ncount& + inline constexpr bool ncount::operator==(this ncount self, ncount_invalid_t) noexcept { - self._value /= static_cast(other); - return self; + return self._width == 0; } - constexpr auto ncount::operator++(this ncount& self) noexcept -> ncount& - { - self._value += 1; - return self; - } - - constexpr auto ncount::operator++(this ncount& self, int) noexcept -> ncount - { - const ncount old = self; - self._value += 1; - return old; - } - - constexpr auto ncount::operator--(this ncount& self) noexcept -> ncount& - { - self._value -= 1; - return self; - } - - constexpr auto ncount::operator--(this ncount& self, int) noexcept -> ncount - { - const ncount old = self; - self._value -= 1; - return old; - } - - constexpr bool ncount::operator==(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept - { - return self._value == static_cast(other); - } - - constexpr auto ncount::operator<=>(this ncount self, ice::concepts::NValueCompatibleType auto other) noexcept - { - return self._value <=> static_cast(other); - } - - constexpr ncount::operator bool(this ncount self) noexcept - { - return static_cast(self._value * self._width); - } - - constexpr ncount::operator ice::usize(this ncount self) noexcept - { - return ice::usize{ static_cast(self._value) * self._width }; - } - - constexpr ncount::operator ncount::base_type(this ncount self) noexcept - { - return std::max(self._value, 0); - } - - constexpr ncount::operator ncount::base_signed_type(this ncount self) noexcept - { - return self._value; - } - - // special operators - - constexpr bool operator==(ncount self, ncount_invalid_t) noexcept - { - return static_cast(self) == false; - } - - template requires (std::is_same_v || std::is_same_v) - constexpr auto operator+(CharType* char_ptr, ncount count) noexcept -> CharType* - { - return char_ptr + count.u64(); - } - - template requires (std::is_same_v || std::is_same_v) - constexpr auto operator+(CharType const* char_ptr, ncount count) noexcept -> CharType const* - { - return char_ptr + count.u64(); - } + static constexpr ice::ncount ncount_max{ ice::detail::nvalue_max_value() }; + static constexpr ice::ncount ncount_min{ ice::detail::nvalue_min_value() }; + static constexpr ice::ncount_invalid_t ncount_none{ }; } // namespace ice diff --git a/source/code/core/collections/public/ice/types/nindex.hxx b/source/code/core/collections/public/ice/types/nindex.hxx index cc47abc6..6eac0aa9 100644 --- a/source/code/core/collections/public/ice/types/nindex.hxx +++ b/source/code/core/collections/public/ice/types/nindex.hxx @@ -7,179 +7,51 @@ namespace ice { + struct nindex_invalid_t; + struct nindex : public ice::nvalue { using nvalue::base_type; using nvalue::base_signed_type; + // support for allocation sizes + constexpr auto offset(this nindex self) noexcept -> ice::usize; + constexpr nindex() noexcept = default; constexpr nindex(nvalue value) noexcept; constexpr nindex(base_type value) noexcept; constexpr nindex(base_type value, base_type width) noexcept; + // special operators + constexpr bool operator==(this ncount self, nindex_invalid_t) noexcept; + }; - // Arithmetic - constexpr auto operator+(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex; - constexpr auto operator-(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex; - constexpr auto operator*(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex; - constexpr auto operator/(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex; - constexpr auto operator+=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex&; - constexpr auto operator-=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex&; - constexpr auto operator*=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex&; - constexpr auto operator/=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex&; - - // Increments - constexpr auto operator++(this nindex& self) noexcept -> nindex&; - constexpr auto operator++(this nindex& self, int) noexcept -> nindex; - constexpr auto operator--(this nindex& self) noexcept -> nindex&; - constexpr auto operator--(this nindex& self, int) noexcept -> nindex; - - // Comparison - constexpr bool operator==(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept; - constexpr auto operator<=>(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept; + struct nindex_invalid_t : nindex {}; - // type colapsing - constexpr explicit operator bool(this nindex self) noexcept; - constexpr operator ice::isize(this nindex self) noexcept; - constexpr operator base_type(this nindex self) noexcept; - constexpr explicit operator base_signed_type(this nindex self) noexcept; - }; + inline constexpr auto nindex::offset(this nindex self) noexcept -> ice::usize + { + return { static_cast(self._value) * self._width }; + } - constexpr nindex::nindex(nvalue value) noexcept + inline constexpr nindex::nindex(nvalue value) noexcept : nvalue{ value } { } - constexpr nindex::nindex(base_type value) noexcept + inline constexpr nindex::nindex(base_type value) noexcept : nvalue{ 1, static_cast(value) } { } - constexpr nindex::nindex(base_type value, base_type width) noexcept + inline constexpr nindex::nindex(base_type value, base_type width) noexcept : nvalue{ width, static_cast(value) } { } - struct nindex_invalid_t : nindex { }; - - static constexpr ice::nindex_invalid_t none_index{ }; - - static_assert(ice::size_of == 8_B); - - constexpr auto nindex::operator+(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex - { - return nindex{ self._value + static_cast(other), self._width }; - } - - constexpr auto nindex::operator-(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex + inline constexpr bool nindex::operator==(this ncount self, nindex_invalid_t) noexcept { - return nindex{ self._value - static_cast(other), self._width }; + return self._width == 0; } - constexpr auto nindex::operator*(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex - { - return nindex{ self._value * static_cast(other), self._width }; - } - - constexpr auto nindex::operator/(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex - { - return nindex{ self._value / static_cast(other), self._width }; - } - - constexpr auto nindex::operator+=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex& - { - self._value += static_cast(other); - return self; - } - - constexpr auto nindex::operator-=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex& - { - self._value -= static_cast(other); - return self; - } - - constexpr auto nindex::operator*=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex& - { - self._value *= static_cast(other); - return self; - } - - constexpr auto nindex::operator/=(this nindex& self, ice::concepts::NValueCompatibleType auto other) noexcept -> nindex& - { - self._value /= static_cast(other); - return self; - } - - constexpr auto nindex::operator++(this nindex& self) noexcept -> nindex& - { - self._value += 1; - return self; - } - - constexpr auto nindex::operator++(this nindex& self, int) noexcept -> nindex - { - const nindex old = self; - self._value += 1; - return old; - } - - constexpr auto nindex::operator--(this nindex& self) noexcept -> nindex& - { - self._value -= 1; - return self; - } - - constexpr auto nindex::operator--(this nindex& self, int) noexcept -> nindex - { - const nindex old = self; - self._value -= 1; - return old; - } - - constexpr bool nindex::operator==(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept - { - return static_cast(self._value) == static_cast(other); - } - - constexpr auto nindex::operator<=>(this nindex self, ice::concepts::NValueCompatibleType auto other) noexcept - { - return static_cast(self._value) <=> static_cast(other); - } - - constexpr nindex::operator bool(this nindex self) noexcept - { - return static_cast(self._value * self._width); - } - - constexpr nindex::operator ice::isize(this nindex self) noexcept - { - return ice::isize{ static_cast(self._value * self._width) }; - } - - constexpr nindex::operator nindex::base_type(this nindex self) noexcept - { - return std::max(self._value, 0); - } - - constexpr nindex::operator nindex::base_signed_type(this nindex self) noexcept - { - return std::max(self._value, 0); - } - - // special operators - - constexpr bool operator==(nindex self, nindex_invalid_t) noexcept - { - return self.is_valid() == false; - } - - template requires (std::is_same_v || std::is_same_v) - constexpr auto operator+(CharType* char_ptr, nindex index) noexcept -> CharType* - { - return char_ptr + index.u64(); - } - - template requires (std::is_same_v || std::is_same_v) - constexpr auto operator+(CharType const* char_ptr, nindex index) noexcept -> CharType const* - { - return char_ptr + index.u64(); - } + static constexpr ice::nindex nindex_max{ ice::detail::nvalue_max_value() }; + static constexpr ice::nindex nindex_min{ ice::detail::nvalue_min_value() }; + static constexpr ice::nindex_invalid_t none_index{ }; } // namespace ice diff --git a/source/code/core/collections/public/ice/types/nvalue.hxx b/source/code/core/collections/public/ice/types/nvalue.hxx index 12c0c919..230fcaac 100644 --- a/source/code/core/collections/public/ice/types/nvalue.hxx +++ b/source/code/core/collections/public/ice/types/nvalue.hxx @@ -17,8 +17,8 @@ namespace ice // utilities - consteval auto ncount_min_value() noexcept -> ice::detail::nvalue_base_utype; - consteval auto ncount_max_value() noexcept -> ice::detail::nvalue_base_utype; + consteval auto nvalue_min_value() noexcept -> ice::detail::nvalue_base_utype; + consteval auto nvalue_max_value() noexcept -> ice::detail::nvalue_base_utype; // Sanity Checks @@ -59,12 +59,12 @@ namespace ice # error Unhandled architecture! #endif - consteval auto detail::ncount_min_value() noexcept -> ice::detail::nvalue_base_utype + consteval auto detail::nvalue_min_value() noexcept -> ice::detail::nvalue_base_utype { return 0; } - consteval auto detail::ncount_max_value() noexcept -> ice::detail::nvalue_base_utype + consteval auto detail::nvalue_max_value() noexcept -> ice::detail::nvalue_base_utype { return ICE_NVALUE_VALUE_MAX; } @@ -98,7 +98,190 @@ namespace ice constexpr auto u32() const noexcept { return static_cast(native()); } constexpr auto u64() const noexcept { return static_cast(native()); } - constexpr auto bytes() const noexcept -> ice::usize { return { static_cast(_value) * _width }; } + // Allow 'nvalue' types collaps to the 'base_type' + constexpr operator base_type(this nvalue self) noexcept { return self.native(); } + + // Equality is has two cases: + // > when deriving from 'nvalue': + // - both sides need to be either invalid or valid and have the same '_value'. + // - the '_width' can be different. + // > when comparing to a regular number: + // - the 'nvalue' needs to be valid and the number has the the same value as '_value' + template + constexpr bool operator==(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept; + + template + constexpr auto operator<=>( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> std::strong_ordering; + + // Increments + template + constexpr auto operator++(this Self& self) noexcept -> Self&; + + template + constexpr auto operator++(this Self& self, int) noexcept -> Self; + + template + constexpr auto operator--(this Self& self) noexcept -> Self&; + + template + constexpr auto operator--(this Self& self, int) noexcept -> Self; + + // Arithmetics + template + constexpr auto operator+(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self; + + template + constexpr auto operator-(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self; + + template + constexpr auto operator*(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self; + + template + constexpr auto operator/(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self; + + template + constexpr auto operator+=(this Self& self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self&; + + template + constexpr auto operator-=(this Self& self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self&; + + template + constexpr auto operator*=(this Self& self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self&; + + template + constexpr auto operator/=(this Self& self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self&; }; + template + inline constexpr bool nvalue::operator==( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept + { + if constexpr (std::is_base_of_v) + { + return self.native() == other.native(); + } + else + { + return self.native() == other; + } + } + + template + inline constexpr auto nvalue::operator<=>( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> std::strong_ordering + { + if constexpr (std::is_base_of_v) + { + return self.native() <=> other.native(); + } + else + { + return self.native() <=> static_cast(other); + } + } + + // Increments + template + constexpr auto nvalue::operator++(this Self& self) noexcept -> Self& + { + self._value += 1; + return self; + } + + template + constexpr auto nvalue::operator++(this Self& self, int) noexcept -> Self + { + const Self old = self; + self._value += 1; + return old; + } + + template + constexpr auto nvalue::operator--(this Self& self) noexcept -> Self& + { + self._value -= 1; + return self; + } + + template + constexpr auto nvalue::operator--(this Self& self, int) noexcept -> Self + { + const Self old = self; + self._value -= 1; + return old; + } + + // Arithmetics + template + inline constexpr auto nvalue::operator+( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self + { + return Self{ ice::nvalue{ self._width, self._value + static_cast(other) } }; + } + + template + inline constexpr auto nvalue::operator-( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self + { + return Self{ ice::nvalue{ self._width, self._value - static_cast(other) } }; + } + + template + inline constexpr auto nvalue::operator*( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self + { + return Self{ ice::nvalue{ self._width, self._value * static_cast(other) } }; + } + + template + inline constexpr auto nvalue::operator/( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self + { + return Self{ ice::nvalue{ self._width, self._value / static_cast(other) } }; + } + + template + inline constexpr auto nvalue::operator+=( + this Self& self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self& + { + self._value += static_cast(other); + return self; + } + + template + inline constexpr auto nvalue::operator-=( + this Self& self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self& + { + self._value -= static_cast(other); + return self; + } + + template + inline constexpr auto nvalue::operator*=( + this Self& self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self& + { + self._value *= static_cast(other); + return self; + } + + template + inline constexpr auto nvalue::operator/=( + this Self& self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self& + { + self._value /= static_cast(other); + return self; + } + } // namespace ice diff --git a/source/code/systems/resource_system/public/ice/uri.hxx b/source/code/systems/resource_system/public/ice/uri.hxx index f6465499..eb22bc9f 100644 --- a/source/code/systems/resource_system/public/ice/uri.hxx +++ b/source/code/systems/resource_system/public/ice/uri.hxx @@ -206,7 +206,7 @@ namespace ice , _query{ } , _fragment{ } { - ice::u8 scheme_size; + ice::u8 scheme_size = 0; if (detail::get_scheme_size(uri_raw, scheme_size)) { _scheme = scheme_size; From d0ae2f0eccef0b472f8bb80a90f1023acfa0cfab Mon Sep 17 00:00:00 2001 From: Dandielo Date: Wed, 7 Jan 2026 00:23:14 +0900 Subject: [PATCH 05/40] #ICE-205 State In Progress Proof of concept on defining container operations using C++ concepts and mixin types. --- .../ice/container/container_concepts.hxx | 25 +++++++++++++++++++ .../ice/container/contiguous_container.hxx | 16 ++++++++++++ .../public/ice/container_types.hxx | 12 +++++++++ 3 files changed, 53 insertions(+) create mode 100644 source/code/core/collections/public/ice/container/container_concepts.hxx create mode 100644 source/code/core/collections/public/ice/container/contiguous_container.hxx diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx new file mode 100644 index 00000000..1cfd1241 --- /dev/null +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -0,0 +1,25 @@ +#pragma once +#include +#include + +namespace ice::concepts +{ + + template + concept ContiguousContainer = requires(T t) { + { t.size() } -> std::convertible_to; + { t.data() } -> std::convertible_to; + }; + +} // namespace ice::concepts + +namespace ice::container +{ + + template + using ValueRef = ice::const_correct_t, typename ContainerT::ValueType>&; + + template + using ValuePtr = ice::const_correct_t, typename ContainerT::ValueType>*; + +} // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/contiguous_container.hxx b/source/code/core/collections/public/ice/container/contiguous_container.hxx new file mode 100644 index 00000000..7688ad1b --- /dev/null +++ b/source/code/core/collections/public/ice/container/contiguous_container.hxx @@ -0,0 +1,16 @@ +#pragma once +#include + +namespace ice::container +{ + + struct ContiguousContainer + { + template + constexpr auto front(this Self& self) noexcept -> ice::container::ValueRef + { + return self.data()[0]; + } + }; + +} // namespace ice::container diff --git a/source/code/core/collections/public/ice/container_types.hxx b/source/code/core/collections/public/ice/container_types.hxx index 07900073..5c7be632 100644 --- a/source/code/core/collections/public/ice/container_types.hxx +++ b/source/code/core/collections/public/ice/container_types.hxx @@ -3,6 +3,8 @@ #pragma once #include +#include + #include #include #include @@ -10,6 +12,16 @@ namespace ice { + struct Test : ice::container::ContiguousContainer + { + using ValueType = int; + + int foo[4]; + + template + constexpr auto data(this Self& self) noexcept -> ice::const_correct_t* { return self.foo; } + constexpr ncount size() const noexcept { return 4; } + }; //! \brief A simple contaier storing items in contignous memory. //! From a0783db3a60a3e154f23a3c5068e23f57d81a681 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Thu, 8 Jan 2026 23:32:18 +0900 Subject: [PATCH 06/40] #ICE-204 Added new 'min_value_or' method and optimized the equality operator. #ICE-203 Added user postifx operators '_count' and '_index'. Fixed minor issues. --- .../core/collections/natvis/string.natvis | 20 ++++++------ .../collections/public/ice/types/ncount.hxx | 6 ++++ .../collections/public/ice/types/nindex.hxx | 8 ++++- .../collections/public/ice/types/nvalue.hxx | 32 +++++++++++++++++-- 4 files changed, 52 insertions(+), 14 deletions(-) diff --git a/source/code/core/collections/natvis/string.natvis b/source/code/core/collections/natvis/string.natvis index c2f4e93d..f825e1a7 100644 --- a/source/code/core/collections/natvis/string.natvis +++ b/source/code/core/collections/natvis/string.natvis @@ -2,22 +2,22 @@ - 0 <invalid> - {value} + 0 <invalid> + {_value} - value - width - value * width + _value + _width + _value * _width - 0 <invalid> - {value} + 0 <invalid> + {_value} - value - width - value * width + _value + _width + _value * _width diff --git a/source/code/core/collections/public/ice/types/ncount.hxx b/source/code/core/collections/public/ice/types/ncount.hxx index 8ab48501..925cfc02 100644 --- a/source/code/core/collections/public/ice/types/ncount.hxx +++ b/source/code/core/collections/public/ice/types/ncount.hxx @@ -14,6 +14,7 @@ namespace ice { using nvalue::base_type; using nvalue::base_signed_type; + using ice::nvalue::operator==; // support for allocation sizes constexpr auto bytes(this ncount self) noexcept -> ice::usize; @@ -58,4 +59,9 @@ namespace ice static constexpr ice::ncount ncount_min{ ice::detail::nvalue_min_value() }; static constexpr ice::ncount_invalid_t ncount_none{ }; + constexpr auto operator""_count(unsigned long long value) noexcept -> ice::ncount + { + return ice::ncount{ value }; + } + } // namespace ice diff --git a/source/code/core/collections/public/ice/types/nindex.hxx b/source/code/core/collections/public/ice/types/nindex.hxx index 6eac0aa9..e87d1354 100644 --- a/source/code/core/collections/public/ice/types/nindex.hxx +++ b/source/code/core/collections/public/ice/types/nindex.hxx @@ -13,6 +13,7 @@ namespace ice { using nvalue::base_type; using nvalue::base_signed_type; + using ice::nvalue::operator==; // support for allocation sizes constexpr auto offset(this nindex self) noexcept -> ice::usize; @@ -52,6 +53,11 @@ namespace ice static constexpr ice::nindex nindex_max{ ice::detail::nvalue_max_value() }; static constexpr ice::nindex nindex_min{ ice::detail::nvalue_min_value() }; - static constexpr ice::nindex_invalid_t none_index{ }; + static constexpr ice::nindex_invalid_t nindex_none{ }; + + constexpr auto operator""_index(unsigned long long value) noexcept -> ice::nindex + { + return ice::nindex{ value }; + } } // namespace ice diff --git a/source/code/core/collections/public/ice/types/nvalue.hxx b/source/code/core/collections/public/ice/types/nvalue.hxx index 230fcaac..ea03a1b2 100644 --- a/source/code/core/collections/public/ice/types/nvalue.hxx +++ b/source/code/core/collections/public/ice/types/nvalue.hxx @@ -80,9 +80,9 @@ namespace ice ice::detail::nvalue_base_utype _width ICE_NVALUE_WIDTH_FIELD_BITS; ice::detail::nvalue_base_stype _value ICE_NVALUE_VALUE_FIELD_BITS; - // Checks if the value is valid. (_width > 0) + // Checks if the value is valid. (_width != 0) template - constexpr bool is_valid(this Self self) noexcept { return self._width > 0; } + constexpr bool is_valid(this Self self) noexcept { return static_cast(self._width); } template constexpr auto value_or(this Self self, ice::concepts::NValueCompatibleType auto fallback) noexcept @@ -90,6 +90,19 @@ namespace ice return self.is_valid() ? static_cast>(self.native()) : fallback; } + template + constexpr auto min_value_or( + this Self self, + ice::concepts::NValueCompatibleType auto other, + ice::concepts::NValueCompatibleType auto fallback + ) noexcept + { + using ResultType = std::remove_reference_t; + + ResultType const second_value = static_cast(other); + return self.is_valid() ? ice::min(static_cast(self.native()), second_value) : fallback; + } + // NOTE: In most cases we will use '_width' as a validation field instead of actually using it's value. // I may come in handy for some operations (ncount -> usize) but it's purpose is to define a concrete 'invalid' state. constexpr auto native() const noexcept { return static_cast(_value * (_width != 0)); } @@ -161,7 +174,11 @@ namespace ice { if constexpr (std::is_base_of_v) { - return self.native() == other.native(); +#if 0 // The naive approach (contains jump instructions even after optimization) + return self.is_valid() == other.is_valid() && (self.is_valid() == false || self.native() == other.native()); +#else // The mathematical approach (jump instructions are not present, branch predictor is happy) + return static_cast((self._width * other._width) * (self._value == other._value) + ((self._width + other._width) == 0)); +#endif } else { @@ -169,6 +186,15 @@ namespace ice } } + // (nvalue{W, V} == nvalue{W, V}); + static_assert(nvalue{0, 0} == nvalue{0, 0}, "Invalid values are equal to each other"); + static_assert(nvalue{0, 1} == nvalue{0, 1}, "Invalid values are equal to each other ('_value' is not '0')"); + static_assert(nvalue{1, 0} == nvalue{1, 0}, "Valid values are equal if '_value' is the same."); + static_assert(nvalue{1, 4} == nvalue{2, 4}, "Valid values are equal if '_value' is the same. ('_width' differs)"); + static_assert(nvalue{1, 0} != nvalue{0, 0}, "Valid values are not equal to invalid values. ('_value' is '0' in both)"); + static_assert(nvalue{1, 0} != nvalue{1, 1}, "Valid values are not equal if '_value' differs ('_width' is '1' in both)"); + static_assert(nvalue{1, 1} != nvalue{2, 2}, "Valid values are not equal if '_value' differs ('_width' and '_value' differs)"); + template inline constexpr auto nvalue::operator<=>( this Self self, ice::concepts::NValueCompatibleType auto other From ab2addec6712504178ffae65ac3663aa14b0ed68 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Thu, 8 Jan 2026 23:35:10 +0900 Subject: [PATCH 07/40] (#ICE-205, #ICE-206) State In Progress Finished a working example of the 'Span' type being based on a 'ContiguousContainer' mixin. --- .../ice/container/container_concepts.hxx | 38 +++++- .../ice/container/contiguous_container.hxx | 76 ++++++++++- .../public/ice/container/impl/array_impl.inl | 25 ++-- .../public/ice/container/impl/queue_impl.inl | 8 +- .../code/core/collections/public/ice/sort.hxx | 12 +- .../code/core/collections/public/ice/span.hxx | 119 +++--------------- .../public/ice/string/readonly_operations.hxx | 8 +- 7 files changed, 149 insertions(+), 137 deletions(-) diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index 1cfd1241..df86b312 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -6,20 +6,46 @@ namespace ice::concepts { template - concept ContiguousContainer = requires(T t) { + concept ContainerType = requires(T t) { + typename std::remove_reference_t::SizeType; + typename std::remove_reference_t::ValueType; + typename std::remove_reference_t::Iterator; + typename std::remove_reference_t::ReverseIterator; + typename std::remove_reference_t::ConstIterator; + typename std::remove_reference_t::ConstReverseIterator; + }; + + template + concept ContiguousContainer = ContainerType && requires(T t) { { t.size() } -> std::convertible_to; - { t.data() } -> std::convertible_to; + { t.data() } -> std::convertible_to::ValueType const*>; }; } // namespace ice::concepts +namespace ice +{ + + template + struct Span; + +} // namespace ice + namespace ice::container { - template - using ValueRef = ice::const_correct_t, typename ContainerT::ValueType>&; + template + using ContainerType = typename std::remove_reference_t; + + template + using SpanType = ice::Span::ValueType>; + + template + //using ValueRef = ice::const_correct_t, typename ContainerT::ValueType>&; + using ValueRef = typename std::remove_reference_t::ValueType&; - template - using ValuePtr = ice::const_correct_t, typename ContainerT::ValueType>*; + template + //using ValuePtr = ice::const_correct_t, typename ContainerT::ValueType>*; + using ValuePtr = typename std::remove_reference_t::ValueType*; } // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/contiguous_container.hxx b/source/code/core/collections/public/ice/container/contiguous_container.hxx index 7688ad1b..4e9b5f82 100644 --- a/source/code/core/collections/public/ice/container/contiguous_container.hxx +++ b/source/code/core/collections/public/ice/container/contiguous_container.hxx @@ -4,13 +4,87 @@ namespace ice::container { + template + struct Span; + struct ContiguousContainer { template - constexpr auto front(this Self& self) noexcept -> ice::container::ValueRef + constexpr bool is_empty(this Self const& self) noexcept + { + return self.size() == 0; + } + + template + constexpr bool not_empty(this Self const& self) noexcept + { + return self.is_empty() == false; + } + + template + constexpr auto first(this Self&& self) noexcept -> ice::container::ValueRef { return self.data()[0]; } + + template + constexpr auto last(this Self&& self) noexcept -> ice::container::ValueRef + { + return self.data()[self.size() - 1]; + } + + // Accessing Data with Spans + template + constexpr auto subspan( + this Self&& self, + ice::nindex from, + ice::ncount count = ice::ncount_none + ) noexcept -> ice::container::SpanType + { + ice::ncount const item_count = self.size(); + ice::nindex const from_start = ice::min(from, item_count); + ice::ncount const remaining_count = item_count - from_start; + return { self.data() + from_start, count.min_value_or(remaining_count, remaining_count) }; + } + + template + constexpr auto subspan( + this Self&& self, + ice::ref32 refval + ) noexcept -> ice::container::SpanType + { + return self.subspan(refval.offset, refval.size); + } + + template + constexpr auto headspan( + this Self&& self, + ice::ncount count = 1 + ) noexcept -> ice::container::SpanType + { + // If 'count' is not valid we default to '0' so the returned span is empty. + return { self.data(), count.min_value_or(self.size(), 0_count) }; + } + + template + constexpr auto tailspan( + this Self&& self, + ice::nindex offset = 1 + ) noexcept -> ice::container::SpanType + { + ice::nindex const max_offset = self.size(); + offset = offset.min_value_or(max_offset, max_offset); + + // If 'offset' is not valid we default to 'max_size' so the returned span is empty. + return { self.data() + max_offset, max_offset - offset }; + } + + // Operators + template + constexpr auto operator[](this Self&& self, ice::nindex index) noexcept -> ice::container::ValueRef + { + return self.data()[index]; + } }; } // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/impl/array_impl.inl b/source/code/core/collections/public/ice/container/impl/array_impl.inl index 79608885..e724b67c 100644 --- a/source/code/core/collections/public/ice/container/impl/array_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/array_impl.inl @@ -75,16 +75,16 @@ namespace ice , _count{ 0 } , _data{ nullptr } { - if (ice::span::count(values) > 0) + if (values.not_empty()) { - ice::array::set_capacity(*this, ice::span::count(values)); + ice::array::set_capacity(*this, values.size().u32()); if constexpr (Logic == ContainerLogic::Complex) { ice::mem_copy_construct_n_at( ice::array::memory(*this), ice::span::data(values), - ice::span::count(values) + values.size() ); } else @@ -92,7 +92,7 @@ namespace ice ice::memcpy(_data, ice::span::data(values), ice::span::size_bytes(values)); } - _count = ice::span::count(values); + _count = values.size().u32(); } } @@ -288,7 +288,8 @@ namespace ice template inline auto slice(ice::Array& arr, ice::u32 from_idx, ice::u32 count) noexcept -> ice::Span { - return ice::span::subspan(arr, from_idx, count); + ice::Span arr_span{ arr }; + return arr_span.subspan(from_idx, count); } template @@ -350,7 +351,7 @@ namespace ice requires std::copy_constructible inline void push_back(ice::Array& arr, ice::Span items) noexcept { - ice::u32 const required_capacity = arr._count + ice::span::count(items); + ice::u32 const required_capacity = arr._count + items.size().u32(); if (required_capacity > arr._capacity) { ice::array::grow(arr, required_capacity); @@ -362,7 +363,7 @@ namespace ice ice::mem_copy_construct_n_at( Memory{ .location = arr._data + arr._count, .size = ice::size_of * missing_items, .alignment = ice::align_of }, ice::span::data(items), - ice::span::count(items) + items.size().u32() ); } else @@ -373,14 +374,14 @@ namespace ice ); } - arr._count += ice::span::count(items); + arr._count += items.size().u32(); } template requires std::copy_constructible && (std::is_same_v == false) inline void push_back(ice::Array& arr, ice::Span items, Type(*fn)(Source const&) noexcept) noexcept { - ice::u32 const required_capacity = arr._count + ice::span::count(items); + ice::u32 const required_capacity = arr._count + items.size(); if (required_capacity > arr._capacity) { ice::array::grow(arr, required_capacity); @@ -485,13 +486,15 @@ namespace ice template inline auto slice(ice::Array const& arr, ice::u32 from_idx, ice::u32 count) noexcept -> ice::Span { - return ice::span::subspan(arr, from_idx, count); + ice::Span arr_span{ arr }; + return arr_span.subspan(from_idx, count); } template inline auto slice(ice::Array const& arr, ice::ref32 ref) noexcept -> ice::Span { - return ice::span::subspan(arr, ref); + ice::Span arr_span{ arr }; + return arr_span.subspan(ref.offset, ref.size); } template diff --git a/source/code/core/collections/public/ice/container/impl/queue_impl.inl b/source/code/core/collections/public/ice/container/impl/queue_impl.inl index 1695156b..b0426c58 100644 --- a/source/code/core/collections/public/ice/container/impl/queue_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/queue_impl.inl @@ -438,13 +438,13 @@ namespace ice requires std::copy_constructible inline void push_back(ice::Queue& queue, ice::Span items) noexcept { - ice::u32 const required_capacity = queue._count + ice::span::count(items); + ice::u32 const required_capacity = queue._count + items.size().u32(); if (required_capacity > queue._capacity) { ice::queue::grow(queue, required_capacity); } - ice::u32 const span_count = ice::span::count(items); + ice::u32 const span_count = items.size().u32(); ice::u32 const start_idx = (queue._offset + queue._count) % queue._capacity; ice::u32 const end_idx = ice::min(queue._capacity, start_idx + span_count); @@ -502,7 +502,7 @@ namespace ice ); } - queue._count += ice::span::count(items); + queue._count += items.size().u32(); } template @@ -596,7 +596,7 @@ namespace ice template inline auto take_front(ice::Queue& queue, ice::Span out_values) noexcept -> ice::u32 { - ice::u32 const taken_items = ice::min(ice::count(out_values), ice::count(queue)); + ice::u32 const taken_items = ice::min(out_values.size().u32(), ice::count(queue)); // (offset, end][0, remaining) ice::u32 const first_part = ice::min(queue._offset + taken_items, queue._capacity); diff --git a/source/code/core/collections/public/ice/sort.hxx b/source/code/core/collections/public/ice/sort.hxx index 1f654602..62401937 100644 --- a/source/code/core/collections/public/ice/sort.hxx +++ b/source/code/core/collections/public/ice/sort.hxx @@ -92,14 +92,14 @@ namespace ice constexpr bool binary_search(ice::Span values, U const& predicate, ice::u32& out_index) noexcept { out_index = ice::lower_bound(values, predicate); - return (ice::count(values) != out_index) && (values[out_index] == predicate); + return (values.size() != out_index) && (values[out_index] == predicate); } template requires (std::convertible_to) constexpr bool binary_search(ice::Span values, U const& predicate, Comp&& comp, ice::u32& out_index) noexcept { out_index = ice::lower_bound(values, predicate, ice::forward(comp)); - return (ice::count(values) != out_index) && (values[out_index] == predicate); + return (values.size() != out_index) && (values[out_index] == predicate); } template requires (std::convertible_to) @@ -111,11 +111,11 @@ namespace ice template constexpr bool search(ice::Span values, U const& value, Comp&& comp, ice::u32& out_index) noexcept { - for (ice::u32 idx = 0; idx < ice::span::count(values); ++idx) + for (ice::nindex idx = 0; idx < values.size(); ++idx) { if (ice::forward(comp)(values[idx], value)) { - out_index = idx; + out_index = idx.u32(); return true; } } @@ -125,7 +125,7 @@ namespace ice template constexpr bool search_with(ice::Span values, Comp&& comp, ice::u32& out_index, U const&... params) noexcept { - for (ice::u32 idx = 0; idx < ice::span::count(values); ++idx) + for (ice::u32 idx = 0; idx < values.size(); ++idx) { if (ice::forward(comp)(values[idx], idx, params...)) { @@ -300,7 +300,7 @@ namespace ice inline void sort_indices(ice::Span keys, ice::Span indices, Pred&& pred) noexcept { ice::i32 const first_index = 0; - ice::i32 const last_index = ice::count(keys) - 1; + ice::i32 const last_index = keys.size().u32() - 1; ice::detail::qsort_indices(keys, indices, std::forward(pred), first_index, last_index); } diff --git a/source/code/core/collections/public/ice/span.hxx b/source/code/core/collections/public/ice/span.hxx index 6ce8059f..cfbffeb8 100644 --- a/source/code/core/collections/public/ice/span.hxx +++ b/source/code/core/collections/public/ice/span.hxx @@ -6,6 +6,7 @@ #include #include #include +#include #include #include // TODO: Introduce our own static array object. @@ -14,7 +15,7 @@ namespace ice //! \brief A view into an array of objects laid out in contiguous memory. template - struct Span + struct Span : public ice::container::ContiguousContainer { using ValueType = Type; using Iterator = Type*; @@ -23,13 +24,13 @@ namespace ice using ConstReverseIterator = std::reverse_iterator; using SizeType = ice::ncount; - u64 _count; - Type* _data; + SizeType::base_type _count; + ValueType* _data; constexpr Span() noexcept; constexpr Span(ice::Span&& other) noexcept = default; constexpr Span(ice::Span const& other) noexcept = default; - constexpr Span(Type* location, u64 count) noexcept; + constexpr Span(Type* location, ice::ncount count) noexcept; constexpr Span(Type* from, Type* to) noexcept; template @@ -38,9 +39,13 @@ namespace ice constexpr auto operator=(ice::Span&& other) noexcept -> ice::Span& = default; constexpr auto operator=(ice::Span const& other) noexcept -> ice::Span& = default; - constexpr auto operator[](ice::u64 idx) const noexcept -> Type&; constexpr operator ice::Span() noexcept { return { _data, _count }; } constexpr operator ice::Span() const noexcept { return { _data, _count }; } + + // API Requirements Of: Contiguous Container + template + constexpr auto data(this Self& self) noexcept -> ice::container::ValuePtr { return self._data; } + constexpr auto size(this Span const& self) noexcept -> ice::ncount { return { self._count, sizeof(ValueType) }; } }; template Span(T(&)[Size]) noexcept -> Span; @@ -51,45 +56,15 @@ namespace ice namespace span { - template - constexpr bool empty(ice::Span span) noexcept; - - template - constexpr bool any(ice::Span span) noexcept; - - template - constexpr auto data(ice::Span span) noexcept -> Type*; - template constexpr auto data_view(ice::Span span) noexcept -> ice::Data; - template - constexpr auto count(ice::Span span) noexcept -> ice::u32; - template constexpr auto size_bytes(ice::Span span) noexcept -> ice::usize; template constexpr auto alignment(ice::Span span) noexcept -> ice::ualign; - template - constexpr auto front(ice::Span span) noexcept -> Type&; - - template - constexpr auto back(ice::Span span) noexcept -> Type&; - - template - constexpr auto head(ice::Span span, ice::u64 count) noexcept -> ice::Span; - - template - constexpr auto tail(ice::Span span, ice::u64 from_idx) noexcept -> ice::Span; - - template - constexpr auto subspan(ice::Span span, ice::u64 from_idx, ice::u64 count = ice::u32_max) noexcept -> ice::Span; - - template - constexpr auto subspan(ice::Span span, ice::ref32 ref) noexcept -> ice::Span; - template constexpr auto begin(ice::Span span) noexcept -> typename ice::Span::Iterator; @@ -135,7 +110,7 @@ namespace ice out_value._data = reinterpret_cast(source.location); ice::usize const consumed_size = ice::size_of *count; - source.location = ice::span::data(out_value) + count; + source.location = out_value.data() + count; source.size = ice::usize::subtract(source.size, consumed_size); source.alignment = ice::align_of; return source; @@ -151,8 +126,8 @@ namespace ice } template - constexpr Span::Span(Type* location, ice::u64 count) noexcept - : _count{ count } + constexpr Span::Span(Type* location, ice::ncount count) noexcept + : _count{ count.native() } , _data{ location } { } @@ -172,28 +147,9 @@ namespace ice { } - template - constexpr auto Span::operator[](ice::u64 idx) const noexcept -> Type& - { - // TODO: ASSERT - return _data[idx]; - } - namespace span { - template - constexpr bool empty(ice::Span span) noexcept - { - return span._count == 0; - } - - template - constexpr bool any(ice::Span span) noexcept - { - return span._count != 0; - } - template constexpr auto data(ice::Span span) noexcept -> Type* { @@ -210,16 +166,10 @@ namespace ice }; } - template - constexpr auto count(ice::Span span) noexcept -> ice::u32 - { - return u32(span._count); - } - template constexpr auto size_bytes(ice::Span span) noexcept -> ice::usize { - return ice::size_of * ice::span::count(span); + return span.size(); } template @@ -228,46 +178,6 @@ namespace ice return ice::align_of; } - template - constexpr auto front(ice::Span span) noexcept -> Type& - { - return span._data[0]; - } - - template - constexpr auto back(ice::Span span) noexcept -> Type& - { - return span._data[0]; - } - - template - constexpr auto head(ice::Span span, ice::u64 count) noexcept -> ice::Span - { - ice::u64 const new_count = ice::min(count, span._count); - return { span._data, new_count }; - } - - template - constexpr auto tail(ice::Span span, ice::u64 from_idx) noexcept -> ice::Span - { - ice::u64 const from_start = ice::min(from_idx, span._count); - return { span._data + from_start, span._count - from_start }; - } - - template - constexpr auto subspan(ice::Span span, ice::u64 from_idx, ice::u64 count) noexcept -> ice::Span - { - ice::u64 const from_start = ice::min(from_idx, span._count); - ice::u64 const new_count = ice::min(span._count - from_start, count); - return { span._data + from_start, new_count }; - } - - template - constexpr auto subspan(ice::Span span, ice::ref32 ref) noexcept -> ice::Span - { - return ice::span::subspan(span, ref.offset, ref.size); - } - template constexpr auto begin(ice::Span span) noexcept -> typename ice::Span::Iterator { @@ -365,7 +275,6 @@ namespace ice } // namespace span - using ice::span::count; using ice::span::data_view; using ice::span::begin; diff --git a/source/code/core/collections/public/ice/string/readonly_operations.hxx b/source/code/core/collections/public/ice/string/readonly_operations.hxx index 99ba603a..4e77c521 100644 --- a/source/code/core/collections/public/ice/string/readonly_operations.hxx +++ b/source/code/core/collections/public/ice/string/readonly_operations.hxx @@ -101,7 +101,7 @@ namespace ice::string auto const* const beg = it; auto const* const it_end = self.cend(); - while (it < it_end && character_values.find_first_of(*it) == none_index) + while (it < it_end && character_values.find_first_of(*it) == nindex_none) { it += 1; } @@ -149,7 +149,7 @@ namespace ice::string start -= 1; } - while (it != it_end && character_values.find_first_of(*it) == none_index) + while (it != it_end && character_values.find_first_of(*it) == nindex_none) { it += 1; } @@ -187,7 +187,7 @@ namespace ice::string auto const* const beg = it; auto const* const it_end = self.cend(); - while (it < it_end && character_values.find_first_of(*it) != ice::none_index) + while (it < it_end && character_values.find_first_of(*it) != ice::nindex_none) { it += 1; } @@ -235,7 +235,7 @@ namespace ice::string start_idx -= 1; } - while (it != it_end && character_values.find_first_of(*it) != ice::none_index) + while (it != it_end && character_values.find_first_of(*it) != ice::nindex_none) { it += 1; } From bddb60c5ad12212185122661fd72f8e42b8c8759 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Thu, 8 Jan 2026 23:39:06 +0900 Subject: [PATCH 08/40] #ICE-206 Work Type Refactor (#ICE-203, #ICE-204, #ICE-205, #ICE-206) Required changes after initial refactor of the 'Span' type. --- .../private/internal_tasks/task_utils.hxx | 12 ++-- source/code/core/tasks/private/task_utils.cxx | 4 +- .../private/config/config_builder_value.cxx | 2 +- .../utils/private/config/config_detail.cxx | 2 +- .../code/core/utils/private/native_file.cxx | 4 +- source/code/core/utils/private/path_utils.cxx | 12 ++-- .../asset/tilemap/asset_tilemap_oven_tmx.cxx | 4 +- .../private/ecs/ecs_archetype_index.cxx | 22 +++---- .../engine/private/ecs/ecs_entity_index.cxx | 4 +- .../private/ecs/ecs_entity_operations.cxx | 14 ++--- .../engine/private/ecs/ecs_entity_storage.cxx | 18 +++--- .../engine/private/gfx/ice_gfx_graph.cxx | 22 +++---- .../private/gfx/ice_gfx_graph_runtime.cxx | 12 ++-- .../public/ice/ecs/ecs_entity_operations.hxx | 24 ++++---- .../public/ice/ecs/ecs_query_operations.hxx | 10 ++-- .../private/gfx/iceshard_gfx_device.cxx | 4 +- .../private/gfx/iceshard_gfx_queue.cxx | 2 +- .../private/pipeline_ui/ip_ui_asset.cxx | 26 ++++---- .../pipeline_ui/ip_ui_oven_elements.cxx | 8 +-- .../private/pipeline_ui/ip_ui_oven_utils.cxx | 12 ++-- .../imgui_module/private/imgui_system.cxx | 6 +- .../shader_tools/private/shader_tools.cxx | 3 +- .../vulkan_renderer/private/vk_device.cxx | 59 ++++++++++--------- .../vulkan_renderer/private/vk_queue.cxx | 6 +- .../asset_system/private/asset_storage.cxx | 4 +- .../public/ice/asset_category_archive.hxx | 2 +- .../private/input_action_layer.cxx | 12 ++-- .../private/input_action_stack.cxx | 6 +- .../private/resource_filesystem_traverser.cxx | 4 +- .../resource_system/public/ice/uri.hxx | 4 +- .../resource_system/resource_system_tests.bff | 2 +- .../ui_system/private/ui_element_info.cxx | 16 ++--- .../private/asset_compiler_app.cxx | 6 +- .../asset_compiler_resource_provider.cxx | 2 +- .../tools/hsc_packer/private/hsc_packer.cxx | 8 +-- .../hsc_reader/private/hsc_reader_app.cxx | 4 +- 36 files changed, 181 insertions(+), 181 deletions(-) diff --git a/source/code/core/tasks/private/internal_tasks/task_utils.hxx b/source/code/core/tasks/private/internal_tasks/task_utils.hxx index d5629e4d..c13ff73f 100644 --- a/source/code/core/tasks/private/internal_tasks/task_utils.hxx +++ b/source/code/core/tasks/private/internal_tasks/task_utils.hxx @@ -111,13 +111,13 @@ namespace ice constexpr auto await_ready() const noexcept { // Only suspend if we actually have tasks - return ice::span::empty(tasks); + return tasks.is_empty(); } inline auto await_suspend(std::coroutine_handle<> coro) noexcept { // Set the 'running' variable so we can track how many tasks arleady finished. - running.store(ice::count(tasks) + 1, std::memory_order_relaxed); + running.store(tasks.size().u32() + 1, std::memory_order_relaxed); for (ice::Task& task : tasks) { @@ -132,7 +132,7 @@ namespace ice constexpr bool await_resume() const noexcept { ICE_ASSERT_CORE(running.load(std::memory_order_relaxed) == 0); - return ice::span::any(tasks); + return tasks.not_empty(); } }; return Awaitable{ tasks }; @@ -149,13 +149,13 @@ namespace ice constexpr auto await_ready() const noexcept { // Only suspend if we actually have tasks - return ice::span::empty(tasks); + return tasks.is_empty(); } inline auto await_suspend(std::coroutine_handle<> coro) noexcept { // Set the 'running' variable so we can track how many tasks arleady finished. - running.store(ice::count(tasks) + 1, std::memory_order_relaxed); + running.store(tasks.size().u32() + 1, std::memory_order_relaxed); for (ice::Task<>& task : tasks) { @@ -170,7 +170,7 @@ namespace ice constexpr bool await_resume() const noexcept { ICE_ASSERT_CORE(running.load(std::memory_order_relaxed) == 0); - return ice::span::any(tasks); + return tasks.not_empty(); } }; return Awaitable{ tasks, scheduler }; diff --git a/source/code/core/tasks/private/task_utils.cxx b/source/code/core/tasks/private/task_utils.cxx index 3722d575..dc1fc2f4 100644 --- a/source/code/core/tasks/private/task_utils.cxx +++ b/source/code/core/tasks/private/task_utils.cxx @@ -81,7 +81,7 @@ namespace ice { ice::execute_detached_task(ice::move(task)); } - return ice::span::any(tasks); + return tasks.not_empty(); } bool schedule_task(ice::Task<> task, ice::TaskScheduler& scheduler) noexcept @@ -100,7 +100,7 @@ namespace ice { ice::schedule_detached_task(ice::move(task), scheduler); } - return ice::span::any(tasks); + return tasks.not_empty(); } bool schedule_queue(ice::TaskQueue& queue, ice::TaskScheduler& scheduler) noexcept diff --git a/source/code/core/utils/private/config/config_builder_value.cxx b/source/code/core/utils/private/config/config_builder_value.cxx index 7424d732..be107f3f 100644 --- a/source/code/core/utils/private/config/config_builder_value.cxx +++ b/source/code/core/utils/private/config/config_builder_value.cxx @@ -86,7 +86,7 @@ namespace ice auto ice::ConfigBuilderValue::operator[](ice::String key) noexcept -> ConfigBuilderValue { - ICE_ASSERT_CORE(key.find_first_of('.') == ice::none_index); + ICE_ASSERT_CORE(key.find_first_of('.') == ice::nindex_none); ConfigBuilderEntry* const entry = _idx == ice::u32_max ? _internal : (static_cast(_internal)->_entries._data + _idx); diff --git a/source/code/core/utils/private/config/config_detail.cxx b/source/code/core/utils/private/config/config_detail.cxx index 0c62ea66..02a7a344 100644 --- a/source/code/core/utils/private/config/config_detail.cxx +++ b/source/code/core/utils/private/config/config_detail.cxx @@ -132,7 +132,7 @@ namespace ice::config::detail // If this key has multiple parts recursively enter config search ice::nindex key_split_location = key.find_first_of({".|"}); - while (key_split_location != ice::none_index && result) + while (key_split_location != ice::nindex_none && result) { bool const is_table = finalcfg._keys->type != CONFIG_KEYTYPE_STRING; ice::String const keyval = key.substr(0, key_split_location); diff --git a/source/code/core/utils/private/native_file.cxx b/source/code/core/utils/private/native_file.cxx index 2a90a66e..4f6aa220 100644 --- a/source/code/core/utils/private/native_file.cxx +++ b/source/code/core/utils/private/native_file.cxx @@ -444,7 +444,7 @@ namespace ice::native_file { // Remove the top-most the directory explicitly. ice::nindex const dirslash = dirpath.find_last_of(L"\\/"); - if (dirslash == ice::none_index) + if (dirslash == ice::nindex_none) { return false; } @@ -794,7 +794,7 @@ namespace ice::native_file { // Remove the top-most the directory explicitly. ice::nindex const dirslash = ice::string::find_last_of(dirpath, ice::String{ "/" }); - if (dirslash == ice::none_index) + if (dirslash == ice::nindex_none) { return false; } diff --git a/source/code/core/utils/private/path_utils.cxx b/source/code/core/utils/private/path_utils.cxx index 187249b8..04ff766c 100644 --- a/source/code/core/utils/private/path_utils.cxx +++ b/source/code/core/utils/private/path_utils.cxx @@ -30,7 +30,7 @@ namespace ice::path { if (path.size() >= 3) { - return path[1] == Separators_Drive[0] && Separators_Directory.find_first_of(path[2]) != ice::none_index; + return path[1] == Separators_Drive[0] && Separators_Directory.find_first_of(path[2]) != ice::nindex_none; } return false; } @@ -48,7 +48,7 @@ namespace ice::path // Only support single-letter drives return path.size() == 3 && path[1] == Separators_Drive[0] - && path.find_first_of(Separators_Directory, path[2]) != ice::none_index; + && path.find_first_of(Separators_Directory, path[2]) != ice::nindex_none; } else { @@ -82,7 +82,7 @@ namespace ice::path constexpr auto directory(ice::BasicString str) noexcept -> ice::BasicString { ice::nindex const separator_pos = str.find_last_of(Separators_Directory); - if (separator_pos == ice::none_index) + if (separator_pos == ice::nindex_none) { return str.substr(str.size(), separator_pos); } @@ -178,7 +178,7 @@ namespace ice::path it = beg; ice::nindex const begin = path.find_first_of(Separators_Drive); - if (begin != ice::none_index) + if (begin != ice::nindex_none) { it = it + begin + 1; } @@ -222,7 +222,7 @@ namespace ice::path auto replace_filename(ice::HeapString& str, ice::BasicString name) noexcept -> ice::BasicString { auto const separator_pos = str.find_last_of(Separators_Directory); - if (separator_pos != ice::none_index) + if (separator_pos != ice::nindex_none) { str.resize(separator_pos + 1); } @@ -239,7 +239,7 @@ namespace ice::path auto replace_extension(ice::HeapString& str, ice::BasicString extension) noexcept -> ice::BasicString { auto const separator_pos = str.find_last_of(Separators_Dot[0]); - if (separator_pos != ice::none_index) + if (separator_pos != ice::nindex_none) { str.resize(separator_pos); } diff --git a/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx b/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx index d2a14316..02db7c69 100644 --- a/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx +++ b/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx @@ -144,7 +144,7 @@ namespace ice ice::nindex beg = 0; ice::nindex end = csv_data.find_first_of(','); - while (end != ice::none_index) + while (end != ice::nindex_none) { char const* val_beg = csv_data.begin() + beg; char const* val_end = csv_data.begin() + end; @@ -191,7 +191,7 @@ namespace ice ice::nindex beg = 0; ice::nindex end = points.find_first_of(' '); - while (end != ice::none_index) + while (end != ice::nindex_none) { char const* val_beg = data + beg; char const* val_delim = data + points.find_first_of(',', beg); diff --git a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx index a17baf41..60652a95 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx @@ -36,9 +36,9 @@ namespace ice::ecs { using QueryTypeInfo = ice::ecs::detail::QueryTypeInfo; - ice::u32 const tag_count = ice::count(in_required_tags); - ice::u32 const condition_count = ice::count(in_conditions); - ice::u32 const identifier_count = ice::count(checked_identifiers); + ice::u32 const tag_count = in_required_tags.size().u32(); + ice::u32 const condition_count = in_conditions.size().u32(); + ice::u32 const identifier_count = checked_identifiers.size().u32(); ice::u32 const identifier_last_index = identifier_count - 1; ice::u32 tag_idx = 0; @@ -121,7 +121,7 @@ namespace ice::ecs ice::usize& offset_values_out ) noexcept -> ice::meminfo { - ice::u32 const component_count = ice::span::count(info.component_identifiers); + ice::u32 const component_count = info.component_identifiers.size().u32(); ice::meminfo result = ice::meminfo_of; offset_name_out = result += ice::meminfo_of * (name.size() + 1); @@ -191,7 +191,7 @@ namespace ice::ecs data_block_pool = _default_block_pool.get(); } - ice::u32 const component_count = ice::count(archetype_info.component_identifiers); + ice::u32 const component_count = archetype_info.component_identifiers.size().u32(); ICE_ASSERT( component_count >= 2, @@ -335,12 +335,12 @@ namespace ice::ecs // We need to skip the first query entry if it's for `ice::ecs::Entity` // This is due to the fact that it's always there and is not taken into account when sorting components by identifiers. - if (ice::span::front(query_info).identifier == ice::ecs::Constant_ComponentIdentifier) + if (query_info.first().identifier == ice::ecs::Constant_ComponentIdentifier) { - query_info = ice::span::subspan(query_info, 1); + query_info = query_info.subspan(1); } - ice::u32 const required_tag_count = ice::count(query_tags); + ice::u32 const required_tag_count = query_tags.size().u32(); ice::u32 const required_component_count = [](auto const& query_conditions) noexcept -> ice::u32 { ice::u32 result = 0; @@ -362,7 +362,7 @@ namespace ice::ecs { ice::ecs::detail::ArchetypeInstanceInfo const& archetype_info = entry->archetype_info; - ice::u32 const archetype_component_count = ice::count(archetype_info.component_identifiers); + ice::u32 const archetype_component_count = archetype_info.component_identifiers.size().u32(); if (archetype_component_count < total_required_type_count) { continue; @@ -389,7 +389,7 @@ namespace ice::ecs ) const noexcept { ICE_ASSERT( - ice::count(archetypes) == ice::count(out_instance_infos), + archetypes.size() == out_instance_infos.size(), "Archetype instance fetch called with different input and output array sizes." ); @@ -417,7 +417,7 @@ namespace ice::ecs ) const noexcept { ICE_ASSERT( - ice::count(archetype_instances) == ice::count(out_instance_infos), + archetype_instances.size() == out_instance_infos.size(), "Archetype instance fetch called with different input and output array sizes." ); diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx index 510187bf..1e37ed3c 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx @@ -96,7 +96,7 @@ namespace ice::ecs { ice::u32 const indices_taken = ice::queue::take_front( _free_indices, - ice::span::subspan(ice::Span{indices}, 0, ice::min(free_count, ice::count(indices))) + ice::Span{ indices }.headspan(free_count) ); for (ice::u32 idx = 0; idx < indices_taken; ++idx) @@ -110,7 +110,7 @@ namespace ice::ecs } ice::u32 gen_index = ice::array::count(_generation); - ice::u32 const missing_entities = ice::count(out_entities) - total_indices_taken; + ice::u32 const missing_entities = out_entities.size().u32() - total_indices_taken; ice::u32 const final_index = gen_index + missing_entities; if (final_index > 0) diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx index 1919e342..675331d0 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx @@ -297,16 +297,16 @@ namespace ice::ecs void EntityOperations::destroy(ice::Span entities) noexcept { - if (ice::span::empty(entities)) + if (entities.is_empty()) { return; } void* handle_loc; - EntityOperation* operation = new_storage_operation(ice::meminfo_of * ice::count(entities), handle_loc); + EntityOperation* operation = new_storage_operation(ice::meminfo_of * entities.size().u32(), handle_loc); operation->archetype = ice::ecs::Archetype::Invalid; operation->entities = reinterpret_cast(handle_loc); - operation->entity_count = ice::count(entities); + operation->entity_count = entities.size().u32(); operation->component_data = nullptr; operation->component_data_size = 0; @@ -318,13 +318,13 @@ namespace ice::ecs ice::Span component_data ) noexcept -> Result { - if (ice::span::empty(entities) || (mode == 2 && index_create_count == 0) || mode == 0) + if (entities.is_empty() || (mode == 2 && index_create_count == 0) || mode == 0) { return Result{ *this }; } - ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); - ice::u32 const component_count = ice::count(component_info.names); + ice::u32 const entity_count = mode == 2 ? index_create_count : entities.size().u32(); + ice::u32 const component_count = component_info.names.size().u32(); ice::meminfo additional_data_size = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; additional_data_size += ice::meminfo_of * entity_count; @@ -424,7 +424,7 @@ namespace ice::ecs { if (mode != 0) { - ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); + ice::u32 const entity_count = mode == 2 ? index_create_count : entities.size().u32(); ice::meminfo required_memory = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; required_memory += ice::meminfo_of * entity_count; diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx index 6ce2abc8..2cc07488 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx @@ -50,7 +50,7 @@ namespace ice::ecs if (components[cmp] != ice::StringID_Invalid) { ice::u32 in_arch_idx; - bool const found = ice::binary_search(ice::span::subspan(info.component_identifiers, 1), components[cmp], in_arch_idx); + bool const found = ice::binary_search(info.component_identifiers.subspan(1), components[cmp], in_arch_idx); ICE_ASSERT_CORE(found); out_sizes[cmp] = info.component_sizes[in_arch_idx + 1]; out_offsets[cmp] = info.component_offsets[in_arch_idx + 1]; @@ -92,10 +92,10 @@ namespace ice::ecs ) noexcept { IPT_ZONE_SCOPED; - ice::u32 const entity_count = ice::count(src_entities); + ice::u32 const entity_count = src_entities.size().u32(); - ice::u32 const src_component_count = ice::count(src_info.names); - ice::u32 const dst_component_count = ice::count(dst_info.names); + ice::u32 const src_component_count = src_info.names.size().u32(); + ice::u32 const dst_component_count = dst_info.names.size().u32(); ice::u32 const max_component_count = ice::max(src_component_count, dst_component_count); bool const source_is_smaller = src_component_count < max_component_count; @@ -193,8 +193,8 @@ namespace ice::ecs ) noexcept { IPT_ZONE_SCOPED; - ice::u32 const src_component_count = ice::count(src_info.names); - ice::u32 const dst_component_count = ice::count(dst_info.names); + ice::u32 const src_component_count = src_info.names.size().u32(); + ice::u32 const dst_component_count = dst_info.names.size().u32(); ice::u32 const max_component_count = ice::max(src_component_count, dst_component_count); bool const source_is_smaller = src_component_count < max_component_count; @@ -259,8 +259,8 @@ namespace ice::ecs ) noexcept { IPT_ZONE_SCOPED; - ice::u32 const entity_count = ice::count(src_entities); - ice::u32 const component_count = ice::count(info.names); + ice::u32 const entity_count = src_entities.size().u32(); + ice::u32 const component_count = info.names.size().u32(); // Iterate over each component in the source archetype for (ice::u32 component_index = 0; component_index < component_count; ++component_index) @@ -959,7 +959,7 @@ namespace ice::ecs src_data_details.block_offset = data_block_it_2->block_entity_count - 1; // Get the last entity ice::ecs::Entity const move_entities[1]{ - ice::span::front(ice::ecs::detail::get_entity_array(src_component_info, src_data_details, 1)) + ice::ecs::detail::get_entity_array(src_component_info, src_data_details, 1).first() }; EntityDataSlot const move_slot{ diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx index bc7daf9a..614e315f 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx @@ -41,22 +41,22 @@ namespace ice::gfx { ice::array::push_back(out_resources, res); } - stage_copy.depth_stencil = ice::array::slice(out_resources, offset, ice::count(stage.depth_stencil)); - offset += ice::count(stage.depth_stencil); + stage_copy.depth_stencil = ice::array::slice(out_resources, offset, stage.depth_stencil.size().u32()); + offset += stage.depth_stencil.size().u32(); for (ice::gfx::GfxResource res : stage.inputs) { ice::array::push_back(out_resources, res); } - stage_copy.inputs = ice::array::slice(out_resources, offset, ice::count(stage.inputs)); - offset += ice::count(stage.inputs); + stage_copy.inputs = ice::array::slice(out_resources, offset, stage.inputs.size().u32()); + offset += stage.inputs.size().u32(); for (ice::gfx::GfxResource res : stage.outputs) { ice::array::push_back(out_resources, res); } - stage_copy.outputs = ice::array::slice(out_resources, offset, ice::count(stage.outputs)); - offset += ice::count(stage.inputs); + stage_copy.outputs = ice::array::slice(out_resources, offset, stage.outputs.size().u32()); + offset += stage.inputs.size().u32(); return stage_copy; } @@ -93,12 +93,12 @@ namespace ice::gfx ice::u32 res_count = 0; for (ice::gfx::GfxGraphStage const& stage : pass.stages) { - res_count += ice::count(stage.depth_stencil) + ice::count(stage.inputs) + ice::count(stage.outputs); + res_count += stage.depth_stencil.size().u32() + stage.inputs.size().u32() + stage.outputs.size().u32(); } IceshardGfxGraphPassObjects gfxpass{ _allocator, pass.name }; ice::array::reserve(gfxpass.resources, res_count); - ice::array::reserve(gfxpass.stages, ice::count(pass.stages)); + ice::array::reserve(gfxpass.stages, pass.stages.size().u32()); for (ice::gfx::GfxGraphStage const& stage : pass.stages) { @@ -130,13 +130,13 @@ namespace ice::gfx ice::vec2u extent = swapchain.extent(); - ice::u32 const count_images = ice::count(resources); + ice::u32 const count_images = resources.size().u32(); ice::array::clear(out_images); ice::array::reserve(out_images, count_images); ice::array::push_back(out_images, Image::Invalid); // First image beeing framebuffer - for (GfxResource res : ice::span::subspan(resources, 1)) + for (GfxResource res : resources.subspan(1)) { ImageInfo image_info { .type = ImageType::Image2D, @@ -486,7 +486,7 @@ namespace ice::gfx GfxSnapshotEvent result = GfxSnapshotEvent::EventCreateRes; bool pass_boundary = false; - for (ice::u32 idx = ice::count(snapshots) - 1; idx >= 0; --idx) + for (ice::u32 idx = snapshots.size().u32() - 1; idx >= 0; --idx) { GfxGraphSnapshot const prev = snapshots[idx]; diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx index 158f6671..be5b011f 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx @@ -20,7 +20,7 @@ namespace ice::gfx ) noexcept { ice::u32 last_pass = 0; - for (ice::u32 idx = 0; idx < ice::count(snapshots); ++idx) + for (ice::u32 idx = 0; idx < snapshots.size().u32(); ++idx) { GfxGraphSnapshot& current = snapshots[idx]; if (current.event & (GfxSnapshotEvent::EventBeginPass | GfxSnapshotEvent::EventNextSubPass | GfxSnapshotEvent::EventEndPass)) @@ -35,7 +35,7 @@ namespace ice::gfx } GfxGraphSnapshot prev{}, next{}; - for (GfxGraphSnapshot const prev_candidate : ice::span::subspan(snapshots, 0, idx)) + for (GfxGraphSnapshot const prev_candidate : snapshots.headspan(idx)) { if (current.resource == prev_candidate.resource) { @@ -43,7 +43,7 @@ namespace ice::gfx } } - for (GfxGraphSnapshot const next_candidate : ice::span::subspan(snapshots, idx + 1)) + for (GfxGraphSnapshot const next_candidate : snapshots.subspan(idx + 1)) { if (current.resource == next_candidate.resource) { @@ -113,8 +113,8 @@ namespace ice::gfx ice::Array subpasses{ alloc }; ice::Array dependencies{ alloc }; - ice::array::reserve(attachments, ice::count(resources)); - ice::array::reserve(references, ice::count(graph_snapshots)); + ice::array::reserve(attachments, resources.size().u32()); + ice::array::reserve(references, graph_snapshots.size().u32()); ice::array::push_back( attachments, @@ -363,7 +363,7 @@ namespace ice::gfx } } - ice::array::push_back(stages._counts, ice::u8(ice::count(pass.stages))); + ice::array::push_back(stages._counts, pass.stages.size().u8()); pass_idx += 1; } diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx index 7397dcbf..56f60936 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx @@ -58,7 +58,7 @@ namespace ice::ecs struct Result { - auto one() const noexcept -> ice::ecs::Entity { return ice::span::front(_builder.entities); } + auto one() const noexcept -> ice::ecs::Entity { return _builder.entities.first(); } auto all() const noexcept -> ice::Span { return _builder.entities; } auto store(ice::Array& out_entities, bool append = true) const noexcept @@ -295,10 +295,10 @@ namespace ice::ecs ); static ice::ecs::OperationComponentInfo constexpr ComponentsInfo{ - .names = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_identifiers), 1), - .sizes = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_sizes), 1), + .names = ice::span::from_std_const(HelperArchetype.component_identifiers).tailspan(1), + .sizes = ice::span::from_std_const(HelperArchetype.component_sizes).tailspan(1), // We store alignments in this span just for convenience - .offsets = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_alignments), 1) + .offsets = ice::span::from_std_const(HelperArchetype.component_alignments).tailspan(1) }; ice::Data const unsorted_component_Data[]{ @@ -317,7 +317,7 @@ namespace ice::ecs template inline auto OperationBuilder::with_data(ice::Span&... out_component_spans) noexcept -> Result { - if (ice::span::empty(entities) && mode != 2) + if (entities.is_empty() && mode != 2) { return Result{ *this }; } @@ -329,10 +329,10 @@ namespace ice::ecs ); static ice::ecs::OperationComponentInfo constexpr ComponentsInfo{ - .names = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_identifiers), 1), - .sizes = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_sizes), 1), + .names = ice::span::from_std_const(HelperArchetype.component_identifiers).tailspan(1), + .sizes = ice::span::from_std_const(HelperArchetype.component_sizes).tailspan(1), // We store alignments in this span just for convenience - .offsets = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_alignments), 1) + .offsets = ice::span::from_std_const(HelperArchetype.component_alignments).tailspan(1) }; ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); @@ -459,7 +459,7 @@ namespace ice::ecs template inline auto OperationBuilder::with_data(ice::Span... component_spans) noexcept -> Result { - if (ice::span::empty(entities) && mode != 2) + if (entities.is_empty() && mode != 2) { return { *this }; } @@ -471,10 +471,10 @@ namespace ice::ecs ); static ice::ecs::OperationComponentInfo constexpr ComponentsInfo{ - .names = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_identifiers), 1), - .sizes = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_sizes), 1), + .names = ice::span::from_std_const(HelperArchetype.component_identifiers).tailspan(1), + .sizes = ice::span::from_std_const(HelperArchetype.component_sizes).tailspan(1), // We store alignments in this span just for convenience - .offsets = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_alignments), 1) + .offsets = ice::span::from_std_const(HelperArchetype.component_alignments).tailspan(1) }; ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx index 0fb5b796..4a58ad0d 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx @@ -112,7 +112,7 @@ namespace ice::ecs ICE_ASSERT_CORE(arch != nullptr && block != nullptr); void* helper_pointer_array[component_count]{ nullptr }; - ice::Span make_argument_idx_map = ice::span::subspan(archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = archetype_argument_idx_map.subspan(arch_idx * component_count, component_count); for (ice::u32 arg_idx = 0; arg_idx < component_count; ++arg_idx) { @@ -219,7 +219,7 @@ namespace ice::ecs ICE_ASSERT_CORE(arch != nullptr && block != nullptr); - ice::Span make_argument_idx_map = ice::span::subspan(archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = archetype_argument_idx_map.subspan(arch_idx * component_count, component_count); for (ice::u32 arg_idx = 0; arg_idx < component_count; ++arg_idx) { @@ -389,7 +389,7 @@ namespace ice::ecs ice::array::slice(query.archetype_instances, arch_count), ice::array::slice(query.archetype_data_blocks, arch_count), ice::array::slice(query.archetype_argument_idx_map, arch_count * component_count), - ice::span::subspan(ice::Span{ query.archetype_count_for_part }, 1), + ice::Span{ query.archetype_count_for_part }.tailspan(1), RefParts{}... ); } @@ -452,7 +452,7 @@ namespace ice::ecs ice::array::slice(query_object.archetype_instances, arch_count), ice::array::slice(query_object.archetype_data_blocks, arch_count), ice::array::slice(query_object.archetype_argument_idx_map, arch_count * component_count), - ice::span::subspan(ice::Span{ query_object.archetype_count_for_part }, 1), + ice::Span{ query_object.archetype_count_for_part }.tailspan(1), RefParts{}... ); } @@ -526,7 +526,7 @@ namespace ice::ecs ice::array::slice(query_object.archetype_instances, arch_count), ice::array::slice(query_object.archetype_data_blocks, arch_count), ice::array::slice(query_object.archetype_argument_idx_map, arch_count * component_count), - ice::span::subspan(ice::Span{ query_object.archetype_count_for_part }, 1), + ice::Span{ query_object.archetype_count_for_part }.tailspan(1), MainPart{}, RefParts{}... ); diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx index 32141b13..b67811e1 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx @@ -164,7 +164,7 @@ namespace ice::gfx using ice::render::QueueID; ice::Array queues{ alloc }; - ice::array::reserve(queues, ice::count(render_queues)); + ice::array::reserve(queues, render_queues.size().u32()); auto find_queue_index = [](auto const& array_, QueueID id_, ice::u32& idx_out) noexcept -> bool { @@ -239,7 +239,7 @@ namespace ice::gfx pass_groups, alloc.create( alloc, - ice::count(render_queues) + render_queues.size().u32() ) ); } diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx index ccaf5f74..25885792 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx @@ -85,7 +85,7 @@ namespace ice::gfx ice::Array& cmds = (type == CommandBufferType::Primary) ? _primary : _secondary; ice::u32& used = _cmd_buffers_used[static_cast(type)]; ice::u32 const available = ice::array::count(cmds) - used; - ice::u32 const required = ice::count(out_buffers); + ice::u32 const required = out_buffers.size().u32(); if (available < required) { diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx index 35b6504d..14cfb836 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx @@ -56,10 +56,10 @@ namespace ice ice::UIRawInfo const& raw_info ) noexcept -> ice::UISizeInfo { - ice::u32 const count_elements = u32(ice::count(raw_info.elements)); - ice::u32 const count_shards = u32(ice::count(raw_info.shards)); - ice::u32 const count_resources = u32(ice::count(raw_info.resources)); - ice::u32 const count_styles = u32(ice::count(raw_info.styles)); + ice::u32 const count_elements = raw_info.elements.size().u32(); + ice::u32 const count_shards = raw_info.shards.size().u32(); + ice::u32 const count_resources = raw_info.resources.size().u32(); + ice::u32 const count_styles = raw_info.styles.size().u32(); ice::u32 count_fonts = 0; ice::u32 count_actions = 0; @@ -155,10 +155,10 @@ namespace ice auto find_resource_idx( ice::Span resources, ice::String name - ) noexcept -> ice::u16 + ) noexcept -> ice::nindex { - ice::u16 idx = 0; - ice::u16 const count = ice::u16(ice::count(resources)); + ice::nindex idx = 0; + ice::ncount const count = resources.size(); for (; idx < count; ++idx) { if (resources[idx].ui_name == name) @@ -166,7 +166,7 @@ namespace ice break; } } - return idx == count ? ice::u16{ 0xffff } : idx; + return idx == count ? ice::nindex{ 0xffff } : idx; } struct ConstantData @@ -200,13 +200,13 @@ namespace ice text_size.bytes() ); - constants.data_storage = ice::ptr_add(constants.data_storage, { text_size }); + constants.data_storage = ice::ptr_add(constants.data_storage, text_size); constants.data_storage_offset += text_size.u32(); constants.idx += 1; } else if (out_ref.source == DataSource::ValueResource) { - out_ref.source_i = find_resource_idx(resources, raw_data_ref.data_source); + out_ref.source_i = find_resource_idx(resources, raw_data_ref.data_source).u16(); } } @@ -223,7 +223,7 @@ namespace ice static auto store_span_info = [base_ptr = result.location](auto& span_value) noexcept { void* span_address = std::addressof(span_value); - ice::u32 const span_size = ice::u32(ice::count(span_value)); + ice::u32 const span_size = span_value.size().u32(); ice::u32 const span_offset = ice::u32(ice::ptr_distance(base_ptr, ice::span::data(span_value)).value); ice::u32* values = reinterpret_cast(span_address); @@ -280,7 +280,7 @@ namespace ice { ice::u16 font_idx = 0; ice::u64 idx = 0; - ice::u64 const count = ice::count(raw_info.resources); + ice::u64 const count = raw_info.resources.size(); for (; idx < count; ++idx) { if (raw_info.resources[idx].type == ResourceType::Font) @@ -298,7 +298,7 @@ namespace ice auto const find_shard_idx = [&raw_info](ice::String resource_name) noexcept -> ice::u16 { ice::u16 idx = 0; - ice::u64 const count = ice::count(raw_info.shards); + ice::u64 const count = raw_info.shards.size(); for (; idx < count; ++idx) { if (raw_info.shards[idx].ui_name == resource_name) diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx index 2277aa04..5fcd81c6 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx @@ -17,7 +17,7 @@ namespace ice { ice::nindex const left_bracket = inout_str.find_first_not_of(character); ice::nindex const right_bracket = inout_str.find_last_not_of(character); - if (left_bracket == ice::none_index && right_bracket == ice::none_index) + if (left_bracket == ice::nindex_none && right_bracket == ice::nindex_none) { return false; } @@ -30,7 +30,7 @@ namespace ice { ice::nindex const left_bracket = inout_str.find_first_of('{'); ice::nindex const right_bracket = inout_str.find_last_of('}'); - if (left_bracket == ice::none_index || right_bracket == ice::none_index) + if (left_bracket == ice::nindex_none || right_bracket == ice::nindex_none) { return false; } @@ -47,7 +47,7 @@ namespace ice ice::nindex const type_end = inout_str.find_first_of(' '); bool result = false; - if (type_end != ice::none_index) + if (type_end != ice::nindex_none) { ice::String const action_type = inout_str.substr(0, type_end); if (action_type == RawAction::Constant_ActionType_Shard) @@ -111,7 +111,7 @@ namespace ice bool result = true; ice::nindex const data_start = inout_str.find_first_of('='); - if (data_start != ice::none_index) + if (data_start != ice::nindex_none) { ice::nindex const data_arg_start = inout_str.find_last_of(" ,"_str, data_start); diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx index 83ce97e1..7bdfc4ef 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx @@ -135,7 +135,7 @@ namespace ice ice::nindex const separator = value.find_first_of(','); bool valid_values = true; - if (separator != ice::none_index) + if (separator != ice::nindex_none) { ice::String left = value.substr(0, separator); ice::String right = value.substr(separator + 1); @@ -207,7 +207,7 @@ namespace ice ice::nindex const separator = value.find_first_of(','); bool valid_values = true; - if (separator != ice::none_index) + if (separator != ice::nindex_none) { ice::String left = value.substr(0, separator); ice::String right = value.substr(separator + 1); @@ -276,7 +276,7 @@ namespace ice ice::nindex const sep3 = value.find_first_of(',', sep2 + 1); bool valid_values = true; - if (sep3 != ice::none_index && sep2 != ice::none_index && sep1 != ice::none_index) + if (sep3 != ice::nindex_none && sep2 != ice::nindex_none && sep1 != ice::nindex_none) { ice::String first = value.substr(0, sep1); ice::String second = value.substr(sep1 + 1, (sep2 - sep1) - 1); @@ -328,7 +328,7 @@ namespace ice } } } - else if (sep1 != ice::none_index) + else if (sep1 != ice::nindex_none) { ice::String first = value.substr(0, sep1); ice::String second = value.substr(sep1 + 1); @@ -402,7 +402,7 @@ namespace ice ice::nindex const sep2 = value.find_first_of(',', sep1 + 1); bool valid_values = false; - if (sep1 != ice::none_index && sep2 != ice::none_index) + if (sep1 != ice::nindex_none && sep2 != ice::nindex_none) { ice::String first = value.substr(0, sep1); ice::String second = value.substr(sep1 + 1, (sep2 - sep1) - 1); @@ -413,7 +413,7 @@ namespace ice ice::from_chars(third, out_color.blue); valid_values = true; } - else if (sep1 == ice::none_index && sep2 == ice::none_index) + else if (sep1 == ice::nindex_none && sep2 == ice::nindex_none) { ice::from_chars(value, out_color.red); out_color.green = out_color.red; diff --git a/source/code/modules/imgui_module/private/imgui_system.cxx b/source/code/modules/imgui_module/private/imgui_system.cxx index f2af2b35..5bb5cba6 100644 --- a/source/code/modules/imgui_module/private/imgui_system.cxx +++ b/source/code/modules/imgui_module/private/imgui_system.cxx @@ -22,7 +22,7 @@ namespace ice::devui void build_mainmenu(ice::StaticString<32>& temp, ice::String path, ice::String name, bool& state) noexcept { ice::nindex const separator_pos = path.find_first_of('/'); - if (separator_pos != ice::none_index) + if (separator_pos != ice::nindex_none) { temp = path.substr(0, separator_pos); @@ -48,7 +48,7 @@ namespace ice::devui void ImGuiWidgetFrame::mainmenu(ice::DevUIWidgetInfo const& widget, ice::DevUIWidgetState& state) noexcept { ice::nindex const separator_pos = widget.category.find_first_of('/'); - if (separator_pos == ice::none_index) + if (separator_pos == ice::nindex_none) { ImGui::MenuItem(widget.name.begin(), nullptr, &state.active); return; @@ -205,7 +205,7 @@ namespace ice::devui // ImGui::NewLine(); ImGui::SeparatorText("Info"); ImGui::NewLine(); ImGui::Separator(); - ImGui::TextT("Widgets: {}", ice::count(_widget_manager.widgets())); + ImGui::TextT("Widgets: {}", _widget_manager.widgets().size()); ImGui::NewLine(); ImGui::Separator(); ImGui::TextT("Draw calls: {} ({:p})", stats.draw_calls, stats.draw_datasize); diff --git a/source/code/modules/shader_tools/private/shader_tools.cxx b/source/code/modules/shader_tools/private/shader_tools.cxx index 96c9ae00..81b647a3 100644 --- a/source/code/modules/shader_tools/private/shader_tools.cxx +++ b/source/code/modules/shader_tools/private/shader_tools.cxx @@ -52,8 +52,7 @@ namespace ice { ice::ShaderTargetPlatform const target = param_shader_target(params); static ice::String supported_extensions[]{ ".asl", ".glsl", ".asl", ".hlsl" }; - return ice::span::subspan( - ice::Span{ supported_extensions }, + return ice::Span{ supported_extensions }.subspan( // Select GLSL [0, 1] or HLSL span [2, 3] target == ShaderTargetPlatform::GLSL ? 0 : 2, // If we target 'WGSL' we only want to accept 'asl' files [0] diff --git a/source/code/modules/vulkan_renderer/private/vk_device.cxx b/source/code/modules/vulkan_renderer/private/vk_device.cxx index ab661716..fd57cf99 100644 --- a/source/code/modules/vulkan_renderer/private/vk_device.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_device.cxx @@ -212,13 +212,13 @@ namespace ice::render::vk auto VulkanRenderDevice::create_renderpass(ice::render::RenderpassInfo const& info) noexcept -> ice::render::Renderpass { ice::Array attachments{ _allocator }; - ice::array::reserve(attachments, ice::count(info.attachments)); + ice::array::reserve(attachments, info.attachments.size().u32()); ice::Array subpass_list{ _allocator }; - ice::array::reserve(subpass_list, ice::count(info.subpasses)); + ice::array::reserve(subpass_list, info.subpasses.size().u32()); ice::Array dependencies { _allocator }; - ice::array::reserve(dependencies, ice::count(info.dependencies)); + ice::array::reserve(dependencies, info.dependencies.size().u32()); ice::Array attachment_references{ _allocator }; @@ -250,8 +250,8 @@ namespace ice::render::vk ice::u64 reference_count = 0; for (RenderSubPass const& subpass_info : info.subpasses) { - reference_count += ice::count(subpass_info.color_attachments) - + ice::count(subpass_info.input_attachments) + reference_count += subpass_info.color_attachments.size() + + subpass_info.input_attachments.size() + 1; } @@ -278,12 +278,12 @@ namespace ice::render::vk VkSubpassDescription subpass{ }; // VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2 }; subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; - subpass.inputAttachmentCount = ice::count(subpass_info.input_attachments); + subpass.inputAttachmentCount = subpass_info.input_attachments.size().u32(); if (subpass.inputAttachmentCount > 0) { subpass.pInputAttachments = std::addressof(attachment_references[input_ref_idx]); } - subpass.colorAttachmentCount = ice::count(subpass_info.color_attachments); + subpass.colorAttachmentCount = subpass_info.color_attachments.size().u32(); if (subpass.colorAttachmentCount > 0) { subpass.pColorAttachments = std::addressof(attachment_references[color_ref_idx]); @@ -343,7 +343,7 @@ namespace ice::render::vk ) noexcept -> ice::render::ResourceSetLayout { ice::Array vk_bindings{ _allocator }; - ice::array::reserve(vk_bindings, ice::count(bindings)); + ice::array::reserve(vk_bindings, bindings.size().u32()); for (ResourceSetLayoutBinding const& binding : bindings) { @@ -360,7 +360,7 @@ namespace ice::render::vk } VkDescriptorSetLayoutCreateInfo layout_info{ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO }; - layout_info.bindingCount = ice::count(bindings); + layout_info.bindingCount = bindings.size().u32(); layout_info.pBindings = ice::begin(vk_bindings); VkDescriptorSetLayout vk_descriptor_set_layout = vk_nullptr; @@ -402,7 +402,7 @@ namespace ice::render::vk ); ICE_ASSERT( - ice::count(resource_set_layouts) == ice::count(resource_sets_out), + resource_set_layouts.size() == resource_sets_out.size(), "The output span size does not match the size of provided layouts span." ); @@ -410,7 +410,7 @@ namespace ice::render::vk VkDescriptorSetAllocateInfo descriptorset_info{ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO }; descriptorset_info.descriptorPool = _vk_descriptor_pool; - descriptorset_info.descriptorSetCount = ice::count(resource_set_layouts); + descriptorset_info.descriptorSetCount = resource_set_layouts.size().u32(); descriptorset_info.pSetLayouts = reinterpret_cast(&resource_set_layouts[0]); VkResult result = vkAllocateDescriptorSets( @@ -421,7 +421,7 @@ namespace ice::render::vk ICE_ASSERT( result == VkResult::VK_SUCCESS, "Couldn't allocate new {} descriptor sets.", - ice::count(resource_set_layouts) + resource_set_layouts.size() ); return true; } @@ -433,13 +433,13 @@ namespace ice::render::vk VkResult result = vkFreeDescriptorSets( _vk_device, _vk_descriptor_pool, - ice::count(resource_sets), + resource_sets.size().u32(), reinterpret_cast(&resource_sets[0]) ); ICE_ASSERT( result == VkResult::VK_SUCCESS, "Failed to free given {} descriptor sets.", - ice::count(resource_sets) + resource_sets.size() ); } @@ -448,7 +448,7 @@ namespace ice::render::vk ) noexcept { ice::Array vk_writes{ _allocator }; - ice::array::reserve(vk_writes, ice::count(update_infos)); + ice::array::reserve(vk_writes, update_infos.size().u32()); ice::Array write_image_info{ _allocator }; ice::Array write_buffer_info{ _allocator }; @@ -511,25 +511,25 @@ namespace ice::render::vk descriptor_set_write.dstBinding = update_info.binding_index; descriptor_set_write.dstArrayElement = update_info.array_element; descriptor_set_write.dstSet = native_handle(update_info.resource_set); - descriptor_set_write.descriptorCount = ice::count(update_info.resources); + descriptor_set_write.descriptorCount = update_info.resources.size().u32(); descriptor_set_write.descriptorType = native_enum_value(update_info.resource_type); if (update_info.resource_type == ResourceType::SampledImage || update_info.resource_type == ResourceType::InputAttachment) { descriptor_set_write.pImageInfo = ice::array::begin(write_image_info) + images_offset; - images_offset += ice::count(update_info.resources); + images_offset += update_info.resources.size().u32(); } if (update_info.resource_type == ResourceType::Sampler) { descriptor_set_write.pImageInfo = ice::array::begin(write_image_info) + images_offset; - images_offset += ice::count(update_info.resources); + images_offset += update_info.resources.size().u32(); } if (update_info.resource_type == ResourceType::UniformBuffer) { descriptor_set_write.pBufferInfo = ice::array::begin(write_buffer_info) + buffers_offset; - buffers_offset += ice::count(update_info.resources); + buffers_offset += update_info.resources.size().u32(); } ice::array::push_back(vk_writes, descriptor_set_write); @@ -548,10 +548,10 @@ namespace ice::render::vk ) noexcept -> ice::render::PipelineLayout { ice::Array vk_push_constants{ _allocator }; - ice::array::reserve(vk_push_constants, ice::count(info.push_constants)); + ice::array::reserve(vk_push_constants, info.push_constants.size().u32()); ice::Array vk_descriptorset_layouts{ _allocator }; - ice::array::reserve(vk_descriptorset_layouts, ice::count(info.resource_layouts)); + ice::array::reserve(vk_descriptorset_layouts, info.resource_layouts.size().u32()); for (PipelinePushConstant const& push_constant : info.push_constants) { @@ -574,9 +574,9 @@ namespace ice::render::vk } VkPipelineLayoutCreateInfo pipeline_info{ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; - pipeline_info.pushConstantRangeCount = ice::count(info.push_constants); + pipeline_info.pushConstantRangeCount = info.push_constants.size().u32(); pipeline_info.pPushConstantRanges = ice::begin(vk_push_constants); - pipeline_info.setLayoutCount = ice::count(info.resource_layouts); + pipeline_info.setLayoutCount = info.resource_layouts.size().u32(); pipeline_info.pSetLayouts = ice::begin(vk_descriptorset_layouts); VkPipelineLayout pipeline_layout = vk_nullptr; @@ -644,7 +644,7 @@ namespace ice::render::vk ) noexcept -> ice::render::Pipeline { VkPipelineShaderStageCreateInfo shader_stages[10]; - ice::u32 const stage_count = ice::count(info.shaders); + ice::u32 const stage_count = info.shaders.size().u32(); uint32_t stage_idx = 0; for (; stage_idx < stage_count; ++stage_idx) @@ -695,8 +695,8 @@ namespace ice::render::vk ice::Array vertex_input_bindings{ _allocator }; ice::Array vertex_input_attributes{ _allocator }; - ice::array::reserve(vertex_input_bindings, ice::count(info.vertex_bindings)); - ice::array::reserve(vertex_input_attributes, ice::count(info.vertex_bindings) * 4); + ice::array::reserve(vertex_input_bindings, info.vertex_bindings.size().u32()); + ice::array::reserve(vertex_input_attributes, info.vertex_bindings.size().u32() * 4); for (ice::render::ShaderInputBinding const& binding : info.vertex_bindings) { @@ -734,8 +734,9 @@ namespace ice::render::vk case CullMode::Disabled: rasterization.cullMode = VK_CULL_MODE_NONE; // [issue #34] Needs to be properly available in the creation API. - if (ice::count(info.shaders) == 5) + if (info.shaders.size() == 5) { + ICE_ASSERT(false, "Old workaround to play with geometry shaders!"); rasterization.polygonMode = VK_POLYGON_MODE_LINE; } break; @@ -910,7 +911,7 @@ namespace ice::render::vk ice::Span update_infos ) noexcept { - ice::u32 const update_count = ice::count(update_infos); + ice::u32 const update_count = update_infos.size().u32(); ice::u32 update_offset = 0; while(update_offset < update_count) @@ -956,7 +957,7 @@ namespace ice::render::vk VkRenderPass vk_renderpass = reinterpret_cast(static_cast(renderpass)); ice::Array vk_images{ _allocator }; - ice::array::reserve(vk_images, ice::count(images)); + ice::array::reserve(vk_images, images.size().u32()); for (Image image : images) { diff --git a/source/code/modules/vulkan_renderer/private/vk_queue.cxx b/source/code/modules/vulkan_renderer/private/vk_queue.cxx index 8c401b41..177df7ff 100644 --- a/source/code/modules/vulkan_renderer/private/vk_queue.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_queue.cxx @@ -51,7 +51,7 @@ namespace ice::render::vk VkCommandBufferAllocateInfo alloc_info{ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO }; alloc_info.level = type == CommandBufferType::Primary ? VK_COMMAND_BUFFER_LEVEL_PRIMARY : VK_COMMAND_BUFFER_LEVEL_SECONDARY; alloc_info.commandPool = _vk_cmd_pools[pool_index]; - alloc_info.commandBufferCount = ice::count(buffers); + alloc_info.commandBufferCount = buffers.size().u32(); ICE_ASSERT_CORE(alloc_info.commandBufferCount < 16); VkResult result = vkAllocateCommandBuffers( @@ -95,7 +95,7 @@ namespace ice::render::vk ice::Span buffers ) noexcept { - if (ice::span::empty(buffers)) + if (buffers.is_empty()) { return; } @@ -137,7 +137,7 @@ namespace ice::render::vk ) noexcept { VkCommandBuffer vk_temp_buffers[16]; - ICE_ASSERT_CORE(ice::count(buffers) < 16); + ICE_ASSERT_CORE(buffers.size() < 16); ice::u32 count = 0; for (ice::render::CommandBuffer handle : buffers) diff --git a/source/code/systems/asset_system/private/asset_storage.cxx b/source/code/systems/asset_system/private/asset_storage.cxx index 5e4cb30e..f3ab4d26 100644 --- a/source/code/systems/asset_system/private/asset_storage.cxx +++ b/source/code/systems/asset_system/private/asset_storage.cxx @@ -45,7 +45,7 @@ namespace ice ice::ResourceHandle resource; ice::u32 ext_idx = 0; - ice::u32 const ext_count = ice::u32(ice::count(definition.resource_extensions)); + ice::u32 const ext_count = definition.resource_extensions.size().u32(); ice::u32 const temp_name_len = temp_name.size().u32(); while (resource == nullptr && ext_idx < ext_count) { @@ -241,7 +241,7 @@ namespace ice , _devui_widget{ } { ice::Span categories = _asset_archive->categories(); - ice::hashmap::reserve(_asset_shelves, ice::u32(ice::count(categories))); + ice::hashmap::reserve(_asset_shelves, categories.size().u32()); ice::Array> shelves{ _allocator }; for (ice::AssetCategory_Arg category : categories) diff --git a/source/code/systems/asset_system/public/ice/asset_category_archive.hxx b/source/code/systems/asset_system/public/ice/asset_category_archive.hxx index 8e9934d7..be5f18d8 100644 --- a/source/code/systems/asset_system/public/ice/asset_category_archive.hxx +++ b/source/code/systems/asset_system/public/ice/asset_category_archive.hxx @@ -12,7 +12,7 @@ namespace ice struct AssetCategoryDefinition { - constexpr auto valid() const noexcept { return ice::span::any(resource_extensions); } + constexpr auto valid() const noexcept { return resource_extensions.not_empty(); } ice::String name; ice::Span asset_params; diff --git a/source/code/systems/input_action_system/private/input_action_layer.cxx b/source/code/systems/input_action_system/private/input_action_layer.cxx index 01a39532..73b2ae1f 100644 --- a/source/code/systems/input_action_system/private/input_action_layer.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer.cxx @@ -123,13 +123,13 @@ namespace ice auto load_constants(ice::Span constants_span) const noexcept -> ice::u32 override { - ICE_ASSERT_CORE(ice::count(constants_span) >= Constant_CountInputActionConstants); + ICE_ASSERT_CORE(constants_span.size() >= Constant_CountInputActionConstants); for (ice::InputActionConstantInfo const constant : _constants) { ice::u32 const idx = ice::u32(constant.identifier); constants_span[idx] = _constant_values[constant.offset]; } - return ice::count(_constants); + return _constants.size().u32(); } auto process_inputs( @@ -146,7 +146,7 @@ namespace ice }; ice::u32 count_processed = 0; - ice::u32 const count_events = ice::count(input_events); + ice::u32 const count_events = input_events.size().u32(); // Reset the temporary events. for (ice::InputActionSourceInputInfo const& src : _sources) @@ -263,7 +263,7 @@ namespace ice } bool series_success = false; - ice::Span const conditions = ice::span::subspan(_conditions, action.conditions); + ice::Span const conditions = _conditions.subspan(action.conditions); for (ice::InputActionConditionData const& cond : conditions) { bool cond_result = false; @@ -310,7 +310,7 @@ namespace ice if (ice::has_all(cond.flags, RunSteps) && check_success) { - ice::Span const steps = ice::span::subspan(_steps, cond.steps); + ice::Span const steps = _steps.subspan(cond.steps); for (ice::InputActionStepData const& step : steps) { if (step.id < InputActionStep::Set) @@ -409,7 +409,7 @@ namespace ice // Update the final value and run modifiers over it. runtime->value = { runtime->raw_value.x, runtime->raw_value.y }; - ice::Span const mods = ice::span::subspan(_modifiers, action.mods); + ice::Span const mods = _modifiers.subspan(action.mods); for (ice::InputActionModifierData const& mod : mods) { executor.execute_modifier(mod.id, runtime->value.v[0][mod.axis], mod.param); diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index 404eb24e..61bdca6e 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -162,14 +162,14 @@ namespace ice layer_idx = ice::count(_layers); // We reserve enough space to store all actual indices for accessed layer sources. - ice::u32 const layer_sources_count = ice::count(layer->sources()); + ice::u32 const layer_sources_count = layer->sources().size().u32(); ice::u32 const layer_sources_offset = ice::count(_layers_sources_indices); ice::array::reserve(_layers_sources_indices, layer_sources_offset + layer_sources_count); // Go through each resource and set the indices ice::u64 prev_name_hash = 0; ice::Span sources = layer->sources(); - ice::u32 const count_sources = ice::count(sources); + ice::u32 const count_sources = sources.size().u32(); for (ice::u32 idx = 0; idx < count_sources; ++idx) { ice::InputActionSourceInputInfo const& source = sources[idx]; @@ -403,7 +403,7 @@ namespace ice IPT_ZONE_SCOPED; using Iterator = ice::Array::ConstReverseIterator; - ice::u32 remaining_events = ice::count(events); + ice::u32 remaining_events = events.size().u32(); ice::Array events_copy{ _allocator, events }; ice::Array source_values{ _allocator }; diff --git a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx index 6fecc306..76781f08 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx @@ -195,7 +195,7 @@ namespace ice ) noexcept { ice::Array requests{ _callbacks.allocator() }; - ice::array::reserve(requests, ice::span::count(base_paths)); + ice::array::reserve(requests, base_paths.size().u32()); [[maybe_unused]] std::atomic_uint32_t remaining = 0; @@ -217,7 +217,7 @@ namespace ice ice::TaskScheduler local_sched{ local_queue }; ice::Array requests{ _callbacks.allocator() }; - ice::array::reserve(requests, ice::span::count(base_paths)); + ice::array::reserve(requests, base_paths.size().u32()); std::atomic_uint32_t remaining = 0; diff --git a/source/code/systems/resource_system/public/ice/uri.hxx b/source/code/systems/resource_system/public/ice/uri.hxx index eb22bc9f..505c2125 100644 --- a/source/code/systems/resource_system/public/ice/uri.hxx +++ b/source/code/systems/resource_system/public/ice/uri.hxx @@ -143,7 +143,7 @@ namespace ice ) noexcept { ice::nindex path_separator = uri.find_first_of("?#"); - if (path_separator == none_index) + if (path_separator == nindex_none) { out_path = uri.size().u8(); return out_path > 0; @@ -157,7 +157,7 @@ namespace ice { // Get the next separator if necessary path_separator = uri.find_last_of('#'); - if (path_separator == none_index) + if (path_separator == nindex_none) { // We take te remaining query with the starting '?' character out_query = (uri.size() - out_path).u8(); diff --git a/source/code/systems/resource_system/resource_system_tests.bff b/source/code/systems/resource_system/resource_system_tests.bff index c6d15ab2..66971ad1 100644 --- a/source/code/systems/resource_system/resource_system_tests.bff +++ b/source/code/systems/resource_system/resource_system_tests.bff @@ -29,7 +29,7 @@ .UnitTests = [ - .Enabled = true + .Enabled = false ] ] .Projects + .Project diff --git a/source/code/systems/ui_system/private/ui_element_info.cxx b/source/code/systems/ui_system/private/ui_element_info.cxx index 8ae25ee2..d79eaa61 100644 --- a/source/code/systems/ui_system/private/ui_element_info.cxx +++ b/source/code/systems/ui_system/private/ui_element_info.cxx @@ -17,10 +17,10 @@ namespace ice::ui ice::u16 const index = info.size_i & 0x0fff; ICE_ASSERT( - index < ice::count(uidata.sizes), + index < uidata.sizes.size(), "Trying to read 'size' value for element index outside of the given data. [ idx:{} | range:0 .. {}]", info.size_i, - ice::count(uidata.sizes) + uidata.sizes.size() ); out_size = uidata.sizes[index]; @@ -35,10 +35,10 @@ namespace ice::ui ice::u16 const index = info.pos_i & 0x0fff; ICE_ASSERT( - index < ice::count(uidata.positions), + index < uidata.positions.size(), "Trying to read 'position' value for element index outside of the given data. [ idx:{} | range:0 .. {}]", info.pos_i, - ice::count(uidata.positions) + uidata.positions.size() ); out_position = uidata.positions[index]; @@ -53,10 +53,10 @@ namespace ice::ui ice::u16 const index = info.mar_i & 0x0fff; ICE_ASSERT( - index < ice::count(uidata.margins), + index < uidata.margins.size(), "Trying to read 'margin' value for element index outside of the given data. [ idx:{} | range:0 .. {}]", info.mar_i, - ice::count(uidata.margins) + uidata.margins.size() ); out_rect_offset = uidata.margins[index]; @@ -71,10 +71,10 @@ namespace ice::ui ice::u16 const index = info.mar_i & 0x0fff; ICE_ASSERT( - index < ice::count(uidata.paddings), + index < uidata.paddings.size(), "Trying to read 'padding' value for element index outside of the given data. [ idx:{} | range:0 .. {}]", info.pad_i, - ice::count(uidata.paddings) + uidata.paddings.size() ); out_rect_offset = uidata.paddings[index]; diff --git a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx index ac2dfd99..21797563 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx @@ -42,14 +42,14 @@ class AssetCompilerApp : public ice::tool::ToolApp bool parse_parameter(this AssetCompilerApp& self, ice::Span results) noexcept { - if (ice::count(results) == 2) + if (results.size() == 2) { ice::array::push_back( self._params, ice::shard(results[0], results[1].begin()) ); } - if (ice::count(results) == 1) + if (results.size() == 1) { ice::array::push_back( self._params, @@ -417,7 +417,7 @@ class AssetCompilerApp : public ice::tool::ToolApp }; // Write all parts - for (ice::Data file_part : ice::span::subspan(ice::Span{ file_parts }, _output_raw ? 4 : 0)) + for (ice::Data file_part : ice::Span{ file_parts }.subspan(_output_raw ? 4 : 0)) { if (ice::native_file::append_file(output_file, file_part) != file_part.size) { diff --git a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx index 9d14e2a7..e083d825 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx @@ -64,7 +64,7 @@ AssetCompilerResourceProvider::AssetCompilerResourceProvider( , _resources{ _allocator } , _data{ _allocator } { - ice::array::reserve(_resources, ice::count(files)); + ice::array::reserve(_resources, files.size().u32()); ice::u32 idx = 0; for (ice::String file : files) diff --git a/source/code/tools/hsc_packer/private/hsc_packer.cxx b/source/code/tools/hsc_packer/private/hsc_packer.cxx index 75cd699b..25e7631b 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer.cxx @@ -283,10 +283,10 @@ class HailStormPackerApp final : public ice::tool::ToolApp ice::Array resource_handles{ _allocator }; ice::Array resource_paths{ _allocator }; - ice::array::resize(resource_data, ice::count(resources)); - ice::array::resize(resource_metamap, ice::count(resources)); - ice::array::resize(resource_handles, ice::count(resources)); - ice::array::resize(resource_paths, ice::count(resources)); + ice::array::resize(resource_data, resources.size().u32()); + ice::array::resize(resource_metamap, resources.size().u32()); + ice::array::resize(resource_handles, resources.size().u32()); + ice::array::resize(resource_paths, resources.size().u32()); // We serialize an empty meta object ice::ConfigBuilder meta{ _allocator }; diff --git a/source/code/tools/hsc_reader/private/hsc_reader_app.cxx b/source/code/tools/hsc_reader/private/hsc_reader_app.cxx index c37f6c6e..66d0972c 100644 --- a/source/code/tools/hsc_reader/private/hsc_reader_app.cxx +++ b/source/code/tools/hsc_reader/private/hsc_reader_app.cxx @@ -11,11 +11,11 @@ bool ParamRange::param_parse_results(ParamRange& range, ice::Span 1) + if (results.size() > 1) { value = results[1]; } From 15c9b95956f6a5daf8537b5b670b27f3d545c9fc Mon Sep 17 00:00:00 2001 From: Dandielo Date: Fri, 9 Jan 2026 23:01:44 +0900 Subject: [PATCH 09/40] #ICE-206 State In Review #ICE-205 Added support for iterator functionality. --- .../ice/container/container_concepts.hxx | 6 + .../ice/container/contiguous_container.hxx | 25 ++ .../code/core/collections/public/ice/span.hxx | 263 +++++------------- 3 files changed, 95 insertions(+), 199 deletions(-) diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index df86b312..7120922e 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -48,4 +48,10 @@ namespace ice::container //using ValuePtr = ice::const_correct_t, typename ContainerT::ValueType>*; using ValuePtr = typename std::remove_reference_t::ValueType*; + template + using Iterator = typename std::remove_reference_t::Iterator; + + template + using ReverseIterator = typename std::remove_reference_t::ReverseIterator; + } // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/contiguous_container.hxx b/source/code/core/collections/public/ice/container/contiguous_container.hxx index 4e9b5f82..6874361d 100644 --- a/source/code/core/collections/public/ice/container/contiguous_container.hxx +++ b/source/code/core/collections/public/ice/container/contiguous_container.hxx @@ -79,6 +79,31 @@ namespace ice::container return { self.data() + max_offset, max_offset - offset }; } + // Iteration interface + template + constexpr auto begin(this Self&& self) noexcept -> ice::container::Iterator + { + return { self.data() }; + } + + template + constexpr auto end(this Self&& self) noexcept -> ice::container::Iterator + { + return { self.data() + self.size() }; + } + + template + constexpr auto rbegin(this Self&& self) noexcept -> ice::container::ReverseIterator + { + return { self.data() + self.size() }; + } + + template + constexpr auto rend(this Self&& self) noexcept -> ice::container::ReverseIterator + { + return { self.data() }; + } + // Operators template constexpr auto operator[](this Self&& self, ice::nindex index) noexcept -> ice::container::ValueRef diff --git a/source/code/core/collections/public/ice/span.hxx b/source/code/core/collections/public/ice/span.hxx index cfbffeb8..3e5d4f68 100644 --- a/source/code/core/collections/public/ice/span.hxx +++ b/source/code/core/collections/public/ice/span.hxx @@ -39,248 +39,113 @@ namespace ice constexpr auto operator=(ice::Span&& other) noexcept -> ice::Span& = default; constexpr auto operator=(ice::Span const& other) noexcept -> ice::Span& = default; - constexpr operator ice::Span() noexcept { return { _data, _count }; } - constexpr operator ice::Span() const noexcept { return { _data, _count }; } - // API Requirements Of: Contiguous Container template constexpr auto data(this Self& self) noexcept -> ice::container::ValuePtr { return self._data; } constexpr auto size(this Span const& self) noexcept -> ice::ncount { return { self._count, sizeof(ValueType) }; } + + // API Requirements Of: Data and Memory + constexpr auto data_view(this Span const& self) noexcept -> ice::Data; + constexpr auto memory_view(this Span const& self) noexcept -> ice::Memory + requires(not std::is_const_v); + + // Implicit type conversions + constexpr operator ice::Span() noexcept { return { _data, _count }; } + constexpr operator ice::Span() const noexcept { return { _data, _count }; } }; - template Span(T(&)[Size]) noexcept -> Span; template Span(ice::Span&&) noexcept -> Span; template Span(ice::Span const&) noexcept -> Span; template typename Container> Span(Container const&) noexcept -> Span; + template Span(T(&)[Size]) noexcept -> Span; - namespace span - { - - template - constexpr auto data_view(ice::Span span) noexcept -> ice::Data; - - template - constexpr auto size_bytes(ice::Span span) noexcept -> ice::usize; - - template - constexpr auto alignment(ice::Span span) noexcept -> ice::ualign; - - template - constexpr auto begin(ice::Span span) noexcept -> typename ice::Span::Iterator; - - template - constexpr auto end(ice::Span span) noexcept -> typename ice::Span::Iterator; - - template - constexpr auto rbegin(ice::Span span) noexcept -> typename ice::Span::ReverseIterator; - - template - constexpr auto rend(ice::Span span) noexcept -> typename ice::Span::ReverseIterator; - - template - constexpr auto begin(ice::Span span) noexcept -> typename ice::Span::ConstIterator; - - template - constexpr auto end(ice::Span span) noexcept -> typename ice::Span::ConstIterator; - - template - constexpr auto rbegin(ice::Span span) noexcept -> typename ice::Span::ConstReverseIterator; - - template - constexpr auto rend(ice::Span span) noexcept -> typename ice::Span::ConstReverseIterator; - - - template - constexpr auto from_std(std::array const& std_array) noexcept -> ice::Span; - - template - constexpr auto memory(ice::Span span) noexcept -> ice::Memory; - - } // namespace span - - namespace data - { - - template - requires (std::is_trivially_copyable_v && !std::is_pointer_v) - inline auto read_span(ice::Data source, ice::u64 count, ice::Span& out_value) noexcept -> ice::Data - { - ICE_ASSERT_CORE(source.alignment >= ice::align_of); - out_value._count = count; - out_value._data = reinterpret_cast(source.location); - - ice::usize const consumed_size = ice::size_of *count; - source.location = out_value.data() + count; - source.size = ice::usize::subtract(source.size, consumed_size); - source.alignment = ice::align_of; - return source; - } - - } // namespace data + template + static constexpr auto make_span(std::array& std_array) noexcept -> Span; + template + static constexpr auto make_span(std::array const& std_array) noexcept -> Span; template constexpr Span::Span() noexcept : _count{ 0 } , _data{ nullptr } - { - } + { } template constexpr Span::Span(Type* location, ice::ncount count) noexcept : _count{ count.native() } , _data{ location } - { - } + { } template constexpr Span::Span(Type* from, Type* to) noexcept : _count{ static_cast(to - from) } , _data{ from } - { - } + { } template template constexpr Span::Span(Type(&location)[Size]) noexcept : _count{ Size } , _data{ location } + { } + + template + inline constexpr auto Span::data_view(this Span const& self) noexcept -> ice::Data { + return ice::Data{ + .location = self.data(), + .size = self.size(), + .alignment = ice::align_of + }; } - namespace span + template + inline constexpr auto Span::memory_view(this Span const& self) noexcept -> ice::Memory + requires(not std::is_const_v) { + return ice::Data{ + .location = self.data(), + .size = self.size(), + .alignment = ice::align_of + }; + } - template - constexpr auto data(ice::Span span) noexcept -> Type* - { - return span._data; - } - - template - constexpr auto data_view(ice::Span span) noexcept -> ice::Data - { - return Data{ - .location = ice::span::data(span), - .size = ice::span::size_bytes(span), - .alignment = ice::span::alignment(span) - }; - } - - template - constexpr auto size_bytes(ice::Span span) noexcept -> ice::usize - { - return span.size(); - } - - template - constexpr auto alignment(ice::Span span) noexcept -> ice::ualign - { - return ice::align_of; - } - - template - constexpr auto begin(ice::Span span) noexcept -> typename ice::Span::Iterator - { - return span._data; - } - - template - constexpr auto end(ice::Span span) noexcept -> typename ice::Span::Iterator - { - return span._data + span._count; - } - - template - constexpr auto rbegin(ice::Span span) noexcept -> typename ice::Span::ReverseIterator - { - return typename ice::Span::ReverseIterator{ span._data + span._count }; - } - - template - constexpr auto rend(ice::Span span) noexcept -> typename ice::Span::ReverseIterator - { - return typename ice::Span::ReverseIterator{ span._data }; - } - - template - constexpr auto begin(ice::Span span) noexcept -> typename ice::Span::ConstIterator - { - return span._data; - } - - template - constexpr auto end(ice::Span span) noexcept -> typename ice::Span::ConstIterator - { - return span._data + span._count; - } - - template - constexpr auto rbegin(ice::Span span) noexcept -> typename ice::Span::ConstReverseIterator - { - return typename ice::Span::ConstReverseIterator{ span._data + span._count }; - } - - template - constexpr auto rend(ice::Span span) noexcept -> typename ice::Span::ConstReverseIterator - { - return typename ice::Span::ConstReverseIterator{ span._data }; - } - - - template - constexpr auto from_std(std::array& std_array) noexcept -> ice::Span - { - return ice::Span{ std_array.data(), std_array.size() }; - } - - template - constexpr auto from_std_const(std::array const& std_array) noexcept -> ice::Span - { - return ice::Span{ std_array.data(), std_array.size() }; - } + template + inline constexpr auto make_span(std::array& std_array) noexcept -> Span + { + return Span{ std_array.data(), std_array.size() }; + } - // TODO: Move to another location or rename? Not sure this is properly named - template - constexpr auto memory(ice::Span span) noexcept -> ice::Memory - { - return ice::Memory{ - .location = ice::span::begin(span), - .size = ice::span::size_bytes(span), - .alignment = ice::span::alignment(span) - }; - } + template + inline constexpr auto make_span(std::array const& std_array) noexcept -> Span + { + return Span{ std_array.data(), std_array.size() }; + } - template - constexpr auto from_memory(ice::Memory const& mem, ice::u64 count, ice::usize offset) noexcept -> ice::Span - { - static ice::meminfo minfo = ice::meminfo_of; + static_assert(ice::TrivialContainerLogicAllowed>); - void* const ptr = ice::ptr_add(mem.location, offset); - ICE_ASSERT_CORE(ice::is_aligned(ptr, minfo.alignment)); - ICE_ASSERT_CORE(ice::ptr_add(mem.location, mem.size) >= ice::ptr_add(ptr, minfo.size * count)); - return ice::Span{ reinterpret_cast(ptr), count }; - } + // TODO: Move to a data reader type + namespace data + { - // TODO: Move to another location or rename? Not sure this is properly named - template - constexpr auto from_data(ice::Data const& mem, ice::u64 count, ice::usize offset) noexcept -> ice::Span + template + requires (std::is_trivially_copyable_v && !std::is_pointer_v) + inline auto read_span( + ice::Data source, + ice::ncount count, + ice::Span& out_value + ) noexcept -> ice::Data { - static ice::meminfo constexpr minfo = ice::meminfo_of; + ICE_ASSERT_CORE(source.alignment >= ice::align_of); + out_value._count = count; + out_value._data = reinterpret_cast(source.location); - void const* const ptr = ice::ptr_add(mem.location, offset); - ICE_ASSERT_CORE(ice::is_aligned(ptr, minfo.alignment)); - ICE_ASSERT_CORE(ice::ptr_add(mem.location, mem.size) >= ice::ptr_add(ptr, minfo.size * count)); - return { reinterpret_cast(ptr), count }; + source.location = out_value.data() + count; + source.size = ice::usize::subtract(source.size, out_value.size()); + source.alignment = ice::align_of; + return source; } - } // namespace span - - using ice::span::data_view; - - using ice::span::begin; - using ice::span::end; - - - static_assert(ice::TrivialContainerLogicAllowed>); + } // namespace data } // namespace ice From 7c3944793f41ce621fc53c741f7bbe5a4be02067 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Fri, 9 Jan 2026 23:02:45 +0900 Subject: [PATCH 10/40] #ICE-206 Fixing all code locations affected by the api change of 'Span'. --- .../public/ice/container/array.hxx | 2 - .../public/ice/container/impl/array_impl.inl | 8 +-- .../public/ice/container/impl/queue_impl.inl | 16 +++--- .../code/core/collections/public/ice/sort.hxx | 10 ++-- .../collections/tests/test_data_memory.cxx | 6 +- source/code/core/memsys/private/mem.cxx | 5 ++ source/code/core/memsys/public/ice/mem.hxx | 2 + .../memsys/public/ice/mem_initializers.hxx | 20 +++---- .../code/core/utils/public/ice/algorithm.hxx | 2 +- .../private/ecs/ecs_archetype_index.cxx | 10 ++-- .../engine/private/ecs/ecs_entity_index.cxx | 2 +- .../private/ecs/ecs_entity_operations.cxx | 18 +++--- .../engine/private/ecs/ecs_entity_storage.cxx | 4 +- .../engine/public/ice/ecs/ecs_archetype.hxx | 8 +-- .../public/ice/ecs/ecs_entity_operations.hxx | 56 +++++++++---------- .../public/ice/ecs/ecs_query_provider.hxx | 2 +- .../ice/ecs/ecs_query_storage_entry.hxx | 2 +- .../private/iceshard_world_tasks_launcher.cxx | 2 +- .../private/pipeline_ui/ip_ui_asset.cxx | 2 +- .../private/input_action_layer.cxx | 11 +++- .../private/input_action_script.cxx | 2 +- 21 files changed, 100 insertions(+), 90 deletions(-) diff --git a/source/code/core/collections/public/ice/container/array.hxx b/source/code/core/collections/public/ice/container/array.hxx index 254acd9e..a383fbd3 100644 --- a/source/code/core/collections/public/ice/container/array.hxx +++ b/source/code/core/collections/public/ice/container/array.hxx @@ -74,8 +74,6 @@ namespace ice::array template inline auto back(ice::Array& arr) noexcept -> Type&; - - template inline auto count(ice::Array const& arr) noexcept -> ice::u32; diff --git a/source/code/core/collections/public/ice/container/impl/array_impl.inl b/source/code/core/collections/public/ice/container/impl/array_impl.inl index e724b67c..7f321414 100644 --- a/source/code/core/collections/public/ice/container/impl/array_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/array_impl.inl @@ -83,13 +83,13 @@ namespace ice { ice::mem_copy_construct_n_at( ice::array::memory(*this), - ice::span::data(values), + values.data(), values.size() ); } else { - ice::memcpy(_data, ice::span::data(values), ice::span::size_bytes(values)); + ice::memcpy(_data, values.data(), values.size().bytes()); } _count = values.size().u32(); @@ -362,7 +362,7 @@ namespace ice { ice::mem_copy_construct_n_at( Memory{ .location = arr._data + arr._count, .size = ice::size_of * missing_items, .alignment = ice::align_of }, - ice::span::data(items), + items.data(), items.size().u32() ); } @@ -370,7 +370,7 @@ namespace ice { ice::memcpy( Memory{ .location = arr._data + arr._count, .size = ice::size_of * missing_items, .alignment = ice::align_of }, - ice::span::data_view(items) + items.data_view() ); } diff --git a/source/code/core/collections/public/ice/container/impl/queue_impl.inl b/source/code/core/collections/public/ice/container/impl/queue_impl.inl index b0426c58..61ad29a4 100644 --- a/source/code/core/collections/public/ice/container/impl/queue_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/queue_impl.inl @@ -461,7 +461,7 @@ namespace ice .size = ice::size_of * head_space, .alignment = ice::align_of }, - ice::span::data(items), + items.data(), head_space ); ice::mem_copy_construct_n_at( @@ -470,7 +470,7 @@ namespace ice .size = ice::size_of * tail_space, .alignment = ice::align_of }, - ice::span::data(items) + head_space, + items.data() + head_space, tail_space ); } @@ -483,7 +483,7 @@ namespace ice .alignment = ice::align_of }, Data{ - .location = ice::span::data(items), + .location = items.data(), .size = ice::size_of * head_space, .alignment = ice::align_of } @@ -495,7 +495,7 @@ namespace ice .alignment = ice::align_of }, Data{ - .location = ice::span::data(items) + head_space, + .location = items.data() + head_space, .size = ice::size_of * tail_space, .alignment = ice::align_of } @@ -605,13 +605,13 @@ namespace ice if constexpr (Logic == ContainerLogic::Complex) { - ice::mem_move_n_to(ice::span::begin(out_values), queue._data + queue._offset, first_part_count); - ice::mem_move_n_to(ice::span::begin(out_values) + first_part_count, queue._data, second_part); + ice::mem_move_n_to(out_values.begin(), queue._data + queue._offset, first_part_count); + ice::mem_move_n_to(out_values.begin() + first_part_count, queue._data, second_part); } else { - ice::memcpy(ice::span::begin(out_values), queue._data + queue._offset, first_part_count * sizeof(Type)); - ice::memcpy(ice::span::begin(out_values) + first_part_count, queue._data, second_part * sizeof(Type)); + ice::memcpy(out_values.begin(), queue._data + queue._offset, first_part_count * sizeof(Type)); + ice::memcpy(out_values.begin() + first_part_count, queue._data, second_part * sizeof(Type)); } ice::queue::pop_front(queue, taken_items); diff --git a/source/code/core/collections/public/ice/sort.hxx b/source/code/core/collections/public/ice/sort.hxx index 62401937..e3b42da0 100644 --- a/source/code/core/collections/public/ice/sort.hxx +++ b/source/code/core/collections/public/ice/sort.hxx @@ -67,25 +67,25 @@ namespace ice template requires (std::convertible_to) constexpr auto lower_bound(ice::Span values, U const& value) noexcept -> ice::u32 { - return static_cast(std::lower_bound(ice::span::begin(values), ice::span::end(values), value) - ice::span::begin(values)); + return static_cast(std::lower_bound(values.begin(), values.end(), value) - values.begin()); } template requires (std::convertible_to) constexpr auto lower_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::u32 { - return static_cast(std::lower_bound(ice::span::begin(values), ice::span::end(values), value, ice::forward(comp)) - ice::span::begin(values)); + return static_cast(std::lower_bound(values.begin(), values.end(), value, ice::forward(comp)) - values.begin()); } template requires (std::convertible_to) constexpr auto upper_bound(ice::Span values, U const& value) noexcept -> ice::u32 { - return static_cast(std::upper_bound(ice::span::begin(values), ice::span::end(values), value) - ice::span::begin(values)); + return static_cast(std::upper_bound(values.begin(), values.end(), value) - values.begin()); } template requires (std::convertible_to) constexpr auto upper_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::u32 { - return static_cast(std::upper_bound(ice::span::begin(values), ice::span::end(values), value, ice::forward(comp)) - ice::span::begin(values)); + return static_cast(std::upper_bound(values.begin(), values.end(), value, ice::forward(comp)) - values.begin()); } template requires (std::convertible_to) @@ -274,7 +274,7 @@ namespace ice template inline void sort(ice::Span span, Pred&& pred) noexcept { - std::sort(ice::span::begin(span), ice::span::end(span), ice::forward(pred)); + std::sort(span.begin(), span.end(), ice::forward(pred)); } template diff --git a/source/code/core/collections/tests/test_data_memory.cxx b/source/code/core/collections/tests/test_data_memory.cxx index 1a05a97c..1ed66bdd 100644 --- a/source/code/core/collections/tests/test_data_memory.cxx +++ b/source/code/core/collections/tests/test_data_memory.cxx @@ -48,8 +48,8 @@ SCENARIO("ice :: Data") data = ice::data_view(values_span); - CHECK(data.location == ice::span::data(values_span)); - CHECK(data.size == ice::span::size_bytes(values_span)); - CHECK(data.alignment == ice::span::alignment(values_span)); + CHECK(data.location == values_span.data()); + CHECK(data.size == values_span.size()); + CHECK(data.alignment == ice::align_of::ValueType>); } } diff --git a/source/code/core/memsys/private/mem.cxx b/source/code/core/memsys/private/mem.cxx index 20b19639..a8509619 100644 --- a/source/code/core/memsys/private/mem.cxx +++ b/source/code/core/memsys/private/mem.cxx @@ -94,6 +94,11 @@ namespace ice return std::memcpy(dest, source, size.value); } + auto memcpy(void* dest, ice::Data source) noexcept -> void* + { + return std::memcpy(dest, source.location, source.size.value); + } + auto memcpy(ice::Memory memory, ice::Data data) noexcept -> ice::Memory { ICE_ASSERT_CORE(memory.alignment >= data.alignment); diff --git a/source/code/core/memsys/public/ice/mem.hxx b/source/code/core/memsys/public/ice/mem.hxx index 5f16fa64..9e7cb10a 100644 --- a/source/code/core/memsys/public/ice/mem.hxx +++ b/source/code/core/memsys/public/ice/mem.hxx @@ -39,7 +39,9 @@ namespace ice void release_aligned(void* pointer) noexcept; auto memcpy(void* dest, void const* source, ice::usize size) noexcept -> void*; + auto memcpy(void* dest, ice::Data source) noexcept -> void*; auto memcpy(ice::Memory memory, ice::Data data) noexcept -> ice::Memory; + auto memset(ice::Memory memory, ice::u8 value) noexcept -> ice::Memory; constexpr AllocRequest::AllocRequest(ice::usize size, ice::ualign alignment) noexcept diff --git a/source/code/core/memsys/public/ice/mem_initializers.hxx b/source/code/core/memsys/public/ice/mem_initializers.hxx index 7364f85e..3939110d 100644 --- a/source/code/core/memsys/public/ice/mem_initializers.hxx +++ b/source/code/core/memsys/public/ice/mem_initializers.hxx @@ -30,11 +30,11 @@ namespace ice } template - auto mem_construct_n_at(ice::Memory memory, ice::u32 count) noexcept -> T* + auto mem_construct_n_at(ice::Memory memory, ice::u64 count) noexcept -> T* { // TODO: Assert (align + size) T* target_mem = reinterpret_cast(memory.location); - for (ice::u32 idx = 0; idx < count; ++idx) + for (ice::u64 idx = 0; idx < count; ++idx) { new (target_mem + idx) T{ }; } @@ -42,11 +42,11 @@ namespace ice } template - auto mem_move_construct_n_at(ice::Memory memory, T* objects, ice::u32 count) noexcept -> T* + auto mem_move_construct_n_at(ice::Memory memory, T* objects, ice::u64 count) noexcept -> T* { // TODO: Assert (align + size) T* target_mem = reinterpret_cast(memory.location); - for (ice::u32 idx = 0; idx < count; ++idx) + for (ice::u64 idx = 0; idx < count; ++idx) { new (target_mem + idx) T{ ice::move(objects[idx]) }; } @@ -54,9 +54,9 @@ namespace ice } template - auto mem_move_n_to(T* target_objects, T* objects, ice::u32 count) noexcept -> T* + auto mem_move_n_to(T* target_objects, T* objects, ice::u64 count) noexcept -> T* { - for (ice::u32 idx = 0; idx < count; ++idx) + for (ice::u64 idx = 0; idx < count; ++idx) { target_objects[idx] = ice::move(objects[idx]); } @@ -64,11 +64,11 @@ namespace ice } template - auto mem_copy_construct_n_at(ice::Memory memory, T const* objects, ice::u32 count) noexcept -> T* + auto mem_copy_construct_n_at(ice::Memory memory, T const* objects, ice::u64 count) noexcept -> T* { // TODO: Assert (align + size) T* target_mem = reinterpret_cast(memory.location); - for (ice::u32 idx = 0; idx < count; ++idx) + for (ice::u64 idx = 0; idx < count; ++idx) { new (target_mem + idx) T{ objects[idx] }; } @@ -84,9 +84,9 @@ namespace ice } template - void mem_destruct_n_at(T* location, ice::u32 count) noexcept + void mem_destruct_n_at(T* location, ice::u64 count) noexcept { - for (ice::u32 idx = 0; idx < count; ++idx) + for (ice::u64 idx = 0; idx < count; ++idx) { ice::mem_destruct_at(location + idx); } diff --git a/source/code/core/utils/public/ice/algorithm.hxx b/source/code/core/utils/public/ice/algorithm.hxx index 169e1696..0423731c 100644 --- a/source/code/core/utils/public/ice/algorithm.hxx +++ b/source/code/core/utils/public/ice/algorithm.hxx @@ -11,7 +11,7 @@ namespace ice template constexpr auto accumulate(ice::Span range, U val) noexcept { - return ::std::accumulate(ice::begin(range), ice::end(range), val); + return ::std::accumulate(range.begin(), range.end(), val); } } // namespace ice diff --git a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx index 60652a95..2c276d7e 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx @@ -230,7 +230,7 @@ namespace ice::ecs ice::memcpy(mem_archetype_name, archetype_info.name.data_view()); // Copy the component idnetifiers - ice::memcpy(mem_component_data, ice::span::data_view(archetype_info.component_identifiers)); + ice::memcpy(mem_component_data, archetype_info.component_identifiers.data_view()); component_identifiers = reinterpret_cast(mem_component_data.location); // Calculate where we start storing the u32 values... @@ -238,12 +238,12 @@ namespace ice::ecs // Copy the size and alignment. component_sizes = reinterpret_cast(mem_component_data.location); - ice::memcpy(mem_component_data, ice::span::data_view(archetype_info.component_sizes)); - mem_component_data = ice::ptr_add(mem_component_data, ice::span::size_bytes(archetype_info.component_sizes)); + ice::memcpy(mem_component_data, archetype_info.component_sizes.data_view()); + mem_component_data = ice::ptr_add(mem_component_data, archetype_info.component_sizes.size()); component_alignments = reinterpret_cast(mem_component_data.location); - ice::memcpy(mem_component_data, ice::span::data_view(archetype_info.component_alignments)); - mem_component_data = ice::ptr_add(mem_component_data, ice::span::size_bytes(archetype_info.component_alignments)); + ice::memcpy(mem_component_data, archetype_info.component_alignments.data_view()); + mem_component_data = ice::ptr_add(mem_component_data, archetype_info.component_alignments.size()); // Save location to store calculated offsets component_offsets = reinterpret_cast(mem_component_data.location); diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx index 1e37ed3c..49fc8baa 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx @@ -88,7 +88,7 @@ namespace ice::ecs bool EntityIndex::create_many(ice::Span out_entities) noexcept { ice::u32 total_indices_taken = 0; - auto out_it = ice::span::begin(out_entities); + auto out_it = out_entities.begin(); ice::u32 indices[256]; ice::i32 free_count = ice::i32(ice::queue::count(_free_indices)) - ice::ecs::Constant_MinimumFreeIndicesBeforeReuse; diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx index 675331d0..138051d7 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx @@ -310,7 +310,7 @@ namespace ice::ecs operation->component_data = nullptr; operation->component_data_size = 0; - ice::memcpy(operation->entities, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(operation->entities, entities.data_view()); } auto OperationBuilder::with_data( @@ -331,9 +331,9 @@ namespace ice::ecs // Data for storing component info additional_data_size += ice::meminfo_of; - additional_data_size.size += ice::span::size_bytes(component_info.names); - additional_data_size.size += ice::span::size_bytes(component_info.sizes); - additional_data_size.size += ice::span::size_bytes(component_info.offsets); + additional_data_size.size += component_info.names.size().bytes(); + additional_data_size.size += component_info.sizes.size().bytes(); + additional_data_size.size += component_info.offsets.size().bytes(); // Component data for (ice::Data const& data : component_data) @@ -354,7 +354,7 @@ namespace ice::ecs ice::ecs::Entity* entities_ptr = reinterpret_cast(operation_data); if (mode == 1) { - ice::memcpy(entities_ptr, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(entities_ptr, entities.data_view()); } else { @@ -364,10 +364,10 @@ namespace ice::ecs // Set component info object ice::StringID* names_ptr = reinterpret_cast(entities_ptr + entity_count); - ice::memcpy(names_ptr, ice::span::data(component_info.names), ice::span::size_bytes(component_info.names)); + ice::memcpy(names_ptr, component_info.names.data_view()); ice::u32* sizes_ptr = reinterpret_cast(names_ptr + component_count); - ice::memcpy(sizes_ptr, ice::span::data(component_info.sizes), ice::span::size_bytes(component_info.sizes)); + ice::memcpy(sizes_ptr, component_info.sizes.data_view()); ice::u32* offsets_ptr = reinterpret_cast(sizes_ptr + component_count); @@ -439,7 +439,7 @@ namespace ice::ecs ice::ecs::Entity* entities_ptr = reinterpret_cast(operation_data); if (mode == 1) { - ice::memcpy(entities_ptr, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(entities_ptr, entities.data_view()); } else { @@ -455,7 +455,7 @@ namespace ice::ecs operation->filter_data = filter_ptr; ice::memcpy(operation_data, filter_data, filter_data_size); - ice::memcpy(operation->entities, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(operation->entities, entities.data_view()); if (mode == 2) { diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx index 2cc07488..845fdbb9 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx @@ -322,8 +322,8 @@ namespace ice::ecs ice::Span data_blocks ) noexcept { - auto const* it = ice::span::begin(entities_to_remove); - auto const* const end = ice::span::end(entities_to_remove); + auto const* it = entities_to_remove.begin(); + auto const* const end = entities_to_remove.end(); ArchetypeInstance archetype{}; ArchetypeInstanceInfo const* archetype_infos[1]{ nullptr }; diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx index e846eb71..29bd3cc3 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx @@ -110,7 +110,7 @@ namespace ice::ecs component_alignments[idx] = sorted_components[idx - 1].alignment; } - identifier = ice::ecs::detail::make_archetype_identifier(ice::span::from_std_const(component_identifiers)); + identifier = ice::ecs::detail::make_archetype_identifier(ice::make_span(component_identifiers)); } template @@ -125,9 +125,9 @@ namespace ice::ecs ) noexcept : name{ archetype_info.name } , identifier{ archetype_info.identifier } - , component_identifiers{ ice::span::from_std_const(archetype_info.component_identifiers) } - , component_sizes{ ice::span::from_std_const(archetype_info.component_sizes) } - , component_alignments{ ice::span::from_std_const(archetype_info.component_alignments) } + , component_identifiers{ ice::make_span(archetype_info.component_identifiers) } + , component_sizes{ ice::make_span(archetype_info.component_sizes) } + , component_alignments{ ice::make_span(archetype_info.component_alignments) } { } diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx index 56f60936..6f280d25 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx @@ -291,14 +291,14 @@ namespace ice::ecs static ice::ecs::ArchetypeDefinition constexpr HelperArchetype; static ice::StaticArray constexpr ComponentIdxMap = ice::ecs::detail::make_argument_idx_map( - ice::span::from_std_const(HelperArchetype.component_identifiers) + ice::make_span(HelperArchetype.component_identifiers) ); static ice::ecs::OperationComponentInfo constexpr ComponentsInfo{ - .names = ice::span::from_std_const(HelperArchetype.component_identifiers).tailspan(1), - .sizes = ice::span::from_std_const(HelperArchetype.component_sizes).tailspan(1), + .names = ice::make_span(HelperArchetype.component_identifiers).tailspan(1), + .sizes = ice::make_span(HelperArchetype.component_sizes).tailspan(1), // We store alignments in this span just for convenience - .offsets = ice::span::from_std_const(HelperArchetype.component_alignments).tailspan(1) + .offsets = ice::make_span(HelperArchetype.component_alignments).tailspan(1) }; ice::Data const unsorted_component_Data[]{ @@ -311,7 +311,7 @@ namespace ice::ecs sorted_data_array[ComponentIdxMap[idx] - 1] = unsorted_component_Data[idx]; } - return this->with_data(ComponentsInfo, ice::span::from_std_const(sorted_data_array)); + return this->with_data(ComponentsInfo, ice::make_span(sorted_data_array)); } template @@ -325,14 +325,14 @@ namespace ice::ecs static ice::ecs::ArchetypeDefinition constexpr HelperArchetype; static ice::StaticArray constexpr ComponentIdxMap = ice::ecs::detail::make_argument_idx_map( - ice::span::from_std_const(HelperArchetype.component_identifiers) + ice::make_span(HelperArchetype.component_identifiers) ); static ice::ecs::OperationComponentInfo constexpr ComponentsInfo{ - .names = ice::span::from_std_const(HelperArchetype.component_identifiers).tailspan(1), - .sizes = ice::span::from_std_const(HelperArchetype.component_sizes).tailspan(1), + .names = ice::make_span(HelperArchetype.component_identifiers).tailspan(1), + .sizes = ice::make_span(HelperArchetype.component_sizes).tailspan(1), // We store alignments in this span just for convenience - .offsets = ice::span::from_std_const(HelperArchetype.component_alignments).tailspan(1) + .offsets = ice::make_span(HelperArchetype.component_alignments).tailspan(1) }; ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); @@ -342,9 +342,9 @@ namespace ice::ecs // Data for storing component info additional_data_size += ice::meminfo_of; - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.names); - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.sizes); - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.offsets); + additional_data_size.size += ComponentsInfo.names.size(); + additional_data_size.size += ComponentsInfo.sizes.size(); + additional_data_size.size += ComponentsInfo.offsets.size(); // Use folded expression to calculate all the size for the components... additional_data_size.size += ((ice::usize{ alignof(Components) } + ice::size_of * entity_count) + ...); @@ -362,7 +362,7 @@ namespace ice::ecs ice::ecs::Entity* entities_ptr = reinterpret_cast(operation_data); if (mode == 1) { - ice::memcpy(entities_ptr, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(entities_ptr, entities.data_view()); } else { @@ -372,10 +372,10 @@ namespace ice::ecs // Set component info object ice::StringID* names_ptr = reinterpret_cast(entities_ptr + entity_count); - ice::memcpy(names_ptr, ice::span::data(ComponentsInfo.names), ice::span::size_bytes(ComponentsInfo.names)); + ice::memcpy(names_ptr, ComponentsInfo.names.data_view()); ice::u32* sizes_ptr = reinterpret_cast(names_ptr + component_count); - ice::memcpy(sizes_ptr, ice::span::data(ComponentsInfo.sizes), ice::span::size_bytes(ComponentsInfo.sizes)); + ice::memcpy(sizes_ptr, ComponentsInfo.sizes.data_view()); ice::u32* offsets_ptr = reinterpret_cast(sizes_ptr + component_count); @@ -416,7 +416,7 @@ namespace ice::ecs span_ptr->_count = entity_count; // Move to the next data location... - data_ptr = ice::ptr_add(data_ptr, ice::span::size_bytes(*span_ptr)); + data_ptr = ice::ptr_add(data_ptr, span_ptr->size()); return true; }; @@ -467,14 +467,14 @@ namespace ice::ecs static ice::ecs::ArchetypeDefinition constexpr HelperArchetype; static ice::StaticArray constexpr ComponentIdxMap = ice::ecs::detail::make_argument_idx_map( - ice::span::from_std_const(HelperArchetype.component_identifiers) + ice::make_span(HelperArchetype.component_identifiers) ); static ice::ecs::OperationComponentInfo constexpr ComponentsInfo{ - .names = ice::span::from_std_const(HelperArchetype.component_identifiers).tailspan(1), - .sizes = ice::span::from_std_const(HelperArchetype.component_sizes).tailspan(1), + .names = ice::make_span(HelperArchetype.component_identifiers).tailspan(1), + .sizes = ice::make_span(HelperArchetype.component_sizes).tailspan(1), // We store alignments in this span just for convenience - .offsets = ice::span::from_std_const(HelperArchetype.component_alignments).tailspan(1) + .offsets = ice::make_span(HelperArchetype.component_alignments).tailspan(1) }; ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); @@ -484,9 +484,9 @@ namespace ice::ecs // Data for storing component info additional_data_size += ice::meminfo_of; - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.names); - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.sizes); - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.offsets); + additional_data_size.size += ComponentsInfo.names.size(); + additional_data_size.size += ComponentsInfo.sizes.size(); + additional_data_size.size += ComponentsInfo.offsets.size(); // Use folded expression to calculate all the size for the components... additional_data_size.size += ((ice::usize{ alignof(Components) } + ice::size_of * entity_count) + ...); @@ -504,7 +504,7 @@ namespace ice::ecs ice::ecs::Entity* entities_ptr = reinterpret_cast(operation_data); if (mode == 1) { - ice::memcpy(entities_ptr, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(entities_ptr, entities.data_view()); } else { @@ -514,10 +514,10 @@ namespace ice::ecs // Set component info object ice::StringID* names_ptr = reinterpret_cast(entities_ptr + entity_count); - ice::memcpy(names_ptr, ice::span::data(ComponentsInfo.names), ice::span::size_bytes(ComponentsInfo.names)); + ice::memcpy(names_ptr, ComponentsInfo.names.data_view()); ice::u32* sizes_ptr = reinterpret_cast(names_ptr + component_count); - ice::memcpy(sizes_ptr, ice::span::data(ComponentsInfo.sizes), ice::span::size_bytes(ComponentsInfo.sizes)); + ice::memcpy(sizes_ptr, ComponentsInfo.sizes.data_view()); ice::u32* offsets_ptr = reinterpret_cast(sizes_ptr + component_count); @@ -554,10 +554,10 @@ namespace ice::ecs // Update the span object... SpanType* span_ptr = reinterpret_cast(span_raw_ptr); - ice::memcpy(data_ptr, span_ptr->_data, ice::span::size_bytes(*span_ptr)); + ice::memcpy(data_ptr, span_ptr->data_view()); // Move to the next data location... - data_ptr = ice::ptr_add(data_ptr, ice::span::size_bytes(*span_ptr)); + data_ptr = ice::ptr_add(data_ptr, span_ptr->size()); return true; }; diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx index 51dda7e5..826bbe4a 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx @@ -82,7 +82,7 @@ namespace ice::ecs ice::u32 const prev_arch_count = ice::count(out_instance_infos); this->query_internal( - ice::span::from_std_const(Part::Definition::Constant_Requirements), + ice::make_span(Part::Definition::Constant_Requirements), (RefIdx == 0 ? query_tags : ice::Span{}), // We only want to apply tags on the main part out_access_trackers, out_instance_infos, diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx index 674174f8..dbc11b17 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx @@ -59,7 +59,7 @@ namespace ice::ecs { if constexpr (sizeof...(Tags) > 0) { - provider.initialize_query_object(_query_object, ice::span::from_std_const(ice::ecs::QueryTagsDefinition::Constant_Tags)); + provider.initialize_query_object(_query_object, ice::make_span(ice::ecs::QueryTagsDefinition::Constant_Tags)); } else { diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx index 336782ea..38c827d3 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx @@ -45,7 +45,7 @@ namespace ice shard.id ); - auto out_it = ice::begin(tasks); + auto out_it = tasks.begin(); auto it = ice::multi_hashmap::find_first(handlers, ice::hash(shard.id)); while (it != nullptr) { diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx index 14cfb836..ced28b9d 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx @@ -224,7 +224,7 @@ namespace ice { void* span_address = std::addressof(span_value); ice::u32 const span_size = span_value.size().u32(); - ice::u32 const span_offset = ice::u32(ice::ptr_distance(base_ptr, ice::span::data(span_value)).value); + ice::u32 const span_offset = ice::u32(ice::ptr_distance(base_ptr, span_value.data()).value); ice::u32* values = reinterpret_cast(span_address); values[0] = span_offset; diff --git a/source/code/systems/input_action_system/private/input_action_layer.cxx b/source/code/systems/input_action_system/private/input_action_layer.cxx index 73b2ae1f..ced42209 100644 --- a/source/code/systems/input_action_system/private/input_action_layer.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer.cxx @@ -35,10 +35,15 @@ namespace ice }; template - auto load_field_from_data(ice::Span& out_span, ice::Data data, ice::usize offset, ice::u32 count) noexcept + auto load_field_from_data( + ice::Span& out_span, + ice::Data data, + ice::usize offset, + ice::ncount count + ) noexcept -> ice::usize { - out_span = ice::span::from_data(data, count, offset); - return ice::span::data_view(out_span).size; + ice::data::read_span(ice::ptr_add(data, offset), count, out_span); + return out_span.size(); } auto load_from_data(ice::Data data) noexcept -> ice::Expected diff --git a/source/code/systems/input_action_system/private/input_action_script.cxx b/source/code/systems/input_action_system/private/input_action_script.cxx index 31481c6c..4f911bb7 100644 --- a/source/code/systems/input_action_system/private/input_action_script.cxx +++ b/source/code/systems/input_action_system/private/input_action_script.cxx @@ -70,7 +70,7 @@ namespace ice::asl ice::u32 idx; ice::asl::TokenDefinition const needle{ .value = word.value }; - if (ice::binary_search(ice::span::from_std_const(Constant_TokenDefinitions), needle, idx)) + if (ice::binary_search(ice::make_span(Constant_TokenDefinitions), needle, idx)) { result.type = Constant_TokenDefinitions[idx].type; word = processor.next(); From eb0c6624e538fcaebb300d2497b4a00d0f6ee763 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sat, 10 Jan 2026 11:56:52 +0900 Subject: [PATCH 11/40] #ICE-205 Split out a "BasicContainer" concept from "ContiguousContainer" and improved utilities for using concepts and deducing this implementations. #ICE-207 State In Progress Started work on refactoring the Array container. --- .../core/collections/public/ice/array.hxx | 327 ++++++++++++++++++ .../public/ice/container/array.hxx | 43 --- .../public/ice/container/basic_container.hxx | 34 ++ .../ice/container/container_concepts.hxx | 46 ++- .../ice/container/contiguous_container.hxx | 50 +-- .../public/ice/container/impl/array_impl.inl | 254 +------------- .../ice/container/resizable_container.hxx | 36 ++ .../public/ice/container_types.hxx | 59 +--- .../public/ice/shard_container.hxx | 10 +- .../code/core/collections/public/ice/span.hxx | 5 +- .../collections/public/ice/types/ncount.hxx | 6 + .../core/collections/tests/test_array.cxx | 132 +++---- .../collections/tests/test_data_memory.cxx | 2 +- .../tests/test_shard_container.cxx | 8 +- 14 files changed, 549 insertions(+), 463 deletions(-) create mode 100644 source/code/core/collections/public/ice/array.hxx create mode 100644 source/code/core/collections/public/ice/container/basic_container.hxx create mode 100644 source/code/core/collections/public/ice/container/resizable_container.hxx diff --git a/source/code/core/collections/public/ice/array.hxx b/source/code/core/collections/public/ice/array.hxx new file mode 100644 index 00000000..f38430e6 --- /dev/null +++ b/source/code/core/collections/public/ice/array.hxx @@ -0,0 +1,327 @@ +#pragma once +#include +#include +#include + +namespace ice +{ + + //! \brief A simple contaier storing items in contignous memory. + //! + //! \details Manages a memory block big enough to hold the items that it holds. + //! + //! \tparam Logic The logic used during memory operations for the given type. + //! This value cab be set by the user to enforce expected behavior for stored types. + template> + struct Array : public ice::container::ContiguousContainer, public ice::container::ResizableContainer + { + static_assert( + Logic == ContainerLogic::Complex || ice::TrivialContainerLogicAllowed, + "Collection element type is not allowed with 'Trivial' logic!" + ); + + using ValueType = Type; + using ConstContainerValueType = Type const; + using Iterator = Type*; + using ReverseIterator = std::reverse_iterator; + using ConstIterator = Type const*; + using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; + + ice::Allocator* _allocator; + ice::u32 _capacity; + ice::u32 _count; + ValueType* _data; + + inline explicit Array(ice::Allocator& alloc) noexcept; + inline Array(Array&& other) noexcept; + inline Array(Array const& other) noexcept + requires std::copy_constructible; + inline ~Array() noexcept; + + inline Array( + ice::Allocator& alloc, + ice::Span values + ) noexcept requires std::copy_constructible; + + // API Requirements Of: Container and Resizable Container + template + constexpr auto data(this Self& self) noexcept -> ice::container::ValuePtr { return self._data; } + constexpr auto size() const noexcept -> ice::ncount { return { _count, sizeof(ValueType) }; } + + // API Requirements Of: Resizable Container + constexpr auto capacity() const noexcept -> ice::ncount { return { _capacity, sizeof(ValueType) }; } + constexpr void resize(ice::ncount new_capacity) noexcept; + constexpr void set_capacity(ice::ncount new_capacity) noexcept; + + // API Requirements Of: Data and Memory + constexpr auto data_view(this Array const& self) noexcept -> ice::Data; + constexpr auto memory_view(this Array& self) noexcept -> ice::Memory; + + inline auto operator=(Array&& other) noexcept -> Array&; + inline auto operator=(Array const& other) noexcept -> Array& + requires std::copy_constructible; + + inline operator ice::Span() noexcept; + inline operator ice::Span() const noexcept; + }; + + template + auto data_view(ice::Array const& arr) noexcept -> ice::Data + { + return arr.data_view(); + } + + template + inline Array::Array(ice::Allocator& alloc) noexcept + : _allocator{ &alloc } + , _capacity{ 0 } + , _count{ 0 } + , _data{ nullptr } + { } + + template + inline Array::Array(Array&& other) noexcept + : _allocator{ other._allocator } + , _capacity{ ice::exchange(other._capacity, 0) } + , _count{ ice::exchange(other._count, 0) } + , _data{ ice::exchange(other._data, nullptr) } + { } + + template + inline Array::Array(Array const& other) noexcept + requires std::copy_constructible + : _allocator{ other._allocator } + , _capacity{ 0 } + , _count{ 0 } + , _data{ nullptr } + { + if (other._count > 0) + { + set_capacity(other.size()); + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_copy_construct_n_at( + memory_view(), + other.data(), + other.size() + ); + } + else + { + ice::memcpy( + memory_view(), + other.data_view() + ); + } + + _count = other._count; + } + } + + template + inline Array::~Array() noexcept + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_destruct_n_at(_data, _count); + } + + _allocator->deallocate(memory_view()); + } + + template + inline Array::Array( + ice::Allocator& alloc, + ice::Span values + ) noexcept + requires std::copy_constructible + : _allocator{ &alloc } + , _capacity{ 0 } + , _count{ 0 } + , _data{ nullptr } + { + if (values.not_empty()) + { + set_capacity(values.size()); + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_copy_construct_n_at( + memory_view(), + values.data(), + values.size() + ); + } + else + { + ice::memcpy(memory_view(), values.data_view()); + } + + _count = values.size().u32(); + } + } + + template + inline auto Array::operator=(Array&& other) noexcept -> Array& + { + if (this != &other) + { + set_capacity(0); + + _allocator = other._allocator; + _capacity = ice::exchange(other._capacity, 0); + _data = ice::exchange(other._data, nullptr); + _count = ice::exchange(other._count, 0); + } + return *this; + } + + template + inline auto Array::operator=(Array const& other) noexcept -> Array& + requires std::copy_constructible + { + if (this != &other) + { + this->clear(); + this->reserve(other.capacity()); + + if (other.size() > 0) + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_copy_construct_n_at( + memory_view(), + other.data(), + other.size() + ); + } + else + { + ice::memcpy( + memory_view(), + other.data_view() + ); + } + } + + _count = other._count; + } + return *this; + } + + template + inline Array::operator ice::Span() noexcept + { + return Span{ _data, _count }; + } + + template + inline Array::operator ice::Span() const noexcept + { + return Span{ _data, _count }; + } + + template + inline constexpr void ice::Array::set_capacity(ice::ncount new_capacity) noexcept + { + if (new_capacity == _capacity) + { + return; + } + + if (new_capacity < _count) + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_destruct_n_at(_data + new_capacity, _count - new_capacity); + } + + _count = new_capacity.u32(); + } + + ValueType* new_data = nullptr; + if (new_capacity > 0) + { + ice::AllocResult new_buffer = _allocator->allocate(ice::meminfo_of * new_capacity); + ICE_ASSERT_CORE(new_buffer.memory != nullptr); + if (_count > 0) + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_move_construct_n_at(new_buffer, _data, _count); + ice::mem_destruct_n_at(_data, _count); + } + else + { + ice::memcpy(new_buffer, data_view()); + } + } + new_data = reinterpret_cast(new_buffer.memory); + } + + _allocator->deallocate(memory_view()); + _data = new_data; + _capacity = new_capacity.u32(); + } + + template + inline constexpr void ice::Array::resize(ice::ncount new_size) noexcept + { + if (_capacity < new_size) + { + set_capacity(new_size); + } + + if (new_size > _count) + { + ice::ncount const missing_items = new_size - _count; + ice::Memory const uninitialized_memory = ice::ptr_add(memory_view(), size()); + + // Even for trivial logic we construct items so at least the default ctor is called. + ICE_ASSERT_CORE(std::is_default_constructible_v); + if constexpr (std::is_default_constructible_v) + { + ice::mem_construct_n_at( + uninitialized_memory, + missing_items + ); + } + } + else if constexpr (Logic == ContainerLogic::Complex) + { + static_assert(Logic != ContainerLogic::Trivial); + ice::ncount const destroyed_items = _count - new_size; + + ice::mem_destruct_n_at( + _data + new_size, + destroyed_items + ); + } + + _count = new_size.u32(); + } + + template + inline constexpr auto Array::data_view(this Array const& self) noexcept -> ice::Data + { + return ice::Data{ + .location = self.data(), + .size = self.size(), + .alignment = ice::align_of + }; + } + + template + inline constexpr auto Array::memory_view(this Array& self) noexcept -> ice::Memory + { + return ice::Memory{ + .location = self.data(), + .size = self.capacity(), + .alignment = ice::align_of + }; + } + + +} // namespace ice diff --git a/source/code/core/collections/public/ice/container/array.hxx b/source/code/core/collections/public/ice/container/array.hxx index a383fbd3..c32db4d9 100644 --- a/source/code/core/collections/public/ice/container/array.hxx +++ b/source/code/core/collections/public/ice/container/array.hxx @@ -8,24 +8,6 @@ namespace ice::array { - template - inline void set_capacity(ice::Array& arr, ice::u32 new_capacity) noexcept; - - template - inline void reserve(ice::Array& arr, ice::u32 min_capacity) noexcept; - - template - inline void grow(ice::Array& arr, ice::u32 min_capacity = 0) noexcept; - - template - inline void resize(ice::Array& arr, ice::u32 new_size) noexcept; - - template - inline void shrink(ice::Array& arr) noexcept; - - template - inline void clear(ice::Array& arr) noexcept; - template inline auto slice( ice::Array& arr, @@ -68,27 +50,9 @@ namespace ice::array template inline auto rend(ice::Array& arr) noexcept -> typename ice::Array::ReverseIterator; - template - inline auto front(ice::Array& arr) noexcept -> Type&; - - template - inline auto back(ice::Array& arr) noexcept -> Type&; - - template - inline auto count(ice::Array const& arr) noexcept -> ice::u32; - - template - inline auto capacity(ice::Array const& arr) noexcept -> ice::u32; - template inline auto size_bytes(ice::Array const& arr) noexcept -> ice::usize; - template - inline bool any(ice::Array const& arr) noexcept; - - template - inline bool empty(ice::Array const& arr) noexcept; - template inline auto slice( ice::Array const& arr, @@ -108,12 +72,6 @@ namespace ice::array template inline auto rend(ice::Array const& arr) noexcept -> typename ice::Array::ConstReverseIterator; - template - inline auto front(ice::Array const& arr) noexcept -> Type const&; - - template - inline auto back(ice::Array const& arr) noexcept -> Type const&; - template @@ -133,7 +91,6 @@ namespace ice::array namespace ice { - using ice::array::count; using ice::array::begin; using ice::array::end; diff --git a/source/code/core/collections/public/ice/container/basic_container.hxx b/source/code/core/collections/public/ice/container/basic_container.hxx new file mode 100644 index 00000000..7e574ced --- /dev/null +++ b/source/code/core/collections/public/ice/container/basic_container.hxx @@ -0,0 +1,34 @@ +#pragma once +#include + +namespace ice::container +{ + + struct BasicContainer + { + template + constexpr bool is_empty(this Self const& self) noexcept + { + return self.size() == 0; + } + + template + constexpr bool not_empty(this Self const& self) noexcept + { + return self.is_empty() == false; + } + + template + constexpr auto first(this Self&& self) noexcept -> ice::container::ValueRef + { + return self.data()[0]; + } + + template + constexpr auto last(this Self&& self) noexcept -> ice::container::ValueRef + { + return self.data()[self.size() - 1]; + } + }; + +} // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index 7120922e..46080975 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -9,6 +9,7 @@ namespace ice::concepts concept ContainerType = requires(T t) { typename std::remove_reference_t::SizeType; typename std::remove_reference_t::ValueType; + typename std::remove_reference_t::ConstContainerValueType; typename std::remove_reference_t::Iterator; typename std::remove_reference_t::ReverseIterator; typename std::remove_reference_t::ConstIterator; @@ -16,11 +17,19 @@ namespace ice::concepts }; template - concept ContiguousContainer = ContainerType && requires(T t) { + concept Container = ContainerType && requires(T t) { { t.size() } -> std::convertible_to; { t.data() } -> std::convertible_to::ValueType const*>; }; + template + concept ResizableContainer = Container && requires(T t, ice::ncount size) { + { t.data() } -> std::convertible_to::ValueType*>; + { t.resize(size) } -> std::convertible_to; + { t.capacity() } -> std::convertible_to; + { t.set_capacity(size) } -> std::convertible_to; + }; + } // namespace ice::concepts namespace ice @@ -35,23 +44,42 @@ namespace ice::container { template - using ContainerType = typename std::remove_reference_t; + using ConstCorrectContainerValueType = std::conditional_t< + std::is_const_v>, + typename std::remove_reference_t::ConstContainerValueType, + typename std::remove_reference_t::ValueType + >; + + template + using ConstCorrectContainerIterator = std::conditional_t< + std::is_const_v>, + typename std::remove_reference_t::ConstIterator, + typename std::remove_reference_t::Iterator + >; template - using SpanType = ice::Span::ValueType>; + using ConstCorrectContainerReverseIterator = std::conditional_t< + std::is_const_v>, + typename std::remove_reference_t::ReverseConstIterator, + typename std::remove_reference_t::ReverseIterator + >; template - //using ValueRef = ice::const_correct_t, typename ContainerT::ValueType>&; - using ValueRef = typename std::remove_reference_t::ValueType&; + using ValueRef = ConstCorrectContainerValueType&; template - //using ValuePtr = ice::const_correct_t, typename ContainerT::ValueType>*; - using ValuePtr = typename std::remove_reference_t::ValueType*; + using ValuePtr = ConstCorrectContainerValueType*; template - using Iterator = typename std::remove_reference_t::Iterator; + using Iterator = ConstCorrectContainerIterator; + + template + using ReverseIterator = ConstCorrectContainerReverseIterator; + + template + using ContainerType = typename std::remove_reference_t; template - using ReverseIterator = typename std::remove_reference_t::ReverseIterator; + using SpanType = ice::Span>; } // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/contiguous_container.hxx b/source/code/core/collections/public/ice/container/contiguous_container.hxx index 6874361d..d531487b 100644 --- a/source/code/core/collections/public/ice/container/contiguous_container.hxx +++ b/source/code/core/collections/public/ice/container/contiguous_container.hxx @@ -1,5 +1,5 @@ #pragma once -#include +#include namespace ice::container { @@ -7,34 +7,10 @@ namespace ice::container template struct Span; - struct ContiguousContainer + struct ContiguousContainer : ice::container::BasicContainer { - template - constexpr bool is_empty(this Self const& self) noexcept - { - return self.size() == 0; - } - - template - constexpr bool not_empty(this Self const& self) noexcept - { - return self.is_empty() == false; - } - - template - constexpr auto first(this Self&& self) noexcept -> ice::container::ValueRef - { - return self.data()[0]; - } - - template - constexpr auto last(this Self&& self) noexcept -> ice::container::ValueRef - { - return self.data()[self.size() - 1]; - } - // Accessing Data with Spans - template + template constexpr auto subspan( this Self&& self, ice::nindex from, @@ -44,10 +20,10 @@ namespace ice::container ice::ncount const item_count = self.size(); ice::nindex const from_start = ice::min(from, item_count); ice::ncount const remaining_count = item_count - from_start; - return { self.data() + from_start, count.min_value_or(remaining_count, remaining_count) }; + return { self.data() + from_start.native(), count.min_value_or(remaining_count, remaining_count)}; } - template + template constexpr auto subspan( this Self&& self, ice::ref32 refval @@ -56,7 +32,7 @@ namespace ice::container return self.subspan(refval.offset, refval.size); } - template + template constexpr auto headspan( this Self&& self, ice::ncount count = 1 @@ -66,7 +42,7 @@ namespace ice::container return { self.data(), count.min_value_or(self.size(), 0_count) }; } - template + template constexpr auto tailspan( this Self&& self, ice::nindex offset = 1 @@ -76,36 +52,36 @@ namespace ice::container offset = offset.min_value_or(max_offset, max_offset); // If 'offset' is not valid we default to 'max_size' so the returned span is empty. - return { self.data() + max_offset, max_offset - offset }; + return { self.data() + offset, max_offset - offset }; } // Iteration interface - template + template constexpr auto begin(this Self&& self) noexcept -> ice::container::Iterator { return { self.data() }; } - template + template constexpr auto end(this Self&& self) noexcept -> ice::container::Iterator { return { self.data() + self.size() }; } - template + template constexpr auto rbegin(this Self&& self) noexcept -> ice::container::ReverseIterator { return { self.data() + self.size() }; } - template + template constexpr auto rend(this Self&& self) noexcept -> ice::container::ReverseIterator { return { self.data() }; } // Operators - template + template constexpr auto operator[](this Self&& self, ice::nindex index) noexcept -> ice::container::ValueRef { return self.data()[index]; diff --git a/source/code/core/collections/public/ice/container/impl/array_impl.inl b/source/code/core/collections/public/ice/container/impl/array_impl.inl index 7f321414..37a1b242 100644 --- a/source/code/core/collections/public/ice/container/impl/array_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/array_impl.inl @@ -1,180 +1,15 @@ +#include "array.hxx" /// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT namespace ice { - template - inline Array::Array(ice::Allocator& alloc) noexcept - : _allocator{ &alloc } - , _capacity{ 0 } - , _count{ 0 } - , _data{ nullptr } - { } - - template - inline Array::Array(Array&& other) noexcept - : _allocator{ other._allocator } - , _capacity{ ice::exchange(other._capacity, 0) } - , _count{ ice::exchange(other._count, 0) } - , _data{ ice::exchange(other._data, nullptr) } - { - } - - template - inline Array::Array(Array const& other) noexcept - requires std::copy_constructible - : _allocator{ other._allocator } - , _capacity{ 0 } - , _count{ 0 } - , _data{ nullptr } - { - if (other._count > 0) - { - ice::array::set_capacity(*this, other._count); - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - ice::array::memory(*this), - other._data, - other._count - ); - } - else - { - ice::memcpy( - ice::array::memory(*this), - ice::array::data_view(other) - ); - } - - _count = other._count; - } - } - - template - inline Array::~Array() noexcept - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_n_at(_data, _count); - } - - _allocator->deallocate(ice::array::memory(*this)); - } - - template - inline Array::Array( - ice::Allocator& alloc, - ice::Span values - ) noexcept - requires std::copy_constructible - : _allocator{ &alloc } - , _capacity{ 0 } - , _count{ 0 } - , _data{ nullptr } - { - if (values.not_empty()) - { - ice::array::set_capacity(*this, values.size().u32()); - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - ice::array::memory(*this), - values.data(), - values.size() - ); - } - else - { - ice::memcpy(_data, values.data(), values.size().bytes()); - } - - _count = values.size().u32(); - } - } - - template - inline auto Array::operator=(Array&& other) noexcept -> Array& - { - if (this != &other) - { - ice::array::set_capacity(*this, 0); - - _allocator = other._allocator; - _capacity = ice::exchange(other._capacity, 0); - _data = ice::exchange(other._data, nullptr); - _count = ice::exchange(other._count, 0); - } - return *this; - } - - template - inline auto Array::operator=(Array const& other) noexcept -> Array& - requires std::copy_constructible - { - if (this != &other) - { - ice::array::clear(*this); - ice::array::reserve(*this, other._capacity); - - if (other._count > 0) - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - ice::array::memory(*this), - other._data, - other._count - ); - } - else - { - ice::memcpy( - ice::array::memory(*this), - ice::array::data_view(other) - ); - } - } - - _count = other._count; - } - return *this; - } - - template - inline auto Array::operator[](ice::u32 idx) noexcept -> Type& - { - // TODO: Assert - return _data[idx]; - } - - template - inline auto Array::operator[](ice::u32 idx) const noexcept -> Type const& - { - // TODO: Assert - return _data[idx]; - } - - template - inline Array::operator ice::Span() noexcept - { - return Span{ _data, _count }; - } - - template - inline Array::operator ice::Span() const noexcept - { - return Span{ _data, _count }; - } - namespace array { template - inline void set_capacity(ice::Array& arr, ice::u32 new_capacity) noexcept + inline void set_capacity(ice::Array& arr, ice::ncount new_capacity) noexcept { if (new_capacity == arr._capacity) { @@ -188,7 +23,7 @@ namespace ice ice::mem_destruct_n_at(arr._data + new_capacity, arr._count - new_capacity); } - arr._count = new_capacity; + arr._count = new_capacity.u32(); } Type* new_data = nullptr; @@ -213,11 +48,11 @@ namespace ice arr._allocator->deallocate(ice::array::memory(arr)); arr._data = new_data; - arr._capacity = new_capacity; + arr._capacity = new_capacity.u32(); } template - inline void reserve(ice::Array& arr, ice::u32 min_capacity) noexcept + inline void reserve(ice::Array& arr, ice::ncount min_capacity) noexcept { if (arr._capacity < min_capacity) { @@ -226,9 +61,9 @@ namespace ice } template - inline void grow(ice::Array& arr, ice::u32 min_capacity) noexcept + inline void grow(ice::Array& arr, ice::ncount min_capacity) noexcept { - ice::u32 new_capacity = arr._capacity * 2 + 4; + ice::ncount new_capacity = arr._capacity * 2 + 4; if (new_capacity < min_capacity) { new_capacity = min_capacity; @@ -237,7 +72,7 @@ namespace ice } template - inline void resize(ice::Array& arr, ice::u32 new_count) noexcept + inline void resize(ice::Array& arr, ice::ncount new_count) noexcept { if (arr._capacity < new_count) { @@ -246,7 +81,7 @@ namespace ice if (new_count > arr._count) { - ice::u32 const missing_items = new_count - arr._count; + ice::ncount const missing_items = new_count - arr._count; // Even for trivial logic we construct items so at least the default ctor is called. ice::mem_construct_n_at( @@ -257,7 +92,7 @@ namespace ice else if constexpr (Logic == ContainerLogic::Complex) { static_assert(Logic != ContainerLogic::Trivial); - ice::u32 const destroyed_items = arr._count - new_count; + ice::ncount const destroyed_items = arr._count - new_count; ice::mem_destruct_n_at( arr._data + new_count, @@ -265,7 +100,7 @@ namespace ice ); } - arr._count = new_count; + arr._count = new_count.u32(); } template @@ -296,9 +131,9 @@ namespace ice requires std::move_constructible inline void push_back(ice::Array& arr, Type&& item) noexcept { - if (arr._count == arr._capacity) + if (arr.size() == arr.capacity()) { - ice::array::grow(arr); + arr.grow(); } if constexpr (Logic == ContainerLogic::Complex) @@ -320,15 +155,15 @@ namespace ice requires std::copy_constructible && std::convertible_to inline void push_back(ice::Array& arr, Value const& item) noexcept { - if (arr._count == arr._capacity) + if (arr.size() == arr.capacity()) { - ice::array::grow(arr); + arr.grow(); } if constexpr (Logic == ContainerLogic::Complex) { ice::mem_copy_construct_at( - Memory{ .location = arr._data + arr._count, .size = ice::size_of, .alignment = ice::align_of }, + ice::ptr_add(arr.memory_view(), arr.size()), item ); } @@ -437,52 +272,12 @@ namespace ice return typename ice::Array::ReverseIterator{ arr._data }; } - template - inline auto front(ice::Array& arr) noexcept -> Type& - { - // #todo assert - return arr._data[0]; - } - - template - inline auto back(ice::Array& arr) noexcept -> Type& - { - // #todo assert - return arr._data[arr._count - 1]; - } - - - - template - inline auto count(ice::Array const& arr) noexcept -> ice::u32 - { - return arr._count; - } - - template - inline auto capacity(ice::Array const& arr) noexcept -> ice::u32 - { - return arr._capacity; - } - template inline auto size_bytes(ice::Array const& arr) noexcept -> ice::usize { return ice::size_of * arr._count; } - template - inline bool any(ice::Array const& arr) noexcept - { - return arr._count != 0; - } - - template - inline bool empty(ice::Array const& arr) noexcept - { - return arr._count == 0; - } - template inline auto slice(ice::Array const& arr, ice::u32 from_idx, ice::u32 count) noexcept -> ice::Span { @@ -521,21 +316,6 @@ namespace ice return typename ice::Array::ConstReverseIterator{ arr._data }; } - template - inline auto front(ice::Array const& arr) noexcept -> Type const& - { - // #todo assert - return arr._data[0]; - } - - template - inline auto back(ice::Array const& arr) noexcept -> Type const& - { - // #todo assert - return arr._data[arr._size - 1]; - } - - template inline auto data_view(ice::Array const& arr) noexcept -> ice::Data @@ -568,7 +348,7 @@ namespace ice template inline auto meminfo(ice::Array const& arr) noexcept -> ice::meminfo { - return ice::meminfo_of * ice::array::count(arr); + return ice::meminfo_of * arr.size().native(); } } // namespace array diff --git a/source/code/core/collections/public/ice/container/resizable_container.hxx b/source/code/core/collections/public/ice/container/resizable_container.hxx new file mode 100644 index 00000000..9aad2ac7 --- /dev/null +++ b/source/code/core/collections/public/ice/container/resizable_container.hxx @@ -0,0 +1,36 @@ +#pragma once +#include + +namespace ice::container +{ + + struct ResizableContainer + { + template + constexpr void clear(this Self& self) noexcept + { + self.resize(0); + } + + template + constexpr void reserve(this Self& self, ice::ncount min_capacity) noexcept + { + if (self.capacity() < min_capacity) + { + self.set_capacity(min_capacity); + } + } + + template + inline void grow(this Self& self, ice::ncount min_capacity = ice::ncount_none) noexcept + { + ice::ncount new_capacity = self.capacity() * 2 + 4; + if (new_capacity < min_capacity) + { + new_capacity = min_capacity; + } + self.set_capacity(new_capacity); + } + }; + +} // namespace ice diff --git a/source/code/core/collections/public/ice/container_types.hxx b/source/code/core/collections/public/ice/container_types.hxx index 5c7be632..f66c7d39 100644 --- a/source/code/core/collections/public/ice/container_types.hxx +++ b/source/code/core/collections/public/ice/container_types.hxx @@ -9,67 +9,10 @@ #include #include #include +#include namespace ice { - struct Test : ice::container::ContiguousContainer - { - using ValueType = int; - - int foo[4]; - - template - constexpr auto data(this Self& self) noexcept -> ice::const_correct_t* { return self.foo; } - constexpr ncount size() const noexcept { return 4; } - }; - - //! \brief A simple contaier storing items in contignous memory. - //! - //! \details Manages a memory block big enough to hold the items that it holds. - //! - //! \tparam Logic The logic used during memory operations for the given type. - //! This value cab be set by the user to enforce expected behavior for stored types. - template> - struct Array - { - static_assert( - Logic == ContainerLogic::Complex || ice::TrivialContainerLogicAllowed, - "Collection element type is not allowed with 'Trivial' logic!" - ); - - using ValueType = Type; - using Iterator = Type*; - using ReverSeIterator = std::reverse_iterator; - using ConstIterator = Type const*; - using ConstReverseIterator = std::reverse_iterator; - - ice::Allocator* _allocator; - ice::u32 _capacity; - ice::u32 _count; - Type* _data; - - inline explicit Array(ice::Allocator& alloc) noexcept; - inline Array(Array&& other) noexcept; - inline Array(Array const& other) noexcept - requires std::copy_constructible; - inline ~Array() noexcept; - - inline Array( - ice::Allocator& alloc, - ice::Span values - ) noexcept requires std::copy_constructible; - - inline auto operator=(Array&& other) noexcept -> Array&; - inline auto operator=(Array const& other) noexcept -> Array& - requires std::copy_constructible; - - inline auto operator[](ice::u32 idx) noexcept -> Type&; - inline auto operator[](ice::u32 idx) const noexcept -> Type const&; - - inline operator ice::Span() noexcept; - inline operator ice::Span() const noexcept; - }; - //! \brief A double ended queue build on a circular buffer. //! diff --git a/source/code/core/collections/public/ice/shard_container.hxx b/source/code/core/collections/public/ice/shard_container.hxx index 59e8c743..072c9118 100644 --- a/source/code/core/collections/public/ice/shard_container.hxx +++ b/source/code/core/collections/public/ice/shard_container.hxx @@ -155,7 +155,7 @@ namespace ice inline void remove_all_of(ice::ShardContainer& container, ice::ShardID value) noexcept { ice::Array& data = container._data; - ice::u32 count = ice::array::count(data); + ice::ncount count = data.size(); for (ice::u32 idx = 0; idx < count; ++idx) { @@ -166,7 +166,7 @@ namespace ice } } - ice::array::resize(data, count); + data.resize(count); } inline auto begin(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator @@ -182,17 +182,17 @@ namespace ice inline auto empty(ice::ShardContainer const& container) noexcept -> bool { - return ice::array::empty(container._data); + return container._data.is_empty(); } inline auto size(ice::ShardContainer const& container) noexcept -> ice::u32 { - return ice::array::count(container._data); + return container._data.size().u32(); } inline auto capacity(ice::ShardContainer const& container) noexcept -> ice::u32 { - return ice::array::capacity(container._data); + return container._data.capacity().u32(); } inline auto count(ice::ShardContainer const& container, ice::ShardID expected_shard) noexcept -> ice::u32 diff --git a/source/code/core/collections/public/ice/span.hxx b/source/code/core/collections/public/ice/span.hxx index 3e5d4f68..e473807b 100644 --- a/source/code/core/collections/public/ice/span.hxx +++ b/source/code/core/collections/public/ice/span.hxx @@ -2,13 +2,11 @@ /// SPDX-License-Identifier: MIT #pragma once -#include #include #include #include #include -#include -#include // TODO: Introduce our own static array object. +#include namespace ice { @@ -18,6 +16,7 @@ namespace ice struct Span : public ice::container::ContiguousContainer { using ValueType = Type; + using ConstContainerValueType = Type; using Iterator = Type*; using ReverseIterator = std::reverse_iterator; using ConstIterator = Type const*; diff --git a/source/code/core/collections/public/ice/types/ncount.hxx b/source/code/core/collections/public/ice/types/ncount.hxx index 925cfc02..1dd78548 100644 --- a/source/code/core/collections/public/ice/types/ncount.hxx +++ b/source/code/core/collections/public/ice/types/ncount.hxx @@ -64,4 +64,10 @@ namespace ice return ice::ncount{ value }; } + static constexpr ice::meminfo Test_Meminfo = ice::meminfo_of; + static_assert(Test_Meminfo.size == ice::size_of); + + static constexpr ice::meminfo Test_Meminfo_3 = Test_Meminfo * 3_count; + static_assert(Test_Meminfo_3.size == ice::size_of * 3); + } // namespace ice diff --git a/source/code/core/collections/tests/test_array.cxx b/source/code/core/collections/tests/test_array.cxx index f724d1ff..b3866d8a 100644 --- a/source/code/core/collections/tests/test_array.cxx +++ b/source/code/core/collections/tests/test_array.cxx @@ -14,10 +14,10 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" GIVEN("an empty Array object") { - CHECK(ice::array::empty(objects)); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::capacity(objects) == 0); - CHECK(ice::array::count(objects) == 0); + CHECK(objects.is_empty()); + CHECK(objects.not_empty() == false); + CHECK(objects.capacity() == 0); + CHECK(objects.size() == 0); // We force a capacity of 1, so we ensure a reallocation in later. ice::array::set_capacity(objects, 1); @@ -26,12 +26,12 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" { ice::array::push_back(objects, Test_TrackingObject{ }); - REQUIRE(ice::array::capacity(objects) >= 1); - REQUIRE(ice::array::count(objects) == 1); + REQUIRE(objects.capacity() >= 1); + REQUIRE(objects.size() == 1); THEN("constructors are called") { - Test_TrackingObject& obj = ice::array::front(objects); + Test_TrackingObject& obj = objects.first(); CHECK(obj == Test_ObjectEvents{ .test_ctor_move = 1 }); @@ -47,7 +47,7 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" AND_WHEN("resizing the array") { - Test_TrackingObject& obj = ice::array::front(objects); + Test_TrackingObject& obj = objects.first(); ice::u32 dtor_val = 0; obj.data.test_dtor = &dtor_val; @@ -56,15 +56,15 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" // The old object was moved to a new location (move ctor + dtor) CHECK(dtor_val == 1); - CHECK(ice::array::any(objects)); - CHECK(ice::array::empty(objects) == false); - CHECK(ice::array::capacity(objects) >= 10); - CHECK(ice::array::count(objects) == 10); + CHECK(objects.not_empty()); + CHECK(objects.is_empty() == false); + CHECK(objects.capacity() >= 10); + CHECK(objects.size() == 10); THEN("constructors are called") { - Test_TrackingObject& obj_front = ice::array::front(objects); - Test_TrackingObject& obj_back = ice::array::back(objects); + Test_TrackingObject& obj_front = objects.first(); + Test_TrackingObject& obj_back = objects.last(); CHECK(obj_front == Test_ObjectEvents{ .test_ctor_move = 1 }); CHECK(obj_back == Test_ObjectEvents{ .test_ctor = 1 }); @@ -75,10 +75,10 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" ice::Array array_copy = objects; ice::array::push_back(objects, array_copy); - CHECK(ice::array::capacity(objects) >= 20); - CHECK(ice::array::any(objects)); - CHECK(ice::array::empty(objects) == false); - CHECK(ice::array::count(objects) == 20); + CHECK(objects.capacity() >= 20); + CHECK(objects.not_empty()); + CHECK(objects.is_empty() == false); + CHECK(objects.size() == 20); ice::u32 copied_objects = 0; ice::u32 moved_objects = 0; @@ -101,10 +101,10 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" ice::array::clear(objects); CHECK(dtor_val == 20); - CHECK(ice::array::capacity(objects) > 0); - CHECK(ice::array::empty(objects)); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::count(objects) == 0); + CHECK(objects.capacity() > 0); + CHECK(objects.is_empty()); + CHECK(objects.not_empty() == false); + CHECK(objects.size() == 0); } } @@ -127,10 +127,10 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" ice::Array moved_objects = ice::move(objects); CHECK(dtor_val == 0); - CHECK(ice::array::capacity(objects) == 0); - CHECK(ice::array::empty(objects)); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::count(objects) == 0); + CHECK(objects.capacity() == 0); + CHECK(objects.is_empty()); + CHECK(objects.not_empty() == false); + CHECK(objects.size() == 0); total_events = Test_ObjectEvents{ }; for (Test_TrackingObject const& object : moved_objects) @@ -155,32 +155,32 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod GIVEN("an empty 'plain-old-data' Array") { - REQUIRE(ice::array::empty(objects)); - REQUIRE(ice::array::capacity(objects) == 0); + REQUIRE(objects.is_empty()); + REQUIRE(objects.capacity() == 0); WHEN("one element is pushed") { ice::array::push_back(objects, test_value_1); - CHECK(ice::array::count(objects) == 1); - CHECK(ice::array::any(objects) == true); - CHECK(ice::array::front(objects) == test_value_1); - CHECK(ice::array::back(objects) == test_value_1); + CHECK(objects.size() == 1); + CHECK(objects.not_empty() == true); + CHECK(objects.first() == test_value_1); + CHECK(objects.last() == test_value_1); THEN("one element is poped") { ice::array::pop_back(objects); - CHECK(ice::array::count(objects) == 0); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::empty(objects) == true); + CHECK(objects.size() == 0); + CHECK(objects.not_empty() == false); + CHECK(objects.is_empty() == true); THEN("array is shrunk") { ice::array::shrink(objects); - REQUIRE(ice::array::count(objects) == 0); - REQUIRE(ice::array::capacity(objects) == 0); + REQUIRE(objects.size() == 0); + REQUIRE(objects.capacity() == 0); } } @@ -188,9 +188,9 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod { ice::array::pop_back(objects, 10); - CHECK(ice::array::count(objects) == 0); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::empty(objects) == true); + CHECK(objects.size() == 0); + CHECK(objects.not_empty() == false); + CHECK(objects.is_empty() == true); } } @@ -201,43 +201,43 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod ice::array::push_back(objects, test_value_2 + i); } - CHECK(ice::array::count(objects) == 100); - CHECK(ice::array::capacity(objects) >= 100); - CHECK(ice::array::any(objects) == true); - CHECK(ice::array::empty(objects) == false); + CHECK(objects.size() == 100); + CHECK(objects.capacity() >= 100); + CHECK(objects.not_empty() == true); + CHECK(objects.is_empty() == false); - CHECK(ice::array::front(objects) == test_value_2); - CHECK(ice::array::back(objects) == test_value_2 + 99); + CHECK(objects.first() == test_value_2); + CHECK(objects.last() == test_value_2 + 99); THEN("50 elements are poped") { ice::array::pop_back(objects, 50); - CHECK(ice::array::any(objects) == true); - CHECK(ice::array::empty(objects) == false); - REQUIRE(ice::array::count(objects) == 50); + CHECK(objects.not_empty() == true); + CHECK(objects.is_empty() == false); + REQUIRE(objects.size() == 50); THEN("array is shrunk") { ice::array::shrink(objects); - CHECK(ice::array::any(objects) == true); - CHECK(ice::array::empty(objects) == false); - REQUIRE(ice::array::count(objects) == 50); - REQUIRE(ice::array::capacity(objects) == 50); + CHECK(objects.not_empty() == true); + CHECK(objects.is_empty() == false); + REQUIRE(objects.size() == 50); + REQUIRE(objects.capacity() == 50); } } THEN("array is cleared") { - ice::u32 const saved_capacity = ice::array::capacity(objects); + ice::ncount const saved_capacity = objects.capacity(); - ice::array::clear(objects); + objects.clear(); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::empty(objects) == true); - REQUIRE(ice::array::count(objects) == 0); - REQUIRE(ice::array::capacity(objects) == saved_capacity); + CHECK(objects.not_empty() == false); + CHECK(objects.is_empty() == true); + REQUIRE(objects.size() == 0); + REQUIRE(objects.capacity() == saved_capacity); } THEN("we can iterate over them") @@ -248,7 +248,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod elements_seen += 1; } - CHECK(elements_seen == ice::array::count(objects)); + CHECK(elements_seen == objects.size()); } THEN("we can iterate over a span") @@ -259,7 +259,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod elements_seen += 1; } - CHECK(elements_seen == ice::array::count(objects)); + CHECK(elements_seen == objects.size()); } THEN("we can iterate over a const span") @@ -270,20 +270,20 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod elements_seen += 1; } - CHECK(elements_seen == ice::array::count(objects)); + CHECK(elements_seen == objects.size()); } THEN("we can move them") { ice::Array moved_array = ice::move(objects); - CHECK(ice::array::count(moved_array) == 100); + CHECK(moved_array.size() == 100); THEN("we can add new items") { ice::array::push_back(objects, 100); - CHECK(ice::array::count(objects) == 1); + CHECK(objects.size() == 1); REQUIRE(objects[0] == 100); } } @@ -295,13 +295,13 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod moved_array = ice::move(objects); - CHECK(ice::array::count(moved_array) == 100); + CHECK(moved_array.size() == 100); THEN("we can add new items") { ice::array::push_back(objects, 100); - CHECK(ice::array::count(objects) == 1); + CHECK(objects.size() == 1); REQUIRE(objects[0] == 100); THEN("we can move again") diff --git a/source/code/core/collections/tests/test_data_memory.cxx b/source/code/core/collections/tests/test_data_memory.cxx index 1ed66bdd..2e252b9c 100644 --- a/source/code/core/collections/tests/test_data_memory.cxx +++ b/source/code/core/collections/tests/test_data_memory.cxx @@ -46,7 +46,7 @@ SCENARIO("ice :: Data") ice::Span values_span = values; - data = ice::data_view(values_span); + data = values_span.data_view(); CHECK(data.location == values_span.data()); CHECK(data.size == values_span.size()); diff --git a/source/code/core/collections/tests/test_shard_container.cxx b/source/code/core/collections/tests/test_shard_container.cxx index 7247678e..85bf5c4c 100644 --- a/source/code/core/collections/tests/test_shard_container.cxx +++ b/source/code/core/collections/tests/test_shard_container.cxx @@ -266,7 +266,7 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") ice::Array payloads{ alloc }; ice::shards::inspect_all(test_container, test_shard_1, payloads); - REQUIRE(ice::array::count(payloads) == 2); + REQUIRE(payloads.size() == 2); CHECK(payloads[0] == test_u32_payload_value1); CHECK(payloads[1] == test_u32_payload_value2); @@ -295,19 +295,19 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") ice::array::clear(payloads); ice::shards::inspect_all(test_container, test_shard_2, payloads); - REQUIRE(ice::array::count(payloads) == 0); + REQUIRE(payloads.size() == 0); ice::array::clear(payloads); ice::shards::inspect_all(test_container, test_shard_3, payloads); - REQUIRE(ice::array::count(payloads) == 2); + REQUIRE(payloads.size() == 2); CHECK(payloads[0] == test_u32_payload_value2); CHECK(payloads[1] == test_u32_payload_value1); ice::array::clear(payloads); ice::shards::inspect_all(test_container, test_shard_4, payloads); - REQUIRE(ice::array::count(payloads) == 1); + REQUIRE(payloads.size() == 1); CHECK(payloads[0] == test_u32_payload_value2); } } From bf7eb6a13aba4728bf5225a809f99e001454be0d Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sat, 10 Jan 2026 11:58:16 +0900 Subject: [PATCH 12/40] #ICE-207 Changes to engine source code after initial refactor of the Array type. --- .../tasks/private/task_scoped_container.cxx | 19 +++++------ .../tasks/private/task_thread_pool_impl.cxx | 4 +-- .../utils/private/config/config_builder.cxx | 8 ++--- .../private/config/config_builder_utils.cxx | 14 ++++---- .../code/core/utils/private/log_internal.cxx | 4 +-- source/code/core/utils/private/params.cxx | 2 +- .../private/ecs/ecs_archetype_index.cxx | 16 ++++----- .../engine/private/ecs/ecs_entity_index.cxx | 14 ++++---- .../engine/private/ecs/ecs_entity_storage.cxx | 20 +++++------ .../private/engine_state_tracker_default.cxx | 6 ++-- .../engine/private/gfx/ice_gfx_graph.cxx | 6 ++-- .../private/gfx/ice_gfx_graph_runtime.cxx | 2 +- .../public/ice/ecs/ecs_query_operations.hxx | 4 +-- .../public/ice/ecs/ecs_query_provider.hxx | 10 +++--- .../private/gfx/iceshard_gfx_device.cxx | 4 +-- .../private/gfx/iceshard_gfx_queue.cxx | 4 +-- .../iceshard/private/iceshard_frame.cxx | 22 ++++++------ .../iceshard/private/iceshard_runner.hxx | 4 +-- .../private/iceshard_task_executor.cxx | 6 ++-- .../private/iceshard_world_manager.cxx | 2 +- .../private/iceshard_world_tasks_devui.cxx | 10 +++--- .../private/pipeline_ui/ip_ui_oven_page.cxx | 4 +-- .../imgui_module/private/imgui_gfx_stage.cxx | 2 +- .../imgui_module/private/imgui_trait.cxx | 2 +- .../private/widgets/imgui_devui_manager.cxx | 2 +- .../private/widgets/imgui_logger.cxx | 2 +- .../vulkan_renderer/private/vk_device.cxx | 34 +++++++++---------- .../vulkan_renderer/private/vk_driver.cxx | 4 +-- .../asset_system/private/asset_storage.cxx | 6 ++-- .../private/input_action_layer_builder.cxx | 32 ++++++++--------- .../private/input_action_stack.cxx | 18 +++++----- .../input_system/private/input_controller.cxx | 2 +- .../input_system/private/input_keyboard.cxx | 2 +- .../input_system/private/input_mouse.cxx | 2 +- .../private/input_touchscreen.cxx | 2 +- .../public/ice/input/device_event_queue.hxx | 4 +-- .../private/resource_filesystem_traverser.cxx | 4 +-- .../private/resource_provider_custom.cxx | 2 +- .../private/resource_provider_filelist.cxx | 4 +-- .../private/resource_provider_filesystem.cxx | 4 +-- .../private/resource_tracker.cxx | 2 +- .../private/resource_writer_filesystem.cxx | 4 +-- .../tests/test_resource_meta.cxx | 16 ++++----- .../private/asset_compiler_app.cxx | 4 +-- .../asset_compiler_resource_provider.cxx | 4 +-- .../tools/hsc_packer/private/hsc_packer.cxx | 16 ++++----- 46 files changed, 178 insertions(+), 181 deletions(-) diff --git a/source/code/core/tasks/private/task_scoped_container.cxx b/source/code/core/tasks/private/task_scoped_container.cxx index a9aab041..bbee7e40 100644 --- a/source/code/core/tasks/private/task_scoped_container.cxx +++ b/source/code/core/tasks/private/task_scoped_container.cxx @@ -26,17 +26,16 @@ namespace ice ice::ShardID shardid ) noexcept -> ice::Span> { - ice::u32 const new_count = ice::array::count(_tasks) + count; - - if (new_count > ice::array::capacity(_tasks)) + ice::ncount const new_count = _tasks.size() + count; + if (new_count > _tasks.capacity()) { // Updates the capacity of the array to fit the new tasks - ice::array::grow(_tasks, new_count); + _tasks.grow(new_count); } // Creates the tasks and returns a slice to them - ice::array::resize(_tasks, new_count); - return ice::array::slice(_tasks, ice::array::count(_tasks) - count, count); + _tasks.resize(new_count); + return _tasks.tailspan(_tasks.size() - count); } auto ScopedTaskContainer::await_tasks_scheduled_on(ice::TaskScheduler& scheduler, ice::TaskScheduler& resumer) noexcept -> ice::Task<> @@ -46,14 +45,14 @@ namespace ice auto ScopedTaskContainer::execute_tasks() noexcept -> ice::u32 { - ice::u32 const result = ice::array::count(_tasks); + ice::ncount const result = _tasks.size(); if (result > 0) { - _barrier.reset(static_cast(result)); + _barrier.reset(result.u8()); ice::manual_wait_for(_barrier, _tasks); - ice::array::clear(_tasks); + _tasks.clear(); } - return result; + return result.u32(); } auto ScopedTaskContainer::running_tasks() const noexcept -> ice::u32 diff --git a/source/code/core/tasks/private/task_thread_pool_impl.cxx b/source/code/core/tasks/private/task_thread_pool_impl.cxx index 111ed7d4..534aa68c 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.cxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.cxx @@ -107,12 +107,12 @@ namespace ice auto TaskThreadPoolImplementation::thread_count() const noexcept -> ice::u32 { - return ice::array::count(_thread_pool); + return _thread_pool.size().u32(); } auto TaskThreadPoolImplementation::managed_thread_count() const noexcept -> ice::u32 { - return ice::array::count(_managed_threads) + ice::hashmap::count(_created_threads); + return _managed_threads.size().u32() + ice::hashmap::count(_created_threads); } auto TaskThreadPoolImplementation::estimated_task_count() const noexcept -> ice::u32 diff --git a/source/code/core/utils/private/config/config_builder.cxx b/source/code/core/utils/private/config/config_builder.cxx index 6ac9b211..ceae95ce 100644 --- a/source/code/core/utils/private/config/config_builder.cxx +++ b/source/code/core/utils/private/config/config_builder.cxx @@ -196,11 +196,11 @@ namespace ice // Then add all children key-values ice::u32 out_keyidx = 0; - it_entry = ice::array::begin(config._entries); + it_entry = config._entries.begin(); if (config.vtype == CONFIG_VALTYPE_TABLE) { - ice::u32 const table_size = ice::count(config._entries); + ice::u32 const table_size = config._entries.size().u32(); // Save table size in first key out_keylist[0].offset = table_size >> 8; @@ -249,7 +249,7 @@ namespace ice ConfigBuilderContainer& sub = *config._entries[out_keyidx].data.val_container; // Set the value to the current 'keyoffset' value. This serves as the relative offset starting from the passed key. - out_vallist[out_keyidx].internal = ice::array::empty(sub._entries) ? ice::u32_max : keyoffset - out_keyidx; + out_vallist[out_keyidx].internal = sub._entries.is_empty() ? ice::u32_max : keyoffset - out_keyidx; if (out_vallist[out_keyidx].internal != ice::u32_max) { @@ -371,7 +371,7 @@ namespace ice using ice::config::detail::ConfigValue; ice::config::detail::ConfigBuilderContainer& container = *_internal->data.val_container; - if (ice::array::empty(container._entries)) + if (container._entries.is_empty()) { return {}; } diff --git a/source/code/core/utils/private/config/config_builder_utils.cxx b/source/code/core/utils/private/config/config_builder_utils.cxx index 8d40af56..efc806e6 100644 --- a/source/code/core/utils/private/config/config_builder_utils.cxx +++ b/source/code/core/utils/private/config/config_builder_utils.cxx @@ -64,7 +64,7 @@ namespace ice::config::detail ice::config::detail::ConfigBuilderContainer& container = *entry.data.val_container; ice::u32 idx = 0; - for (;idx < ice::count(container._entries); ++idx) + for (;idx < container._entries.size(); ++idx) { ice::String const entry_key = detail::cb_getkey(container._keystrings, container._entries[idx]); if (key == entry_key) @@ -74,9 +74,9 @@ namespace ice::config::detail } ice::config::detail::ConfigBuilderEntry* result; - if (idx < ice::count(container._entries)) + if (idx < container._entries.size()) { - result = ice::array::begin(container._entries) + idx; + result = container._entries.begin() + idx; if (clean) { cb_clear_value_type(alloc, result); @@ -84,7 +84,7 @@ namespace ice::config::detail } else { - idx = ice::count(container._entries); + idx = container._entries.size().u32(); ice::ncount const offset = container._keystrings.size(); container._keystrings.push_back(key); @@ -109,7 +109,7 @@ namespace ice::config::detail ice::config::detail::ConfigBuilderContainer& container = *entry.data.val_container; ice::config::detail::ConfigBuilderEntry* result; - if (idx < ice::count(container._entries)) + if (idx < container._entries.size()) { result = ice::array::begin(container._entries) + idx; if (clean) @@ -121,10 +121,10 @@ namespace ice::config::detail { if (idx == ice::u32_max) { - idx = ice::count(container._entries); + idx = container._entries.size().u32(); } - while(ice::count(container._entries) <= idx) + while(container._entries.size() <= idx) { ice::array::push_back(container._entries, ConfigKey{ 0, CONFIG_KEYTYPE_NONE, CONFIG_VALTYPE_NONE, 0, 0 }); } diff --git a/source/code/core/utils/private/log_internal.cxx b/source/code/core/utils/private/log_internal.cxx index 97cfa018..db95f124 100644 --- a/source/code/core/utils/private/log_internal.cxx +++ b/source/code/core/utils/private/log_internal.cxx @@ -32,7 +32,7 @@ namespace ice::detail auto LogState::register_sink(ice::LogSinkFn fn_sink, void* userdata) noexcept -> ice::LogSinkID { - ice::u32 const sinkidx = ice::count(_sinks); + ice::u32 const sinkidx = _sinks.size().u32(); // Pottentially an error when sinks are added and remove all the time! // NOTE: Once added sinks should only be reset when a module was reloaded! ICE_ASSERT_CORE(sinkidx < 50); @@ -43,7 +43,7 @@ namespace ice::detail void LogState::unregister_sink(ice::LogSinkID sinkid) noexcept { ice::u32 const sinkidx = static_cast(sinkid); - if (ice::count(_sinks) > sinkidx) + if (_sinks.size() > sinkidx) { // Just clear the values _sinks[sinkidx] = Sink{ nullptr, nullptr }; diff --git a/source/code/core/utils/private/params.cxx b/source/code/core/utils/private/params.cxx index 42110f1a..64c66db5 100644 --- a/source/code/core/utils/private/params.cxx +++ b/source/code/core/utils/private/params.cxx @@ -392,7 +392,7 @@ namespace ice while (it != end && valid) { std::string_view const result{ *it }; - if (ice::count(ice_results) == result_count || result.empty()) + if (ice_results.size() == result_count || result.empty()) { valid &= ice_callback(ice_userdata, ice_results); ice::array::clear(ice_results); diff --git a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx index 2c276d7e..3d75a542 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx @@ -167,7 +167,7 @@ namespace ice::ecs auto ArchetypeIndex::registered_archetype_count() const noexcept -> ice::u32 { - return ice::array::count(_archetype_data); + return _archetype_data.size().u32(); } auto ArchetypeIndex::register_archetype( @@ -296,7 +296,7 @@ namespace ice::ecs } } - ice::u32 const archetype_index = ice::array::count(_archetype_data); + ice::u32 const archetype_index = _archetype_data.size().u32(); data_header->archetype_info.archetype_instance = ice::ecs::detail::ArchetypeInstance{ archetype_index }; ice::array::push_back(_archetype_data, data_header); @@ -315,7 +315,7 @@ namespace ice::ecs ice::String name ) const noexcept -> ice::ecs::Archetype { - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 const instance_idx = ice::hashmap::get(_archetype_names_index, ice::hash(name), ice::u32_max); if (instance_idx >= instance_count) { @@ -393,7 +393,7 @@ namespace ice::ecs "Archetype instance fetch called with different input and output array sizes." ); - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 archetype_idx = 0; for (Archetype archetype : archetypes) @@ -421,7 +421,7 @@ namespace ice::ecs "Archetype instance fetch called with different input and output array sizes." ); - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 archetype_idx = 0; for (ice::ecs::detail::ArchetypeInstance archetype_instance : archetype_instances) @@ -443,7 +443,7 @@ namespace ice::ecs ice::ecs::detail::ArchetypeInstanceInfo const*& out_instance_info ) const noexcept { - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 const instance_idx = index; if (instance_idx < instance_count) @@ -464,7 +464,7 @@ namespace ice::ecs ice::ecs::detail::DataBlockPool*& out_block_pool ) const noexcept { - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 const instance_idx = ice::hashmap::get(_archetype_index, ice::hash(archetype), ice::u32_max); if (instance_idx < instance_count) @@ -486,7 +486,7 @@ namespace ice::ecs ice::ecs::detail::DataBlockPool*& out_block_pool ) const noexcept { - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 const instance_idx = static_cast(archetype_instance); if (instance_idx < instance_count) diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx index 49fc8baa..c4239ac9 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx @@ -56,7 +56,7 @@ namespace ice::ecs auto EntityIndex::count() const noexcept -> ice::u32 { - return ice::array::count(_generation) - ice::queue::count(_free_indices); + return _generation.size().u32() - ice::queue::count(_free_indices); } bool EntityIndex::is_alive(ice::ecs::Entity entity) const noexcept @@ -64,12 +64,12 @@ namespace ice::ecs using ice::ecs::EntityInfo; EntityInfo const info = ice::ecs::entity_info(entity); - return ice::count(_generation) > info.index && _generation[info.index] == info.generation; + return _generation.size() > info.index && _generation[info.index] == info.generation; } auto EntityIndex::create() noexcept -> ice::ecs::Entity { - ice::u32 index = 0; + ice::nindex index = 0; if (ice::queue::count(_free_indices) >= ice::ecs::Constant_MinimumFreeIndicesBeforeReuse) { @@ -78,11 +78,11 @@ namespace ice::ecs } else { - index = ice::array::count(_generation); + index = _generation.size(); ice::array::push_back(_generation, ice::u8{ 0 }); } - return ice::ecs::detail::make_entity(index, _generation[index]); + return ice::ecs::detail::make_entity(index.u32(), _generation[index]); } bool EntityIndex::create_many(ice::Span out_entities) noexcept @@ -109,7 +109,7 @@ namespace ice::ecs total_indices_taken += indices_taken; } - ice::u32 gen_index = ice::array::count(_generation); + ice::u32 gen_index = _generation.size().u32(); ice::u32 const missing_entities = out_entities.size().u32() - total_indices_taken; ice::u32 const final_index = gen_index + missing_entities; @@ -120,7 +120,7 @@ namespace ice::ecs "Moved past the maximum allowed number of entities!" ); - ice::array::resize(_generation, final_index); + _generation.resize(final_index); } while (gen_index < final_index) diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx index 845fdbb9..d57d4b3b 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx @@ -621,7 +621,7 @@ namespace ice::ecs using ice::ecs::detail::DataBlock; using ice::ecs::detail::ArchetypeInstance; - ice::u32 const existing_count = ice::count(_head_blocks); + ice::u32 const existing_count = _head_blocks.size().u32(); ice::u32 const archetype_count = _archetype_index.registered_archetype_count(); if (existing_count >= archetype_count) { @@ -711,9 +711,9 @@ namespace ice::ecs // [Done] Set Component: {EntityHandle[*], None} // remove // Ensure we have enough data slots - if (ice::array::count(_data_slots) < _entity_index.count()) + if (_data_slots.size() < _entity_index.count()) { - ice::array::resize(_data_slots, _entity_index.count()); + _data_slots.resize(_entity_index.count()); } // Ensure all queries are finished @@ -1156,21 +1156,21 @@ namespace ice::ecs ice::array::reserve(archetypes, (u32) ice::mem_max_capacity(archetypes_alloc.Constant_InternalCapacity)); _archetype_index.find_archetypes(archetypes, query_info, query_tags); - ice::u32 const prev_archetype_count = ice::count(out_instance_infos); - ice::u32 const new_archetype_count = ice::count(archetypes); - ice::array::resize(out_instance_infos, prev_archetype_count + new_archetype_count); - ice::array::reserve(out_data_blocks, prev_archetype_count + new_archetype_count); + ice::ncount const prev_archetype_count = out_instance_infos.size(); + ice::ncount const new_archetype_count = archetypes.size(); + out_instance_infos.resize(prev_archetype_count + new_archetype_count); + out_data_blocks.reserve(prev_archetype_count + new_archetype_count); - _archetype_index.fetch_archetype_instance_infos(archetypes, ice::array::slice(out_instance_infos, prev_archetype_count)); + _archetype_index.fetch_archetype_instance_infos(archetypes, out_instance_infos.tailspan(prev_archetype_count)); - for (ice::ecs::detail::ArchetypeInstanceInfo const* instance : ice::array::slice(out_instance_infos, prev_archetype_count)) + for (ice::ecs::detail::ArchetypeInstanceInfo const* instance : out_instance_infos.tailspan(prev_archetype_count)) { ice::u32 const instance_idx = static_cast(instance->archetype_instance); ice::array::push_back(out_data_blocks, _data_blocks[instance_idx]); } // Find or create work trackers for queried components - ice::u32 idx = prev_archetype_count; + ice::nindex idx = prev_archetype_count; for (ice::ecs::detail::QueryTypeInfo const& type_info : query_info) { ice::ecs::QueryAccessTracker* tracker = ice::hashmap::get(_access_trackers, ice::hash(type_info.identifier), nullptr); diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index 05e51a89..93371897 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -49,7 +49,7 @@ namespace ice ice::multi_hashmap::insert( _current_state_index, ice::hash(params.initial.graph.value), - ice::count(_current_state) + _current_state.size().u32() ); ice::array::push_back(_current_state, initial_state); } @@ -71,7 +71,7 @@ namespace ice ice::multi_hashmap::insert( _current_state_index, ice::hash(params.initial.graph.value), - ice::count(_current_state) + _current_state.size().u32() ); ice::array::push_back(_current_state, initial_state); } @@ -115,7 +115,7 @@ namespace ice ice::multi_hashmap::insert( _current_state_index, ice::hash(engine_state.graph.value), - ice::count(_current_state) + _current_state.size().u32() ); ice::array::push_back(_current_state, engine_state); } diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx index 614e315f..048d7f2f 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx @@ -36,7 +36,7 @@ namespace ice::gfx .name = stage.name }; - ice::u32 offset = ice::array::count(out_resources); + ice::u32 offset = out_resources.size().u32(); for (ice::gfx::GfxResource res : stage.depth_stencil) { ice::array::push_back(out_resources, res); @@ -205,7 +205,7 @@ namespace ice::gfx _framebuffers ); - ice::array::resize(_clears, ice::count(_resources)); + _clears.resize(_resources.size()); for (vec4f& ccolor : _clears) { ccolor = vec4f{ 0.2f }; @@ -265,7 +265,7 @@ namespace ice::gfx ice::Array temp_stages{ _allocator }; if (stage_registry.query_stages(_stages._stage_names, temp_stages)) { - for (ice::u32 idx = 0; idx < ice::count(_stages._stage_names); ++idx) + for (ice::u32 idx = 0; idx < _stages._stage_names.size(); ++idx) { ice::u64 const stage_hash = ice::hash(_stages._stage_names[idx]); GfxStage* stage_ptr = temp_stages[idx]; diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx index be5b011f..5725895d 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx @@ -63,7 +63,7 @@ namespace ice::gfx ICE_ASSERT_CORE(prev.event != GfxSnapshotEvent::EventInvalid || next.event != GfxSnapshotEvent::EventInvalid); if (prev.event != GfxSnapshotEvent::EventInvalid) { - current.info = ice::array::count(out_barriers); + current.info = out_barriers.size().u32(); if (current.event & GfxSnapshotEvent::EventReadRes) { diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx index 4a58ad0d..766afedb 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx @@ -599,12 +599,12 @@ namespace ice::ecs void* helper_pointer_array[component_count]{ nullptr }; - ice::u32 const arch_count = ice::count(query.archetype_instances); + ice::u32 const arch_count = query.archetype_instances.size().u32(); for (ice::u32 arch_idx = 0; arch_idx < arch_count; ++arch_idx) { ice::ecs::detail::ArchetypeInstanceInfo const* arch = query.archetype_instances[arch_idx]; ice::ecs::detail::DataBlock const* block = query.archetype_data_blocks[arch_idx]; - ice::Span make_argument_idx_map = ice::array::slice(query.archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = query.archetype_argument_idx_map.subspan(arch_idx * component_count, component_count); // We skip the first block because it will be always empty. ICE_ASSERT_CORE(block->block_entity_count == 0); diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx index 826bbe4a..6ad5e5a3 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx @@ -79,7 +79,7 @@ namespace ice::ecs { using Part = ice::ecs::detail::QueryObjectPart; - ice::u32 const prev_arch_count = ice::count(out_instance_infos); + ice::u32 const prev_arch_count = out_instance_infos.size().u32(); this->query_internal( ice::make_span(Part::Definition::Constant_Requirements), @@ -89,14 +89,14 @@ namespace ice::ecs out_data_blocks ); - ice::u32 const new_arch_count = ice::count(out_instance_infos); + ice::u32 const new_arch_count = out_instance_infos.size().u32(); out_archetype_count = new_arch_count - prev_arch_count; - ice::u32 const prev_arim_count = ice::count(out_argument_idx_map); - ice::array::resize(out_argument_idx_map, prev_arim_count + out_archetype_count * Part::ComponentCount); + ice::u32 const prev_arim_count = out_argument_idx_map.size().u32(); + out_argument_idx_map.resize(prev_arim_count + out_archetype_count * Part::ComponentCount); // Copy values to the array - ice::u32* it = ice::array::begin(out_argument_idx_map) + prev_arim_count; + ice::u32* it = out_argument_idx_map.begin() + prev_arim_count; for (ice::ecs::detail::ArchetypeInstanceInfo const* instance : ice::array::slice(out_instance_infos, prev_arch_count)) { auto const archetype_argument_idx_map = ice::ecs::detail::make_argument_idx_map(*instance); diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx index b67811e1..c3067389 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx @@ -168,7 +168,7 @@ namespace ice::gfx auto find_queue_index = [](auto const& array_, QueueID id_, ice::u32& idx_out) noexcept -> bool { - ice::u32 const size = ice::array::count(array_); + ice::u32 const size = array_.size().u32(); idx_out = 0; while (idx_out < size && array_[idx_out].id != id_) @@ -176,7 +176,7 @@ namespace ice::gfx idx_out += 1; } - return ice::array::count(array_) > idx_out; + return array_.size() > idx_out; }; ice::HashMap queue_index_tracker{ alloc }; diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx index 25885792..e2e1a8c6 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx @@ -84,12 +84,12 @@ namespace ice::gfx ice::Array& cmds = (type == CommandBufferType::Primary) ? _primary : _secondary; ice::u32& used = _cmd_buffers_used[static_cast(type)]; - ice::u32 const available = ice::array::count(cmds) - used; + ice::u32 const available = cmds.size().u32() - used; ice::u32 const required = out_buffers.size().u32(); if (available < required) { - ice::array::resize(cmds, used + required); + cmds.resize(used + required); _render_queue->allocate_buffers(_queue_pool_index, type, ice::array::slice(cmds, used)); } diff --git a/source/code/iceshard/iceshard/private/iceshard_frame.cxx b/source/code/iceshard/iceshard/private/iceshard_frame.cxx index 5cd61750..f5d81817 100644 --- a/source/code/iceshard/iceshard/private/iceshard_frame.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_frame.cxx @@ -20,7 +20,7 @@ namespace ice } , _task_groups{ _frame_data._fwd_allocator } { - ice::array::reserve(_task_groups, 32); + _task_groups.reserve(32); } IceshardEngineFrame::~IceshardEngineFrame() noexcept @@ -30,7 +30,7 @@ namespace ice ICE_ASSERT_CORE(group.barrier->is_set() == true); _frame_data._fwd_allocator.deallocate(group.barrier); } - ice::array::clear(_task_groups); + _task_groups.clear(); ice::hashmap::clear(_data._values); _frame_data._fwd_allocator.reset(); @@ -51,8 +51,8 @@ namespace ice .barrier = _frame_data._fwd_allocator.create() } ); - ice::Array>& result = ice::array::back(_task_groups).tasks; - ice::array::resize(result, count); + ice::Array>& result = _task_groups.last().tasks; + result.resize(count); return result; } @@ -61,13 +61,13 @@ namespace ice ice::u32 task_count = 0; for (TaskGroup& group : _task_groups) { - task_count += ice::count(group.tasks); + task_count += group.tasks.size().u32(); } if (task_count > 0) { ice::Array> final_task_list{ _frame_data._fwd_allocator }; - ice::array::reserve(final_task_list, task_count); + final_task_list.reserve(task_count); for (TaskGroup& group : _task_groups) { @@ -75,7 +75,7 @@ namespace ice { ice::array::push_back(final_task_list, ice::move(task)); } - ice::array::clear(group.tasks); + group.tasks.clear(); } co_await ice::await_scheduled_on(final_task_list, scheduler, resumer); @@ -87,18 +87,18 @@ namespace ice ice::u32 total_count = 0; for (TaskGroup& group : _task_groups) { - ice::u32 const current_count = ice::count(group.tasks); + ice::u32 const current_count = group.tasks.size().u32(); // Only reset the barrier if we actual have tasks to execute. if (current_count > 0) { total_count += current_count; - ICE_ASSERT_CORE(ice::count(group.tasks) < ice::u8_max); + ICE_ASSERT_CORE(group.tasks.size() < ice::u8_max); - group.barrier->reset(ice::u8(ice::count(group.tasks))); + group.barrier->reset(group.tasks.size().u8()); ice::manual_wait_for(*group.barrier, group.tasks); - ice::array::clear(group.tasks); + group.tasks.clear(); } } return total_count; diff --git a/source/code/iceshard/iceshard/private/iceshard_runner.hxx b/source/code/iceshard/iceshard/private/iceshard_runner.hxx index cd0eedb2..44004a4e 100644 --- a/source/code/iceshard/iceshard/private/iceshard_runner.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_runner.hxx @@ -111,8 +111,8 @@ namespace ice void execute_all() noexcept { - ice::u32 const num_tasks = ice::array::count(_pending_tasks); - _running_tasks.fetch_add(num_tasks, std::memory_order_relaxed); + ice::ncount const num_tasks = _pending_tasks.size(); + _running_tasks.fetch_add(num_tasks.u32(), std::memory_order_relaxed); for (ice::Task<>& pending_task : _pending_tasks) { diff --git a/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx b/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx index a0ae6b8a..03b90253 100644 --- a/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx @@ -14,7 +14,7 @@ namespace ice IceshardTaskExecutor::TaskList tasks ) noexcept : _allocator{ alloc } - , _task_count{ ice::count(tasks) } + , _task_count{ tasks.size().u32() } , _tasks{ ice::move(tasks) } , _sync_sem{ 0 } { @@ -55,10 +55,10 @@ namespace ice void IceshardTaskExecutor::wait_ready() noexcept { - if (ice::array::any(_tasks)) + if (_tasks.not_empty()) { _sync_sem.wait(); - ice::array::clear(_tasks); + _tasks.clear(); } } diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx index e23834af..f9c3684c 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx @@ -120,7 +120,7 @@ namespace ice if (desc != nullptr) { ice::UniquePtr trait_context = ice::make_unique( - world_context->allocator(), *world_context.get(), ice::array::count(world_traits) + world_context->allocator(), *world_context.get(), world_traits.size().u32() ); ice::UniquePtr trait = desc->fn_factory(world_context->allocator(), *trait_context.get(), desc->fn_factory_userdata); if (trait != nullptr) diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx index 4513175b..e4b5f14b 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx @@ -23,7 +23,7 @@ namespace ice auto TraitTasksTrackerDevUI::report_resume(ice::u32 id) noexcept -> ice::u32 { ice::u32 const eventidx = _current_event_count.fetch_add(1, std::memory_order_relaxed); - if (eventidx >= ice::count(_tracked_task_events)) + if (eventidx >= _tracked_task_events.size()) { return 0; } @@ -45,7 +45,7 @@ namespace ice void TraitTasksTrackerDevUI::report_finish(ice::u32 id) noexcept { ice::u32 const eventidx = _current_event_count.fetch_add(1, std::memory_order_relaxed); - if (eventidx >= ice::count(_tracked_task_events)) + if (eventidx >= _tracked_task_events.size()) { return; } @@ -60,7 +60,7 @@ namespace ice void TraitTasksTrackerDevUI::update_state(ice::DevUIWidgetState &state) noexcept { _stat_events = _current_event_count.exchange(1, std::memory_order_relaxed); - if (_stat_events >= ice::count(_tracked_task_events)) + if (_stat_events >= _tracked_task_events.size()) { ice::array::grow(_tracked_task_events, _stat_events); ice::array::resize(_tracked_task_events, _stat_events); @@ -82,7 +82,7 @@ namespace ice snapshot._release = false; ice::array::clear(snapshot._events); } - else if (ice::array::any(snapshot._events)) + else if (snapshot._events.not_empty()) { snapshot.draw(); } @@ -97,7 +97,7 @@ namespace ice ImVec2 const region = ImGui::GetWindowContentRegionMax(); ice::u32 first_entry = 1; - ice::u32 const last_entry = ice::count(_events); + ice::u32 const last_entry = _events.size().u32(); EventEntry const* entries = ice::begin(_events); ice::u32 running = 0; diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx index b5a5bad3..634cc42c 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx @@ -277,9 +277,7 @@ namespace ice ice::Array& elements ) noexcept { - ice::u16 const element_index = static_cast( - ice::array::count(elements) - ); + ice::u16 const element_index = elements.size().u16(); ice::array::push_back( elements, diff --git a/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx b/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx index acc017dd..0cdfb47e 100644 --- a/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx +++ b/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx @@ -236,7 +236,7 @@ namespace ice::devui using namespace ice::render; ImDrawData* draw_data = ImGui::GetDrawData(); - if (draw_data == nullptr || ice::array::empty(draw_commands)) + if (draw_data == nullptr || draw_commands.is_empty()) { return; } diff --git a/source/code/modules/imgui_module/private/imgui_trait.cxx b/source/code/modules/imgui_module/private/imgui_trait.cxx index e62e9095..b1c0869c 100644 --- a/source/code/modules/imgui_module/private/imgui_trait.cxx +++ b/source/code/modules/imgui_module/private/imgui_trait.cxx @@ -530,7 +530,7 @@ namespace ice::devui } ice::array::push_back(out_draw_cmds, ImGuiGfxStage::DrawCommand{}); - ImGuiGfxStage::DrawCommand& cmd = ice::array::back(out_draw_cmds); + ImGuiGfxStage::DrawCommand& cmd = out_draw_cmds.last(); cmd.resource_set_idx = curr_resource_idx; ImVec4 clip_rect; diff --git a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx index 5ec6ee0b..05cded45 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx @@ -63,7 +63,7 @@ namespace ice::devui { // TODO: ice::array::remove_at - ice::u32 const count = ice::array::count(_widgets); + ice::u32 const count = _widgets.size().u32(); if (count == 0) { return; diff --git a/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx b/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx index bc909e7c..e21c36ee 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx @@ -78,7 +78,7 @@ namespace ice::devui void ImGuiLogger::add_entry(ice::LogSinkMessage const& message) noexcept { std::lock_guard lk{ mtx }; - ice::array::push_back(_entries_visible, ice::array::count(_entries)); + ice::array::push_back(_entries_visible, _entries.size().u32()); ice::array::push_back(_entries, { message.severity, message.tag, message.tag_name, {LoggerAlloc,message.message} }); } diff --git a/source/code/modules/vulkan_renderer/private/vk_device.cxx b/source/code/modules/vulkan_renderer/private/vk_device.cxx index fd57cf99..0363cbaf 100644 --- a/source/code/modules/vulkan_renderer/private/vk_device.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_device.cxx @@ -102,7 +102,7 @@ namespace ice::render::vk ); ICE_ASSERT( - ice::array::empty(surface_formats) == false, + surface_formats.not_empty(), "No supported image formats found for given surface!" ); @@ -118,7 +118,7 @@ namespace ice::render::vk "Failed to query surface capabilities!" ); - VkSurfaceFormatKHR selected_format = ice::array::front(surface_formats); + VkSurfaceFormatKHR selected_format = surface_formats.first(); if constexpr (ice::build::is_linux) { // If possible select UNORM istead of SRGB @@ -259,7 +259,7 @@ namespace ice::render::vk auto store_references = [&attachment_references](ice::Span references) noexcept -> ice::u32 { - ice::u32 ref_index = ice::count(attachment_references); + ice::u32 ref_index = attachment_references.size().u32(); for (AttachmentReference const& attachment_ref : references) { VkAttachmentReference reference{ }; // VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2 }; @@ -312,12 +312,12 @@ namespace ice::render::vk } VkRenderPassCreateInfo renderpass_info{ VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO }; - renderpass_info.attachmentCount = ice::array::count(attachments); - renderpass_info.pAttachments = ice::array::begin(attachments); - renderpass_info.subpassCount = ice::array::count(subpass_list); - renderpass_info.pSubpasses = ice::array::begin(subpass_list); - renderpass_info.dependencyCount = ice::array::count(dependencies); - renderpass_info.pDependencies = ice::array::begin(dependencies); + renderpass_info.attachmentCount = attachments.size().u32(); + renderpass_info.pAttachments = attachments.begin(); + renderpass_info.subpassCount = subpass_list.size().u32(); + renderpass_info.pSubpasses = subpass_list.begin(); + renderpass_info.dependencyCount = dependencies.size().u32(); + renderpass_info.pDependencies = dependencies.begin(); VkRenderPass renderpass; VkResult result = vkCreateRenderPass(_vk_device, &renderpass_info, nullptr, &renderpass); @@ -537,8 +537,8 @@ namespace ice::render::vk vkUpdateDescriptorSets( _vk_device, - ice::count(vk_writes), - ice::begin(vk_writes), + vk_writes.size().u32(), + vk_writes.begin(), 0, nullptr ); } @@ -718,10 +718,10 @@ namespace ice::render::vk } VkPipelineVertexInputStateCreateInfo vertex_input{ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO }; - vertex_input.vertexBindingDescriptionCount = ice::array::count(vertex_input_bindings); - vertex_input.pVertexBindingDescriptions = ice::array::begin(vertex_input_bindings); - vertex_input.vertexAttributeDescriptionCount = ice::array::count(vertex_input_attributes); - vertex_input.pVertexAttributeDescriptions = ice::array::begin(vertex_input_attributes); + vertex_input.vertexBindingDescriptionCount = vertex_input_bindings.size().u32(); + vertex_input.pVertexBindingDescriptions = vertex_input_bindings.begin(); + vertex_input.vertexAttributeDescriptionCount= vertex_input_attributes.size().u32(); + vertex_input.pVertexAttributeDescriptions = vertex_input_attributes.begin(); VkPipelineInputAssemblyStateCreateInfo input_assembly{ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO }; input_assembly.primitiveRestartEnable = VK_FALSE; @@ -967,8 +967,8 @@ namespace ice::render::vk VkFramebufferCreateInfo fb_info{ VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO }; fb_info.renderPass = vk_renderpass; - fb_info.attachmentCount = ice::array::count(vk_images); - fb_info.pAttachments = ice::array::begin(vk_images); + fb_info.attachmentCount = vk_images.size().u32(); + fb_info.pAttachments = vk_images.begin(); fb_info.width = extent.x; fb_info.height = extent.y; fb_info.layers = 1; diff --git a/source/code/modules/vulkan_renderer/private/vk_driver.cxx b/source/code/modules/vulkan_renderer/private/vk_driver.cxx index 6120b6d4..9dbeee78 100644 --- a/source/code/modules/vulkan_renderer/private/vk_driver.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_driver.cxx @@ -103,7 +103,7 @@ namespace ice::render::vk if (enumerate_objects(_vk_queue_family_properties, vkGetPhysicalDeviceQueueFamilyProperties, _vk_physical_device)) { - VK_LOG(ice::LogSeverity::Debug, "Device has {} queue families", count(_vk_queue_family_properties)); + VK_LOG(ice::LogSeverity::Debug, "Device has {} queue families", _vk_queue_family_properties.size()); } } @@ -389,7 +389,7 @@ namespace ice::render::vk device_create_info.enabledExtensionCount = count_extensions; device_create_info.ppEnabledExtensionNames = ice::array::begin(extension_names); device_create_info.pQueueCreateInfos = ice::array::begin(queue_create_infos); - device_create_info.queueCreateInfoCount = ice::array::count(queue_create_infos); + device_create_info.queueCreateInfoCount = queue_create_infos.size().u32(); VkDevice vk_device; VkResult result = vkCreateDevice( diff --git a/source/code/systems/asset_system/private/asset_storage.cxx b/source/code/systems/asset_system/private/asset_storage.cxx index f3ab4d26..15e1c5c0 100644 --- a/source/code/systems/asset_system/private/asset_storage.cxx +++ b/source/code/systems/asset_system/private/asset_storage.cxx @@ -91,13 +91,13 @@ namespace ice } // If empty we add our own handle to the list - if (ice::array::empty(sources)) + if (sources.is_empty()) { ice::array::push_back(sources, resource); } ice::Array> tasks{ alloc }; - ice::array::reserve(tasks, ice::array::count(sources)); + ice::array::reserve(tasks, sources.size()); auto fn_validate = [&ctx]( ice::ResourceCompiler const& compiler, @@ -130,7 +130,7 @@ namespace ice } ice::Array compiled_sources{ alloc }; - ice::array::resize(compiled_sources, ice::array::count(sources)); + compiled_sources.resize(sources.size()); auto fn_compile = [&ctx]( ice::ResourceCompiler const& compiler, diff --git a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx index 88d40b54..f092f9f4 100644 --- a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx @@ -131,7 +131,7 @@ namespace ice void add_step(ActionBuilderStep&& step) noexcept { ice::array::push_back( - ice::array::back(conditions).steps, + conditions.last().steps, ice::move(step) ); } @@ -143,7 +143,7 @@ namespace ice void finalize() noexcept { - ActionBuilderCondition& final_condition = ice::array::back(conditions); + ActionBuilderCondition& final_condition = conditions.last(); // Ensure this series is finished after this condition. final_condition.flags |= InputActionConditionFlags::SeriesFinish; @@ -182,7 +182,7 @@ namespace ice auto add_condition_series() noexcept -> InputActionBuilder::ConditionSeries { ice::array::push_back(cond_series, Internal{ allocator }); - Internal* const series_ptr = ice::addressof(ice::array::back(cond_series)); + Internal* const series_ptr = ice::addressof(cond_series.last()); return { series_ptr }; } @@ -328,7 +328,7 @@ namespace ice idx_found ); - ICE_ASSERT_CORE(found && idx_found < ice::array::count(final_sources)); + ICE_ASSERT_CORE(found && idx_found < final_sources.size()); ice::u16 const source_storage_idx = final_sources[idx_found].storage_offset; return source_storage_idx; }; @@ -349,7 +349,7 @@ namespace ice idx_found ); - ICE_ASSERT_CORE(found && idx_found < ice::array::count(final_actions)); + ICE_ASSERT_CORE(found && idx_found < final_actions.size()); return ice::u16(idx_found); }; @@ -437,7 +437,7 @@ namespace ice } } // for (ConditionSeries& series : ...) - modifier_count = ice::u8(ice::count(action.modifiers)); + modifier_count = action.modifiers.size().u8(); ice::array::push_back(final_modifiers, action.modifiers); ice::array::push_back(final_actions, @@ -460,19 +460,19 @@ namespace ice ice::Array final_constants{ alloc }; for (auto [constant, value] : _constants) { - ice::u8 const offset = (ice::u8) ice::count(final_constant_values); + ice::u8 const offset = final_constant_values.size().u8(); ice::array::push_back(final_constants, { .identifier = constant, .offset = offset }); ice::array::push_back(final_constant_values, value); } ice::InputActionLayerInfoHeader final_info{ .size_name = _name.size().u8(), - .count_constants = ice::u8(ice::count(final_constants)), - .count_sources = ice::u16(ice::count(final_sources)), - .count_actions = ice::u16(ice::count(final_actions)), - .count_conditions = ice::u16(ice::count(final_conditions)), - .count_steps = ice::u16(ice::count(final_steps)), - .count_modifiers = ice::u16(ice::count(final_modifiers)), + .count_constants = final_constants.size().u8(), + .count_sources = final_sources.size().u16(), + .count_actions = final_actions.size().u16(), + .count_conditions = final_conditions.size().u16(), + .count_steps = final_steps.size().u16(), + .count_modifiers = final_modifiers.size().u16(), .offset_strings = 0, }; @@ -483,7 +483,7 @@ namespace ice ice::usize const offset_conditions = minfo_layer += ice::array::meminfo(final_conditions); ice::usize const offset_steps = minfo_layer += ice::array::meminfo(final_steps); ice::usize const offset_modifiers = minfo_layer += ice::array::meminfo(final_modifiers); - ice::usize const offset_constant_values = minfo_layer += ice::meminfo_of * ice::count(final_constant_values); + ice::usize const offset_constant_values = minfo_layer += ice::meminfo_of * final_constant_values.size(); ice::usize const offset_constants = minfo_layer += ice::array::meminfo(final_constants); ice::usize const offset_strings = minfo_layer += strings.meminfo(); final_info.offset_strings = ice::u32(offset_strings.value); @@ -592,11 +592,11 @@ namespace ice { if (can_finalize_condition_checks) { - ice::array::back(internal().conditions).flags |= InputActionConditionFlags::Final; + internal().conditions.last().flags |= InputActionConditionFlags::Final; } else { - ice::array::back(internal().conditions).flags |= InputActionConditionFlags::SeriesFinish; + internal().conditions.last().flags |= InputActionConditionFlags::SeriesFinish; } } diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index 61bdca6e..065a6665 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -140,7 +140,7 @@ namespace ice { ice::array::push_back(out_layers, layer.layer); } - return ice::count(_layers); + return _layers.size().u32(); } auto SimpleInputActionStack::register_layer( @@ -159,12 +159,12 @@ namespace ice return S_LayerAlreadyRegistered; } - layer_idx = ice::count(_layers); + layer_idx = _layers.size().u32(); // We reserve enough space to store all actual indices for accessed layer sources. - ice::u32 const layer_sources_count = layer->sources().size().u32(); - ice::u32 const layer_sources_offset = ice::count(_layers_sources_indices); - ice::array::reserve(_layers_sources_indices, layer_sources_offset + layer_sources_count); + ice::ncount const layer_sources_count = layer->sources().size().u32(); + ice::ncount const layer_sources_offset = _layers_sources_indices.size(); + _layers_sources_indices.reserve(layer_sources_offset + layer_sources_count); // Go through each resource and set the indices ice::u64 prev_name_hash = 0; @@ -197,7 +197,7 @@ namespace ice } else { - values_index = ice::array::count(_sources_runtime_values); + values_index = _sources_runtime_values.size().u32(); ice::array::push_back(_sources_runtime_values, InputActionSource{}); // If we have an Axis2d source, we need to actually push back two values for both axis @@ -247,7 +247,7 @@ namespace ice // Stores the layer along with a ref where it's indices for all sources are stored. ice::array::push_back( _layers, - StackLayer{ layer, { ice::u16(layer_sources_offset), ice::u16(ice::count(_layers_sources_indices) - layer_sources_offset) } } + StackLayer{ layer, { layer_sources_offset.u16(), (_layers_sources_indices.size() - layer_sources_offset).u16() } } ); return S_Ok; } @@ -264,7 +264,7 @@ namespace ice ice::array::push_back(out_layers, _layers[it->index].layer); it += 1; } - return ice::count(_layers_active); + return _layers_active.size().u32(); } void SimpleInputActionStack::push_layer( @@ -279,7 +279,7 @@ namespace ice } // Check if we are already at the top of the stack. - if (ice::array::any(_layers_active) && ice::array::back(_layers_active).index == idx) + if (_layers_active.not_empty() && _layers_active.last().index == idx) { return; // #TODO: Implement success with info. } diff --git a/source/code/systems/input_system/private/input_controller.cxx b/source/code/systems/input_system/private/input_controller.cxx index 2b5af9b5..8867d7ba 100644 --- a/source/code/systems/input_system/private/input_controller.cxx +++ b/source/code/systems/input_system/private/input_controller.cxx @@ -110,7 +110,7 @@ namespace ice::input if (input != InputID::Invalid) { ice::u32 const control_index = input_identifier_value(input); - ICE_ASSERT_CORE(control_index < ice::array::count(_controls)); + ICE_ASSERT_CORE(control_index < _controls.size()); detail::ControlState control = _controls[control_index]; control.id = input; diff --git a/source/code/systems/input_system/private/input_keyboard.cxx b/source/code/systems/input_system/private/input_keyboard.cxx index 2bd63e67..85a8b2c7 100644 --- a/source/code/systems/input_system/private/input_keyboard.cxx +++ b/source/code/systems/input_system/private/input_keyboard.cxx @@ -123,7 +123,7 @@ namespace ice::input } ice::u32 const control_index = detail::input_control_index(input); - ICE_ASSERT_CORE(control_index < ice::array::count(_controls)); + ICE_ASSERT_CORE(control_index < _controls.size()); detail::ControlState control = _controls[control_index]; control.id = input; diff --git a/source/code/systems/input_system/private/input_mouse.cxx b/source/code/systems/input_system/private/input_mouse.cxx index d410cc60..3b55e7ec 100644 --- a/source/code/systems/input_system/private/input_mouse.cxx +++ b/source/code/systems/input_system/private/input_mouse.cxx @@ -94,7 +94,7 @@ namespace ice::input if (input != InputID::Invalid) { ice::u32 const control_index = input_identifier_value(input); - ICE_ASSERT_CORE(control_index < ice::array::count(_controls)); + ICE_ASSERT_CORE(control_index < _controls.size()); detail::ControlState control = _controls[control_index]; control.id = input; diff --git a/source/code/systems/input_system/private/input_touchscreen.cxx b/source/code/systems/input_system/private/input_touchscreen.cxx index 88dd11a1..cb864a1b 100644 --- a/source/code/systems/input_system/private/input_touchscreen.cxx +++ b/source/code/systems/input_system/private/input_touchscreen.cxx @@ -135,7 +135,7 @@ namespace ice::input if (input != InputID::Invalid) { ice::u32 const control_index = input_identifier_value(input) + pointer_index; - ICE_ASSERT_CORE(control_index < ice::array::count(_controls)); + ICE_ASSERT_CORE(control_index < _controls.size()); detail::ControlState control = _controls[control_index]; control.id = input; diff --git a/source/code/systems/input_system/public/ice/input/device_event_queue.hxx b/source/code/systems/input_system/public/ice/input/device_event_queue.hxx index 75621472..aaa2829d 100644 --- a/source/code/systems/input_system/public/ice/input/device_event_queue.hxx +++ b/source/code/systems/input_system/public/ice/input/device_event_queue.hxx @@ -46,12 +46,12 @@ namespace ice::input inline bool DeviceEventQueue::empty() const noexcept { - return ice::array::empty(_events); + return _events.is_empty(); } inline void DeviceEventQueue::clear() noexcept { - ice::array::clear(_events); + _events.clear(); } inline void DeviceEventQueue::push( diff --git a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx index 76781f08..ba5a018d 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx @@ -203,7 +203,7 @@ namespace ice { ice::array::push_back(requests, { *this, base_path, remaining, nullptr, nullptr }); ice::native_file::traverse_directories( - base_path, traverse_callback, &ice::array::back(requests) + base_path, traverse_callback, &requests.last() ); } } @@ -226,7 +226,7 @@ namespace ice { ice::array::push_back(requests, { *this, base_path, remaining, ice::addressof(scheduler), &local_sched }); ice::native_file::traverse_directories( - base_path, traverse_callback, &ice::array::back(requests) + base_path, traverse_callback, &requests.last() ); } diff --git a/source/code/systems/resource_system/private/resource_provider_custom.cxx b/source/code/systems/resource_system/private/resource_provider_custom.cxx index 13b93ebf..a0f996c2 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.cxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.cxx @@ -77,7 +77,7 @@ namespace ice { IPT_ZONE_SCOPED; - ice::array::reserve(out_changes, ice::array::count(out_changes) + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { ice::array::push_back(out_changes, resource); diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index 44068419..f76fb74b 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -111,7 +111,7 @@ namespace ice if (resource != nullptr) { - resource->data_index = ice::array::count(_resources_data); + resource->data_index = _resources_data.size().u32(); ice::array::push_back(_resources_data, ice::Memory{}); ice::u64 const hash = ice::hash(resource->uri().path()); @@ -147,7 +147,7 @@ namespace ice { IPT_ZONE_SCOPED; - ice::array::reserve(out_changes, ice::array::count(out_changes) + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { ice::array::push_back(out_changes, resource); diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx index b91ba569..43a467c7 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx @@ -112,7 +112,7 @@ namespace ice { IPT_ZONE_SCOPED; - ice::array::reserve(out_changes, ice::array::count(out_changes) + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { ice::array::push_back(out_changes, resource); @@ -285,7 +285,7 @@ namespace ice ice::FileSystemResource* resource ) noexcept -> ice::Result { - resource->data_index = ice::array::count(_resources_data); + resource->data_index = _resources_data.size().u32(); ice::array::push_back(_resources_data, ice::Memory{}); ice::u64 const hash = ice::hash(resource->origin()); diff --git a/source/code/systems/resource_system/private/resource_tracker.cxx b/source/code/systems/resource_system/private/resource_tracker.cxx index effd05b4..2610b6d7 100644 --- a/source/code/systems/resource_system/private/resource_tracker.cxx +++ b/source/code/systems/resource_system/private/resource_tracker.cxx @@ -346,7 +346,7 @@ namespace ice return; } - ice::u32 const new_count = ice::hashmap::count(_resources) + ice::array::count(out_resources); + ice::u32 const new_count = ice::hashmap::count(_resources) + out_resources.size().u32(); ICE_ASSERT( new_count <= _info.predicted_resource_count, "Maximum resource capacity of {} entiries reached!", diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx index c6303aad..2c4ac486 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx @@ -107,7 +107,7 @@ namespace ice { IPT_ZONE_SCOPED; - ice::array::reserve(out_changes, ice::array::count(out_changes) + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { ice::array::push_back(out_changes, resource); @@ -333,7 +333,7 @@ namespace ice { ice::WritableFileSystemResource* const resource = static_cast(fs_resource); - resource->data_index = ice::array::count(_resources_data); + resource->data_index = _resources_data.size().u32(); ice::array::push_back(_resources_data, ice::Memory{}); ice::u64 const hash = ice::hash(resource->origin()); diff --git a/source/code/systems/resource_system/tests/test_resource_meta.cxx b/source/code/systems/resource_system/tests/test_resource_meta.cxx index e0e64fa5..772b9f27 100644 --- a/source/code/systems/resource_system/tests/test_resource_meta.cxx +++ b/source/code/systems/resource_system/tests/test_resource_meta.cxx @@ -70,14 +70,14 @@ SCENARIO("resource_system 'ice/resource_meta.hxx'", "[resource][metadata]") ice::Array meta_numbers{ alloc }; CHECK(ice::config::get_array(meta, "details.numbers", meta_numbers)); - CHECK(ice::array::count(meta_numbers) == 3); + CHECK(meta_numbers.size() == 3); CHECK(meta_numbers[0] == 1); CHECK(meta_numbers[1] == 2); CHECK(meta_numbers[2] == 3); ice::Array meta_strings{ alloc }; CHECK(ice::config::get_array(meta, "details.strings", meta_strings)); - CHECK(ice::array::count(meta_strings) == 4); + CHECK(meta_strings.size() == 4); CHECK(meta_strings[0] == "The"); CHECK(meta_strings[2] == "brown"); @@ -103,14 +103,14 @@ SCENARIO("resource_system 'ice/resource_meta.hxx'", "[resource][metadata]") ice::Array meta_numbers_2{ alloc }; CHECK(ice::config::get_array(const_meta, "details.numbers", meta_numbers_2)); - CHECK(ice::array::count(meta_numbers_2) == 3); + CHECK(meta_numbers_2.size() == 3); CHECK(meta_numbers_2[0] == 1); CHECK(meta_numbers_2[1] == 2); CHECK(meta_numbers_2[2] == 3); ice::Array meta_strings_2{ alloc }; CHECK(ice::config::get_array(const_meta, "details.strings", meta_strings_2)); - CHECK(ice::array::count(meta_strings_2) == 4); + CHECK(meta_strings_2.size() == 4); CHECK(meta_strings_2[0] == "The"); CHECK(meta_strings_2[2] == "brown"); } @@ -216,10 +216,10 @@ SCENARIO("resource_system 'ice/resource_meta.hxx'", "[resource][metadata]") CHECK(ice::config::get_array(empty_config, "value.float", meta_float_arr) == ice::E_Fail); CHECK(ice::config::get_array(empty_config, "value.string", meta_string_arr) == ice::E_Fail); - CHECK(ice::array::count(meta_bool_arr) == 0); - CHECK(ice::array::count(meta_int32_arr) == 0); - CHECK(ice::array::count(meta_float_arr) == 0); - CHECK(ice::array::count(meta_string_arr) == 0); + CHECK(meta_bool_arr.size() == 0); + CHECK(meta_int32_arr.size() == 0); + CHECK(meta_float_arr.size() == 0); + CHECK(meta_string_arr.size() == 0); } } } diff --git a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx index 21797563..d4fc8700 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx @@ -190,7 +190,7 @@ class AssetCompilerApp : public ice::tool::ToolApp Param_Verbose, ice::LogSeverity::Retail, ice::LogTag::Tool, "Creating asset '{}' from {} sources and {} metadata files.", - input_resource->name(), ice::count(_inputs), ice::count(_inputs_meta) + input_resource->name(), _inputs.size(), _inputs_meta.size() ); ice::HeapString<> uristr{ _allocator, "file://" }; @@ -321,7 +321,7 @@ class AssetCompilerApp : public ice::tool::ToolApp } // If empty we add our own handle to the list - if (ice::array::empty(sources)) + if (sources.is_empty()) { ice::array::push_back(sources, res); } diff --git a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx index e083d825..cee93954 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx @@ -79,8 +79,8 @@ AssetCompilerResourceProvider::AssetCompilerResourceProvider( ice::array::push_back(_resources, res); } - ice::array::resize(_data, ice::count(_resources)); - ice::memset(ice::begin(_data), '\0', ice::array::data_view(_data).size.value); + _data.resize(_resources.size()); + ice::memset(_data.begin(), '\0', _data.size().bytes().value); } AssetCompilerResourceProvider::~AssetCompilerResourceProvider() noexcept diff --git a/source/code/tools/hsc_packer/private/hsc_packer.cxx b/source/code/tools/hsc_packer/private/hsc_packer.cxx index 25e7631b..12d50e10 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer.cxx @@ -162,7 +162,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp for (ice::String ext : extensions) { ice::array::push_back(_filter_extensions_heap, { _allocator, ext }); - ice::array::push_back(_filter_extensions, ice::array::back(_filter_extensions_heap)); + ice::array::push_back(_filter_extensions, _filter_extensions_heap.last()); } } HSCP_ERROR_IF( @@ -176,7 +176,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp } } - if (ice::array::empty(_filter_extensions)) + if (_filter_extensions.is_empty()) { HSCP_ERROR("No valid configuration files where provided."); return 1; @@ -237,8 +237,8 @@ class HailStormPackerApp final : public ice::tool::ToolApp _param_output = hscp_process_directory(_allocator, _param_output); // The paths that will be searched for loose file resources. - ice::Array files{ _allocator, }; - ice::array::reserve(files, ice::count(_inputs)); + ice::Array files{ _allocator }; + files.reserve(_inputs.size()); for (ice::String file : _inputs) { ice::array::push_back(files, { .path = file }); @@ -283,10 +283,10 @@ class HailStormPackerApp final : public ice::tool::ToolApp ice::Array resource_handles{ _allocator }; ice::Array resource_paths{ _allocator }; - ice::array::resize(resource_data, resources.size().u32()); - ice::array::resize(resource_metamap, resources.size().u32()); - ice::array::resize(resource_handles, resources.size().u32()); - ice::array::resize(resource_paths, resources.size().u32()); + resource_data.resize(resources.size()); + resource_metamap.resize(resources.size()); + resource_handles.resize(resources.size()); + resource_paths.resize(resources.size()); // We serialize an empty meta object ice::ConfigBuilder meta{ _allocator }; From e0b9b02e766aab1724f04a72e5c3e0fc1b76e14f Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sat, 10 Jan 2026 14:25:27 +0900 Subject: [PATCH 13/40] #ICE-207 Continued work on the Array type. Almost finished the refactor. #ICE-205 Added 'clear' to the requirements of a 'Resizable' container. In addition, any operations that change the contents are better to be part of the type itself. --- .../core/collections/public/ice/array.hxx | 81 ++++- .../public/ice/container/array.hxx | 63 ---- .../ice/container/container_concepts.hxx | 21 +- .../ice/container/contiguous_container.hxx | 19 +- .../public/ice/container/impl/array_impl.inl | 276 +----------------- .../ice/container/resizable_container.hxx | 14 +- .../core/collections/tests/test_array.cxx | 20 +- 7 files changed, 124 insertions(+), 370 deletions(-) diff --git a/source/code/core/collections/public/ice/array.hxx b/source/code/core/collections/public/ice/array.hxx index f38430e6..ee8c08af 100644 --- a/source/code/core/collections/public/ice/array.hxx +++ b/source/code/core/collections/public/ice/array.hxx @@ -13,7 +13,9 @@ namespace ice //! \tparam Logic The logic used during memory operations for the given type. //! This value cab be set by the user to enforce expected behavior for stored types. template> - struct Array : public ice::container::ContiguousContainer, public ice::container::ResizableContainer + struct Array + : public ice::container::ContiguousContainer + , public ice::container::ResizableContainer { static_assert( Logic == ContainerLogic::Complex || ice::TrivialContainerLogicAllowed, @@ -51,8 +53,14 @@ namespace ice // API Requirements Of: Resizable Container constexpr auto capacity() const noexcept -> ice::ncount { return { _capacity, sizeof(ValueType) }; } - constexpr void resize(ice::ncount new_capacity) noexcept; constexpr void set_capacity(ice::ncount new_capacity) noexcept; + constexpr void resize(ice::ncount new_size) noexcept; + constexpr void clear() noexcept; + + // API Manipulation + template + requires std::convertible_to && std::is_constructible_v + inline void push_back(ItemType&& item) noexcept; // API Requirements Of: Data and Memory constexpr auto data_view(this Array const& self) noexcept -> ice::Data; @@ -279,15 +287,10 @@ namespace ice ice::ncount const missing_items = new_size - _count; ice::Memory const uninitialized_memory = ice::ptr_add(memory_view(), size()); - // Even for trivial logic we construct items so at least the default ctor is called. - ICE_ASSERT_CORE(std::is_default_constructible_v); - if constexpr (std::is_default_constructible_v) - { - ice::mem_construct_n_at( - uninitialized_memory, - missing_items - ); - } + ice::mem_construct_n_at( + uninitialized_memory, + missing_items + ); } else if constexpr (Logic == ContainerLogic::Complex) { @@ -303,6 +306,62 @@ namespace ice _count = new_size.u32(); } + template + inline constexpr void ice::Array::clear() noexcept + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_destruct_n_at(_data, _count); + } + _count = 0; + } + + template + template + requires std::convertible_to && std::is_constructible_v + inline void Array::push_back(ItemType&& item) noexcept + { + if (size() == capacity()) + { + this->grow(); + } + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_construct_at(this->end(), ice::forward(item)); + } + else + { + _data[_count] = Type{ ice::forward(item) }; + } + + _count += 1; + } + + //template + // requires std::copy_constructible&& std::convertible_to + //inline void push_back(ice::Array& arr, Value const& item) noexcept + //{ + // if (arr.size() == arr.capacity()) + // { + // arr.grow(); + // } + + // if constexpr (Logic == ContainerLogic::Complex) + // { + // ice::mem_copy_construct_at( + // ice::ptr_add(arr.memory_view(), arr.size()), + // item + // ); + // } + // else + // { + // arr._data[arr._count] = Type{ item }; + // } + + // arr._count += 1; + //} + template inline constexpr auto Array::data_view(this Array const& self) noexcept -> ice::Data { diff --git a/source/code/core/collections/public/ice/container/array.hxx b/source/code/core/collections/public/ice/container/array.hxx index c32db4d9..655869b4 100644 --- a/source/code/core/collections/public/ice/container/array.hxx +++ b/source/code/core/collections/public/ice/container/array.hxx @@ -8,21 +8,6 @@ namespace ice::array { - template - inline auto slice( - ice::Array& arr, - ice::u32 from_idx = 0, - ice::u32 count = ice::u32_max - ) noexcept -> ice::Span; - - template - requires std::move_constructible - inline void push_back(ice::Array& arr, Type&& item) noexcept; - - template - requires std::copy_constructible && std::convertible_to - inline void push_back(ice::Array& arr, Value const& item) noexcept; - template requires std::copy_constructible inline void push_back(ice::Array& arr, ice::Array const& items) noexcept; @@ -38,62 +23,14 @@ namespace ice::array template inline void pop_back(ice::Array& arr, ice::u32 count = 1) noexcept; - template - inline auto begin(ice::Array& arr) noexcept -> typename ice::Array::Iterator; - - template - inline auto end(ice::Array& arr) noexcept -> typename ice::Array::Iterator; - - template - inline auto rbegin(ice::Array& arr) noexcept -> typename ice::Array::ReverseIterator; - - template - inline auto rend(ice::Array& arr) noexcept -> typename ice::Array::ReverseIterator; - - template - inline auto size_bytes(ice::Array const& arr) noexcept -> ice::usize; - - template - inline auto slice( - ice::Array const& arr, - ice::u32 from_idx = 0, - ice::u32 count = ice::u32_max - )noexcept -> ice::Span; - - template - inline auto begin(ice::Array const& arr) noexcept -> typename ice::Array::ConstIterator; - - template - inline auto end(ice::Array const& arr) noexcept -> typename ice::Array::ConstIterator; - - template - inline auto rbegin(ice::Array const& arr) noexcept -> typename ice::Array::ConstReverseIterator; - - template - inline auto rend(ice::Array const& arr) noexcept -> typename ice::Array::ConstReverseIterator; - - - - template - inline auto data_view(ice::Array const& arr) noexcept -> ice::Data; - - template - inline auto memory(ice::Array& arr) noexcept -> ice::Memory; - template inline auto memset(ice::Array& arr, ice::u8 value) noexcept -> ice::Memory; - template - inline auto meminfo(ice::Array const& arr) noexcept -> ice::meminfo; - } // namespace ice::array namespace ice { - using ice::array::begin; - using ice::array::end; - } // namespace ice #include "impl/array_impl.inl" diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index 46080975..50bd0a91 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -1,6 +1,7 @@ #pragma once #include #include +#include namespace ice::concepts { @@ -22,12 +23,21 @@ namespace ice::concepts { t.data() } -> std::convertible_to::ValueType const*>; }; + template + concept TrivialContainerLogic = ContainerType + && TrivialContainerLogicAllowed::ValueType>; + + template + concept RegularContainerLogic = ContainerType + && not TrivialContainerLogicAllowed::ValueType>; + template concept ResizableContainer = Container && requires(T t, ice::ncount size) { { t.data() } -> std::convertible_to::ValueType*>; - { t.resize(size) } -> std::convertible_to; { t.capacity() } -> std::convertible_to; { t.set_capacity(size) } -> std::convertible_to; + { t.resize(size) } -> std::convertible_to; + { t.clear() } -> std::convertible_to; }; } // namespace ice::concepts @@ -60,15 +70,18 @@ namespace ice::container template using ConstCorrectContainerReverseIterator = std::conditional_t< std::is_const_v>, - typename std::remove_reference_t::ReverseConstIterator, + typename std::remove_reference_t::ConstReverseIterator, typename std::remove_reference_t::ReverseIterator >; template - using ValueRef = ConstCorrectContainerValueType&; + using ValueType = ConstCorrectContainerValueType; + + template + using ValueRef = ValueType&; template - using ValuePtr = ConstCorrectContainerValueType*; + using ValuePtr = ValueType*; template using Iterator = ConstCorrectContainerIterator; diff --git a/source/code/core/collections/public/ice/container/contiguous_container.hxx b/source/code/core/collections/public/ice/container/contiguous_container.hxx index d531487b..5b0b9e14 100644 --- a/source/code/core/collections/public/ice/container/contiguous_container.hxx +++ b/source/code/core/collections/public/ice/container/contiguous_container.hxx @@ -71,13 +71,13 @@ namespace ice::container template constexpr auto rbegin(this Self&& self) noexcept -> ice::container::ReverseIterator { - return { self.data() + self.size() }; + return ice::container::ReverseIterator{ self.data() + self.size() }; } template constexpr auto rend(this Self&& self) noexcept -> ice::container::ReverseIterator { - return { self.data() }; + return ice::container::ReverseIterator{ self.data() }; } // Operators @@ -86,6 +86,21 @@ namespace ice::container { return self.data()[index]; } + + // Data API + template + inline auto meminfo(this Self const& self) noexcept -> ice::meminfo + { + return ice::meminfo_of * self.size(); + } + + template requires (ice::concepts::TrivialContainerLogic) + inline auto memset(this Self const& self, ice::u8 value) noexcept -> ice::Memory + { + ice::Memory mem{ self.data(), self.size(), ice::align_of> }; + ice::memset(mem.location, value, mem.size.value); + return mem; + } }; } // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/impl/array_impl.inl b/source/code/core/collections/public/ice/container/impl/array_impl.inl index 37a1b242..dd958f6b 100644 --- a/source/code/core/collections/public/ice/container/impl/array_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/array_impl.inl @@ -8,178 +8,11 @@ namespace ice namespace array { - template - inline void set_capacity(ice::Array& arr, ice::ncount new_capacity) noexcept - { - if (new_capacity == arr._capacity) - { - return; - } - - if (new_capacity < arr._count) - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_n_at(arr._data + new_capacity, arr._count - new_capacity); - } - - arr._count = new_capacity.u32(); - } - - Type* new_data = nullptr; - if (new_capacity > 0) - { - ice::AllocResult new_buffer = arr._allocator->allocate(ice::meminfo_of * new_capacity); - ICE_ASSERT_CORE(new_buffer.memory != nullptr); - if (arr._count > 0) - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_move_construct_n_at(new_buffer, arr._data, arr._count); - ice::mem_destruct_n_at(arr._data, arr._count); - } - else - { - ice::memcpy(new_buffer, ice::array::data_view(arr)); - } - } - new_data = reinterpret_cast(new_buffer.memory); - } - - arr._allocator->deallocate(ice::array::memory(arr)); - arr._data = new_data; - arr._capacity = new_capacity.u32(); - } - - template - inline void reserve(ice::Array& arr, ice::ncount min_capacity) noexcept - { - if (arr._capacity < min_capacity) - { - ice::array::set_capacity(arr, min_capacity); - } - } - - template - inline void grow(ice::Array& arr, ice::ncount min_capacity) noexcept - { - ice::ncount new_capacity = arr._capacity * 2 + 4; - if (new_capacity < min_capacity) - { - new_capacity = min_capacity; - } - ice::array::set_capacity(arr, new_capacity); - } - - template - inline void resize(ice::Array& arr, ice::ncount new_count) noexcept - { - if (arr._capacity < new_count) - { - ice::array::set_capacity(arr, new_count); - } - - if (new_count > arr._count) - { - ice::ncount const missing_items = new_count - arr._count; - - // Even for trivial logic we construct items so at least the default ctor is called. - ice::mem_construct_n_at( - Memory{ .location = arr._data + arr._count, .size = ice::size_of * missing_items, .alignment = ice::align_of }, - missing_items - ); - } - else if constexpr (Logic == ContainerLogic::Complex) - { - static_assert(Logic != ContainerLogic::Trivial); - ice::ncount const destroyed_items = arr._count - new_count; - - ice::mem_destruct_n_at( - arr._data + new_count, - destroyed_items - ); - } - - arr._count = new_count.u32(); - } - - template - inline void shrink(ice::Array& arr) noexcept - { - ice::array::set_capacity(arr, arr._count); - } - - template - inline void clear(ice::Array& arr) noexcept - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_n_at(arr._data, arr._count); - } - - arr._count = 0; - } - - template - inline auto slice(ice::Array& arr, ice::u32 from_idx, ice::u32 count) noexcept -> ice::Span - { - ice::Span arr_span{ arr }; - return arr_span.subspan(from_idx, count); - } - - template - requires std::move_constructible - inline void push_back(ice::Array& arr, Type&& item) noexcept - { - if (arr.size() == arr.capacity()) - { - arr.grow(); - } - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_move_construct_at( - Memory{ .location = arr._data + arr._count, .size = ice::size_of, .alignment = ice::align_of }, - ice::forward(item) - ); - } - else - { - arr._data[arr._count] = Type{ item }; - } - - arr._count += 1; - } - - template - requires std::copy_constructible && std::convertible_to - inline void push_back(ice::Array& arr, Value const& item) noexcept - { - if (arr.size() == arr.capacity()) - { - arr.grow(); - } - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_at( - ice::ptr_add(arr.memory_view(), arr.size()), - item - ); - } - else - { - arr._data[arr._count] = Type{ item }; - } - - arr._count += 1; - } - template requires std::copy_constructible inline void push_back(ice::Array& arr, ice::Array const& items) noexcept { - return ice::array::push_back(arr, ice::array::slice(items)); + return ice::array::push_back(arr, items.tailspan(0)); } template @@ -189,7 +22,7 @@ namespace ice ice::u32 const required_capacity = arr._count + items.size().u32(); if (required_capacity > arr._capacity) { - ice::array::grow(arr, required_capacity); + arr.grow(required_capacity); } ice::u32 const missing_items = required_capacity - arr._count; @@ -219,7 +52,7 @@ namespace ice ice::u32 const required_capacity = arr._count + items.size(); if (required_capacity > arr._capacity) { - ice::array::grow(arr, required_capacity); + arr.grow(required_capacity); } ice::u32 const missing_items = required_capacity - arr._count; @@ -248,109 +81,6 @@ namespace ice } } - template - inline auto begin(ice::Array& arr) noexcept -> typename ice::Array::Iterator - { - return arr._data; - } - - template - inline auto end(ice::Array& arr) noexcept -> typename ice::Array::Iterator - { - return arr._data + arr._count; - } - - template - inline auto rbegin(ice::Array& arr) noexcept -> typename ice::Array::ReverseIterator - { - return typename ice::Array::ReverseIterator{ arr._data + arr._count }; - } - - template - inline auto rend(ice::Array& arr) noexcept -> typename ice::Array::ReverseIterator - { - return typename ice::Array::ReverseIterator{ arr._data }; - } - - template - inline auto size_bytes(ice::Array const& arr) noexcept -> ice::usize - { - return ice::size_of * arr._count; - } - - template - inline auto slice(ice::Array const& arr, ice::u32 from_idx, ice::u32 count) noexcept -> ice::Span - { - ice::Span arr_span{ arr }; - return arr_span.subspan(from_idx, count); - } - - template - inline auto slice(ice::Array const& arr, ice::ref32 ref) noexcept -> ice::Span - { - ice::Span arr_span{ arr }; - return arr_span.subspan(ref.offset, ref.size); - } - - template - inline auto begin(ice::Array const& arr) noexcept -> typename ice::Array::ConstIterator - { - return arr._data; - } - - template - inline auto end(ice::Array const& arr) noexcept -> typename ice::Array::ConstIterator - { - return arr._data + arr._count; - } - - template - inline auto rbegin(ice::Array const& arr) noexcept -> typename ice::Array::ConstReverseIterator - { - return typename ice::Array::ConstReverseIterator{ arr._data + arr._count }; - } - - template - inline auto rend(ice::Array const& arr) noexcept -> typename ice::Array::ConstReverseIterator - { - return typename ice::Array::ConstReverseIterator{ arr._data }; - } - - - template - inline auto data_view(ice::Array const& arr) noexcept -> ice::Data - { - return ice::Data{ - .location = arr._data, - .size = ice::size_of * arr._count, - .alignment = ice::align_of - }; - } - - template - inline auto memory(ice::Array& arr) noexcept -> ice::Memory - { - return ice::Memory{ - .location = arr._data, - .size = ice::size_of * arr._capacity, - .alignment = ice::align_of - }; - } - - template - inline auto memset(ice::Array& arr, ice::u8 value) noexcept -> ice::Memory - { - ice::Memory const mem = ice::array::memory(arr); - ice::memset(mem.location, value, mem.size.value); - return mem; - } - - template - inline auto meminfo(ice::Array const& arr) noexcept -> ice::meminfo - { - return ice::meminfo_of * arr.size().native(); - } - } // namespace array } // namespace ice diff --git a/source/code/core/collections/public/ice/container/resizable_container.hxx b/source/code/core/collections/public/ice/container/resizable_container.hxx index 9aad2ac7..3b4d5c45 100644 --- a/source/code/core/collections/public/ice/container/resizable_container.hxx +++ b/source/code/core/collections/public/ice/container/resizable_container.hxx @@ -6,12 +6,6 @@ namespace ice::container struct ResizableContainer { - template - constexpr void clear(this Self& self) noexcept - { - self.resize(0); - } - template constexpr void reserve(this Self& self, ice::ncount min_capacity) noexcept { @@ -22,7 +16,7 @@ namespace ice::container } template - inline void grow(this Self& self, ice::ncount min_capacity = ice::ncount_none) noexcept + constexpr void grow(this Self& self, ice::ncount min_capacity = ice::ncount_none) noexcept { ice::ncount new_capacity = self.capacity() * 2 + 4; if (new_capacity < min_capacity) @@ -31,6 +25,12 @@ namespace ice::container } self.set_capacity(new_capacity); } + + template + constexpr void shrink(this Self& self) noexcept + { + self.set_capacity(self.size()); + } }; } // namespace ice diff --git a/source/code/core/collections/tests/test_array.cxx b/source/code/core/collections/tests/test_array.cxx index b3866d8a..bc95cc1a 100644 --- a/source/code/core/collections/tests/test_array.cxx +++ b/source/code/core/collections/tests/test_array.cxx @@ -20,11 +20,11 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" CHECK(objects.size() == 0); // We force a capacity of 1, so we ensure a reallocation in later. - ice::array::set_capacity(objects, 1); + objects.set_capacity(1); WHEN("adding a new object") { - ice::array::push_back(objects, Test_TrackingObject{ }); + objects.push_back(Test_TrackingObject{ }); REQUIRE(objects.capacity() >= 1); REQUIRE(objects.size() == 1); @@ -51,7 +51,7 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" ice::u32 dtor_val = 0; obj.data.test_dtor = &dtor_val; - ice::array::resize(objects, 10); + objects.resize(10); // The old object was moved to a new location (move ctor + dtor) CHECK(dtor_val == 1); @@ -98,7 +98,7 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" object.data.test_dtor = &dtor_val; } - ice::array::clear(objects); + objects.clear(); CHECK(dtor_val == 20); CHECK(objects.capacity() > 0); @@ -160,7 +160,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod WHEN("one element is pushed") { - ice::array::push_back(objects, test_value_1); + objects.push_back(test_value_1); CHECK(objects.size() == 1); CHECK(objects.not_empty() == true); @@ -177,7 +177,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod THEN("array is shrunk") { - ice::array::shrink(objects); + objects.shrink(); REQUIRE(objects.size() == 0); REQUIRE(objects.capacity() == 0); @@ -198,7 +198,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod { for (ice::i32 i = 0; i < 100; ++i) { - ice::array::push_back(objects, test_value_2 + i); + objects.push_back(test_value_2 + i); } CHECK(objects.size() == 100); @@ -219,7 +219,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod THEN("array is shrunk") { - ice::array::shrink(objects); + objects.shrink(); CHECK(objects.not_empty() == true); CHECK(objects.is_empty() == false); @@ -281,7 +281,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod THEN("we can add new items") { - ice::array::push_back(objects, 100); + objects.push_back(100); CHECK(objects.size() == 1); REQUIRE(objects[0] == 100); @@ -299,7 +299,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod THEN("we can add new items") { - ice::array::push_back(objects, 100); + objects.push_back(100); CHECK(objects.size() == 1); REQUIRE(objects[0] == 100); From 5acb7299935783e96b31e3fa2c68f42708bd6ac8 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sat, 10 Jan 2026 14:26:25 +0900 Subject: [PATCH 14/40] #ICE-207 Changes to engine source code after additioanl refactor of the Array type. --- .../public/ice/shard_container.hxx | 32 ++++----- .../tests/test_shard_container.cxx | 6 +- .../memsys/public/ice/mem_initializers.hxx | 17 ++++- .../core/modules/private/module_register.cxx | 2 +- .../core/modules/public/ice/module_query.hxx | 4 +- .../tasks/private/task_thread_pool_impl.cxx | 14 ++-- .../utils/private/config/config_builder.cxx | 10 +-- .../private/config/config_builder_types.cxx | 2 +- .../private/config/config_builder_utils.cxx | 10 +-- .../code/core/utils/private/log_internal.cxx | 4 +- source/code/core/utils/private/params.cxx | 10 +-- .../utils/public/ice/config/config_impl.hxx | 4 +- .../framework_base/private/framework_main.cxx | 6 +- .../engine/private/action/action_system.cxx | 5 +- .../private/ecs/ecs_archetype_index.cxx | 14 ++-- .../engine/private/ecs/ecs_entity_index.cxx | 6 +- .../engine/private/ecs/ecs_entity_storage.cxx | 12 ++-- .../private/engine_state_tracker_default.cxx | 11 ++- .../engine/private/gfx/ice_gfx_graph.cxx | 39 +++++------ .../private/gfx/ice_gfx_graph_runtime.cxx | 69 +++++++------------ .../private/gfx/ice_gfx_stage_registry.cxx | 2 +- .../public/ice/ecs/ecs_entity_operations.hxx | 2 +- .../public/ice/ecs/ecs_query_operations.hxx | 36 +++++----- .../public/ice/ecs/ecs_query_provider.hxx | 2 +- .../private/gfx/iceshard_gfx_device.cxx | 12 ++-- .../private/gfx/iceshard_gfx_queue.cxx | 7 +- .../private/gfx/iceshard_gfx_queue_group.cxx | 5 +- .../private/iceshard_data_storage.hxx | 2 +- .../iceshard/private/iceshard_frame.cxx | 4 +- .../iceshard/private/iceshard_runner.hxx | 4 +- .../private/iceshard_trait_context.cxx | 4 +- .../iceshard/private/iceshard_world.cxx | 2 +- .../private/iceshard_world_context.cxx | 3 +- .../private/iceshard_world_context.hxx | 1 + .../private/iceshard_world_manager.cxx | 6 +- .../private/iceshard_world_manager_devui.cxx | 2 +- .../private/iceshard_world_tasks_devui.cxx | 14 ++-- .../private/iceshard_world_tasks_launcher.cxx | 3 +- .../private/pipeline_ui/ip_ui_asset.cxx | 12 ++-- .../private/pipeline_ui/ip_ui_oven_page.cxx | 15 ++-- .../imgui_module/private/imgui_gfx_stage.cxx | 14 ++-- .../imgui_module/private/imgui_system.cxx | 6 +- .../imgui_module/private/imgui_trait.cxx | 7 +- .../private/widgets/imgui_devui_manager.cxx | 8 +-- .../private/widgets/imgui_devui_manager.hxx | 2 +- .../private/widgets/imgui_logger.cxx | 12 ++-- .../private/shader_tools_asl_importer.cxx | 10 +-- .../private/shader_tools_asl_shader.cxx | 6 +- .../vulkan_renderer/private/vk_device.cxx | 69 +++++++++---------- .../vulkan_renderer/private/vk_driver.cxx | 13 ++-- .../vulkan_renderer/private/vk_extensions.cxx | 6 +- .../vulkan_renderer/private/vk_module.cxx | 6 +- .../vulkan_renderer/private/vk_utility.hxx | 8 +-- .../private/win32_sdl2_platform.cxx | 2 +- .../private/win32_sdl2_platform.hxx | 2 +- .../asset_system/private/asset_storage.cxx | 13 ++-- .../private/asset_type_archive.cxx | 2 +- .../private/input_action_layer.cxx | 2 +- .../private/input_action_layer_builder.cxx | 69 +++++++++---------- .../private/input_action_stack.cxx | 45 ++++++------ .../input_system/private/input_controller.cxx | 8 +-- .../input_system/private/input_keyboard.cxx | 4 +- .../input_system/private/input_mouse.cxx | 14 ++-- .../private/input_touchscreen.cxx | 10 +-- .../input_system/private/input_tracker.cxx | 2 +- .../public/ice/input/device_event_queue.hxx | 5 +- .../private/resource_filesystem_traverser.cxx | 8 +-- .../private/resource_provider_custom.cxx | 2 +- .../private/resource_provider_dynlib.cxx | 2 +- .../private/resource_provider_filelist.cxx | 6 +- .../private/resource_provider_filesystem.cxx | 8 +-- .../private/resource_provider_hailstorm.cxx | 8 +-- .../private/resource_tracker.cxx | 2 +- .../private/resource_writer_filesystem.cxx | 6 +- source/code/test/private/game.cxx | 4 +- .../private/asset_compiler_app.cxx | 10 ++- .../asset_compiler_resource_provider.cxx | 6 +- .../tools/hsc_packer/private/hsc_packer.cxx | 14 ++-- 78 files changed, 400 insertions(+), 436 deletions(-) diff --git a/source/code/core/collections/public/ice/shard_container.hxx b/source/code/core/collections/public/ice/shard_container.hxx index 072c9118..02d0a206 100644 --- a/source/code/core/collections/public/ice/shard_container.hxx +++ b/source/code/core/collections/public/ice/shard_container.hxx @@ -21,7 +21,7 @@ namespace ice inline auto operator=(ice::ShardContainer&& other) noexcept -> ice::ShardContainer&; inline auto operator=(ice::ShardContainer const& other) noexcept -> ice::ShardContainer&; - inline operator ice::Span() const noexcept { return ice::array::slice(_data); } + inline operator ice::Span() const noexcept { return _data; } ice::Array _data; }; @@ -129,22 +129,22 @@ namespace ice inline void reserve(ice::ShardContainer& container, ice::u32 new_capacity) noexcept { - ice::array::reserve(container._data, new_capacity); + container._data.reserve(new_capacity); } inline void resize(ice::ShardContainer& container, ice::u32 new_size) noexcept { - ice::array::resize(container._data, new_size); + container._data.resize(new_size); } inline void clear(ice::ShardContainer& container) noexcept { - ice::array::clear(container._data); + container._data.clear(); } inline void push_back(ice::ShardContainer& container, ice::Shard value) noexcept { - ice::array::push_back(container._data, value); + container._data.push_back(value); } inline void push_back(ice::ShardContainer& container, ice::Span values) noexcept @@ -171,12 +171,12 @@ namespace ice inline auto begin(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator { - return ice::array::begin(container._data); + return container._data.begin(); } inline auto end(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator { - return ice::array::end(container._data); + return container._data.end(); } @@ -212,8 +212,8 @@ namespace ice inline auto find_first_of(ice::ShardContainer const& container, ice::ShardID shard, ice::u32 offset) noexcept -> ice::Shard { - auto it = ice::array::begin(container._data); - auto const end = ice::array::end(container._data); + auto it = container._data.begin(); + auto const end = container._data.end(); if (offset != ~0) { @@ -238,8 +238,8 @@ namespace ice inline auto find_last_of(ice::ShardContainer const& container, ice::ShardID shard, ice::u32 offset) noexcept -> ice::Shard { - auto it = ice::array::rbegin(container._data); - auto const end = ice::array::rend(container._data); + auto it = container._data.rbegin(); + auto const end = container._data.rend(); if (offset != ~0) { @@ -299,7 +299,7 @@ namespace ice { if (shard == shard_type && ice::shard_inspect(shard, payload)) { - ice::array::push_back(payloads, payload); + payloads.push_back(payload); count += 1; } } @@ -331,8 +331,8 @@ namespace ice template inline bool inspect_first(ice::ShardContainer const& container, ice::ShardID shard_type, T(&payload)[Size]) noexcept { - auto it = ice::array::begin(container._data); - auto const end = ice::array::end(container._data); + auto it = container._data.begin(); + auto const end = container._data.end(); ice::u32 idx = 0; while (it != end && idx < Size) @@ -361,12 +361,12 @@ namespace ice inline auto begin(ice::ShardContainer const& container) noexcept -> ice::ShardContainer::ConstIterator { - return ice::array::begin(container._data); + return container._data.begin(); } inline auto end(ice::ShardContainer const& container) noexcept -> ice::ShardContainer::ConstIterator { - return ice::array::end(container._data); + return container._data.end(); } } diff --git a/source/code/core/collections/tests/test_shard_container.cxx b/source/code/core/collections/tests/test_shard_container.cxx index 85bf5c4c..973659fc 100644 --- a/source/code/core/collections/tests/test_shard_container.cxx +++ b/source/code/core/collections/tests/test_shard_container.cxx @@ -292,19 +292,19 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") CHECK(payload == payloads[0]); } - ice::array::clear(payloads); + payloads.clear(); ice::shards::inspect_all(test_container, test_shard_2, payloads); REQUIRE(payloads.size() == 0); - ice::array::clear(payloads); + payloads.clear(); ice::shards::inspect_all(test_container, test_shard_3, payloads); REQUIRE(payloads.size() == 2); CHECK(payloads[0] == test_u32_payload_value2); CHECK(payloads[1] == test_u32_payload_value1); - ice::array::clear(payloads); + payloads.clear(); ice::shards::inspect_all(test_container, test_shard_4, payloads); REQUIRE(payloads.size() == 1); diff --git a/source/code/core/memsys/public/ice/mem_initializers.hxx b/source/code/core/memsys/public/ice/mem_initializers.hxx index 3939110d..e4c7e49f 100644 --- a/source/code/core/memsys/public/ice/mem_initializers.hxx +++ b/source/code/core/memsys/public/ice/mem_initializers.hxx @@ -8,18 +8,31 @@ namespace ice { + template + auto mem_construct_at(void* memory_ptr, Args&&... args) noexcept -> T* + { + // TODO: Assert (align + size) + return new (memory_ptr) T{ ice::forward(args)... }; + } + template auto mem_construct_at(ice::Memory memory, Args&&... args) noexcept -> T* { // TODO: Assert (align + size) - return new (memory.location) T{ ice::forward(args)... }; + return mem_construct_at(memory.location, ice::forward(args)...); + } + + template + auto mem_move_construct_at(void* memory_ptr, T&& other) noexcept -> T* + { + return new (memory_ptr) T{ ice::move(other) }; } template auto mem_move_construct_at(ice::Memory memory, T&& other) noexcept -> T* { // TODO: Assert (align + size) - return new (memory.location) T{ ice::move(other) }; + return mem_move_construct_at(memory.location, ice::move(other)); } template diff --git a/source/code/core/modules/private/module_register.cxx b/source/code/core/modules/private/module_register.cxx index 7ce5ba92..21dc9975 100644 --- a/source/code/core/modules/private/module_register.cxx +++ b/source/code/core/modules/private/module_register.cxx @@ -124,7 +124,7 @@ namespace ice /* is_app_context */ false ); - ice::array::push_back(_module_handles, ice::move(module_handle)); + _module_handles.push_back(ice::move(module_handle)); return true; } } diff --git a/source/code/core/modules/public/ice/module_query.hxx b/source/code/core/modules/public/ice/module_query.hxx index 7de86ae3..7f160165 100644 --- a/source/code/core/modules/public/ice/module_query.hxx +++ b/source/code/core/modules/public/ice/module_query.hxx @@ -96,10 +96,10 @@ namespace ice query_apis(Type::Constant_APIName, Type::Constant_APIVersion, temp_tab, &num_apis); // Fill the array with the found APIs - ice::array::reserve(out_apis, num_apis); + out_apis.reserve(num_apis); for (ice::u32 idx = 0; idx < num_apis; ++idx) { - ice::array::push_back(out_apis, *reinterpret_cast(temp_tab[idx].api_ptr)); + out_apis.push_back(*reinterpret_cast(temp_tab[idx].api_ptr)); } } return num_apis > 0; diff --git a/source/code/core/tasks/private/task_thread_pool_impl.cxx b/source/code/core/tasks/private/task_thread_pool_impl.cxx index 534aa68c..604d20a3 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.cxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.cxx @@ -47,8 +47,8 @@ namespace ice , _created_threads{ _allocator } , _user_threads{ _allocator } { - ice::array::reserve(_thread_pool, info.thread_count); - ice::array::reserve(_managed_threads, info.thread_count); + _thread_pool.reserve(info.thread_count); + _managed_threads.reserve(info.thread_count); ice::hashmap::reserve(_created_threads, info.thread_count); ice::hashmap::reserve(_user_threads, info.thread_count); @@ -64,8 +64,7 @@ namespace ice detail::format_string(thread_name, info.debug_name_format, idx); thread_info.debug_name = thread_name; - ice::array::push_back( - _managed_threads, + _managed_threads.push_back( ice::make_unique( _allocator, _queue, @@ -79,8 +78,7 @@ namespace ice { detail::format_string(thread_name, "ice.aio {}", idx); - ice::array::push_back( - _managed_threads, + _managed_threads.push_back( ice::make_unique( _allocator, _queue, @@ -101,8 +99,8 @@ namespace ice { ice::hashmap::clear(_user_threads); ice::hashmap::clear(_created_threads); - ice::array::clear(_managed_threads); - ice::array::clear(_thread_pool); + _managed_threads.clear(); + _thread_pool.clear(); } auto TaskThreadPoolImplementation::thread_count() const noexcept -> ice::u32 diff --git a/source/code/core/utils/private/config/config_builder.cxx b/source/code/core/utils/private/config/config_builder.cxx index ceae95ce..9d9c7b1e 100644 --- a/source/code/core/utils/private/config/config_builder.cxx +++ b/source/code/core/utils/private/config/config_builder.cxx @@ -91,8 +91,8 @@ namespace ice ) noexcept -> ice::usize { ice::usize result = 0_B; - ConfigBuilderEntry const* entry = ice::array::begin(config._entries); - ConfigBuilderEntry const* const entry_end = ice::array::end(config._entries); + ConfigBuilderEntry const* entry = config._entries.begin(); + ConfigBuilderEntry const* const entry_end = config._entries.end(); if (entry == entry_end) { @@ -167,8 +167,8 @@ namespace ice { // First add all keys-values to the list ice::u32 keyoffset = 0; - ice::config::detail::ConfigBuilderEntry const* it_entry = ice::array::begin(config._entries); - ice::config::detail::ConfigBuilderEntry const* const it_end = ice::array::end(config._entries); + ice::config::detail::ConfigBuilderEntry const* it_entry = config._entries.begin(); + ice::config::detail::ConfigBuilderEntry const* const it_end = config._entries.end(); do { // Copy the whole key information and just update the str offset. @@ -397,7 +397,7 @@ namespace ice char const* final_keystrings = reinterpret_cast(final_keystrings_mem.location); // Reserve space to hold all keystring entries and build the string buffer. - ice::array::resize(keyoffsets, ice::hashmap::count(keystrings)); + keyoffsets.resize(ice::hashmap::count(keystrings)); ice::ncount keystr_offset = 0; for (CBKeyString const& keystr : ice::hashmap::values(keystrings)) diff --git a/source/code/core/utils/private/config/config_builder_types.cxx b/source/code/core/utils/private/config/config_builder_types.cxx index 53cf8a68..51c32fcc 100644 --- a/source/code/core/utils/private/config/config_builder_types.cxx +++ b/source/code/core/utils/private/config/config_builder_types.cxx @@ -39,7 +39,7 @@ namespace ice::config::detail { cb_clear_value_type(_allocator, &entry); } - ice::array::clear(_entries); + _entries.clear(); } ConfigBuilderContainer::~ConfigBuilderContainer() noexcept diff --git a/source/code/core/utils/private/config/config_builder_utils.cxx b/source/code/core/utils/private/config/config_builder_utils.cxx index efc806e6..a8298536 100644 --- a/source/code/core/utils/private/config/config_builder_utils.cxx +++ b/source/code/core/utils/private/config/config_builder_utils.cxx @@ -89,10 +89,10 @@ namespace ice::config::detail container._keystrings.push_back(key); // Add the new entry - ice::array::push_back(container._entries, ConfigKey{ 0, CONFIG_KEYTYPE_STRING, CONFIG_VALTYPE_NONE, offset.u32(), key.size().u32()}); + container._entries.push_back(ConfigKey{ 0, CONFIG_KEYTYPE_STRING, CONFIG_VALTYPE_NONE, offset.u32(), key.size().u32()}); // Return the entry - result = ice::array::begin(container._entries) + idx; + result = container._entries.begin() + idx; } return result; @@ -111,7 +111,7 @@ namespace ice::config::detail ice::config::detail::ConfigBuilderEntry* result; if (idx < container._entries.size()) { - result = ice::array::begin(container._entries) + idx; + result = container._entries.begin() + idx; if (clean) { cb_clear_value_type(alloc, result); @@ -126,11 +126,11 @@ namespace ice::config::detail while(container._entries.size() <= idx) { - ice::array::push_back(container._entries, ConfigKey{ 0, CONFIG_KEYTYPE_NONE, CONFIG_VALTYPE_NONE, 0, 0 }); + container._entries.push_back(ConfigKey{ 0, CONFIG_KEYTYPE_NONE, CONFIG_VALTYPE_NONE, 0, 0 }); } // Return the entry - result = ice::array::begin(container._entries) + idx; + result = container._entries.begin() + idx; } return result; diff --git a/source/code/core/utils/private/log_internal.cxx b/source/code/core/utils/private/log_internal.cxx index db95f124..87ea9ea9 100644 --- a/source/code/core/utils/private/log_internal.cxx +++ b/source/code/core/utils/private/log_internal.cxx @@ -16,7 +16,7 @@ namespace ice::detail , _tags{ _allocator } , _sinks{ _allocator } { - ice::array::resize(_sinks, 5); + _sinks.resize(5); } LogState::~LogState() noexcept = default; @@ -36,7 +36,7 @@ namespace ice::detail // Pottentially an error when sinks are added and remove all the time! // NOTE: Once added sinks should only be reset when a module was reloaded! ICE_ASSERT_CORE(sinkidx < 50); - ice::array::push_back(_sinks, Sink{ fn_sink, userdata }); + _sinks.push_back(Sink{ fn_sink, userdata }); return static_cast(sinkidx); } diff --git a/source/code/core/utils/private/params.cxx b/source/code/core/utils/private/params.cxx index 64c66db5..f7c64f3d 100644 --- a/source/code/core/utils/private/params.cxx +++ b/source/code/core/utils/private/params.cxx @@ -336,7 +336,7 @@ namespace ice { for (std::string const& result : results) { - ice::array::push_back(out_values, { result.data(), static_cast(result.size()) }); + out_values.push_back({ result.data(), static_cast(result.size()) }); } return true; }; @@ -356,7 +356,7 @@ namespace ice { for (std::string const& result : results) { - ice::array::push_back(out_values, { alloc, ice::String{ std::string_view{ result } } }); + out_values.push_back({ alloc, ice::String{ std::string_view{ result } } }); } return true; }; @@ -383,7 +383,7 @@ namespace ice ); ice::StackAllocator * 8> stack_alloc; ice::Array ice_results{ result_count <= 8 ? stack_alloc : alloc }; - ice::array::reserve(ice_results, result_count); + ice_results.reserve(result_count); auto it = results.begin(); auto const end = results.end(); @@ -395,11 +395,11 @@ namespace ice if (ice_results.size() == result_count || result.empty()) { valid &= ice_callback(ice_userdata, ice_results); - ice::array::clear(ice_results); + ice_results.clear(); } else if (result.empty() == false) { - ice::array::push_back(ice_results, result); + ice_results.push_back(result); } it += 1; } diff --git a/source/code/core/utils/public/ice/config/config_impl.hxx b/source/code/core/utils/public/ice/config/config_impl.hxx index 5278f498..5105568d 100644 --- a/source/code/core/utils/public/ice/config/config_impl.hxx +++ b/source/code/core/utils/public/ice/config/config_impl.hxx @@ -132,13 +132,13 @@ namespace ice::config::detail } ice::ErrorCode result = S_Ok; - ice::array::reserve(out_values, table_size); + out_values.reserve(table_size); do { T temp_value; if (result = ice::config::detail::get(config, entry_key, entry_value, temp_value, flags); result == S_Ok) { - ice::array::push_back(out_values, temp_value); + out_values.push_back(temp_value); } else if (result != E_ConfigValueTypeMissmatch) { diff --git a/source/code/framework/framework_base/private/framework_main.cxx b/source/code/framework/framework_base/private/framework_main.cxx index e0783f46..4abf008b 100644 --- a/source/code/framework/framework_base/private/framework_main.cxx +++ b/source/code/framework/framework_base/private/framework_main.cxx @@ -340,8 +340,8 @@ auto ice_setup( ice::path::normalize(config.dev_dirs.assets); config.dev_dirs.shaders.push_back('/'); config.dev_dirs.assets.push_back('/'); - ice::array::push_back(resource_paths, config.dev_dirs.assets); - ice::array::push_back(resource_paths, config.dev_dirs.shaders); + resource_paths.push_back(config.dev_dirs.assets); + resource_paths.push_back(config.dev_dirs.shaders); } else { @@ -593,7 +593,7 @@ auto ice_game_frame( co_await runtime.runner->pre_update(new_frame->shards()); // Push input events - ice::array::clear(runtime.input_events); + runtime.input_events.clear(); runtime.input_tracker->process_device_events(state.platform.core->input_events(), runtime.input_events); ice_process_input_events(runtime.input_events, new_frame->shards()); diff --git a/source/code/iceshard/engine/private/action/action_system.cxx b/source/code/iceshard/engine/private/action/action_system.cxx index 8094b45a..8b93aaff 100644 --- a/source/code/iceshard/engine/private/action/action_system.cxx +++ b/source/code/iceshard/engine/private/action/action_system.cxx @@ -163,10 +163,7 @@ namespace ice::action if (instance != nullptr) { instance->stage_timeline = ice::timeline::create_timeline(_clock); - ice::array::push_back( - _actions, - instance - ); + _actions.push_back(instance); } } diff --git a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx index 3d75a542..5e5dcde0 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx @@ -146,13 +146,13 @@ namespace ice::ecs , _archetype_names_index{ _allocator } , _archetype_data{ _allocator } { - ice::array::reserve(_archetype_data, ice::ecs::Constant_MaxArchetypeCount); - ice::array::push_back(_archetype_data, nullptr); + _archetype_data.reserve(ice::ecs::Constant_MaxArchetypeCount); + _archetype_data.push_back(nullptr); } ArchetypeIndex::~ArchetypeIndex() noexcept { - for (ArchetypeDataHeader* header : ice::array::slice(_archetype_data, 1)) + for (ArchetypeDataHeader* header : _archetype_data.tailspan()) { ice::usize const size = ArchetypeDataHeader::calculate_meminfo(header->archetype_name, header->archetype_info); _allocator.deallocate( @@ -299,7 +299,7 @@ namespace ice::ecs ice::u32 const archetype_index = _archetype_data.size().u32(); data_header->archetype_info.archetype_instance = ice::ecs::detail::ArchetypeInstance{ archetype_index }; - ice::array::push_back(_archetype_data, data_header); + _archetype_data.push_back(data_header); ice::hashmap::set(_archetype_index, ice::hash(archetype_info.identifier), archetype_index); // Save the 'index' for the given name @@ -331,7 +331,7 @@ namespace ice::ecs ice::Span query_tags ) const noexcept { - ice::array::clear(out_archetypes); + out_archetypes.clear(); // We need to skip the first query entry if it's for `ice::ecs::Entity` // This is due to the fact that it's always there and is not taken into account when sorting components by identifiers. @@ -358,7 +358,7 @@ namespace ice::ecs ); ice::u32 const total_required_type_count = required_component_count + required_tag_count; - for (ArchetypeDataHeader const* entry : ice::array::slice(_archetype_data, 1)) + for (ArchetypeDataHeader const* entry : _archetype_data.tailspan()) { ice::ecs::detail::ArchetypeInstanceInfo const& archetype_info = entry->archetype_info; @@ -378,7 +378,7 @@ namespace ice::ecs // #todo: we should probably also check for the existance of the EntityHandle in the query. Then the check should be `> 1` if (was_matched) { - ice::array::push_back(out_archetypes, entry->archetype_identifier); + out_archetypes.push_back(entry->archetype_identifier); } } } diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx index c4239ac9..78869fbb 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx @@ -44,7 +44,7 @@ namespace ice::ecs _max_entity_count ); - ice::array::reserve(_generation, estimated_entity_count); + _generation.reserve(estimated_entity_count); // #todo: decide if we need this [[maybe_unused]] @@ -79,7 +79,7 @@ namespace ice::ecs else { index = _generation.size(); - ice::array::push_back(_generation, ice::u8{ 0 }); + _generation.push_back(ice::u8{ 0 }); } return ice::ecs::detail::make_entity(index.u32(), _generation[index]); @@ -156,7 +156,7 @@ namespace ice::ecs bool EntityIndex::recreate(ice::Array& entities, ice::u32 new_count) noexcept { destroy_many(entities); - ice::array::resize(entities, new_count); + entities.resize(new_count); create_many(entities); return false; } diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx index d57d4b3b..03d4b86c 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx @@ -561,8 +561,8 @@ namespace ice::ecs , _data_slots{ _allocator } , _destructors{ _allocator } { - ice::array::reserve(_head_blocks, 100); // 100 archetypes should suffice for now - ice::array::resize(_data_slots, Constant_InitialEntityCount); + _head_blocks.reserve(100); // 100 archetypes should suffice for now + _data_slots.resize(Constant_InitialEntityCount); } EntityStorage::~EntityStorage() noexcept @@ -628,8 +628,8 @@ namespace ice::ecs return; // Don't remove archetype headblocks because queries might still reference them. } - ice::array::resize(_head_blocks, archetype_count); - ice::array::resize(_data_blocks, archetype_count); + _head_blocks.resize(archetype_count); + _data_blocks.resize(archetype_count); ice::hashmap::reserve(_destructors, archetype_count); // Setup the empty head blocks for new archetypes. @@ -1153,7 +1153,7 @@ namespace ice::ecs IPT_ZONE_SCOPED; ice::StackAllocator<512_B> archetypes_alloc{}; ice::Array archetypes{ archetypes_alloc }; - ice::array::reserve(archetypes, (u32) ice::mem_max_capacity(archetypes_alloc.Constant_InternalCapacity)); + archetypes.reserve(ice::mem_max_capacity(archetypes_alloc.Constant_InternalCapacity)); _archetype_index.find_archetypes(archetypes, query_info, query_tags); ice::ncount const prev_archetype_count = out_instance_infos.size(); @@ -1166,7 +1166,7 @@ namespace ice::ecs for (ice::ecs::detail::ArchetypeInstanceInfo const* instance : out_instance_infos.tailspan(prev_archetype_count)) { ice::u32 const instance_idx = static_cast(instance->archetype_instance); - ice::array::push_back(out_data_blocks, _data_blocks[instance_idx]); + out_data_blocks.push_back(_data_blocks[instance_idx]); } // Find or create work trackers for queried components diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index 93371897..8029b00d 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -51,7 +51,7 @@ namespace ice ice::hash(params.initial.graph.value), _current_state.size().u32() ); - ice::array::push_back(_current_state, initial_state); + _current_state.push_back(initial_state); } else { @@ -73,7 +73,7 @@ namespace ice ice::hash(params.initial.graph.value), _current_state.size().u32() ); - ice::array::push_back(_current_state, initial_state); + _current_state.push_back(initial_state); } ice::hashmap::set( @@ -117,7 +117,7 @@ namespace ice ice::hash(engine_state.graph.value), _current_state.size().u32() ); - ice::array::push_back(_current_state, engine_state); + _current_state.push_back(engine_state); } return true; } @@ -167,9 +167,8 @@ namespace ice { ice::StackAllocator<512_B> temp_alloc; ice::ShardContainer temp_shards{ temp_alloc }; - ice::array::reserve( - temp_shards._data, - (u32)ice::mem_max_capacity( + temp_shards._data.reserve( + ice::mem_max_capacity( ice::size_of, decltype(temp_alloc)::Constant_InternalCapacity ) diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx index 048d7f2f..d5890165 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx @@ -39,23 +39,23 @@ namespace ice::gfx ice::u32 offset = out_resources.size().u32(); for (ice::gfx::GfxResource res : stage.depth_stencil) { - ice::array::push_back(out_resources, res); + out_resources.push_back(res); } - stage_copy.depth_stencil = ice::array::slice(out_resources, offset, stage.depth_stencil.size().u32()); + stage_copy.depth_stencil = out_resources.subspan(offset, stage.depth_stencil.size().u32()); offset += stage.depth_stencil.size().u32(); for (ice::gfx::GfxResource res : stage.inputs) { - ice::array::push_back(out_resources, res); + out_resources.push_back(res); } - stage_copy.inputs = ice::array::slice(out_resources, offset, stage.inputs.size().u32()); + stage_copy.inputs = out_resources.subspan(offset, stage.inputs.size().u32()); offset += stage.inputs.size().u32(); for (ice::gfx::GfxResource res : stage.outputs) { - ice::array::push_back(out_resources, res); + out_resources.push_back(res); } - stage_copy.outputs = ice::array::slice(out_resources, offset, stage.outputs.size().u32()); + stage_copy.outputs = out_resources.subspan(offset, stage.outputs.size().u32()); offset += stage.inputs.size().u32(); return stage_copy; @@ -97,15 +97,15 @@ namespace ice::gfx } IceshardGfxGraphPassObjects gfxpass{ _allocator, pass.name }; - ice::array::reserve(gfxpass.resources, res_count); - ice::array::reserve(gfxpass.stages, pass.stages.size().u32()); + gfxpass.resources.reserve(res_count); + gfxpass.stages.reserve(pass.stages.size().u32()); for (ice::gfx::GfxGraphStage const& stage : pass.stages) { - ice::array::push_back(gfxpass.stages, detail::copy_gfx_pass_stage(stage, gfxpass.resources)); + gfxpass.stages.push_back(detail::copy_gfx_pass_stage(stage, gfxpass.resources)); } - ice::array::push_back(_passes, GfxGraphPass{ .name = pass.name, .stages = gfxpass.stages }); + _passes.push_back(GfxGraphPass{ .name = pass.name, .stages = gfxpass.stages }); ice::hashmap::set(_objects, ice::hash(pass.name), ice::move(gfxpass)); } return true; @@ -132,9 +132,9 @@ namespace ice::gfx ice::u32 const count_images = resources.size().u32(); - ice::array::clear(out_images); - ice::array::reserve(out_images, count_images); - ice::array::push_back(out_images, Image::Invalid); // First image beeing framebuffer + out_images.clear(); + out_images.reserve(count_images); + out_images.push_back(Image::Invalid); // First image beeing framebuffer for (GfxResource res : resources.subspan(1)) { @@ -156,10 +156,7 @@ namespace ice::gfx image_info.usage = ImageUsageFlags::DepthStencilAttachment; } - ice::array::push_back( - out_images, - render_device.create_image(image_info, {}) - ); + out_images.push_back(render_device.create_image(image_info, {})); } ice::u32 fb_idx = 0; @@ -193,7 +190,7 @@ namespace ice::gfx , _clears{ _allocator } , _stages{ ice::move(stages) } { - ice::array::resize(_framebuffers, _swapchain.image_count()); + _framebuffers.resize(_swapchain.image_count()); create_framebuffers( _allocator, @@ -230,7 +227,7 @@ namespace ice::gfx { device.destroy_framebuffer(framebuffer); } - for (ice::render::Image image : ice::array::slice(_framebuffer_images, 1)) + for (ice::render::Image image : _framebuffer_images.tailspan()) { device.destroy_image(image); } @@ -440,7 +437,7 @@ namespace ice::gfx } else if (GfxGraphSnapshot.event & GfxSnapshotEvent::EventNextSubPass && ice::exchange(first_skipped, true)) { - for (ice::StringID_Arg stage : ice::array::slice(_stages._stage_names, stage_idx, _stages._counts[pass_idx])) + for (ice::StringID_Arg stage : _stages._stage_names.subspan(stage_idx, _stages._counts[pass_idx])) { // TODO: Separate update and draw? _stages.apply_stages(stage, &GfxStage::update, frame, _context); @@ -455,7 +452,7 @@ namespace ice::gfx { { IPT_ZONE_SCOPED_NAMED("graph_execute_stages"); - for (ice::StringID_Arg stage : ice::array::slice(_stages._stage_names, stage_idx, _stages._counts[pass_idx])) + for (ice::StringID_Arg stage : _stages._stage_names.subspan( stage_idx, _stages._counts[pass_idx])) { // TODO: Separate update and draw? _stages.apply_stages(stage, &GfxStage::update, frame, _context); diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx index 5725895d..829436e6 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx @@ -67,8 +67,7 @@ namespace ice::gfx if (current.event & GfxSnapshotEvent::EventReadRes) { - ice::array::push_back( - out_barriers, + out_barriers.push_back( GraphBarrier{ .pass_idx = last_pass, .source_layout = render::ImageLayout::Color, @@ -80,8 +79,7 @@ namespace ice::gfx } else { - ice::array::push_back( - out_barriers, + out_barriers.push_back( GraphBarrier{ .pass_idx = last_pass, .source_layout = render::ImageLayout::Undefined, @@ -113,11 +111,10 @@ namespace ice::gfx ice::Array subpasses{ alloc }; ice::Array dependencies{ alloc }; - ice::array::reserve(attachments, resources.size().u32()); - ice::array::reserve(references, graph_snapshots.size().u32()); + attachments.reserve(resources.size().u32()); + references.reserve(graph_snapshots.size().u32()); - ice::array::push_back( - attachments, + attachments.push_back( RenderAttachment{ .format = swapchain.image_format(), .final_layout = ImageLayout::Present, @@ -138,8 +135,7 @@ namespace ice::gfx } else if (type == GfxResourceType::RenderTarget) { - ice::array::push_back( - attachments, + attachments.push_back( RenderAttachment{ .format = swapchain.image_format(), .final_layout = ImageLayout::ShaderReadOnly, @@ -153,8 +149,7 @@ namespace ice::gfx } else // if (type == GfxResourceType::DepthStencil) { - ice::array::push_back( - attachments, + attachments.push_back( RenderAttachment{ .format = ImageFormat::SFLOAT_D32_UINT_S8, .final_layout = ImageLayout::DepthStencil, @@ -178,11 +173,10 @@ namespace ice::gfx { if (subpass_idx > 1) { - ice::array::push_back( - subpasses, + subpasses.push_back( RenderSubPass{ - .input_attachments = ice::array::slice(references, ref_subpass_idx, counts[0]), - .color_attachments = ice::array::slice(references, ref_subpass_idx + counts[0], counts[1]), + .input_attachments = references.subspan(ref_subpass_idx, counts[0]), + .color_attachments = references.subspan(ref_subpass_idx + counts[0], counts[1]), .depth_stencil_attachment = counts[2] == 0 ? AttachmentReference{ } : references[ref_subpass_idx + counts[0] + counts[1]], } ); @@ -195,8 +189,7 @@ namespace ice::gfx { if (subpass_idx == 2) { - ice::array::push_back( - dependencies, + dependencies.push_back( SubpassDependency{ .source_subpass = subpass_idx - 2, .source_stage = PipelineStage::ColorAttachmentOutput, @@ -209,8 +202,7 @@ namespace ice::gfx } else { - ice::array::push_back( - dependencies, + dependencies.push_back( SubpassDependency{ .source_subpass = subpass_idx - 2, .source_stage = PipelineStage::ColorAttachmentOutput, @@ -234,8 +226,7 @@ namespace ice::gfx if (type == GfxResourceType::DepthStencil) { counts[2] += 1; - ice::array::push_back( - references, + references.push_back( AttachmentReference{ .attachment_index = idx, .layout = ImageLayout::DepthStencil @@ -245,8 +236,7 @@ namespace ice::gfx else if (graph_snapshot.event & GfxSnapshotEvent::EventWriteRes) { counts[1] += 1; - ice::array::push_back( - references, + references.push_back( AttachmentReference{ .attachment_index = idx, .layout = ImageLayout::Color @@ -256,8 +246,7 @@ namespace ice::gfx else { counts[0] += 1; - ice::array::push_back( - references, + references.push_back( AttachmentReference{ .attachment_index = idx, .layout = ImageLayout::ShaderReadOnly @@ -295,11 +284,10 @@ namespace ice::gfx ice::Array snapshots{ alloc }; ice::Array resources{ alloc }; - ice::array::push_back(resources, base_definition.get_framebuffer()); + resources.push_back(base_definition.get_framebuffer()); ice::u32 pass_idx = 0; - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = 0, .resource = { pass_idx++ }, @@ -311,8 +299,7 @@ namespace ice::gfx IceshardGfxGraphStages stages{ alloc }; for (GfxGraphPass const& pass : base_definition.passes()) { - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = pass_idx, .resource = { pass_idx }, @@ -323,12 +310,11 @@ namespace ice::gfx for (GfxGraphStage const& stage : pass.stages) { - ice::array::push_back(stages._stage_names, stage.name); + stages._stage_names.push_back(stage.name); for (GfxResource res : stage.inputs) { - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = pass_idx, .resource = res, @@ -339,8 +325,7 @@ namespace ice::gfx } for (GfxResource res : stage.outputs) { - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = pass_idx, .resource = res, @@ -351,8 +336,7 @@ namespace ice::gfx } for (GfxResource res : stage.depth_stencil) { - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = pass_idx, .resource = res, @@ -363,12 +347,11 @@ namespace ice::gfx } } - ice::array::push_back(stages._counts, pass.stages.size().u8()); + stages._counts.push_back(pass.stages.size().u8()); pass_idx += 1; } - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = pass_idx, .resource = { pass_idx }, @@ -398,7 +381,7 @@ namespace ice::gfx bool const res_created = (snapshot.event & GfxSnapshotEvent::EventCreateRes) != 0; if (res_created) { - ice::array::push_back(resources, snapshot.resource); + resources.push_back(snapshot.resource); } current_images += ice::u32(res_created); @@ -407,7 +390,7 @@ namespace ice::gfx } ice::sort( - ice::array::slice(resources), + resources.tailspan(0), [](GfxResource lhs, GfxResource rhs) noexcept { return (lhs.value & 0xffff) < (rhs.value & 0xffff); } ); diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx index b8153688..8eb9c268 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx @@ -62,7 +62,7 @@ namespace ice::gfx for (ice::StringID_Arg key : stage_keys) { ice::gfx::GfxStage* const* stage_ptr = ice::hashmap::try_get(_stages, ice::hash(key)); - ice::array::push_back(out_stages, stage_ptr == nullptr ? nullptr : *stage_ptr); + out_stages.push_back(stage_ptr == nullptr ? nullptr : *stage_ptr); result |= stage_ptr != nullptr; } return result; diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx index 6f280d25..7879d801 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx @@ -63,7 +63,7 @@ namespace ice::ecs auto store(ice::Array& out_entities, bool append = true) const noexcept { - if (append == false) ice::array::clear(out_entities); + if (append == false) out_entities.clear(); ice::array::push_back(out_entities, all()); } diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx index 766afedb..9e959a6a 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx @@ -274,7 +274,7 @@ namespace ice::ecs ) noexcept -> ice::u32 { // On a query with multiple parts we only want to check the blocks of the main part. - ice::Span const blocks_to_check = ice::array::slice(query.archetype_data_blocks, 0, query.archetype_count_for_part[0]); + ice::Span const blocks_to_check = query.archetype_data_blocks.headspan(query.archetype_count_for_part[0]); ice::u32 result = 0; for (ice::ecs::detail::DataBlock const* const head_block : blocks_to_check) @@ -299,7 +299,7 @@ namespace ice::ecs ) noexcept -> ice::u32 { // On a query with multiple parts we only want to check the blocks of the main part. - ice::Span const blocks_to_check = ice::array::slice(query.archetype_data_blocks, 0, query.archetype_count_for_part[0]); + ice::Span const blocks_to_check = query.archetype_data_blocks.headspan(query.archetype_count_for_part[0]); ice::u32 result = 0; for (ice::ecs::detail::DataBlock const* const head_block : blocks_to_check) @@ -356,8 +356,8 @@ namespace ice::ecs ICE_ASSERT_CORE(arch != nullptr && block != nullptr); void* helper_pointer_array[component_count]{ nullptr }; - ice::Span make_argument_idx_map = ice::array::slice( - query.archetype_argument_idx_map, arch_idx * component_count, component_count + ice::Span make_argument_idx_map = query.archetype_argument_idx_map.subspan( + arch_idx * component_count, component_count ); for (ice::u32 arg_idx = 0; arg_idx < component_count; ++arg_idx) @@ -386,9 +386,9 @@ namespace ice::ecs return ice::ecs::detail::create_entity_tuple_concat( ice::ecs::detail::create_entity_tuple(slotinfo.index, helper_pointer_array, MainPart{}), *query.provider, - ice::array::slice(query.archetype_instances, arch_count), - ice::array::slice(query.archetype_data_blocks, arch_count), - ice::array::slice(query.archetype_argument_idx_map, arch_count * component_count), + query.archetype_instances.headspan(arch_count), + query.archetype_data_blocks.headspan(arch_count), + query.archetype_argument_idx_map.headspan(arch_count * component_count), ice::Span{ query.archetype_count_for_part }.tailspan(1), RefParts{}... ); @@ -412,7 +412,7 @@ namespace ice::ecs { ice::ecs::detail::ArchetypeInstanceInfo const* arch = query_object.archetype_instances[arch_idx]; ice::ecs::detail::DataBlock const* block = query_object.archetype_data_blocks[arch_idx]; - ice::Span make_argument_idx_map = ice::array::slice(query_object.archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = query_object.archetype_argument_idx_map.subspan(arch_idx * component_count, component_count); // We skip the first block because it will be always empty. ICE_ASSERT_CORE(block->block_entity_count == 0); @@ -449,9 +449,9 @@ namespace ice::ecs co_yield ice::ecs::detail::create_entity_tuple_concat( ice::ecs::detail::create_entity_tuple(entity_idx, helper_pointer_array, MainPart{}), *query_object.provider, - ice::array::slice(query_object.archetype_instances, arch_count), - ice::array::slice(query_object.archetype_data_blocks, arch_count), - ice::array::slice(query_object.archetype_argument_idx_map, arch_count * component_count), + query_object.archetype_instances.headspan(arch_count), + query_object.archetype_data_blocks.headspan(arch_count), + query_object.archetype_argument_idx_map.headspan(arch_count * component_count), ice::Span{ query_object.archetype_count_for_part }.tailspan(1), RefParts{}... ); @@ -482,7 +482,9 @@ namespace ice::ecs { ice::ecs::detail::ArchetypeInstanceInfo const* arch = query_object.archetype_instances[arch_idx]; ice::ecs::detail::DataBlock const* block = query_object.archetype_data_blocks[arch_idx]; - ice::Span make_argument_idx_map = ice::array::slice(query_object.archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = query_object.archetype_argument_idx_map.subspan( + arch_idx * component_count, component_count + ); // We skip the first block because it will be always empty. ICE_ASSERT_CORE(block->block_entity_count == 0); @@ -523,9 +525,9 @@ namespace ice::ecs helper_pointer_array, // Ref parts *query_object.provider, - ice::array::slice(query_object.archetype_instances, arch_count), - ice::array::slice(query_object.archetype_data_blocks, arch_count), - ice::array::slice(query_object.archetype_argument_idx_map, arch_count * component_count), + query_object.archetype_instances.headspan(arch_count), + query_object.archetype_data_blocks.headspan(arch_count), + query_object.archetype_argument_idx_map.headspan(arch_count * component_count), ice::Span{ query_object.archetype_count_for_part }.tailspan(1), MainPart{}, RefParts{}... @@ -555,7 +557,9 @@ namespace ice::ecs { ice::ecs::detail::ArchetypeInstanceInfo const* arch = query.archetype_instances[arch_idx]; ice::ecs::detail::DataBlock const* block = query.archetype_data_blocks[arch_idx]; - ice::Span make_argument_idx_map = ice::array::slice(query.archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = query.archetype_argument_idx_map.subspan( + arch_idx* component_count, component_count + ); // We skip the first block because it will be always empty. ICE_ASSERT_CORE(block->block_entity_count == 0); diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx index 6ad5e5a3..3b59df06 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx @@ -97,7 +97,7 @@ namespace ice::ecs // Copy values to the array ice::u32* it = out_argument_idx_map.begin() + prev_arim_count; - for (ice::ecs::detail::ArchetypeInstanceInfo const* instance : ice::array::slice(out_instance_infos, prev_arch_count)) + for (ice::ecs::detail::ArchetypeInstanceInfo const* instance : out_instance_infos.tailspan(prev_arch_count)) { auto const archetype_argument_idx_map = ice::ecs::detail::make_argument_idx_map(*instance); ice::memcpy(it, archetype_argument_idx_map.data(), archetype_argument_idx_map.size() * sizeof(ice::u32)); diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx index c3067389..1ba67e81 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx @@ -156,7 +156,7 @@ namespace ice::gfx ) noexcept -> ice::UniquePtr { ice::Array queue_families{ alloc }; - ice::array::reserve(queue_families, 20); + queue_families.reserve(20); render_driver.query_queue_infos(queue_families); using ice::render::QueueFlags; @@ -164,7 +164,7 @@ namespace ice::gfx using ice::render::QueueID; ice::Array queues{ alloc }; - ice::array::reserve(queues, render_queues.size().u32()); + queues.reserve(render_queues.size().u32()); auto find_queue_index = [](auto const& array_, QueueID id_, ice::u32& idx_out) noexcept -> bool { @@ -195,8 +195,7 @@ namespace ice::gfx } else { - ice::array::push_back( - queues, + queues.push_back( QueueInfo{ .id = pass_queue_id, .count = 1 @@ -231,12 +230,11 @@ namespace ice::gfx if (render_device != nullptr) { ice::Array pass_groups{ alloc }; - ice::array::reserve(pass_groups, pass_group_count); + pass_groups.reserve(pass_group_count); for (ice::u32 group_pool_index = 0; group_pool_index < pass_group_count; ++group_pool_index) { - ice::array::push_back( - pass_groups, + pass_groups.push_back( alloc.create( alloc, render_queues.size().u32() diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx index e2e1a8c6..e4ef8f4c 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx @@ -28,7 +28,7 @@ namespace ice::gfx , _primary{ alloc } , _secondary{ alloc } { - ice::array::resize(_primary, 1); + _primary.resize(1); _render_queue->allocate_buffers( _queue_pool_index, ice::render::CommandBufferType::Primary, @@ -90,11 +90,10 @@ namespace ice::gfx if (available < required) { cmds.resize(used + required); - _render_queue->allocate_buffers(_queue_pool_index, type, ice::array::slice(cmds, used)); + _render_queue->allocate_buffers(_queue_pool_index, type, cmds.tailspan(used)); } - auto from = ice::array::slice(cmds, used); - + ice::Span from = cmds.tailspan(used); for (ice::u32 idx = 0; idx < required; ++idx) { out_buffers[idx] = from[idx]; diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx index d152bdc7..f996c53a 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx @@ -112,7 +112,7 @@ namespace ice::gfx { for (IceGfxQueue* queue : _gfx_queues) { - ice::array::push_back(out_names, ice::stringid_hash(queue->name())); + out_names.push_back(ice::stringid_hash(queue->name())); } } @@ -135,8 +135,7 @@ namespace ice::gfx ice::render::RenderQueue* render_queue = queue->render_queue(); if (has_queue(queues_out, render_queue) == false) { - ice::array::push_back( - queues_out, + queues_out.push_back( render_queue ); } diff --git a/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx b/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx index a87ada29..4a6994c7 100644 --- a/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx @@ -74,7 +74,7 @@ namespace ice auto do_allocate(ice::AllocRequest request) noexcept -> ice::AllocResult override { ice::AllocResult const r = _backing.allocate(request); - ice::array::push_back(_allocated, r.memory); + _allocated.push_back(r.memory); return r; } diff --git a/source/code/iceshard/iceshard/private/iceshard_frame.cxx b/source/code/iceshard/iceshard/private/iceshard_frame.cxx index f5d81817..19e69540 100644 --- a/source/code/iceshard/iceshard/private/iceshard_frame.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_frame.cxx @@ -45,7 +45,7 @@ namespace ice { if (count == 0) return { }; - ice::array::push_back(_task_groups, + _task_groups.push_back( TaskGroup{ .tasks = ice::Array>{ _frame_data._fwd_allocator }, .barrier = _frame_data._fwd_allocator.create() @@ -73,7 +73,7 @@ namespace ice { for (ice::Task<>& task : group.tasks) { - ice::array::push_back(final_task_list, ice::move(task)); + final_task_list.push_back(ice::move(task)); } group.tasks.clear(); } diff --git a/source/code/iceshard/iceshard/private/iceshard_runner.hxx b/source/code/iceshard/iceshard/private/iceshard_runner.hxx index 44004a4e..387a501e 100644 --- a/source/code/iceshard/iceshard/private/iceshard_runner.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_runner.hxx @@ -100,7 +100,7 @@ namespace ice void execute(ice::Task<> task) noexcept override { - ice::array::push_back(_pending_tasks, ice::move(task)); + _pending_tasks.push_back(ice::move(task)); } auto execute_internal(ice::Task<> task) noexcept -> ice::Task<> @@ -119,7 +119,7 @@ namespace ice // We schedule the task on the given scheduler. ice::schedule_task(execute_internal(ice::move(pending_task)), _scheduler); } - ice::array::clear(_pending_tasks); + _pending_tasks.clear(); } void wait_all() noexcept diff --git a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx index 8a1538a6..2feaa4ef 100644 --- a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx @@ -53,7 +53,7 @@ namespace ice } else { - ice::array::push_back(_events, event); + _events.push_back(event); } } @@ -71,7 +71,7 @@ namespace ice // Copy all current events into the _expired events list. // We use copy+clean so we don't allocate one of the arrays every time. _events_expired = _events; - ice::array::clear(_events); + _events.clear(); // Push shards into the out container. (ice::detail::TraitEvent decays into ice::Shard) for (ice::Shard shard : _events_expired) diff --git a/source/code/iceshard/iceshard/private/iceshard_world.cxx b/source/code/iceshard/iceshard/private/iceshard_world.cxx index d888d638..a1db37cd 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world.cxx @@ -23,7 +23,7 @@ namespace ice , _entity_query_storage{ _allocator, _entity_storage } , _entity_operations{ _allocator, entities, entity_storage.archetypes(), 16 } , _traits{ ice::move(traits) } - , _tasks_launcher{ context, ice::array::slice(_traits), task_tracker } + , _tasks_launcher{ context, _traits, task_tracker } , _devui{ create_devui(_allocator, context) } { } diff --git a/source/code/iceshard/iceshard/private/iceshard_world_context.cxx b/source/code/iceshard/iceshard/private/iceshard_world_context.cxx index 19a86c7a..1a9b02e7 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_context.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_context.cxx @@ -8,7 +8,8 @@ namespace ice { IceshardWorldContext::IceshardWorldContext(ice::Allocator& alloc, ice::StringID_Arg worldid) noexcept - : _allocator{ alloc, ice::stringid_hint(worldid) } + : _world_name{ alloc, ice::stringid_hint(worldid) } + , _allocator{ alloc, ice::String{ _world_name } } , _always_reached_checkpoint{ true } , _checkpoints{ alloc } , _frame_handlers{ diff --git a/source/code/iceshard/iceshard/private/iceshard_world_context.hxx b/source/code/iceshard/iceshard/private/iceshard_world_context.hxx index 55085046..b490995b 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_context.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_context.hxx @@ -40,6 +40,7 @@ namespace ice void close_checkpoints() noexcept; private: + ice::HeapString<> _world_name; ice::ProxyAllocator _allocator; ice::UniquePtr _world; diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx index f9c3684c..bd5bbb67 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx @@ -126,7 +126,7 @@ namespace ice if (trait != nullptr) { trait_context->trait = ice::move(trait); - ice::array::push_back(world_traits, ice::move(trait_context)); + world_traits.push_back(ice::move(trait_context)); } } } @@ -190,14 +190,14 @@ namespace ice { if (entry.is_active) { - ice::array::push_back(out_worlds, entry.world->worldID); + out_worlds.push_back(entry.world->worldID); } } } void IceshardWorldManager::query_pending_events(ice::ShardContainer& out_events) noexcept { - ice::shards::push_back(out_events, ice::array::slice(_pending_events._data)); + ice::shards::push_back(out_events, _pending_events._data); ice::shards::clear(_pending_events); } diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx index 4c6551f1..40a25662 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx @@ -43,7 +43,7 @@ namespace ice // Always ensure same size - ice::array::resize(_entries, ice::hashmap::count(_manager._worlds)); + _entries.resize(ice::hashmap::count(_manager._worlds)); [[maybe_unused]] ImVec2 const avail = ImGui::GetContentRegionAvail(); diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx index e4b5f14b..0d5fe4bb 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx @@ -17,7 +17,7 @@ namespace ice , _snapshots{ _allocator } { ice::devui_register_widget(this); - ice::array::resize(_tracked_task_events, 500); + _tracked_task_events.resize(500); } auto TraitTasksTrackerDevUI::report_resume(ice::u32 id) noexcept -> ice::u32 @@ -62,8 +62,8 @@ namespace ice _stat_events = _current_event_count.exchange(1, std::memory_order_relaxed); if (_stat_events >= _tracked_task_events.size()) { - ice::array::grow(_tracked_task_events, _stat_events); - ice::array::resize(_tracked_task_events, _stat_events); + _tracked_task_events.grow(_stat_events); + _tracked_task_events.resize(_stat_events); } } @@ -72,7 +72,9 @@ namespace ice ImGui::TextT("Collected events: {}", _stat_events - 1); if (ImGui::Button("Take snapshot")) { - ice::array::push_back(_snapshots, TraitTasksSnapshot{ _allocator, ice::array::slice(_tracked_task_events, 0, _stat_events) }); + _snapshots.push_back( + TraitTasksSnapshot{ _allocator, _tracked_task_events.headspan(_stat_events) } + ); } for (ice::TraitTasksSnapshot& snapshot : _snapshots) @@ -80,7 +82,7 @@ namespace ice if (snapshot._release == true) { snapshot._release = false; - ice::array::clear(snapshot._events); + snapshot._events.clear(); } else if (snapshot._events.not_empty()) { @@ -98,7 +100,7 @@ namespace ice ice::u32 first_entry = 1; ice::u32 const last_entry = _events.size().u32(); - EventEntry const* entries = ice::begin(_events); + EventEntry const* entries = _events.begin(); ice::u32 running = 0; EventEntry const* concurrent[32]{}; diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx index 38c827d3..583adef2 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx @@ -98,8 +98,7 @@ namespace ice : _traits[handler.trait_idx]->trait.get(); //ICE_ASSERT(ice::array::count(out_tasks) < ice::array::capacity(out_tasks), "Maximum number of tasks suppored by default launcher reached!"); - ice::array::push_back( - out_tasks, + out_tasks.push_back( handler.procedure(userdata, params, shard) ); diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx index ced28b9d..4b02faef 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx @@ -525,18 +525,18 @@ namespace ice { ice::Array uishards{ alloc }; - ice::array::reserve(uishards, 25); - ice::array::push_back(uishards, RawShard{ }); + uishards.reserve(25); + uishards.push_back(RawShard{ }); ice::Array uires{ alloc }; - ice::array::reserve(uires, 25); + uires.reserve(25); ice::Array styles{ alloc }; - ice::array::reserve(styles, 25); - ice::array::push_back(styles, RawStyle{ .flags = ice::ui::StyleFlags::None }); + styles.reserve(25); + styles.push_back(RawStyle{ .flags = ice::ui::StyleFlags::None }); ice::Array elements{ alloc }; - ice::array::reserve(elements, 50); + elements.reserve(50); rapidxml_ns::xml_document* doc = alloc.create>(); doc->parse(reinterpret_cast(data_copy.location)); diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx index 634cc42c..1cfb7be3 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx @@ -122,7 +122,7 @@ namespace ice xml_prop = ice::xml_next_sibling(xml_prop); } - ice::array::push_back(styles, style); + styles.push_back(style); } xml_child = ice::xml_next_sibling( @@ -212,10 +212,7 @@ namespace ice if (uiref && res.type != ResourceType::None) { - ice::array::push_back( - shards, - res - ); + shards.push_back(res); } xml_child = ice::xml_next_sibling( @@ -252,8 +249,7 @@ namespace ice if (uiref && attr_name) { - ice::array::push_back( - shards, + shards.push_back( ice::RawShard { .ui_name = ice::xml_value(uiref), @@ -279,10 +275,7 @@ namespace ice { ice::u16 const element_index = elements.size().u16(); - ice::array::push_back( - elements, - ice::RawElement{ .parent = parent_idx } - ); + elements.push_back(ice::RawElement{ .parent = parent_idx }); parse_element_attribs( alloc, diff --git a/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx b/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx index 0cdfb47e..d2774fd9 100644 --- a/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx +++ b/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx @@ -188,14 +188,8 @@ namespace ice::devui _pipeline = device.create_pipeline(pipeline_info); _index_buffer_host = _index_buffers._allocator->allocate(1024 * 1024 * 32); - ice::array::push_back( - _index_buffers, - device.create_buffer(BufferType::Index, 1024 * 1024 * 64) - ); - ice::array::push_back( - _vertex_buffers, - device.create_buffer(BufferType::Vertex, 1024 * 1024 * 64) - ); + _index_buffers.push_back(device.create_buffer(BufferType::Index, 1024 * 1024 * 64)); + _vertex_buffers.push_back(device.create_buffer(BufferType::Vertex, 1024 * 1024 * 64)); co_return; } @@ -215,8 +209,8 @@ namespace ice::devui { device.destroy_buffer(buffer); } - ice::array::clear(_index_buffers); - ice::array::clear(_vertex_buffers); + _index_buffers.clear(); + _vertex_buffers.clear(); device.destroy_buffer(_uniform_buffer); device.destroy_pipeline(_pipeline); diff --git a/source/code/modules/imgui_module/private/imgui_system.cxx b/source/code/modules/imgui_module/private/imgui_system.cxx index 5bb5cba6..b56b6272 100644 --- a/source/code/modules/imgui_module/private/imgui_system.cxx +++ b/source/code/modules/imgui_module/private/imgui_system.cxx @@ -77,7 +77,7 @@ namespace ice::devui , _widget_logger{ _allocator } , _widget_style{ _allocator } { - ice::array::push_back(_builtin_widgets, create_allocator_tree_widget(_allocator)); + _builtin_widgets.push_back(create_allocator_tree_widget(_allocator)); // ice::array::push_back(_builtin_widgets, (ice::UniquePtr) ice::make_unique(_allocator, _allocator)); // Register all built-in's @@ -100,10 +100,10 @@ namespace ice::devui void ImGuiSystem::setup_mainmenu(ice::Span categories) noexcept { - ice::array::clear(_menu_categories); + _menu_categories.clear(); for (ice::String category : categories) { - ice::array::push_back(_menu_categories, ice::HeapString<>{ _allocator, category }); + _menu_categories.push_back({ _allocator, category }); } } diff --git a/source/code/modules/imgui_module/private/imgui_trait.cxx b/source/code/modules/imgui_module/private/imgui_trait.cxx index b1c0869c..b9fdb713 100644 --- a/source/code/modules/imgui_module/private/imgui_trait.cxx +++ b/source/code/modules/imgui_module/private/imgui_trait.cxx @@ -483,7 +483,7 @@ namespace ice::devui IPT_ZONE_SCOPED; _stats = {}; // reset stats - ice::array::clear(_imgui_gfx_stage->draw_commands); + _imgui_gfx_stage->draw_commands.clear(); ImDrawData* draw_data = ImGui::GetDrawData(); if (draw_data == nullptr) @@ -492,8 +492,7 @@ namespace ice::devui } // Reserve enough space for all possible commands - ice::array::reserve( - _imgui_gfx_stage->draw_commands, + _imgui_gfx_stage->draw_commands.reserve( detail::total_command_count(*draw_data) ); @@ -529,7 +528,7 @@ namespace ice::devui curr_resource_idx += 1; } - ice::array::push_back(out_draw_cmds, ImGuiGfxStage::DrawCommand{}); + out_draw_cmds.push_back(ImGuiGfxStage::DrawCommand{}); ImGuiGfxStage::DrawCommand& cmd = out_draw_cmds.last(); cmd.resource_set_idx = curr_resource_idx; diff --git a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx index 05cded45..728aaf39 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx @@ -23,8 +23,8 @@ namespace ice::devui , _allocator{ alloc } , _widgets{ alloc } { - ice::array::reserve(_widgets, 100); - ice::array::push_back(_widgets, ice::make_unique(_allocator)); + _widgets.reserve(100); + _widgets.push_back(ice::make_unique(_allocator)); } ImGuiDevUIManager::~ImGuiDevUIManager() noexcept @@ -48,7 +48,7 @@ namespace ice::devui owner_state = ice::addressof(_widgets[owner_idx]->state); } - ice::array::push_back(_widgets, + _widgets.push_back( ice::make_unique(_allocator, ImGuiDevUIWidget{ .state = {.owner = owner_state }, @@ -104,7 +104,7 @@ namespace ice::devui ImGui::TableSetupColumn("Visible"); ImGui::TableHeadersRow(); - for (auto const& widget : ice::array::slice(_widgets, 1)) + for (auto const& widget : _widgets.tailspan()) { ImGui::TableNextRow(); diff --git a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx index fd63d55a..f37d605f 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx @@ -29,7 +29,7 @@ namespace ice::devui ) noexcept; void remove_widget(ice::DevUIWidget* widget) noexcept; - auto widgets() noexcept -> ice::Span const> { return ice::array::slice(_widgets, 1); } + auto widgets() noexcept -> ice::Span const> { return _widgets.tailspan(); } void build_content() noexcept override; diff --git a/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx b/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx index e21c36ee..9cd4c269 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx @@ -65,8 +65,8 @@ namespace ice::devui , _entries{ LoggerAlloc } , _entries_visible{ LoggerAlloc } { - ice::array::reserve(_entries, 2000); - ice::array::reserve(_entries_visible, 2000); + _entries.reserve(2000); + _entries_visible.reserve(2000); } ImGuiLogger::~ImGuiLogger() noexcept @@ -78,8 +78,8 @@ namespace ice::devui void ImGuiLogger::add_entry(ice::LogSinkMessage const& message) noexcept { std::lock_guard lk{ mtx }; - ice::array::push_back(_entries_visible, _entries.size().u32()); - ice::array::push_back(_entries, { message.severity, message.tag, message.tag_name, {LoggerAlloc,message.message} }); + _entries_visible.push_back(_entries.size().u32()); + _entries.push_back({ message.severity, message.tag, message.tag_name, {LoggerAlloc,message.message} }); } static inline auto severity_color(ice::LogSeverity sev) noexcept -> ImGuiColorCtx @@ -210,8 +210,8 @@ namespace ice::devui ice::f64 const max_match = _entries[_entries_visible[0]].filter_match; ice::sort_indices( - ice::array::slice(_entries), - ice::array::slice(_entries_visible), + _entries.tailspan(0), + _entries_visible.tailspan(0), [max_match](ImGuiLogEntry const& l, ImGuiLogEntry const& r) noexcept { if (l.filter_match == r.filter_match && r.filter_match >= max_match) diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx b/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx index 503af543..e63a37c1 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx @@ -92,12 +92,12 @@ namespace ice void ASLImportTracker::track_script(ASLScriptFile* file) noexcept { // Store the tracker pointer in a list. - ice::array::push_back(_global, file); + _global.push_back(file); } void ASLImportTracker::add_visitor(arctic::SyntaxVisitor* visitor) noexcept { - ice::array::push_back(_script_visitors, visitor); + _script_visitors.push_back(visitor); } auto ASLImportTracker::find(arctic::String identifier) noexcept -> arctic::SyntaxNode<> @@ -182,7 +182,7 @@ namespace ice } // Store the tracker pointer in a list. - ice::array::push_back(_global, import_entry.file.get()); + _global.push_back(import_entry.file.get()); // Store the whole entry. ice::multi_hashmap::insert(_imports, detail::arc_hash(node.data().path), ice::move(import_entry)); @@ -216,8 +216,8 @@ namespace ice result = ice::make_unique(alloc._backing, alloc, asl_alias); ice::Array final_visitors{ alloc._backing, visitors }; - ice::array::push_back(final_visitors, &imports); - ice::array::push_back(final_visitors, result.get()); + final_visitors.push_back(&imports); + final_visitors.push_back(result.get()); if (parser->parse(lexer, alloc, final_visitors) == false) { diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx b/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx index 56f1c2b9..17102287 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx @@ -77,7 +77,7 @@ namespace ice prev = std::exchange(member, member.sibling()); } - ice::array::push_back(_structs, ice::move(node)); + _structs.push_back(ice::move(node)); } } @@ -146,7 +146,7 @@ namespace ice } } - ice::array::push_back(_functions, node); + _functions.push_back(node); } void ASLShader::visit(arctic::SyntaxNode node) noexcept @@ -181,7 +181,7 @@ namespace ice else if (detail::arc_annotation(var, "uniform", annotation)) { ICE_ASSERT_CORE(var.data().is_reference == false); // not supported in shaders - ice::array::push_back(_uniforms, var); + _uniforms.push_back(var); } else { diff --git a/source/code/modules/vulkan_renderer/private/vk_device.cxx b/source/code/modules/vulkan_renderer/private/vk_device.cxx index 0363cbaf..b739e74e 100644 --- a/source/code/modules/vulkan_renderer/private/vk_device.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_device.cxx @@ -212,13 +212,13 @@ namespace ice::render::vk auto VulkanRenderDevice::create_renderpass(ice::render::RenderpassInfo const& info) noexcept -> ice::render::Renderpass { ice::Array attachments{ _allocator }; - ice::array::reserve(attachments, info.attachments.size().u32()); + attachments.reserve(info.attachments.size().u32()); ice::Array subpass_list{ _allocator }; - ice::array::reserve(subpass_list, info.subpasses.size().u32()); + subpass_list.reserve(info.subpasses.size().u32()); ice::Array dependencies { _allocator }; - ice::array::reserve(dependencies, info.dependencies.size().u32()); + dependencies.reserve(info.dependencies.size().u32()); ice::Array attachment_references{ _allocator }; @@ -244,7 +244,7 @@ namespace ice::render::vk attachment.initialLayout = native_enum_value(attachment_info.initial_layout);; attachment.finalLayout = native_enum_value(attachment_info.final_layout); - ice::array::push_back(attachments, attachment); + attachments.push_back(attachment); } ice::u64 reference_count = 0; @@ -255,7 +255,7 @@ namespace ice::render::vk + 1; } - ice::array::reserve(attachment_references, static_cast(reference_count)); + attachment_references.reserve(static_cast(reference_count)); auto store_references = [&attachment_references](ice::Span references) noexcept -> ice::u32 { @@ -266,7 +266,7 @@ namespace ice::render::vk reference.attachment = attachment_ref.attachment_index; reference.layout = native_enum_value(attachment_ref.layout); - ice::array::push_back(attachment_references, reference); + attachment_references.push_back(reference); } return ref_index; }; @@ -294,7 +294,7 @@ namespace ice::render::vk subpass.pDepthStencilAttachment = std::addressof(attachment_references[depth_ref_idx]); } - ice::array::push_back(subpass_list, subpass); + subpass_list.push_back(subpass); } for (SubpassDependency const& dependency_info : info.dependencies) @@ -308,7 +308,7 @@ namespace ice::render::vk dependency.dstAccessMask = native_enum_value(dependency_info.destination_access); dependency.dependencyFlags = VkDependencyFlagBits::VK_DEPENDENCY_BY_REGION_BIT; - ice::array::push_back(dependencies, dependency); + dependencies.push_back(dependency); } VkRenderPassCreateInfo renderpass_info{ VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO }; @@ -343,12 +343,11 @@ namespace ice::render::vk ) noexcept -> ice::render::ResourceSetLayout { ice::Array vk_bindings{ _allocator }; - ice::array::reserve(vk_bindings, bindings.size().u32()); + vk_bindings.reserve(bindings.size().u32()); for (ResourceSetLayoutBinding const& binding : bindings) { - ice::array::push_back( - vk_bindings, + vk_bindings.push_back( VkDescriptorSetLayoutBinding{ .binding = binding.binding_index, .descriptorType = native_enum_value(binding.resource_type), @@ -361,7 +360,7 @@ namespace ice::render::vk VkDescriptorSetLayoutCreateInfo layout_info{ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO }; layout_info.bindingCount = bindings.size().u32(); - layout_info.pBindings = ice::begin(vk_bindings); + layout_info.pBindings = vk_bindings.begin(); VkDescriptorSetLayout vk_descriptor_set_layout = vk_nullptr; VkResult result = vkCreateDescriptorSetLayout( @@ -448,7 +447,7 @@ namespace ice::render::vk ) noexcept { ice::Array vk_writes{ _allocator }; - ice::array::reserve(vk_writes, update_infos.size().u32()); + vk_writes.reserve(update_infos.size().u32()); ice::Array write_image_info{ _allocator }; ice::Array write_buffer_info{ _allocator }; @@ -468,7 +467,7 @@ namespace ice::render::vk image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; image_info.imageView = image_ptr->vk_image_view; - ice::array::push_back(write_image_info, image_info); + write_image_info.push_back(image_info); } } @@ -481,7 +480,7 @@ namespace ice::render::vk VkDescriptorImageInfo sampler_info; sampler_info.sampler = vk_sampler; - ice::array::push_back(write_image_info, sampler_info); + write_image_info.push_back(sampler_info); } } @@ -498,7 +497,7 @@ namespace ice::render::vk buffer_info.offset = resource_info.uniform_buffer.offset; buffer_info.range = resource_info.uniform_buffer.size; - ice::array::push_back(write_buffer_info, buffer_info); + write_buffer_info.push_back(buffer_info); } } } @@ -516,23 +515,23 @@ namespace ice::render::vk if (update_info.resource_type == ResourceType::SampledImage || update_info.resource_type == ResourceType::InputAttachment) { - descriptor_set_write.pImageInfo = ice::array::begin(write_image_info) + images_offset; + descriptor_set_write.pImageInfo = write_image_info.begin() + images_offset; images_offset += update_info.resources.size().u32(); } if (update_info.resource_type == ResourceType::Sampler) { - descriptor_set_write.pImageInfo = ice::array::begin(write_image_info) + images_offset; + descriptor_set_write.pImageInfo = write_image_info.begin() + images_offset; images_offset += update_info.resources.size().u32(); } if (update_info.resource_type == ResourceType::UniformBuffer) { - descriptor_set_write.pBufferInfo = ice::array::begin(write_buffer_info) + buffers_offset; + descriptor_set_write.pBufferInfo = write_buffer_info.begin() + buffers_offset; buffers_offset += update_info.resources.size().u32(); } - ice::array::push_back(vk_writes, descriptor_set_write); + vk_writes.push_back(descriptor_set_write); } vkUpdateDescriptorSets( @@ -548,15 +547,14 @@ namespace ice::render::vk ) noexcept -> ice::render::PipelineLayout { ice::Array vk_push_constants{ _allocator }; - ice::array::reserve(vk_push_constants, info.push_constants.size().u32()); + vk_push_constants.reserve(info.push_constants.size().u32()); ice::Array vk_descriptorset_layouts{ _allocator }; - ice::array::reserve(vk_descriptorset_layouts, info.resource_layouts.size().u32()); + vk_descriptorset_layouts.reserve(info.resource_layouts.size().u32()); for (PipelinePushConstant const& push_constant : info.push_constants) { - ice::array::push_back( - vk_push_constants, + vk_push_constants.push_back( VkPushConstantRange{ .stageFlags = native_enum_flags(push_constant.shader_stage_flags), .offset = push_constant.offset, @@ -567,17 +565,16 @@ namespace ice::render::vk for (ResourceSetLayout layout : info.resource_layouts) { - ice::array::push_back( - vk_descriptorset_layouts, + vk_descriptorset_layouts.push_back( native_handle(layout) ); } VkPipelineLayoutCreateInfo pipeline_info{ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; pipeline_info.pushConstantRangeCount = info.push_constants.size().u32(); - pipeline_info.pPushConstantRanges = ice::begin(vk_push_constants); + pipeline_info.pPushConstantRanges = vk_push_constants.begin(); pipeline_info.setLayoutCount = info.resource_layouts.size().u32(); - pipeline_info.pSetLayouts = ice::begin(vk_descriptorset_layouts); + pipeline_info.pSetLayouts = vk_descriptorset_layouts.begin(); VkPipelineLayout pipeline_layout = vk_nullptr; VkResult result = vkCreatePipelineLayout( @@ -695,8 +692,8 @@ namespace ice::render::vk ice::Array vertex_input_bindings{ _allocator }; ice::Array vertex_input_attributes{ _allocator }; - ice::array::reserve(vertex_input_bindings, info.vertex_bindings.size().u32()); - ice::array::reserve(vertex_input_attributes, info.vertex_bindings.size().u32() * 4); + vertex_input_bindings.reserve(info.vertex_bindings.size().u32()); + vertex_input_attributes.reserve(info.vertex_bindings.size().u32() * 4); for (ice::render::ShaderInputBinding const& binding : info.vertex_bindings) { @@ -704,7 +701,7 @@ namespace ice::render::vk vk_binding.binding = binding.binding; vk_binding.stride = binding.stride; vk_binding.inputRate = static_cast(binding.instanced); - ice::array::push_back(vertex_input_bindings, vk_binding); + vertex_input_bindings.push_back(vk_binding); for (ice::render::ShaderInputAttribute const& attrib : binding.attributes) { @@ -713,7 +710,7 @@ namespace ice::render::vk vk_attrib.location = attrib.location; vk_attrib.offset = attrib.offset; vk_attrib.binding = binding.binding; - ice::array::push_back(vertex_input_attributes, vk_attrib); + vertex_input_attributes.push_back(vk_attrib); } } @@ -957,12 +954,12 @@ namespace ice::render::vk VkRenderPass vk_renderpass = reinterpret_cast(static_cast(renderpass)); ice::Array vk_images{ _allocator }; - ice::array::reserve(vk_images, images.size().u32()); + vk_images.reserve(images.size().u32()); for (Image image : images) { VulkanImage* const image_ptr = reinterpret_cast(static_cast(image)); - ice::array::push_back(vk_images, image_ptr->vk_image_view); + vk_images.push_back(image_ptr->vk_image_view); } VkFramebufferCreateInfo fb_info{ VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO }; @@ -1095,7 +1092,7 @@ namespace ice::render::vk vkGetDeviceQueue(_vk_device, queue_family_index, queue_index, &queue); ice::Array cmd_pools{ _allocator }; - ice::array::reserve(cmd_pools, command_pools); + cmd_pools.reserve(command_pools); for (ice::u32 idx = 0; idx < command_pools; ++idx) { @@ -1110,7 +1107,7 @@ namespace ice::render::vk "Failed to create command pool for device!" ); - ice::array::push_back(cmd_pools, vk_cmd_pool); + cmd_pools.push_back(vk_cmd_pool); } const bool profiled = ice::has_any(flags, QueueFlags::Compute | QueueFlags::Graphics); diff --git a/source/code/modules/vulkan_renderer/private/vk_driver.cxx b/source/code/modules/vulkan_renderer/private/vk_driver.cxx index 9dbeee78..f1f54f74 100644 --- a/source/code/modules/vulkan_renderer/private/vk_driver.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_driver.cxx @@ -310,7 +310,7 @@ namespace ice::render::vk } ice::u32 queue_index = 0; - ice::array::reserve(queue_info, queue_count); + queue_info.reserve(queue_count); for (VkQueueFamilyProperties const& queue_family_props : _vk_queue_family_properties) { QueueFlags flags = QueueFlags::None; @@ -332,8 +332,7 @@ namespace ice::render::vk flags = flags | QueueFlags::Present; } - ice::array::push_back( - queue_info, + queue_info.push_back( QueueFamilyInfo{ .id = QueueID{ queue_index }, .flags = flags, @@ -357,7 +356,7 @@ namespace ice::render::vk }; ice::Array queue_create_infos{ _allocator }; - ice::array::reserve(queue_create_infos, 3); + queue_create_infos.reserve(3); for (QueueInfo const& queue_info : queue_infos) { @@ -368,7 +367,7 @@ namespace ice::render::vk queue_create_info.queueCount = queue_info.count; queue_create_info.pQueuePriorities = queue_priorities; - ice::array::push_back(queue_create_infos, queue_create_info); + queue_create_infos.push_back(queue_create_info); } ice::u32 count_extensions = 0; @@ -387,8 +386,8 @@ namespace ice::render::vk VkDeviceCreateInfo device_create_info{ .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO }; device_create_info.pEnabledFeatures = &enabled_device_features; device_create_info.enabledExtensionCount = count_extensions; - device_create_info.ppEnabledExtensionNames = ice::array::begin(extension_names); - device_create_info.pQueueCreateInfos = ice::array::begin(queue_create_infos); + device_create_info.ppEnabledExtensionNames = extension_names.begin(); + device_create_info.pQueueCreateInfos = queue_create_infos.begin(); device_create_info.queueCreateInfoCount = queue_create_infos.size().u32(); VkDevice vk_device; diff --git a/source/code/modules/vulkan_renderer/private/vk_extensions.cxx b/source/code/modules/vulkan_renderer/private/vk_extensions.cxx index f67fb0bd..39c16cce 100644 --- a/source/code/modules/vulkan_renderer/private/vk_extensions.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_extensions.cxx @@ -58,7 +58,7 @@ namespace ice::render::vk { result |= supported.extension; out_count += 1; - ice::array::push_back(out_names, supported.identifier); + out_names.push_back(supported.identifier); } } } @@ -94,7 +94,7 @@ namespace ice::render::vk { result |= supported.extension; out_count += 1; - ice::array::push_back(out_names, supported.identifier); + out_names.push_back(supported.identifier); } } } @@ -130,7 +130,7 @@ namespace ice::render::vk { result |= supported.extension; out_count += 1; - ice::array::push_back(out_names, supported.identifier); + out_names.push_back(supported.identifier); } } } diff --git a/source/code/modules/vulkan_renderer/private/vk_module.cxx b/source/code/modules/vulkan_renderer/private/vk_module.cxx index e12dbab9..ab043073 100644 --- a/source/code/modules/vulkan_renderer/private/vk_module.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_module.cxx @@ -36,16 +36,16 @@ namespace ice::render::vk instance_create_info.flags = 0; instance_create_info.pApplicationInfo = &app_info; instance_create_info.enabledLayerCount = layer_count; - instance_create_info.ppEnabledLayerNames = ice::array::begin(names); + instance_create_info.ppEnabledLayerNames = names.begin(); instance_create_info.enabledExtensionCount = extension_count; - instance_create_info.ppEnabledExtensionNames = ice::array::begin(names) + layer_count; + instance_create_info.ppEnabledExtensionNames = names.begin() + layer_count; VkInstance vk_instance; VkResult const vk_create_result = vkCreateInstance(&instance_create_info, vk_alloc->vulkan_callbacks(), &vk_instance); ICE_ASSERT(vk_create_result == VkResult::VK_SUCCESS, "Creation of Vulkan instance failed!"); // Release the array backing data - ice::array::set_capacity(names, 0); + names.set_capacity(0); return alloc.create(alloc, ice::move(vk_alloc), vk_instance, extensions); } diff --git a/source/code/modules/vulkan_renderer/private/vk_utility.hxx b/source/code/modules/vulkan_renderer/private/vk_utility.hxx index 1a4cf583..6dbd8ce5 100644 --- a/source/code/modules/vulkan_renderer/private/vk_utility.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_utility.hxx @@ -86,8 +86,8 @@ namespace ice::render::vk fn(args..., &obj_count, nullptr); if (obj_count > 0) { - ice::array::resize(objects_out, obj_count); - fn(args..., &obj_count, ice::array::begin(objects_out)); + objects_out.resize(obj_count); + fn(args..., &obj_count, objects_out.begin()); } return true; } @@ -97,9 +97,9 @@ namespace ice::render::vk VkResult result = fn(args..., &obj_count, nullptr); if (result == VkResult::VK_SUCCESS && obj_count > 0) { - ice::array::resize(objects_out, obj_count); + objects_out.resize(obj_count); - result = fn(args..., &obj_count, ice::array::begin(objects_out)); + result = fn(args..., &obj_count, objects_out.begin()); } return result == VK_SUCCESS; } diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx index 7ffa5dd0..e7c4e852 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx @@ -20,7 +20,7 @@ namespace ice::platform::win32::sdl2 , _render_surface{ } { ice::shards::reserve(_system_events, 32); - ice::array::reserve(_input_events._events, 512); + _input_events._events.reserve(512); SDL_InitSubSystem(SDL_INIT_EVENTS); diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx index 8531a006..d4598da8 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx @@ -26,7 +26,7 @@ namespace ice::platform::win32::sdl2 auto refresh_events() noexcept -> ice::Result override; auto system_events() noexcept -> ice::ShardContainer const& override { return _system_events; } - auto input_events() noexcept -> ice::Span override { return ice::array::slice(_input_events._events); } + auto input_events() noexcept -> ice::Span override { return _input_events._events; } auto allocator() noexcept -> ice::Allocator& { return _alloc.backing_allocator(); } diff --git a/source/code/systems/asset_system/private/asset_storage.cxx b/source/code/systems/asset_system/private/asset_storage.cxx index 15e1c5c0..cc0a34b0 100644 --- a/source/code/systems/asset_system/private/asset_storage.cxx +++ b/source/code/systems/asset_system/private/asset_storage.cxx @@ -93,11 +93,11 @@ namespace ice // If empty we add our own handle to the list if (sources.is_empty()) { - ice::array::push_back(sources, resource); + sources.push_back(resource); } ice::Array> tasks{ alloc }; - ice::array::reserve(tasks, sources.size()); + tasks.reserve(sources.size()); auto fn_validate = [&ctx]( ice::ResourceCompiler const& compiler, @@ -116,12 +116,12 @@ namespace ice std::atomic_bool all_sources_valid = true; for (ice::ResourceHandle const& source : sources) { - ice::array::push_back(tasks, fn_validate(compiler, source, resource_tracker, all_sources_valid)); + tasks.push_back(fn_validate(compiler, source, resource_tracker, all_sources_valid)); } co_await ice::await_tasks(tasks); - ice::array::clear(tasks); + tasks.clear(); // Validation failed if (all_sources_valid == false) @@ -156,8 +156,7 @@ namespace ice ice::u32 source_idx = 0; for (ice::ResourceHandle const& source : sources) { - ice::array::push_back( - tasks, + tasks.push_back( fn_compile( compiler, source, @@ -256,7 +255,7 @@ namespace ice if constexpr (ice::build::is_debug || ice::build::is_develop) { - ice::array::push_back(shelves, ice::make_unique(_allocator, *shelve)); + shelves.push_back(ice::make_unique(_allocator, *shelve)); } } diff --git a/source/code/systems/asset_system/private/asset_type_archive.cxx b/source/code/systems/asset_system/private/asset_type_archive.cxx index 4705d643..ed0a06b6 100644 --- a/source/code/systems/asset_system/private/asset_type_archive.cxx +++ b/source/code/systems/asset_system/private/asset_type_archive.cxx @@ -103,7 +103,7 @@ namespace ice } } - ice::array::push_back(_types, category); + _types.push_back(category); ice::hashmap::set( _definitions, type_hash, diff --git a/source/code/systems/input_action_system/private/input_action_layer.cxx b/source/code/systems/input_action_system/private/input_action_layer.cxx index ced42209..6b8355db 100644 --- a/source/code/systems/input_action_system/private/input_action_layer.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer.cxx @@ -486,7 +486,7 @@ namespace ice void on_layer_parsed(ice::UniquePtr layer) noexcept override { - ice::array::push_back(results, ice::move(layer)); + results.push_back(ice::move(layer)); } } parser{ alloc }; diff --git a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx index f092f9f4..86d4faa5 100644 --- a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx @@ -125,20 +125,17 @@ namespace ice : allocator{ alloc } , conditions{ alloc } { - ice::array::reserve(conditions, 4); + conditions.reserve(4); } void add_step(ActionBuilderStep&& step) noexcept { - ice::array::push_back( - conditions.last().steps, - ice::move(step) - ); + conditions.last().steps.push_back(ice::move(step)); } void add_condition(ActionBuilderCondition&& condition) noexcept { - ice::array::push_back(conditions, ice::move(condition)); + conditions.push_back(ice::move(condition)); } void finalize() noexcept @@ -168,8 +165,8 @@ namespace ice , cond_series{ alloc } , modifiers{ alloc } { - ice::array::reserve(cond_series, 3); - ice::array::reserve(modifiers, 2); + cond_series.reserve(3); + modifiers.reserve(2); } ice::Allocator& allocator; @@ -181,7 +178,7 @@ namespace ice auto add_condition_series() noexcept -> InputActionBuilder::ConditionSeries { - ice::array::push_back(cond_series, Internal{ allocator }); + cond_series.push_back(Internal{ allocator }); Internal* const series_ptr = ice::addressof(cond_series.last()); return { series_ptr }; } @@ -212,7 +209,7 @@ namespace ice { ice::hashmap::reserve(_sources, 16); ice::hashmap::reserve(_actions, 10); - ice::array::push_back(_constants, { InputActionConstant::Nil, 0.0f }); + _constants.push_back({ InputActionConstant::Nil, 0.0f }); } ~SimpleInputActionLayerBuilder() @@ -233,7 +230,7 @@ namespace ice ice::f32 value ) noexcept override { - ice::array::push_back(_constants, { constant, value }); + _constants.push_back({ constant, value }); } auto define_source( @@ -274,7 +271,7 @@ namespace ice { if (ice::hashmap::empty(source.events)) { - ice::array::push_back(final_sources, + final_sources.push_back( InputActionSourceInputInfo{ .name = { strings.size().u16(), source.name.size().u16() }, .input = ice::input::InputID::Invalid, @@ -287,7 +284,7 @@ namespace ice for (ice::input::InputID input_event : source.events) { - ice::array::push_back(final_sources, + final_sources.push_back( InputActionSourceInputInfo{ .name = { strings.size().u16(), source.name.size().u16() }, .input = input_event, @@ -316,7 +313,7 @@ namespace ice { ice::u32 idx_found = ice::u32_max; bool const found = ice::search( - ice::array::slice(final_sources), + final_sources.tailspan(0), source_name, [&strings](ice::InputActionSourceInputInfo const& source, ice::String expected) noexcept { @@ -337,7 +334,7 @@ namespace ice { ice::u32 idx_found = ice::u32_max; bool const found = ice::search( - ice::array::slice(final_actions), + final_actions.tailspan(0), source_name, [&strings](ice::InputActionInfo const& action, ice::String expected) noexcept { @@ -374,7 +371,7 @@ namespace ice { if (step.step < InputActionStep::Set) { - ice::array::push_back(final_steps, + final_steps.push_back( InputActionStepData{ .source = { 0, 0 }, .id = step.step, @@ -384,7 +381,7 @@ namespace ice } else { - ice::array::push_back(final_steps, + final_steps.push_back( InputActionStepData{ .source = { .source_index = find_source_storage_index(step.source), @@ -422,7 +419,7 @@ namespace ice source_index.source_axis = condition.axis; } - ice::array::push_back(final_conditions, + final_conditions.push_back( InputActionConditionData{ .source = source_index, .id = condition.condition, @@ -440,7 +437,7 @@ namespace ice modifier_count = action.modifiers.size().u8(); ice::array::push_back(final_modifiers, action.modifiers); - ice::array::push_back(final_actions, + final_actions.push_back( InputActionInfo{ .name = { strings.size().u16(), action.name.size().u16() }, .type = action.type, @@ -461,8 +458,8 @@ namespace ice for (auto [constant, value] : _constants) { ice::u8 const offset = final_constant_values.size().u8(); - ice::array::push_back(final_constants, { .identifier = constant, .offset = offset }); - ice::array::push_back(final_constant_values, value); + final_constants.push_back({ .identifier = constant, .offset = offset }); + final_constant_values.push_back(value); } ice::InputActionLayerInfoHeader final_info{ @@ -478,25 +475,25 @@ namespace ice // Allocate memory and copy all data ice::meminfo minfo_layer = ice::meminfo_of; - ice::usize const offset_sources = minfo_layer += ice::array::meminfo(final_sources); - ice::usize const offset_actions = minfo_layer += ice::array::meminfo(final_actions); - ice::usize const offset_conditions = minfo_layer += ice::array::meminfo(final_conditions); - ice::usize const offset_steps = minfo_layer += ice::array::meminfo(final_steps); - ice::usize const offset_modifiers = minfo_layer += ice::array::meminfo(final_modifiers); - ice::usize const offset_constant_values = minfo_layer += ice::meminfo_of * final_constant_values.size(); - ice::usize const offset_constants = minfo_layer += ice::array::meminfo(final_constants); + ice::usize const offset_sources = minfo_layer += final_sources.meminfo(); + ice::usize const offset_actions = minfo_layer += final_actions.meminfo(); + ice::usize const offset_conditions = minfo_layer += final_conditions.meminfo(); + ice::usize const offset_steps = minfo_layer += final_steps.meminfo(); + ice::usize const offset_modifiers = minfo_layer += final_modifiers.meminfo(); + ice::usize const offset_constant_values = minfo_layer += final_constant_values.meminfo(); + ice::usize const offset_constants = minfo_layer += final_constants.meminfo(); ice::usize const offset_strings = minfo_layer += strings.meminfo(); final_info.offset_strings = ice::u32(offset_strings.value); ice::Memory const final_memory = alloc.allocate(minfo_layer); ice::memcpy(final_memory, ice::data_view(final_info)); - ice::memcpy(ice::ptr_add(final_memory, offset_sources), ice::array::data_view(final_sources)); - ice::memcpy(ice::ptr_add(final_memory, offset_actions), ice::array::data_view(final_actions)); - ice::memcpy(ice::ptr_add(final_memory, offset_conditions), ice::array::data_view(final_conditions)); - ice::memcpy(ice::ptr_add(final_memory, offset_steps), ice::array::data_view(final_steps)); - ice::memcpy(ice::ptr_add(final_memory, offset_modifiers), ice::array::data_view(final_modifiers)); - ice::memcpy(ice::ptr_add(final_memory, offset_constant_values), ice::array::data_view(final_constant_values)); - ice::memcpy(ice::ptr_add(final_memory, offset_constants), ice::array::data_view(final_constants)); + ice::memcpy(ice::ptr_add(final_memory, offset_sources), final_sources.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_actions), final_actions.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_conditions), final_conditions.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_steps), final_steps.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_modifiers), final_modifiers.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_constant_values), final_constant_values.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_constants), final_constants.data_view()); ice::memcpy(ice::ptr_add(final_memory, offset_strings), strings.data_view()); return ice::create_input_action_layer(alloc, final_memory); } @@ -684,7 +681,7 @@ namespace ice ICE_ASSERT_CORE(axis_component >= 'x' && axis_component <= 'z'); // .xyz ice::u8 const axis = axis_component - 'x'; - ice::array::push_back(internal().modifiers, { .id = modifier, .axis = axis, .param = param }); + internal().modifiers.push_back({ .id = modifier, .axis = axis, .param = param }); } return *this; } diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index 065a6665..a5d56fd4 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -138,7 +138,7 @@ namespace ice { for (StackLayer const& layer : _layers) { - ice::array::push_back(out_layers, layer.layer); + out_layers.push_back(layer.layer); } return _layers.size().u32(); } @@ -186,12 +186,12 @@ namespace ice values_index = ice::hashmap::try_get(_sources, source_name_hash)->index; // Stores the index for the source - ice::array::push_back(_layers_sources_indices, values_index); + _layers_sources_indices.push_back(values_index); if (source.type == InputActionSourceType::Axis2d) { // Stores the index for the source - ice::array::push_back(_layers_sources_indices, values_index); + _layers_sources_indices.push_back(values_index); } } } @@ -199,23 +199,23 @@ namespace ice { values_index = _sources_runtime_values.size().u32(); - ice::array::push_back(_sources_runtime_values, InputActionSource{}); + _sources_runtime_values.push_back(InputActionSource{}); // If we have an Axis2d source, we need to actually push back two values for both axis if (source.type == InputActionSourceType::Axis2d) { - ice::array::push_back(_sources_runtime_values, InputActionSource{}); + _sources_runtime_values.push_back(InputActionSource{}); } // Save the index where we store the runtime value(s) ice::hashmap::set(_sources, source_name_hash, { values_index }); // Stores the index for the source - ice::array::push_back(_layers_sources_indices, values_index); + _layers_sources_indices.push_back(values_index); if (source.type == InputActionSourceType::Axis2d) { // Stores the index for the source - ice::array::push_back(_layers_sources_indices, values_index); + _layers_sources_indices.push_back(values_index); } } @@ -245,8 +245,7 @@ namespace ice } // Stores the layer along with a ref where it's indices for all sources are stored. - ice::array::push_back( - _layers, + _layers.push_back( StackLayer{ layer, { layer_sources_offset.u16(), (_layers_sources_indices.size() - layer_sources_offset).u16() } } ); return S_Ok; @@ -256,12 +255,12 @@ namespace ice ice::Array& out_layers ) const noexcept -> ice::u32 { - auto it = ice::array::rbegin(_layers_active); - auto const end = ice::array::rend(_layers_active); + auto it = _layers_active.rbegin(); + auto const end = _layers_active.rend(); while (it != end) { - ice::array::push_back(out_layers, _layers[it->index].layer); + out_layers.push_back(_layers[it->index].layer); it += 1; } return _layers_active.size().u32(); @@ -285,7 +284,7 @@ namespace ice } // Push back the new active layer. - ice::array::push_back(_layers_active, { idx }); + _layers_active.push_back({ idx }); } void SimpleInputActionStack::pop_layer( @@ -296,7 +295,7 @@ namespace ice if (ice::search(ice::Span{ _layers }, layer, compare_layers, idx)) { // We just cut anything below this index, because we want to pop everything up to this layer - ice::array::resize(_layers, idx); + _layers.resize(idx); ice::array::pop_back(_layers); // And pop the item itself } } @@ -408,25 +407,25 @@ namespace ice ice::Array source_values{ _allocator }; // We go in reverse order since, the recently pushed layers should be processed first as they might override inputs. - Iterator const start = ice::array::rbegin(_layers_active); - Iterator const end = ice::array::rend(_layers_active); + Iterator const start = _layers_active.rbegin(); + Iterator const end = _layers_active.rend(); for (Iterator it = start; it != end; ++it) { StackLayer const& layer = _layers[it->index]; - for (ice::u32 offset : ice::array::slice(_layers_sources_indices, layer.sources_indices)) + for (ice::u32 offset : _layers_sources_indices.subspan(layer.sources_indices)) { - ice::array::push_back(source_values, ice::addressof(_sources_runtime_values[offset])); + source_values.push_back(ice::addressof(_sources_runtime_values[offset])); } ice::u32 const processed_events = layer.layer->process_inputs( - ice::array::slice(events_copy, 0, remaining_events), + events_copy.headspan(remaining_events), source_values ); ICE_ASSERT_CORE(processed_events <= remaining_events); remaining_events -= processed_events; - ice::array::clear(source_values); + source_values.clear(); // TODO: Should we change how this loop is finishing? if (remaining_events == 0) @@ -439,15 +438,15 @@ namespace ice for (Iterator it = start; it != end; ++it) { StackLayer const& layer = _layers[it->index]; - for (ice::u32 offset : ice::array::slice(_layers_sources_indices, layer.sources_indices)) + for (ice::u32 offset : _layers_sources_indices.subspan(layer.sources_indices)) { - ice::array::push_back(source_values, ice::addressof(_sources_runtime_values[offset])); + source_values.push_back(ice::addressof(_sources_runtime_values[offset])); } ex.prepare_constants(*layer.layer); layer.layer->update_actions(ex, source_values, _actions); - ice::array::clear(source_values); + source_values.clear(); } } diff --git a/source/code/systems/input_system/private/input_controller.cxx b/source/code/systems/input_system/private/input_controller.cxx index 8867d7ba..fc4c0f29 100644 --- a/source/code/systems/input_system/private/input_controller.cxx +++ b/source/code/systems/input_system/private/input_controller.cxx @@ -47,7 +47,7 @@ namespace ice::input : _device{ device } , _controls{ alloc } { - ice::array::resize(_controls, controller_button_num + 5); + _controls.resize(controller_button_num + 5); } void ControllerDevice::on_tick(ice::Timer const& timer) noexcept @@ -143,7 +143,7 @@ namespace ice::input event.axis_idx = axis_index; event.value.axis.value_f32 = value; event.value_type = InputValueType::AxisFloat; - ice::array::push_back(events_out, event); + events_out.push_back(event); } else if (reset == false) { @@ -152,7 +152,7 @@ namespace ice::input event.axis_idx = axis_index; event.value.axis.value_f32 = 0.0f; event.value_type = InputValueType::AxisFloat; - ice::array::push_back(events_out, event); + events_out.push_back(event); } }; @@ -167,7 +167,7 @@ namespace ice::input { if (detail::prepared_input_event(control, event)) { - ice::array::push_back(events_out, event); + events_out.push_back(event); } } } diff --git a/source/code/systems/input_system/private/input_keyboard.cxx b/source/code/systems/input_system/private/input_keyboard.cxx index 85a8b2c7..5130a266 100644 --- a/source/code/systems/input_system/private/input_keyboard.cxx +++ b/source/code/systems/input_system/private/input_keyboard.cxx @@ -79,7 +79,7 @@ namespace ice::input , _device{ device } , _controls{ alloc } { - ice::array::resize(_controls, keyboard_key_num + keyboard_mod_num + 10); + _controls.resize(keyboard_key_num + keyboard_mod_num + 10); for (detail::ControlState& control : _controls) { control.id = InputID::Invalid; @@ -158,7 +158,7 @@ namespace ice::input { if (detail::prepared_input_event(control, event)) { - ice::array::push_back(events_out, event); + events_out.push_back(event); } } } diff --git a/source/code/systems/input_system/private/input_mouse.cxx b/source/code/systems/input_system/private/input_mouse.cxx index 3b55e7ec..ceb653e6 100644 --- a/source/code/systems/input_system/private/input_mouse.cxx +++ b/source/code/systems/input_system/private/input_mouse.cxx @@ -45,7 +45,7 @@ namespace ice::input : _device{ device } , _controls{ alloc } { - ice::array::resize(_controls, mouse_button_num + 5); + _controls.resize(mouse_button_num + 5); for (detail::ControlState& control : _controls) { control.id = InputID::Invalid; @@ -122,13 +122,13 @@ namespace ice::input event.axis_idx = 0; event.value.axis.value_i32 = _position[0]; event.value_type = InputValueType::AxisInt; - ice::array::push_back(events_out, event); + events_out.push_back(event); event.identifier = input_identifier(DeviceType::Mouse, MouseInput::PositionY); event.axis_idx = 1; event.value.axis.value_i32 = _position[1]; event.value_type = InputValueType::AxisInt; - ice::array::push_back(events_out, event); + events_out.push_back(event); if (_position_relative[0] != 0) { @@ -136,7 +136,7 @@ namespace ice::input event.axis_idx = 0; event.value.axis.value_i32 = _position_relative[0]; event.value_type = InputValueType::AxisInt; - ice::array::push_back(events_out, event); + events_out.push_back(event); } if (_position_relative[1] != 0) { @@ -144,7 +144,7 @@ namespace ice::input event.axis_idx = 1; event.value.axis.value_i32 = _position_relative[1]; event.value_type = InputValueType::AxisInt; - ice::array::push_back(events_out, event); + events_out.push_back(event); } // All other events have an axis_idx == 0 @@ -153,14 +153,14 @@ namespace ice::input { event.identifier = input_identifier(DeviceType::Mouse, MouseInput::Wheel); event.value.axis.value_i32 = _wheel; - ice::array::push_back(events_out, event); + events_out.push_back(event); } for (detail::ControlState& control : _controls) { if (detail::prepared_input_event(control, event)) { - ice::array::push_back(events_out, event); + events_out.push_back(event); } } } diff --git a/source/code/systems/input_system/private/input_touchscreen.cxx b/source/code/systems/input_system/private/input_touchscreen.cxx index cb864a1b..ff945f3a 100644 --- a/source/code/systems/input_system/private/input_touchscreen.cxx +++ b/source/code/systems/input_system/private/input_touchscreen.cxx @@ -77,7 +77,7 @@ namespace ice::input pointer = ice::input::DeviceHandle::Invalid; } - ice::array::resize(_controls, Constant_MaxPointerCount + 1); + _controls.resize(Constant_MaxPointerCount + 1); for (detail::ControlState& control : _controls) { control.id = InputID::Invalid; @@ -164,7 +164,7 @@ namespace ice::input event.identifier = input_identifier(DeviceType::TouchScreen, TouchInput::TouchPointerCount); event.value_type = InputValueType::AxisInt; event.value.axis.value_i32 = _pointer_count; - ice::array::push_back(events_out, event); + events_out.push_back(event); } event.value_type = InputValueType::AxisFloat; @@ -178,11 +178,11 @@ namespace ice::input event.device = _pointers[idx]; event.identifier = input_identifier(DeviceType::TouchScreen, TouchInput::TouchPosX); event.value.axis.value_f32 = (_positions[idx].x / _screen_size.x) - 0.5f; - ice::array::push_back(events_out, event); + events_out.push_back(event); event.identifier = input_identifier(DeviceType::TouchScreen, TouchInput::TouchPosY); event.value.axis.value_f32 = (_positions[idx].y / _screen_size.y) - 0.5f; - ice::array::push_back(events_out, event); + events_out.push_back(event); remaining -= 1; } @@ -192,7 +192,7 @@ namespace ice::input event.device = make_device_handle(DeviceType::TouchPointer, DeviceIndex(control_index++)); if (detail::prepared_input_event(control, event)) { - ice::array::push_back(events_out, event); + events_out.push_back(event); } } } diff --git a/source/code/systems/input_system/private/input_tracker.cxx b/source/code/systems/input_system/private/input_tracker.cxx index 295c26c0..cb1f7f96 100644 --- a/source/code/systems/input_system/private/input_tracker.cxx +++ b/source/code/systems/input_system/private/input_tracker.cxx @@ -155,7 +155,7 @@ namespace ice::input { for (InputDevice* device : _devices) { - ice::array::push_back(devices_out, device->handle()); + devices_out.push_back(device->handle()); } } diff --git a/source/code/systems/input_system/public/ice/input/device_event_queue.hxx b/source/code/systems/input_system/public/ice/input/device_event_queue.hxx index aaa2829d..2925287b 100644 --- a/source/code/systems/input_system/public/ice/input/device_event_queue.hxx +++ b/source/code/systems/input_system/public/ice/input/device_event_queue.hxx @@ -59,8 +59,7 @@ namespace ice::input ice::input::DeviceMessage message ) noexcept { - ice::array::push_back( - _events, + _events.push_back( DeviceEvent{ .device = device, .message = message, @@ -104,7 +103,7 @@ namespace ice::input event.payload_data.val_f32 = payload_value; } - ice::array::push_back(_events, event); + _events.push_back(event); } template requires std::is_enum_v diff --git a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx index ba5a018d..0198b6ad 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx @@ -195,13 +195,13 @@ namespace ice ) noexcept { ice::Array requests{ _callbacks.allocator() }; - ice::array::reserve(requests, base_paths.size().u32()); + requests.reserve(base_paths.size().u32()); [[maybe_unused]] std::atomic_uint32_t remaining = 0; for (ice::native_file::FilePath base_path : base_paths) { - ice::array::push_back(requests, { *this, base_path, remaining, nullptr, nullptr }); + requests.push_back({ *this, base_path, remaining, nullptr, nullptr }); ice::native_file::traverse_directories( base_path, traverse_callback, &requests.last() ); @@ -217,14 +217,14 @@ namespace ice ice::TaskScheduler local_sched{ local_queue }; ice::Array requests{ _callbacks.allocator() }; - ice::array::reserve(requests, base_paths.size().u32()); + requests.reserve(base_paths.size().u32()); std::atomic_uint32_t remaining = 0; // Traverse directories synchronously but create resources asynchronously. for (ice::native_file::FilePath base_path : base_paths) { - ice::array::push_back(requests, { *this, base_path, remaining, ice::addressof(scheduler), &local_sched }); + requests.push_back({ *this, base_path, remaining, ice::addressof(scheduler), &local_sched }); ice::native_file::traverse_directories( base_path, traverse_callback, &requests.last() ); diff --git a/source/code/systems/resource_system/private/resource_provider_custom.cxx b/source/code/systems/resource_system/private/resource_provider_custom.cxx index a0f996c2..57727f28 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.cxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.cxx @@ -80,7 +80,7 @@ namespace ice out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { - ice::array::push_back(out_changes, resource); + out_changes.push_back(resource); } return ice::hashmap::count(_resources); } diff --git a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx index 4378cf56..c736085a 100644 --- a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx +++ b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx @@ -123,7 +123,7 @@ namespace ice for (auto* resource : _resources) { - ice::array::push_back(out_changes, resource); + out_changes.push_back(resource); } } return ResourceProviderResult::Success; diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index f76fb74b..b7240427 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -51,7 +51,7 @@ namespace ice ? entry.path.size() - ice::path::filename(entry.path).size() : entry.basepath.size(); - ice::array::push_back(_file_paths, { .path = file_path, .basepath_size = basepath_size.u32() }); + _file_paths.push_back({ .path = file_path, .basepath_size = basepath_size.u32() }); } } @@ -112,7 +112,7 @@ namespace ice if (resource != nullptr) { resource->data_index = _resources_data.size().u32(); - ice::array::push_back(_resources_data, ice::Memory{}); + _resources_data.push_back(ice::Memory{}); ice::u64 const hash = ice::hash(resource->uri().path()); ICE_ASSERT( @@ -150,7 +150,7 @@ namespace ice out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { - ice::array::push_back(out_changes, resource); + out_changes.push_back(resource); } return ice::hashmap::count(_resources); } diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx index 43a467c7..0ed60291 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx @@ -33,7 +33,7 @@ namespace ice { ice::native_file::path_from_string(base_path, path); ice::path::normalize(base_path); - ice::array::push_back(_base_paths, base_path); + _base_paths.push_back(base_path); } } @@ -99,7 +99,7 @@ namespace ice _named_allocator.deallocate(metadata_mem); } - ice::array::push_back(out_uris, resource->uri()); + out_uris.push_back(resource->uri()); collected += 1; } } @@ -115,7 +115,7 @@ namespace ice out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { - ice::array::push_back(out_changes, resource); + out_changes.push_back(resource); } return ice::hashmap::count(_resources); } @@ -286,7 +286,7 @@ namespace ice ) noexcept -> ice::Result { resource->data_index = _resources_data.size().u32(); - ice::array::push_back(_resources_data, ice::Memory{}); + _resources_data.push_back(ice::Memory{}); ice::u64 const hash = ice::hash(resource->origin()); ICE_ASSERT( diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx index d78dddec..3fb776cd 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx @@ -141,7 +141,7 @@ namespace ice // both data and metadata pointers are allocated separately, which doubles the required hashmap size. ice::u32 const estimated_pointer_count = _chunk.count_entries * (_chunk.type == 3 ? 2 : 1); ice::hashmap::reserve(_offset_map, estimated_pointer_count); - ice::array::resize(_pointers, estimated_pointer_count); + _pointers.resize(estimated_pointer_count); } HailstormChunkLoader_Regular::~HailstormChunkLoader_Regular() noexcept @@ -309,7 +309,7 @@ namespace ice FileOpenFlags::Exclusive ).value(); - ice::array::resize(_loaders, _pack.header.count_chunks); + _loaders.resize(_pack.header.count_chunks); for (ice::u32 idx = 0; idx < _pack.header.count_chunks; ++idx) { if (_pack.chunks[idx].persistance >= 2) @@ -326,7 +326,7 @@ namespace ice } } - ice::array::resize(_entries, _pack.header.count_resources); + _entries.resize(_pack.header.count_resources); for (ice::u32 idx = 0; idx < _pack.header.count_resources; ++idx) { v1::HailstormResource const& res = _pack.resources[idx]; @@ -362,7 +362,7 @@ namespace ice } ice::multi_hashmap::insert(_entrymap, ice::hash(res_uri.path()), idx); - ice::array::push_back(out_changes, _entries[idx]); + out_changes.push_back(_entries[idx]); } return ResourceProviderResult::Success; diff --git a/source/code/systems/resource_system/private/resource_tracker.cxx b/source/code/systems/resource_system/private/resource_tracker.cxx index 2610b6d7..7013916e 100644 --- a/source/code/systems/resource_system/private/resource_tracker.cxx +++ b/source/code/systems/resource_system/private/resource_tracker.cxx @@ -104,7 +104,7 @@ namespace ice ice::Array temp_resources{ _allocator }; for (auto const& provider : _resource_providers) { - ice::array::clear(temp_resources); + temp_resources.clear(); this->sync_provider(temp_resources, *provider); } diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx index 2c4ac486..6ee6f1c3 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx @@ -94,7 +94,7 @@ namespace ice _named_allocator.deallocate(metadata_mem); } - ice::array::push_back(out_uris, resource->uri()); + out_uris.push_back(resource->uri()); collected += 1; } } @@ -110,7 +110,7 @@ namespace ice out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { - ice::array::push_back(out_changes, resource); + out_changes.push_back(resource); } return ice::hashmap::count(_resources); } @@ -334,7 +334,7 @@ namespace ice ice::WritableFileSystemResource* const resource = static_cast(fs_resource); resource->data_index = _resources_data.size().u32(); - ice::array::push_back(_resources_data, ice::Memory{}); + _resources_data.push_back(ice::Memory{}); ice::u64 const hash = ice::hash(resource->origin()); ICE_ASSERT( diff --git a/source/code/test/private/game.cxx b/source/code/test/private/game.cxx index 839c2960..24581e21 100644 --- a/source/code/test/private/game.cxx +++ b/source/code/test/private/game.cxx @@ -171,11 +171,11 @@ struct TestTrait : public ice::Trait ice::ecs::Query q = query(); ice::Array> tasks{ update.frame.allocator() }; - ice::array::reserve(tasks, q.block_count()); + tasks.reserve(q.block_count()); q.for_each_block([&](ice::u32 count, C1* c1p, C2* c2p) noexcept { - ice::array::push_back(tasks, [](ice::u32 count, C1* c1p, C2* c2p) noexcept -> ice::Task<> + tasks.push_back([](ice::u32 count, C1* c1p, C2* c2p) noexcept -> ice::Task<> { IPT_ZONE_SCOPED_NAMED("block for-each"); for (ice::u32 idx = 0; idx < count; ++idx) diff --git a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx index d4fc8700..4b228e47 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx @@ -44,15 +44,13 @@ class AssetCompilerApp : public ice::tool::ToolApp { if (results.size() == 2) { - ice::array::push_back( - self._params, + self._params.push_back( ice::shard(results[0], results[1].begin()) ); } if (results.size() == 1) { - ice::array::push_back( - self._params, + self._params.push_back( ice::shard(results[0], true) ); } @@ -323,7 +321,7 @@ class AssetCompilerApp : public ice::tool::ToolApp // If empty we add our own handle to the list if (sources.is_empty()) { - ice::array::push_back(sources, res); + sources.push_back(res); } ice::Array dependencies{ _allocator }; @@ -364,7 +362,7 @@ class AssetCompilerApp : public ice::tool::ToolApp _queue.process_all(); } - ice::array::push_back(results, result); + results.push_back(result); } if (ice::wait_for_result(resource_compiler->fn_build_metadata(ctx, res, *resource_tracker, results, dependencies, meta)) == false) diff --git a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx index cee93954..97ee3636 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx @@ -64,7 +64,7 @@ AssetCompilerResourceProvider::AssetCompilerResourceProvider( , _resources{ _allocator } , _data{ _allocator } { - ice::array::reserve(_resources, files.size().u32()); + _resources.reserve(files.size().u32()); ice::u32 idx = 0; for (ice::String file : files) @@ -76,7 +76,7 @@ AssetCompilerResourceProvider::AssetCompilerResourceProvider( AssetCompilerResource* res = _allocator.create(_allocator, ice::move(filehandle), file); res->idx = idx++; - ice::array::push_back(_resources, res); + _resources.push_back(res); } _data.resize(_resources.size()); @@ -109,7 +109,7 @@ auto AssetCompilerResourceProvider::refresh( { for (AssetCompilerResource* res : _resources) { - ice::array::push_back(out_changes, res); + out_changes.push_back(res); } return ice::ResourceProviderResult::Success; } diff --git a/source/code/tools/hsc_packer/private/hsc_packer.cxx b/source/code/tools/hsc_packer/private/hsc_packer.cxx index 12d50e10..81146085 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer.cxx @@ -161,8 +161,8 @@ class HailStormPackerApp final : public ice::tool::ToolApp { for (ice::String ext : extensions) { - ice::array::push_back(_filter_extensions_heap, { _allocator, ext }); - ice::array::push_back(_filter_extensions, _filter_extensions_heap.last()); + _filter_extensions_heap.push_back({ _allocator, ext }); + _filter_extensions.push_back(_filter_extensions_heap.last()); } } HSCP_ERROR_IF( @@ -241,7 +241,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp files.reserve(_inputs.size()); for (ice::String file : _inputs) { - ice::array::push_back(files, { .path = file }); + files.push_back({ .path = file }); } ice::UniquePtr fsprov = ice::create_resource_provider_files( @@ -308,7 +308,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp ice::Data md; ice::wait_for_result(ice::resource_meta(resource_handles[res_idx], md)); - ice::array::push_back(resource_metas, hsdata_view(md)); + resource_metas.push_back(hsdata_view(md)); ice::schedule_task( read_resource_size(resource_handles[res_idx], resource_data[res_idx], res_count), @@ -326,9 +326,9 @@ class HailStormPackerApp final : public ice::tool::ToolApp ice::current_thread::sleep(1_Tms); } - ice::array::resize(resource_paths, res_idx); - ice::array::resize(resource_data, res_idx); - ice::array::resize(resource_metamap, res_idx); + resource_paths.resize(res_idx); + resource_data.resize(res_idx); + resource_metamap.resize(res_idx); hailstorm::v1::HailstormWriteData const hsdata{ .paths = resource_paths, From 38fb5194dbcc07b66abe08459b194a5654e4d33e Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sun, 11 Jan 2026 16:43:17 +0900 Subject: [PATCH 15/40] Finished refactor of the Array type. #ICE-207 State Done --- .../core/collections/public/ice/array.hxx | 74 ++++++++++------ .../public/ice/container/array.hxx | 36 -------- .../ice/container/container_concepts.hxx | 35 ++++++-- .../public/ice/container/impl/array_impl.inl | 86 ------------------- .../code/core/collections/public/ice/span.hxx | 1 + .../core/collections/tests/test_array.cxx | 12 +-- .../memsys/public/ice/mem_initializers.hxx | 15 +++- 7 files changed, 98 insertions(+), 161 deletions(-) delete mode 100644 source/code/core/collections/public/ice/container/array.hxx delete mode 100644 source/code/core/collections/public/ice/container/impl/array_impl.inl diff --git a/source/code/core/collections/public/ice/array.hxx b/source/code/core/collections/public/ice/array.hxx index ee8c08af..2bafdca5 100644 --- a/source/code/core/collections/public/ice/array.hxx +++ b/source/code/core/collections/public/ice/array.hxx @@ -2,6 +2,7 @@ #include #include #include +#include namespace ice { @@ -29,6 +30,7 @@ namespace ice using ConstIterator = Type const*; using ConstReverseIterator = std::reverse_iterator; using SizeType = ice::ncount; + using ContainerTag = ice::concepts::ContiguousContainerTag; ice::Allocator* _allocator; ice::u32 _capacity; @@ -62,6 +64,13 @@ namespace ice requires std::convertible_to && std::is_constructible_v inline void push_back(ItemType&& item) noexcept; + template + requires (std::convertible_to, Type> + && std::is_constructible_v>) + inline void push_back(ContainerT const& other) noexcept; + + inline void pop_back(ice::ncount count = 1_count) noexcept; + // API Requirements Of: Data and Memory constexpr auto data_view(this Array const& self) noexcept -> ice::Data; constexpr auto memory_view(this Array& self) noexcept -> ice::Memory; @@ -287,7 +296,7 @@ namespace ice ice::ncount const missing_items = new_size - _count; ice::Memory const uninitialized_memory = ice::ptr_add(memory_view(), size()); - ice::mem_construct_n_at( + ice::mem_default_construct_n_at( uninitialized_memory, missing_items ); @@ -338,29 +347,46 @@ namespace ice _count += 1; } - //template - // requires std::copy_constructible&& std::convertible_to - //inline void push_back(ice::Array& arr, Value const& item) noexcept - //{ - // if (arr.size() == arr.capacity()) - // { - // arr.grow(); - // } - - // if constexpr (Logic == ContainerLogic::Complex) - // { - // ice::mem_copy_construct_at( - // ice::ptr_add(arr.memory_view(), arr.size()), - // item - // ); - // } - // else - // { - // arr._data[arr._count] = Type{ item }; - // } - - // arr._count += 1; - //} + template + template + requires (std::convertible_to, Type> + && std::is_constructible_v>) + inline void ice::Array::push_back(ContainerT const& other) noexcept + { + ice::ncount const current_size = size(); + ice::ncount const required_capacity = other.size() + current_size; + if (required_capacity > _capacity) + { + this->grow(required_capacity); + } + + ice::Memory target_memory = ice::ptr_add(memory_view(), current_size); + if constexpr (ice::concepts::ContiguousContainer && Logic == ContainerLogic::Trivial) + { + ice::memcpy(target_memory, other.data_view()); + } + else + { + ice::mem_copy_construct_it_at( + target_memory, other.begin(), other.end() + ); + } + + _count = required_capacity.u32(); + } + + template + inline void ice::Array::pop_back(ice::ncount count) noexcept + { + ice::ncount const current_count = size(); + ice::ncount const final_count = current_count - ice::min(count, current_count); + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_destruct_n_at(data() + final_count, current_count - final_count); + } + + _count = final_count.u32(); + } template inline constexpr auto Array::data_view(this Array const& self) noexcept -> ice::Data diff --git a/source/code/core/collections/public/ice/container/array.hxx b/source/code/core/collections/public/ice/container/array.hxx deleted file mode 100644 index 655869b4..00000000 --- a/source/code/core/collections/public/ice/container/array.hxx +++ /dev/null @@ -1,36 +0,0 @@ -/// Copyright 2022 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -namespace ice::array -{ - - template - requires std::copy_constructible - inline void push_back(ice::Array& arr, ice::Array const& items) noexcept; - - template - requires std::copy_constructible - inline void push_back(ice::Array& arr, ice::Span items) noexcept; - - template - requires std::copy_constructible && (std::is_same_v == false) - inline void push_back(ice::Array& arr, ice::Span items, Type(*fn)(Source const&) noexcept) noexcept; - - template - inline void pop_back(ice::Array& arr, ice::u32 count = 1) noexcept; - - template - inline auto memset(ice::Array& arr, ice::u8 value) noexcept -> ice::Memory; - -} // namespace ice::array - -namespace ice -{ - -} // namespace ice - -#include "impl/array_impl.inl" diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index 50bd0a91..cc7c5e3e 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -23,14 +23,6 @@ namespace ice::concepts { t.data() } -> std::convertible_to::ValueType const*>; }; - template - concept TrivialContainerLogic = ContainerType - && TrivialContainerLogicAllowed::ValueType>; - - template - concept RegularContainerLogic = ContainerType - && not TrivialContainerLogicAllowed::ValueType>; - template concept ResizableContainer = Container && requires(T t, ice::ncount size) { { t.data() } -> std::convertible_to::ValueType*>; @@ -40,6 +32,22 @@ namespace ice::concepts { t.clear() } -> std::convertible_to; }; + struct ContiguousContainerTag{ }; + + template + concept ContiguousContainer = Container && requires(T t) { + std::is_same_v::ContainerTag, ContiguousContainerTag>; + { t.data_view() } -> std::convertible_to; + }; + + template + concept TrivialContainerLogic = ContainerType + && TrivialContainerLogicAllowed::ValueType>; + + template + concept RegularContainerLogic = ContainerType + && not TrivialContainerLogicAllowed::ValueType>; + } // namespace ice::concepts namespace ice @@ -96,3 +104,14 @@ namespace ice::container using SpanType = ice::Span>; } // namespace ice::container + +namespace ice::concepts +{ + + template + concept IterableContainer = ContainerType && requires(T t) { + { t.begin() } -> std::convertible_to>; + { t.end() } -> std::convertible_to>; + }; + +} // namespace ice::concepts diff --git a/source/code/core/collections/public/ice/container/impl/array_impl.inl b/source/code/core/collections/public/ice/container/impl/array_impl.inl deleted file mode 100644 index dd958f6b..00000000 --- a/source/code/core/collections/public/ice/container/impl/array_impl.inl +++ /dev/null @@ -1,86 +0,0 @@ -#include "array.hxx" -/// Copyright 2022 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -namespace ice -{ - - namespace array - { - - template - requires std::copy_constructible - inline void push_back(ice::Array& arr, ice::Array const& items) noexcept - { - return ice::array::push_back(arr, items.tailspan(0)); - } - - template - requires std::copy_constructible - inline void push_back(ice::Array& arr, ice::Span items) noexcept - { - ice::u32 const required_capacity = arr._count + items.size().u32(); - if (required_capacity > arr._capacity) - { - arr.grow(required_capacity); - } - - ice::u32 const missing_items = required_capacity - arr._count; - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - Memory{ .location = arr._data + arr._count, .size = ice::size_of * missing_items, .alignment = ice::align_of }, - items.data(), - items.size().u32() - ); - } - else - { - ice::memcpy( - Memory{ .location = arr._data + arr._count, .size = ice::size_of * missing_items, .alignment = ice::align_of }, - items.data_view() - ); - } - - arr._count += items.size().u32(); - } - - template - requires std::copy_constructible && (std::is_same_v == false) - inline void push_back(ice::Array& arr, ice::Span items, Type(*fn)(Source const&) noexcept) noexcept - { - ice::u32 const required_capacity = arr._count + items.size(); - if (required_capacity > arr._capacity) - { - arr.grow(required_capacity); - } - - ice::u32 const missing_items = required_capacity - arr._count; - for (ice::u32 src_idx = 0; src_idx < missing_items; ++src_idx) - { - ice::array::push_back(arr, fn(items[src_idx])); - } - } - - template - inline void pop_back(ice::Array& arr, ice::u32 count /*= 1*/) noexcept - { - count = ice::min(count, arr._count); - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_n_at(arr._data + (arr._count - count), count); - } - - if (arr._count > count) - { - arr._count -= count; - } - else - { - arr._count = 0; - } - } - - } // namespace array - -} // namespace ice diff --git a/source/code/core/collections/public/ice/span.hxx b/source/code/core/collections/public/ice/span.hxx index e473807b..5f4549a4 100644 --- a/source/code/core/collections/public/ice/span.hxx +++ b/source/code/core/collections/public/ice/span.hxx @@ -22,6 +22,7 @@ namespace ice using ConstIterator = Type const*; using ConstReverseIterator = std::reverse_iterator; using SizeType = ice::ncount; + using ContainerTag = ice::concepts::ContiguousContainerTag; SizeType::base_type _count; ValueType* _data; diff --git a/source/code/core/collections/tests/test_array.cxx b/source/code/core/collections/tests/test_array.cxx index bc95cc1a..6fc82bd4 100644 --- a/source/code/core/collections/tests/test_array.cxx +++ b/source/code/core/collections/tests/test_array.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include -#include +#include #include #include #include "util_tracking_object.hxx" @@ -39,7 +39,7 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" { ice::u32 dtor_val = 0; obj.data.test_dtor = &dtor_val; - ice::array::pop_back(objects, 1); + objects.pop_back(); CHECK(dtor_val == 1); } @@ -73,7 +73,7 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" AND_THEN("we can copy and push back the same elements") { ice::Array array_copy = objects; - ice::array::push_back(objects, array_copy); + objects.push_back(array_copy); CHECK(objects.capacity() >= 20); CHECK(objects.not_empty()); @@ -169,7 +169,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod THEN("one element is poped") { - ice::array::pop_back(objects); + objects.pop_back(); CHECK(objects.size() == 0); CHECK(objects.not_empty() == false); @@ -186,7 +186,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod THEN("10 elements are poped") { - ice::array::pop_back(objects, 10); + objects.pop_back(10); CHECK(objects.size() == 0); CHECK(objects.not_empty() == false); @@ -211,7 +211,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod THEN("50 elements are poped") { - ice::array::pop_back(objects, 50); + objects.pop_back(50); CHECK(objects.not_empty() == true); CHECK(objects.is_empty() == false); diff --git a/source/code/core/memsys/public/ice/mem_initializers.hxx b/source/code/core/memsys/public/ice/mem_initializers.hxx index e4c7e49f..9f8b791a 100644 --- a/source/code/core/memsys/public/ice/mem_initializers.hxx +++ b/source/code/core/memsys/public/ice/mem_initializers.hxx @@ -43,7 +43,7 @@ namespace ice } template - auto mem_construct_n_at(ice::Memory memory, ice::u64 count) noexcept -> T* + auto mem_default_construct_n_at(ice::Memory memory, ice::u64 count) noexcept -> T* { // TODO: Assert (align + size) T* target_mem = reinterpret_cast(memory.location); @@ -88,6 +88,19 @@ namespace ice return target_mem; } + template + auto mem_copy_construct_it_at(ice::Memory memory, ItT begin, ItT end) noexcept -> T* + { + T* const target_mem = reinterpret_cast(memory.location); + ice::u64 idx = 0; + while (begin != end) + { + new (target_mem + idx) T{ *begin }; + begin += 1; + idx += 1; + } + return target_mem; + } template From c63271091955696b24a1f238d3b579707ffa1d1b Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sun, 11 Jan 2026 16:43:46 +0900 Subject: [PATCH 16/40] Changes to engine code after finalized Array refactor, --- .../code/core/collections/public/ice/container/hashmap.hxx | 2 +- .../collections/public/ice/container/impl/hashmap_impl.inl | 2 +- .../collections/public/ice/container/impl/queue_impl.inl | 4 ++-- source/code/core/collections/public/ice/shard_container.hxx | 4 ++-- source/code/core/modules/private/module_register.cxx | 2 +- source/code/core/modules/public/ice/module_query.hxx | 2 +- source/code/core/modules/public/ice/module_register.hxx | 2 +- source/code/core/tasks/private/task_thread_pool_impl.hxx | 2 +- source/code/core/tasks/public/ice/task_container.hxx | 2 +- source/code/core/tasks/public/ice/task_scoped_container.hxx | 2 +- .../code/core/utils/private/config/config_builder_types.hxx | 2 +- source/code/core/utils/private/params.cxx | 2 +- source/code/core/utils/public/ice/config/config_builder.hxx | 2 +- source/code/core/utils/public/ice/config/config_impl.hxx | 2 +- .../code/framework/framework_base/private/framework_main.cxx | 2 +- .../framework_base/private/traits/trait_tilemap.hxx | 2 +- .../framework_base/private/traits/ui/game_ui_trait.cxx | 2 +- source/code/iceshard/engine/private/action/action_system.cxx | 2 +- .../code/iceshard/engine/private/ecs/ecs_archetype_index.cxx | 2 +- source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx | 2 +- .../iceshard/engine/private/engine_state_tracker_default.cxx | 5 +---- .../iceshard/engine/private/engine_state_tracker_default.hxx | 2 +- .../iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx | 2 +- source/code/iceshard/engine/private/world_trait_module.cxx | 2 +- .../iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx | 4 ++-- .../iceshard/engine/public/ice/ecs/ecs_query_provider.hxx | 2 +- .../iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx | 2 +- .../iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx | 2 +- .../iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx | 2 +- .../iceshard/iceshard/private/iceshard_task_executor.cxx | 2 +- .../iceshard/iceshard/private/iceshard_world_tasks_devui.hxx | 4 ++-- .../iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx | 2 +- .../private/pipeline_ui/ip_ui_oven_page.hxx | 2 +- source/code/modules/imgui_module/private/imgui_system.hxx | 2 +- .../imgui_module/private/widgets/imgui_devui_manager.cxx | 2 +- .../imgui_module/private/widgets/imgui_devui_manager.hxx | 2 +- .../modules/imgui_module/private/widgets/imgui_logger.hxx | 2 +- .../code/modules/shader_tools/private/shader_tools_glsl.cxx | 2 +- source/code/modules/vulkan_renderer/private/vk_device.hxx | 2 +- source/code/modules/vulkan_renderer/private/vk_driver.cxx | 2 +- source/code/modules/vulkan_renderer/private/vk_driver.hxx | 2 +- .../code/modules/vulkan_renderer/private/vk_extensions.hxx | 2 +- source/code/modules/vulkan_renderer/private/vk_queue.hxx | 2 +- source/code/modules/vulkan_renderer/private/vk_utility.hxx | 2 +- .../modules/webgpu_renderer/private/webgpu_framebuffer.hxx | 2 +- .../modules/webgpu_renderer/private/webgpu_renderpass.hxx | 2 +- .../platforms/platform_webasm/private/webasm_core_app.hxx | 2 +- source/code/systems/asset_system/private/asset_module.cxx | 2 +- .../input_action_system/private/input_action_layer.cxx | 2 +- .../private/input_action_layer_builder.cxx | 2 +- .../input_action_system/private/input_action_stack.cxx | 4 ++-- .../code/systems/input_system/private/input_controller.cxx | 2 +- source/code/systems/input_system/private/input_keyboard.cxx | 2 +- source/code/systems/input_system/private/input_mouse.cxx | 2 +- .../code/systems/input_system/private/input_touchscreen.cxx | 2 +- .../input_system/public/ice/input/device_event_queue.hxx | 2 +- .../systems/input_system/public/ice/input/input_device.hxx | 4 ++-- .../render_system/public/ice/render/render_driver.hxx | 2 +- .../resource_system/private/resource_provider_hailstorm.hxx | 2 +- 59 files changed, 65 insertions(+), 68 deletions(-) diff --git a/source/code/core/collections/public/ice/container/hashmap.hxx b/source/code/core/collections/public/ice/container/hashmap.hxx index e5350656..c88b1218 100644 --- a/source/code/core/collections/public/ice/container/hashmap.hxx +++ b/source/code/core/collections/public/ice/container/hashmap.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include namespace ice diff --git a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl index 8f4c96f6..6cbd4917 100644 --- a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl @@ -893,7 +893,7 @@ namespace ice while (it._entry != nullptr) { - ice::array::push_back(items, *it._value); + items.push_back(*it._value); it = ice::multi_hashmap::find_next(map, it); } } diff --git a/source/code/core/collections/public/ice/container/impl/queue_impl.inl b/source/code/core/collections/public/ice/container/impl/queue_impl.inl index 61ad29a4..e2b7a320 100644 --- a/source/code/core/collections/public/ice/container/impl/queue_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/queue_impl.inl @@ -336,7 +336,7 @@ namespace ice ice::u32 const wrapped_end_idx = missing_items - (end_idx - start_idx); // Construct until we hit end of the queue buffer - ice::mem_construct_n_at( + ice::mem_default_construct_n_at( Memory{ .location = queue._data + start_idx, .size = ice::size_of * (end_idx - start_idx), @@ -345,7 +345,7 @@ namespace ice (end_idx - start_idx) ); // Construct the rest wrapped around the buffer - ice::mem_construct_n_at( + ice::mem_default_construct_n_at( Memory{ .location = queue._data, .size = ice::size_of * wrapped_end_idx, diff --git a/source/code/core/collections/public/ice/shard_container.hxx b/source/code/core/collections/public/ice/shard_container.hxx index 02d0a206..0896102f 100644 --- a/source/code/core/collections/public/ice/shard_container.hxx +++ b/source/code/core/collections/public/ice/shard_container.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include namespace ice { @@ -149,7 +149,7 @@ namespace ice inline void push_back(ice::ShardContainer& container, ice::Span values) noexcept { - ice::array::push_back(container._data, values); + container._data.push_back(values); } inline void remove_all_of(ice::ShardContainer& container, ice::ShardID value) noexcept diff --git a/source/code/core/modules/private/module_register.cxx b/source/code/core/modules/private/module_register.cxx index 21dc9975..18bdcb60 100644 --- a/source/code/core/modules/private/module_register.cxx +++ b/source/code/core/modules/private/module_register.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include -#include +#include #include #include #include diff --git a/source/code/core/modules/public/ice/module_query.hxx b/source/code/core/modules/public/ice/module_query.hxx index 7f160165..73d98061 100644 --- a/source/code/core/modules/public/ice/module_query.hxx +++ b/source/code/core/modules/public/ice/module_query.hxx @@ -2,10 +2,10 @@ /// SPDX-License-Identifier: MIT #pragma once +#include #include #include #include -#include namespace ice { diff --git a/source/code/core/modules/public/ice/module_register.hxx b/source/code/core/modules/public/ice/module_register.hxx index 9c827e88..5d4a1fb6 100644 --- a/source/code/core/modules/public/ice/module_register.hxx +++ b/source/code/core/modules/public/ice/module_register.hxx @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/core/tasks/private/task_thread_pool_impl.hxx b/source/code/core/tasks/private/task_thread_pool_impl.hxx index 39e0faf6..4de86615 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.hxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include #include #include "task_native_thread.hxx" diff --git a/source/code/core/tasks/public/ice/task_container.hxx b/source/code/core/tasks/public/ice/task_container.hxx index 7af01f7a..3bbb1807 100644 --- a/source/code/core/tasks/public/ice/task_container.hxx +++ b/source/code/core/tasks/public/ice/task_container.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include namespace ice { diff --git a/source/code/core/tasks/public/ice/task_scoped_container.hxx b/source/code/core/tasks/public/ice/task_scoped_container.hxx index 951dadee..7c027214 100644 --- a/source/code/core/tasks/public/ice/task_scoped_container.hxx +++ b/source/code/core/tasks/public/ice/task_scoped_container.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include namespace ice diff --git a/source/code/core/utils/private/config/config_builder_types.hxx b/source/code/core/utils/private/config/config_builder_types.hxx index 838f8eb4..c56802ce 100644 --- a/source/code/core/utils/private/config/config_builder_types.hxx +++ b/source/code/core/utils/private/config/config_builder_types.hxx @@ -6,7 +6,7 @@ #include #include #include -#include +#include namespace ice::config::detail { diff --git a/source/code/core/utils/private/params.cxx b/source/code/core/utils/private/params.cxx index f7c64f3d..679f4bd4 100644 --- a/source/code/core/utils/private/params.cxx +++ b/source/code/core/utils/private/params.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include -#include +#include #include #include #include diff --git a/source/code/core/utils/public/ice/config/config_builder.hxx b/source/code/core/utils/public/ice/config/config_builder.hxx index 7b3cfd23..c01061c0 100644 --- a/source/code/core/utils/public/ice/config/config_builder.hxx +++ b/source/code/core/utils/public/ice/config/config_builder.hxx @@ -2,8 +2,8 @@ /// SPDX-License-Identifier: MIT #pragma once +#include #include -#include #include namespace ice diff --git a/source/code/core/utils/public/ice/config/config_impl.hxx b/source/code/core/utils/public/ice/config/config_impl.hxx index 5105568d..f5cf5075 100644 --- a/source/code/core/utils/public/ice/config/config_impl.hxx +++ b/source/code/core/utils/public/ice/config/config_impl.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include namespace ice::config::detail { diff --git a/source/code/framework/framework_base/private/framework_main.cxx b/source/code/framework/framework_base/private/framework_main.cxx index 4abf008b..79177b37 100644 --- a/source/code/framework/framework_base/private/framework_main.cxx +++ b/source/code/framework/framework_base/private/framework_main.cxx @@ -346,7 +346,7 @@ auto ice_setup( else { dylib_path = storage->dylibs_location(); - ice::array::push_back(resource_paths, storage->data_locations()); + resource_paths.push_back(storage->data_locations()); } ice::framework::Config game_config{ diff --git a/source/code/framework/framework_base/private/traits/trait_tilemap.hxx b/source/code/framework/framework_base/private/traits/trait_tilemap.hxx index 2c2ad6f0..788970ac 100644 --- a/source/code/framework/framework_base/private/traits/trait_tilemap.hxx +++ b/source/code/framework/framework_base/private/traits/trait_tilemap.hxx @@ -6,7 +6,7 @@ #include #include -#include +#include namespace ice { diff --git a/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx b/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx index c8613c87..6c0706c2 100644 --- a/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx +++ b/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include #include diff --git a/source/code/iceshard/engine/private/action/action_system.cxx b/source/code/iceshard/engine/private/action/action_system.cxx index 8b93aaff..42e2973b 100644 --- a/source/code/iceshard/engine/private/action/action_system.cxx +++ b/source/code/iceshard/engine/private/action/action_system.cxx @@ -8,7 +8,7 @@ #include #include -#include +#include #include namespace ice::action diff --git a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx index 5e5dcde0..7a424e54 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include -#include +#include #include #include #include diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx index 78869fbb..8e4de4bd 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include -#include +#include #include #include diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index 8029b00d..bcd60142 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -89,10 +89,7 @@ namespace ice params.committer ); - ice::array::push_back( - _available_triggers, - triggers - ); + _available_triggers.push_back(triggers); return true; } diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx index 24b51468..43d489d3 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx index 829436e6..f73fe0c7 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include namespace ice::gfx diff --git a/source/code/iceshard/engine/private/world_trait_module.cxx b/source/code/iceshard/engine/private/world_trait_module.cxx index c68eedf6..b0eab282 100644 --- a/source/code/iceshard/engine/private/world_trait_module.cxx +++ b/source/code/iceshard/engine/private/world_trait_module.cxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include namespace ice { diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx index 7879d801..4c269771 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include #include @@ -64,7 +64,7 @@ namespace ice::ecs auto store(ice::Array& out_entities, bool append = true) const noexcept { if (append == false) out_entities.clear(); - ice::array::push_back(out_entities, all()); + out_entities.push_back(all()); } Result(OperationBuilder& builder) noexcept : _builder{ builder } { } diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx index 3b59df06..72521ce7 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include #include diff --git a/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx b/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx index 3b8983e6..14e3708b 100644 --- a/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx +++ b/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx index 1d009725..d9a236fe 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "../iceshard_data_storage.hxx" namespace ice::gfx diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx index 835b2db8..f553558b 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx b/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx index 03b90253..da731ad5 100644 --- a/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx @@ -4,7 +4,7 @@ #include #include "iceshard_task_executor.hxx" #include -#include +#include namespace ice { diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx index fed88295..0e431fa0 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include "iceshard_world_tasks_launcher.hxx" @@ -27,7 +27,7 @@ namespace ice : _events{ alloc } , _release{ false } { - ice::array::push_back(_events, events); + _events.push_back(events); } void draw() noexcept; diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx index fc77acd2..1d99f160 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx @@ -4,7 +4,7 @@ #pragma once #include "ip_ui_oven_types.hxx" #include -#include +#include #include #include diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx index 986e62c6..2029af9d 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include #include #include "ip_ui_oven.hxx" diff --git a/source/code/modules/imgui_module/private/imgui_system.hxx b/source/code/modules/imgui_module/private/imgui_system.hxx index 36788474..cd705b0f 100644 --- a/source/code/modules/imgui_module/private/imgui_system.hxx +++ b/source/code/modules/imgui_module/private/imgui_system.hxx @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include "widgets/imgui_devui_manager.hxx" diff --git a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx index 728aaf39..d4497a39 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx @@ -78,7 +78,7 @@ namespace ice::devui } _widgets[idx] = ice::move(_widgets[count - 1]); - ice::array::pop_back(_widgets); + _widgets.pop_back(); } void ImGuiDevUIManager::build_content() noexcept diff --git a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx index f37d605f..1d42ac9a 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include #include namespace ice::devui diff --git a/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx b/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx index 976878db..86faf7ea 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx @@ -5,7 +5,7 @@ #pragma once #include #include -#include +#include #include namespace ice::devui diff --git a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx index a10d2fd3..2008f425 100644 --- a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include diff --git a/source/code/modules/vulkan_renderer/private/vk_device.hxx b/source/code/modules/vulkan_renderer/private/vk_device.hxx index 1a00999c..db9ab19d 100644 --- a/source/code/modules/vulkan_renderer/private/vk_device.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_device.hxx @@ -2,8 +2,8 @@ /// SPDX-License-Identifier: MIT #pragma once +#include #include -#include #include #include diff --git a/source/code/modules/vulkan_renderer/private/vk_driver.cxx b/source/code/modules/vulkan_renderer/private/vk_driver.cxx index f1f54f74..4f391a72 100644 --- a/source/code/modules/vulkan_renderer/private/vk_driver.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_driver.cxx @@ -7,7 +7,7 @@ #include "vk_include.hxx" #include "vk_utility.hxx" -#include +#include #include extern "C" diff --git a/source/code/modules/vulkan_renderer/private/vk_driver.hxx b/source/code/modules/vulkan_renderer/private/vk_driver.hxx index 6e625f6f..55542d21 100644 --- a/source/code/modules/vulkan_renderer/private/vk_driver.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_driver.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "vk_allocator.hxx" #include "vk_memory_allocator.hxx" #include "vk_extensions.hxx" diff --git a/source/code/modules/vulkan_renderer/private/vk_extensions.hxx b/source/code/modules/vulkan_renderer/private/vk_extensions.hxx index bfbc100b..415b437e 100644 --- a/source/code/modules/vulkan_renderer/private/vk_extensions.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_extensions.hxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include "vk_include.hxx" namespace ice::render::vk diff --git a/source/code/modules/vulkan_renderer/private/vk_queue.hxx b/source/code/modules/vulkan_renderer/private/vk_queue.hxx index 30544331..3ae6bada 100644 --- a/source/code/modules/vulkan_renderer/private/vk_queue.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_queue.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include "vk_command_buffer.hxx" #include "vk_swapchain.hxx" #include "vk_include.hxx" diff --git a/source/code/modules/vulkan_renderer/private/vk_utility.hxx b/source/code/modules/vulkan_renderer/private/vk_utility.hxx index 6dbd8ce5..560e2162 100644 --- a/source/code/modules/vulkan_renderer/private/vk_utility.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_utility.hxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include diff --git a/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx b/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx index 1f7b6de3..3469061d 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include "webgpu_utils.hxx" #include "webgpu_image.hxx" diff --git a/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx b/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx index f46e6200..ddf87d5c 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include "webgpu_utils.hxx" #include "webgpu_image.hxx" diff --git a/source/code/platforms/platform_webasm/private/webasm_core_app.hxx b/source/code/platforms/platform_webasm/private/webasm_core_app.hxx index 2e8090f9..b4d23b8c 100644 --- a/source/code/platforms/platform_webasm/private/webasm_core_app.hxx +++ b/source/code/platforms/platform_webasm/private/webasm_core_app.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/asset_system/private/asset_module.cxx b/source/code/systems/asset_system/private/asset_module.cxx index c3d18f91..5dae0d81 100644 --- a/source/code/systems/asset_system/private/asset_module.cxx +++ b/source/code/systems/asset_system/private/asset_module.cxx @@ -3,7 +3,7 @@ #include #include -#include +#include #include namespace ice diff --git a/source/code/systems/input_action_system/private/input_action_layer.cxx b/source/code/systems/input_action_system/private/input_action_layer.cxx index 6b8355db..c09169d0 100644 --- a/source/code/systems/input_action_system/private/input_action_layer.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer.cxx @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx index 86d4faa5..bd53635a 100644 --- a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx @@ -435,7 +435,7 @@ namespace ice } // for (ConditionSeries& series : ...) modifier_count = action.modifiers.size().u8(); - ice::array::push_back(final_modifiers, action.modifiers); + final_modifiers.push_back(action.modifiers); final_actions.push_back( InputActionInfo{ diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index a5d56fd4..fb613f1e 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -296,7 +296,7 @@ namespace ice { // We just cut anything below this index, because we want to pop everything up to this layer _layers.resize(idx); - ice::array::pop_back(_layers); // And pop the item itself + _layers.pop_back(); // And pop the item itself } } diff --git a/source/code/systems/input_system/private/input_controller.cxx b/source/code/systems/input_system/private/input_controller.cxx index fc4c0f29..cd37ddeb 100644 --- a/source/code/systems/input_system/private/input_controller.cxx +++ b/source/code/systems/input_system/private/input_controller.cxx @@ -5,7 +5,7 @@ #include "input_state_helpers.hxx" #include -#include +#include namespace ice::input { diff --git a/source/code/systems/input_system/private/input_keyboard.cxx b/source/code/systems/input_system/private/input_keyboard.cxx index 5130a266..21c0f2d4 100644 --- a/source/code/systems/input_system/private/input_keyboard.cxx +++ b/source/code/systems/input_system/private/input_keyboard.cxx @@ -5,7 +5,7 @@ #include "input_state_helpers.hxx" #include -#include +#include namespace ice::input { diff --git a/source/code/systems/input_system/private/input_mouse.cxx b/source/code/systems/input_system/private/input_mouse.cxx index ceb653e6..8d2d0cab 100644 --- a/source/code/systems/input_system/private/input_mouse.cxx +++ b/source/code/systems/input_system/private/input_mouse.cxx @@ -5,7 +5,7 @@ #include "input_state_helpers.hxx" #include -#include +#include namespace ice::input { diff --git a/source/code/systems/input_system/private/input_touchscreen.cxx b/source/code/systems/input_system/private/input_touchscreen.cxx index ff945f3a..4572a95b 100644 --- a/source/code/systems/input_system/private/input_touchscreen.cxx +++ b/source/code/systems/input_system/private/input_touchscreen.cxx @@ -6,7 +6,7 @@ #include #include -#include +#include namespace ice::input { diff --git a/source/code/systems/input_system/public/ice/input/device_event_queue.hxx b/source/code/systems/input_system/public/ice/input/device_event_queue.hxx index 2925287b..9b2e233f 100644 --- a/source/code/systems/input_system/public/ice/input/device_event_queue.hxx +++ b/source/code/systems/input_system/public/ice/input/device_event_queue.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include namespace ice::input { diff --git a/source/code/systems/input_system/public/ice/input/input_device.hxx b/source/code/systems/input_system/public/ice/input/input_device.hxx index b9c10a00..3c473af7 100644 --- a/source/code/systems/input_system/public/ice/input/input_device.hxx +++ b/source/code/systems/input_system/public/ice/input/input_device.hxx @@ -2,9 +2,9 @@ /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include -#include +#include #include #include diff --git a/source/code/systems/render_system/public/ice/render/render_driver.hxx b/source/code/systems/render_system/public/ice/render/render_driver.hxx index f01324da..a1d94343 100644 --- a/source/code/systems/render_system/public/ice/render/render_driver.hxx +++ b/source/code/systems/render_system/public/ice/render/render_driver.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx index ded6b32a..4184bbb8 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include From 4ed3854bdfafa911e24219b4f78f752757ac0fd6 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Mon, 12 Jan 2026 22:54:41 +0900 Subject: [PATCH 17/40] [WIP] Partial refactor of the Queue Type. #ICE-211 --- .../core/collections/public/ice/array.hxx | 80 +- .../public/ice/container/basic_container.hxx | 20 +- .../ice/container/container_concepts.hxx | 27 +- .../ice/container/contiguous_container.hxx | 22 +- .../public/ice/container/impl/queue_impl.inl | 689 +----------------- .../public/ice/container/queue.hxx | 98 --- .../public/ice/container_types.hxx | 37 +- .../core/collections/public/ice/queue.hxx | 612 ++++++++++++++++ .../core/collections/tests/test_queue.cxx | 164 ++--- .../engine/private/ecs/ecs_entity_index.cxx | 12 +- .../engine/private/ecs/ecs_entity_storage.cxx | 2 +- .../private/engine_state_tracker_default.cxx | 12 +- 12 files changed, 808 insertions(+), 967 deletions(-) create mode 100644 source/code/core/collections/public/ice/queue.hxx diff --git a/source/code/core/collections/public/ice/array.hxx b/source/code/core/collections/public/ice/array.hxx index 2bafdca5..7790c532 100644 --- a/source/code/core/collections/public/ice/array.hxx +++ b/source/code/core/collections/public/ice/array.hxx @@ -38,22 +38,27 @@ namespace ice ValueType* _data; inline explicit Array(ice::Allocator& alloc) noexcept; + inline ~Array() noexcept; + inline Array(Array&& other) noexcept; inline Array(Array const& other) noexcept requires std::copy_constructible; - inline ~Array() noexcept; inline Array( ice::Allocator& alloc, ice::Span values ) noexcept requires std::copy_constructible; - // API Requirements Of: Container and Resizable Container - template - constexpr auto data(this Self& self) noexcept -> ice::container::ValuePtr { return self._data; } + inline auto operator=(Array&& other) noexcept -> Array&; + inline auto operator=(Array const& other) noexcept -> Array& + requires std::copy_constructible; + + // API Requirements Of: Container constexpr auto size() const noexcept -> ice::ncount { return { _count, sizeof(ValueType) }; } // API Requirements Of: Resizable Container + template + constexpr auto data(this Self& self) noexcept -> ice::container::ValuePtr { return self._data; } constexpr auto capacity() const noexcept -> ice::ncount { return { _capacity, sizeof(ValueType) }; } constexpr void set_capacity(ice::ncount new_capacity) noexcept; constexpr void resize(ice::ncount new_size) noexcept; @@ -65,8 +70,7 @@ namespace ice inline void push_back(ItemType&& item) noexcept; template - requires (std::convertible_to, Type> - && std::is_constructible_v>) + requires (ice::concepts::CompatibleContainer) inline void push_back(ContainerT const& other) noexcept; inline void pop_back(ice::ncount count = 1_count) noexcept; @@ -75,19 +79,13 @@ namespace ice constexpr auto data_view(this Array const& self) noexcept -> ice::Data; constexpr auto memory_view(this Array& self) noexcept -> ice::Memory; - inline auto operator=(Array&& other) noexcept -> Array&; - inline auto operator=(Array const& other) noexcept -> Array& - requires std::copy_constructible; - + // Operators and implicit conversions inline operator ice::Span() noexcept; inline operator ice::Span() const noexcept; }; template - auto data_view(ice::Array const& arr) noexcept -> ice::Data - { - return arr.data_view(); - } + auto data_view(ice::Array const& arr) noexcept -> ice::Data = delete; template inline Array::Array(ice::Allocator& alloc) noexcept @@ -97,6 +95,17 @@ namespace ice , _data{ nullptr } { } + template + inline Array::~Array() noexcept + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_destruct_n_at(_data, _count); + } + + _allocator->deallocate(memory_view()); + } + template inline Array::Array(Array&& other) noexcept : _allocator{ other._allocator } @@ -137,24 +146,12 @@ namespace ice } } - template - inline Array::~Array() noexcept - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_n_at(_data, _count); - } - - _allocator->deallocate(memory_view()); - } - template inline Array::Array( ice::Allocator& alloc, ice::Span values - ) noexcept - requires std::copy_constructible - : _allocator{ &alloc } + ) noexcept requires std::copy_constructible + : _allocator{ &alloc } , _capacity{ 0 } , _count{ 0 } , _data{ nullptr } @@ -228,18 +225,6 @@ namespace ice return *this; } - template - inline Array::operator ice::Span() noexcept - { - return Span{ _data, _count }; - } - - template - inline Array::operator ice::Span() const noexcept - { - return Span{ _data, _count }; - } - template inline constexpr void ice::Array::set_capacity(ice::ncount new_capacity) noexcept { @@ -349,8 +334,7 @@ namespace ice template template - requires (std::convertible_to, Type> - && std::is_constructible_v>) + requires (ice::concepts::CompatibleContainer) inline void ice::Array::push_back(ContainerT const& other) noexcept { ice::ncount const current_size = size(); @@ -408,5 +392,17 @@ namespace ice }; } + template + inline Array::operator ice::Span() noexcept + { + return Span{ _data, _count }; + } + + template + inline Array::operator ice::Span() const noexcept + { + return Span{ _data, _count }; + } + } // namespace ice diff --git a/source/code/core/collections/public/ice/container/basic_container.hxx b/source/code/core/collections/public/ice/container/basic_container.hxx index 7e574ced..4307e7b4 100644 --- a/source/code/core/collections/public/ice/container/basic_container.hxx +++ b/source/code/core/collections/public/ice/container/basic_container.hxx @@ -19,15 +19,31 @@ namespace ice::container } template + requires ice::concepts::ContiguousContainer || ice::concepts::IterableContainer constexpr auto first(this Self&& self) noexcept -> ice::container::ValueRef { - return self.data()[0]; + if constexpr (ice::concepts::ContiguousContainer) + { + return self.data()[0]; + } + else + { + return *self.begin(); + } } template + requires ice::concepts::ContiguousContainer || ice::concepts::ReverseIterableContainer constexpr auto last(this Self&& self) noexcept -> ice::container::ValueRef { - return self.data()[self.size() - 1]; + if constexpr (ice::concepts::ContiguousContainer) + { + return self.data()[self.size() - 1]; + } + else + { + return *self.rbegin(); + } } }; diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index cc7c5e3e..5a2bede3 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -20,12 +20,11 @@ namespace ice::concepts template concept Container = ContainerType && requires(T t) { { t.size() } -> std::convertible_to; - { t.data() } -> std::convertible_to::ValueType const*>; }; template concept ResizableContainer = Container && requires(T t, ice::ncount size) { - { t.data() } -> std::convertible_to::ValueType*>; + // { t.data() } -> std::convertible_to::ValueType*>; { t.capacity() } -> std::convertible_to; { t.set_capacity(size) } -> std::convertible_to; { t.resize(size) } -> std::convertible_to; @@ -37,9 +36,15 @@ namespace ice::concepts template concept ContiguousContainer = Container && requires(T t) { std::is_same_v::ContainerTag, ContiguousContainerTag>; + { t.data() } -> std::convertible_to::ValueType const*>; { t.data_view() } -> std::convertible_to; }; + template + concept ContiguousResizableContainer = ResizableContainer && ContiguousContainer && requires(T t) { + { t.memory_view() } -> std::convertible_to; + }; + template concept TrivialContainerLogic = ContainerType && TrivialContainerLogicAllowed::ValueType>; @@ -88,6 +93,9 @@ namespace ice::container template using ValueRef = ValueType&; + template + using ValueRVal = ValueType&&; + template using ValuePtr = ValueType*; @@ -108,10 +116,23 @@ namespace ice::container namespace ice::concepts { + template + concept CompatibleContainer = std::convertible_to< + ice::container::ValueType, + TargetT + >;// && std::is_constructible_v>) + + template - concept IterableContainer = ContainerType && requires(T t) { + concept IterableContainer = ice::concepts::Container && requires(T t) { { t.begin() } -> std::convertible_to>; { t.end() } -> std::convertible_to>; }; + template + concept ReverseIterableContainer = requires(T t) { + { t.rbegin() } -> std::convertible_to>; + { t.rend() } -> std::convertible_to>; + }; + } // namespace ice::concepts diff --git a/source/code/core/collections/public/ice/container/contiguous_container.hxx b/source/code/core/collections/public/ice/container/contiguous_container.hxx index 5b0b9e14..f4de905a 100644 --- a/source/code/core/collections/public/ice/container/contiguous_container.hxx +++ b/source/code/core/collections/public/ice/container/contiguous_container.hxx @@ -10,7 +10,7 @@ namespace ice::container struct ContiguousContainer : ice::container::BasicContainer { // Accessing Data with Spans - template + template constexpr auto subspan( this Self&& self, ice::nindex from, @@ -23,7 +23,7 @@ namespace ice::container return { self.data() + from_start.native(), count.min_value_or(remaining_count, remaining_count)}; } - template + template constexpr auto subspan( this Self&& self, ice::ref32 refval @@ -32,7 +32,7 @@ namespace ice::container return self.subspan(refval.offset, refval.size); } - template + template constexpr auto headspan( this Self&& self, ice::ncount count = 1 @@ -42,7 +42,7 @@ namespace ice::container return { self.data(), count.min_value_or(self.size(), 0_count) }; } - template + template constexpr auto tailspan( this Self&& self, ice::nindex offset = 1 @@ -56,45 +56,45 @@ namespace ice::container } // Iteration interface - template + template constexpr auto begin(this Self&& self) noexcept -> ice::container::Iterator { return { self.data() }; } - template + template constexpr auto end(this Self&& self) noexcept -> ice::container::Iterator { return { self.data() + self.size() }; } - template + template constexpr auto rbegin(this Self&& self) noexcept -> ice::container::ReverseIterator { return ice::container::ReverseIterator{ self.data() + self.size() }; } - template + template constexpr auto rend(this Self&& self) noexcept -> ice::container::ReverseIterator { return ice::container::ReverseIterator{ self.data() }; } // Operators - template + template constexpr auto operator[](this Self&& self, ice::nindex index) noexcept -> ice::container::ValueRef { return self.data()[index]; } // Data API - template + template inline auto meminfo(this Self const& self) noexcept -> ice::meminfo { return ice::meminfo_of * self.size(); } - template requires (ice::concepts::TrivialContainerLogic) + template requires (ice::concepts::TrivialContainerLogic) inline auto memset(this Self const& self, ice::u8 value) noexcept -> ice::Memory { ice::Memory mem{ self.data(), self.size(), ice::align_of> }; diff --git a/source/code/core/collections/public/ice/container/impl/queue_impl.inl b/source/code/core/collections/public/ice/container/impl/queue_impl.inl index e2b7a320..56195dc4 100644 --- a/source/code/core/collections/public/ice/container/impl/queue_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/queue_impl.inl @@ -4,604 +4,18 @@ namespace ice { - namespace queue::detail - { - - template - inline void destroy_head_items(ice::Queue& queue, ice::u32 destroy_count) noexcept; - - template - inline void destroy_tail_items(ice::Queue& queue, ice::u32 destroy_count) noexcept; - - template - inline void copy_items_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept; - - template - inline void move_items_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept; - - template - inline void copy_memory_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept; - - - } // namespace queue::detail - - template - inline Queue::Queue(ice::Allocator& alloc) noexcept - : _allocator{ &alloc } - , _capacity{ 0 } - , _count{ 0 } - , _offset{ 0 } - , _data{ nullptr } - { - } - - template - inline Queue::Queue(Queue&& other) noexcept - : _allocator{ other._allocator } - , _capacity{ ice::exchange(other._capacity, 0) } - , _count{ ice::exchange(other._count, 0) } - , _offset{ ice::exchange(other._offset, 0) } - , _data{ ice::exchange(other._data, nullptr) } - { - } - - template - inline Queue::Queue(Queue const& other) noexcept - requires std::copy_constructible - : _allocator{ other._allocator } - , _capacity{ 0 } - , _count{ 0 } - , _offset{ 0 } - , _data{ nullptr } - { - if (other._count > 0) - { - ice::queue::set_capacity(*this, other._count); - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::queue::detail::copy_items_to_new_location(ice::queue::memory(*this), other); - } - else - { - ice::queue::detail::copy_memory_to_new_location(ice::queue::memory(*this), other); - } - - _count = other._count; - } - } - - template - inline Queue::~Queue() noexcept - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::u32 const last_raw_idx = _offset + _count; - if (last_raw_idx > _capacity) - { - ice::u32 const wrapped_count = last_raw_idx - _capacity; - ice::mem_destruct_n_at(_data + _offset, _count - wrapped_count); // Destroyes elements at the end of the ring buffer [_offset, count_until_capacity) - ice::mem_destruct_n_at(_data, wrapped_count); // Destroys wrapped tail elements [0, tail_size) - } - else - { - ice::mem_destruct_n_at(_data + _offset, _count); - } - } - - _allocator->deallocate(ice::queue::memory(*this)); - } - - template - inline auto Queue::operator=(Queue&& other) noexcept -> Queue& - { - if (this != &other) - { - ice::queue::set_capacity(*this, 0); - - _capacity = ice::exchange(other._capacity, 0); - _count = ice::exchange(other._count, 0); - _offset = ice::exchange(other._offset, 0); - _data = ice::exchange(other._data, nullptr); - } - return *this; - } - - template - inline auto Queue::operator=(Queue const& other) noexcept -> Queue& - requires std::copy_constructible - { - if (this != &other) - { - ice::queue::clear(*this); - ice::queue::reserve(*this, other._capacity); - - if (other._count > 0) - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::queue::detail::copy_items_to_new_location(ice::queue::memory(*this), other); - } - else - { - ice::queue::detail::copy_memory_to_new_location(ice::queue::memory(*this), other); - } - } - - _count = other._count; - } - return *this; - } - - template - inline auto Queue::operator[](ice::u32 idx) noexcept -> Type& - { - return _data[(idx + _offset) % _capacity]; - } - - template - inline auto Queue::operator[](ice::u32 idx) const noexcept -> Type const& - { - return _data[(idx + _offset) % _capacity]; - } - - namespace queue::detail - { - - template - void destroy_head_items(ice::Queue& queue, ice::u32 destroy_count) noexcept - { - ice::u32 const raw_end_idx = queue._offset + destroy_count; - ice::u32 const start_idx = queue._offset; - ice::u32 const end_idx = raw_end_idx % queue._capacity; - - // We got a wrapped case - if (start_idx > end_idx) - { - ice::mem_destruct_n_at(queue._data + start_idx, queue._capacity - start_idx); - ice::mem_destruct_n_at(queue._data, end_idx); - } - else - { - ice::mem_destruct_n_at(queue._data + start_idx, destroy_count); - } - } - - template - void destroy_tail_items(ice::Queue& queue, ice::u32 destroy_count) noexcept - { - ice::u32 const raw_end_idx = queue._offset + queue._count; - ice::u32 const start_idx = (raw_end_idx - destroy_count) % queue._capacity; - ice::u32 const end_idx = raw_end_idx % queue._capacity; - - // We got a wrapped case - if (start_idx > end_idx) - { - ice::mem_destruct_n_at(queue._data + start_idx, queue._capacity - start_idx); - ice::mem_destruct_n_at(queue._data, end_idx); - } - else - { - ice::mem_destruct_n_at(queue._data + start_idx, destroy_count); - } - } - - template - inline void copy_items_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept - { - ice::u32 const start_idx = queue._offset; - ice::u32 const head_count = queue._capacity - start_idx; - ice::usize const head_size = ice::size_of * head_count; - - ice::mem_copy_construct_n_at(dest, queue._data + start_idx, head_count); - // Move destination pointer - dest.size.value = static_cast((dest.size - head_size).value); - dest.location = ice::ptr_add(dest.location, ice::size_of * head_count); - ice::mem_copy_construct_n_at(dest, queue._data, queue._count - head_count); - } - - template - inline void move_items_to_new_location(ice::Memory dest, ice::Queue& queue) noexcept - { - ice::u32 const start_idx = queue._offset; - ice::u32 const head_count = queue._capacity - start_idx; - ice::usize const head_size = ice::size_of * head_count; - - ice::mem_move_construct_n_at(dest, queue._data + start_idx, head_count); - // Move destination pointer - dest.size.value = static_cast((dest.size - head_size).value); - dest.location = ice::ptr_add(dest.location, ice::size_of *head_count); - ice::mem_move_construct_n_at(dest, queue._data, queue._count - head_count); - - // Destroy the items left in the old queue memory. - ice::mem_destruct_n_at(queue._data + start_idx, head_count); - ice::mem_destruct_n_at(queue._data, queue._count - head_count); - } - - template - inline void copy_memory_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept - { - ice::usize const total_size = ice::size_of * queue._count; - - ice::u32 const head_count = std::min(queue._offset + queue._count, queue._capacity) - queue._offset; - ice::u32 const tail_count = queue._count - head_count; - - ice::usize const head_size = ice::size_of * head_count; - ice::usize const head_end_offset = ice::size_of * head_count; - ice::usize const tail_end_offset = ice::size_of * tail_count; - - ice::memcpy( - dest, - Data{ - .location = queue._data + queue._offset, - .size = head_end_offset, - .alignment = ice::align_of - } - ); - // Move destination pointer - dest.size.value = static_cast((dest.size - head_size).value); - dest.location = ice::ptr_add(dest.location, head_size); - ice::memcpy( - dest, - Data{ - .location = queue._data, - .size = tail_end_offset, - .alignment = ice::align_of - } - ); - } - - } // namespace queue::detail - namespace queue { - template - inline void set_capacity(ice::Queue& queue, ice::u32 new_capacity) noexcept - { - if (new_capacity == queue._capacity) - { - return; - } - - if (new_capacity < queue._count) - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::queue::detail::destroy_tail_items(queue, queue._count - new_capacity); - } - - queue._count = new_capacity; - } - - Type* new_data = nullptr; - if (new_capacity > 0) - { - ice::AllocResult new_buffer = queue._allocator->allocate(ice::meminfo_of *new_capacity); - if (queue._count > 0) - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::queue::detail::move_items_to_new_location(new_buffer, queue); - } - else - { - ice::queue::detail::copy_memory_to_new_location(new_buffer, queue); - } - } - new_data = reinterpret_cast(new_buffer.memory); - } - - queue._allocator->deallocate(ice::queue::memory(queue)); - queue._data = new_data; - queue._capacity = new_capacity; - queue._offset = 0; // Ofset is set to 0, as moving memory between buffers re-arranges the items. - } - - template - inline void reserve(ice::Queue& queue, ice::u32 min_capacity) noexcept - { - if (queue._capacity < min_capacity) - { - ice::queue::set_capacity(queue, min_capacity); - } - } - - template - inline void grow(ice::Queue& queue, ice::u32 min_capacity /*= 0*/) noexcept - { - ice::u32 new_capacity = queue._count * 2 + 4; - if (new_capacity < min_capacity) - { - new_capacity = min_capacity; - } - ice::queue::set_capacity(queue, new_capacity); - } - - template - inline void resize(ice::Queue& queue, ice::u32 new_count) noexcept - { - if (queue._capacity < new_count) - { - ice::queue::set_capacity(queue, new_count); - } - - // Even for trivial logic we construct items so at least the default ctor is called. - if (new_count > queue._count) - { - ice::u32 const missing_items = new_count - queue._count; - ice::u32 const start_idx = (queue._offset + queue._count) % queue._capacity; - - ice::u32 const end_idx = ice::min(start_idx + missing_items, queue._capacity); - ice::u32 const wrapped_end_idx = missing_items - (end_idx - start_idx); - - // Construct until we hit end of the queue buffer - ice::mem_default_construct_n_at( - Memory{ - .location = queue._data + start_idx, - .size = ice::size_of * (end_idx - start_idx), - .alignment = ice::align_of - }, - (end_idx - start_idx) - ); - // Construct the rest wrapped around the buffer - ice::mem_default_construct_n_at( - Memory{ - .location = queue._data, - .size = ice::size_of * wrapped_end_idx, - .alignment = ice::align_of - }, - wrapped_end_idx - ); - } - else if constexpr (Logic == ContainerLogic::Complex) - { - ice::queue::detail::destroy_tail_items(queue, queue._count - new_count); - } - - queue._count = new_count; - } - - template - inline void shrink(ice::Queue& queue) noexcept - { - ice::queue::set_capacity(queue, queue._count); - } - - template - inline void clear(ice::Queue& queue) noexcept - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::queue::detail::destroy_head_items(queue, queue._count); - } - - queue._count = 0; - queue._offset = 0; - } - - template - requires std::move_constructible - inline void push_back(ice::Queue& queue, Type&& item) noexcept - { - if (queue._count == queue._capacity) - { - ice::queue::grow(queue); - } - - ice::u32 const item_idx = (queue._offset + queue._count) % queue._capacity; - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_move_construct_at( - Memory{ .location = queue._data + item_idx, .size = ice::size_of, .alignment = ice::align_of }, - ice::forward(item) - ); - } - else - { - queue._data[item_idx] = Type{ item }; - } - - queue._count += 1; - } - - template - requires std::copy_constructible && std::convertible_to - inline void push_back(ice::Queue& queue, Value const& item) noexcept - { - if (queue._count == queue._capacity) - { - ice::queue::grow(queue); - } - - ice::u32 const item_idx = (queue._offset + queue._count) % queue._capacity; - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_at( - Memory{ .location = queue._data + item_idx, .size = ice::size_of, .alignment = ice::align_of }, - item - ); - } - else - { - queue._data[item_idx] = Type{ item }; - } - - queue._count += 1; - } - - template - requires std::copy_constructible - inline void push_back(ice::Queue& queue, ice::Queue const& items) noexcept; - - template - requires std::copy_constructible - inline void push_back(ice::Queue& queue, ice::Span items) noexcept - { - ice::u32 const required_capacity = queue._count + items.size().u32(); - if (required_capacity > queue._capacity) - { - ice::queue::grow(queue, required_capacity); - } - - ice::u32 const span_count = items.size().u32(); - ice::u32 const start_idx = (queue._offset + queue._count) % queue._capacity; - ice::u32 const end_idx = ice::min(queue._capacity, start_idx + span_count); - - // The space can we use before wrapping around the buffer. - ice::u32 const head_space = end_idx - start_idx; - // The space after the wrapped buffer we still need to allocate. Can be 0. - ice::u32 const tail_space = span_count - head_space; - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - Memory{ - .location = queue._data + start_idx, - .size = ice::size_of * head_space, - .alignment = ice::align_of - }, - items.data(), - head_space - ); - ice::mem_copy_construct_n_at( - Memory{ - .location = queue._data, - .size = ice::size_of * tail_space, - .alignment = ice::align_of - }, - items.data() + head_space, - tail_space - ); - } - else - { - ice::memcpy( - Memory{ - .location = queue._data + start_idx, - .size = ice::size_of * head_space, - .alignment = ice::align_of - }, - Data{ - .location = items.data(), - .size = ice::size_of * head_space, - .alignment = ice::align_of - } - ); - ice::memcpy( - Memory{ - .location = queue._data, - .size = ice::size_of * tail_space, - .alignment = ice::align_of - }, - Data{ - .location = items.data() + head_space, - .size = ice::size_of * tail_space, - .alignment = ice::align_of - } - ); - } - - queue._count += items.size().u32(); - } - - template - inline void pop_back(ice::Queue& queue, ice::u32 count /*= 1*/) noexcept - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::queue::detail::destroy_tail_items(queue, ice::min(count, queue._count)); - } - - if (queue._count > count) - { - queue._count -= count; - } - else - { - queue._count = 0; - queue._offset = 0; - } - } - - template - requires std::move_constructible - inline void push_front(ice::Queue& queue, Type&& item) noexcept - { - if (queue._count == queue._capacity) - { - ice::queue::grow(queue); - } - - if (queue._offset == 0) - { - queue._offset = queue._capacity; - } - - queue._offset -= 1; - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_move_construct_at( - Memory{ .location = queue._data + queue._offset, .size = ice::size_of, .alignment = ice::align_of }, - ice::forward(item) - ); - } - else - { - queue._data[queue._offset] = Type{ item }; - } - - queue._count += 1; - } - - template - requires std::copy_constructible && std::convertible_to - inline void push_front(ice::Queue& queue, Value const& item) noexcept - { - if (queue._count == queue._capacity) - { - ice::queue::grow(queue); - } - - if (queue._offset == 0) - { - queue._offset = queue._capacity; - } - - ice::u32 const item_idx = queue._offset - 1; - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_at( - Memory{ .location = queue._data + item_idx, .size = ice::size_of, .alignment = ice::align_of }, - item - ); - } - else - { - queue._data[item_idx] = item; - } - - queue._count += 1; - } - - template - requires std::copy_constructible - inline void push_front(ice::Queue& queue, ice::Queue const& items) noexcept; - - template - requires std::copy_constructible - inline void push_front(ice::Queue& queue, ice::Span items) noexcept; - template inline auto take_front(ice::Queue& queue, ice::Span out_values) noexcept -> ice::u32 { - ice::u32 const taken_items = ice::min(out_values.size().u32(), ice::count(queue)); + ice::ncount const taken_items = ice::min(out_values.size(), queue.size()); // (offset, end][0, remaining) - ice::u32 const first_part = ice::min(queue._offset + taken_items, queue._capacity); - ice::u32 const second_part = (queue._offset + taken_items) - first_part; - ice::u32 const first_part_count = first_part - queue._offset; + ice::ncount const first_part = ice::min(queue._offset + taken_items, queue._capacity); + ice::ncount const second_part = (queue._offset + taken_items) - first_part; + ice::ncount const first_part_count = first_part - queue._offset; if constexpr (Logic == ContainerLogic::Complex) { @@ -610,89 +24,15 @@ namespace ice } else { - ice::memcpy(out_values.begin(), queue._data + queue._offset, first_part_count * sizeof(Type)); - ice::memcpy(out_values.begin() + first_part_count, queue._data, second_part * sizeof(Type)); - } - - ice::queue::pop_front(queue, taken_items); - return taken_items; - } - - template - inline void pop_front(ice::Queue& queue, ice::u32 count /*= 1*/) noexcept - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::queue::detail::destroy_head_items(queue, ice::min(count, queue._count)); + ice::memcpy(out_values.begin(), queue._data + queue._offset, ice::size_of * first_part_count); + ice::memcpy(out_values.begin() + first_part_count, queue._data, ice::size_of * second_part); } - if (queue._count > count) - { - queue._count -= count; - queue._offset = (queue._offset + count) % queue._capacity; - } - else - { - queue._count = 0; - queue._offset = 0; - } - } - - template - inline auto front(ice::Queue& queue) noexcept -> Type& - { - return queue._data[queue._offset]; - } - - template - inline auto back(ice::Queue& queue) noexcept -> Type& - { - return queue._data[((queue._offset + queue._count) - 1) % queue._capacity]; - } - - - template - inline auto count(ice::Queue const& queue) noexcept -> ice::u32 - { - return queue._count; - } - - template - inline auto capacity(ice::Queue const& queue) noexcept -> ice::u32 - { - return queue._capacity; - } - - template - inline auto size_bytes(ice::Queue const& queue) noexcept -> ice::usize - { - return ice::queue::count(queue) * ice::size_of; - } - - template - inline bool any(ice::Queue const& queue) noexcept - { - return queue._count != 0; - } - - template - inline bool empty(ice::Queue const& queue) noexcept - { - return queue._count == 0; - } - - template - inline auto front(ice::Queue const& queue) noexcept -> Type const& - { - return queue._data[queue._offset]; - } - - template - inline auto back(ice::Queue const& queue) noexcept -> Type const& - { - return queue._data[((queue._offset + queue._count) - 1) % queue._capacity]; + queue.pop_front(taken_items.u32()); + return taken_items.u32(); } +#if 0 template inline void for_each(ice::Queue const& queue, Fn&& fn) noexcept { @@ -743,16 +83,7 @@ namespace ice ice::forward(fn)(queue._data[queue._offset]); } - - template - inline auto memory(ice::Queue& queue) noexcept -> ice::Memory - { - return ice::Memory{ - .location = queue._data, - .size = ice::size_of * queue._capacity, - .alignment = ice::align_of - }; - } +#endif } // namespace queue diff --git a/source/code/core/collections/public/ice/container/queue.hxx b/source/code/core/collections/public/ice/container/queue.hxx index 3d193a1b..f07fae2c 100644 --- a/source/code/core/collections/public/ice/container/queue.hxx +++ b/source/code/core/collections/public/ice/container/queue.hxx @@ -8,109 +8,11 @@ namespace ice::queue { - // TODO: Move to details (we don't need this, also makes no sense for this queue) - template - inline void set_capacity(ice::Queue& queue, ice::u32 new_capacity) noexcept; - - template - inline void reserve(ice::Queue& queue, ice::u32 min_capacity) noexcept; - - template - inline void grow(ice::Queue& queue, ice::u32 min_capacity = 0) noexcept; - - // TODO: Move to details (we don't need this, also makes no sense for this queue) - template - inline void resize(ice::Queue& queue, ice::u32 new_count) noexcept; - - template - inline void shrink(ice::Queue& queue) noexcept; - - template - inline void clear(ice::Queue& queue) noexcept; - - template - requires std::move_constructible - inline void push_back(ice::Queue& queue, Type&& item) noexcept; - - template - requires std::copy_constructible&& std::convertible_to - inline void push_back(ice::Queue& queue, Value const& item) noexcept; - - template - requires std::copy_constructible - inline void push_back(ice::Queue& queue, ice::Queue const& items) noexcept; - - template - requires std::copy_constructible - inline void push_back(ice::Queue& queue, ice::Span items) noexcept; - - template - inline void pop_back(ice::Queue& queue, ice::u32 count = 1) noexcept; - - template - requires std::move_constructible - inline void push_front(ice::Queue& queue, Type&& item) noexcept; - - template - requires std::copy_constructible && std::convertible_to - inline void push_front(ice::Queue& queue, Value const& item) noexcept; - - template - requires std::copy_constructible - inline void push_front(ice::Queue& queue, ice::Queue const& items) noexcept; - - template - requires std::copy_constructible - inline void push_front(ice::Queue& queue, ice::Span items) noexcept; - - template - inline void pop_front(ice::Queue& queue, ice::u32 count = 1) noexcept; - - template - inline auto front(ice::Queue& queue) noexcept -> Type&; - - template - inline auto back(ice::Queue& queue) noexcept -> Type&; - - - template - inline auto count(ice::Queue const& queue) noexcept -> ice::u32; - - template - inline auto capacity(ice::Queue const& queue) noexcept -> ice::u32; - - template - inline auto size_bytes(ice::Queue const& queue) noexcept -> ice::usize; - - template - inline bool any(ice::Queue const& queue) noexcept; - - template - inline bool empty(ice::Queue const& queue) noexcept; - - template - inline auto front(ice::Queue const& queue) noexcept -> Type const&; - - template - inline auto back(ice::Queue const& queue) noexcept -> Type const&; - - template - inline void for_each(ice::Queue const& queue, Fn&& fn) noexcept; - - template - inline void for_each_reverse(ice::Queue const& queue, Fn&& fn) noexcept; - - - template - inline auto memory(ice::Queue& queue) noexcept -> ice::Memory; - } // namespace ice::queue namespace ice { - using ice::queue::count; - } // namespace ice #include "impl/queue_impl.inl" diff --git a/source/code/core/collections/public/ice/container_types.hxx b/source/code/core/collections/public/ice/container_types.hxx index f66c7d39..0e7dd660 100644 --- a/source/code/core/collections/public/ice/container_types.hxx +++ b/source/code/core/collections/public/ice/container_types.hxx @@ -10,46 +10,11 @@ #include #include #include +#include namespace ice { - //! \brief A double ended queue build on a circular buffer. - //! - //! \details Manages a memory block big enough to hold the items that it holds. - //! - //! \tparam Logic The logic used during memory operations for the given type. - //! This value is set by the user to enforce expected behavior for stored types. - template> - struct Queue - { - static_assert( - Logic == ContainerLogic::Complex || ice::TrivialContainerLogicAllowed, - "Collection element type is not allowed with 'Trivial' logic!" - ); - - using ValueType = Type; - - ice::Allocator* _allocator; - ice::u32 _capacity; - ice::u32 _count; - ice::u32 _offset; - Type* _data; - - inline explicit Queue(ice::Allocator& alloc) noexcept; - inline Queue(Queue&& other) noexcept; - inline Queue(Queue const& other) noexcept - requires std::copy_constructible; - inline ~Queue() noexcept; - - inline auto operator=(Queue&& other) noexcept -> Queue&; - inline auto operator=(Queue const& other) noexcept -> Queue& - requires std::copy_constructible; - - auto operator[](ice::u32 idx) noexcept -> Type&; - auto operator[](ice::u32 idx) const noexcept -> Type const&; - }; - //! \brief A hash map build on a single block of memory. //! diff --git a/source/code/core/collections/public/ice/queue.hxx b/source/code/core/collections/public/ice/queue.hxx new file mode 100644 index 00000000..6c561aff --- /dev/null +++ b/source/code/core/collections/public/ice/queue.hxx @@ -0,0 +1,612 @@ +#pragma once +#include +#include +#include + +namespace ice +{ + + //! \brief A double ended queue, build on a circular buffer. + //! + //! \details Manages a memory block big enough to hold the items that it holds. + //! + //! \tparam Logic The logic used during memory operations for the given type. + //! This value is set by the user to enforce expected behavior for stored types. + template> + struct Queue + : public ice::container::BasicContainer + , public ice::container::ResizableContainer + { + static_assert( + Logic == ContainerLogic::Complex || ice::TrivialContainerLogicAllowed, + "Collection element type is not allowed with 'Trivial' logic!" + ); + + using ValueType = Type; + using ConstContainerValueType = Type const; + using Iterator = Type*; + using ReverseIterator = std::reverse_iterator; + using ConstIterator = Type const*; + using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; + using ContainerTag = ice::concepts::ContiguousContainerTag; + + ice::Allocator* _allocator; + ice::u32 _capacity; + ice::u32 _count; + ice::u32 _offset; + Type* _data; + + inline explicit Queue(ice::Allocator& alloc) noexcept; + inline Queue(Queue&& other) noexcept; + inline Queue(Queue const& other) noexcept + requires std::copy_constructible; + inline ~Queue() noexcept; + + // API Requirements Of: Container + constexpr auto size() const noexcept -> ice::ncount { return { _count, sizeof(ValueType) }; } + + // API Requirements Of: Resizable Container + constexpr auto capacity() const noexcept -> ice::ncount { return { _capacity, sizeof(ValueType) }; } + constexpr void set_capacity(ice::ncount new_capacity) noexcept; + constexpr void resize(ice::ncount new_size) noexcept; + constexpr void clear() noexcept; + + // API Manipulation + template + requires std::convertible_to && std::is_constructible_v + constexpr void push_front(ItemType&& item) noexcept; + + template + requires std::convertible_to && std::is_constructible_v + constexpr void push_back(ItemType&& item) noexcept; + + // TODO: Think of changing it to iterable container? + template + requires (ice::concepts::CompatibleContainer) + constexpr void push_front(ContainerT const& other) noexcept; + + // TODO: Think of changing it to iterable container? + template + requires (ice::concepts::CompatibleContainer) + constexpr void push_back(ContainerT const& other) noexcept; + + constexpr void pop_front(ice::ncount count = 1_count) noexcept; + constexpr void pop_back(ice::ncount count = 1_count) noexcept; + + // Explicit functionality + template + constexpr auto front(this Self&& self) noexcept -> ice::container::ValueRef; + template + constexpr auto back(this Self&& self) noexcept -> ice::container::ValueRef; + + // API Requirements Of: Memory + constexpr auto memory_view(this Queue& self) noexcept -> ice::Memory; + + // Operators and implicit conversions + inline auto operator=(Queue&& other) noexcept -> Queue&; + inline auto operator=(Queue const& other) noexcept -> Queue& + requires std::copy_constructible; + + template + constexpr auto operator[]( + this Self&& self, ice::nindex idx + ) noexcept -> ice::container::ValueRef; + }; + + namespace queue::detail + { + + template + void destroy_head_items(ice::Queue& queue, ice::ncount destroy_count) noexcept + { + ice::u32 const raw_end_idx = queue._offset + destroy_count.u32(); + ice::nindex const start_idx = queue._offset; + ice::nindex const end_idx = raw_end_idx % queue._capacity; + + // We got a wrapped case + if (start_idx > end_idx) + { + ice::mem_destruct_n_at(queue._data + start_idx, queue._capacity - start_idx); + ice::mem_destruct_n_at(queue._data, end_idx); + } + else + { + ice::mem_destruct_n_at(queue._data + start_idx, destroy_count); + } + } + + template + void destroy_tail_items(ice::Queue& queue, ice::ncount destroy_count) noexcept + { + ice::u32 const raw_end_idx = queue._offset + queue._count; + ice::nindex const start_idx = (raw_end_idx - destroy_count.u32()) % queue._capacity; + ice::nindex const end_idx = raw_end_idx % queue._capacity; + + // We got a wrapped case + if (start_idx > end_idx) + { + ice::mem_destruct_n_at(queue._data + start_idx, queue._capacity - start_idx); + ice::mem_destruct_n_at(queue._data, end_idx); + } + else + { + ice::mem_destruct_n_at(queue._data + start_idx, destroy_count); + } + } + + template + inline void copy_items_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept + { + ice::u32 const start_idx = queue._offset; + ice::u32 const head_count = queue._capacity - start_idx; + ice::usize const head_size = ice::size_of * head_count; + + ice::mem_copy_construct_n_at(dest, queue._data + start_idx, head_count); + // Move destination pointer + dest.size.value = static_cast((dest.size - head_size).value); + dest.location = ice::ptr_add(dest.location, ice::size_of * head_count); + ice::mem_copy_construct_n_at(dest, queue._data, queue._count - head_count); + } + + template + inline void move_items_to_new_location(ice::Memory dest, ice::Queue& queue) noexcept + { + ice::u32 const start_idx = queue._offset; + ice::u32 const head_count = queue._capacity - start_idx; + ice::usize const head_size = ice::size_of * head_count; + + ice::mem_move_construct_n_at(dest, queue._data + start_idx, head_count); + // Move destination pointer + dest.size.value = static_cast((dest.size - head_size).value); + dest.location = ice::ptr_add(dest.location, ice::size_of *head_count); + ice::mem_move_construct_n_at(dest, queue._data, queue._count - head_count); + + // Destroy the items left in the old queue memory. + ice::mem_destruct_n_at(queue._data + start_idx, head_count); + ice::mem_destruct_n_at(queue._data, queue._count - head_count); + } + + template + inline void copy_memory_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept + { + ice::usize const total_size = ice::size_of * queue._count; + + ice::u32 const head_count = std::min(queue._offset + queue._count, queue._capacity) - queue._offset; + ice::u32 const tail_count = queue._count - head_count; + + ice::usize const head_size = ice::size_of * head_count; + ice::usize const head_end_offset = ice::size_of * head_count; + ice::usize const tail_end_offset = ice::size_of * tail_count; + + ice::memcpy( + dest, + Data{ + .location = queue._data + queue._offset, + .size = head_end_offset, + .alignment = ice::align_of + } + ); + // Move destination pointer + dest.size.value = static_cast((dest.size - head_size).value); + dest.location = ice::ptr_add(dest.location, head_size); + ice::memcpy( + dest, + Data{ + .location = queue._data, + .size = tail_end_offset, + .alignment = ice::align_of + } + ); + } + + } // namespace queue::detail + + template + inline Queue::Queue(ice::Allocator& alloc) noexcept + : _allocator{ &alloc } + , _capacity{ 0 } + , _count{ 0 } + , _offset{ 0 } + , _data{ nullptr } + { + } + + template + inline Queue::Queue(Queue&& other) noexcept + : _allocator{ other._allocator } + , _capacity{ ice::exchange(other._capacity, 0) } + , _count{ ice::exchange(other._count, 0) } + , _offset{ ice::exchange(other._offset, 0) } + , _data{ ice::exchange(other._data, nullptr) } + { + } + + template + inline Queue::Queue(Queue const& other) noexcept requires std::copy_constructible + : _allocator{ other._allocator } + , _capacity{ 0 } + , _count{ 0 } + , _offset{ 0 } + , _data{ nullptr } + { + if (other._count > 0) + { + this->set_capacity(other.size()); + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::queue::detail::copy_items_to_new_location(this->memory_view(), other); + } + else + { + ice::queue::detail::copy_memory_to_new_location(this->memory_view(), other); + } + + _count = other._count; + } + } + + template + inline Queue::~Queue() noexcept + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::u32 const last_raw_idx = _offset + _count; + if (last_raw_idx > _capacity) + { + ice::u32 const wrapped_count = last_raw_idx - _capacity; + // Destroyes elements at the end of the ring buffer [_offset, count_until_capacity) + ice::mem_destruct_n_at(_data + _offset, _count - wrapped_count); + // Destroys wrapped tail elements [0, tail_size) + ice::mem_destruct_n_at(_data, wrapped_count); + } + else + { + ice::mem_destruct_n_at(_data + _offset, _count); + } + } + + _allocator->deallocate(this->memory_view()); + } + + template + inline auto Queue::operator=(Queue&& other) noexcept -> Queue& + { + if (this != &other) + { + this->set_capacity(0_count); + + _capacity = ice::exchange(other._capacity, 0); + _count = ice::exchange(other._count, 0); + _offset = ice::exchange(other._offset, 0); + _data = ice::exchange(other._data, nullptr); + } + return *this; + } + + template + inline auto Queue::operator=(Queue const& other) noexcept -> Queue& + requires std::copy_constructible + { + if (this != &other) + { + this->clear(); + this->reserve(other.size()); + + if (other._count > 0) + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::queue::detail::copy_items_to_new_location(this->memory_view(), other); + } + else + { + ice::queue::detail::copy_memory_to_new_location(this->memory_view(), other); + } + } + + _count = other._count; + } + return *this; + } + + template + inline constexpr void ice::Queue::set_capacity(ice::ncount new_capacity) noexcept + { + if (new_capacity == _capacity) + { + return; + } + + if (new_capacity < _count) + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::queue::detail::destroy_tail_items(*this, _count - new_capacity); + } + + _count = new_capacity.u32(); + } + + Type* new_data = nullptr; + if (new_capacity > 0) + { + ice::AllocResult new_buffer = _allocator->allocate(ice::meminfo_of * new_capacity); + if (_count > 0) + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::queue::detail::move_items_to_new_location(new_buffer, *this); + } + else + { + ice::queue::detail::copy_memory_to_new_location(new_buffer, *this); + } + } + new_data = reinterpret_cast(new_buffer.memory); + } + + _allocator->deallocate(this->memory_view()); + _data = new_data; + _capacity = new_capacity.u32(); + _offset = 0; + } + + template + inline constexpr void ice::Queue::resize(ice::ncount new_size) noexcept + { + if (_capacity < new_size) + { + set_capacity(new_size); + } + + // Even for trivial logic we construct items so at least the default ctor is called. + if (new_size > _count) + { + ice::ncount const missing_items = new_size - _count; + ice::nindex const start_idx = (_offset + _count) % _capacity; + + ice::nindex const end_idx = ice::min(start_idx + missing_items, _capacity); + ice::nindex const wrapped_end_idx = missing_items - (end_idx - start_idx); + + // Construct until we hit end of the queue buffer + ice::mem_default_construct_n_at( + Memory{ + .location = _data + start_idx, + .size = ice::size_of * (end_idx - start_idx), + .alignment = ice::align_of + }, + (end_idx - start_idx) + ); + // Construct the rest wrapped around the buffer + ice::mem_default_construct_n_at( + Memory{ + .location = _data, + .size = ice::size_of * wrapped_end_idx, + .alignment = ice::align_of + }, + wrapped_end_idx + ); + } + else if constexpr (Logic == ContainerLogic::Complex) + { + ice::queue::detail::destroy_tail_items(*this, _count - new_size); + } + + _count = new_size.u32(); + } + + template + constexpr void ice::Queue::clear() noexcept + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::queue::detail::destroy_head_items(*this, size()); + } + + _count = 0; + _offset = 0; + } + + template + template requires std::convertible_to && std::is_constructible_v + inline constexpr void ice::Queue::push_front(ItemType&& item) noexcept + { + if (_count == _capacity) + { + this->grow(); + } + + if (_offset == 0) + { + _offset = _capacity; + } + + _offset -= 1; + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_construct_at( + ice::ptr_add(this->memory_view(), ice::size_of * _offset), + ice::forward(item) + ); + } + else + { + _data[_offset] = Type{ item }; + } + + _count += 1; + } + + template + template requires std::convertible_to && std::is_constructible_v + inline constexpr void ice::Queue::push_back(ItemType&& item) noexcept + { + if (_count == _capacity) + { + this->grow(); + } + + ice::u32 const item_idx = (_offset + _count) % _capacity; + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_construct_at( + ice::ptr_add(this->memory_view(), ice::size_of * item_idx), + ice::forward(item) + ); + } + else + { + _data[item_idx] = Type{ item }; + } + + _count += 1; + } + + template + inline constexpr void ice::Queue::pop_front(ice::ncount count) noexcept + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::queue::detail::destroy_head_items(*this, ice::min(count, this->size())); + } + + if (_count > count) + { + _count -= count.u32(); + _offset = (_offset + count.u32()) % _capacity; + } + else + { + _count = 0; + _offset = 0; + } + } + + template + inline constexpr void ice::Queue::pop_back(ice::ncount count) noexcept + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::queue::detail::destroy_tail_items(queue, ice::min(count, this->size())); + } + + if (_count > count) + { + _count -= count.u32(); + } + else + { + _count = 0; + _offset = 0; + } + } + + template + template + requires (ice::concepts::CompatibleContainer) + inline constexpr void ice::Queue::push_back(ContainerT const& other) noexcept + { + ice::ncount const other_count = other.size(); + ice::ncount const required_capacity = _count + other_count; + if (required_capacity > _capacity) + { + this->grow(required_capacity); + } + + ice::nindex const start_idx = (_offset + _count) % _capacity; + ice::nindex const end_idx = ice::min(_capacity, start_idx + other_count); + + // The space can we use before wrapping around the buffer. + ice::ncount const head_space = end_idx - start_idx; + // The space after the wrapped buffer we still need to allocate. Can be 0. + ice::ncount const tail_space = other_count - head_space; + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_copy_construct_n_at( + Memory{ + .location = _data + start_idx, + .size = ice::size_of * head_space, + .alignment = ice::align_of + }, + other.data(), + head_space + ); + ice::mem_copy_construct_n_at( + Memory{ + .location = _data, + .size = ice::size_of * tail_space, + .alignment = ice::align_of + }, + other.data() + head_space, + tail_space + ); + } + else + { + ice::memcpy( + Memory{ + .location = _data + start_idx, + .size = ice::size_of * head_space, + .alignment = ice::align_of + }, + Data{ + .location = other.data(), + .size = ice::size_of * head_space, + .alignment = ice::align_of + } + ); + ice::memcpy( + Memory{ + .location = _data, + .size = ice::size_of * tail_space, + .alignment = ice::align_of + }, + Data{ + .location = other.data() + head_space, + .size = ice::size_of * tail_space, + .alignment = ice::align_of + } + ); + } + + _count += other.size().u32(); + } + + template + template + inline constexpr auto Queue::front(this Self&& self) noexcept -> ice::container::ValueRef + { + return self._data[self._offset]; + } + + template + template + inline constexpr auto Queue::back(this Self&& self) noexcept -> ice::container::ValueRef + { + return self._data[((self._offset + self._count) - 1) % self._capacity]; + } + + template + inline constexpr auto Queue::memory_view(this Queue& self) noexcept -> ice::Memory + { + return ice::Memory{ + .location = self._data, + .size = self.capacity(), + .alignment = ice::align_of + }; + } + + template + template + constexpr auto Queue::operator[]( + this Self&& self, ice::nindex idx + ) noexcept -> ice::container::ValueRef + { + return self._data[(idx + self._offset) % self._capacity]; + } + +} // namespace ice diff --git a/source/code/core/collections/tests/test_queue.cxx b/source/code/core/collections/tests/test_queue.cxx index 4df2ceb1..47d0b3d4 100644 --- a/source/code/core/collections/tests/test_queue.cxx +++ b/source/code/core/collections/tests/test_queue.cxx @@ -15,17 +15,17 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" ice::ProxyAllocator alloc{ host_alloc, "queue_test" }; ice::Queue test_queue{ alloc }; - CHECK(queue::count(test_queue) == 0); + CHECK(test_queue.size() == 0); GIVEN("an empty queue") { WHEN("resizing constructs objects") { - queue::resize(test_queue, 5); + test_queue.resize(5); ice::u32 dtor_count = 0; Test_ObjectEvents events{}; - for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < test_queue.size(); ++idx) { test_queue[idx].gather_ctors(events); test_queue[idx].data.test_dtor = &dtor_count; @@ -35,7 +35,7 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" WHEN("cleared calls destructors") { - queue::clear(test_queue); + test_queue.clear(); CHECK(dtor_count == 5); } @@ -44,24 +44,24 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" WHEN("pushing a value move constructs an object") { { - queue::push_back(test_queue, { 24 }); - Test_TrackingObject& test_object = queue::front(test_queue); + test_queue.push_back({ 24 }); + Test_TrackingObject& test_object = test_queue.front(); CHECK(test_object == Test_ObjectEvents{ .test_ctor_move = 1 }); CHECK(test_object.value == 24); } { - queue::push_front(test_queue, { 33 }); - Test_TrackingObject& test_object = queue::front(test_queue); + test_queue.push_front({ 33 }); + Test_TrackingObject& test_object = test_queue.front(); CHECK(test_object == Test_ObjectEvents{ .test_ctor_move = 1 }); CHECK(test_object.value == 33); } { - queue::push_back(test_queue, { 42 }); - Test_TrackingObject& test_object = queue::back(test_queue); + test_queue.push_back({ 42 }); + Test_TrackingObject& test_object = test_queue.back(); CHECK(test_object == Test_ObjectEvents{ .test_ctor_move = 1 }); CHECK(test_object.value == 42); @@ -69,7 +69,7 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" ice::u32 dtor_count = 0; Test_ObjectEvents events{}; - for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < test_queue.size(); ++idx) { test_queue[idx].gather_ctors(events); test_queue[idx].data.test_dtor = &dtor_count; @@ -79,7 +79,7 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" WHEN("cleared calls destructors") { - queue::clear(test_queue); + test_queue.clear(); CHECK(dtor_count == 3); } @@ -88,30 +88,30 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" GIVEN("an wrapped queue") { - queue::resize(test_queue, 7); + test_queue.resize(7); ice::u32 dtor_count = 0; - for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < test_queue.size(); ++idx) { test_queue[idx].data.test_dtor = &dtor_count; } - queue::pop_front(test_queue, 6); // We pop 6, as poping everything will reset the queue. + test_queue.pop_front(6); // We pop 6, as poping everything will reset the queue. - CHECK(queue::count(test_queue) == 1); - CHECK(queue::capacity(test_queue) == 7); + CHECK(test_queue.size() == 1); + CHECK(test_queue.capacity() == 7); for (Test_TrackingObject obj : { Test_TrackingObject{ 1 }, Test_TrackingObject{ 2 }, Test_TrackingObject{ 3 } }) { - queue::push_back(test_queue, obj); + test_queue.push_back(obj); } - CHECK(queue::count(test_queue) == 4); + CHECK(test_queue.size() == 4); // Ensure we have a wrapped queue. CHECK(test_queue._offset != 0); CHECK(test_queue._capacity < (test_queue._offset + test_queue._count)); - for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < test_queue.size(); ++idx) { test_queue[idx].data.test_dtor = &dtor_count; } @@ -119,7 +119,7 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" // Clear the queue and calculate the dtor count; WHEN("cleared calls destructors") { - queue::clear(test_queue); + test_queue.clear(); CHECK(dtor_count == 10); } @@ -134,50 +134,50 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod ice::ProxyAllocator alloc{ host_alloc, "queue_test" }; ice::Queue test_queue{ alloc }; - CHECK(queue::count(test_queue) == 0); + CHECK(test_queue.size() == 0); GIVEN("An empty queue object") { - CHECK(queue::count(test_queue) == 0); + CHECK(test_queue.size() == 0); WHEN("we can push elements from the front and back") { - queue::push_back(test_queue, 0xd00b); - CHECK(queue::count(test_queue) == 1); + test_queue.push_back(0xd00b); + CHECK(test_queue.size() == 1); - CHECK(queue::front(test_queue) == 0xd00b); - CHECK(queue::back(test_queue) == 0xd00b); + CHECK(test_queue.front() == 0xd00b); + CHECK(test_queue.back() == 0xd00b); - queue::push_front(test_queue, 0x0db0); - CHECK(queue::count(test_queue) == 2); + test_queue.push_front(0x0db0); + CHECK(test_queue.size() == 2); - CHECK(queue::front(test_queue) == 0x0db0); - CHECK(queue::back(test_queue) == 0xd00b); + CHECK(test_queue.front() == 0x0db0); + CHECK(test_queue.back() == 0xd00b); AND_WHEN("we pop them 'back' then 'front' the queue ends up empty") { - queue::pop_back(test_queue, 1); - CHECK(queue::count(test_queue) == 1); + test_queue.pop_back(1); + CHECK(test_queue.size() == 1); - CHECK(queue::front(test_queue) == 0x0db0); - CHECK(queue::back(test_queue) == 0x0db0); + CHECK(test_queue.front() == 0x0db0); + CHECK(test_queue.back() == 0x0db0); - queue::pop_front(test_queue, 1); - CHECK(queue::count(test_queue) == 0); - CHECK(queue::empty(test_queue)); + test_queue.pop_front(1); + CHECK(test_queue.size() == 0); + CHECK(test_queue.is_empty()); } AND_WHEN("we pop them 'front' then 'back' the queue ends up empty") { - queue::pop_front(test_queue, 1); - CHECK(queue::count(test_queue) == 1); + test_queue.pop_front(1); + CHECK(test_queue.size() == 1); - CHECK(queue::front(test_queue) == 0xd00b); - CHECK(queue::back(test_queue) == 0xd00b); + CHECK(test_queue.front() == 0xd00b); + CHECK(test_queue.back() == 0xd00b); - queue::pop_back(test_queue, 1); - CHECK(queue::count(test_queue) == 0); - CHECK(queue::empty(test_queue)); + test_queue.pop_back(1); + CHECK(test_queue.size() == 0); + CHECK(test_queue.is_empty()); } } @@ -185,10 +185,10 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod { for (ice::u32 i = 0; i < 100; ++i) { - queue::push_back(test_queue, 0xd00b); + test_queue.push_back(0xd00b); } - CHECK(queue::count(test_queue) == 100); + CHECK(test_queue.size() == 100); AND_WHEN("we create a copy of the array") { @@ -196,13 +196,13 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod THEN("popping 50 front elements 'front' at once or one-by-one results in the same queue") { - queue::pop_front(test_queue, 50); + test_queue.pop_front(50); for (ice::u32 idx = 0; idx < 50; ++idx) { - queue::pop_front(test_copy); + test_copy.pop_front(); } - for (ice::u32 idx = 0; idx < ice::queue::count(test_copy); ++idx) + for (ice::u32 idx = 0; idx < test_copy.size(); ++idx) { CHECK(test_queue[idx] == test_copy[idx]); } @@ -210,13 +210,13 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod THEN("popping from back 50 elements at once or one-by-one results in the same queue") { - queue::pop_back(test_queue, 50); + test_queue.pop_back(50); for (ice::u32 idx = 0; idx < 50; ++idx) { - queue::pop_back(test_copy); + test_copy.pop_back(); } - for (ice::u32 idx = 0; idx < ice::queue::count(test_copy); ++idx) + for (ice::u32 idx = 0; idx < test_copy.size(); ++idx) { CHECK(test_queue[idx] == test_copy[idx]); } @@ -225,23 +225,23 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod THEN("we clear the queue by popping all elements (back)") { - queue::pop_back(test_queue, queue::count(test_queue)); + test_queue.pop_back(test_queue.size().u32()); - CHECK(queue::count(test_queue) == 0); + CHECK(test_queue.size() == 0); } THEN("we clear the queue by popping all elements (front)") { - queue::pop_front(test_queue, queue::count(test_queue)); + test_queue.pop_front(test_queue.size().u32()); - CHECK(queue::count(test_queue) == 0); + CHECK(test_queue.size() == 0); } THEN("we clear the queue by calling 'clear'") { - queue::clear(test_queue); + test_queue.clear(); - CHECK(queue::count(test_queue) == 0); + CHECK(test_queue.size() == 0); } } } @@ -249,21 +249,21 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod GIVEN("A queue with 7 elements") { // Reserve space for 10 elements - queue::reserve(test_queue, 10); - CHECK(queue::count(test_queue) == 0); + test_queue.reserve(10); + CHECK(test_queue.size() == 0); ice::i32 const test_values[]{ 1, 2, 3, 4, 5, 6, 7 }; - queue::push_back(test_queue, { test_values }); + test_queue.push_back(ice::Span{ test_values }); THEN("we preare it so the values are wrapped around the buffer") { ice::i32 const test_values2[]{ 7, 1, 2, 3, 4, 5, 6, 7 }; - queue::pop_front(test_queue, 6); // We pop 6, as poping everything will reset the queue. - CHECK(queue::count(test_queue) == 1); + test_queue.pop_front(6); // We pop 6, as poping everything will reset the queue. + CHECK(test_queue.size() == 1); - queue::push_back(test_queue, { test_values }); - CHECK(queue::count(test_queue) == 8); + test_queue.push_back(ice::Span{ test_values }); + CHECK(test_queue.size() == 8); // Ensure we have a wrapped queue. CHECK(test_queue._offset != 0); @@ -271,7 +271,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod AND_THEN("the queue matches test values2") { - for (ice::u32 idx = 0; idx < ice::queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < test_queue.size(); ++idx) { CHECK(test_values2[idx] == test_queue[idx]); } @@ -285,9 +285,9 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod { CHECK(test_copy._offset == 0); CHECK(test_queue._offset != 0); - CHECK(queue::count(test_copy) == queue::count(test_queue)); + CHECK(test_copy.size() == test_queue.size()); - for (ice::u32 idx = 0; idx < ice::queue::count(test_copy); ++idx) + for (ice::u32 idx = 0; idx < test_copy.size(); ++idx) { CHECK(test_queue[idx] == test_copy[idx]); } @@ -296,31 +296,31 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod WHEN("cleared it resets the interall offset") { - ice::queue::clear(test_queue); + test_queue.clear(); CHECK(test_queue._offset == 0); - CHECK(ice::queue::empty(test_queue)); + CHECK(test_queue.is_empty()); } } - queue::clear(test_queue); - queue::push_back(test_queue, { test_values }); + test_queue.clear(); + test_queue.push_back(ice::Span{ test_values }); - REQUIRE(queue::count(test_queue) == 7); + REQUIRE(test_queue.size() == 7); // Popping 6 front elements - queue::pop_front(test_queue, 6); + test_queue.pop_front(6); // Push another 5 elements so we got 3 elements at the end of the ring buffer and 3 at the begining ice::i32 const test_values_2[]{ 7, 1, 2, 3, 4, 5 }; - queue::push_back(test_queue, { test_values_2 + 1, 5 }); - CHECK(queue::count(test_queue) == 6); + test_queue.push_back(ice::Span{ test_values_2 + 1, 5 }); + CHECK(test_queue.size() == 6); THEN("Check if we iterate in the proper order over the queue") { - ice::u32 const queue_size = queue::count(test_queue); - for (ice::u32 i = 0; i < queue_size; ++i) + ice::ncount const queue_size = test_queue.size(); + for (ice::nindex i = 0; i < queue_size; ++i) { CHECK(test_queue[i] == test_values_2[i]); } @@ -357,18 +357,18 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod { ice::u32 const alloc_count = alloc.allocation_total_count(); - queue::reserve(test_queue, 100); + test_queue.reserve(100); // Check that we did force a reallocation CHECK(alloc_count + 1 == alloc.allocation_total_count()); } else { - queue::reserve(test_queue, 100); + test_queue.reserve(100); } // Check the queue is still in tact - CHECK(queue_size == queue::count(test_queue)); + CHECK(queue_size == test_queue.size()); for (ice::u32 i = 0; i < queue_size; ++i) { CHECK(test_queue[i] == test_values_2[i]); diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx index 8e4de4bd..45272f76 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx @@ -56,7 +56,7 @@ namespace ice::ecs auto EntityIndex::count() const noexcept -> ice::u32 { - return _generation.size().u32() - ice::queue::count(_free_indices); + return (_generation.size() - _free_indices.size()).u32(); } bool EntityIndex::is_alive(ice::ecs::Entity entity) const noexcept @@ -71,10 +71,10 @@ namespace ice::ecs { ice::nindex index = 0; - if (ice::queue::count(_free_indices) >= ice::ecs::Constant_MinimumFreeIndicesBeforeReuse) + if (_free_indices.size() >= ice::ecs::Constant_MinimumFreeIndicesBeforeReuse) { - index = ice::queue::front(_free_indices); - ice::queue::pop_front(_free_indices); + index = _free_indices.front(); + _free_indices.pop_front(); } else { @@ -91,7 +91,7 @@ namespace ice::ecs auto out_it = out_entities.begin(); ice::u32 indices[256]; - ice::i32 free_count = ice::i32(ice::queue::count(_free_indices)) - ice::ecs::Constant_MinimumFreeIndicesBeforeReuse; + ice::i32 free_count = ice::i32(_free_indices.size().u32()) - ice::ecs::Constant_MinimumFreeIndicesBeforeReuse; while(free_count > 0) { ice::u32 const indices_taken = ice::queue::take_front( @@ -142,7 +142,7 @@ namespace ice::ecs EntityInfo const info = ice::ecs::entity_info(entity); _generation[info.index] += 1; - ice::queue::push_back(_free_indices, info.index); + _free_indices.push_back(info.index); } void EntityIndex::destroy_many(ice::Span entities) noexcept diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx index 03d4b86c..5da8f36a 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx @@ -764,7 +764,7 @@ namespace ice::ecs } ICE_LOG_IF( - same_archetype == true, + same_archetype == false, LogSeverity::Warning, LogTag::Engine, "Entities in operation have different archetypes, not all operations can handle this yet! Check for possible bugs!" ); diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index bcd60142..8a0978be 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -15,7 +15,7 @@ namespace ice , _current_state{ alloc } , _pending_states{ alloc } { - ice::queue::reserve(_pending_states, 16); + _pending_states.reserve(16); } // auto EngineStateTracker_Default::current_states() const noexcept -> ice::Span @@ -204,7 +204,7 @@ namespace ice } ); - ice::queue::clear(_pending_states); + _pending_states.clear(); } else { @@ -280,8 +280,7 @@ namespace ice trigger.to.value ); - ice::queue::push_back( - _pending_states, + _pending_states.push_back( EngineStatePending { .trigger_shard = trigger_shard, @@ -368,8 +367,7 @@ namespace ice ); // Push to the front so it's before all the current pending states - ice::queue::push_front( - _pending_states, + _pending_states.push_front( EngineStatePending { .trigger_shard = trigger_shard, @@ -382,7 +380,7 @@ namespace ice } } - return ice::queue::any(_pending_states); + return _pending_states.not_empty(); } auto create_state_tracker(ice::Allocator& alloc) noexcept -> ice::UniquePtr From 932272266afe59f0e3fc0050d43e6749a112cff9 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Fri, 16 Jan 2026 00:02:23 +0900 Subject: [PATCH 18/40] Update IBT version to 1.12.0-alpha --- tools/conanfile.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/conanfile.txt b/tools/conanfile.txt index 10335a1e..270a0025 100644 --- a/tools/conanfile.txt +++ b/tools/conanfile.txt @@ -1,6 +1,6 @@ [requires] fastbuild-installer/1.12@iceshard/stable -ice-build-tools/1.11.1@iceshard/stable +ice-build-tools/1.12.0-alpha@iceshard/stable [generators] VirtualRunEnv From 26af975afa2b43b0453fb61ccdb9dbbe110e17d4 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sat, 17 Jan 2026 01:58:00 +0900 Subject: [PATCH 19/40] TeamCity - Test commit for license inspections. --- source/code/core/collections/public/ice/queue.hxx | 1 + 1 file changed, 1 insertion(+) diff --git a/source/code/core/collections/public/ice/queue.hxx b/source/code/core/collections/public/ice/queue.hxx index 6c561aff..2fc3aeab 100644 --- a/source/code/core/collections/public/ice/queue.hxx +++ b/source/code/core/collections/public/ice/queue.hxx @@ -609,4 +609,5 @@ namespace ice return self._data[(idx + self._offset) % self._capacity]; } + } // namespace ice From 2bd9f81df0b1f0705624c66db417e42b0ba92206 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sat, 17 Jan 2026 11:27:58 +0900 Subject: [PATCH 20/40] Finished the refactoring of the ice::Queue type. #ICE-211 Status In Review No additional features where added. --- .../core/collections/natvis/string.natvis | 5 +- .../public/ice/container/basic_container.hxx | 28 ------ .../ice/container/contiguous_container.hxx | 12 +++ .../public/ice/container/impl/queue_impl.inl | 90 ------------------- .../public/ice/container/queue.hxx | 18 ---- .../core/collections/public/ice/queue.hxx | 90 +++++++++++++++++++ .../collections/public/ice/types/ncount.hxx | 2 +- .../collections/public/ice/types/nindex.hxx | 6 +- .../collections/public/ice/types/nvalue.hxx | 5 +- .../core/collections/tests/test_queue.cxx | 8 +- .../engine/private/ecs/ecs_entity_index.cxx | 12 ++- .../private/engine_state_tracker_default.cxx | 6 +- .../private/engine_state_tracker_default.hxx | 2 +- .../public/ice/ecs/ecs_entity_index.hxx | 2 +- .../private/input_action_stack.cxx | 1 - 15 files changed, 125 insertions(+), 162 deletions(-) delete mode 100644 source/code/core/collections/public/ice/container/impl/queue_impl.inl delete mode 100644 source/code/core/collections/public/ice/container/queue.hxx diff --git a/source/code/core/collections/natvis/string.natvis b/source/code/core/collections/natvis/string.natvis index f825e1a7..e147d39d 100644 --- a/source/code/core/collections/natvis/string.natvis +++ b/source/code/core/collections/natvis/string.natvis @@ -7,7 +7,8 @@ _value _width - _value * _width + _value * _width + 0 @@ -17,7 +18,7 @@ _value _width - _value * _width + _value * uint64_t(_width) diff --git a/source/code/core/collections/public/ice/container/basic_container.hxx b/source/code/core/collections/public/ice/container/basic_container.hxx index 4307e7b4..0d37c69a 100644 --- a/source/code/core/collections/public/ice/container/basic_container.hxx +++ b/source/code/core/collections/public/ice/container/basic_container.hxx @@ -17,34 +17,6 @@ namespace ice::container { return self.is_empty() == false; } - - template - requires ice::concepts::ContiguousContainer || ice::concepts::IterableContainer - constexpr auto first(this Self&& self) noexcept -> ice::container::ValueRef - { - if constexpr (ice::concepts::ContiguousContainer) - { - return self.data()[0]; - } - else - { - return *self.begin(); - } - } - - template - requires ice::concepts::ContiguousContainer || ice::concepts::ReverseIterableContainer - constexpr auto last(this Self&& self) noexcept -> ice::container::ValueRef - { - if constexpr (ice::concepts::ContiguousContainer) - { - return self.data()[self.size() - 1]; - } - else - { - return *self.rbegin(); - } - } }; } // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/contiguous_container.hxx b/source/code/core/collections/public/ice/container/contiguous_container.hxx index f4de905a..d554a774 100644 --- a/source/code/core/collections/public/ice/container/contiguous_container.hxx +++ b/source/code/core/collections/public/ice/container/contiguous_container.hxx @@ -9,6 +9,18 @@ namespace ice::container struct ContiguousContainer : ice::container::BasicContainer { + template + constexpr auto first(this Self && self) noexcept -> ice::container::ValueRef + { + return self.data()[0]; + } + + template + constexpr auto last(this Self && self) noexcept -> ice::container::ValueRef + { + return self.data()[self.size() - 1]; + } + // Accessing Data with Spans template constexpr auto subspan( diff --git a/source/code/core/collections/public/ice/container/impl/queue_impl.inl b/source/code/core/collections/public/ice/container/impl/queue_impl.inl deleted file mode 100644 index 56195dc4..00000000 --- a/source/code/core/collections/public/ice/container/impl/queue_impl.inl +++ /dev/null @@ -1,90 +0,0 @@ -/// Copyright 2022 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -namespace ice -{ - - namespace queue - { - - template - inline auto take_front(ice::Queue& queue, ice::Span out_values) noexcept -> ice::u32 - { - ice::ncount const taken_items = ice::min(out_values.size(), queue.size()); - - // (offset, end][0, remaining) - ice::ncount const first_part = ice::min(queue._offset + taken_items, queue._capacity); - ice::ncount const second_part = (queue._offset + taken_items) - first_part; - ice::ncount const first_part_count = first_part - queue._offset; - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_move_n_to(out_values.begin(), queue._data + queue._offset, first_part_count); - ice::mem_move_n_to(out_values.begin() + first_part_count, queue._data, second_part); - } - else - { - ice::memcpy(out_values.begin(), queue._data + queue._offset, ice::size_of * first_part_count); - ice::memcpy(out_values.begin() + first_part_count, queue._data, ice::size_of * second_part); - } - - queue.pop_front(taken_items.u32()); - return taken_items.u32(); - } - -#if 0 - template - inline void for_each(ice::Queue const& queue, Fn&& fn) noexcept - { - if (queue._count == 0) - { - return; - } - - ice::u32 const first_part = ice::min(queue._offset + queue._count, queue._capacity); - ice::u32 const second_part = (queue._offset + queue._count) - first_part; - - for (ice::u32 idx = queue._offset; idx < first_part; ++idx) - { - ice::forward(fn)(queue._data[idx]); - } - - for (ice::u32 idx = 0; idx < second_part; ++idx) - { - ice::forward(fn)(queue._data[idx]); - } - } - - template - inline void for_each_reverse(ice::Queue const& queue, Fn&& fn) noexcept - { - if (queue._count == 0) - { - return; - } - - ice::u32 const first_part = ice::min(queue._offset + queue._count, queue._capacity); - ice::u32 const second_part = (queue._offset + queue._count) - first_part; - - if (second_part > 0) - { - for (ice::u32 idx = second_part - 1; idx > 0; --idx) - { - ice::forward(fn)(queue._data[idx]); - } - - ice::forward(fn)(queue._data[0]); - } - - for (ice::u32 idx = first_part - 1; idx > queue._offset; --idx) - { - ice::forward(fn)(queue._data[idx]); - } - - ice::forward(fn)(queue._data[queue._offset]); - } -#endif - - } // namespace queue - -} // namespace ice diff --git a/source/code/core/collections/public/ice/container/queue.hxx b/source/code/core/collections/public/ice/container/queue.hxx deleted file mode 100644 index f07fae2c..00000000 --- a/source/code/core/collections/public/ice/container/queue.hxx +++ /dev/null @@ -1,18 +0,0 @@ -/// Copyright 2022 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -namespace ice::queue -{ - -} // namespace ice::queue - -namespace ice -{ - -} // namespace ice - -#include "impl/queue_impl.inl" diff --git a/source/code/core/collections/public/ice/queue.hxx b/source/code/core/collections/public/ice/queue.hxx index 2fc3aeab..4e37f812 100644 --- a/source/code/core/collections/public/ice/queue.hxx +++ b/source/code/core/collections/public/ice/queue.hxx @@ -80,6 +80,14 @@ namespace ice template constexpr auto back(this Self&& self) noexcept -> ice::container::ValueRef; + template + constexpr void for_each(this Self&& self, Fn&& fn) noexcept; + template + constexpr void for_each_reverse(this Self&& self, Fn&& fn) noexcept; + + template + constexpr auto take_front(this Self&& self, ice::Span out_values) noexcept -> ice::ncount; + // API Requirements Of: Memory constexpr auto memory_view(this Queue& self) noexcept -> ice::Memory; @@ -590,6 +598,88 @@ namespace ice return self._data[((self._offset + self._count) - 1) % self._capacity]; } + template + template + inline constexpr void ice::Queue::for_each(this Self&& self, Fn&& fn) noexcept + { + if (self._count == 0) + { + return; + } + + ice::u32 const first_part = ice::min(self._offset + self._count, self._capacity); + ice::u32 const second_part = (self._offset + self._count) - first_part; + + for (ice::u32 idx = self._offset; idx < first_part; ++idx) + { + ice::forward(fn)(self._data[idx]); + } + + for (ice::u32 idx = 0; idx < second_part; ++idx) + { + ice::forward(fn)(self._data[idx]); + } + } + + template + template + inline constexpr void ice::Queue::for_each_reverse(this Self&& self, Fn&& fn) noexcept + { + if (self._count == 0) + { + return; + } + + ice::u32 const first_part = ice::min(self._offset + self._count, self._capacity); + ice::u32 const second_part = (self._offset + self._count) - first_part; + + if (second_part > 0) + { + for (ice::u32 idx = second_part - 1; idx > 0; --idx) + { + ice::forward(fn)(self._data[idx]); + } + + ice::forward(fn)(self._data[0]); + } + + for (ice::u32 idx = first_part - 1; idx > self._offset; --idx) + { + ice::forward(fn)(self._data[idx]); + } + + ice::forward(fn)(self._data[self._offset]); + } + + template + template + inline constexpr auto ice::Queue::take_front( + this Self&& self, + ice::Span out_values + ) noexcept -> ice::ncount + { + ice::ncount const taken_items = ice::min(out_values.size(), self.size()); + + // (offset, end][0, remaining) + ice::ncount const first_part = ice::min(self._offset + taken_items, self._capacity); + ice::ncount const second_part = (self._offset + taken_items) - first_part; + ice::ncount const first_part_count = first_part - self._offset; + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_move_n_to(out_values.begin(), self._data + self._offset, first_part_count); + ice::mem_move_n_to(out_values.begin() + first_part_count, self._data, second_part); + } + else + { + ice::memcpy(out_values.begin(), self._data + self._offset, ice::size_of * first_part_count); + ice::memcpy(out_values.begin() + first_part_count, self._data, ice::size_of * second_part); + } + + self.pop_front(taken_items); + return taken_items; + } + template inline constexpr auto Queue::memory_view(this Queue& self) noexcept -> ice::Memory { diff --git a/source/code/core/collections/public/ice/types/ncount.hxx b/source/code/core/collections/public/ice/types/ncount.hxx index 1dd78548..f8c32000 100644 --- a/source/code/core/collections/public/ice/types/ncount.hxx +++ b/source/code/core/collections/public/ice/types/ncount.hxx @@ -35,7 +35,7 @@ namespace ice inline constexpr auto ncount::bytes(this ncount self) noexcept -> ice::usize { - return { static_cast(self._value) * self._width }; + return { static_cast(std::max(self._value, 0)) * self._width }; } inline constexpr ncount::ncount(nvalue value) noexcept diff --git a/source/code/core/collections/public/ice/types/nindex.hxx b/source/code/core/collections/public/ice/types/nindex.hxx index e87d1354..0d7d4bd8 100644 --- a/source/code/core/collections/public/ice/types/nindex.hxx +++ b/source/code/core/collections/public/ice/types/nindex.hxx @@ -16,7 +16,7 @@ namespace ice using ice::nvalue::operator==; // support for allocation sizes - constexpr auto offset(this nindex self) noexcept -> ice::usize; + constexpr auto offset(this nindex self) noexcept -> ice::isize; constexpr nindex() noexcept = default; constexpr nindex(nvalue value) noexcept; @@ -29,9 +29,9 @@ namespace ice struct nindex_invalid_t : nindex {}; - inline constexpr auto nindex::offset(this nindex self) noexcept -> ice::usize + inline constexpr auto nindex::offset(this nindex self) noexcept -> ice::isize { - return { static_cast(self._value) * self._width }; + return { self._value * static_cast(self._width) }; } inline constexpr nindex::nindex(nvalue value) noexcept diff --git a/source/code/core/collections/public/ice/types/nvalue.hxx b/source/code/core/collections/public/ice/types/nvalue.hxx index ea03a1b2..991c2a82 100644 --- a/source/code/core/collections/public/ice/types/nvalue.hxx +++ b/source/code/core/collections/public/ice/types/nvalue.hxx @@ -106,6 +106,7 @@ namespace ice // NOTE: In most cases we will use '_width' as a validation field instead of actually using it's value. // I may come in handy for some operations (ncount -> usize) but it's purpose is to define a concrete 'invalid' state. constexpr auto native() const noexcept { return static_cast(_value * (_width != 0)); } + constexpr auto internal() const noexcept { return static_cast(_value * (_width != 0)); } constexpr auto u8() const noexcept { return static_cast(native()); } constexpr auto u16() const noexcept { return static_cast(native()); } constexpr auto u32() const noexcept { return static_cast(native()); } @@ -202,11 +203,11 @@ namespace ice { if constexpr (std::is_base_of_v) { - return self.native() <=> other.native(); + return self.internal() <=> other.internal(); } else { - return self.native() <=> static_cast(other); + return self.internal() <=> static_cast(other); } } diff --git a/source/code/core/collections/tests/test_queue.cxx b/source/code/core/collections/tests/test_queue.cxx index 47d0b3d4..c09a8a58 100644 --- a/source/code/core/collections/tests/test_queue.cxx +++ b/source/code/core/collections/tests/test_queue.cxx @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "util_tracking_object.hxx" SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]") @@ -328,8 +328,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod WHEN("using 'for_each' we iterate as expected in succession") { ice::u32 idx = 0; - ice::queue::for_each( - test_queue, + test_queue.for_each( [&test_values_2, &idx](ice::i32 val) noexcept { CHECK(val == test_values_2[idx]); @@ -341,8 +340,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod WHEN("using 'for_each_reverse' we iterate as expected in reverse") { ice::u32 idx = ice::count(test_values_2) - 1; - ice::queue::for_each_reverse( - test_queue, + test_queue.for_each_reverse( [&test_values_2, &idx](ice::i32 val) noexcept { CHECK(val == test_values_2[idx]); diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx index 45272f76..f7ca951f 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx @@ -3,7 +3,6 @@ #include #include -#include #include namespace ice::ecs @@ -87,15 +86,14 @@ namespace ice::ecs bool EntityIndex::create_many(ice::Span out_entities) noexcept { - ice::u32 total_indices_taken = 0; + ice::ncount total_indices_taken = 0; auto out_it = out_entities.begin(); ice::u32 indices[256]; - ice::i32 free_count = ice::i32(_free_indices.size().u32()) - ice::ecs::Constant_MinimumFreeIndicesBeforeReuse; + ice::ncount free_count = _free_indices.size() - ice::ecs::Constant_MinimumFreeIndicesBeforeReuse; while(free_count > 0) { - ice::u32 const indices_taken = ice::queue::take_front( - _free_indices, + ice::ncount const indices_taken = _free_indices.take_front( ice::Span{ indices }.headspan(free_count) ); @@ -110,8 +108,8 @@ namespace ice::ecs } ice::u32 gen_index = _generation.size().u32(); - ice::u32 const missing_entities = out_entities.size().u32() - total_indices_taken; - ice::u32 const final_index = gen_index + missing_entities; + ice::u64 const missing_entities = out_entities.size() - total_indices_taken; + ice::u64 const final_index = missing_entities + gen_index; if (final_index > 0) { diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index 8a0978be..106aa626 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -183,7 +183,7 @@ namespace ice ice::shards::clear(temp_shards); // Commit the new states and gather the new shards - ice::queue::for_each(_pending_states, [&temp_shards](EngineStatePending const& pending) noexcept + _pending_states.for_each([&temp_shards](EngineStatePending const& pending) noexcept { bool const success = pending.committer.commit(pending.trigger, pending.trigger_shard, temp_shards); ICE_LOG_IF(success == false, LogSeverity::Error, LogTag::Engine, @@ -261,7 +261,7 @@ namespace ice // Check that this pending state was not added already. bool already_added = false; - ice::queue::for_each(_pending_states, [&](ice::EngineStatePending const& pending) noexcept + _pending_states.for_each([&](ice::EngineStatePending const& pending) noexcept { already_added |= pending.trigger.to == trigger.to && pending.current.subname == from_state.subname; } @@ -328,7 +328,7 @@ namespace ice ICE_ASSERT_CORE(from_state.graph == trigger.from.graph); ice::Shard trigger_shard = ice::Shard_Invalid; - ice::queue::for_each(_pending_states, [&](ice::EngineStatePending const& pending) noexcept + _pending_states.for_each([&](ice::EngineStatePending const& pending) noexcept { // Not a valid 'before' trigger... if (pending.trigger.to != trigger.before) diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx index 43d489d3..4a8fcd91 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include #include #include #include diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_index.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_index.hxx index a13d00e9..846ee942 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_index.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_index.hxx @@ -3,8 +3,8 @@ #pragma once #include +#include #include -#include #include namespace ice::ecs diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index fb613f1e..fa09db62 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include From bfb00a8337bdafff065943b54684f316e8f43f70 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sat, 17 Jan 2026 14:09:51 +0900 Subject: [PATCH 21/40] Update licenses for changed files compared to branch 'master' --- source/code/core/collections/public/ice/array.hxx | 3 +++ .../core/collections/public/ice/container/basic_container.hxx | 3 +++ .../collections/public/ice/container/container_concepts.hxx | 3 +++ .../collections/public/ice/container/contiguous_container.hxx | 3 +++ .../collections/public/ice/container/resizable_container.hxx | 3 +++ source/code/core/collections/public/ice/queue.hxx | 3 +++ source/code/core/collections/public/ice/shard_container.hxx | 2 +- source/code/core/collections/tests/test_data_memory.cxx | 2 +- source/code/core/collections/tests/test_shard_container.cxx | 2 +- source/code/core/memsys/private/mem.cxx | 2 +- source/code/core/memsys/public/ice/mem.hxx | 2 +- source/code/core/tasks/private/internal_tasks/task_utils.hxx | 2 +- source/code/core/tasks/private/task_utils.cxx | 2 +- source/code/core/utils/private/config/config_builder_types.cxx | 2 +- source/code/core/utils/public/ice/algorithm.hxx | 2 +- source/code/core/utils/public/ice/config/config_impl.hxx | 2 +- .../framework/framework_base/private/traits/trait_tilemap.hxx | 2 +- source/code/iceshard/engine/private/action/action_system.cxx | 2 +- source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx | 2 +- .../iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx | 2 +- source/code/iceshard/engine/private/world_trait_module.cxx | 2 +- source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx | 2 +- .../code/iceshard/engine/public/ice/ecs/ecs_entity_index.hxx | 2 +- .../iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx | 2 +- .../code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx | 2 +- .../code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx | 2 +- .../code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx | 2 +- .../code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx | 2 +- .../code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx | 2 +- .../iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx | 2 +- .../code/iceshard/iceshard/private/iceshard_data_storage.hxx | 2 +- .../code/iceshard/iceshard/private/iceshard_task_executor.cxx | 2 +- source/code/iceshard/iceshard/private/iceshard_world.cxx | 2 +- .../code/iceshard/iceshard/private/iceshard_world_context.cxx | 2 +- .../code/iceshard/iceshard/private/iceshard_world_context.hxx | 2 +- .../iceshard/iceshard/private/iceshard_world_manager_devui.cxx | 2 +- .../iceshard/iceshard/private/iceshard_world_tasks_devui.cxx | 2 +- .../iceshard/iceshard/private/iceshard_world_tasks_devui.hxx | 2 +- .../iceshard/private/iceshard_world_tasks_launcher.cxx | 2 +- .../iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx | 2 +- source/code/modules/imgui_module/private/imgui_gfx_stage.cxx | 2 +- source/code/modules/imgui_module/private/imgui_system.hxx | 2 +- .../imgui_module/private/widgets/imgui_devui_manager.hxx | 2 +- .../code/modules/imgui_module/private/widgets/imgui_logger.hxx | 2 +- source/code/modules/shader_tools/private/shader_tools.cxx | 2 +- .../modules/shader_tools/private/shader_tools_asl_importer.cxx | 2 +- .../modules/shader_tools/private/shader_tools_asl_shader.cxx | 2 +- source/code/modules/vulkan_renderer/private/vk_device.hxx | 2 +- source/code/modules/vulkan_renderer/private/vk_driver.hxx | 2 +- source/code/modules/vulkan_renderer/private/vk_queue.hxx | 2 +- .../modules/webgpu_renderer/private/webgpu_framebuffer.hxx | 2 +- .../code/modules/webgpu_renderer/private/webgpu_renderpass.hxx | 2 +- .../code/platforms/platform_webasm/private/webasm_core_app.hxx | 2 +- .../platforms/platform_win32/private/win32_sdl2_platform.cxx | 2 +- .../platforms/platform_win32/private/win32_sdl2_platform.hxx | 2 +- source/code/systems/asset_system/private/asset_module.cxx | 2 +- .../code/systems/asset_system/private/asset_type_archive.cxx | 2 +- source/code/systems/input_system/private/input_mouse.cxx | 2 +- source/code/systems/input_system/private/input_tracker.cxx | 2 +- .../input_system/public/ice/input/device_event_queue.hxx | 2 +- .../systems/render_system/public/ice/render/render_driver.hxx | 2 +- source/code/systems/ui_system/private/ui_element_info.cxx | 2 +- 62 files changed, 74 insertions(+), 56 deletions(-) diff --git a/source/code/core/collections/public/ice/array.hxx b/source/code/core/collections/public/ice/array.hxx index 7790c532..0d4107dc 100644 --- a/source/code/core/collections/public/ice/array.hxx +++ b/source/code/core/collections/public/ice/array.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include #include diff --git a/source/code/core/collections/public/ice/container/basic_container.hxx b/source/code/core/collections/public/ice/container/basic_container.hxx index 0d37c69a..caac3e2a 100644 --- a/source/code/core/collections/public/ice/container/basic_container.hxx +++ b/source/code/core/collections/public/ice/container/basic_container.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index 5a2bede3..cd8bcef0 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include #include diff --git a/source/code/core/collections/public/ice/container/contiguous_container.hxx b/source/code/core/collections/public/ice/container/contiguous_container.hxx index d554a774..bb5e5e48 100644 --- a/source/code/core/collections/public/ice/container/contiguous_container.hxx +++ b/source/code/core/collections/public/ice/container/contiguous_container.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include diff --git a/source/code/core/collections/public/ice/container/resizable_container.hxx b/source/code/core/collections/public/ice/container/resizable_container.hxx index 3b4d5c45..21a3fe64 100644 --- a/source/code/core/collections/public/ice/container/resizable_container.hxx +++ b/source/code/core/collections/public/ice/container/resizable_container.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include diff --git a/source/code/core/collections/public/ice/queue.hxx b/source/code/core/collections/public/ice/queue.hxx index 4e37f812..bd2c8dd2 100644 --- a/source/code/core/collections/public/ice/queue.hxx +++ b/source/code/core/collections/public/ice/queue.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include #include diff --git a/source/code/core/collections/public/ice/shard_container.hxx b/source/code/core/collections/public/ice/shard_container.hxx index 0896102f..a7ca2622 100644 --- a/source/code/core/collections/public/ice/shard_container.hxx +++ b/source/code/core/collections/public/ice/shard_container.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/collections/tests/test_data_memory.cxx b/source/code/core/collections/tests/test_data_memory.cxx index 2e252b9c..18ef6c20 100644 --- a/source/code/core/collections/tests/test_data_memory.cxx +++ b/source/code/core/collections/tests/test_data_memory.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/core/collections/tests/test_shard_container.cxx b/source/code/core/collections/tests/test_shard_container.cxx index 973659fc..edfc0aa3 100644 --- a/source/code/core/collections/tests/test_shard_container.cxx +++ b/source/code/core/collections/tests/test_shard_container.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/core/memsys/private/mem.cxx b/source/code/core/memsys/private/mem.cxx index a8509619..11634865 100644 --- a/source/code/core/memsys/private/mem.cxx +++ b/source/code/core/memsys/private/mem.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/core/memsys/public/ice/mem.hxx b/source/code/core/memsys/public/ice/mem.hxx index 9e7cb10a..d4d4c9db 100644 --- a/source/code/core/memsys/public/ice/mem.hxx +++ b/source/code/core/memsys/public/ice/mem.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/tasks/private/internal_tasks/task_utils.hxx b/source/code/core/tasks/private/internal_tasks/task_utils.hxx index c13ff73f..bceac42a 100644 --- a/source/code/core/tasks/private/internal_tasks/task_utils.hxx +++ b/source/code/core/tasks/private/internal_tasks/task_utils.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/tasks/private/task_utils.cxx b/source/code/core/tasks/private/task_utils.cxx index dc1fc2f4..80ed1d5d 100644 --- a/source/code/core/tasks/private/task_utils.cxx +++ b/source/code/core/tasks/private/task_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/core/utils/private/config/config_builder_types.cxx b/source/code/core/utils/private/config/config_builder_types.cxx index 51c32fcc..f5baab36 100644 --- a/source/code/core/utils/private/config/config_builder_types.cxx +++ b/source/code/core/utils/private/config/config_builder_types.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "config_builder_utils.hxx" diff --git a/source/code/core/utils/public/ice/algorithm.hxx b/source/code/core/utils/public/ice/algorithm.hxx index 0423731c..8c179792 100644 --- a/source/code/core/utils/public/ice/algorithm.hxx +++ b/source/code/core/utils/public/ice/algorithm.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/utils/public/ice/config/config_impl.hxx b/source/code/core/utils/public/ice/config/config_impl.hxx index f5cf5075..80637eb7 100644 --- a/source/code/core/utils/public/ice/config/config_impl.hxx +++ b/source/code/core/utils/public/ice/config/config_impl.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/framework/framework_base/private/traits/trait_tilemap.hxx b/source/code/framework/framework_base/private/traits/trait_tilemap.hxx index 788970ac..8089dfd8 100644 --- a/source/code/framework/framework_base/private/traits/trait_tilemap.hxx +++ b/source/code/framework/framework_base/private/traits/trait_tilemap.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/engine/private/action/action_system.cxx b/source/code/iceshard/engine/private/action/action_system.cxx index 42e2973b..197c28d8 100644 --- a/source/code/iceshard/engine/private/action/action_system.cxx +++ b/source/code/iceshard/engine/private/action/action_system.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx index f7ca951f..5921a65d 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx index 8eb9c268..83cb6658 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/iceshard/engine/private/world_trait_module.cxx b/source/code/iceshard/engine/private/world_trait_module.cxx index b0eab282..aaf7e2c2 100644 --- a/source/code/iceshard/engine/private/world_trait_module.cxx +++ b/source/code/iceshard/engine/private/world_trait_module.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx index 29bd3cc3..399fe005 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_index.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_index.hxx index 846ee942..8c94a563 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_index.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_index.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx index dbc11b17..ed0288ae 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx b/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx index 14e3708b..b7736269 100644 --- a/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx +++ b/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx index 1ba67e81..17e62a53 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_gfx_device.hxx" diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx index d9a236fe..23602a1d 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx index e4ef8f4c..f110638d 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_gfx_queue.hxx" diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx index f553558b..97fd990a 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx index f996c53a..6cc122c4 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_gfx_queue_group.hxx" diff --git a/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx b/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx index 4a6994c7..ba041d32 100644 --- a/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx b/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx index da731ad5..078dba4a 100644 --- a/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/iceshard/iceshard/private/iceshard_world.cxx b/source/code/iceshard/iceshard/private/iceshard_world.cxx index a1db37cd..82353cb9 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_world.hxx" diff --git a/source/code/iceshard/iceshard/private/iceshard_world_context.cxx b/source/code/iceshard/iceshard/private/iceshard_world_context.cxx index 1a9b02e7..018d01a5 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_context.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_context.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_world_context.hxx" diff --git a/source/code/iceshard/iceshard/private/iceshard_world_context.hxx b/source/code/iceshard/iceshard/private/iceshard_world_context.hxx index b490995b..8e69f2b2 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_context.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_context.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx index 40a25662..be9d2f4f 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_world_manager_devui.hxx" diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx index 0d5fe4bb..5fdb601f 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_world_tasks_devui.hxx" diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx index 0e431fa0..0b8b6a95 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx index 583adef2..a1ff7785 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_world.hxx" diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx index 2029af9d..5464dafd 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx b/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx index d2774fd9..e842bd52 100644 --- a/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx +++ b/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_gfx_stage.hxx" diff --git a/source/code/modules/imgui_module/private/imgui_system.hxx b/source/code/modules/imgui_module/private/imgui_system.hxx index cd705b0f..a83190bf 100644 --- a/source/code/modules/imgui_module/private/imgui_system.hxx +++ b/source/code/modules/imgui_module/private/imgui_system.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx index 1d42ac9a..455d6a4c 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx b/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx index 86faf7ea..f6bb81b9 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT diff --git a/source/code/modules/shader_tools/private/shader_tools.cxx b/source/code/modules/shader_tools/private/shader_tools.cxx index 81b647a3..b0cf6326 100644 --- a/source/code/modules/shader_tools/private/shader_tools.cxx +++ b/source/code/modules/shader_tools/private/shader_tools.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx b/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx index e63a37c1..6b94b35c 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "shader_tools_asl_importer.hxx" diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx b/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx index 17102287..56ffe744 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "shader_tools_asl_shader.hxx" diff --git a/source/code/modules/vulkan_renderer/private/vk_device.hxx b/source/code/modules/vulkan_renderer/private/vk_device.hxx index db9ab19d..73664031 100644 --- a/source/code/modules/vulkan_renderer/private/vk_device.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_device.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/modules/vulkan_renderer/private/vk_driver.hxx b/source/code/modules/vulkan_renderer/private/vk_driver.hxx index 55542d21..5b9dacb6 100644 --- a/source/code/modules/vulkan_renderer/private/vk_driver.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_driver.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/modules/vulkan_renderer/private/vk_queue.hxx b/source/code/modules/vulkan_renderer/private/vk_queue.hxx index 3ae6bada..bafdc946 100644 --- a/source/code/modules/vulkan_renderer/private/vk_queue.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_queue.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx b/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx index 3469061d..5cda8932 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx b/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx index ddf87d5c..40aacbb1 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/platforms/platform_webasm/private/webasm_core_app.hxx b/source/code/platforms/platform_webasm/private/webasm_core_app.hxx index b4d23b8c..303f1689 100644 --- a/source/code/platforms/platform_webasm/private/webasm_core_app.hxx +++ b/source/code/platforms/platform_webasm/private/webasm_core_app.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx index e7c4e852..2db688f3 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "win32_sdl2_platform.hxx" diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx index d4598da8..cccce3e0 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/asset_system/private/asset_module.cxx b/source/code/systems/asset_system/private/asset_module.cxx index 5dae0d81..82f5160a 100644 --- a/source/code/systems/asset_system/private/asset_module.cxx +++ b/source/code/systems/asset_system/private/asset_module.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/systems/asset_system/private/asset_type_archive.cxx b/source/code/systems/asset_system/private/asset_type_archive.cxx index ed0a06b6..4f88d4a3 100644 --- a/source/code/systems/asset_system/private/asset_type_archive.cxx +++ b/source/code/systems/asset_system/private/asset_type_archive.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/systems/input_system/private/input_mouse.cxx b/source/code/systems/input_system/private/input_mouse.cxx index 8d2d0cab..15d4eef9 100644 --- a/source/code/systems/input_system/private/input_mouse.cxx +++ b/source/code/systems/input_system/private/input_mouse.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_devices.hxx" diff --git a/source/code/systems/input_system/private/input_tracker.cxx b/source/code/systems/input_system/private/input_tracker.cxx index cb1f7f96..86fd4914 100644 --- a/source/code/systems/input_system/private/input_tracker.cxx +++ b/source/code/systems/input_system/private/input_tracker.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/systems/input_system/public/ice/input/device_event_queue.hxx b/source/code/systems/input_system/public/ice/input/device_event_queue.hxx index 9b2e233f..caedd68d 100644 --- a/source/code/systems/input_system/public/ice/input/device_event_queue.hxx +++ b/source/code/systems/input_system/public/ice/input/device_event_queue.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/render_system/public/ice/render/render_driver.hxx b/source/code/systems/render_system/public/ice/render/render_driver.hxx index a1d94343..1880f487 100644 --- a/source/code/systems/render_system/public/ice/render/render_driver.hxx +++ b/source/code/systems/render_system/public/ice/render/render_driver.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/ui_system/private/ui_element_info.cxx b/source/code/systems/ui_system/private/ui_element_info.cxx index d79eaa61..14a537b1 100644 --- a/source/code/systems/ui_system/private/ui_element_info.cxx +++ b/source/code/systems/ui_system/private/ui_element_info.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include From 829c4221e94ada45710cbcdf59c9d1614766c854 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sat, 17 Jan 2026 16:04:28 +0900 Subject: [PATCH 22/40] Initial work on HashMap refactor. * Introduced new concepts: "AssociativeContainer" and "HashMapContainer" * Started rebuilding the HashMap type and all associated utilities. #ICE-213, #ICE-210 --- .../core/collections/public/ice/array.hxx | 14 +- .../ice/container/associative_container.hxx | 12 + .../ice/container/container_concepts.hxx | 18 +- .../public/ice/container/hashmap.hxx | 25 +- .../public/ice/container/hashmap_details.hxx | 371 +++++++++ .../ice/container/impl/hashmap_impl.inl | 709 +++--------------- .../public/ice/container_types.hxx | 83 +- .../core/collections/public/ice/hashmap.hxx | 254 +++++++ .../core/collections/tests/test_hashmap.cxx | 15 +- 9 files changed, 785 insertions(+), 716 deletions(-) create mode 100644 source/code/core/collections/public/ice/container/associative_container.hxx create mode 100644 source/code/core/collections/public/ice/container/hashmap_details.hxx create mode 100644 source/code/core/collections/public/ice/hashmap.hxx diff --git a/source/code/core/collections/public/ice/array.hxx b/source/code/core/collections/public/ice/array.hxx index 0d4107dc..e43f97cf 100644 --- a/source/code/core/collections/public/ice/array.hxx +++ b/source/code/core/collections/public/ice/array.hxx @@ -57,14 +57,14 @@ namespace ice requires std::copy_constructible; // API Requirements Of: Container - constexpr auto size() const noexcept -> ice::ncount { return { _count, sizeof(ValueType) }; } + constexpr auto size() const noexcept -> SizeType { return { _count, sizeof(ValueType) }; } // API Requirements Of: Resizable Container template constexpr auto data(this Self& self) noexcept -> ice::container::ValuePtr { return self._data; } - constexpr auto capacity() const noexcept -> ice::ncount { return { _capacity, sizeof(ValueType) }; } - constexpr void set_capacity(ice::ncount new_capacity) noexcept; - constexpr void resize(ice::ncount new_size) noexcept; + constexpr auto capacity() const noexcept -> SizeType { return { _capacity, sizeof(ValueType) }; } + constexpr void set_capacity(SizeType new_capacity) noexcept; + constexpr void resize(SizeType new_size) noexcept; constexpr void clear() noexcept; // API Manipulation @@ -229,7 +229,7 @@ namespace ice } template - inline constexpr void ice::Array::set_capacity(ice::ncount new_capacity) noexcept + inline constexpr void ice::Array::set_capacity(SizeType new_capacity) noexcept { if (new_capacity == _capacity) { @@ -272,7 +272,7 @@ namespace ice } template - inline constexpr void ice::Array::resize(ice::ncount new_size) noexcept + inline constexpr void ice::Array::resize(SizeType new_size) noexcept { if (_capacity < new_size) { @@ -281,7 +281,7 @@ namespace ice if (new_size > _count) { - ice::ncount const missing_items = new_size - _count; + SizeType const missing_items = new_size - _count; ice::Memory const uninitialized_memory = ice::ptr_add(memory_view(), size()); ice::mem_default_construct_n_at( diff --git a/source/code/core/collections/public/ice/container/associative_container.hxx b/source/code/core/collections/public/ice/container/associative_container.hxx new file mode 100644 index 00000000..4167fadb --- /dev/null +++ b/source/code/core/collections/public/ice/container/associative_container.hxx @@ -0,0 +1,12 @@ +#pragma once +#include + +namespace ice::container +{ + + struct AssociativeContainer : ice::container::BasicContainer + { + + }; + +} // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index cd8bcef0..cf17bcdc 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -14,10 +14,11 @@ namespace ice::concepts typename std::remove_reference_t::SizeType; typename std::remove_reference_t::ValueType; typename std::remove_reference_t::ConstContainerValueType; - typename std::remove_reference_t::Iterator; - typename std::remove_reference_t::ReverseIterator; - typename std::remove_reference_t::ConstIterator; - typename std::remove_reference_t::ConstReverseIterator; + }; + + template + concept AssociativeContainerType = ContainerType && requires(T t) { + typename std::remove_reference_t::EntryType; }; template @@ -25,6 +26,11 @@ namespace ice::concepts { t.size() } -> std::convertible_to; }; + template + concept AssociativeContainer = Container && AssociativeContainerType && requires(T t) { + { t.size() } -> std::convertible_to; + }; + template concept ResizableContainer = Container && requires(T t, ice::ncount size) { // { t.data() } -> std::convertible_to::ValueType*>; @@ -38,6 +44,10 @@ namespace ice::concepts template concept ContiguousContainer = Container && requires(T t) { + typename std::remove_reference_t::Iterator; + typename std::remove_reference_t::ReverseIterator; + typename std::remove_reference_t::ConstIterator; + typename std::remove_reference_t::ConstReverseIterator; std::is_same_v::ContainerTag, ContiguousContainerTag>; { t.data() } -> std::convertible_to::ValueType const*>; { t.data_view() } -> std::convertible_to; diff --git a/source/code/core/collections/public/ice/container/hashmap.hxx b/source/code/core/collections/public/ice/container/hashmap.hxx index c88b1218..91b95a4f 100644 --- a/source/code/core/collections/public/ice/container/hashmap.hxx +++ b/source/code/core/collections/public/ice/container/hashmap.hxx @@ -47,36 +47,27 @@ namespace ice inline auto values(ice::HashMap& map) noexcept -> ice::Span; - template requires HashMapReadAccess - inline auto count(HashMapType const& map) noexcept -> ice::u32; - - template requires HashMapReadAccess + template inline bool full(HashMapType const& map) noexcept; - template requires HashMapReadAccess - inline bool empty(HashMapType const& map) noexcept; - - template requires HashMapReadAccess - inline bool any(HashMapType const& map) noexcept; - - template requires HashMapReadAccess + template inline bool has(HashMapType const& map, ice::u64 key) noexcept; - template requires HashMapReadAccess + template inline auto get( HashMapType const& map, ice::u64 key, typename HashMapType::ValueType const& fallback_value - ) noexcept -> typename HashMapType::Value const&; + ) noexcept -> typename HashMapType::ValueType const&; - template requires HashMapReadAccess + template inline auto get( HashMapType const& map, ice::u64 key, std::nullptr_t ) noexcept -> typename HashMapType::ValueType; - template requires HashMapReadAccess + template inline auto try_get(HashMapType const& map, ice::u64 key) noexcept -> typename HashMapType::ValueType const*; template @@ -85,10 +76,10 @@ namespace ice template inline auto end(ice::HashMap const& map) noexcept -> typename ice::HashMap::ConstIterator; - template requires HashMapReadAccess + template inline auto values(HashMapType const& map) noexcept -> ice::Span; - template requires HashMapReadAccess + template inline auto entries(HashMapType const& map) noexcept -> ice::Span; diff --git a/source/code/core/collections/public/ice/container/hashmap_details.hxx b/source/code/core/collections/public/ice/container/hashmap_details.hxx new file mode 100644 index 00000000..18a235ab --- /dev/null +++ b/source/code/core/collections/public/ice/container/hashmap_details.hxx @@ -0,0 +1,371 @@ +#pragma +#include +#include +#include + +namespace ice +{ + + namespace container + { + } + + namespace concepts::hashmap + { + + } // namespace concepts + + namespace detail::hashmap + { + + template + using HashMapEntryType = ice::const_correct_t::EntryType>; + + //! \brief A concept used to enable access to read-only operations for all compatible types. + template + concept HashMapContainer = ice::concepts::AssociativeContainerType && requires(T t) { + typename std::remove_reference_t::EntryType; + { std::remove_reference_t::OperationLogic } -> std::convertible_to; + { t._capacity } -> std::convertible_to; + { t._count } -> std::convertible_to; + { t._hashes } -> std::convertible_to; + { t._entries } -> std::convertible_to*>; + { t._data } -> std::convertible_to>; + }; + + static constexpr ice::f32 Constant_HashMapMaxFill = 0.7f; + static constexpr ice::u32 Constant_EndOfList = 0xffffffffu; + + struct FindResult + { + ice::u32 hash_i; + ice::u32 entry_prev; + ice::u32 entry_i; + }; + + constexpr auto calc_required_capacity(ice::ncount max_count) noexcept -> ice::ncount + { + return static_cast( + max_count.native() / Constant_HashMapMaxFill + 0.99f /* magic */ + ); + } + + constexpr bool can_store_expected_size(ice::ncount capacity, ice::ncount expected_size) noexcept + { + ice::ncount const max_size_for_capacity = static_cast( + capacity * Constant_HashMapMaxFill + ); + return max_size_for_capacity >= expected_size; + } + + template + inline auto find(ContainerT const& map, ice::u64 key) noexcept -> FindResult + { + FindResult fr{ + .hash_i = Constant_EndOfList, + .entry_prev = Constant_EndOfList, + .entry_i = Constant_EndOfList, + }; + + if (map._count == 0) + { + return fr; + } + + fr.hash_i = key % map._capacity; + fr.entry_i = map._hashes[fr.hash_i]; + + while (fr.entry_i != Constant_EndOfList) + { + if (map._entries[fr.entry_i].key == key) + { + return fr; + } + + fr.entry_prev = fr.entry_i; + fr.entry_i = map._entries[fr.entry_i].next; + } + return fr; + } + + template + inline auto make(ContainerT& map, ice::u64 key) noexcept -> ice::u32 + { + FindResult fr = ice::detail::hashmap::find(map, key); + if (fr.hash_i == Constant_EndOfList) + { + fr.hash_i = key % map._capacity; + } + + // The count is now the new index. + ice::u32 const index = map._count; + + // Set the key we are use to make the new entry. + map._entries[index].key = key; + + // ... and the next to the previous index stored in the hashes + map._entries[index].next = map._hashes[fr.hash_i]; + + // ... then this is the first entry on this hash table. + map._hashes[fr.hash_i] = index; + + // ... increase the entry count + map._count += 1; + + return index; + } + + template + inline void erase(ContainerT& map, FindResult const fr) noexcept + { + using Entry = typename ContainerT::EntryType; + using Type = typename ContainerT::ValueType; + + // We only update the hash index if we remove the first entry. + if (fr.entry_prev == Constant_EndOfList) + { + map._hashes[fr.hash_i] = map._entries[fr.entry_i].next; + } + else + { + map._entries[fr.entry_prev].next = map._entries[fr.entry_i].next; + } + + // Destroy the object... + if constexpr (ContainerT::OperationLogic == ContainerLogic::Complex) + { + ice::mem_destruct_at(map._data + fr.entry_i); + } + + map._count -= 1; + if (fr.entry_i == map._count) + { + return; + } + + if constexpr (ContainerT::OperationLogic == ContainerLogic::Complex) + { + // Move construct the last object to the now empty location... + ice::mem_move_construct_at( + Memory{ + .location = map._data + fr.entry_i, + .size = ice::size_of, + .alignment = ice::align_of + }, + ice::move(map._data[map._count]) + ); + + // ... then destroy the object at the last location. + ice::mem_destruct_at(map._data + map._count); + } + else + { + map._data[fr.entry_i] = map._data[map._count]; + } + + // Copy entry data... + map._entries[fr.entry_i] = map._entries[map._count]; + + // The first and last entry are the same... + FindResult const last_key_first_entry = ice::detail::hashmap::find(map, map._entries[map._count].key); + if (last_key_first_entry.entry_prev == Constant_EndOfList) + { + // ... update the hashes + map._hashes[last_key_first_entry.hash_i] = fr.entry_i; + } + else + { + Entry* prev_entry = map._entries + last_key_first_entry.entry_prev; + + // Until 'next' holds the last value index... + while (prev_entry->next != map._count) + { + // ... we move forward + prev_entry = map._entries + prev_entry->next; + } + + // ... we can fix the 'next' value + prev_entry->next = fr.entry_i; + } + } + + template + inline auto find_or_fail(ContainerT const& map, ice::u64 key) noexcept -> ice::u32 + { + return ice::detail::hashmap::find(map, key).entry_i; + } + + template + inline auto find_or_make(ContainerT& map, ice::u64 key, bool& found) noexcept -> ice::u32 + { + FindResult fr = ice::detail::hashmap::find(map, key); + + // If entry index is not valid we still might have a previous element on the same hash index. + if (fr.entry_i != Constant_EndOfList) + { + found = true; + return fr.entry_i; + } + + if (fr.hash_i == Constant_EndOfList) + { + fr.hash_i = key % map._capacity; + } + + // The count is now the new index. + ice::u32 const index = map._count; + + // Set the key we are use to make the new entry. + map._entries[index].key = key; + + // ... and the next to the previous index stored in the hashes + map._entries[index].next = map._hashes[fr.hash_i]; + + // ... then this is the first entry on this hash table. + map._hashes[fr.hash_i] = index; + + // ... increase the entry count + map._count += 1; + + return index; + } + + template + inline void find_and_erase(ContainerT& map, ice::u64 key) noexcept + { + FindResult const fr = ice::detail::hashmap::find(map, key); + if (fr.entry_i != Constant_EndOfList) + { + ice::detail::hashmap::erase(map, fr); + } + } + + template + inline void rehash(ContainerT& map, ice::u32 new_capacity) noexcept + { + using Entry = typename ContainerT::EntryType; + using Type = typename ContainerT::ValueType; + + ICE_ASSERT_CORE(new_capacity * Constant_HashMapMaxFill >= map._count); + + ice::u32* new_hashes_ptr = nullptr; + Entry* new_entries_ptr = nullptr; + Type* new_value_ptr = nullptr; + + if (new_capacity > 0) + { + ice::u32 const new_capacity_values = ice::u32(new_capacity * Constant_HashMapMaxFill); + + ice::meminfo alloc_info = ice::meminfo_of *new_capacity; + ice::usize const offset_entries = alloc_info += ice::meminfo_of *new_capacity_values; + ice::usize const offset_values = alloc_info += ice::meminfo_of *new_capacity_values; + + ice::AllocResult const new_data = map._allocator->allocate(alloc_info); + new_hashes_ptr = reinterpret_cast(new_data.memory); + new_entries_ptr = reinterpret_cast(ice::ptr_add(new_data.memory, offset_entries)); + new_value_ptr = reinterpret_cast(ice::ptr_add(new_data.memory, offset_values)); + + // Prepare hashes memory + // TODO: memset? + for (ice::u32& hashed_idx : ice::Span{ new_hashes_ptr, new_capacity }) + { + hashed_idx = Constant_EndOfList; + } + + if (map._count > 0) + { + // NOTE: We keep the original entry + data indices, they don't need to change. + + // Copy all the entries, this is always a POD type. + static_assert(std::is_pod_v, "HashMap::Entry should not be changed!"); + ice::memcpy( + Memory{ .location = new_entries_ptr, .size = ice::size_of *map._count, .alignment = ice::align_of }, + Data{ .location = map._entries, .size = ice::size_of *map._count, .alignment = ice::align_of } + ); + + // If the value is a complex type, properly move construct it in the new location + destroy in the old one. + if constexpr (ContainerT::OperationLogic == ContainerLogic::Complex) + { + ice::mem_move_construct_n_at( + Memory{ .location = new_value_ptr, .size = ice::size_of *map._count, .alignment = ice::align_of }, + map._data, + map._count + ); + } + else + { + ice::memcpy( + Memory{ .location = new_value_ptr, .size = ice::size_of *map._count, .alignment = ice::align_of }, + Data{ .location = map._data, .size = ice::size_of *map._count, .alignment = ice::align_of } + ); + } + + ICE_ASSERT_CORE(false); + //ice::u32 idx = 0; + //for (Entry const& entry : ice::hashmap::entries(map)) + //{ + // // First remember the previous set index... + // new_entries_ptr[idx].next = new_hashes_ptr[entry.key % new_capacity]; + + // // ... then save the current index in the hashed array. + // new_hashes_ptr[entry.key % new_capacity] = idx; + // idx += 1; + //} + } + } + + ICE_ASSERT_CORE(false); + //map._allocator->deallocate(ice::hashmap::memory(map)); + map._capacity = new_capacity; + map._hashes = new_hashes_ptr; + map._entries = new_entries_ptr; + map._data = new_value_ptr; + } + + template + inline auto find(ContainerT& map, typename ContainerT::ConstIterator it) noexcept -> FindResult + { + FindResult fr{ + .hash_i = Constant_EndOfList, + .entry_prev = Constant_EndOfList, + .entry_i = Constant_EndOfList, + }; + + if (map._count == 0) + { + return fr; + } + + fr.hash_i = it._entry->key % map._capacity; + fr.entry_i = map._hashes[fr.hash_i]; + + while (fr.entry_i != Constant_EndOfList) + { + if ((map._entries + fr.entry_i) == it._entry) + { + return fr; + } + + fr.entry_prev = fr.entry_i; + fr.entry_i = map._entries[fr.entry_i].next; + } + return fr; + } + + template + inline void grow(ContainerT& map) noexcept + { + ice::detail::hashmap::rehash(map, map._capacity * 2 + 8); + } + + template + inline void clear_and_dealloc(ContainerT& map) noexcept + { + ICE_ASSERT_CORE(false); + //ice::hashmap::clear(map); + ice::detail::hashmap::rehash(map, 0); + } + + } // namespace hashmap::detail + +} // namespace ice diff --git a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl index 6cbd4917..d06a51d3 100644 --- a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl @@ -7,8 +7,6 @@ namespace ice namespace hashmap::detail { - static constexpr ice::f32 Constant_HashMapMaxFill = 0.7f; - struct FindResult; constexpr auto calc_storage_capacity(ice::u32 max_count) noexcept -> ice::u32; @@ -16,7 +14,7 @@ namespace ice template inline bool can_store_count(ice::HashMap const& map, ice::u32 expected_count) noexcept; - template requires HashMapReadAccess + template inline auto find(HashMapType const& map, ice::u64 key) noexcept -> FindResult; template @@ -25,7 +23,7 @@ namespace ice template inline void erase(ice::HashMap& map, FindResult const fr) noexcept; - template requires HashMapReadAccess + template inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::u32; template @@ -48,497 +46,6 @@ namespace ice } // namespace hashmap::detail - template - inline HashMap::HashMap(ice::Allocator& alloc) noexcept - : _allocator{ &alloc } - , _capacity{ 0 } - , _count{ 0 } - , _hashes{ nullptr } - , _entries { nullptr } - , _data{ nullptr } - { - } - - template - inline HashMap::HashMap(HashMap&& other) noexcept - : _allocator{ other._allocator } - , _capacity{ ice::exchange(other._capacity, 0) } - , _count{ ice::exchange(other._count, 0) } - , _hashes{ ice::exchange(other._hashes, nullptr) } - , _entries{ ice::exchange(other._entries, nullptr) } - , _data{ ice::exchange(other._data, nullptr) } - { - } - - template - inline HashMap::HashMap(HashMap const& other) noexcept - requires std::copy_constructible - : _allocator{ other._allocator } - , _capacity{ 0 } - , _count{ 0 } - , _hashes{ 0 } - , _entries{ 0 } - , _data{ 0 } - { - if (other._count > 0) - { - ice::hashmap::detail::rehash(*this, other._capacity); - - // NOTE: We keep the original entry + data indices, they don't need to change. - // Copy all the entries, this is always a POD type. - static_assert(std::is_pod_v, "HashMap::Entry should not be changed!"); - ice::memcpy( - Memory{ .location = _entries, .size = ice::size_of * other._count, .alignment = ice::align_of }, - Data{ .location = other._entries, .size = ice::size_of * other._count, .alignment = ice::align_of } - ); - - // If the value is a complex type, properly move construct it in the new location + destroy in the old one. - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - Memory{ - .location = _data, - .size = ice::size_of * other._count, - .alignment = ice::align_of - }, - other._data, - other._count - ); - } - else - { - ice::memcpy( - Memory{ .location = _data, .size = ice::size_of * other._count, .alignment = ice::align_of }, - Data{ .location = other._data, .size = ice::size_of *other._count, .alignment = ice::align_of } - ); - } - - ice::u32 idx = 0; - for (Entry const& entry : ice::hashmap::entries(other._entries)) - { - // First remember the previous set index... - _entries[idx].next = _hashes[entry.key % _capacity]; - - // ... then save the current index in the hashed array. - _hashes[entry.key % _capacity] = idx; - idx += 1; - } - - _count = other._count; - } - } - - template - inline HashMap::~HashMap() noexcept - { - ice::hashmap::detail::clear_and_dealloc(*this); - } - - template - inline auto HashMap::operator=(HashMap&& other) noexcept -> HashMap& - { - if (this != &other) - { - ice::hashmap::detail::clear_and_dealloc(*this); // Clears the current data - - _allocator = other._allocator; - _capacity = std::exchange(other._capacity, 0); - _count = std::exchange(other._count, 0); - _hashes = std::exchange(other._hashes, nullptr); - _entries = std::exchange(other._entries, nullptr); - _data = std::exchange(other._data, nullptr); - } - return *this; - } - - template - inline auto HashMap::operator=(HashMap const& other) noexcept -> HashMap& - requires std::copy_constructible - { - if (this != &other) - { - ice::hashmap::clear(*this); - - // Grow if needed to the specific size - if (ice::hashmap::detail::can_store_count(*this, other._count) == false) - { - ice::hashmap::detail::rehash(*this, ice::hashmap::detail::calc_storage_capacity(other._count)); - } - - // NOTE: We keep the original entry + data indices, they don't need to change. - // Copy all the entries, this is always a POD type. - static_assert(std::is_pod_v, "HashMap::Entry should not be changed!"); - ice::memcpy( - Memory{ .location = _entries, .size = ice::size_of * other._count, .alignment = ice::align_of }, - Data{ .location = other._entries, .size = ice::size_of * other._count, .alignment = ice::align_of } - ); - - // If the value is a complex type, properly move construct it in the new location + destroy in the old one. - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - Memory{ - .location = _data, - .size = ice::size_of * other._count, - .alignment = ice::align_of - }, - other._data, - other._count - ); - } - else - { - ice::memcpy( - Memory{ .location = _data, .size = ice::size_of * other._count, .alignment = ice::align_of }, - Data{ .location = other._data, .size = ice::size_of * other._count, .alignment = ice::align_of } - ); - } - - ice::u32 idx = 0; - for (Entry const& entry : ice::hashmap::entries(other._entries)) - { - // First remember the previous set index... - _entries[idx].next = _hashes[entry.key % _capacity]; - - // ... then save the current index in the hashed array. - _hashes[entry.key % _capacity] = idx; - idx += 1; - } - - _count = other._count; - } - return this; - } - - namespace hashmap::detail - { - - static constexpr ice::u32 Constant_EndOfList = 0xffffffffu; - - struct FindResult - { - ice::u32 hash_i; - ice::u32 entry_prev; - ice::u32 entry_i; - }; - - - constexpr auto calc_storage_capacity(ice::u32 max_count) noexcept -> ice::u32 - { - return ice::u32(max_count / Constant_HashMapMaxFill + 0.99f /* magic */); - } - - template - inline bool can_store_count(ice::HashMap const& map, ice::u32 expected_count) noexcept - { - ice::u32 const max_u32 = ice::u32(map._capacity * Constant_HashMapMaxFill); - return max_u32 >= expected_count; - } - - template requires HashMapReadAccess - inline auto find(HashMapType const& map, ice::u64 key) noexcept -> FindResult - { - FindResult fr{ - .hash_i = Constant_EndOfList, - .entry_prev = Constant_EndOfList, - .entry_i = Constant_EndOfList, - }; - - if (map._count == 0) - { - return fr; - } - - fr.hash_i = key % map._capacity; - fr.entry_i = map._hashes[fr.hash_i]; - - while (fr.entry_i != Constant_EndOfList) - { - if (map._entries[fr.entry_i].key == key) - { - return fr; - } - - fr.entry_prev = fr.entry_i; - fr.entry_i = map._entries[fr.entry_i].next; - } - return fr; - } - - template - inline auto make(ice::HashMap& map, ice::u64 key) noexcept -> ice::u32 - { - FindResult fr = ice::hashmap::detail::find(map, key); - if (fr.hash_i == Constant_EndOfList) - { - fr.hash_i = key % map._capacity; - } - - // The count is now the new index. - ice::u32 const index = map._count; - - // Set the key we are use to make the new entry. - map._entries[index].key = key; - - // ... and the next to the previous index stored in the hashes - map._entries[index].next = map._hashes[fr.hash_i]; - - // ... then this is the first entry on this hash table. - map._hashes[fr.hash_i] = index; - - // ... increase the entry count - map._count += 1; - - return index; - } - - template - inline void erase(ice::HashMap& map, FindResult const fr) noexcept - { - using Entry = typename ice::HashMap::Entry; - - // We only update the hash index if we remove the first entry. - if (fr.entry_prev == Constant_EndOfList) - { - map._hashes[fr.hash_i] = map._entries[fr.entry_i].next; - } - else - { - map._entries[fr.entry_prev].next = map._entries[fr.entry_i].next; - } - - // Destroy the object... - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_at(map._data + fr.entry_i); - } - - map._count -= 1; - if (fr.entry_i == map._count) - { - return; - } - - if constexpr (Logic == ContainerLogic::Complex) - { - // Move construct the last object to the now empty location... - ice::mem_move_construct_at( - Memory{ - .location = map._data + fr.entry_i, - .size = ice::size_of, - .alignment = ice::align_of - }, - ice::move(map._data[map._count]) - ); - - // ... then destroy the object at the last location. - ice::mem_destruct_at(map._data + map._count); - } - else - { - map._data[fr.entry_i] = map._data[map._count]; - } - - // Copy entry data... - map._entries[fr.entry_i] = map._entries[map._count]; - - // The first and last entry are the same... - FindResult const last_key_first_entry = ice::hashmap::detail::find(map, map._entries[map._count].key); - if (last_key_first_entry.entry_prev == Constant_EndOfList) - { - // ... update the hashes - map._hashes[last_key_first_entry.hash_i] = fr.entry_i; - } - else - { - Entry* prev_entry = map._entries + last_key_first_entry.entry_prev; - - // Until 'next' holds the last value index... - while (prev_entry->next != map._count) - { - // ... we move forward - prev_entry = map._entries + prev_entry->next; - } - - // ... we can fix the 'next' value - prev_entry->next = fr.entry_i; - } - } - - template requires HashMapReadAccess - inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::u32 - { - return ice::hashmap::detail::find(map, key).entry_i; - } - - template - inline auto find_or_make(ice::HashMap& map, ice::u64 key, bool& found) noexcept -> ice::u32 - { - FindResult fr = ice::hashmap::detail::find(map, key); - - // If entry index is not valid we still might have a previous element on the same hash index. - if (fr.entry_i != Constant_EndOfList) - { - found = true; - return fr.entry_i; - } - - if (fr.hash_i == Constant_EndOfList) - { - fr.hash_i = key % map._capacity; - } - - // The count is now the new index. - ice::u32 const index = map._count; - - // Set the key we are use to make the new entry. - map._entries[index].key = key; - - // ... and the next to the previous index stored in the hashes - map._entries[index].next = map._hashes[fr.hash_i]; - - // ... then this is the first entry on this hash table. - map._hashes[fr.hash_i] = index; - - // ... increase the entry count - map._count += 1; - - return index; - } - - template - inline void find_and_erase(ice::HashMap& map, ice::u64 key) noexcept - { - FindResult const fr = ice::hashmap::detail::find(map, key); - if (fr.entry_i != Constant_EndOfList) - { - ice::hashmap::detail::erase(map, fr); - } - } - - template - inline void rehash(ice::HashMap& map, ice::u32 new_capacity) noexcept - { - using Entry = typename ice::HashMap::Entry; - - ICE_ASSERT_CORE(new_capacity * Constant_HashMapMaxFill >= map._count); - - ice::u32* new_hashes_ptr = nullptr; - Entry* new_entries_ptr = nullptr; - Type* new_value_ptr = nullptr; - - if (new_capacity > 0) - { - ice::u32 const new_capacity_values = ice::u32(new_capacity * Constant_HashMapMaxFill); - - ice::meminfo alloc_info = ice::meminfo_of * new_capacity; - ice::usize const offset_entries = alloc_info += ice::meminfo_of * new_capacity_values; - ice::usize const offset_values = alloc_info += ice::meminfo_of * new_capacity_values; - - ice::AllocResult const new_data = map._allocator->allocate(alloc_info); - new_hashes_ptr = reinterpret_cast(new_data.memory); - new_entries_ptr = reinterpret_cast(ice::ptr_add(new_data.memory, offset_entries)); - new_value_ptr = reinterpret_cast(ice::ptr_add(new_data.memory, offset_values)); - - // Prepare hashes memory - // TODO: memset? - for (ice::u32& hashed_idx : ice::Span{ new_hashes_ptr, new_capacity }) - { - hashed_idx = Constant_EndOfList; - } - - if (map._count > 0) - { - // NOTE: We keep the original entry + data indices, they don't need to change. - - // Copy all the entries, this is always a POD type. - static_assert(std::is_pod_v, "HashMap::Entry should not be changed!"); - ice::memcpy( - Memory{ .location = new_entries_ptr, .size = ice::size_of * map._count, .alignment = ice::align_of }, - Data{ .location = map._entries, .size = ice::size_of * map._count, .alignment = ice::align_of } - ); - - // If the value is a complex type, properly move construct it in the new location + destroy in the old one. - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_move_construct_n_at( - Memory{ .location = new_value_ptr, .size = ice::size_of * map._count, .alignment = ice::align_of }, - map._data, - map._count - ); - } - else - { - ice::memcpy( - Memory{ .location = new_value_ptr, .size = ice::size_of * map._count, .alignment = ice::align_of }, - Data{ .location = map._data, .size = ice::size_of * map._count, .alignment = ice::align_of } - ); - } - - ice::u32 idx = 0; - for (Entry const& entry : ice::hashmap::entries(map)) - { - // First remember the previous set index... - new_entries_ptr[idx].next = new_hashes_ptr[entry.key % new_capacity]; - - // ... then save the current index in the hashed array. - new_hashes_ptr[entry.key % new_capacity] = idx; - idx += 1; - } - } - } - - map._allocator->deallocate(ice::hashmap::memory(map)); - map._capacity = new_capacity; - map._hashes = new_hashes_ptr; - map._entries = new_entries_ptr; - map._data = new_value_ptr; - } - - template - inline auto find(ice::HashMap& map, typename ice::HashMap::ConstIterator it) noexcept -> FindResult - { - FindResult fr{ - .hash_i = Constant_EndOfList, - .entry_prev = Constant_EndOfList, - .entry_i = Constant_EndOfList, - }; - - if (map._count == 0) - { - return fr; - } - - fr.hash_i = it._entry->key % map._capacity; - fr.entry_i = map._hashes[fr.hash_i]; - - while (fr.entry_i != Constant_EndOfList) - { - if ((map._entries + fr.entry_i) == it._entry) - { - return fr; - } - - fr.entry_prev = fr.entry_i; - fr.entry_i = map._entries[fr.entry_i].next; - } - return fr; - } - - template - inline void grow(ice::HashMap& map) noexcept - { - ice::hashmap::detail::rehash(map, map._capacity * 2 + 8); - } - - template - inline void clear_and_dealloc(ice::HashMap& map) noexcept - { - ice::hashmap::clear(map); - ice::hashmap::detail::rehash(map, 0); - } - - } // namespace hashmap::detail namespace hashmap { @@ -549,7 +56,7 @@ namespace ice template inline void reserve(ice::HashMap& map, ice::u32 new_count) noexcept { - ice::hashmap::detail::rehash(map, ice::hashmap::detail::calc_storage_capacity(new_count)); + ice::detail::hashmap::rehash(map, ice::detail::hashmap::calc_required_capacity(new_count).u32()); } template @@ -564,14 +71,14 @@ namespace ice for (ice::u32 hash_idx = 0; hash_idx < map._capacity; ++hash_idx) { // TODO: memset? - map._hashes[hash_idx] = ice::hashmap::detail::Constant_EndOfList; + map._hashes[hash_idx] = ice::detail::hashmap::Constant_EndOfList; } } template inline void shrink(ice::HashMap& map) noexcept { - ice::hashmap::detail::rehash(map, ice::hashmap::detail::calc_storage_capacity(map._count)); + ice::detail::hashmap::rehash(map, ice::detail::hashmap::calc_required_capacity(map._count).u32()); } template @@ -580,11 +87,11 @@ namespace ice { if (ice::hashmap::full(map)) { - ice::hashmap::detail::grow(map); + ice::detail::hashmap::grow(map); } bool found = false; - ice::u32 const index = ice::hashmap::detail::find_or_make(map, key, found); + ice::u32 const index = ice::detail::hashmap::find_or_make(map, key, found); if constexpr (Logic == ContainerLogic::Complex) { // If the index was found we need to destroy the previous value. @@ -614,11 +121,11 @@ namespace ice { if (ice::hashmap::full(map)) { - ice::hashmap::detail::grow(map); + ice::detail::hashmap::grow(map); } bool found = false; - ice::u32 const index = ice::hashmap::detail::find_or_make(map, key, found); + ice::u32 const index = ice::detail::hashmap::find_or_make(map, key, found); if constexpr (Logic == ContainerLogic::Complex) { // If the index was found we need to destroy the previous value. @@ -651,16 +158,16 @@ namespace ice ice::hashmap::set(map, key, ice::forward(value)); } - ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); - ICE_ASSERT_CORE(index != ice::hashmap::detail::Constant_EndOfList); + ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); + ICE_ASSERT_CORE(index != ice::detail::hashmap::Constant_EndOfList); return *(map._data + index); } template inline auto try_get(ice::HashMap& map, ice::u64 key) noexcept -> Type* { - ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); - return index == ice::hashmap::detail::Constant_EndOfList + ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); + return index == ice::detail::hashmap::Constant_EndOfList ? nullptr : map._data + index; } @@ -668,7 +175,7 @@ namespace ice template inline void remove(ice::HashMap& map, ice::u64 key) noexcept { - ice::hashmap::detail::find_and_erase(map, key); + ice::detail::hashmap::find_and_erase(map, key); } template @@ -679,95 +186,95 @@ namespace ice - template requires HashMapReadAccess - inline auto count(HashMapType const& map) noexcept -> ice::u32 - { - return map._count; - } - - template requires HashMapReadAccess - inline bool full(HashMapType const& map) noexcept - { - ice::u32 const max_count = ice::u32(map._capacity * ice::hashmap::detail::Constant_HashMapMaxFill); - ICE_ASSERT_CORE(max_count >= map._count); - - return max_count == map._count; - } - - template requires HashMapReadAccess - inline bool empty(HashMapType const& map) noexcept - { - return map._count == 0; - } - - template requires HashMapReadAccess - inline bool any(HashMapType const& map) noexcept - { - return ice::hashmap::empty(map) == false; - } - - template requires HashMapReadAccess - inline bool has(HashMapType const& map, ice::u64 key) noexcept - { - return ice::hashmap::detail::find_or_fail(map, key) != ice::hashmap::detail::Constant_EndOfList; - } - - template requires HashMapReadAccess - inline auto get(HashMapType const& map, ice::u64 key, typename HashMapType::ValueType const& fallback_value) noexcept -> typename HashMapType::ValueType const& - { - ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); - return index == ice::hashmap::detail::Constant_EndOfList - ? fallback_value - : map._data[index]; - } - - template requires HashMapReadAccess - inline auto get(HashMapType const& map, ice::u64 key, std::nullptr_t) noexcept -> typename HashMapType::ValueType - { - ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); - return index == ice::hashmap::detail::Constant_EndOfList - ? nullptr - : map._data[index]; - } - - template requires HashMapReadAccess - inline auto try_get(HashMapType const& map, ice::u64 key) noexcept -> typename HashMapType::ValueType const* - { - ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); - return index == ice::hashmap::detail::Constant_EndOfList - ? nullptr - : map._data + index; - } - - template - inline auto begin(ice::HashMap const& map) noexcept -> typename ice::HashMap::ConstIterator - { - return { map._entries, map._data }; - } - - template - inline auto end(ice::HashMap const& map) noexcept -> typename ice::HashMap::ConstIterator - { - return { map._entries + map._count, map._data + map._count }; - } - - template requires HashMapReadAccess - inline auto values(HashMapType const& map) noexcept -> ice::Span - { - return ice::Span{ map._data, map._count }; - } - - template requires HashMapReadAccess - inline auto entries(HashMapType const& map) noexcept -> ice::Span - { - return ice::Span{ map._entries, map._count }; - } + //template requires HashMapReadAccess + //inline auto count(HashMapType const& map) noexcept -> ice::u32 + //{ + // return map._count; + //} + + //template requires HashMapReadAccess + //inline bool full(HashMapType const& map) noexcept + //{ + // ice::u32 const max_count = ice::u32(map._capacity * ice::detail::hashmap::Constant_HashMapMaxFill); + // ICE_ASSERT_CORE(max_count >= map._count); + + // return max_count == map._count; + //} + + //template requires HashMapReadAccess + //inline bool empty(HashMapType const& map) noexcept + //{ + // return map._count == 0; + //} + + //template requires HashMapReadAccess + //inline bool any(HashMapType const& map) noexcept + //{ + // return ice::hashmap::empty(map) == false; + //} + + //template requires HashMapReadAccess + //inline bool has(HashMapType const& map, ice::u64 key) noexcept + //{ + // return ice::detail::hashmap::find_or_fail(map, key) != ice::detail::hashmap::Constant_EndOfList; + //} + + //template requires HashMapReadAccess + //inline auto get(HashMapType const& map, ice::u64 key, typename HashMapType::ValueType const& fallback_value) noexcept -> typename HashMapType::ValueType const& + //{ + // ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); + // return index == ice::detail::hashmap::Constant_EndOfList + // ? fallback_value + // : map._data[index]; + //} + + //template requires HashMapReadAccess + //inline auto get(HashMapType const& map, ice::u64 key, std::nullptr_t) noexcept -> typename HashMapType::ValueType + //{ + // ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); + // return index == ice::detail::hashmap::Constant_EndOfList + // ? nullptr + // : map._data[index]; + //} + + //template requires HashMapReadAccess + //inline auto try_get(HashMapType const& map, ice::u64 key) noexcept -> typename HashMapType::ValueType const* + //{ + // ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); + // return index == ice::detail::hashmap::Constant_EndOfList + // ? nullptr + // : map._data + index; + //} + + //template + //inline auto begin(ice::HashMap const& map) noexcept -> typename ice::HashMap::ConstIterator + //{ + // return { map._entries, map._data }; + //} + + //template + //inline auto end(ice::HashMap const& map) noexcept -> typename ice::HashMap::ConstIterator + //{ + // return { map._entries + map._count, map._data + map._count }; + //} + + //template requires HashMapReadAccess + //inline auto values(HashMapType const& map) noexcept -> ice::Span + //{ + // return ice::Span{ map._data, map._count }; + //} + + //template requires HashMapReadAccess + //inline auto entries(HashMapType const& map) noexcept -> ice::Span + //{ + // return ice::Span{ map._entries, map._count }; + //} template inline auto memory(ice::HashMap& map) noexcept -> ice::Memory { - ice::u32 const capacity_values = ice::u32(map._capacity * ice::hashmap::detail::Constant_HashMapMaxFill); + ice::u32 const capacity_values = ice::u32(map._capacity * ice::detail::hashmap::Constant_HashMapMaxFill); // TODO: Easier way to calculate the allocated size. ice::meminfo alloc_info = ice::meminfo_of * map._capacity; @@ -792,10 +299,10 @@ namespace ice { if (ice::hashmap::full(map)) { - ice::hashmap::detail::grow(map); + ice::detail::hashmap::grow(map); } - ice::u32 const index = ice::hashmap::detail::make(map, key); + ice::u32 const index = ice::detail::hashmap::make(map, key); if constexpr (Logic == ContainerLogic::Complex) { // If the index is below the current map._count we need to destroy the previous value. @@ -824,10 +331,10 @@ namespace ice { if (ice::hashmap::full(map)) { - ice::hashmap::detail::grow(map); + ice::detail::hashmap::grow(map); } - ice::u32 const index = ice::hashmap::detail::make(map, key); + ice::u32 const index = ice::detail::hashmap::make(map, key); if constexpr (Logic == ContainerLogic::Complex) { // If the index is below the current map._count we need to destroy the previous value. @@ -854,10 +361,10 @@ namespace ice template inline void remove(ice::HashMap& map, typename ice::HashMap::ConstIterator it) noexcept { - ice::hashmap::detail::FindResult const fr = ice::hashmap::detail::find(map, it); - if (fr.entry_i != ice::hashmap::detail::Constant_EndOfList) + ice::detail::hashmap::FindResult const fr = ice::detail::hashmap::find(map, it); + if (fr.entry_i != ice::detail::hashmap::Constant_EndOfList) { - ice::hashmap::detail::erase(map, fr); + ice::detail::hashmap::erase(map, fr); } } @@ -903,8 +410,8 @@ namespace ice { using ConstIterator = typename ice::HashMap::ConstIterator; - ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); - if (index == ice::hashmap::detail::Constant_EndOfList) + ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); + if (index == ice::detail::hashmap::Constant_EndOfList) { return ConstIterator{ nullptr, nullptr }; } @@ -925,7 +432,7 @@ namespace ice using ConstIterator = typename ice::HashMap::ConstIterator; ice::u32 index = it._entry->next; - while (index != ice::hashmap::detail::Constant_EndOfList) + while (index != ice::detail::hashmap::Constant_EndOfList) { if (map._entries[index].key == it._entry->key) { diff --git a/source/code/core/collections/public/ice/container_types.hxx b/source/code/core/collections/public/ice/container_types.hxx index 0e7dd660..d743689b 100644 --- a/source/code/core/collections/public/ice/container_types.hxx +++ b/source/code/core/collections/public/ice/container_types.hxx @@ -8,83 +8,15 @@ #include #include #include -#include #include #include +#include +#include namespace ice { - //! \brief A hash map build on a single block of memory. - //! - //! \details Manages a memory block big enough to hold the items that it holds. - //! - //! \tparam Logic The logic used during memory operations for the given type. - //! This value is set by the user to enforce expected behavior for stored types. - template> - struct HashMap - { - static_assert( - Logic == ContainerLogic::Complex || ice::TrivialContainerLogicAllowed, - "Collection element type is not allowed with 'Trivial' logic!" - ); - - using ValueType = Type; - - struct Entry - { - ice::u64 key; - ice::u32 next; - }; - - struct ConstIterator - { - Entry const* _entry; - Type const* _value; - - constexpr ConstIterator(std::nullptr_t) noexcept - : _entry{ nullptr } - , _value{ nullptr } - { - } - - constexpr ConstIterator(Entry const* entry, Type const* value) noexcept - : _entry{ entry } - , _value{ value } - { - } - - constexpr auto key() const noexcept -> ice::u64 const& { return _entry->key; } - constexpr auto value() const noexcept -> Type const& { return *_value; } - - constexpr auto operator==(ConstIterator const& other) const noexcept { return _entry == other._entry; } - constexpr auto operator!=(ConstIterator const& other) const noexcept { return !(*this == other); } - - constexpr void operator++() noexcept { _entry += 1; _value += 1; } - constexpr auto operator*() const noexcept -> Type const& { return value(); } - }; - - ice::Allocator* _allocator; - ice::u32 _capacity; - ice::u32 _count; - - ice::u32* _hashes; - Entry* _entries; - Type* _data; - - inline explicit HashMap(ice::Allocator& alloc) noexcept; - inline HashMap(HashMap&& other) noexcept; - inline HashMap(HashMap const& other) noexcept - requires std::copy_constructible; - inline ~HashMap() noexcept; - - inline auto operator=(HashMap&& other) noexcept -> HashMap&; - inline auto operator=(HashMap const& other) noexcept -> HashMap& - requires std::copy_constructible; - }; - - //! \brief A view into data created by a hashmap object. //! //! \note No modification of data is allowed through this type. @@ -103,17 +35,6 @@ namespace ice Type const* _data; }; - //! \brief A concept used to enable access to read-only operations for all compatible types. - template - concept HashMapReadAccess = requires(Type t) { - { typename Type::Entry() } -> std::convertible_to; - { t._capacity } -> std::convertible_to; - { t._count } -> std::convertible_to; - { t._hashes } -> std::convertible_to; - { t._entries } -> std::convertible_to; - { t._data } -> std::convertible_to; - }; - // TODO: Introduce our own type and create proper concepts for function access. template diff --git a/source/code/core/collections/public/ice/hashmap.hxx b/source/code/core/collections/public/ice/hashmap.hxx new file mode 100644 index 00000000..720bafab --- /dev/null +++ b/source/code/core/collections/public/ice/hashmap.hxx @@ -0,0 +1,254 @@ +#pragma once +#include +#include + +namespace ice +{ + + //! \brief A Map container designed for storing values using hashed values. + //! \note This implementation only allows `u64` keys but provides some utility to calculate hashes + //! from well-known engine types like \ref ice::StringID. + //! + //! \details Manages single block of memory big enough to hold all data. + //! The implementation seperates the storage of values and internal data + //! into different blocks allowing to access values separately as continous data. + //! + //! \tparam Logic The operation logic used during memory operations for the given type. + //! This value can be forced by the user for specific behavior requirements. + template> + struct HashMap + : public ice::container::AssociativeContainer + { + static constexpr ContainerLogic OperationLogic = Logic; + static_assert( + OperationLogic == ContainerLogic::Complex || ice::TrivialContainerLogicAllowed, + "Collection element type is not allowed with 'Trivial' logic!" + ); + + struct ConstIterator; + + using ValueType = Type; + using ConstContainerValueType = Type const; + using Iterator = ConstIterator; + using SizeType = ice::ncount; + using ContainerTag = ice::concepts::ContiguousContainerTag; + + struct EntryType + { + ice::u64 key; + ice::u32 next; + }; + + ice::Allocator* _allocator; + ice::u32 _capacity; + ice::u32 _count; + + ice::u32* _hashes; + EntryType* _entries; + ValueType* _data; + + inline explicit HashMap(ice::Allocator& alloc) noexcept; + inline ~HashMap() noexcept; + + inline HashMap(HashMap&& other) noexcept; + inline HashMap(HashMap const& other) noexcept + requires std::copy_constructible; + + inline auto operator=(HashMap&& other) noexcept -> HashMap&; + inline auto operator=(HashMap const& other) noexcept -> HashMap& + requires std::copy_constructible; + + // API Requirements Of: AssociativeContainer + constexpr auto size() const noexcept -> SizeType { return _count; } + }; + + template + struct HashMap::ConstIterator + { + EntryType const* _entry; + ValueType const* _value; + + constexpr ConstIterator(std::nullptr_t) noexcept + : _entry{ nullptr } + , _value{ nullptr } + { } + + constexpr ConstIterator(EntryType const* entry, Type const* value) noexcept + : _entry{ entry } + , _value{ value } + { } + + constexpr auto key() const noexcept -> ice::u64 const& { return _entry->key; } + constexpr auto value() const noexcept -> Type const& { return *_value; } + + constexpr auto operator==(ConstIterator const& other) const noexcept { return _entry == other._entry; } + constexpr auto operator!=(ConstIterator const& other) const noexcept { return !(*this == other); } + + constexpr void operator++() noexcept { _entry += 1; _value += 1; } + constexpr auto operator*() const noexcept -> Type const& { return value(); } + }; + + template + inline HashMap::HashMap(ice::Allocator& alloc) noexcept + : _allocator{ &alloc } + , _capacity{ 0 } + , _count{ 0 } + , _hashes{ nullptr } + , _entries { nullptr } + , _data{ nullptr } + { } + + template + inline HashMap::~HashMap() noexcept + { + ice::detail::hashmap::clear_and_dealloc(*this); + } + + template + inline HashMap::HashMap(HashMap&& other) noexcept + : _allocator{ other._allocator } + , _capacity{ ice::exchange(other._capacity, 0) } + , _count{ ice::exchange(other._count, 0) } + , _hashes{ ice::exchange(other._hashes, nullptr) } + , _entries{ ice::exchange(other._entries, nullptr) } + , _data{ ice::exchange(other._data, nullptr) } + { } + + template + inline HashMap::HashMap(HashMap const& other) noexcept + requires std::copy_constructible + : _allocator{ other._allocator } + , _capacity{ 0 } + , _count{ 0 } + , _hashes{ 0 } + , _entries{ 0 } + , _data{ 0 } + { + if (other._count > 0) + { + ice::detail::hashmap::rehash(*this, other._capacity); + + // NOTE: We keep the original entry + data indices, they don't need to change. + // Copy all the entries, this is always a POD type. + static_assert(std::is_pod_v, "HashMap::Entry should not be changed!"); + ice::memcpy( + Memory{ .location = _entries, .size = ice::size_of * other._count, .alignment = ice::align_of }, + Data{ .location = other._entries, .size = ice::size_of * other._count, .alignment = ice::align_of } + ); + + // If the value is a complex type, properly move construct it in the new location + destroy in the old one. + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_copy_construct_n_at( + Memory{ + .location = _data, + .size = ice::size_of * other._count, + .alignment = ice::align_of + }, + other._data, + other._count + ); + } + else + { + ice::memcpy( + Memory{ .location = _data, .size = ice::size_of * other._count, .alignment = ice::align_of }, + Data{ .location = other._data, .size = ice::size_of *other._count, .alignment = ice::align_of } + ); + } + + ice::u32 idx = 0; + ICE_ASSERT_CORE(false); + //for (EntryType const& entry : ice::hashmap::entries(other._entries)) + //{ + // // First remember the previous set index... + // _entries[idx].next = _hashes[entry.key % _capacity]; + + // // ... then save the current index in the hashed array. + // _hashes[entry.key % _capacity] = idx; + // idx += 1; + //} + + _count = other._count; + } + } + + template + inline auto HashMap::operator=(HashMap&& other) noexcept -> HashMap& + { + if (this != &other) + { + ice::detail::hashmap::clear_and_dealloc(*this); // Clears the current data + + _allocator = other._allocator; + _capacity = std::exchange(other._capacity, 0); + _count = std::exchange(other._count, 0); + _hashes = std::exchange(other._hashes, nullptr); + _entries = std::exchange(other._entries, nullptr); + _data = std::exchange(other._data, nullptr); + } + return *this; + } + + template + inline auto HashMap::operator=(HashMap const& other) noexcept -> HashMap& + requires std::copy_constructible + { + if (this != &other) + { + ICE_ASSERT_CORE(false); + //ice::hashmap::clear(*this); + + // Grow if needed to the specific size + if (ice::detail::hashmap::can_store_expected_size(*this, other._count) == false) + { + ice::detail::hashmap::rehash(*this, ice::detail::hashmap::calc_required_capacity(other._count)); + } + + // NOTE: We keep the original entry + data indices, they don't need to change. + // Copy all the entries, this is always a POD type. + static_assert(std::is_pod_v, "HashMap::Entry should not be changed!"); + ice::memcpy( + Memory{ .location = _entries, .size = ice::size_of * other._count, .alignment = ice::align_of }, + Data{ .location = other._entries, .size = ice::size_of * other._count, .alignment = ice::align_of } + ); + + // If the value is a complex type, properly move construct it in the new location + destroy in the old one. + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_copy_construct_n_at( + Memory{ + .location = _data, + .size = ice::size_of * other._count, + .alignment = ice::align_of + }, + other._data, + other._count + ); + } + else + { + ice::memcpy( + Memory{ .location = _data, .size = ice::size_of * other._count, .alignment = ice::align_of }, + Data{ .location = other._data, .size = ice::size_of * other._count, .alignment = ice::align_of } + ); + } + + ice::u32 idx = 0; + ICE_ASSERT_CORE(false); + //for (EntryType const& entry : ice::hashmap::entries(other._entries)) + //{ + // // First remember the previous set index... + // _entries[idx].next = _hashes[entry.key % _capacity]; + + // // ... then save the current index in the hashed array. + // _hashes[entry.key % _capacity] = idx; + // idx += 1; + //} + + _count = other._count; + } + return this; + } + +} // namespace ice diff --git a/source/code/core/collections/tests/test_hashmap.cxx b/source/code/core/collections/tests/test_hashmap.cxx index 753f4530..8a21c279 100644 --- a/source/code/core/collections/tests/test_hashmap.cxx +++ b/source/code/core/collections/tests/test_hashmap.cxx @@ -8,6 +8,8 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex]") { + using ice::operator""_count; + namespace hash = ice::hashmap; namespace multi_hash = ice::multi_hashmap; @@ -68,7 +70,7 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] obj.gather_ctors(test_events); } - CHECK(ice::hashmap::count(test_hash) == 3); + CHECK(test_hash.size() == 3_count); CHECK(test_events.test_ctor == 0); CHECK(test_events.test_ctor_move == 3); CHECK(test_events.test_ctor_copy == 0); @@ -92,7 +94,7 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] obj.gather_ctors(test_events); } - CHECK(ice::hashmap::count(test_hash) == 3); + CHECK(test_hash.size() == 3_count); CHECK(test_events.test_ctor == 0); CHECK(test_events.test_ctor_move == 3); CHECK(test_events.test_ctor_copy == 0); @@ -155,11 +157,12 @@ SCENARIO("collections 'ice/container/hashmap.hxx' (POD)", "[collection][hash][po THEN("We got values to iterate over") { + ICE_ASSERT_CORE(false); ice::i32 count = 0; - for (auto& entry : hash::entries(test_hash)) - { - count += (entry, 1); - } + //for (auto& entry : hash::entries(test_hash)) + //{ + // count += (entry, 1); + //} CHECK(count == 3); } From 3acf0b61f53b66bb0da9717ad61f04f44ef200ef Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sat, 17 Jan 2026 16:05:31 +0900 Subject: [PATCH 23/40] Initial refactor of refactored HashMap API. * Replaced 'empty', 'any' and 'count' with new equivalents. #ICE-210 --- .../core/tasks/private/task_thread_pool_impl.cxx | 14 +++++++------- .../core/tasks/private/task_thread_pool_impl.hxx | 6 +++--- .../core/tasks/public/ice/task_thread_pool.hxx | 8 ++++---- .../traits/iceshard_gfx_shader_storage_trait.cxx | 2 +- .../iceshard/private/iceshard_world_devui.cxx | 4 ++-- .../private/iceshard_world_manager_devui.cxx | 2 +- .../platform/public/ice/platform_threads.hxx | 2 +- .../platform_win32/private/win32_threads.hxx | 2 +- .../private/input_action_layer_builder.cxx | 2 +- .../private/resource_provider_custom.cxx | 6 +++--- .../private/resource_provider_dynlib.cxx | 2 +- .../private/resource_provider_filelist.cxx | 6 +++--- .../private/resource_provider_filesystem.cxx | 6 +++--- .../private/resource_provider_hailstorm.cxx | 4 ++-- .../resource_system/private/resource_tracker.cxx | 4 ++-- .../private/resource_writer_filesystem.cxx | 6 +++--- 16 files changed, 38 insertions(+), 38 deletions(-) diff --git a/source/code/core/tasks/private/task_thread_pool_impl.cxx b/source/code/core/tasks/private/task_thread_pool_impl.cxx index 604d20a3..d640058b 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.cxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.cxx @@ -49,8 +49,8 @@ namespace ice { _thread_pool.reserve(info.thread_count); _managed_threads.reserve(info.thread_count); - ice::hashmap::reserve(_created_threads, info.thread_count); - ice::hashmap::reserve(_user_threads, info.thread_count); + ice::hashmap::reserve(_created_threads, info.thread_count.u32()); + ice::hashmap::reserve(_user_threads, info.thread_count.u32()); ice::TaskThreadInfo thread_info{ .exclusive_queue = false, @@ -103,17 +103,17 @@ namespace ice _thread_pool.clear(); } - auto TaskThreadPoolImplementation::thread_count() const noexcept -> ice::u32 + auto TaskThreadPoolImplementation::thread_count() const noexcept -> ice::ncount { - return _thread_pool.size().u32(); + return _thread_pool.size(); } - auto TaskThreadPoolImplementation::managed_thread_count() const noexcept -> ice::u32 + auto TaskThreadPoolImplementation::managed_thread_count() const noexcept -> ice::ncount { - return _managed_threads.size().u32() + ice::hashmap::count(_created_threads); + return _managed_threads.size() + _created_threads.size(); } - auto TaskThreadPoolImplementation::estimated_task_count() const noexcept -> ice::u32 + auto TaskThreadPoolImplementation::estimated_task_count() const noexcept -> ice::ncount { return 0; // TODO: } diff --git a/source/code/core/tasks/private/task_thread_pool_impl.hxx b/source/code/core/tasks/private/task_thread_pool_impl.hxx index 4de86615..acaddba1 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.hxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.hxx @@ -21,9 +21,9 @@ namespace ice ) noexcept; ~TaskThreadPoolImplementation() noexcept override; - auto thread_count() const noexcept -> ice::u32 override; - auto managed_thread_count() const noexcept -> ice::u32 override; - auto estimated_task_count() const noexcept -> ice::u32 override; + auto thread_count() const noexcept -> ice::ncount override; + auto managed_thread_count() const noexcept -> ice::ncount override; + auto estimated_task_count() const noexcept -> ice::ncount override; auto create_thread(ice::StringID name) noexcept -> ice::TaskThread& override; auto find_thread(ice::StringID name) noexcept -> ice::TaskThread* override; diff --git a/source/code/core/tasks/public/ice/task_thread_pool.hxx b/source/code/core/tasks/public/ice/task_thread_pool.hxx index 43aa7cb4..abab9ee1 100644 --- a/source/code/core/tasks/public/ice/task_thread_pool.hxx +++ b/source/code/core/tasks/public/ice/task_thread_pool.hxx @@ -14,7 +14,7 @@ namespace ice struct TaskThreadPoolCreateInfo { //! \brief The thread count of this thread pool. - ice::u32 thread_count = 0; + ice::ncount thread_count = 0; //! \brief The AIO port to be used for internal AIO threads. ice::native_aio::AIOPort aioport = nullptr; @@ -27,9 +27,9 @@ namespace ice { public: virtual ~TaskThreadPool() noexcept = default; - virtual auto thread_count() const noexcept -> ice::u32 = 0; - virtual auto managed_thread_count() const noexcept -> ice::u32 = 0; - virtual auto estimated_task_count() const noexcept -> ice::u32 = 0; + virtual auto thread_count() const noexcept -> ice::ncount = 0; + virtual auto managed_thread_count() const noexcept -> ice::ncount = 0; + virtual auto estimated_task_count() const noexcept -> ice::ncount = 0; //! \brief Creates an additonal thread with the given name (ID). //! diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx index 8f759b46..eda81ba8 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx @@ -40,7 +40,7 @@ namespace ice::gfx void Trait_GfxShaderStorage::build_content() noexcept { - ImGui::TextT("Loaded shaders: {}", ice::hashmap::count(_loaded_shaders)); + ImGui::TextT("Loaded shaders: {}", _loaded_shaders.size()); if (ImGui::BeginCombo("##shader-list", "Shader to preview", ImGuiComboFlags_WidthFitPreview)) { for (GfxShaderEntry& entry : ice::hashmap::values(_loaded_shaders)) diff --git a/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx index 742aeef8..3e908141 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx @@ -83,8 +83,8 @@ namespace ice auto make_handler_list = [this](ice::String handler_type, auto const& hashmap) noexcept { - ImGui::TextT("{} handlers (count: {})", handler_type, ice::hashmap::count(hashmap)); - if (ice::hashmap::any(hashmap)) + ImGui::TextT("{} handlers (count: {})", handler_type, hashmap.size()); + if (hashmap.not_empty()) { detail::devui_handlers_table(ice::hashmap::values(hashmap), _world._traits); } diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx index be9d2f4f..997e6cee 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx @@ -43,7 +43,7 @@ namespace ice // Always ensure same size - _entries.resize(ice::hashmap::count(_manager._worlds)); + _entries.resize(_manager._worlds.size()); [[maybe_unused]] ImVec2 const avail = ImGui::GetContentRegionAvail(); diff --git a/source/code/platforms/platform/public/ice/platform_threads.hxx b/source/code/platforms/platform/public/ice/platform_threads.hxx index 78e8923d..9ce15bcc 100644 --- a/source/code/platforms/platform/public/ice/platform_threads.hxx +++ b/source/code/platforms/platform/public/ice/platform_threads.hxx @@ -30,7 +30,7 @@ namespace ice::platform //! \brief Number of threads available in the threadpool. //! \note By default at least one (1), but can have more depending on platform capabilities. - virtual auto threadpool_size() const noexcept -> ice::u32 = 0; + virtual auto threadpool_size() const noexcept -> ice::ncount = 0; //! \returns Pointer to the threadpool object managed by the platform. virtual auto threadpool_object() noexcept -> ice::TaskThreadPool* = 0; diff --git a/source/code/platforms/platform_win32/private/win32_threads.hxx b/source/code/platforms/platform_win32/private/win32_threads.hxx index a2609fd1..b8e26e08 100644 --- a/source/code/platforms/platform_win32/private/win32_threads.hxx +++ b/source/code/platforms/platform_win32/private/win32_threads.hxx @@ -25,7 +25,7 @@ namespace ice::platform::win32 auto graphics() noexcept -> ice::TaskScheduler& override { return _scheduler_gfx; } auto threadpool() noexcept -> ice::TaskScheduler& override { return _scheduler_tasks; } - auto threadpool_size() const noexcept -> ice::u32 override { return _threads->managed_thread_count(); } + auto threadpool_size() const noexcept -> ice::ncount override { return _threads->managed_thread_count(); } auto threadpool_object() noexcept -> ice::TaskThreadPool* override { return _threads.get(); } auto aio_port() const noexcept -> ice::native_aio::AIOPort override { return _aioport; } diff --git a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx index bd53635a..d80819d5 100644 --- a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx @@ -269,7 +269,7 @@ namespace ice // Prepare data of all sources for (Internal const& source : _sources) { - if (ice::hashmap::empty(source.events)) + if (source.events.is_empty()) { final_sources.push_back( InputActionSourceInputInfo{ diff --git a/source/code/systems/resource_system/private/resource_provider_custom.cxx b/source/code/systems/resource_system/private/resource_provider_custom.cxx index 57727f28..cffc9f82 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.cxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.cxx @@ -77,12 +77,12 @@ namespace ice { IPT_ZONE_SCOPED; - out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + _resources.size()); for (auto* resource : _resources) { out_changes.push_back(resource); } - return ice::hashmap::count(_resources); + return _resources.size().u32(); } auto CustomResourceProvider::refresh( @@ -90,7 +90,7 @@ namespace ice ) noexcept -> ice::ResourceProviderResult { IPT_ZONE_SCOPED; - if (ice::hashmap::empty(_resources)) + if (_resources.is_empty()) { collect(out_changes); } diff --git a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx index c736085a..0c89efd8 100644 --- a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx +++ b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx @@ -117,7 +117,7 @@ namespace ice ice::Array& out_changes ) noexcept -> ice::ResourceProviderResult override { - if (ice::hashmap::empty(_resources)) + if (_resources.is_empty()) { initial_traverse(); diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index b7240427..60fe7c19 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -147,12 +147,12 @@ namespace ice { IPT_ZONE_SCOPED; - out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + _resources.size()); for (auto* resource : _resources) { out_changes.push_back(resource); } - return ice::hashmap::count(_resources); + return _resources.size().u32(); } auto FileListResourceProvider::refresh( @@ -160,7 +160,7 @@ namespace ice ) noexcept -> ice::ResourceProviderResult { IPT_ZONE_SCOPED; - if (ice::hashmap::empty(_resources)) + if (_resources.is_empty()) { initial_traverse(); collect(out_changes); diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx index 0ed60291..eb7587da 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx @@ -112,12 +112,12 @@ namespace ice { IPT_ZONE_SCOPED; - out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + _resources.size()); for (auto* resource : _resources) { out_changes.push_back(resource); } - return ice::hashmap::count(_resources); + return _resources.size().u32(); } auto FileSystemResourceProvider::refresh( @@ -125,7 +125,7 @@ namespace ice ) noexcept -> ice::ResourceProviderResult { IPT_ZONE_SCOPED; - if (ice::hashmap::empty(_resources)) + if (_resources.is_empty()) { if (_scheduler == nullptr) { diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx index 3fb776cd..aaac737a 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx @@ -163,7 +163,7 @@ namespace ice ) noexcept { ice::u32 const ptr_idx = ice::hashmap::get_or_set( - _offset_map, offset, ice::hashmap::count(_offset_map) + _offset_map, offset, _offset_map.size().u32() ); // Why would we free something that was never allocated? ICE_ASSERT_CORE(_pointers[ptr_idx] != nullptr); @@ -177,7 +177,7 @@ namespace ice ) noexcept -> ice::Task { ice::u32 const ptr_idx = ice::hashmap::get_or_set( - _offset_map, offset, ice::hashmap::count(_offset_map) + _offset_map, offset, _offset_map.size().u32() ); if (_pointers[ptr_idx] == nullptr) { diff --git a/source/code/systems/resource_system/private/resource_tracker.cxx b/source/code/systems/resource_system/private/resource_tracker.cxx index 7013916e..062fc43b 100644 --- a/source/code/systems/resource_system/private/resource_tracker.cxx +++ b/source/code/systems/resource_system/private/resource_tracker.cxx @@ -346,14 +346,14 @@ namespace ice return; } - ice::u32 const new_count = ice::hashmap::count(_resources) + out_resources.size().u32(); + ice::ncount const new_count = _resources.size() + out_resources.size(); ICE_ASSERT( new_count <= _info.predicted_resource_count, "Maximum resource capacity of {} entiries reached!", _info.predicted_resource_count ); - ice::hashmap::reserve(_resources, new_count); + ice::hashmap::reserve(_resources, new_count.u32()); // Store all resource handles IPT_ZONE_SCOPED_NAMED("create_hash_entries"); diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx index 6ee6f1c3..aefd5a58 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx @@ -107,12 +107,12 @@ namespace ice { IPT_ZONE_SCOPED; - out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + _resources.size()); for (auto* resource : _resources) { out_changes.push_back(resource); } - return ice::hashmap::count(_resources); + return _resources.size().u32(); } auto FileSystemResourceWriter::refresh( @@ -120,7 +120,7 @@ namespace ice ) noexcept -> ice::ResourceProviderResult { IPT_ZONE_SCOPED; - if (ice::hashmap::empty(_resources)) + if (_resources.is_empty()) { if (_scheduler == nullptr) { From 076e1bcc8c38933a5eed62f36bd810c4bc5f92ba Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sun, 18 Jan 2026 15:20:59 +0900 Subject: [PATCH 24/40] Refactored 'rehash' as 'set_capacity' for the HashMap. * Removed some old functions and reintroduced them in the 'HashMap' * Added additional utility functions to all resizable containers: 'is_full' and 'not_full' * Added utility for 'has' and 'missing' functions to accept hashable types. #ICE-213 Remember to put more time into naming the 'has' and 'missing' methods. Something feels not right with them. #ICE-210 MultiHashMap might be come a real pain in the end. --- .../ice/container/associative_container.hxx | 22 ++ .../ice/container/container_concepts.hxx | 25 +- .../public/ice/container/hashmap.hxx | 39 --- .../public/ice/container/hashmap_details.hxx | 132 ++------- .../ice/container/impl/hashmap_impl.inl | 162 +++-------- .../ice/container/resizable_container.hxx | 12 + .../core/collections/public/ice/hashmap.hxx | 265 +++++++++++++++--- .../core/collections/public/ice/string.hxx | 6 - 8 files changed, 337 insertions(+), 326 deletions(-) diff --git a/source/code/core/collections/public/ice/container/associative_container.hxx b/source/code/core/collections/public/ice/container/associative_container.hxx index 4167fadb..c240ec19 100644 --- a/source/code/core/collections/public/ice/container/associative_container.hxx +++ b/source/code/core/collections/public/ice/container/associative_container.hxx @@ -6,7 +6,29 @@ namespace ice::container struct AssociativeContainer : ice::container::BasicContainer { + template + bool has(this Self const& self, ice::container::KeyTypeArg key) noexcept + { + return self.find(key) != nullptr; + } + template + bool has(this Self const& self, KeyType&& key) noexcept + { + return self.has(ice::hash(ice::forward(key))); + } + + template + bool missing(this Self const& self, ice::container::KeyTypeArg key) noexcept + { + return self.find(key) == nullptr; + } + + template + bool missing(this Self const& self, KeyType&& key) noexcept + { + return self.missing(ice::hash(ice::forward(key))); + } }; } // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index cf17bcdc..e788ee62 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -2,6 +2,8 @@ /// SPDX-License-Identifier: MIT #pragma once +#include +#include #include #include #include @@ -18,6 +20,7 @@ namespace ice::concepts template concept AssociativeContainerType = ContainerType && requires(T t) { + typename std::remove_reference_t::KeyType; typename std::remove_reference_t::EntryType; }; @@ -27,16 +30,16 @@ namespace ice::concepts }; template - concept AssociativeContainer = Container && AssociativeContainerType && requires(T t) { + concept AssociativeContainer = Container && AssociativeContainerType + && requires(T t, typename std::remove_reference_t::KeyType key) { { t.size() } -> std::convertible_to; + { t.find(key) } -> std::convertible_to::ValueType const*>; }; template concept ResizableContainer = Container && requires(T t, ice::ncount size) { - // { t.data() } -> std::convertible_to::ValueType*>; { t.capacity() } -> std::convertible_to; { t.set_capacity(size) } -> std::convertible_to; - { t.resize(size) } -> std::convertible_to; { t.clear() } -> std::convertible_to; }; @@ -66,6 +69,11 @@ namespace ice::concepts concept RegularContainerLogic = ContainerType && not TrivialContainerLogicAllowed::ValueType>; + template + concept HashableKeyType = not std::is_arithmetic_v> && requires(T t) { + { ice::hash(t) } -> std::convertible_to; + }; + } // namespace ice::concepts namespace ice @@ -100,6 +108,17 @@ namespace ice::container typename std::remove_reference_t::ReverseIterator >; + template + using KeyType = typename std::remove_reference_t::KeyType; + + template + using KeyTypeArg = std::conditional_t< + sizeof(ice::container::KeyType) <= 16 && std::is_trivially_copyable_v>, + ice::container::KeyType, + ice::container::KeyType const& + >; + + template using ValueType = ConstCorrectContainerValueType; diff --git a/source/code/core/collections/public/ice/container/hashmap.hxx b/source/code/core/collections/public/ice/container/hashmap.hxx index 91b95a4f..2cffbb25 100644 --- a/source/code/core/collections/public/ice/container/hashmap.hxx +++ b/source/code/core/collections/public/ice/container/hashmap.hxx @@ -12,15 +12,6 @@ namespace ice namespace hashmap { - template - inline void reserve(ice::HashMap& map, ice::u32 new_capacity) noexcept; - - template - inline void clear(ice::HashMap& map) noexcept; - - template - inline void shrink(ice::HashMap& map) noexcept; - template requires std::copy_constructible && std::convertible_to inline void set(ice::HashMap& map, ice::u64 key, Value const& value) noexcept; @@ -43,16 +34,6 @@ namespace ice template inline void remove(ice::HashMap& map, ice::u64 key) noexcept; - template - inline auto values(ice::HashMap& map) noexcept -> ice::Span; - - - template - inline bool full(HashMapType const& map) noexcept; - - template - inline bool has(HashMapType const& map, ice::u64 key) noexcept; - template inline auto get( HashMapType const& map, @@ -70,18 +51,6 @@ namespace ice template inline auto try_get(HashMapType const& map, ice::u64 key) noexcept -> typename HashMapType::ValueType const*; - template - inline auto begin(ice::HashMap const& map) noexcept -> typename ice::HashMap::ConstIterator; - - template - inline auto end(ice::HashMap const& map) noexcept -> typename ice::HashMap::ConstIterator; - - template - inline auto values(HashMapType const& map) noexcept -> ice::Span; - - template - inline auto entries(HashMapType const& map) noexcept -> ice::Span; - template inline auto memory(ice::HashMap& map) noexcept -> ice::Memory; @@ -124,12 +93,4 @@ namespace ice } // namespace ice -namespace ice -{ - - using ice::hashmap::begin; - using ice::hashmap::end; - -} // namespace ice - #include "impl/hashmap_impl.inl" diff --git a/source/code/core/collections/public/ice/container/hashmap_details.hxx b/source/code/core/collections/public/ice/container/hashmap_details.hxx index 18a235ab..3d123b17 100644 --- a/source/code/core/collections/public/ice/container/hashmap_details.hxx +++ b/source/code/core/collections/public/ice/container/hashmap_details.hxx @@ -43,6 +43,11 @@ namespace ice ice::u32 entry_i; }; + constexpr auto calc_value_capacity(ice::ncount raw_capacity) noexcept -> ice::ncount + { + return static_cast(raw_capacity.native() * Constant_HashMapMaxFill); + } + constexpr auto calc_required_capacity(ice::ncount max_count) noexcept -> ice::ncount { return static_cast( @@ -50,12 +55,31 @@ namespace ice ); } - constexpr bool can_store_expected_size(ice::ncount capacity, ice::ncount expected_size) noexcept + constexpr auto capacity_with_overhead(ice::ncount max_count) noexcept -> ice::ncount { - ice::ncount const max_size_for_capacity = static_cast( - capacity * Constant_HashMapMaxFill - ); - return max_size_for_capacity >= expected_size; + return calc_required_capacity(max_count); + } + + constexpr bool can_store_expected_size(ice::ncount raw_capacity, ice::ncount expected_size) noexcept + { + return calc_value_capacity(raw_capacity) >= expected_size; + } + + template + constexpr auto calc_meminfo(ice::ncount capacity) noexcept -> ice::meminfo + { + ice::ncount const new_internal_capacity = ice::detail::hashmap::capacity_with_overhead(capacity); + + ice::meminfo alloc_info = ice::meminfo_of * new_internal_capacity; + alloc_info += ice::meminfo_of * capacity; + alloc_info += ice::meminfo_of * capacity; + return alloc_info; + } + + template + inline auto entries(ContainerT const& map) noexcept -> ice::Span + { + return ice::Span{ map._entries, map._count }; } template @@ -190,7 +214,7 @@ namespace ice } template - inline auto find_or_fail(ContainerT const& map, ice::u64 key) noexcept -> ice::u32 + inline auto find_or_fail(ContainerT const& map, ice::container::KeyType key) noexcept -> ice::u32 { return ice::detail::hashmap::find(map, key).entry_i; } @@ -240,88 +264,6 @@ namespace ice } } - template - inline void rehash(ContainerT& map, ice::u32 new_capacity) noexcept - { - using Entry = typename ContainerT::EntryType; - using Type = typename ContainerT::ValueType; - - ICE_ASSERT_CORE(new_capacity * Constant_HashMapMaxFill >= map._count); - - ice::u32* new_hashes_ptr = nullptr; - Entry* new_entries_ptr = nullptr; - Type* new_value_ptr = nullptr; - - if (new_capacity > 0) - { - ice::u32 const new_capacity_values = ice::u32(new_capacity * Constant_HashMapMaxFill); - - ice::meminfo alloc_info = ice::meminfo_of *new_capacity; - ice::usize const offset_entries = alloc_info += ice::meminfo_of *new_capacity_values; - ice::usize const offset_values = alloc_info += ice::meminfo_of *new_capacity_values; - - ice::AllocResult const new_data = map._allocator->allocate(alloc_info); - new_hashes_ptr = reinterpret_cast(new_data.memory); - new_entries_ptr = reinterpret_cast(ice::ptr_add(new_data.memory, offset_entries)); - new_value_ptr = reinterpret_cast(ice::ptr_add(new_data.memory, offset_values)); - - // Prepare hashes memory - // TODO: memset? - for (ice::u32& hashed_idx : ice::Span{ new_hashes_ptr, new_capacity }) - { - hashed_idx = Constant_EndOfList; - } - - if (map._count > 0) - { - // NOTE: We keep the original entry + data indices, they don't need to change. - - // Copy all the entries, this is always a POD type. - static_assert(std::is_pod_v, "HashMap::Entry should not be changed!"); - ice::memcpy( - Memory{ .location = new_entries_ptr, .size = ice::size_of *map._count, .alignment = ice::align_of }, - Data{ .location = map._entries, .size = ice::size_of *map._count, .alignment = ice::align_of } - ); - - // If the value is a complex type, properly move construct it in the new location + destroy in the old one. - if constexpr (ContainerT::OperationLogic == ContainerLogic::Complex) - { - ice::mem_move_construct_n_at( - Memory{ .location = new_value_ptr, .size = ice::size_of *map._count, .alignment = ice::align_of }, - map._data, - map._count - ); - } - else - { - ice::memcpy( - Memory{ .location = new_value_ptr, .size = ice::size_of *map._count, .alignment = ice::align_of }, - Data{ .location = map._data, .size = ice::size_of *map._count, .alignment = ice::align_of } - ); - } - - ICE_ASSERT_CORE(false); - //ice::u32 idx = 0; - //for (Entry const& entry : ice::hashmap::entries(map)) - //{ - // // First remember the previous set index... - // new_entries_ptr[idx].next = new_hashes_ptr[entry.key % new_capacity]; - - // // ... then save the current index in the hashed array. - // new_hashes_ptr[entry.key % new_capacity] = idx; - // idx += 1; - //} - } - } - - ICE_ASSERT_CORE(false); - //map._allocator->deallocate(ice::hashmap::memory(map)); - map._capacity = new_capacity; - map._hashes = new_hashes_ptr; - map._entries = new_entries_ptr; - map._data = new_value_ptr; - } - template inline auto find(ContainerT& map, typename ContainerT::ConstIterator it) noexcept -> FindResult { @@ -352,20 +294,6 @@ namespace ice return fr; } - template - inline void grow(ContainerT& map) noexcept - { - ice::detail::hashmap::rehash(map, map._capacity * 2 + 8); - } - - template - inline void clear_and_dealloc(ContainerT& map) noexcept - { - ICE_ASSERT_CORE(false); - //ice::hashmap::clear(map); - ice::detail::hashmap::rehash(map, 0); - } - } // namespace hashmap::detail } // namespace ice diff --git a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl index d06a51d3..9f12fdc9 100644 --- a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl @@ -32,9 +32,6 @@ namespace ice template inline void find_and_erase(ice::HashMap& map, ice::u64 key) noexcept; - template - inline void rehash(ice::HashMap& map, ice::u32 new_capacity) noexcept; - template inline auto find(ice::HashMap& map, typename ice::HashMap::ConstIterator it) noexcept -> FindResult; @@ -50,44 +47,13 @@ namespace ice namespace hashmap { - //! \brief Allocates enough space in the hash map to hold the given amount of values. - //! - //! \note Keep in mind, the number of valies a hashmap can store is lower than it's total capacity. - template - inline void reserve(ice::HashMap& map, ice::u32 new_count) noexcept - { - ice::detail::hashmap::rehash(map, ice::detail::hashmap::calc_required_capacity(new_count).u32()); - } - - template - inline void clear(ice::HashMap& map) noexcept - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_n_at(map._data, map._count); - } - - map._count = 0; - for (ice::u32 hash_idx = 0; hash_idx < map._capacity; ++hash_idx) - { - // TODO: memset? - map._hashes[hash_idx] = ice::detail::hashmap::Constant_EndOfList; - } - } - - template - inline void shrink(ice::HashMap& map) noexcept - { - ice::detail::hashmap::rehash(map, ice::detail::hashmap::calc_required_capacity(map._count).u32()); - } - template requires std::copy_constructible && std::convertible_to inline void set(ice::HashMap& map, ice::u64 key, Value const& value) noexcept { - if (ice::hashmap::full(map)) + if (map.is_full()) { - ice::detail::hashmap::grow(map); + map.grow(); } bool found = false; @@ -119,9 +85,9 @@ namespace ice requires std::move_constructible && std::convertible_to inline void set(ice::HashMap& map, ice::u64 key, Value&& value) noexcept { - if (ice::hashmap::full(map)) + if (map.is_full()) { - ice::detail::hashmap::grow(map); + map.grow(); } bool found = false; @@ -153,7 +119,7 @@ namespace ice requires std::move_constructible && std::convertible_to inline auto get_or_set(ice::HashMap& map, ice::u64 key, Value&& value) noexcept -> Type& { - if (ice::hashmap::has(map, key) == false) + if (map.missing(key)) { ice::hashmap::set(map, key, ice::forward(value)); } @@ -178,97 +144,33 @@ namespace ice ice::detail::hashmap::find_and_erase(map, key); } - template - inline auto values(ice::HashMap& map) noexcept -> ice::Span + template + inline auto get(HashMapType const& map, ice::u64 key, typename HashMapType::ValueType const& fallback_value) noexcept -> typename HashMapType::ValueType const& { - return ice::Span{ map._data, map._count }; + ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); + return index == ice::detail::hashmap::Constant_EndOfList + ? fallback_value + : map._data[index]; } + template + inline auto get(HashMapType const& map, ice::u64 key, std::nullptr_t) noexcept -> typename HashMapType::ValueType + { + ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); + return index == ice::detail::hashmap::Constant_EndOfList + ? nullptr + : map._data[index]; + } + template + inline auto try_get(HashMapType const& map, ice::u64 key) noexcept -> typename HashMapType::ValueType const* + { + ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); + return index == ice::detail::hashmap::Constant_EndOfList + ? nullptr + : map._data + index; + } - //template requires HashMapReadAccess - //inline auto count(HashMapType const& map) noexcept -> ice::u32 - //{ - // return map._count; - //} - - //template requires HashMapReadAccess - //inline bool full(HashMapType const& map) noexcept - //{ - // ice::u32 const max_count = ice::u32(map._capacity * ice::detail::hashmap::Constant_HashMapMaxFill); - // ICE_ASSERT_CORE(max_count >= map._count); - - // return max_count == map._count; - //} - - //template requires HashMapReadAccess - //inline bool empty(HashMapType const& map) noexcept - //{ - // return map._count == 0; - //} - - //template requires HashMapReadAccess - //inline bool any(HashMapType const& map) noexcept - //{ - // return ice::hashmap::empty(map) == false; - //} - - //template requires HashMapReadAccess - //inline bool has(HashMapType const& map, ice::u64 key) noexcept - //{ - // return ice::detail::hashmap::find_or_fail(map, key) != ice::detail::hashmap::Constant_EndOfList; - //} - - //template requires HashMapReadAccess - //inline auto get(HashMapType const& map, ice::u64 key, typename HashMapType::ValueType const& fallback_value) noexcept -> typename HashMapType::ValueType const& - //{ - // ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); - // return index == ice::detail::hashmap::Constant_EndOfList - // ? fallback_value - // : map._data[index]; - //} - - //template requires HashMapReadAccess - //inline auto get(HashMapType const& map, ice::u64 key, std::nullptr_t) noexcept -> typename HashMapType::ValueType - //{ - // ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); - // return index == ice::detail::hashmap::Constant_EndOfList - // ? nullptr - // : map._data[index]; - //} - - //template requires HashMapReadAccess - //inline auto try_get(HashMapType const& map, ice::u64 key) noexcept -> typename HashMapType::ValueType const* - //{ - // ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); - // return index == ice::detail::hashmap::Constant_EndOfList - // ? nullptr - // : map._data + index; - //} - - //template - //inline auto begin(ice::HashMap const& map) noexcept -> typename ice::HashMap::ConstIterator - //{ - // return { map._entries, map._data }; - //} - - //template - //inline auto end(ice::HashMap const& map) noexcept -> typename ice::HashMap::ConstIterator - //{ - // return { map._entries + map._count, map._data + map._count }; - //} - - //template requires HashMapReadAccess - //inline auto values(HashMapType const& map) noexcept -> ice::Span - //{ - // return ice::Span{ map._data, map._count }; - //} - - //template requires HashMapReadAccess - //inline auto entries(HashMapType const& map) noexcept -> ice::Span - //{ - // return ice::Span{ map._entries, map._count }; - //} template @@ -297,9 +199,9 @@ namespace ice requires std::move_constructible && std::convertible_to inline void insert(ice::HashMap& map, ice::u64 key, Type&& value) noexcept { - if (ice::hashmap::full(map)) + if (map.is_full()) { - ice::detail::hashmap::grow(map); + map.grow(); } ice::u32 const index = ice::detail::hashmap::make(map, key); @@ -329,9 +231,9 @@ namespace ice template inline void insert(ice::HashMap& map, ice::u64 key, Type const& value) noexcept { - if (ice::hashmap::full(map)) + if (map.is_full()) { - ice::detail::hashmap::grow(map); + map.grow(); } ice::u32 const index = ice::detail::hashmap::make(map, key); @@ -371,7 +273,7 @@ namespace ice template inline void remove_all(ice::HashMap& map, ice::u64 key) noexcept { - while (ice::hashmap::has(map, key)) + while (map.has(key)) { ice::hashmap::remove(map, key); } diff --git a/source/code/core/collections/public/ice/container/resizable_container.hxx b/source/code/core/collections/public/ice/container/resizable_container.hxx index 21a3fe64..f1737eb8 100644 --- a/source/code/core/collections/public/ice/container/resizable_container.hxx +++ b/source/code/core/collections/public/ice/container/resizable_container.hxx @@ -9,6 +9,18 @@ namespace ice::container struct ResizableContainer { + template + constexpr bool is_full(this Self const& self) noexcept + { + return self.size() == self.capacity(); + } + + template + constexpr bool not_full(this Self const& self) noexcept + { + return self.size() < self.capacity(); + } + template constexpr void reserve(this Self& self, ice::ncount min_capacity) noexcept { diff --git a/source/code/core/collections/public/ice/hashmap.hxx b/source/code/core/collections/public/ice/hashmap.hxx index 720bafab..5fe1dc48 100644 --- a/source/code/core/collections/public/ice/hashmap.hxx +++ b/source/code/core/collections/public/ice/hashmap.hxx @@ -1,6 +1,7 @@ #pragma once #include #include +#include namespace ice { @@ -18,6 +19,7 @@ namespace ice template> struct HashMap : public ice::container::AssociativeContainer + , public ice::container::ResizableContainer { static constexpr ContainerLogic OperationLogic = Logic; static_assert( @@ -27,6 +29,7 @@ namespace ice struct ConstIterator; + using KeyType = ice::u64; using ValueType = Type; using ConstContainerValueType = Type const; using Iterator = ConstIterator; @@ -35,7 +38,7 @@ namespace ice struct EntryType { - ice::u64 key; + KeyType key; ice::u32 next; }; @@ -59,7 +62,32 @@ namespace ice requires std::copy_constructible; // API Requirements Of: AssociativeContainer - constexpr auto size() const noexcept -> SizeType { return _count; } + constexpr auto size() const noexcept -> SizeType { return { _count, sizeof(ValueType) }; } + template + constexpr auto find(this Self&& self, KeyType key) noexcept -> ice::container::ValuePtr; + + // Additional functionality + template + constexpr auto values(this Self&& self) noexcept -> ice::container::SpanType; + + // API Requirements Of: ResizableContainer + constexpr auto capacity() const noexcept -> SizeType { return { _capacity, sizeof(ValueType) }; } + constexpr void set_capacity(ice::ncount new_capacity) noexcept; + constexpr void clear() noexcept; + + // API Requirements Of: IterableContainer + template + constexpr auto begin(this Self&& self) noexcept -> ice::container::Iterator; + template + constexpr auto end(this Self&& self) noexcept -> ice::container::Iterator; + + // API Requriements Of: Memory and Data + constexpr auto memory_view() noexcept -> ice::Memory; + constexpr auto entries_memory_view() noexcept -> ice::Memory; + + // Data Helpers + constexpr auto values_data_view() const noexcept -> ice::Data; + constexpr auto entries_data_view() const noexcept -> ice::Data; }; template @@ -101,7 +129,8 @@ namespace ice template inline HashMap::~HashMap() noexcept { - ice::detail::hashmap::clear_and_dealloc(*this); + clear(); + set_capacity(0); } template @@ -126,7 +155,7 @@ namespace ice { if (other._count > 0) { - ice::detail::hashmap::rehash(*this, other._capacity); + set_capacity(other.capacity()); // NOTE: We keep the original entry + data indices, they don't need to change. // Copy all the entries, this is always a POD type. @@ -137,14 +166,11 @@ namespace ice ); // If the value is a complex type, properly move construct it in the new location + destroy in the old one. + ice::Memory const self_values_memory{ _data, this->size(), ice::align_of }; if constexpr (Logic == ContainerLogic::Complex) { ice::mem_copy_construct_n_at( - Memory{ - .location = _data, - .size = ice::size_of * other._count, - .alignment = ice::align_of - }, + self_values_memory, other._data, other._count ); @@ -152,22 +178,21 @@ namespace ice else { ice::memcpy( - Memory{ .location = _data, .size = ice::size_of * other._count, .alignment = ice::align_of }, - Data{ .location = other._data, .size = ice::size_of *other._count, .alignment = ice::align_of } + self_values_memory, + other.values_data_view() ); } ice::u32 idx = 0; - ICE_ASSERT_CORE(false); - //for (EntryType const& entry : ice::hashmap::entries(other._entries)) - //{ - // // First remember the previous set index... - // _entries[idx].next = _hashes[entry.key % _capacity]; + for (EntryType const& entry : ice::detail::hashmap::entries(*this)) + { + // First remember the previous set index... + _entries[idx].next = _hashes[entry.key % _capacity]; - // // ... then save the current index in the hashed array. - // _hashes[entry.key % _capacity] = idx; - // idx += 1; - //} + // ... then save the current index in the hashed array. + _hashes[entry.key % _capacity] = idx; + idx += 1; + } _count = other._count; } @@ -178,7 +203,8 @@ namespace ice { if (this != &other) { - ice::detail::hashmap::clear_and_dealloc(*this); // Clears the current data + clear(); + set_capacity(other.capacity()); _allocator = other._allocator; _capacity = std::exchange(other._capacity, 0); @@ -196,32 +222,25 @@ namespace ice { if (this != &other) { - ICE_ASSERT_CORE(false); - //ice::hashmap::clear(*this); + this->clear(); - // Grow if needed to the specific size - if (ice::detail::hashmap::can_store_expected_size(*this, other._count) == false) - { - ice::detail::hashmap::rehash(*this, ice::detail::hashmap::calc_required_capacity(other._count)); - } + // Grows the internal data structure to the required size. + this->reserve(other.size()); // NOTE: We keep the original entry + data indices, they don't need to change. // Copy all the entries, this is always a POD type. static_assert(std::is_pod_v, "HashMap::Entry should not be changed!"); ice::memcpy( - Memory{ .location = _entries, .size = ice::size_of * other._count, .alignment = ice::align_of }, - Data{ .location = other._entries, .size = ice::size_of * other._count, .alignment = ice::align_of } + this->entries_memory_view(), + other.entries_data_view() ); // If the value is a complex type, properly move construct it in the new location + destroy in the old one. + ice::Memory const self_values_memory{ _data, this->size(), ice::align_of }; if constexpr (Logic == ContainerLogic::Complex) { ice::mem_copy_construct_n_at( - Memory{ - .location = _data, - .size = ice::size_of * other._count, - .alignment = ice::align_of - }, + self_values_memory, other._data, other._count ); @@ -229,26 +248,180 @@ namespace ice else { ice::memcpy( - Memory{ .location = _data, .size = ice::size_of * other._count, .alignment = ice::align_of }, - Data{ .location = other._data, .size = ice::size_of * other._count, .alignment = ice::align_of } + self_values_memory, + other.values_data_view() ); } ice::u32 idx = 0; - ICE_ASSERT_CORE(false); - //for (EntryType const& entry : ice::hashmap::entries(other._entries)) - //{ - // // First remember the previous set index... - // _entries[idx].next = _hashes[entry.key % _capacity]; + for (EntryType const& entry : ice::detail::hashmap::entries(*this)) + { + // First remember the previous set index... + _entries[idx].next = _hashes[entry.key % _capacity]; - // // ... then save the current index in the hashed array. - // _hashes[entry.key % _capacity] = idx; - // idx += 1; - //} + // ... then save the current index in the hashed array. + _hashes[entry.key % _capacity] = idx; + idx += 1; + } _count = other._count; } return this; } + template + template + inline constexpr auto ice::HashMap::find( + this Self&& self, + KeyType key + ) noexcept -> ice::container::ValuePtr + { + ice::u32 const entry_index = ice::detail::hashmap::find_or_fail(self, key); + return entry_index != ice::detail::hashmap::Constant_EndOfList + ? ice::addressof(self._data[entry_index]) + : nullptr; + } + + template + template + inline constexpr auto ice::HashMap::values(this Self&& self) noexcept -> ice::container::SpanType + { + return { self._data, self._count }; + } + + template + inline constexpr void ice::HashMap::set_capacity(ice::ncount new_capacity) noexcept + { + ice::u32* new_hashes_ptr = nullptr; + EntryType* new_entries_ptr = nullptr; + ValueType* new_value_ptr = nullptr; + + if (new_capacity > 0) + { + ICE_ASSERT_CORE(new_capacity >= this->size()); // We don't support support reduction below current item count! + ice::ncount const new_internal_capacity = ice::detail::hashmap::capacity_with_overhead(new_capacity); + + ice::ChunkedAllocRequest alloc_reqest; + alloc_reqest.include(new_hashes_ptr, new_internal_capacity); + alloc_reqest.include(new_entries_ptr, new_capacity); + alloc_reqest.include(new_value_ptr, new_capacity); + _allocator->allocate(alloc_reqest); + + // Prepare hashes memory + std::memset(new_hashes_ptr, 0xffffffff, new_internal_capacity * sizeof(u32)); + + if (_count > 0) + { + // NOTE: We keep the original entry + data indices, they don't need to change. + + // Copy all the entries, this is always a POD type. + static_assert(std::is_pod_v, "HashMap::EntryType should not be changed!"); + std::memcpy(new_entries_ptr, this->_entries, sizeof(EntryType) * _count); + + // If the value is a complex type, properly move construct it in the new location + destroy in the old one. + ice::Memory const new_values_memory{ new_value_ptr, this->size(), ice::align_of }; + if constexpr (OperationLogic == ContainerLogic::Complex) + { + ice::mem_move_construct_n_at(new_values_memory, _data, _count); + } + else + { + ice::memcpy(new_values_memory, this->values_data_view()); + } + + ice::u32 idx = 0; + ice::u32 const new_capacity_u32 = new_capacity.u32(); + for (EntryType const& entry : ice::detail::hashmap::entries(*this)) + { + // First remember the previous set index... + new_entries_ptr[idx].next = new_hashes_ptr[entry.key % new_capacity_u32]; + + // ... then save the current index in the hashed array. + new_hashes_ptr[entry.key % new_capacity_u32] = idx; + idx += 1; + } + } + } + + _allocator->deallocate(this->memory_view()); + _capacity = new_capacity.u32(); + _hashes = new_hashes_ptr; + _entries = new_entries_ptr; + _data = new_value_ptr; + } + + template + inline constexpr void ice::HashMap::clear() noexcept + { + if (_count == 0) + { + return; + } + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_destruct_n_at(_data, _count); + } + + ice::ncount const internal_capacity = ice::detail::hashmap::capacity_with_overhead(_capacity); + std::memset(_hashes, ice::detail::hashmap::Constant_EndOfList, sizeof(u32) * internal_capacity); + + _count = 0; + } + + template + template + inline constexpr auto HashMap::begin(this Self&& self) noexcept -> ice::container::Iterator + { + return { self._entries, self._data }; + } + + template + template + inline constexpr auto HashMap::end(this Self&& self) noexcept -> ice::container::Iterator + { + return { self._entries + self._count, self._data + self._count }; + } + + template + inline constexpr auto ice::HashMap::memory_view() noexcept -> ice::Memory + { + ice::meminfo const info = ice::detail::hashmap::calc_meminfo(_capacity); + return ice::Memory{ + .location = _hashes, + .size = info.size, + .alignment = ice::align_of + }; + } + + template + inline constexpr auto ice::HashMap::entries_memory_view() noexcept -> ice::Memory + { + return ice::Memory{ + .location = _entries, + .size = ice::size_of * _count, + .alignment = ice::align_of + }; + } + + template + inline constexpr auto ice::HashMap::values_data_view() const noexcept -> ice::Data + { + return Data{ + .location = _data, + .size = this->size(), + .alignment = ice::align_of + }; + } + + template + inline constexpr auto ice::HashMap::entries_data_view() const noexcept -> ice::Data + { + return Data{ + .location = _entries, + .size = ice::size_of * _count, + .alignment = ice::align_of + }; + } + } // namespace ice diff --git a/source/code/core/collections/public/ice/string.hxx b/source/code/core/collections/public/ice/string.hxx index 04b77832..d31c8255 100644 --- a/source/code/core/collections/public/ice/string.hxx +++ b/source/code/core/collections/public/ice/string.hxx @@ -26,12 +26,6 @@ namespace ice constexpr BasicString() noexcept = default; - constexpr BasicString(BasicString&& other) noexcept = default; - constexpr BasicString(BasicString const& other) noexcept = default; - - constexpr auto operator=(BasicString&& other) noexcept -> BasicString& = default; - constexpr auto operator=(BasicString const& other) noexcept -> BasicString& = default; - constexpr BasicString(ValueType* ptr_array_nt) noexcept : _data{ ptr_array_nt } , _count{ ice::string::detail::strptr_size(ptr_array_nt) } From 224a30bf2fad7bb73198a5815871bccc13bc47a2 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sun, 18 Jan 2026 15:21:29 +0900 Subject: [PATCH 25/40] Updating code after refactoring parts of the HashMap API. --- .../core/collections/tests/test_array.cxx | 8 ++ .../core/collections/tests/test_hashmap.cxx | 76 ++++++++++--------- .../core/memsys/private/mem_allocator.cxx | 11 +++ source/code/core/memsys/public/ice/mem.hxx | 52 +++++++++++++ .../core/memsys/public/ice/mem_allocator.hxx | 9 +++ .../core/modules/private/module_register.cxx | 2 +- .../tasks/private/task_thread_pool_impl.cxx | 16 ++-- .../utils/private/config/config_builder.cxx | 10 +-- .../private/traits/trait_camera.cxx | 6 +- .../private/ecs/ecs_archetype_index.cxx | 2 +- .../engine/private/ecs/ecs_entity_storage.cxx | 8 +- .../private/engine_state_tracker_default.cxx | 2 +- .../engine/private/gfx/ice_gfx_graph.cxx | 4 +- .../engine/private/world_trait_archive.cxx | 2 +- .../public/ice/ecs/ecs_query_builder.hxx | 2 +- .../public/ice/ecs/ecs_query_storage.hxx | 2 +- .../private/gfx/iceshard_gfx_queue_group.cxx | 7 +- .../iceshard_gfx_image_storage_trait.cxx | 6 +- .../iceshard_gfx_shader_storage_trait.cxx | 8 +- .../private/iceshard_data_storage.hxx | 4 +- .../iceshard/private/iceshard_frame.cxx | 2 +- .../private/iceshard_trait_context.cxx | 2 +- .../iceshard/private/iceshard_world_devui.cxx | 2 +- .../private/iceshard_world_manager.cxx | 6 +- .../private/iceshard_world_manager.hxx | 4 +- .../private/iceshard_world_manager_devui.cxx | 2 +- .../asset_system/private/asset_shelve.cxx | 2 +- .../private/asset_shelve_devui.cxx | 2 +- .../asset_system/private/asset_storage.cxx | 2 +- .../private/asset_type_archive.cxx | 2 +- .../private/input_action_layer_builder.cxx | 8 +- .../private/input_action_stack.cxx | 4 +- .../input_system/private/input_tracker.cxx | 4 +- .../private/resource_provider_custom.cxx | 2 +- .../private/resource_provider_dynlib.cxx | 2 +- .../private/resource_provider_filelist.cxx | 2 +- .../private/resource_provider_filesystem.cxx | 2 +- .../resource_provider_filesystem_devui.cxx | 2 +- .../private/resource_provider_hailstorm.cxx | 2 +- .../private/resource_tracker.cxx | 10 +-- .../private/resource_writer_filesystem.cxx | 2 +- 41 files changed, 195 insertions(+), 108 deletions(-) diff --git a/source/code/core/collections/tests/test_array.cxx b/source/code/core/collections/tests/test_array.cxx index 6fc82bd4..e8419add 100644 --- a/source/code/core/collections/tests/test_array.cxx +++ b/source/code/core/collections/tests/test_array.cxx @@ -201,6 +201,14 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod objects.push_back(test_value_2 + i); } + THEN("the returned 'size' properly stores the number and byte size of elements.") + { + CHECK(objects.size() == 100); + CHECK(objects.size() == ice::size_of * 100); + CHECK(objects.capacity() >= 100); + CHECK(objects.capacity() >= ice::size_of * 100); + } + CHECK(objects.size() == 100); CHECK(objects.capacity() >= 100); CHECK(objects.not_empty() == true); diff --git a/source/code/core/collections/tests/test_hashmap.cxx b/source/code/core/collections/tests/test_hashmap.cxx index 8a21c279..64122ccf 100644 --- a/source/code/core/collections/tests/test_hashmap.cxx +++ b/source/code/core/collections/tests/test_hashmap.cxx @@ -57,28 +57,37 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] GIVEN("an hashmap with a multiple elements") { - static constexpr ice::u32 values[]{ 42, 11, 23 }; + static constexpr ice::u32 values[]{ 42, 11, 23, 54, 21 }; for (ice::u32 value : values) { ice::hashmap::set(test_hash, value, Test_TrackingObject{ value }); } + THEN("the returned 'size' properly stores the number and byte size of elements.") + { + ice::u32 const val_count = ice::count(values); + CHECK(test_hash.size() == val_count); + CHECK(test_hash.size() == ice::size_of * val_count); + CHECK(test_hash.capacity() >= val_count); + CHECK(test_hash.capacity() >= ice::size_of * val_count); + } + Test_ObjectEvents test_events{}; for (Test_TrackingObject const& obj : test_hash) { obj.gather_ctors(test_events); } - CHECK(test_hash.size() == 3_count); + CHECK(test_hash.size() == 5_count); CHECK(test_events.test_ctor == 0); - CHECK(test_events.test_ctor_move == 3); + CHECK(test_events.test_ctor_move == 5); CHECK(test_events.test_ctor_copy == 0); AND_THEN("replacing the objects will call destructors") { ice::u32 dtor_count = 0; - for (Test_TrackingObject& obj : ice::hashmap::values(test_hash)) + for (Test_TrackingObject& obj : test_hash.values()) { obj.data.test_dtor = &dtor_count; } @@ -94,12 +103,12 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] obj.gather_ctors(test_events); } - CHECK(test_hash.size() == 3_count); + CHECK(test_hash.size() == 5_count); CHECK(test_events.test_ctor == 0); - CHECK(test_events.test_ctor_move == 3); + CHECK(test_events.test_ctor_move == 5); CHECK(test_events.test_ctor_copy == 0); - CHECK(dtor_count == 3); + CHECK(dtor_count == 5); } } } @@ -112,14 +121,14 @@ SCENARIO("collections 'ice/container/hashmap.hxx' (POD)", "[collection][hash][po ice::HostAllocator alloc{ }; ice::HashMap test_hash{ alloc }; - ice::hashmap::detail::rehash(test_hash, 2); + test_hash.set_capacity(2); GIVEN("an empty hash container") { WHEN("setting a single value") { hash::set(test_hash, 0, 0xd00b); - CHECK(hash::has(test_hash, 0) == true); + CHECK(test_hash.has(0) == true); CHECK(hash::get(test_hash, 0, 0xffff) == 0xd00b); CHECK(hash::get(test_hash, 1, 0xffff) == 0xffff); } @@ -131,50 +140,49 @@ SCENARIO("collections 'ice/container/hashmap.hxx' (POD)", "[collection][hash][po hash::set(test_hash, 4, 0xd00b + 2); hash::set(test_hash, 6, 0xd00b + 3); - CHECK(hash::has(test_hash, 0) == true); - CHECK(hash::has(test_hash, 2) == true); - CHECK(hash::has(test_hash, 4) == true); - CHECK(hash::has(test_hash, 6) == true); + CHECK(test_hash.has(0) == true); + CHECK(test_hash.has(2) == true); + CHECK(test_hash.has(4) == true); + CHECK(test_hash.has(6) == true); hash::remove(test_hash, 0); hash::remove(test_hash, 4); - CHECK(hash::has(test_hash, 0) == false); - CHECK(hash::has(test_hash, 2) == true); - CHECK(hash::has(test_hash, 4) == false); - CHECK(hash::has(test_hash, 6) == true); + CHECK(test_hash.has(0) == false); + CHECK(test_hash.has(2) == true); + CHECK(test_hash.has(4) == false); + CHECK(test_hash.has(6) == true); hash::set(test_hash, 0, 0xd00b + 4); hash::set(test_hash, 0, 0xd00b + 5); // Replaces the old value - CHECK(hash::has(test_hash, 0) == true); - CHECK(hash::has(test_hash, 2) == true); - CHECK(hash::has(test_hash, 4) == false); - CHECK(hash::has(test_hash, 6) == true); + CHECK(test_hash.has(0) == true); + CHECK(test_hash.has(2) == true); + CHECK(test_hash.has(4) == false); + CHECK(test_hash.has(6) == true); CHECK(hash::get(test_hash, 0, 0xffff) == 0xd00b + 5); hash::set(test_hash, 0, 0xd00b + 0); THEN("We got values to iterate over") { - ICE_ASSERT_CORE(false); ice::i32 count = 0; - //for (auto& entry : hash::entries(test_hash)) - //{ - // count += (entry, 1); - //} + for (auto& entry : test_hash) + { + count += (entry, 1); + } CHECK(count == 3); } THEN("We clear the hash") { - hash::clear(test_hash); + test_hash.clear(); - CHECK(hash::has(test_hash, 0) == false); - CHECK(hash::has(test_hash, 2) == false); - CHECK(hash::has(test_hash, 4) == false); - CHECK(hash::has(test_hash, 6) == false); + CHECK(test_hash.missing(0) == true); + CHECK(test_hash.missing(2) == true); + CHECK(test_hash.missing(4) == true); + CHECK(test_hash.missing(6) == true); } } } @@ -224,8 +232,8 @@ SCENARIO("collections 'ice/container/hashmap.hxx' (POD)", "[collection][hash][po THEN("We got values to iterate over") { - auto it = ice::begin(test_hash); - auto const end = ice::end(test_hash); + auto it = test_hash.begin(); + auto const end = test_hash.end(); int count = 0; for (auto& entry : test_hash) @@ -238,7 +246,7 @@ SCENARIO("collections 'ice/container/hashmap.hxx' (POD)", "[collection][hash][po THEN("We clear the hash") { - hash::clear(test_hash); + test_hash.clear(); CHECK(multi_hash::count(test_hash, 0) == 0); CHECK(multi_hash::count(test_hash, 2) == 0); diff --git a/source/code/core/memsys/private/mem_allocator.cxx b/source/code/core/memsys/private/mem_allocator.cxx index 37ceef80..0cc7193a 100644 --- a/source/code/core/memsys/private/mem_allocator.cxx +++ b/source/code/core/memsys/private/mem_allocator.cxx @@ -178,6 +178,17 @@ namespace ice return result; } + auto AllocatorBase::allocate(ice::ChunkedAllocRequest const& request) noexcept -> ice::AllocResult + { + // TODO: Check if requesting sizes of '0' can be actually allowed + // ICE_ASSERT_CORE(request.size != 0_B); + ice::AllocResult result = do_allocate(request._request_meminfo); + _internal->insert(result); + dbg_count_add(); + request.finalize(result); + return result; + } + void AllocatorBase::deallocate(void* pointer) noexcept { if (pointer == nullptr) return; diff --git a/source/code/core/memsys/public/ice/mem.hxx b/source/code/core/memsys/public/ice/mem.hxx index d4d4c9db..f6707873 100644 --- a/source/code/core/memsys/public/ice/mem.hxx +++ b/source/code/core/memsys/public/ice/mem.hxx @@ -10,6 +10,7 @@ namespace ice { + struct AllocResult; struct AllocRequest { ice::usize size = 0_B; @@ -23,6 +24,21 @@ namespace ice constexpr AllocRequest(ice::AlignResult align_result) noexcept; }; + struct ChunkedAllocRequest + { + ice::meminfo _request_meminfo{ }; + ice::u64 _chunk_count = 0; + ice::usize _chunk_offsets[14]; + void** _chunk_pointers[15]; + + constexpr explicit ChunkedAllocRequest() noexcept = default; + + template + constexpr auto include(T*& ptrref, ice::u64 count) noexcept; + constexpr void finalize(ice::AllocResult result) const noexcept; + constexpr void reset() noexcept; + }; + struct AllocResult { void* memory; @@ -70,4 +86,40 @@ namespace ice }; } + template + inline constexpr auto ChunkedAllocRequest::include(T*& ptrref, ice::u64 count) noexcept + { + ICE_ASSERT_CORE(_chunk_count < 14); // You sure you need that much? (Refactor if more are required) + + if (_chunk_count == 0) + { + _request_meminfo = ice::meminfo_of * count; + } + else + { + ice::usize const offset = _request_meminfo += ice::meminfo_of * count; + _chunk_offsets[_chunk_count - 1] = offset; + } + _chunk_pointers[_chunk_count] = reinterpret_cast(ice::addressof(ptrref)); + _chunk_count += 1; + } + + inline constexpr void ChunkedAllocRequest::finalize(ice::AllocResult result) const noexcept + { + ICE_ASSERT_CORE(result.size >= _request_meminfo.size); + ICE_ASSERT_CORE(result.alignment >= _request_meminfo.alignment); + *_chunk_pointers[0] = result.memory; // Assign the allocation result directly to the first pointer. + // Assign the other pointers according to the stored offsets + for (ice::u64 index = 1; index < _chunk_count; ++index) + { + *_chunk_pointers[index] = ice::ptr_add(result.memory, _chunk_offsets[index - 1]); + } + } + + inline constexpr void ChunkedAllocRequest::reset() noexcept + { + _request_meminfo = ice::meminfo{}; + _chunk_count = 0; + } + } // namespace ice diff --git a/source/code/core/memsys/public/ice/mem_allocator.hxx b/source/code/core/memsys/public/ice/mem_allocator.hxx index 24226a6e..2552d36d 100644 --- a/source/code/core/memsys/public/ice/mem_allocator.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator.hxx @@ -28,6 +28,13 @@ namespace ice return do_allocate(request); } + auto allocate(ice::ChunkedAllocRequest const& request) noexcept -> ice::AllocResult + { + ice::AllocResult const result = do_allocate(request._request_meminfo); + request.finalize(result); + return result; + } + template requires std::is_trivial_v auto allocate(ice::u64 count = 1) noexcept -> T* { @@ -176,6 +183,8 @@ namespace ice AllocatorBase(std::source_location const& src_loc, AllocatorBase& parent, std::string_view name) noexcept; auto allocate(ice::AllocRequest request) noexcept -> ice::AllocResult; + auto allocate(ice::ChunkedAllocRequest const& request) noexcept -> ice::AllocResult; + template requires std::is_trivial_v auto allocate(ice::u64 count = 1) noexcept -> T* { diff --git a/source/code/core/modules/private/module_register.cxx b/source/code/core/modules/private/module_register.cxx index 18bdcb60..c58dddc1 100644 --- a/source/code/core/modules/private/module_register.cxx +++ b/source/code/core/modules/private/module_register.cxx @@ -86,7 +86,7 @@ namespace ice DefaultModuleRegister::~DefaultModuleRegister() noexcept { ice::FnModuleUnload* fn_unload_prev = nullptr; - for (DefaultModuleEntry const& entry : ice::hashmap::values(_modules)) + for (DefaultModuleEntry const& entry : _modules.values()) { if (fn_unload_prev != entry.unload_proc) { diff --git a/source/code/core/tasks/private/task_thread_pool_impl.cxx b/source/code/core/tasks/private/task_thread_pool_impl.cxx index d640058b..4e2f8c59 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.cxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.cxx @@ -49,8 +49,8 @@ namespace ice { _thread_pool.reserve(info.thread_count); _managed_threads.reserve(info.thread_count); - ice::hashmap::reserve(_created_threads, info.thread_count.u32()); - ice::hashmap::reserve(_user_threads, info.thread_count.u32()); + _created_threads.reserve(info.thread_count); + _user_threads.reserve(info.thread_count); ice::TaskThreadInfo thread_info{ .exclusive_queue = false, @@ -97,8 +97,8 @@ namespace ice TaskThreadPoolImplementation::~TaskThreadPoolImplementation() noexcept { - ice::hashmap::clear(_user_threads); - ice::hashmap::clear(_created_threads); + _user_threads.clear(); + _created_threads.clear(); _managed_threads.clear(); _thread_pool.clear(); } @@ -121,7 +121,7 @@ namespace ice auto TaskThreadPoolImplementation::create_thread(ice::StringID name) noexcept -> ice::TaskThread& { ICE_ASSERT( - ice::hashmap::has(_created_threads, ice::hash(name)) == false, + _created_threads.missing(name), "A pool thread with name '{}' already exists", name ); @@ -159,7 +159,7 @@ namespace ice bool TaskThreadPoolImplementation::destroy_thread(ice::StringID name) noexcept { ice::u64 const name_hash = ice::hash(name); - bool const exists = ice::hashmap::has(_created_threads, name_hash); + bool const exists = _created_threads.has(name_hash); if (exists) { ice::hashmap::remove(_created_threads, name_hash); @@ -175,7 +175,7 @@ namespace ice { ice::u64 const name_hash = ice::hash(name); ICE_ASSERT( - ice::hashmap::has(_user_threads, name_hash) == false, + _user_threads.missing(name_hash), "A user thread with name '{}' already exists", name ); @@ -195,7 +195,7 @@ namespace ice { ice::u64 const name_hash = ice::hash(name); ice::UniquePtr result; - if (ice::hashmap::has(_user_threads, name_hash)) + if (_user_threads.has(name_hash)) { // Move the thread out of the map result = ice::move(*ice::hashmap::try_get(_user_threads, name_hash)); diff --git a/source/code/core/utils/private/config/config_builder.cxx b/source/code/core/utils/private/config/config_builder.cxx index 9d9c7b1e..0c97fb71 100644 --- a/source/code/core/utils/private/config/config_builder.cxx +++ b/source/code/core/utils/private/config/config_builder.cxx @@ -56,7 +56,7 @@ namespace ice it = ice::multi_hashmap::find_next(keystrings, it); } - return it == nullptr ? ice::hashmap::count(keystrings) : it.value().index; + return it == nullptr ? keystrings.size().u32() : it.value().index; } auto cb_calculate_key_size( @@ -74,7 +74,7 @@ namespace ice // If it's not there, store a new entry and give it a new index. // This allows us to reuse duplicate key names - if (keystr_idx == ice::hashmap::count(keystrings)) + if (keystr_idx == keystrings.size()) { ice::multi_hashmap::insert(keystrings, ice::hash(keystr), { keystr, keystr_idx }); result += { entry->size }; // Increase the size required @@ -184,7 +184,7 @@ namespace ice { ice::String const it_keystr = cb_getkey(config._keystrings, *it_entry); ice::u32 const it_keystr_idx = ice::cb_find_keystr_idx(keystrings, it_keystr); - ICE_ASSERT_CORE(it_keystr_idx < ice::hashmap::count(keystrings)); + ICE_ASSERT_CORE(it_keystr_idx < keystrings.size()); ice::u32 const new_keystr_offset = keystringoffsets[it_keystr_idx]; out_keylist[keyoffset].offset = new_keystr_offset; } @@ -397,10 +397,10 @@ namespace ice char const* final_keystrings = reinterpret_cast(final_keystrings_mem.location); // Reserve space to hold all keystring entries and build the string buffer. - keyoffsets.resize(ice::hashmap::count(keystrings)); + keyoffsets.resize(keystrings.size()); ice::ncount keystr_offset = 0; - for (CBKeyString const& keystr : ice::hashmap::values(keystrings)) + for (CBKeyString const& keystr : keystrings.values()) { // Copy and advance the pointer ice::memcpy(final_keystrings_mem, keystr.value.data_view()); diff --git a/source/code/framework/framework_base/private/traits/trait_camera.cxx b/source/code/framework/framework_base/private/traits/trait_camera.cxx index 2e4f4bc2..92eff1ee 100644 --- a/source/code/framework/framework_base/private/traits/trait_camera.cxx +++ b/source/code/framework/framework_base/private/traits/trait_camera.cxx @@ -89,7 +89,7 @@ namespace ice ice::CameraPerspective const* >().synchronized_on(params.thread.tasks); - ice::hashmap::reserve(_render_data, query_cameras.entity_count()); + _render_data.reserve(query_cameras.entity_count()); for (auto[entity, camera, ortho, persp] : query_cameras.for_each_entity()) { @@ -160,7 +160,7 @@ namespace ice { using namespace ice::render; - for (ice::TraitCameraData& camera : ice::hashmap::values(_render_data)) + for (ice::TraitCameraData& camera : _render_data.values()) { if (camera.render_data == Buffer::Invalid) { @@ -183,7 +183,7 @@ namespace ice ice::render::RenderDevice& device ) noexcept -> ice::Task<> { - for (ice::TraitCameraData& data : ice::hashmap::values(_render_data)) + for (ice::TraitCameraData& data : _render_data.values()) { device.destroy_buffer(data.render_data); } diff --git a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx index 7a424e54..1b858b2e 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx @@ -176,7 +176,7 @@ namespace ice::ecs ice::ecs::detail::DataBlockPool* data_block_pool ) noexcept -> ice::ecs::Archetype { - if (ice::hashmap::has(_archetype_index, ice::hash(archetype_info.identifier))) + if (_archetype_index.has(archetype_info.identifier)) { ICE_LOG( ice::LogSeverity::Warning, ice::LogTag::Engine, diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx index 5da8f36a..57722831 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx @@ -571,7 +571,7 @@ namespace ice::ecs using ice::ecs::detail::DataBlockPool; using ice::ecs::detail::ArchetypeInstance; - for (ice::ecs::QueryAccessTracker* tracker : ice::hashmap::values(_access_trackers)) + for (ice::ecs::QueryAccessTracker* tracker : _access_trackers.values()) { _allocator.destroy(tracker); } @@ -630,7 +630,7 @@ namespace ice::ecs _head_blocks.resize(archetype_count); _data_blocks.resize(archetype_count); - ice::hashmap::reserve(_destructors, archetype_count); + _destructors.reserve(archetype_count); // Setup the empty head blocks for new archetypes. // This approach gives two benefits: @@ -679,7 +679,7 @@ namespace ice::ecs _archetype_index.fetch_archetype_instance_info_with_pool(archetype, info, pool); ICE_ASSERT_CORE(info != nullptr); - if (ice::hashmap::has(_destructors, ice::hash(info->archetype_instance))) + if (_destructors.has(info->archetype_instance)) { auto it = ice::multi_hashmap::find_first(_destructors, ice::hash(info->archetype_instance)); while (it != nullptr && it.value().identifier != destructor.identifier) @@ -717,7 +717,7 @@ namespace ice::ecs } // Ensure all queries are finished - for (ice::ecs::QueryAccessTracker* tracker : ice::hashmap::values(_access_trackers)) + for (ice::ecs::QueryAccessTracker* tracker : _access_trackers.values()) { ice::u32 const final_counter_exec = tracker->access_stage_executed.exchange(0, std::memory_order_relaxed); ice::u32 const final_counter_next = tracker->access_stage_next.exchange(0, std::memory_order_relaxed); diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index 106aa626..d156ddfc 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -28,7 +28,7 @@ namespace ice ice::Span triggers ) noexcept { - if (ice::hashmap::has(_initial_states, ice::hash(params.initial.graph.value))) + if (_initial_states.has(ice::hash(params.initial.graph.value))) { return false; } diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx index d5890165..fb2ce5b6 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx @@ -88,7 +88,7 @@ namespace ice::gfx bool IceshardGfxGraph::add_pass(GfxGraphPass const& pass) noexcept { - if (ice::hashmap::has(_objects, ice::hash(pass.name)) == false) + if (_objects.missing(pass.name)) { ice::u32 res_count = 0; for (ice::gfx::GfxGraphStage const& stage : pass.stages) @@ -325,7 +325,7 @@ namespace ice::gfx ice::u32 pass_idx = 0; ice::u32 pass_idx_stages = _stages._counts[0]; - auto it = ice::begin(_stages._stages); + auto it = _stages._stages.begin(); for (ice::StringID stagename : _stages._stage_names) { if (it.key() == ice::hash(stagename)) diff --git a/source/code/iceshard/engine/private/world_trait_archive.cxx b/source/code/iceshard/engine/private/world_trait_archive.cxx index e6b6c8c6..32e4e139 100644 --- a/source/code/iceshard/engine/private/world_trait_archive.cxx +++ b/source/code/iceshard/engine/private/world_trait_archive.cxx @@ -34,7 +34,7 @@ namespace ice "Register function for trait {} returned unsuccessful.", descriptor.name ); // TODO: Allow registering with priority instead of first in - if (can_register && ice::hashmap::has(_traits, ice::hash(descriptor.name)) == false) + if (can_register && _traits.missing(descriptor.name)) { if (descriptor.fn_arch_register != nullptr) { diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx index 0c4a945e..dfb08b88 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx @@ -58,7 +58,7 @@ namespace ice::ecs auto query_object() const noexcept -> ice::ecs::QueryObject const& { - if (ice::hashmap::has(_queries, Entry::hash_value()) == false) + if (this->_queries.missing(Entry::hash_value())) { ice::UniquePtr entry = ice::make_unique(_allocator, _allocator); entry->initialize(_query_provider); diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage.hxx index bf55e518..9475c91e 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage.hxx @@ -42,7 +42,7 @@ namespace ice::ecs inline QueryStorage::~QueryStorage() noexcept { - ice::hashmap::clear(_queries); + _queries.clear(); } inline auto QueryStorage::query_provider() const noexcept -> ice::ecs::QueryProvider const& diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx index 6cc122c4..5f3811cb 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx @@ -17,7 +17,7 @@ namespace ice::gfx : _allocator{ alloc } , _gfx_queues{ _allocator } { - ice::hashmap::reserve(_gfx_queues, queue_count * 2); + _gfx_queues.reserve(queue_count * 2); } IceGfxQueueGroup::~IceGfxQueueGroup() noexcept @@ -36,9 +36,8 @@ namespace ice::gfx ice::u32 pool_index ) noexcept -> ice::gfx::IceGfxQueue* { - ice::u64 const name_hash = ice::hash(name); ICE_ASSERT( - ice::hashmap::has(_gfx_queues, name_hash) == false, + _gfx_queues.missing(name), "Duplicate graphics queue encountered! [{}]", ice::stringid_hint(name) ); @@ -54,7 +53,7 @@ namespace ice::gfx ice::hashmap::set( _gfx_queues, - name_hash, + ice::hash(name), queue ); diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx index 3888bc45..caabc9fb 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx @@ -47,7 +47,7 @@ namespace ice::gfx void Trait_GfxImageStorage::build_content() noexcept { static ice::i32 selected = -1; - ice::Span images = ice::hashmap::values(_loaded_images); + ice::Span images = _loaded_images.values(); ice::String const preview = selected < 0 ? "" : ice::stringid_hint(images[selected].asset.name()); @@ -263,13 +263,13 @@ namespace ice::gfx ice::render::RenderDevice& device ) noexcept -> ice::Task<> { - for (ice::gfx::GfxImageEntry& entry : ice::hashmap::values(_loaded_images)) + for (ice::gfx::GfxImageEntry& entry : _loaded_images.values()) { device.destroy_image(entry.image); entry.asset.release(); } - ice::hashmap::clear(_loaded_images); + _loaded_images.clear(); co_return; } diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx index eda81ba8..70694af5 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx @@ -43,7 +43,7 @@ namespace ice::gfx ImGui::TextT("Loaded shaders: {}", _loaded_shaders.size()); if (ImGui::BeginCombo("##shader-list", "Shader to preview", ImGuiComboFlags_WidthFitPreview)) { - for (GfxShaderEntry& entry : ice::hashmap::values(_loaded_shaders)) + for (GfxShaderEntry& entry : _loaded_shaders.values()) { ice::URI const uri = entry.asset.uri(); ImGui::Selectable(uri.path()._data, &entry.devui_loaded); @@ -51,7 +51,7 @@ namespace ice::gfx ImGui::EndCombo(); } - for (GfxShaderEntry& entry : ice::hashmap::values(_loaded_shaders)) + for (GfxShaderEntry& entry : _loaded_shaders.values()) { if (entry.devui_loaded) { @@ -134,13 +134,13 @@ namespace ice::gfx auto Trait_GfxShaderStorage::gfx_shutdown(ice::render::RenderDevice& device) noexcept -> ice::Task<> { - for (ice::gfx::GfxShaderEntry& entry : ice::hashmap::values(_loaded_shaders)) + for (ice::gfx::GfxShaderEntry& entry : _loaded_shaders.values()) { device.destroy_shader(entry.shader); entry.asset.release(); } - ice::hashmap::clear(_loaded_shaders); + _loaded_shaders.clear(); co_return; } diff --git a/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx b/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx index ba041d32..43e108f2 100644 --- a/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx @@ -33,13 +33,13 @@ namespace ice bool has(ice::StringID_Arg name) const noexcept override { - return ice::hashmap::has(_values, ice::hash(name)); + return _values.has(name); } bool set(ice::StringID_Arg name, void* value) noexcept override { ice::u64 const hash = ice::hash(name); - bool const missing = ice::hashmap::has(_values, hash) == false; + bool const missing = _values.missing(hash); ICE_ASSERT_CORE(missing); //if (missing) { diff --git a/source/code/iceshard/iceshard/private/iceshard_frame.cxx b/source/code/iceshard/iceshard/private/iceshard_frame.cxx index 19e69540..626751c6 100644 --- a/source/code/iceshard/iceshard/private/iceshard_frame.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_frame.cxx @@ -31,7 +31,7 @@ namespace ice _frame_data._fwd_allocator.deallocate(group.barrier); } _task_groups.clear(); - ice::hashmap::clear(_data._values); + _data._values.clear(); _frame_data._fwd_allocator.reset(); } diff --git a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx index 2feaa4ef..2a291287 100644 --- a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx @@ -97,7 +97,7 @@ namespace ice bool IceshardTraitContext::register_checkpoint(ice::StringID id, ice::TaskCheckpoint& checkpoint) noexcept { - if (ice::hashmap::has(_world_context._checkpoints, ice::hash(id))) + if (_world_context._checkpoints.has(id)) { return false; } diff --git a/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx index 3e908141..d7bb05bc 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx @@ -86,7 +86,7 @@ namespace ice ImGui::TextT("{} handlers (count: {})", handler_type, hashmap.size()); if (hashmap.not_empty()) { - detail::devui_handlers_table(ice::hashmap::values(hashmap), _world._traits); + detail::devui_handlers_table(hashmap.values(), _world._traits); } else { diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx index bd5bbb67..b614bba5 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx @@ -100,7 +100,7 @@ namespace ice { ICE_ASSERT( - ice::hashmap::has(_worlds, ice::hash(world_template.name)) == false, + _worlds.missing(world_template.name), "A world with this name {} was already created!", world_template.name ); @@ -205,7 +205,7 @@ namespace ice ice::ShardContainer& out_shards ) noexcept { - for (Entry& world_entry : ice::hashmap::values(_worlds)) + for (Entry& world_entry : _worlds.values()) { world_entry.context->close_checkpoints(); world_entry.world->pre_update(out_shards); @@ -218,7 +218,7 @@ namespace ice ice::Span event_shards ) noexcept { - for (Entry& world_entry : ice::hashmap::values(_worlds)) + for (Entry& world_entry : _worlds.values()) { if (world_entry.is_active) { diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager.hxx b/source/code/iceshard/iceshard/private/iceshard_world_manager.hxx index f64b8be9..2c4571ca 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager.hxx @@ -55,8 +55,8 @@ namespace ice ice::Span event_shards ) noexcept override; - auto begin() noexcept { return ice::hashmap::begin(_worlds); } - auto end() noexcept { return ice::hashmap::end(_worlds); } + auto begin() noexcept { return _worlds.begin(); } + auto end() noexcept { return _worlds.end(); } public: // Implementation of: ice::EngineStateCommiter bool commit( diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx index 997e6cee..b880d256 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx @@ -56,7 +56,7 @@ namespace ice ImGui::TableNextColumn(); ice::u32 idx = 0; - ice::Span const entries = ice::hashmap::values(_manager._worlds); + ice::Span const entries = _manager._worlds.values(); for (IceshardWorldManager::Entry const& entry : entries) { ice::IceshardWorld const& world = *entry.world; diff --git a/source/code/systems/asset_system/private/asset_shelve.cxx b/source/code/systems/asset_system/private/asset_shelve.cxx index 7cdc60eb..e796959c 100644 --- a/source/code/systems/asset_system/private/asset_shelve.cxx +++ b/source/code/systems/asset_system/private/asset_shelve.cxx @@ -27,7 +27,7 @@ namespace ice , _allocator{ alloc } , _asset_resources{ alloc } { - ice::hashmap::reserve(_asset_resources, 25); + _asset_resources.reserve(25); } AssetShelve::~AssetShelve() noexcept diff --git a/source/code/systems/asset_system/private/asset_shelve_devui.cxx b/source/code/systems/asset_system/private/asset_shelve_devui.cxx index ae6c620d..eface9c9 100644 --- a/source/code/systems/asset_system/private/asset_shelve_devui.cxx +++ b/source/code/systems/asset_system/private/asset_shelve_devui.cxx @@ -41,7 +41,7 @@ namespace ice ImGui::TableSetupColumn("Resource", ImGuiTableColumnFlags_DefaultHide); ImGui::TableHeadersRow(); - for (ice::AssetEntry const* entry : ice::hashmap::values(_shelve._asset_resources)) + for (ice::AssetEntry const* entry : _shelve._asset_resources.values()) { ImGui::TableNextRow(); ImGui::TableNextColumn(); diff --git a/source/code/systems/asset_system/private/asset_storage.cxx b/source/code/systems/asset_system/private/asset_storage.cxx index cc0a34b0..a3198779 100644 --- a/source/code/systems/asset_system/private/asset_storage.cxx +++ b/source/code/systems/asset_system/private/asset_storage.cxx @@ -240,7 +240,7 @@ namespace ice , _devui_widget{ } { ice::Span categories = _asset_archive->categories(); - ice::hashmap::reserve(_asset_shelves, categories.size().u32()); + _asset_shelves.reserve(categories.size().u32()); ice::Array> shelves{ _allocator }; for (ice::AssetCategory_Arg category : categories) diff --git a/source/code/systems/asset_system/private/asset_type_archive.cxx b/source/code/systems/asset_system/private/asset_type_archive.cxx index 4f88d4a3..5c176112 100644 --- a/source/code/systems/asset_system/private/asset_type_archive.cxx +++ b/source/code/systems/asset_system/private/asset_type_archive.cxx @@ -70,7 +70,7 @@ namespace ice ) noexcept { ice::u64 const type_hash = category.identifier; - bool const type_not_defined = ice::hashmap::has(_definitions, type_hash) == false; + bool const type_not_defined = _definitions.missing(type_hash); ICE_ASSERT( type_not_defined == true, diff --git a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx index d80819d5..e8f71c48 100644 --- a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx @@ -110,7 +110,7 @@ namespace ice , type{ type } , events{ alloc } { - ice::hashmap::reserve(events, 2); + events.reserve(2); } ice::HeapString<> name; @@ -207,8 +207,8 @@ namespace ice , _actions{ _allocator } , _name{ _allocator, name } { - ice::hashmap::reserve(_sources, 16); - ice::hashmap::reserve(_actions, 10); + _sources.reserve(16); + _actions.reserve(10); _constants.push_back({ InputActionConstant::Nil, 0.0f }); } @@ -351,7 +351,7 @@ namespace ice }; // Run finalization on all internal action objects. - for (Internal& action : ice::hashmap::values(_actions)) + for (Internal& action : _actions.values()) { action.finalize(); } diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index fa09db62..fc2adce6 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -178,7 +178,7 @@ namespace ice // First we check if a source with a name like this already exists, if so we take the index to it's location // else we push back a new value to the list of runtime values and store it's index under the hashed name. ice::u32 values_index = 0; - if (ice::hashmap::has(_sources, source_name_hash)) + if (_sources.has(source_name_hash)) { if (prev_name_hash != source_name_hash) { @@ -227,7 +227,7 @@ namespace ice ice::String const action_name = layer->action_name(action); ice::u64 const action_name_hash = ice::hash(action_name); - if (ice::hashmap::has(_actions, action_name_hash) == false) + if (_actions.missing(action_name_hash)) { // Create the final name with the prefix and store it so the pointer reimains valid. // #TODO: Consider using refs instead? diff --git a/source/code/systems/input_system/private/input_tracker.cxx b/source/code/systems/input_system/private/input_tracker.cxx index 86fd4914..3c313a06 100644 --- a/source/code/systems/input_system/private/input_tracker.cxx +++ b/source/code/systems/input_system/private/input_tracker.cxx @@ -66,7 +66,7 @@ namespace ice::input ) noexcept { // #todo handle duplicate type case - if (ice::hashmap::has(_factories, ice::hash(type)) == false) + if (_factories.missing(ice::hash(type))) { ice::hashmap::set(_factories, ice::hash(type), device_factory); } @@ -124,7 +124,7 @@ namespace ice::input ice::hashmap::remove(_devices, device_hash); // #todo log device disconnected (shard?) } - else if (ice::hashmap::has(_devices, device_hash)) + else if (_devices.has(device_hash)) { InputDevice* const device = ice::hashmap::get(_devices, device_hash, nullptr); device->on_event(event); diff --git a/source/code/systems/resource_system/private/resource_provider_custom.cxx b/source/code/systems/resource_system/private/resource_provider_custom.cxx index cffc9f82..259d4b9e 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.cxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.cxx @@ -59,7 +59,7 @@ namespace ice { ice::u64 const hash = ice::hash(resource->origin()); ICE_ASSERT( - ice::hashmap::has(_resources, hash) == false, + _resources.missing(hash), "A resource cannot be a explicit resource AND part of another resource." ); diff --git a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx index 0c89efd8..19e87ce9 100644 --- a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx +++ b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx @@ -60,7 +60,7 @@ namespace ice ); ice::u64 const resource_hash = ice::hash(resource->uri().path()); - if (ice::hashmap::has(_resources, resource_hash)) + if (_resources.has(resource_hash)) { ICE_LOG( LogSeverity::Warning, LogTag::Core, diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index 60fe7c19..b18b93fd 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -116,7 +116,7 @@ namespace ice ice::u64 const hash = ice::hash(resource->uri().path()); ICE_ASSERT( - ice::hashmap::has(_resources, hash) == false, + _resources.missing(hash), "A resource cannot be a explicit resource AND part of another resource." ); diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx index eb7587da..798ab00a 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx @@ -290,7 +290,7 @@ namespace ice ice::u64 const hash = ice::hash(resource->origin()); ICE_ASSERT( - ice::hashmap::has(_resources, hash) == false, + _resources.missing(hash), "A resource cannot be a explicit resource AND part of another resource." ); diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx index 693b157f..527fbb0c 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx @@ -82,7 +82,7 @@ namespace ice void FileSystemResourceProvider::DevUI::build_resources_table(ice::u32 idx_start, ice::u32 idx_end) noexcept { ice::u32 idx = 1; // We start with '1' since the first entry are the headers. - for (ice::FileSystemResource* const res : ice::hashmap::values(_resources)) + for (ice::FileSystemResource* const res : _resources.values()) { if (strstr(res->name().begin(), _filter) == nullptr) { diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx index aaac737a..a5542bc9 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx @@ -140,7 +140,7 @@ namespace ice // For mixed-regular chunks we need double the number of entries because // both data and metadata pointers are allocated separately, which doubles the required hashmap size. ice::u32 const estimated_pointer_count = _chunk.count_entries * (_chunk.type == 3 ? 2 : 1); - ice::hashmap::reserve(_offset_map, estimated_pointer_count); + _offset_map.reserve(estimated_pointer_count); _pointers.resize(estimated_pointer_count); } diff --git a/source/code/systems/resource_system/private/resource_tracker.cxx b/source/code/systems/resource_system/private/resource_tracker.cxx index 062fc43b..a0c08a00 100644 --- a/source/code/systems/resource_system/private/resource_tracker.cxx +++ b/source/code/systems/resource_system/private/resource_tracker.cxx @@ -57,14 +57,14 @@ namespace ice "Invalid value ({}) provided for 'predicted_resource_count'. Value needs to be a positive integer." ); - ice::hashmap::reserve(_resources, _info.predicted_resource_count); - ice::hashmap::reserve(_resource_providers, 12); - ice::hashmap::reserve(_resource_writers, 4); + _resources.reserve(_info.predicted_resource_count); + _resource_providers.reserve(12); + _resource_writers.reserve(4); } ResourceTrackerImplementation::~ResourceTrackerImplementation() noexcept { - ice::hashmap::clear(_resources); + _resources.clear(); } auto ResourceTrackerImplementation::attach_provider( @@ -353,7 +353,7 @@ namespace ice _info.predicted_resource_count ); - ice::hashmap::reserve(_resources, new_count.u32()); + _resources.reserve(new_count.u32()); // Store all resource handles IPT_ZONE_SCOPED_NAMED("create_hash_entries"); diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx index aefd5a58..3155c2f2 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx @@ -338,7 +338,7 @@ namespace ice ice::u64 const hash = ice::hash(resource->origin()); ICE_ASSERT( - ice::hashmap::has(_resources, hash) == false, + _resources.missing(hash), "A resource cannot be a explicit resource AND part of another resource." ); From 792d65b5c6f660cac108e518bce415a704d7b27a Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sun, 18 Jan 2026 15:22:26 +0900 Subject: [PATCH 26/40] Updating SPDX headers in all new and modified source files. --- .../collections/public/ice/container/associative_container.hxx | 3 +++ .../core/collections/public/ice/container/hashmap_details.hxx | 3 +++ source/code/core/collections/public/ice/hashmap.hxx | 3 +++ source/code/core/memsys/private/mem_allocator.cxx | 2 +- source/code/core/memsys/public/ice/mem_allocator.hxx | 2 +- .../framework/framework_base/private/traits/trait_camera.cxx | 2 +- source/code/iceshard/engine/private/world_trait_archive.cxx | 2 +- .../code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx | 2 +- .../code/iceshard/engine/public/ice/ecs/ecs_query_storage.hxx | 2 +- .../private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx | 2 +- source/code/iceshard/iceshard/private/iceshard_world_devui.cxx | 2 +- .../code/iceshard/iceshard/private/iceshard_world_manager.hxx | 2 +- source/code/platforms/platform/public/ice/platform_threads.hxx | 2 +- source/code/platforms/platform_win32/private/win32_threads.hxx | 2 +- 14 files changed, 20 insertions(+), 11 deletions(-) diff --git a/source/code/core/collections/public/ice/container/associative_container.hxx b/source/code/core/collections/public/ice/container/associative_container.hxx index c240ec19..86fe77a2 100644 --- a/source/code/core/collections/public/ice/container/associative_container.hxx +++ b/source/code/core/collections/public/ice/container/associative_container.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include diff --git a/source/code/core/collections/public/ice/container/hashmap_details.hxx b/source/code/core/collections/public/ice/container/hashmap_details.hxx index 3d123b17..d8e95924 100644 --- a/source/code/core/collections/public/ice/container/hashmap_details.hxx +++ b/source/code/core/collections/public/ice/container/hashmap_details.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma #include #include diff --git a/source/code/core/collections/public/ice/hashmap.hxx b/source/code/core/collections/public/ice/hashmap.hxx index 5fe1dc48..0a974ed6 100644 --- a/source/code/core/collections/public/ice/hashmap.hxx +++ b/source/code/core/collections/public/ice/hashmap.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include #include diff --git a/source/code/core/memsys/private/mem_allocator.cxx b/source/code/core/memsys/private/mem_allocator.cxx index 0cc7193a..950fb976 100644 --- a/source/code/core/memsys/private/mem_allocator.cxx +++ b/source/code/core/memsys/private/mem_allocator.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/core/memsys/public/ice/mem_allocator.hxx b/source/code/core/memsys/public/ice/mem_allocator.hxx index 2552d36d..d8f38229 100644 --- a/source/code/core/memsys/public/ice/mem_allocator.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/framework/framework_base/private/traits/trait_camera.cxx b/source/code/framework/framework_base/private/traits/trait_camera.cxx index 92eff1ee..6bed604c 100644 --- a/source/code/framework/framework_base/private/traits/trait_camera.cxx +++ b/source/code/framework/framework_base/private/traits/trait_camera.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "trait_camera.hxx" diff --git a/source/code/iceshard/engine/private/world_trait_archive.cxx b/source/code/iceshard/engine/private/world_trait_archive.cxx index 32e4e139..997eba2b 100644 --- a/source/code/iceshard/engine/private/world_trait_archive.cxx +++ b/source/code/iceshard/engine/private/world_trait_archive.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx index dfb08b88..f2d0877e 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage.hxx index 9475c91e..0f03c5d0 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx index 70694af5..cf87bcc3 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_gfx_shader_storage_trait.hxx" diff --git a/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx index d7bb05bc..0c18f74f 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_world_devui.hxx" diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager.hxx b/source/code/iceshard/iceshard/private/iceshard_world_manager.hxx index 2c4571ca..082ea17d 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/platforms/platform/public/ice/platform_threads.hxx b/source/code/platforms/platform/public/ice/platform_threads.hxx index 9ce15bcc..c54add0d 100644 --- a/source/code/platforms/platform/public/ice/platform_threads.hxx +++ b/source/code/platforms/platform/public/ice/platform_threads.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/platforms/platform_win32/private/win32_threads.hxx b/source/code/platforms/platform_win32/private/win32_threads.hxx index b8e26e08..08a8b95a 100644 --- a/source/code/platforms/platform_win32/private/win32_threads.hxx +++ b/source/code/platforms/platform_win32/private/win32_threads.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once From 8ae38d8a5f7410dc3469be5bfac0efe080b10352 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sun, 18 Jan 2026 23:08:05 +0900 Subject: [PATCH 27/40] Finalized the refactor of all existing dyanmic container types. * Introduced new type MultiHashMap that contains an easier to use API compared to the previous one. (This type is still not preety) (#ICE-207, #ICE-211, #ICE-210) State Done --- .../collections/natvis/collections.natvis | 21 -- .../ice/container/associative_container.hxx | 108 +++++- .../ice/container/container_concepts.hxx | 14 +- .../public/ice/container/hashmap.hxx | 96 ----- .../public/ice/container/hashmap_details.hxx | 3 +- .../ice/container/impl/hashmap_impl.inl | 351 ------------------ .../public/ice/container_types.hxx | 43 --- .../core/collections/public/ice/hashmap.hxx | 56 ++- .../collections/public/ice/heap_string.hxx | 5 + .../collections/public/ice/multi_hashmap.hxx | 169 +++++++++ .../collections/public/ice/static_array.hxx | 11 + .../collections/public/ice/string_types.hxx | 14 - .../core/collections/tests/test_hashmap.cxx | 110 +++--- 13 files changed, 401 insertions(+), 600 deletions(-) delete mode 100644 source/code/core/collections/public/ice/container/hashmap.hxx delete mode 100644 source/code/core/collections/public/ice/container/impl/hashmap_impl.inl delete mode 100644 source/code/core/collections/public/ice/container_types.hxx create mode 100644 source/code/core/collections/public/ice/multi_hashmap.hxx create mode 100644 source/code/core/collections/public/ice/static_array.hxx delete mode 100644 source/code/core/collections/public/ice/string_types.hxx diff --git a/source/code/core/collections/natvis/collections.natvis b/source/code/core/collections/natvis/collections.natvis index 1d9ff586..202436d6 100644 --- a/source/code/core/collections/natvis/collections.natvis +++ b/source/code/core/collections/natvis/collections.natvis @@ -90,25 +90,4 @@ - - Hash {{ count={_count}, capacity={_capacity}, load_factor={(float)_count/(float)_capacity,g} }} - - _count - _capacity - - load_factor {{ {(float)_count/(float)_capacity,g} }} - - - _count - _data - - - - - _count - _data[$i] - - - - diff --git a/source/code/core/collections/public/ice/container/associative_container.hxx b/source/code/core/collections/public/ice/container/associative_container.hxx index 86fe77a2..7b074cd1 100644 --- a/source/code/core/collections/public/ice/container/associative_container.hxx +++ b/source/code/core/collections/public/ice/container/associative_container.hxx @@ -9,28 +9,114 @@ namespace ice::container struct AssociativeContainer : ice::container::BasicContainer { - template - bool has(this Self const& self, ice::container::KeyTypeArg key) noexcept + template + bool has(this Self const& self, KeyType const& key) noexcept { - return self.find(key) != nullptr; + return self.find(ice::hash(key)) != nullptr; } template - bool has(this Self const& self, KeyType&& key) noexcept + bool missing(this Self const& self, KeyType const& key) noexcept { - return self.has(ice::hash(ice::forward(key))); + return self.find(ice::hash(key)) == nullptr; } - template - bool missing(this Self const& self, ice::container::KeyTypeArg key) noexcept + template< + ice::concepts::AssociativeContainer Self, + ice::concepts::HashableKeyType KeyType, + typename InValueType = typename std::remove_reference_t::ValueType + > + auto get( + this Self const& self, + KeyType const& key, + InValueType const& fallback_value + ) noexcept -> ice::container::ValueRef { - return self.find(key) == nullptr; + ice::container::ValuePtr result = self.find(ice::hash(key)); + // TODO: We need to rethink all 'get' methods since + // we will always run into lifetime issue with this approach. + return result != nullptr ? *result : fallback_value; } - template - bool missing(this Self const& self, KeyType&& key) noexcept + template< + ice::concepts::AssociativeContainer Self, + ice::concepts::HashableKeyType KeyType> + auto try_get( + this Self&& self, + KeyType const& key + ) noexcept -> ice::container::ValuePtr + { + return self.find(ice::hash(key)); + } + }; + + + struct AssociativeResizableContainer : ice::container::AssociativeContainer + { + template< + ice::concepts::AssociativeResizableContainer Self, + ice::concepts::HashableKeyType KeyType, + typename InValueType = typename std::remove_reference_t::ValueType + > + requires(std::convertible_to) + auto set( + this Self& self, + KeyType const& key, + InValueType&& in_value + ) noexcept -> ice::container::ValueRef + { + return self.store(ice::hash(key), std::forward(in_value)); + } + + template< + ice::concepts::AssociativeResizableContainer Self, + ice::concepts::HashableKeyType KeyType, + typename InValueType = typename std::remove_reference_t::ValueType + > + requires(std::convertible_to) + void set_if_missing( + this Self& self, + KeyType const& key, + InValueType&& in_value + ) noexcept + { + ice::u64 const key_hash = ice::hash(key); + if (self.missing(key_hash)) + { + self.set(key_hash, std::forward(in_value)); + } + } + + template< + ice::concepts::AssociativeContainer Self, + ice::concepts::HashableKeyType KeyType, + typename InValueType = typename std::remove_reference_t::ValueType + > + auto get_or_set( + this Self&& self, + KeyType const& key, + InValueType&& in_value + ) noexcept -> ice::container::ValueRef + { + ice::u64 const key_hash = ice::hash(key); + if (self.missing(key_hash)) + { + return self.set(key_hash, std::forward(in_value)); + } + else + { + ice::container::ValuePtr result = self.try_get(key_hash); + ICE_ASSERT_CORE(result != nullptr); + return *result; + } + } + + template< + ice::concepts::AssociativeContainer Self, + ice::concepts::HashableKeyType KeyType> + bool remove(this Self&& self, KeyType const& key) noexcept { - return self.missing(ice::hash(ice::forward(key))); + return self.remove(ice::hash(key)); } }; diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index e788ee62..a3cd3b11 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -31,7 +31,7 @@ namespace ice::concepts template concept AssociativeContainer = Container && AssociativeContainerType - && requires(T t, typename std::remove_reference_t::KeyType key) { + && requires(T t, typename std::remove_reference_t::KeyType key, typename std::remove_reference_t::ValueType&& val) { { t.size() } -> std::convertible_to; { t.find(key) } -> std::convertible_to::ValueType const*>; }; @@ -43,6 +43,16 @@ namespace ice::concepts { t.clear() } -> std::convertible_to; }; + template + concept AssociativeResizableContainer = AssociativeContainer && ResizableContainer && requires( + T t, + typename std::remove_reference_t::KeyType key, + typename std::remove_reference_t::ValueType&& val) + { + { t.store(key, val) } -> std::convertible_to::ValueType&>; + { t.remove(key) } -> std::convertible_to; + }; + struct ContiguousContainerTag{ }; template @@ -70,7 +80,7 @@ namespace ice::concepts && not TrivialContainerLogicAllowed::ValueType>; template - concept HashableKeyType = not std::is_arithmetic_v> && requires(T t) { + concept HashableKeyType = requires(T t) { { ice::hash(t) } -> std::convertible_to; }; diff --git a/source/code/core/collections/public/ice/container/hashmap.hxx b/source/code/core/collections/public/ice/container/hashmap.hxx deleted file mode 100644 index 2cffbb25..00000000 --- a/source/code/core/collections/public/ice/container/hashmap.hxx +++ /dev/null @@ -1,96 +0,0 @@ -/// Copyright 2022 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include -#include - -namespace ice -{ - - namespace hashmap - { - - template - requires std::copy_constructible && std::convertible_to - inline void set(ice::HashMap& map, ice::u64 key, Value const& value) noexcept; - - template - requires std::move_constructible && std::convertible_to - inline void set(ice::HashMap& map, ice::u64 key, Value&& value) noexcept; - - template - requires std::copy_constructible - inline auto get_or_set(ice::HashMap& map, ice::u64 key, Type const& value_if_missing) noexcept -> Type&; - - template - requires std::move_constructible && std::convertible_to - inline auto get_or_set(ice::HashMap& map, ice::u64 key, Value&& value_if_missing) noexcept -> Type&; - - template - inline auto try_get(ice::HashMap& map, ice::u64 key) noexcept -> Type*; - - template - inline void remove(ice::HashMap& map, ice::u64 key) noexcept; - - template - inline auto get( - HashMapType const& map, - ice::u64 key, - typename HashMapType::ValueType const& fallback_value - ) noexcept -> typename HashMapType::ValueType const&; - - template - inline auto get( - HashMapType const& map, - ice::u64 key, - std::nullptr_t - ) noexcept -> typename HashMapType::ValueType; - - template - inline auto try_get(HashMapType const& map, ice::u64 key) noexcept -> typename HashMapType::ValueType const*; - - - template - inline auto memory(ice::HashMap& map) noexcept -> ice::Memory; - - } // namespace hashmap - - namespace multi_hashmap - { - - template - requires std::move_constructible && std::convertible_to - inline void insert(ice::HashMap& map, ice::u64 key, Type&& value) noexcept; - - template - inline void insert(ice::HashMap& map, ice::u64 key, Type const& value) noexcept; - - template - inline void remove(ice::HashMap& map, typename ice::HashMap::ConstIterator entry) noexcept; - - template - inline void remove_all(ice::HashMap& map, ice::u64 key) noexcept; - - - template - inline auto count(ice::HashMap const& map, ice::u64 key) noexcept -> ice::u32; - - template - inline void get(ice::HashMap const& map, ice::u64 key, ice::Array& items) noexcept; - - template - inline auto find_first(ice::HashMap const& map, ice::u64 key) noexcept -> typename ice::HashMap::ConstIterator; - - template - inline auto find_next( - ice::HashMap const& map, - typename ice::HashMap::ConstIterator entry - ) noexcept -> typename ice::HashMap::ConstIterator; - - } // namespace multi_hashmap - -} // namespace ice - -#include "impl/hashmap_impl.inl" diff --git a/source/code/core/collections/public/ice/container/hashmap_details.hxx b/source/code/core/collections/public/ice/container/hashmap_details.hxx index d8e95924..70794b4d 100644 --- a/source/code/core/collections/public/ice/container/hashmap_details.hxx +++ b/source/code/core/collections/public/ice/container/hashmap_details.hxx @@ -258,13 +258,14 @@ namespace ice } template - inline void find_and_erase(ContainerT& map, ice::u64 key) noexcept + inline bool find_and_erase(ContainerT& map, ice::u64 key) noexcept { FindResult const fr = ice::detail::hashmap::find(map, key); if (fr.entry_i != Constant_EndOfList) { ice::detail::hashmap::erase(map, fr); } + return fr.entry_i != Constant_EndOfList; } template diff --git a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl deleted file mode 100644 index 9f12fdc9..00000000 --- a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl +++ /dev/null @@ -1,351 +0,0 @@ -/// Copyright 2022 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -namespace ice -{ - - namespace hashmap::detail - { - - struct FindResult; - - constexpr auto calc_storage_capacity(ice::u32 max_count) noexcept -> ice::u32; - - template - inline bool can_store_count(ice::HashMap const& map, ice::u32 expected_count) noexcept; - - template - inline auto find(HashMapType const& map, ice::u64 key) noexcept -> FindResult; - - template - inline auto make(ice::HashMap& map, ice::u64 key) noexcept -> ice::u32; - - template - inline void erase(ice::HashMap& map, FindResult const fr) noexcept; - - template - inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::u32; - - template - inline auto find_or_make(ice::HashMap& map, ice::u64 key, bool& found) noexcept -> ice::u32; - - template - inline void find_and_erase(ice::HashMap& map, ice::u64 key) noexcept; - - template - inline auto find(ice::HashMap& map, typename ice::HashMap::ConstIterator it) noexcept -> FindResult; - - template - inline void grow(ice::HashMap& map) noexcept; - - template - inline void clear_and_dealloc(ice::HashMap& map) noexcept; - - } // namespace hashmap::detail - - - namespace hashmap - { - - template - requires std::copy_constructible && std::convertible_to - inline void set(ice::HashMap& map, ice::u64 key, Value const& value) noexcept - { - if (map.is_full()) - { - map.grow(); - } - - bool found = false; - ice::u32 const index = ice::detail::hashmap::find_or_make(map, key, found); - if constexpr (Logic == ContainerLogic::Complex) - { - // If the index was found we need to destroy the previous value. - if (found) - { - ice::mem_destruct_at(map._data + index); - } - - ice::mem_copy_construct_at( - Memory{ - .location = map._data + index, - .size = ice::size_of, - .alignment = ice::align_of - }, - value - ); - } - else - { - map._data[index] = value; - } - } - - template - requires std::move_constructible && std::convertible_to - inline void set(ice::HashMap& map, ice::u64 key, Value&& value) noexcept - { - if (map.is_full()) - { - map.grow(); - } - - bool found = false; - ice::u32 const index = ice::detail::hashmap::find_or_make(map, key, found); - if constexpr (Logic == ContainerLogic::Complex) - { - // If the index was found we need to destroy the previous value. - if (found) - { - ice::mem_destruct_at(map._data + index); - } - - ice::mem_move_construct_at( - Memory{ - .location = map._data + index, - .size = ice::size_of, - .alignment = ice::align_of - }, - ice::forward(value) - ); - } - else - { - map._data[index] = value; - } - } - - template - requires std::move_constructible && std::convertible_to - inline auto get_or_set(ice::HashMap& map, ice::u64 key, Value&& value) noexcept -> Type& - { - if (map.missing(key)) - { - ice::hashmap::set(map, key, ice::forward(value)); - } - - ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); - ICE_ASSERT_CORE(index != ice::detail::hashmap::Constant_EndOfList); - return *(map._data + index); - } - - template - inline auto try_get(ice::HashMap& map, ice::u64 key) noexcept -> Type* - { - ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); - return index == ice::detail::hashmap::Constant_EndOfList - ? nullptr - : map._data + index; - } - - template - inline void remove(ice::HashMap& map, ice::u64 key) noexcept - { - ice::detail::hashmap::find_and_erase(map, key); - } - - template - inline auto get(HashMapType const& map, ice::u64 key, typename HashMapType::ValueType const& fallback_value) noexcept -> typename HashMapType::ValueType const& - { - ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); - return index == ice::detail::hashmap::Constant_EndOfList - ? fallback_value - : map._data[index]; - } - - template - inline auto get(HashMapType const& map, ice::u64 key, std::nullptr_t) noexcept -> typename HashMapType::ValueType - { - ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); - return index == ice::detail::hashmap::Constant_EndOfList - ? nullptr - : map._data[index]; - } - - template - inline auto try_get(HashMapType const& map, ice::u64 key) noexcept -> typename HashMapType::ValueType const* - { - ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); - return index == ice::detail::hashmap::Constant_EndOfList - ? nullptr - : map._data + index; - } - - - - template - inline auto memory(ice::HashMap& map) noexcept -> ice::Memory - { - ice::u32 const capacity_values = ice::u32(map._capacity * ice::detail::hashmap::Constant_HashMapMaxFill); - - // TODO: Easier way to calculate the allocated size. - ice::meminfo alloc_info = ice::meminfo_of * map._capacity; - alloc_info += ice::meminfo_of::Entry> * capacity_values; - alloc_info += ice::meminfo_of * capacity_values; - - return Memory{ - .location = map._hashes, - .size = alloc_info.size, - .alignment = alloc_info.alignment - }; - } - - } // namespace hashmap - - namespace multi_hashmap - { - - template - requires std::move_constructible && std::convertible_to - inline void insert(ice::HashMap& map, ice::u64 key, Type&& value) noexcept - { - if (map.is_full()) - { - map.grow(); - } - - ice::u32 const index = ice::detail::hashmap::make(map, key); - if constexpr (Logic == ContainerLogic::Complex) - { - // If the index is below the current map._count we need to destroy the previous value. - if ((index + 1) < map._count) - { - ice::mem_destruct_at(map._data + index); - } - - ice::mem_move_construct_at( - Memory{ - .location = map._data + index, - .size = ice::size_of, - .alignment = ice::align_of - }, - ice::forward(value) - ); - } - else - { - map._data[index] = value; - } - } - - template - inline void insert(ice::HashMap& map, ice::u64 key, Type const& value) noexcept - { - if (map.is_full()) - { - map.grow(); - } - - ice::u32 const index = ice::detail::hashmap::make(map, key); - if constexpr (Logic == ContainerLogic::Complex) - { - // If the index is below the current map._count we need to destroy the previous value. - if ((index + 1) < map._count) - { - ice::mem_destruct_at(map._data + index); - } - - ice::mem_copy_construct_at( - Memory{ - .location = map._data + index, - .size = ice::size_of, - .alignment = ice::align_of - }, - value - ); - } - else - { - map._data[index] = value; - } - } - - template - inline void remove(ice::HashMap& map, typename ice::HashMap::ConstIterator it) noexcept - { - ice::detail::hashmap::FindResult const fr = ice::detail::hashmap::find(map, it); - if (fr.entry_i != ice::detail::hashmap::Constant_EndOfList) - { - ice::detail::hashmap::erase(map, fr); - } - } - - template - inline void remove_all(ice::HashMap& map, ice::u64 key) noexcept - { - while (map.has(key)) - { - ice::hashmap::remove(map, key); - } - } - - template - inline auto count(ice::HashMap const& map, ice::u64 key) noexcept -> ice::u32 - { - using ConstIterator = typename ice::HashMap::ConstIterator; - - ice::u32 result = 0; - ConstIterator it = ice::multi_hashmap::find_first(map, key); - while (it._entry != nullptr) - { - result += 1; - it = ice::multi_hashmap::find_next(map, it); - } - return result; - } - - template - inline void get(ice::HashMap const& map, ice::u64 key, ice::Array& items) noexcept - { - using ConstIterator = typename ice::HashMap::ConstIterator; - ConstIterator it = ice::multi_hashmap::find_first(map, key); - - while (it._entry != nullptr) - { - items.push_back(*it._value); - it = ice::multi_hashmap::find_next(map, it); - } - } - - template - inline auto find_first(ice::HashMap const& map, ice::u64 key) noexcept -> typename ice::HashMap::ConstIterator - { - using ConstIterator = typename ice::HashMap::ConstIterator; - - ice::u32 const index = ice::detail::hashmap::find_or_fail(map, key); - if (index == ice::detail::hashmap::Constant_EndOfList) - { - return ConstIterator{ nullptr, nullptr }; - } - else - { - return ConstIterator{ map._entries + index, map._data + index }; - } - } - - template - inline auto find_next( - ice::HashMap const& map, - typename ice::HashMap::ConstIterator it - ) noexcept -> typename ice::HashMap::ConstIterator - { - ICE_ASSERT_CORE(it._entry != nullptr && it._value != nullptr); - - using ConstIterator = typename ice::HashMap::ConstIterator; - - ice::u32 index = it._entry->next; - while (index != ice::detail::hashmap::Constant_EndOfList) - { - if (map._entries[index].key == it._entry->key) - { - return ConstIterator{ map._entries + index, map._data + index }; - } - index = map._entries[index].next; - } - - return ConstIterator{ nullptr, nullptr }; - } - - } // namespace multi_hash - -} // namespace ice diff --git a/source/code/core/collections/public/ice/container_types.hxx b/source/code/core/collections/public/ice/container_types.hxx deleted file mode 100644 index d743689b..00000000 --- a/source/code/core/collections/public/ice/container_types.hxx +++ /dev/null @@ -1,43 +0,0 @@ -/// Copyright 2022 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace ice -{ - - - //! \brief A view into data created by a hashmap object. - //! - //! \note No modification of data is allowed through this type. - //! \note Because this is only a view into a hashmap there is no difference in 'logic' so it's unused. - template - struct HashMapView - { - using Entry = typename ice::HashMap::Entry; - using ValueType = Type; - - ice::u32 _capacity; - ice::u32 _count; - - ice::u32 const* _hashes; - Entry const* _entries; - Type const* _data; - }; - - - // TODO: Introduce our own type and create proper concepts for function access. - template - using StaticArray = std::array; - -} // namespace ice diff --git a/source/code/core/collections/public/ice/hashmap.hxx b/source/code/core/collections/public/ice/hashmap.hxx index 0a974ed6..e0cfee4c 100644 --- a/source/code/core/collections/public/ice/hashmap.hxx +++ b/source/code/core/collections/public/ice/hashmap.hxx @@ -21,7 +21,7 @@ namespace ice //! This value can be forced by the user for specific behavior requirements. template> struct HashMap - : public ice::container::AssociativeContainer + : public ice::container::AssociativeResizableContainer , public ice::container::ResizableContainer { static constexpr ContainerLogic OperationLogic = Logic; @@ -37,7 +37,6 @@ namespace ice using ConstContainerValueType = Type const; using Iterator = ConstIterator; using SizeType = ice::ncount; - using ContainerTag = ice::concepts::ContiguousContainerTag; struct EntryType { @@ -64,10 +63,20 @@ namespace ice inline auto operator=(HashMap const& other) noexcept -> HashMap& requires std::copy_constructible; - // API Requirements Of: AssociativeContainer + // API Requirements Of: Associative(Resizable)Container constexpr auto size() const noexcept -> SizeType { return { _count, sizeof(ValueType) }; } template constexpr auto find(this Self&& self, KeyType key) noexcept -> ice::container::ValuePtr; + template + constexpr bool remove(this Self& self, KeyType key) noexcept; + + template + constexpr auto store( + this Self& self, KeyType key, InValueType&& in_value + ) noexcept -> ice::container::ValueRef; + + // Take some of the extended methods from the container mixin. + using AssociativeResizableContainer::remove; // Additional functionality template @@ -272,6 +281,47 @@ namespace ice return this; } + template + template + inline constexpr auto ice::HashMap::store( + this Self& self, KeyType key, InValueType&& in_value + ) noexcept -> ice::container::ValueRef + { + if (self.is_full()) + { + self.grow(); + } + + bool found = false; + ice::u32 const index = ice::detail::hashmap::find_or_make(self, key, found); + if constexpr (OperationLogic == ContainerLogic::Complex) + { + // If the index was found we need to destroy the previous value. + if (found) + { + ice::mem_destruct_at(self._data + index); + } + + ice::mem_construct_at( + Memory{ self._data + index, ice::size_of, ice::align_of }, + std::forward(in_value) + ); + } + else + { + self._data[index] = in_value; + } + + return self._data[index]; + } + + template + template + inline constexpr bool ice::HashMap::remove(this Self& self, KeyType key) noexcept + { + return ice::detail::hashmap::find_and_erase(self, key); + } + template template inline constexpr auto ice::HashMap::find( diff --git a/source/code/core/collections/public/ice/heap_string.hxx b/source/code/core/collections/public/ice/heap_string.hxx index fcbb37bd..0e7015ca 100644 --- a/source/code/core/collections/public/ice/heap_string.hxx +++ b/source/code/core/collections/public/ice/heap_string.hxx @@ -247,4 +247,9 @@ namespace ice }; } + constexpr auto hash(ice::HeapString<> const& value) noexcept -> ice::u64 + { + return ice::hash(ice::String{ value }); + } + } // namespace ice diff --git a/source/code/core/collections/public/ice/multi_hashmap.hxx b/source/code/core/collections/public/ice/multi_hashmap.hxx new file mode 100644 index 00000000..dce02f3f --- /dev/null +++ b/source/code/core/collections/public/ice/multi_hashmap.hxx @@ -0,0 +1,169 @@ +#pragma once +#include + +namespace ice +{ + + template> + struct MultiHashMap : public ice::HashMap + { + using HashMap::HashMap; + + using EntryType = typename HashMap::EntryType; + using KeyType = typename HashMap::KeyType; + using ValueType = typename HashMap::ValueType; + using ConstContainerValueType = typename HashMap::ConstContainerValueType; + using SizeType = typename HashMap::SizeType; + using Iterator = typename HashMap::Iterator; + using ConstIterator = typename HashMap::ConstIterator; + + struct ConstMultiIterator; + + // API Specific to this extended type of a HashMap + template + constexpr auto count_values(HashableKeyT const& key) noexcept -> SizeType; + + template + constexpr auto find_values( + this Self const& self, HashableKeyT const& key + ) noexcept -> ConstMultiIterator; + + template< + typename Self, + ice::concepts::HashableKeyType HashableKeyT, + typename InValueType = typename std::remove_reference_t::ValueType + > + requires(std::convertible_to>) + constexpr auto insert( + this Self&& self, HashableKeyT const& key, InValueType&& in_value + ) noexcept -> ice::container::ValueRef; + + template + constexpr void remove_all(HashableKeyT const& key) noexcept; + }; + + template + struct MultiHashMap::ConstMultiIterator + { + ice::u32 _current; + EntryType const* _entries; + ValueType const* _values; + + constexpr ConstMultiIterator(std::nullptr_t) noexcept + : _current{ ice::detail::hashmap::Constant_EndOfList } + , _entries{ nullptr } + , _values{ nullptr } + { } + + constexpr ConstMultiIterator( + ice::u32 current_entry, + EntryType const* entries, + ValueType const* values + ) noexcept + : _current{ current_entry } + , _entries{ entries } + , _values{ values } + { } + + constexpr bool has_next() const noexcept { return _current != ice::detail::hashmap::Constant_EndOfList; } + constexpr void next() noexcept + { + ICE_ASSERT_CORE(has_next()); + + _current = _entries[_current].next; + if (_current == ice::detail::hashmap::Constant_EndOfList) + { + _entries = nullptr; + _values = nullptr; + } + } + + constexpr auto key() const noexcept -> ice::u64 const& { return _entries[_current].key; } + constexpr auto value() const noexcept -> Type const& { return _values[_current]; } + + constexpr auto operator==(ConstMultiIterator const& other) const noexcept + { + return _entries == other._entries && _current == other._current; + } + + constexpr void operator++() noexcept { next(); } + constexpr auto operator*() const noexcept -> Type const& { return value(); } + }; + + template + template + inline constexpr auto MultiHashMap::count_values( + HashableKeyT const& key + ) noexcept -> SizeType + { + ice::u64 result = 0; + + auto it = find_values(key); + while (it.has_next()) + { + result += 1; + it.next(); + } + return { result, sizeof(ValueType) }; + } + + template + template + inline constexpr auto MultiHashMap::find_values( + this Self const& self, HashableKeyT const& key + ) noexcept -> ConstMultiIterator + { + ice::u32 const index = ice::detail::hashmap::find_or_fail(self, ice::hash(key)); + if (index != ice::detail::hashmap::Constant_EndOfList) + { + return { index, self._entries, self._data }; + } + return { nullptr }; + } + + template + template + requires(std::convertible_to>) + constexpr auto MultiHashMap::insert( + this Self&& self, HashableKeyT const& key, InValueType&& in_value + ) noexcept -> ice::container::ValueRef + { + if (self.is_full()) + { + self.grow(); + } + + ice::u32 const index = ice::detail::hashmap::make(self, ice::hash(key)); + if constexpr (Logic == ContainerLogic::Complex) + { + // If the index is below the current map._count we need to destroy the previous value. + if ((index + 1) < self._count) + { + ice::mem_destruct_at(self._data + index); + } + + ice::mem_construct_at( + self._data + index, + ice::forward(in_value) + ); + } + else + { + self._data[index] = in_value; + } + + return self._data[index]; + } + + template + template + inline constexpr void MultiHashMap::remove_all(HashableKeyT const& key) noexcept + { + ice::u64 const key_hash = ice::hash(key); + while (this->find(key_hash) != nullptr) + { + this->remove(key_hash); + } + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/static_array.hxx b/source/code/core/collections/public/ice/static_array.hxx new file mode 100644 index 00000000..c6b2a93b --- /dev/null +++ b/source/code/core/collections/public/ice/static_array.hxx @@ -0,0 +1,11 @@ +#pragma once +#include + +namespace ice +{ + + // TODO: Introduce our own type and create proper concepts for function access. + template + using StaticArray = std::array; + +} // namespace ice diff --git a/source/code/core/collections/public/ice/string_types.hxx b/source/code/core/collections/public/ice/string_types.hxx deleted file mode 100644 index f92fb75a..00000000 --- a/source/code/core/collections/public/ice/string_types.hxx +++ /dev/null @@ -1,14 +0,0 @@ -/// Copyright 2022 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include -#include -#include -#include - -#include -#include -#include -#include diff --git a/source/code/core/collections/tests/test_hashmap.cxx b/source/code/core/collections/tests/test_hashmap.cxx index 64122ccf..24949af9 100644 --- a/source/code/core/collections/tests/test_hashmap.cxx +++ b/source/code/core/collections/tests/test_hashmap.cxx @@ -3,24 +3,21 @@ #include #include -#include +#include #include "util_tracking_object.hxx" SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex]") { using ice::operator""_count; - namespace hash = ice::hashmap; - namespace multi_hash = ice::multi_hashmap; - ice::HostAllocator alloc{ }; ice::HashMap test_hash{ alloc }; GIVEN("an hashmap with a single element") { - ice::hashmap::set(test_hash, 0, Test_TrackingObject{ 42 }); + test_hash.set(0, Test_TrackingObject{ 42 }); - Test_TrackingObject* obj = ice::hashmap::try_get(test_hash, 0); + Test_TrackingObject* obj = test_hash.try_get(0); REQUIRE(obj != nullptr); { @@ -38,9 +35,9 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] ice::u32 dtor_count = 0; obj->data.test_dtor = &dtor_count; - ice::hashmap::set(test_hash, 0, Test_TrackingObject{ 69 }); + test_hash.set(0, Test_TrackingObject{ 69 }); - obj = ice::hashmap::try_get(test_hash, 0); + obj = test_hash.try_get(0); REQUIRE(obj != nullptr); Test_ObjectEvents test_events{ }; @@ -61,7 +58,7 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] for (ice::u32 value : values) { - ice::hashmap::set(test_hash, value, Test_TrackingObject{ value }); + test_hash.set(value, Test_TrackingObject{ value }); } THEN("the returned 'size' properly stores the number and byte size of elements.") @@ -94,7 +91,7 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] for (ice::u32 value : values) { - ice::hashmap::set(test_hash, value, Test_TrackingObject{ value }); + test_hash.set(value, Test_TrackingObject{ value }); } test_events = Test_ObjectEvents{}; @@ -115,11 +112,8 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] SCENARIO("collections 'ice/container/hashmap.hxx' (POD)", "[collection][hash][pod]") { - namespace hash = ice::hashmap; - namespace multi_hash = ice::multi_hashmap; - ice::HostAllocator alloc{ }; - ice::HashMap test_hash{ alloc }; + ice::MultiHashMap test_hash{ alloc }; test_hash.set_capacity(2); @@ -127,42 +121,42 @@ SCENARIO("collections 'ice/container/hashmap.hxx' (POD)", "[collection][hash][po { WHEN("setting a single value") { - hash::set(test_hash, 0, 0xd00b); + test_hash.set(0, 0xd00b); CHECK(test_hash.has(0) == true); - CHECK(hash::get(test_hash, 0, 0xffff) == 0xd00b); - CHECK(hash::get(test_hash, 1, 0xffff) == 0xffff); + CHECK(test_hash.get(0, 0xffff) == 0xd00b); + CHECK(test_hash.get(1, 0xffff) == 0xffff); } WHEN("setting multiple values") { - hash::set(test_hash, 0, 0xd00b + 0); - hash::set(test_hash, 2, 0xd00b + 1); - hash::set(test_hash, 4, 0xd00b + 2); - hash::set(test_hash, 6, 0xd00b + 3); + test_hash.set(0, 0xd00b + 0); + test_hash.set(2, 0xd00b + 1); + test_hash.set(4, 0xd00b + 2); + test_hash.set(6, 0xd00b + 3); CHECK(test_hash.has(0) == true); CHECK(test_hash.has(2) == true); CHECK(test_hash.has(4) == true); CHECK(test_hash.has(6) == true); - hash::remove(test_hash, 0); - hash::remove(test_hash, 4); + test_hash.remove(0); + test_hash.remove(4); CHECK(test_hash.has(0) == false); CHECK(test_hash.has(2) == true); CHECK(test_hash.has(4) == false); CHECK(test_hash.has(6) == true); - hash::set(test_hash, 0, 0xd00b + 4); - hash::set(test_hash, 0, 0xd00b + 5); // Replaces the old value + test_hash.set(0, 0xd00b + 4); + test_hash.set(0, 0xd00b + 5); // Replaces the old value CHECK(test_hash.has(0) == true); CHECK(test_hash.has(2) == true); CHECK(test_hash.has(4) == false); CHECK(test_hash.has(6) == true); - CHECK(hash::get(test_hash, 0, 0xffff) == 0xd00b + 5); - hash::set(test_hash, 0, 0xd00b + 0); + CHECK(test_hash.get(0, 0xffff) == 0xd00b + 5); + test_hash.set(0, 0xd00b + 0); THEN("We got values to iterate over") { @@ -191,44 +185,44 @@ SCENARIO("collections 'ice/container/hashmap.hxx' (POD)", "[collection][hash][po { WHEN("Setting a single value") { - multi_hash::insert(test_hash, 0, 0xd00b); - CHECK(multi_hash::count(test_hash, 0) == 1); - CHECK(multi_hash::find_first(test_hash, 0).value() == 0xd00b); - CHECK(multi_hash::find_first(test_hash, 1) == nullptr); + test_hash.insert(0, 0xd00b); + CHECK(test_hash.count_values(0) == 1); + CHECK(test_hash.find_values(0).value() == 0xd00b); + CHECK(test_hash.find_values(1).has_next() == false); } WHEN("Setting multiple values") { - multi_hash::insert(test_hash, 0, 0xd00b + 0); - multi_hash::insert(test_hash, 2, 0xd00b + 1); - multi_hash::insert(test_hash, 4, 0xd00b + 2); - multi_hash::insert(test_hash, 6, 0xd00b + 3); + test_hash.insert(0, 0xd00b + 0); + test_hash.insert(2, 0xd00b + 1); + test_hash.insert(4, 0xd00b + 2); + test_hash.insert(6, 0xd00b + 3); - CHECK(multi_hash::count(test_hash, 0) == 1); - CHECK(multi_hash::count(test_hash, 2) == 1); - CHECK(multi_hash::count(test_hash, 4) == 1); - CHECK(multi_hash::count(test_hash, 6) == 1); + CHECK(test_hash.count_values(0) == 1); + CHECK(test_hash.count_values(2) == 1); + CHECK(test_hash.count_values(4) == 1); + CHECK(test_hash.count_values(6) == 1); - multi_hash::remove_all(test_hash, 0); - multi_hash::remove_all(test_hash, 4); + test_hash.remove_all(0); + test_hash.remove_all(4); - CHECK(multi_hash::count(test_hash, 0) == 0); - CHECK(multi_hash::count(test_hash, 2) == 1); - CHECK(multi_hash::count(test_hash, 4) == 0); - CHECK(multi_hash::count(test_hash, 6) == 1); + CHECK(test_hash.count_values(0) == 0); + CHECK(test_hash.count_values(2) == 1); + CHECK(test_hash.count_values(4) == 0); + CHECK(test_hash.count_values(6) == 1); - multi_hash::insert(test_hash, 0, 0xd00b + 4); - multi_hash::insert(test_hash, 0, 0xd00b + 5); // Is added as the new head + test_hash.insert(0, 0xd00b + 4); + test_hash.insert(0, 0xd00b + 5); // Is added as the new head - CHECK(multi_hash::count(test_hash, 0) == 2); - CHECK(multi_hash::count(test_hash, 2) == 1); - CHECK(multi_hash::count(test_hash, 4) == 0); - CHECK(multi_hash::count(test_hash, 6) == 1); + CHECK(test_hash.count_values(0) == 2); + CHECK(test_hash.count_values(2) == 1); + CHECK(test_hash.count_values(4) == 0); + CHECK(test_hash.count_values(6) == 1); - CHECK(multi_hash::find_first(test_hash, 0).value() == 0xd00b + 5); - multi_hash::insert(test_hash, 0, 0xd00b + 0); + CHECK(test_hash.find_values(0).value() == 0xd00b + 5); + test_hash.insert(0, 0xd00b + 0); - CHECK(multi_hash::count(test_hash, 0) == 3); + CHECK(test_hash.count_values(0) == 3); THEN("We got values to iterate over") { @@ -248,10 +242,10 @@ SCENARIO("collections 'ice/container/hashmap.hxx' (POD)", "[collection][hash][po { test_hash.clear(); - CHECK(multi_hash::count(test_hash, 0) == 0); - CHECK(multi_hash::count(test_hash, 2) == 0); - CHECK(multi_hash::count(test_hash, 4) == 0); - CHECK(multi_hash::count(test_hash, 6) == 0); + CHECK(test_hash.count_values(0) == 0); + CHECK(test_hash.count_values(2) == 0); + CHECK(test_hash.count_values(4) == 0); + CHECK(test_hash.count_values(6) == 0); } } } From 9cd9576e7a6347072aa0ad1dd8cd71e305ce9bb8 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sun, 18 Jan 2026 23:08:46 +0900 Subject: [PATCH 28/40] Fixes to source code after the API changes. --- source/code/core/core/public/ice/hash.hxx | 4 +- source/code/core/core/public/ice/utility.hxx | 9 ++++ .../core/modules/private/module_register.cxx | 16 +++--- .../modules/public/ice/module_register.hxx | 3 +- .../core/tasks/private/task_native_thread.cxx | 2 +- .../tasks/private/task_thread_pool_impl.cxx | 32 ++++-------- .../tasks/private/task_thread_pool_impl.hxx | 2 +- .../core/tasks/public/ice/task_thread.hxx | 2 +- .../tasks/public/ice/task_thread_pool.hxx | 2 +- .../utils/private/config/config_builder.cxx | 20 ++++---- .../code/core/utils/private/log_internal.cxx | 13 ++--- .../code/core/utils/private/log_internal.hxx | 4 +- source/code/core/utils/public/ice/config.hxx | 4 +- .../core/utils/public/ice/data_storage.hxx | 4 +- .../core/utils/public/ice/log_formatters.hxx | 2 +- source/code/core/utils/public/ice/params.hxx | 5 +- .../code/core/utils/public/ice/path_utils.hxx | 2 +- .../core/utils/public/ice/shard_payloads.hxx | 4 +- .../core/utils/public/ice/string_utils.hxx | 1 + .../render/trait_render_texture_loader.hxx | 4 +- .../private/traits/trait_camera.cxx | 4 +- .../private/traits/trait_sprite_animator.hxx | 4 +- .../private/traits/ui/game_ui_trait.hxx | 4 +- .../private/traits/ui/render_ui_trait.hxx | 4 +- .../public/ice/framework_app.hxx | 4 +- .../public/ice/game_sprites.hxx | 4 +- .../engine/private/action/action_trigger.cxx | 8 +-- .../private/ecs/ecs_archetype_index.cxx | 12 ++--- .../engine/private/ecs/ecs_entity_storage.cxx | 20 ++++---- .../engine/private/ecs/ecs_entity_tracker.cxx | 4 +- .../private/engine_state_tracker_default.cxx | 49 ++++++++----------- .../private/engine_state_tracker_default.hxx | 4 +- .../engine/private/gfx/ice_gfx_graph.cxx | 8 +-- .../engine/private/gfx/ice_gfx_graph.hxx | 4 +- .../private/gfx/ice_gfx_graph_runtime.hxx | 6 +-- .../private/gfx/ice_gfx_object_storage.hxx | 4 +- .../private/gfx/ice_gfx_stage_registry.cxx | 8 +-- .../engine/private/world_trait_archive.cxx | 6 +-- .../public/ice/ecs/ecs_archetype_detail.hxx | 3 +- .../public/ice/ecs/ecs_archetype_index.hxx | 4 +- .../public/ice/ecs/ecs_entity_storage.hxx | 3 +- .../public/ice/ecs/ecs_entity_tracker.hxx | 4 +- .../public/ice/ecs/ecs_query_builder.hxx | 6 +-- .../public/ice/ecs/ecs_query_details.hxx | 2 +- .../private/gfx/iceshard_gfx_device.cxx | 8 ++- .../private/gfx/iceshard_gfx_queue_group.cxx | 16 ++---- .../private/gfx/iceshard_gfx_queue_group.hxx | 4 +- .../iceshard_gfx_image_storage_trait.cxx | 7 ++- .../iceshard_gfx_image_storage_trait.hxx | 2 +- .../iceshard_gfx_shader_storage_trait.cxx | 6 +-- .../iceshard_gfx_shader_storage_trait.hxx | 4 +- .../private/iceshard_data_storage.hxx | 8 +-- .../iceshard/private/iceshard_gfx_runner.cxx | 4 +- .../iceshard/private/iceshard_runner.hxx | 2 +- .../private/iceshard_task_executor.hxx | 2 +- .../private/iceshard_trait_context.cxx | 13 +++-- .../private/iceshard_world_context.cxx | 6 +-- .../private/iceshard_world_context.hxx | 4 +- .../iceshard/private/iceshard_world_devui.cxx | 2 +- .../private/iceshard_world_manager.cxx | 18 ++++--- .../private/iceshard_world_tasks_launcher.cxx | 18 +++---- .../private/pipeline_ui/ip_ui_oven_types.hxx | 4 +- .../imgui_module/private/imgui_system.cxx | 1 + .../private/shader_tools_asl_importer.cxx | 10 ++-- .../private/shader_tools_asl_importer.hxx | 5 +- .../private/shader_tools_asl_script.cxx | 18 +++---- .../private/shader_tools_asl_script.hxx | 12 ++--- .../private/shader_tools_asl_utils.hxx | 2 +- .../private/shader_tools_glsl.cxx | 8 +-- .../private/shader_tools_wgsl.cxx | 4 +- .../vulkan_renderer/private/vk_allocator.hxx | 4 +- .../webgpu_renderer/private/webgpu_queue.hxx | 4 +- .../win32_sdl2_platform_render_surface.cxx | 1 + .../asset_system/private/asset_shelve.cxx | 24 ++++----- .../asset_system/private/asset_shelve.hxx | 3 +- .../private/asset_shelve_devui.cxx | 2 +- .../asset_system/private/asset_storage.cxx | 7 +-- .../asset_system/private/asset_storage.hxx | 2 +- .../private/asset_type_archive.cxx | 9 ++-- .../private/input_action_layer.cxx | 8 +-- .../private/input_action_layer_builder.cxx | 30 ++++++------ .../private/input_action_script.hxx | 4 +- .../private/input_action_stack.cxx | 24 +++++---- .../public/ice/input_action_layer.hxx | 2 +- .../input_system/private/input_tracker.cxx | 33 +++++-------- .../private/resource_filesystem_baked.hxx | 1 - .../private/resource_filesystem_loose.cxx | 2 +- .../private/resource_filesystem_loose.hxx | 1 - .../private/resource_filesystem_traverser.hxx | 4 +- .../private/resource_filesystem_writable.cxx | 2 +- .../private/resource_filesystem_writable.hxx | 1 - .../private/resource_provider_custom.cxx | 10 ++-- .../private/resource_provider_custom.hxx | 2 +- .../private/resource_provider_dynlib.cxx | 7 ++- .../private/resource_provider_filelist.cxx | 17 ++----- .../private/resource_provider_filelist.hxx | 2 +- .../private/resource_provider_filesystem.cxx | 26 ++-------- .../private/resource_provider_filesystem.hxx | 2 +- .../private/resource_provider_hailstorm.cxx | 17 ++++--- .../private/resource_provider_hailstorm.hxx | 4 +- .../private/resource_tracker.cxx | 39 +++++---------- .../private/resource_tracker.hxx | 8 +-- .../private/resource_writer_filesystem.cxx | 26 ++-------- .../private/resource_writer_filesystem.hxx | 2 +- .../resource_system/public/ice/resource.hxx | 2 +- .../public/ice/resource_provider.hxx | 4 +- .../public/ice/resource_tracker.hxx | 2 +- .../tests/test_resource_meta.cxx | 2 +- 108 files changed, 370 insertions(+), 472 deletions(-) diff --git a/source/code/core/core/public/ice/hash.hxx b/source/code/core/core/public/ice/hash.hxx index 5ac52ecd..a525a9b1 100644 --- a/source/code/core/core/public/ice/hash.hxx +++ b/source/code/core/core/public/ice/hash.hxx @@ -1,10 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include +#include namespace ice { @@ -52,6 +53,7 @@ namespace ice template constexpr auto hash(T value) noexcept -> ice::u64 { + static_assert(ice::concepts::EnumOrIntegral); return static_cast(value); } diff --git a/source/code/core/core/public/ice/utility.hxx b/source/code/core/core/public/ice/utility.hxx index 5a21699e..f8cbf2f4 100644 --- a/source/code/core/core/public/ice/utility.hxx +++ b/source/code/core/core/public/ice/utility.hxx @@ -104,4 +104,13 @@ namespace ice ); } + namespace concepts + { + + template + concept EnumOrIntegral = std::is_enum_v + or (std::is_arithmetic_v && not std::is_floating_point_v); + + } // namespace concepts + } // namespace ice diff --git a/source/code/core/modules/private/module_register.cxx b/source/code/core/modules/private/module_register.cxx index c58dddc1..2b25ddb5 100644 --- a/source/code/core/modules/private/module_register.cxx +++ b/source/code/core/modules/private/module_register.cxx @@ -2,8 +2,7 @@ /// SPDX-License-Identifier: MIT #include -#include -#include +#include #include #include #include @@ -11,6 +10,7 @@ #include "module_globals.hxx" #include "module_native.hxx" +#include namespace ice { @@ -73,7 +73,7 @@ namespace ice private: ice::Allocator& _allocator; - ice::HashMap _modules; + ice::MultiHashMap _modules; ice::Array _module_handles; }; @@ -170,7 +170,7 @@ namespace ice ) const noexcept -> ice::u32 { ice::u32 result = 0; - auto it = ice::multi_hashmap::find_first(_modules, ice::hash(api_name)); + auto it = _modules.find_values(api_name); while (it != nullptr) { ice::ModuleAPI api_ptr; @@ -178,7 +178,7 @@ namespace ice { result += 1; } - it = ice::multi_hashmap::find_next(_modules, it); + it.next(); } return result; } @@ -202,7 +202,7 @@ namespace ice } ice::u32 idx = 0; - auto it = ice::multi_hashmap::find_first(_modules, ice::hash(api_name)); + auto it = _modules.find_values(api_name); ice::u32 const array_size = *inout_array_size; while (it != nullptr && idx < array_size) @@ -213,7 +213,7 @@ namespace ice out_array[idx] = api_ptr; idx += 1; } - it = ice::multi_hashmap::find_next(_modules, it); + it.next(); } return idx > 0; } @@ -223,7 +223,7 @@ namespace ice ) noexcept { ice::u64 const name_hash = ice::hash(entry.name); - ice::multi_hashmap::insert(_modules, name_hash, entry); + _modules.insert(name_hash, entry); return true; } diff --git a/source/code/core/modules/public/ice/module_register.hxx b/source/code/core/modules/public/ice/module_register.hxx index 5d4a1fb6..7e62275f 100644 --- a/source/code/core/modules/public/ice/module_register.hxx +++ b/source/code/core/modules/public/ice/module_register.hxx @@ -4,9 +4,8 @@ #pragma once #include #include -#include +#include #include -#include #include #include #include diff --git a/source/code/core/tasks/private/task_native_thread.cxx b/source/code/core/tasks/private/task_native_thread.cxx index bd3d4dee..97aec1ec 100644 --- a/source/code/core/tasks/private/task_native_thread.cxx +++ b/source/code/core/tasks/private/task_native_thread.cxx @@ -50,7 +50,7 @@ namespace ice while (_runtime._state != ThreadState::Destroyed) { _runtime._queue.push_back(&final_awaitable); - thread_native::sleep(1); + thread_native::sleep(3); // sleep for a few milliseconds to ensure the thread was destroyed } thread_native::destroy_thread(_native); diff --git a/source/code/core/tasks/private/task_thread_pool_impl.cxx b/source/code/core/tasks/private/task_thread_pool_impl.cxx index 4e2f8c59..5ec6f4d3 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.cxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.cxx @@ -134,9 +134,8 @@ namespace ice .debug_name = ice::String{ name_hint.data(), static_cast(name_hint.size()) } }; - ice::hashmap::set( - _created_threads, - ice::hash(name), + _created_threads.set( + name, ice::make_unique( _allocator, _queue, @@ -144,12 +143,12 @@ namespace ice ) ); - return **ice::hashmap::try_get(_created_threads, ice::hash(name)); + return **_created_threads.try_get(ice::hash(name)); } auto TaskThreadPoolImplementation::find_thread(ice::StringID name) noexcept -> ice::TaskThread* { - if (auto const& unique_ptr = ice::hashmap::try_get(_created_threads, ice::hash(name))) + if (auto const& unique_ptr = _created_threads.try_get(ice::hash(name))) { return unique_ptr->get(); } @@ -158,13 +157,7 @@ namespace ice bool TaskThreadPoolImplementation::destroy_thread(ice::StringID name) noexcept { - ice::u64 const name_hash = ice::hash(name); - bool const exists = _created_threads.has(name_hash); - if (exists) - { - ice::hashmap::remove(_created_threads, name_hash); - } - return exists; + return _created_threads.remove(name); } auto TaskThreadPoolImplementation::attach_thread( @@ -173,20 +166,13 @@ namespace ice ice::UniquePtr thread ) noexcept -> ice::TaskThread& { - ice::u64 const name_hash = ice::hash(name); ICE_ASSERT( - _user_threads.missing(name_hash), + _user_threads.missing(name), "A user thread with name '{}' already exists", name ); - ice::hashmap::set( - _user_threads, - name_hash, - ice::move(thread) - ); - - return **ice::hashmap::try_get(_user_threads, name_hash); + return *_user_threads.set(name, ice::move(thread)); } auto TaskThreadPoolImplementation::detach_thread( @@ -198,9 +184,9 @@ namespace ice if (_user_threads.has(name_hash)) { // Move the thread out of the map - result = ice::move(*ice::hashmap::try_get(_user_threads, name_hash)); + result = ice::move(*_user_threads.try_get(name_hash)); // Remove the element from the map - ice::hashmap::remove(_user_threads, name_hash); + _user_threads.remove(name_hash); } return result; } diff --git a/source/code/core/tasks/private/task_thread_pool_impl.hxx b/source/code/core/tasks/private/task_thread_pool_impl.hxx index acaddba1..07274842 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.hxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "task_native_thread.hxx" namespace ice diff --git a/source/code/core/tasks/public/ice/task_thread.hxx b/source/code/core/tasks/public/ice/task_thread.hxx index 7804239c..dce4a0a7 100644 --- a/source/code/core/tasks/public/ice/task_thread.hxx +++ b/source/code/core/tasks/public/ice/task_thread.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include namespace ice { diff --git a/source/code/core/tasks/public/ice/task_thread_pool.hxx b/source/code/core/tasks/public/ice/task_thread_pool.hxx index abab9ee1..daf0a620 100644 --- a/source/code/core/tasks/public/ice/task_thread_pool.hxx +++ b/source/code/core/tasks/public/ice/task_thread_pool.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace ice diff --git a/source/code/core/utils/private/config/config_builder.cxx b/source/code/core/utils/private/config/config_builder.cxx index 0c97fb71..694f595d 100644 --- a/source/code/core/utils/private/config/config_builder.cxx +++ b/source/code/core/utils/private/config/config_builder.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include -#include +#include #include #include @@ -47,20 +47,20 @@ namespace ice ice::u32 offset_strings; }; - auto cb_find_keystr_idx(ice::HashMap const& keystrings, ice::String keystr) noexcept -> ice::u32 + auto cb_find_keystr_idx(ice::MultiHashMap const& keystrings, ice::String keystr) noexcept -> ice::u32 { ice::u64 const keystr_hash = ice::hash(keystr); - auto it = ice::multi_hashmap::find_first(keystrings, keystr_hash); + auto it = keystrings.find_values(keystr_hash); while(it != nullptr && it.value().value != keystr) { - it = ice::multi_hashmap::find_next(keystrings, it); + it.next(); } return it == nullptr ? keystrings.size().u32() : it.value().index; } auto cb_calculate_key_size( - ice::HashMap& keystrings, + ice::MultiHashMap& keystrings, ice::config::detail::ConfigBuilderContainer const& config, ice::config::detail::ConfigBuilderEntry const* entry ) noexcept -> ice::usize @@ -76,7 +76,7 @@ namespace ice // This allows us to reuse duplicate key names if (keystr_idx == keystrings.size()) { - ice::multi_hashmap::insert(keystrings, ice::hash(keystr), { keystr, keystr_idx }); + keystrings.insert(keystr, { keystr, keystr_idx }); result += { entry->size }; // Increase the size required } } @@ -84,7 +84,7 @@ namespace ice } auto cb_calculate_final_size( - ice::HashMap& keystrings, + ice::MultiHashMap& keystrings, ice::config::detail::ConfigBuilderContainer const& config, ice::usize& out_data_size, ice::u32& out_count @@ -138,7 +138,7 @@ namespace ice } auto cb_calculate_final_size( - ice::HashMap& keystrings, + ice::MultiHashMap& keystrings, ice::config::detail::ConfigBuilderContainer const& config, ice::u32& out_count ) noexcept -> ice::usize @@ -157,7 +157,7 @@ namespace ice } auto cb_finalize_store_keysvalues( - ice::HashMap& keystrings, + ice::MultiHashMap& keystrings, ice::Span keystringoffsets, ice::config::detail::ConfigBuilderContainer const& config, ice::config::detail::ConfigKey* out_keylist, @@ -377,7 +377,7 @@ namespace ice } ice::Array keyoffsets{ alloc }; - ice::HashMap keystrings{ alloc }; + ice::MultiHashMap keystrings{ alloc }; ice::u32 final_count = 0; ice::usize const final_size = cb_calculate_final_size(keystrings, container, final_count); diff --git a/source/code/core/utils/private/log_internal.cxx b/source/code/core/utils/private/log_internal.cxx index 87ea9ea9..0c8a271c 100644 --- a/source/code/core/utils/private/log_internal.cxx +++ b/source/code/core/utils/private/log_internal.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include "log_internal.hxx" -#include +#include #include namespace ice::detail @@ -23,8 +23,7 @@ namespace ice::detail void LogState::register_tag(ice::LogTagDefinition tag_def) noexcept { - ice::hashmap::set( - _tags, + _tags.set( tag_hash(tag_def.tag), { ice::HeapString{ _allocator, tag_def.name }, true } ); @@ -52,7 +51,7 @@ namespace ice::detail void LogState::enable_tag(ice::LogTag tag, bool enabled) noexcept { - if (LogTagInfo* tagv = ice::hashmap::try_get(_tags, tag_hash(tag))) + if (LogTagInfo* tagv = _tags.try_get(tag_hash(tag))) { tagv->enabled = enabled; } @@ -60,8 +59,7 @@ namespace ice::detail auto LogState::tag_name(ice::LogTag tag) const noexcept -> ice::String { - return ice::hashmap::get( - _tags, + return _tags.get( tag_hash(tag), _empty_tag ).name; @@ -69,8 +67,7 @@ namespace ice::detail bool LogState::tag_enabled(ice::LogTag tag) const noexcept { - return ice::hashmap::get( - _tags, + return _tags.get( tag_hash(tag), _empty_tag ).enabled; diff --git a/source/code/core/utils/private/log_internal.hxx b/source/code/core/utils/private/log_internal.hxx index b292ae53..cf29803f 100644 --- a/source/code/core/utils/private/log_internal.hxx +++ b/source/code/core/utils/private/log_internal.hxx @@ -2,8 +2,8 @@ /// SPDX-License-Identifier: MIT #pragma once -#include -#include +#include +#include #include #include #include diff --git a/source/code/core/utils/public/ice/config.hxx b/source/code/core/utils/public/ice/config.hxx index bc29df85..181660c8 100644 --- a/source/code/core/utils/public/ice/config.hxx +++ b/source/code/core/utils/public/ice/config.hxx @@ -1,8 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include namespace ice::config diff --git a/source/code/core/utils/public/ice/data_storage.hxx b/source/code/core/utils/public/ice/data_storage.hxx index 68dc1c37..bf4cd569 100644 --- a/source/code/core/utils/public/ice/data_storage.hxx +++ b/source/code/core/utils/public/ice/data_storage.hxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include namespace ice diff --git a/source/code/core/utils/public/ice/log_formatters.hxx b/source/code/core/utils/public/ice/log_formatters.hxx index de13f69b..6d19466c 100644 --- a/source/code/core/utils/public/ice/log_formatters.hxx +++ b/source/code/core/utils/public/ice/log_formatters.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/source/code/core/utils/public/ice/params.hxx b/source/code/core/utils/public/ice/params.hxx index cc2c765e..fcf34f88 100644 --- a/source/code/core/utils/public/ice/params.hxx +++ b/source/code/core/utils/public/ice/params.hxx @@ -1,9 +1,10 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include +#include namespace ice { diff --git a/source/code/core/utils/public/ice/path_utils.hxx b/source/code/core/utils/public/ice/path_utils.hxx index 88cbb648..01d1fe9b 100644 --- a/source/code/core/utils/public/ice/path_utils.hxx +++ b/source/code/core/utils/public/ice/path_utils.hxx @@ -2,8 +2,8 @@ /// SPDX-License-Identifier: MIT #pragma once -#include #include +#include namespace ice::path { diff --git a/source/code/core/utils/public/ice/shard_payloads.hxx b/source/code/core/utils/public/ice/shard_payloads.hxx index 8e749d66..dc9a1ac6 100644 --- a/source/code/core/utils/public/ice/shard_payloads.hxx +++ b/source/code/core/utils/public/ice/shard_payloads.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include namespace ice diff --git a/source/code/core/utils/public/ice/string_utils.hxx b/source/code/core/utils/public/ice/string_utils.hxx index 7caeff63..bbe5d334 100644 --- a/source/code/core/utils/public/ice/string_utils.hxx +++ b/source/code/core/utils/public/ice/string_utils.hxx @@ -3,6 +3,7 @@ #pragma once #include +#include #include #include #include diff --git a/source/code/framework/framework_base/private/traits/render/trait_render_texture_loader.hxx b/source/code/framework/framework_base/private/traits/render/trait_render_texture_loader.hxx index ddb95f29..2db9ba98 100644 --- a/source/code/framework/framework_base/private/traits/render/trait_render_texture_loader.hxx +++ b/source/code/framework/framework_base/private/traits/render/trait_render_texture_loader.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -7,7 +7,7 @@ #include #include -#include +#include namespace ice { diff --git a/source/code/framework/framework_base/private/traits/trait_camera.cxx b/source/code/framework/framework_base/private/traits/trait_camera.cxx index 6bed604c..7a91eae4 100644 --- a/source/code/framework/framework_base/private/traits/trait_camera.cxx +++ b/source/code/framework/framework_base/private/traits/trait_camera.cxx @@ -21,7 +21,7 @@ #include #include -#include +#include #include namespace ice @@ -116,7 +116,7 @@ namespace ice } }; - ice::TraitCameraData& data = ice::hashmap::get_or_set(_render_data, ice::hash(camera->name), { camera->name }); + ice::TraitCameraData& data = _render_data.get_or_set(camera->name, { camera->name }); ice::CameraData& camera_data = data.camera_data; if (ortho != nullptr) { diff --git a/source/code/framework/framework_base/private/traits/trait_sprite_animator.hxx b/source/code/framework/framework_base/private/traits/trait_sprite_animator.hxx index ae04963c..c55b34f9 100644 --- a/source/code/framework/framework_base/private/traits/trait_sprite_animator.hxx +++ b/source/code/framework/framework_base/private/traits/trait_sprite_animator.hxx @@ -1,8 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include #include diff --git a/source/code/framework/framework_base/private/traits/ui/game_ui_trait.hxx b/source/code/framework/framework_base/private/traits/ui/game_ui_trait.hxx index a7dfad5f..d35e31c5 100644 --- a/source/code/framework/framework_base/private/traits/ui/game_ui_trait.hxx +++ b/source/code/framework/framework_base/private/traits/ui/game_ui_trait.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include "render_ui_trait.hxx" diff --git a/source/code/framework/framework_base/private/traits/ui/render_ui_trait.hxx b/source/code/framework/framework_base/private/traits/ui/render_ui_trait.hxx index 9ca34838..1e275c30 100644 --- a/source/code/framework/framework_base/private/traits/ui/render_ui_trait.hxx +++ b/source/code/framework/framework_base/private/traits/ui/render_ui_trait.hxx @@ -1,11 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include +#include #include #include diff --git a/source/code/framework/framework_base/public/ice/framework_app.hxx b/source/code/framework/framework_base/public/ice/framework_app.hxx index 5db70294..f9bbf930 100644 --- a/source/code/framework/framework_base/public/ice/framework_app.hxx +++ b/source/code/framework/framework_base/public/ice/framework_app.hxx @@ -1,9 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #include #include diff --git a/source/code/framework/framework_base/public/ice/game_sprites.hxx b/source/code/framework/framework_base/public/ice/game_sprites.hxx index 33411328..38e75d77 100644 --- a/source/code/framework/framework_base/public/ice/game_sprites.hxx +++ b/source/code/framework/framework_base/public/ice/game_sprites.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/iceshard/engine/private/action/action_trigger.cxx b/source/code/iceshard/engine/private/action/action_trigger.cxx index d8ab629d..2307741c 100644 --- a/source/code/iceshard/engine/private/action/action_trigger.cxx +++ b/source/code/iceshard/engine/private/action/action_trigger.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -6,7 +6,7 @@ #include #include -#include +#include namespace ice::action { @@ -108,12 +108,12 @@ namespace ice::action void SimpleTriggerDatabase::add_trigger(ice::StringID_Arg name, ice::action::ActionTriggerDefinition trigger_info) noexcept { - ice::hashmap::set(_triggers, ice::hash(name), trigger_info); + _triggers.set(name, trigger_info); } auto SimpleTriggerDatabase::get_trigger(ice::StringID_Arg name) const noexcept -> ice::action::ActionTriggerDefinition { - return ice::hashmap::get(_triggers, ice::hash(name), ActionTriggerDefinition{ ice::Shard_Invalid.id }); + return _triggers.get(name, ActionTriggerDefinition{ ice::Shard_Invalid.id }); } auto create_trigger_database( diff --git a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx index 1b858b2e..0ebc0c24 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include @@ -300,12 +300,12 @@ namespace ice::ecs data_header->archetype_info.archetype_instance = ice::ecs::detail::ArchetypeInstance{ archetype_index }; _archetype_data.push_back(data_header); - ice::hashmap::set(_archetype_index, ice::hash(archetype_info.identifier), archetype_index); + _archetype_index.set(archetype_info.identifier, archetype_index); // Save the 'index' for the given name if (data_header->archetype_name.not_empty()) { - ice::hashmap::set(_archetype_names_index, ice::hash(data_header->archetype_name), archetype_index); + _archetype_names_index.set(data_header->archetype_name, archetype_index); } return archetype_info.identifier; @@ -316,7 +316,7 @@ namespace ice::ecs ) const noexcept -> ice::ecs::Archetype { ice::u32 const instance_count = _archetype_data.size().u32(); - ice::u32 const instance_idx = ice::hashmap::get(_archetype_names_index, ice::hash(name), ice::u32_max); + ice::u32 const instance_idx = _archetype_names_index.get(name, ice::u32_max); if (instance_idx >= instance_count) { return Archetype::Invalid; @@ -398,7 +398,7 @@ namespace ice::ecs ice::u32 archetype_idx = 0; for (Archetype archetype : archetypes) { - ice::u32 const instance_idx = ice::hashmap::get(_archetype_index, ice::hash(archetype), ice::u32_max); + ice::u32 const instance_idx = _archetype_index.get(archetype, ice::u32_max); ICE_ASSERT( instance_idx < instance_count, "Unknown archetype handle {} provided while fetching instance infos. Did you forget to register this archetype?", @@ -465,7 +465,7 @@ namespace ice::ecs ) const noexcept { ice::u32 const instance_count = _archetype_data.size().u32(); - ice::u32 const instance_idx = ice::hashmap::get(_archetype_index, ice::hash(archetype), ice::u32_max); + ice::u32 const instance_idx = _archetype_index.get(archetype, ice::u32_max); if (instance_idx < instance_count) { diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx index 57722831..4df80f45 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include -#include +#include #include #include #include @@ -316,7 +316,7 @@ namespace ice::ecs void batch_remove_entities( ice::ecs::ArchetypeIndex const& archetypes, - ice::HashMap const& destructors, + ice::MultiHashMap const& destructors, ice::Span data_slots, ice::Span entities_to_remove, ice::Span data_blocks @@ -350,7 +350,7 @@ namespace ice::ecs // Query all attached destructors dtor_count = 0; - auto dtor_it = ice::multi_hashmap::find_first(destructors, ice::hash(archetype)); + auto dtor_it = destructors.find_values(archetype); while (dtor_it != nullptr) { dtors[dtor_count] = ice::addressof(dtor_it.value()); @@ -361,7 +361,7 @@ namespace ice::ecs dtor_components_offsets + dtor_count * 2 ); dtor_count += 1; - dtor_it = ice::multi_hashmap::find_next(destructors, dtor_it); + dtor_it.next(); } } @@ -659,11 +659,11 @@ namespace ice::ecs for (ice::StringID component_id : info->component_identifiers) { - ice::ecs::QueryAccessTracker* tracker = ice::hashmap::get(_access_trackers, ice::hash(component_id), nullptr); + ice::ecs::QueryAccessTracker* tracker = _access_trackers.get(component_id, nullptr); if (tracker == nullptr) { tracker = _allocator.create(); - ice::hashmap::set(_access_trackers, ice::hash(component_id), tracker); + _access_trackers.set(component_id, tracker); } } } @@ -681,15 +681,15 @@ namespace ice::ecs if (_destructors.has(info->archetype_instance)) { - auto it = ice::multi_hashmap::find_first(_destructors, ice::hash(info->archetype_instance)); + auto it = _destructors.find_values(info->archetype_instance); while (it != nullptr && it.value().identifier != destructor.identifier) { - it = ice::multi_hashmap::find_next(_destructors, it); + it.next(); } ICE_ASSERT(it == nullptr, "A destructor with id {} was already attached to this archetype!"); } - ice::multi_hashmap::insert(_destructors, ice::hash(info->archetype_instance), destructor); + _destructors.insert(info->archetype_instance, destructor); return true; } @@ -1173,7 +1173,7 @@ namespace ice::ecs ice::nindex idx = prev_archetype_count; for (ice::ecs::detail::QueryTypeInfo const& type_info : query_info) { - ice::ecs::QueryAccessTracker* tracker = ice::hashmap::get(_access_trackers, ice::hash(type_info.identifier), nullptr); + ice::ecs::QueryAccessTracker* tracker = _access_trackers.get(type_info.identifier, nullptr); ICE_ASSERT_CORE(tracker != nullptr); out_access_trackers[idx] = tracker; diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_tracker.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_tracker.cxx index 3dc00fc5..490ef8cd 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_tracker.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_tracker.cxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include -#include +#include #include namespace ice::ecs diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index d156ddfc..3b237e6b 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -46,9 +46,8 @@ namespace ice initial_state.value = params.initial.value; initial_state.subname = ice::StringID_Invalid; - ice::multi_hashmap::insert( - _current_state_index, - ice::hash(params.initial.graph.value), + _current_state_index.insert( + params.initial.graph.value, _current_state.size().u32() ); _current_state.push_back(initial_state); @@ -68,27 +67,20 @@ namespace ice initial_state.value = params.initial.value; initial_state.subname = subname; - ice::multi_hashmap::insert( - _current_state_index, - ice::hash(params.initial.graph.value), + _current_state_index.insert( + params.initial.graph.value, _current_state.size().u32() ); _current_state.push_back(initial_state); } - ice::hashmap::set( - _initial_states, - ice::hash(params.initial.graph.value), + _initial_states.set( + params.initial.graph.value, params.initial ); } - ice::hashmap::get_or_set( - _state_committers, - ice::hash(params.initial.graph.value), - params.committer - ); - + _state_committers.set_if_missing(params.initial.graph.value, params.committer); _available_triggers.push_back(triggers); return true; @@ -109,9 +101,8 @@ namespace ice engine_state.value = initial_state.value; engine_state.subname = subname; - ice::multi_hashmap::insert( - _current_state_index, - ice::hash(engine_state.graph.value), + _current_state_index.insert( + engine_state.graph.value, _current_state.size().u32() ); _current_state.push_back(engine_state); @@ -124,8 +115,8 @@ namespace ice ice::StringID_Arg subname ) const noexcept -> ice::EngineStateCurrent { - auto it = ice::multi_hashmap::find_first(_current_state_index, ice::hash(state_graph.value)); - while (it != nullptr) + auto it = _current_state_index.find_values(state_graph.value); + while (it.has_next()) { ice::EngineStateCurrent const& current = _current_state[it.value()]; @@ -133,7 +124,7 @@ namespace ice { break; } - it = ice::multi_hashmap::find_next(_current_state_index, it); + it.next(); } if (it == nullptr) @@ -232,7 +223,7 @@ namespace ice ice::StringID trigger_subname; bool const has_trigger_subname = ice::shard_inspect(trigger_shard, trigger_subname.value); - auto it = ice::multi_hashmap::find_first(_current_state_index, ice::hash(trigger.from.graph.value)); + auto it = _current_state_index.find_values(trigger.from.graph.value); while (it != nullptr) { ice::EngineStateCurrent& from_state = _current_state[it.value()]; @@ -243,7 +234,7 @@ namespace ice { if (has_trigger_subname) { - it = ice::multi_hashmap::find_next(_current_state_index, it); + it.next(); continue; } return; @@ -254,7 +245,7 @@ namespace ice { if (trigger_subname != from_state.subname) { - it = ice::multi_hashmap::find_next(_current_state_index, it); + it.next(); continue; } } @@ -286,12 +277,12 @@ namespace ice .trigger_shard = trigger_shard, .trigger = trigger, // TODO: Provide a default committer - .committer = *ice::hashmap::get(_state_committers, ice::hash(trigger.to.graph.value), nullptr), + .committer = *_state_committers.get(trigger.to.graph.value, nullptr), .current = from_state } ); - it = ice::multi_hashmap::find_next(_current_state_index, it); + it.next(); } } @@ -321,7 +312,7 @@ namespace ice } // Find the states for the possibly affected graphs - auto it = ice::multi_hashmap::find_first(_current_state_index, ice::hash(trigger.from.graph.value)); + auto it = _current_state_index.find_values(trigger.from.graph.value); while (it != nullptr) { ice::EngineStateCurrent& from_state = _current_state[it.value()]; @@ -345,7 +336,7 @@ namespace ice } ); - it = ice::multi_hashmap::find_next(_current_state_index, it); + it.next(); // If we have a trigger shard, then we can almost submit this trigger as pending if (trigger_shard == ice::Shard_Invalid) @@ -373,7 +364,7 @@ namespace ice .trigger_shard = trigger_shard, .trigger = trigger, // TODO: Provide a default committer - .committer = *ice::hashmap::get(_state_committers, ice::hash(trigger.to.graph.value), nullptr), + .committer = *_state_committers.get(trigger.to.graph.value, nullptr), .current = from_state } ); diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx index 4a8fcd91..4f1f11c4 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -74,7 +74,7 @@ namespace ice ice::Array _available_triggers; ice::HashMap _initial_states; ice::HashMap _state_committers; - ice::HashMap _current_state_index; + ice::MultiHashMap _current_state_index; ice::Array _current_state; ice::Queue _pending_states; diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx index fb2ce5b6..e945a6fe 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx @@ -106,7 +106,7 @@ namespace ice::gfx } _passes.push_back(GfxGraphPass{ .name = pass.name, .stages = gfxpass.stages }); - ice::hashmap::set(_objects, ice::hash(pass.name), ice::move(gfxpass)); + _objects.set(pass.name, ice::move(gfxpass)); } return true; } @@ -270,7 +270,7 @@ namespace ice::gfx // TODO: Add possible optionality // Check for the entry to be compared with - Entry* entry = ice::hashmap::get(_stages._stages, stage_hash, nullptr); + Entry* entry = _stages._stages.get(stage_hash, nullptr); if (entry != nullptr && entry->stage != stage_ptr) { removed_stages += 1; @@ -286,7 +286,7 @@ namespace ice::gfx if (stage_ptr == nullptr) { // Remove the entry from the map. - ice::hashmap::remove(_stages._stages, stage_hash); + _stages._stages.remove(stage_hash); } // Delete the entry object @@ -300,7 +300,7 @@ namespace ice::gfx if (entry == nullptr) { new_stages += 1; - ice::hashmap::set(_stages._stages, stage_hash, _allocator.create(stage_ptr, new_revision, false)); + _stages._stages.set(stage_hash, _allocator.create(stage_ptr, new_revision, false)); } else if (entry->stage != stage_ptr) { diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.hxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.hxx index fb766bb7..aa7bde99 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.hxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include "ice_gfx_graph_snapshot.hxx" diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.hxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.hxx index 0874f179..185da3e0 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.hxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.hxx @@ -1,10 +1,10 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include "ice_gfx_graph_snapshot.hxx" @@ -58,7 +58,7 @@ namespace ice::gfx template void apply_stages(ice::StringID_Arg key, Method fn, Args&&... args) noexcept { - Entry* const entry = ice::hashmap::get(_stages, ice::hash(key), nullptr); + Entry* const entry = _stages.get(key, nullptr); if (entry != nullptr) { ((entry->stage)->*fn)(ice::forward(args)...); diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_object_storage.hxx b/source/code/iceshard/engine/private/gfx/ice_gfx_object_storage.hxx index 6441849c..4a76aae4 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_object_storage.hxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_object_storage.hxx @@ -1,9 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice::gfx { diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx index 83cb6658..471db5d7 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include -#include +#include namespace ice::gfx { @@ -43,14 +43,14 @@ namespace ice::gfx ice::gfx::GfxStage* stage ) noexcept { - ice::hashmap::set(_stages, ice::hash(key), stage); + _stages.set(key, stage); } void IceGfxStageRegistry::remove_stage( ice::StringID_Arg key ) noexcept { - ice::hashmap::remove(_stages, ice::hash(key)); + _stages.remove(key); } bool IceGfxStageRegistry::query_stages( @@ -61,7 +61,7 @@ namespace ice::gfx bool result = true; for (ice::StringID_Arg key : stage_keys) { - ice::gfx::GfxStage* const* stage_ptr = ice::hashmap::try_get(_stages, ice::hash(key)); + ice::gfx::GfxStage* const* stage_ptr = _stages.try_get(ice::hash(key)); out_stages.push_back(stage_ptr == nullptr ? nullptr : *stage_ptr); result |= stage_ptr != nullptr; } diff --git a/source/code/iceshard/engine/private/world_trait_archive.cxx b/source/code/iceshard/engine/private/world_trait_archive.cxx index 997eba2b..94df869c 100644 --- a/source/code/iceshard/engine/private/world_trait_archive.cxx +++ b/source/code/iceshard/engine/private/world_trait_archive.cxx @@ -3,7 +3,7 @@ #include #include -#include +#include #include namespace ice @@ -41,13 +41,13 @@ namespace ice descriptor.fn_arch_register(_archetypes); } - ice::hashmap::set(_traits, ice::hash(descriptor.name), ice::move(descriptor)); + _traits.set(descriptor.name, ice::move(descriptor)); } } auto trait(ice::StringID_Arg name) const noexcept -> ice::TraitDescriptor const* override { - return ice::hashmap::try_get(_traits, ice::hash(name)); + return _traits.try_get(ice::hash(name)); } private: diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx index 5b1a4a53..3eb41c29 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx @@ -4,9 +4,10 @@ #pragma once #include #include +#include #include -#include #include +#include namespace ice::ecs::detail { diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_index.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_index.hxx index 1f2263d1..43ecadfa 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_index.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_index.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include namespace ice::ecs diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx index 75182aa0..1ff4417d 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx @@ -2,6 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once +#include #include #include #include @@ -79,7 +80,7 @@ namespace ice::ecs ice::Array _data_blocks; ice::Array _data_slots; - ice::HashMap _destructors; + ice::MultiHashMap _destructors; }; } // namespace ice::ecs diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_tracker.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_tracker.hxx index bab609e8..8e9b71ee 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_tracker.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_tracker.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #include diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx index f2d0877e..1ccf2983 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_builder.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include namespace ice::ecs { @@ -62,11 +62,11 @@ namespace ice::ecs { ice::UniquePtr entry = ice::make_unique(_allocator, _allocator); entry->initialize(_query_provider); - ice::hashmap::set(_queries, Entry::hash_value(), ice::move(entry)); + _queries.set(Entry::hash_value(), ice::move(entry)); } return static_cast( - ice::hashmap::try_get(_queries, Entry::hash_value())->get() + _queries.try_get(Entry::hash_value())->get() )->object_query(); } diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx index e1b82b4b..10d40039 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx @@ -6,7 +6,7 @@ #include #include #include -#include +#include namespace ice::ecs::detail { diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx index 17e62a53..e32dec45 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -203,8 +203,7 @@ namespace ice::gfx ); } - ice::hashmap::set( - queue_index_tracker, + queue_index_tracker.set( ice::hash(reinterpret_cast(&pass_info)), queues[queue_info_idx].count - 1 ); @@ -245,8 +244,7 @@ namespace ice::gfx for (ice::gfx::GfxQueueDefinition const& pass_info : render_queues) { QueueID const pass_queue_id = detail::find_queue_id(queue_families, pass_info.flags); - ice::u32 const pass_queue_index = ice::hashmap::get( - queue_index_tracker, + ice::u32 const pass_queue_index = queue_index_tracker.get( ice::hash(reinterpret_cast(&pass_info)), ~0u ); diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx index 5f3811cb..11f6de3f 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx @@ -3,7 +3,7 @@ #include "iceshard_gfx_queue_group.hxx" #include "iceshard_gfx_queue.hxx" -#include +#include #include #include @@ -51,13 +51,7 @@ namespace ice::gfx pool_index ); - ice::hashmap::set( - _gfx_queues, - ice::hash(name), - queue - ); - - return queue; + return _gfx_queues.set(name, queue); } bool IceGfxQueueGroup::get_queue(ice::render::QueueFlags flags, ice::gfx::GfxQueue*& out_queue) noexcept @@ -92,11 +86,7 @@ namespace ice::gfx auto IceGfxQueueGroup::get_queue(ice::StringID_Arg name) noexcept -> ice::gfx::IceGfxQueue* { - return ice::hashmap::get( - _gfx_queues, - ice::hash(name), - nullptr - ); + return _gfx_queues.get(name, nullptr); } void IceGfxQueueGroup::reset_all() noexcept diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.hxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.hxx index f196ce9e..a2c584c9 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.hxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.hxx @@ -1,11 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include +#include namespace ice::gfx { diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx index caabc9fb..78356ff0 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx @@ -83,7 +83,7 @@ namespace ice::gfx auto Trait_GfxImageStorage::on_asset_released(ice::Asset const& asset) noexcept -> ice::Task<> { - GfxImageEntry* entry = ice::hashmap::try_get(_loaded_images, ice::hash(asset.name())); + GfxImageEntry* entry = _loaded_images.try_get(ice::hash(asset.name())); ICE_ASSERT_CORE(entry != nullptr); entry->released = true; // Mark as released co_return; @@ -112,7 +112,7 @@ namespace ice::gfx ICE_ASSERT_CORE(state == AssetState::Loaded); // The image needs to be loaded. ice::StringID const nameid = request->asset_name(); - GfxImageEntry* entry = ice::hashmap::try_get(_loaded_images, ice::hash(nameid)); + GfxImageEntry* entry = _loaded_images.try_get(ice::hash(nameid)); if (entry && entry->image != Image::Invalid) { // Allocates a handle for it... (TODO: Rework?) @@ -249,8 +249,7 @@ namespace ice::gfx ice::Asset asset = uploaded_request->resolve(resolve_success); // Save the image handle - ice::hashmap::set( - _loaded_images, + _loaded_images.set( asset_hash, { .asset = ice::move(asset), .image = created_images[idx] } ); diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx index 95d903aa..6ee4e63c 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include #include diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx index cf87bcc3..6ff477aa 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx @@ -67,7 +67,7 @@ namespace ice::gfx auto Trait_GfxShaderStorage::on_asset_released(ice::Asset const& asset) noexcept -> ice::Task<> { - GfxShaderEntry* entry = ice::hashmap::try_get(_loaded_shaders, ice::hash(asset.name())); + GfxShaderEntry* entry = _loaded_shaders.try_get(ice::hash(asset.name())); ICE_ASSERT_CORE(entry != nullptr); entry->released = true; // Mark as released co_return; @@ -92,7 +92,7 @@ namespace ice::gfx ICE_ASSERT_CORE(state == AssetState::Loaded); // The shader needs to be loaded. ice::u64 const shader_hash = ice::hash(request->asset_name()); - GfxShaderEntry* entry = ice::hashmap::try_get(_loaded_shaders, shader_hash); + GfxShaderEntry* entry = _loaded_shaders.try_get(shader_hash); ICE_ASSERT_CORE(entry == nullptr || entry->released); using namespace ice::render; @@ -123,7 +123,7 @@ namespace ice::gfx send("iceshard:shaders-internal:loaded"_shardid, asset); // Save the shader handle - ice::hashmap::set(_loaded_shaders, shader_hash, { .asset = ice::move(asset), .shader = shader, }); + _loaded_shaders.set(shader_hash, { .asset = ice::move(asset), .shader = shader, }); // Get the next queued request request = assets.aquire_request(ice::render::AssetCategory_Shader, AssetState::Runtime); diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.hxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.hxx index b4fe8979..46abde2a 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.hxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.hxx @@ -1,8 +1,8 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include #include diff --git a/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx b/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx index 43e108f2..4914b376 100644 --- a/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include namespace ice { @@ -43,20 +43,20 @@ namespace ice ICE_ASSERT_CORE(missing); //if (missing) { - ice::hashmap::set(_values, ice::hash(name), value); + _values.set(ice::hash(name), value); } return missing; } bool get(ice::StringID_Arg name, void*& value) noexcept override { - value = ice::hashmap::get(_values, ice::hash(name), nullptr); + value = _values.get(name, nullptr); return value != nullptr; } bool get(ice::StringID_Arg name, void const*& value) const noexcept override { - value = ice::hashmap::get(_values, ice::hash(name), nullptr); + value = _values.get(name, nullptr); return value != nullptr; } diff --git a/source/code/iceshard/iceshard/private/iceshard_gfx_runner.cxx b/source/code/iceshard/iceshard/private/iceshard_gfx_runner.cxx index d224b2ee..6ae66dee 100644 --- a/source/code/iceshard/iceshard/private/iceshard_gfx_runner.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_gfx_runner.cxx @@ -1,11 +1,11 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_gfx_runner.hxx" #include "iceshard_runner.hxx" #include "gfx/iceshard_gfx_device.hxx" -#include +#include #include #include #include diff --git a/source/code/iceshard/iceshard/private/iceshard_runner.hxx b/source/code/iceshard/iceshard/private/iceshard_runner.hxx index 387a501e..24c918db 100644 --- a/source/code/iceshard/iceshard/private/iceshard_runner.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_runner.hxx @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include "iceshard_data_storage.hxx" diff --git a/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx b/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx index 7ff033cf..3ac240e5 100644 --- a/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include namespace ice { diff --git a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx index 2a291287..b2fd0cbb 100644 --- a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx @@ -5,7 +5,7 @@ #include "iceshard_trait_context.hxx" #include -#include +#include #include #include @@ -87,7 +87,7 @@ namespace ice auto IceshardTraitContext::checkpoint(ice::StringID id) noexcept -> ice::TaskCheckpointGate { - ice::TaskCheckpoint* const checkpoint = ice::hashmap::get(_world_context._checkpoints, ice::hash(id), nullptr); + ice::TaskCheckpoint* const checkpoint = _world_context._checkpoints.get(id, nullptr); if (checkpoint != nullptr) { return checkpoint->checkpoint_gate(); @@ -102,16 +102,16 @@ namespace ice return false; } - ice::hashmap::set(_world_context._checkpoints, ice::hash(id), ice::addressof(checkpoint)); + _world_context._checkpoints.set(id, ice::addressof(checkpoint)); return true; } void IceshardTraitContext::unregister_checkpoint(ice::StringID id, ice::TaskCheckpoint& checkpoint) noexcept { - ice::TaskCheckpoint* const checkpoint_ptr = ice::hashmap::get(_world_context._checkpoints, ice::hash(id), nullptr); + ice::TaskCheckpoint* const checkpoint_ptr = _world_context._checkpoints.get(id, nullptr); if (checkpoint_ptr == ice::addressof(checkpoint)) { - ice::hashmap::remove(_world_context._checkpoints, ice::hash(id)); + _world_context._checkpoints.remove(id); } } @@ -124,8 +124,7 @@ namespace ice ICE_ASSERT_CORE(binding.task_type > TraitTaskType::Invalid); ICE_ASSERT_CORE(binding.task_type <= TraitTaskType::Render); - ice::multi_hashmap::insert( - _world_context._frame_handlers[ice::u32(binding.task_type) - 1], + _world_context._frame_handlers[ice::u32(binding.task_type) - 1].insert( ice::hash(trigger_event), ice::IceshardEventHandler{ .trait_idx = _trait_index, diff --git a/source/code/iceshard/iceshard/private/iceshard_world_context.cxx b/source/code/iceshard/iceshard/private/iceshard_world_context.cxx index 018d01a5..61363900 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_context.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_context.cxx @@ -13,9 +13,9 @@ namespace ice , _always_reached_checkpoint{ true } , _checkpoints{ alloc } , _frame_handlers{ - ice::HashMap{ alloc }, - ice::HashMap{ alloc }, - ice::HashMap{ alloc } + ice::MultiHashMap{ alloc }, + ice::MultiHashMap{ alloc }, + ice::MultiHashMap{ alloc } } , _runner_handlers{ alloc } { diff --git a/source/code/iceshard/iceshard/private/iceshard_world_context.hxx b/source/code/iceshard/iceshard/private/iceshard_world_context.hxx index 8e69f2b2..43d110dc 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_context.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_context.hxx @@ -2,10 +2,10 @@ /// SPDX-License-Identifier: MIT #pragma once -#include #include #include #include +#include #include "iceshard_trait_context.hxx" @@ -48,7 +48,7 @@ namespace ice ice::TaskCheckpoint _always_reached_checkpoint; ice::HashMap _checkpoints; - ice::HashMap _frame_handlers[3]; + ice::MultiHashMap _frame_handlers[3]; ice::HashMap _runner_handlers; }; diff --git a/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx index 0c18f74f..73c9c097 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_devui.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include "iceshard_world_devui.hxx" -#include +#include #include #include diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx index b614bba5..d493b748 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx @@ -94,10 +94,13 @@ namespace ice ); } + + auto IceshardWorldManager::create_world( ice::WorldTemplate const& world_template ) noexcept -> World* { + static constexpr bool is_ass = ice::concepts::AssociativeContainer>; ICE_ASSERT( _worlds.missing(world_template.name), @@ -149,9 +152,8 @@ namespace ice ice::ShardID_WorldCreated | ice::stringid_hash(world_template.name) ); - return ice::hashmap::get_or_set( - _worlds, - ice::hash(world_template.name), + return _worlds.get_or_set( + world_template.name, ice::move(world_entry) ).world; } @@ -161,7 +163,7 @@ namespace ice ) noexcept -> World* { static Entry invalid_entry{ }; - return ice::hashmap::get(_worlds, ice::hash(name), invalid_entry).world; + return _worlds.get(name, invalid_entry).world; } void IceshardWorldManager::destroy_world( @@ -170,7 +172,7 @@ namespace ice { static Entry invalid_entry{ }; ICE_ASSERT( - ice::hashmap::get(_worlds, ice::hash(name), invalid_entry).is_active == false, + _worlds.get(name, invalid_entry).is_active == false, "Trying to destroy active world: {}!", name ); @@ -181,7 +183,7 @@ namespace ice ice::ShardID_WorldDestroyed | ice::stringid_hash(name) ); - ice::hashmap::remove(_worlds, ice::hash(name)); + _worlds.remove(name); } void IceshardWorldManager::query_worlds(ice::Array& out_worlds) const noexcept @@ -234,7 +236,7 @@ namespace ice ice::Span event_shards ) noexcept { - Entry const* const entry = ice::hashmap::try_get(_worlds, ice::hash(world_name)); + Entry const* const entry = _worlds.try_get(ice::hash(world_name)); if (entry != nullptr && entry->is_active) { entry->world->task_launcher().gather(out_tasks, params, event_shards); @@ -250,7 +252,7 @@ namespace ice ice::StringID_Hash world_name; if (ice::shard_inspect(trigger_shard, world_name)) { - Entry* const entry = ice::hashmap::try_get(_worlds, ice::hash(world_name)); + Entry * const entry = _worlds.try_get(ice::hash(world_name)); ICE_ASSERT_CORE(entry != nullptr); // Activated diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx index a1ff7785..d762eb8d 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx @@ -38,16 +38,16 @@ namespace ice ICE_ASSERT_CORE(params.task_type <= TraitTaskType::Render); ice::u32 const tasktype_idx = ice::u32(params.task_type) - 1; - ice::HashMap& handlers = _world_context._frame_handlers[tasktype_idx]; + ice::MultiHashMap& handlers = _world_context._frame_handlers[tasktype_idx]; ice::Span> tasks = task_container.create_tasks( - ice::multi_hashmap::count(handlers, ice::hash(shard.id)), + handlers.count_values(shard.id).u32(), shard.id ); auto out_it = tasks.begin(); - auto it = ice::multi_hashmap::find_first(handlers, ice::hash(shard.id)); - while (it != nullptr) + auto it = handlers.find_values(shard.id); + while (it.has_next()) { ice::IceshardEventHandler const& handler = it.value(); void* const userdata = handler.procedure_userdata != nullptr @@ -57,7 +57,7 @@ namespace ice *out_it = handler.procedure(userdata, params, shard); out_it += 1; - it = ice::multi_hashmap::find_next(handlers, it); + it.next(); } } @@ -86,10 +86,10 @@ namespace ice ICE_ASSERT_CORE(params.task_type <= TraitTaskType::Render); ice::u32 const tasktype_idx = ice::u32(params.task_type) - 1; - ice::HashMap& handlers = _world_context._frame_handlers[tasktype_idx]; + ice::MultiHashMap& handlers = _world_context._frame_handlers[tasktype_idx]; - auto it = ice::multi_hashmap::find_first(handlers, ice::hash(shard.id)); - while (it != nullptr) + auto it = handlers.find_values(shard.id); + while (it.has_next()) { ice::IceshardEventHandler const& handler = it.value(); @@ -102,7 +102,7 @@ namespace ice handler.procedure(userdata, params, shard) ); - it = ice::multi_hashmap::find_next(handlers, it); + it.next(); } } diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_types.hxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_types.hxx index 8827b691..618edd36 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_types.hxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_types.hxx @@ -1,11 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include "ip_ui_oven.hxx" #include #include -#include +#include namespace ice { diff --git a/source/code/modules/imgui_module/private/imgui_system.cxx b/source/code/modules/imgui_module/private/imgui_system.cxx index b56b6272..c382892c 100644 --- a/source/code/modules/imgui_module/private/imgui_system.cxx +++ b/source/code/modules/imgui_module/private/imgui_system.cxx @@ -8,6 +8,7 @@ #include #include #include +#include #if ISP_WINDOWS #include diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx b/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx index 6b94b35c..c37272e5 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx @@ -121,7 +121,7 @@ namespace ice arctic::String const potential_alias_key = identifier.substr(0, pos); ice::u64 const hash_alias_key = detail::arc_hash(potential_alias_key); - ASLScriptFile* const file = ice::hashmap::get(_aliases, hash_alias_key, nullptr); + ASLScriptFile* const file = _aliases.get(hash_alias_key, nullptr); ICE_ASSERT_CORE(file == nullptr || file->alias == potential_alias_key); if (file != nullptr) { @@ -145,8 +145,8 @@ namespace ice ice::u64 const hash_import_path = detail::arc_hash(import_path); ice::u64 const hash_import_alias = detail::arc_hash(import_alias); - Entry* const entry = ice::hashmap::try_get(_imports, hash_import_path); - ASLEntityTracker* const aliased = ice::hashmap::get(_aliases, hash_import_alias, nullptr); + Entry* const entry = _imports.try_get(hash_import_path); + ASLEntityTracker* const aliased = _aliases.get(hash_import_alias, nullptr); // The alias is either the same as the entry, or there is no alias ICE_ASSERT_CORE(entry == nullptr || entry->file.get() == aliased || aliased == nullptr); @@ -155,7 +155,7 @@ namespace ice // Safe the new alias if one was provided if (aliased == nullptr && import_alias.empty() == false) { - ice::hashmap::set(_aliases, hash_import_alias, entry->file.get()); + _aliases.set(hash_import_alias, entry->file.get()); } return; } @@ -185,7 +185,7 @@ namespace ice _global.push_back(import_entry.file.get()); // Store the whole entry. - ice::multi_hashmap::insert(_imports, detail::arc_hash(node.data().path), ice::move(import_entry)); + _imports.insert(detail::arc_hash(node.data().path), ice::move(import_entry)); } auto parse_import_file( diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_importer.hxx b/source/code/modules/shader_tools/private/shader_tools_asl_importer.hxx index 44422954..1291f016 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_importer.hxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_importer.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -59,7 +60,7 @@ namespace ice ice::ASLScriptLoader& _resolver; ice::Array _script_visitors; - ice::HashMap _imports; + ice::MultiHashMap _imports; ice::HashMap _aliases; ice::Array _global; }; diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_script.cxx b/source/code/modules/shader_tools/private/shader_tools_asl_script.cxx index 3b6f87e4..1b8344c8 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_script.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_script.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "shader_tools_asl_script.hxx" @@ -48,18 +48,18 @@ namespace ice ice::u64 const hash_identifier = detail::arc_hash(identifier); - arctic::SyntaxNode<> result = ice::hashmap::get(_usertypes, hash_identifier, arctic::SyntaxNode{}); + arctic::SyntaxNode<> result = _usertypes.get(hash_identifier, arctic::SyntaxNode{}); if (result == false) { - result = ice::hashmap::get(_functions, hash_identifier, arctic::SyntaxNode{}); + result = _functions.get(hash_identifier, arctic::SyntaxNode{}); } if (result == false) { - result = ice::hashmap::get(_native_functions, hash_identifier, arctic::SyntaxNode{}); + result = _native_functions.get(hash_identifier, arctic::SyntaxNode{}); } if (result == false) { - result = ice::hashmap::get(_variables, hash_identifier, arctic::SyntaxNode{}); + result = _variables.get(hash_identifier, arctic::SyntaxNode{}); } return result; } @@ -86,7 +86,7 @@ namespace ice } // Store the user type node - ice::multi_hashmap::insert(_usertypes, detail::arc_hash(node.data().name.value), ice::move(usertype)); + _usertypes.insert(detail::arc_hash(node.data().name.value), ice::move(usertype)); } void ASLScriptFile::visit(arctic::SyntaxNode node) noexcept @@ -105,7 +105,7 @@ namespace ice node.replace_annotation(ice::move(native_type)); // Store the user type node - ice::multi_hashmap::insert(_usertypes, detail::arc_hash(name), node); + _usertypes.insert(detail::arc_hash(name), node); } void ASLScriptFile::visit(arctic::SyntaxNode node) noexcept @@ -115,11 +115,11 @@ namespace ice // We ignore all non-native functions if (node.data().is_natvie == false) { - ice::multi_hashmap::insert(_native_functions, detail::arc_hash(node.data().name.value), node); + _native_functions.insert(detail::arc_hash(node.data().name.value), node); } else { - ice::multi_hashmap::insert(_functions, detail::arc_hash(node.data().name.value), node); + _functions.insert(detail::arc_hash(node.data().name.value), node); } } diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_script.hxx b/source/code/modules/shader_tools/private/shader_tools_asl_script.hxx index e3d700bb..5e48487a 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_script.hxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_script.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -7,7 +7,7 @@ #include "shader_tools_asl_database.hxx" #include "shader_tools_asl_utils.hxx" -#include +#include namespace ice { @@ -32,10 +32,10 @@ namespace ice private: ice::ASLAllocator& _allocator; - ice::HashMap> _usertypes; - ice::HashMap> _functions; - ice::HashMap> _native_functions; - ice::HashMap> _variables; + ice::MultiHashMap> _usertypes; + ice::MultiHashMap> _functions; + ice::MultiHashMap> _native_functions; + ice::MultiHashMap> _variables; }; } // namespace ice diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx b/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx index 63e73506..361ff09f 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include #include diff --git a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx index 2008f425..60efa744 100644 --- a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -84,7 +84,7 @@ namespace ice if (op && op.data().token.type == TokenType::CT_Dot) { arctic::String var_base = atom.data().value.value; - var_base = ice::hashmap::get(subs, detail::arc_hash(var_base), var_base); + var_base = subs.get(detail::arc_hash(var_base), var_base); ice::string::push_format(out_code, "{}.", var_base); generate_expression(out_code, subs, func, arg, op.sibling()); @@ -377,8 +377,8 @@ namespace ice ice::string::push_format(result, "\nvoid asl_proxy_{}(", shader._mainfunc.data().name.value); - ice::hashmap::set(subs, detail::arc_hash(arg.data().name.value), arctic::String{ "_a_inputs" }); - ice::hashmap::set(subs, detail::arc_hash(shader._mainfunc.data().name.value), arctic::String{ "_a_outputs" }); + subs.set(detail::arc_hash(arg.data().name.value), arctic::String{ "_a_inputs" }); + subs.set(detail::arc_hash(shader._mainfunc.data().name.value), arctic::String{ "_a_outputs" }); ice::string::push_format(result, "in {} _a_inputs, ", shader._inputs.data().name.value, arg.data().name.value); ice::string::push_format(result, "out {} _a_outputs) {{\n", shader._outputs.data().name.value, shader._mainfunc.data().name.value); generate_function(result, subs, shader._mainfunc.data(), arg.data(), ret.data(), body.child<>()); diff --git a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx index 0e3a10bc..0ef1a12b 100644 --- a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx @@ -77,7 +77,7 @@ namespace ice if (op && op.data().token.type == TokenType::CT_Dot) { arctic::String var_base = atom.data().value.value; - var_base = ice::hashmap::get(subs, detail::arc_hash(var_base), var_base); + var_base = subs.get(detail::arc_hash(var_base), var_base); ice::string::push_format(out_code, "{}.", var_base); generate_expression(out_code, subs, func, arg, op.sibling()); @@ -337,7 +337,7 @@ namespace ice shader._outputs.data().name.value ); ice::string::push_format(result, " var out: {};\n", shader._outputs.data().name.value); - ice::hashmap::set(subs, detail::arc_hash(shader._mainfunc.data().name.value), arctic::String{ "out" }); + subs.set(detail::arc_hash(shader._mainfunc.data().name.value), arctic::String{ "out" }); generate_function(result, subs, shader._mainfunc.data(), arg.data(), ret.data(), body.child()); result.push_back(" return out;\n"); result.push_back("}\n"); diff --git a/source/code/modules/vulkan_renderer/private/vk_allocator.hxx b/source/code/modules/vulkan_renderer/private/vk_allocator.hxx index a7b84b65..ad454278 100644 --- a/source/code/modules/vulkan_renderer/private/vk_allocator.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_allocator.hxx @@ -1,11 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include "vk_include.hxx" #include #include -#include +#include namespace ice::render::vk { diff --git a/source/code/modules/webgpu_renderer/private/webgpu_queue.hxx b/source/code/modules/webgpu_renderer/private/webgpu_queue.hxx index 9a70bf9c..30d91f2c 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_queue.hxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_queue.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -7,7 +7,7 @@ #include "webgpu_command_buffer.hxx" #include -#include +#include namespace ice::render::webgpu { diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx index ed1140de..d60b699e 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx @@ -2,6 +2,7 @@ /// SPDX-License-Identifier: MIT #include "win32_sdl2_platform_render_surface.hxx" +#include #include #include #include diff --git a/source/code/systems/asset_system/private/asset_shelve.cxx b/source/code/systems/asset_system/private/asset_shelve.cxx index e796959c..9d5f96a4 100644 --- a/source/code/systems/asset_system/private/asset_shelve.cxx +++ b/source/code/systems/asset_system/private/asset_shelve.cxx @@ -6,7 +6,7 @@ #include "asset_request_awaitable.hxx" #include -#include +#include #include #include #include @@ -47,17 +47,15 @@ namespace ice ice::StringID_Arg name ) noexcept -> ice::AssetEntry* { - return ice::hashmap::get(_asset_resources, ice::hash(name), nullptr); + return _asset_resources.get(name, nullptr); } auto AssetShelve::select( ice::StringID_Arg name ) const noexcept -> ice::AssetEntry const* { - ice::u64 const name_hash = ice::hash(name); - static ice::AssetEntry invalid_resource{ }; - return ice::hashmap::get(_asset_resources, name_hash, &invalid_resource); + return _asset_resources.get(name, &invalid_resource); } auto AssetShelve::store( @@ -74,22 +72,20 @@ namespace ice { ice::HeapString<> asset_name{ _allocator, name }; - ice::hashmap::set( - _asset_resources, + _asset_resources.set( name_hash, _allocator.create(ice::move(asset_name), this, ice::move(resource_data)) ); } else { - ice::hashmap::set( - _asset_resources, + _asset_resources.set( name_hash, _allocator.create(ice::stringid(name), this, ice::move(resource_data)) ); } - ice::AssetEntry** entry = ice::hashmap::try_get(_asset_resources, name_hash); + ice::AssetEntry* const* entry = _asset_resources.try_get(name_hash); ICE_ASSERT_CORE(entry != nullptr); ICE_ASSERT_CORE(*entry != nullptr); return *entry; @@ -113,22 +109,20 @@ namespace ice { ice::HeapString<> asset_name{ _allocator, name }; - ice::hashmap::set( - _asset_resources, + _asset_resources.set( name_hash, _allocator.create(ice::move(asset_name), this, ice::move(resource_data)) ); } else { - ice::hashmap::set( - _asset_resources, + _asset_resources.set( name_hash, _allocator.create(ice::stringid(name), this, ice::move(resource_data)) ); } - ice::AssetEntry** entry = ice::hashmap::try_get(_asset_resources, name_hash); + ice::AssetEntry* const* entry = _asset_resources.try_get(name_hash); ICE_ASSERT_CORE(entry != nullptr); ICE_ASSERT_CORE(*entry != nullptr); return *entry; diff --git a/source/code/systems/asset_system/private/asset_shelve.hxx b/source/code/systems/asset_system/private/asset_shelve.hxx index 81ee929d..47127617 100644 --- a/source/code/systems/asset_system/private/asset_shelve.hxx +++ b/source/code/systems/asset_system/private/asset_shelve.hxx @@ -1,7 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once +#include #include #include #include diff --git a/source/code/systems/asset_system/private/asset_shelve_devui.cxx b/source/code/systems/asset_system/private/asset_shelve_devui.cxx index eface9c9..5a511eb5 100644 --- a/source/code/systems/asset_system/private/asset_shelve_devui.cxx +++ b/source/code/systems/asset_system/private/asset_shelve_devui.cxx @@ -4,7 +4,7 @@ #include "asset_shelve_devui.hxx" #include -#include +#include #include namespace ice diff --git a/source/code/systems/asset_system/private/asset_storage.cxx b/source/code/systems/asset_system/private/asset_storage.cxx index a3198779..7b74dd17 100644 --- a/source/code/systems/asset_system/private/asset_storage.cxx +++ b/source/code/systems/asset_system/private/asset_storage.cxx @@ -9,6 +9,7 @@ #include "asset_transaction.hxx" #include +#include #include namespace ice @@ -251,7 +252,7 @@ namespace ice _asset_archive->find_definition(category), _asset_archive->find_compiler(category) ); - ice::hashmap::set(_asset_shelves, category.identifier, shelve); + _asset_shelves.set(category.identifier, shelve); if constexpr (ice::build::is_debug || ice::build::is_develop) { @@ -603,7 +604,7 @@ namespace ice ) noexcept -> ice::AssetRequest* { ice::AssetRequest* result = nullptr; - ice::AssetShelve* shelve = ice::hashmap::get(_asset_shelves, category.identifier, nullptr); + ice::AssetShelve* shelve = _asset_shelves.get(category.identifier, nullptr); if (shelve != nullptr) { result = shelve->aquire_request(requested_state); @@ -628,7 +629,7 @@ namespace ice { ice::StringID const nameid = ice::stringid(name); - shelve = ice::hashmap::get(_asset_shelves, category.identifier, nullptr); + shelve = _asset_shelves.get(category.identifier, nullptr); if (shelve != nullptr) { entry = shelve->select(nameid); diff --git a/source/code/systems/asset_system/private/asset_storage.hxx b/source/code/systems/asset_system/private/asset_storage.hxx index ad039ef3..01669e19 100644 --- a/source/code/systems/asset_system/private/asset_storage.hxx +++ b/source/code/systems/asset_system/private/asset_storage.hxx @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/asset_system/private/asset_type_archive.cxx b/source/code/systems/asset_system/private/asset_type_archive.cxx index 5c176112..0987ade4 100644 --- a/source/code/systems/asset_system/private/asset_type_archive.cxx +++ b/source/code/systems/asset_system/private/asset_type_archive.cxx @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -104,8 +104,7 @@ namespace ice } _types.push_back(category); - ice::hashmap::set( - _definitions, + _definitions.set( type_hash, InternalAssetCategory{ .category = category, @@ -124,7 +123,7 @@ namespace ice { static ice::InternalAssetCategory empty_type{}; - ice::InternalAssetCategory const& internal_type = ice::hashmap::get(_definitions, category.identifier, empty_type); + ice::InternalAssetCategory const& internal_type = _definitions.get(category.identifier, empty_type); return internal_type.definition; } @@ -134,7 +133,7 @@ namespace ice { static ice::InternalAssetCategory empty_type{}; - ice::InternalAssetCategory const& internal_type = ice::hashmap::get(_definitions, category.identifier, empty_type); + ice::InternalAssetCategory const& internal_type = _definitions.get(category.identifier, empty_type); return internal_type.has_compiler ? &internal_type.compiler : nullptr; } diff --git a/source/code/systems/input_action_system/private/input_action_layer.cxx b/source/code/systems/input_action_system/private/input_action_layer.cxx index c09169d0..3d4b7ba8 100644 --- a/source/code/systems/input_action_system/private/input_action_layer.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer.cxx @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -260,7 +260,7 @@ namespace ice { ice::String const action_name = _strings.substr(action.name); - ice::InputActionRuntime* const runtime = ice::hashmap::try_get(actions, ice::hash(action_name)); + ice::InputActionRuntime* const runtime = actions.try_get(ice::hash(action_name)); // TODO: Check if we need this //if (action.behavior != InputActionBehavior::Accumulated) { @@ -279,7 +279,7 @@ namespace ice { ice::InputActionInfo const checked_action_info = _actions[cond.source.source_index]; ice::String const checked_action_name = _strings.substr(checked_action_info.name); - checked_action = ice::hashmap::try_get(actions, ice::hash(checked_action_name)); + checked_action = actions.try_get(ice::hash(checked_action_name)); } ICE_ASSERT_CORE(checked_action != nullptr); cond_result = executor.execute_condition( @@ -379,7 +379,7 @@ namespace ice for (ice::InputActionInfo const& action : _actions) { ice::String const action_name = _strings.substr(action.name); - ice::InputActionRuntime* const runtime = ice::hashmap::try_get(actions, ice::hash(action_name)); + ice::InputActionRuntime* const runtime = actions.try_get(ice::hash(action_name)); // Handles 'Toggle'. We only activate of the first press, which is `state == 1`. if (action.behavior == InputActionBehavior::Toggled) diff --git a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx index e8f71c48..8a46cdda 100644 --- a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx @@ -4,7 +4,7 @@ #include "input_action_internal_types.hxx" #include #include -#include +#include #include #include @@ -238,8 +238,8 @@ namespace ice ice::InputActionSourceType type ) noexcept -> ice::InputActionBuilder::Source override { - ice::hashmap::set(_sources, ice::hash(name), {_allocator, name, type}); - return { ice::hashmap::try_get(_sources, ice::hash(name)) }; + _sources.set(name, {_allocator, name, type}); + return { _sources.try_get(ice::hash(name)) }; } auto define_action( @@ -247,8 +247,8 @@ namespace ice ice::InputActionDataType type ) noexcept -> ice::InputActionBuilder::Action override { - ice::hashmap::set(_actions, ice::hash(name), {_allocator, name, type}); - return { ice::hashmap::try_get(_actions, ice::hash(name)) }; + _actions.set(name, {_allocator, name, type}); + return { _actions.try_get(name) }; } auto finalize(ice::Allocator& alloc) noexcept -> ice::UniquePtr override @@ -512,7 +512,7 @@ namespace ice using enum ice::InputActionSourceType; ICE_ASSERT_CORE(internal().type == Key || internal().type == Button); - ice::hashmap::set(internal().events, ice::hash(key), input_identifier(DeviceType::Keyboard, key)); + internal().events.set(key, input_identifier(DeviceType::Keyboard, key)); return *this; } @@ -524,7 +524,7 @@ namespace ice ice::input::InputID const iid = input_identifier(DeviceType::Keyboard, keymod, ice::input::mod_identifier_base_value); ICE_ASSERT_CORE(internal().type == Key || internal().type == Button); - ice::hashmap::set(internal().events, ice::hash(iid), iid); + internal().events.set(iid, iid); return *this; } @@ -534,7 +534,7 @@ namespace ice using enum ice::InputActionSourceType; ICE_ASSERT_CORE(internal().type == Key || internal().type == Button); - ice::hashmap::set(internal().events, ice::hash(button), input_identifier(DeviceType::Mouse, button)); + internal().events.set(button, input_identifier(DeviceType::Mouse, button)); return *this; } @@ -544,7 +544,7 @@ namespace ice using enum ice::InputActionSourceType; ICE_ASSERT_CORE(internal().type == Key || internal().type == Button); - ice::hashmap::set(internal().events, ice::hash(button), input_identifier(DeviceType::Controller, button)); + internal().events.set(button, input_identifier(DeviceType::Controller, button)); return *this; } @@ -558,8 +558,8 @@ namespace ice ICE_ASSERT_CORE(axis == MouseInput::PositionX); if (axis == MouseInput::PositionX) { - ice::hashmap::set(internal().events, ice::hash(MouseInput::PositionX), input_identifier(DeviceType::Mouse, MouseInput::PositionX)); - ice::hashmap::set(internal().events, ice::hash(MouseInput::PositionY), input_identifier(DeviceType::Mouse, MouseInput::PositionY)); + internal().events.set(MouseInput::PositionX, input_identifier(DeviceType::Mouse, MouseInput::PositionX)); + internal().events.set(MouseInput::PositionY, input_identifier(DeviceType::Mouse, MouseInput::PositionY)); } return *this; } @@ -574,13 +574,13 @@ namespace ice ICE_ASSERT_CORE(axis == ControllerInput::LeftAxisX || axis == ControllerInput::RightAxisX); if (axis == ControllerInput::LeftAxisX) { - ice::hashmap::set(internal().events, ice::hash(axis), input_identifier(DeviceType::Controller, ControllerInput::LeftAxisX)); - ice::hashmap::set(internal().events, ice::hash(axis), input_identifier(DeviceType::Controller, ControllerInput::LeftAxisY)); + internal().events.set(axis, input_identifier(DeviceType::Controller, ControllerInput::LeftAxisX)); + internal().events.set(axis, input_identifier(DeviceType::Controller, ControllerInput::LeftAxisY)); } else if (axis == ControllerInput::RightAxisX) { - ice::hashmap::set(internal().events, ice::hash(axis), input_identifier(DeviceType::Controller, ControllerInput::RightAxisX)); - ice::hashmap::set(internal().events, ice::hash(axis), input_identifier(DeviceType::Controller, ControllerInput::RightAxisY)); + internal().events.set(axis, input_identifier(DeviceType::Controller, ControllerInput::RightAxisX)); + internal().events.set(axis, input_identifier(DeviceType::Controller, ControllerInput::RightAxisY)); } return *this; } diff --git a/source/code/systems/input_action_system/private/input_action_script.hxx b/source/code/systems/input_action_system/private/input_action_script.hxx index 52c817b9..8871fc04 100644 --- a/source/code/systems/input_action_system/private/input_action_script.hxx +++ b/source/code/systems/input_action_system/private/input_action_script.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -9,7 +9,7 @@ #include #include "input_action_script_syntax_data.hxx" -#include +#include namespace ice::asl { diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index fc2adce6..eba3098b 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -182,7 +182,7 @@ namespace ice { if (prev_name_hash != source_name_hash) { - values_index = ice::hashmap::try_get(_sources, source_name_hash)->index; + values_index = _sources.try_get(source_name_hash)->index; // Stores the index for the source _layers_sources_indices.push_back(values_index); @@ -206,7 +206,7 @@ namespace ice } // Save the index where we store the runtime value(s) - ice::hashmap::set(_sources, source_name_hash, { values_index }); + _sources.set(source_name_hash, { values_index }); // Stores the index for the source _layers_sources_indices.push_back(values_index); @@ -233,13 +233,13 @@ namespace ice // #TODO: Consider using refs instead? ice::HeapString<> final_name = _idprefix; final_name.push_back(action_name); - ice::hashmap::set(_action_names, action_name_hash, ice::move(final_name)); + _action_names.set(action_name_hash, ice::move(final_name)); - ice::HeapString<> const* final_name_ptr = ice::hashmap::try_get(_action_names, action_name_hash); + ice::HeapString<> const* final_name_ptr = _action_names.try_get(action_name_hash); ICE_ASSERT_CORE(final_name_ptr != nullptr); // Save the pointer where the values are stored - ice::hashmap::set(_actions, action_name_hash, { .type = action.type, .name = *final_name_ptr }); + _actions.set(action_name_hash, { .type = action.type, .name = *final_name_ptr }); } } @@ -301,12 +301,11 @@ namespace ice auto SimpleInputActionStack::action(ice::String action_name) const noexcept -> ice::Expected { - ice::InputActionRuntime const* action = ice::hashmap::try_get(_actions, ice::hash(action_name)); + ice::InputActionRuntime const* action = _actions.try_get(ice::hash(action_name)); if (action == nullptr && action_name.starts_with(_idprefix)) { // Try again after removing the prefix - action = ice::hashmap::try_get( - _actions, + action = _actions.try_get( ice::hash( action_name.substr(_idprefix.size()) ) @@ -486,7 +485,7 @@ namespace ice { static ice::InputActionRuntime invalid{.name=""}; ice::String const action_name = layer.action_name(action_info); - return ice::hashmap::get(_actions, ice::hash(action_name), invalid); + return _actions.get(action_name, invalid); } auto SimpleInputActionStack::source_runtime( @@ -497,9 +496,8 @@ namespace ice static ice::InputActionSource invalid{}; ice::String const source_name = layer.source_name(source_info); - ice::u32 const values_idx = ice::hashmap::get( - _sources, - ice::hash(source_name), + ice::u32 const values_idx = _sources.get( + source_name, {.index=ice::u32_max} ).index; diff --git a/source/code/systems/input_action_system/public/ice/input_action_layer.hxx b/source/code/systems/input_action_system/public/ice/input_action_layer.hxx index 2f867296..7400981a 100644 --- a/source/code/systems/input_action_system/public/ice/input_action_layer.hxx +++ b/source/code/systems/input_action_system/public/ice/input_action_layer.hxx @@ -3,9 +3,9 @@ #pragma once #include +#include #include #include -#include namespace ice { diff --git a/source/code/systems/input_system/private/input_tracker.cxx b/source/code/systems/input_system/private/input_tracker.cxx index 3c313a06..e1381503 100644 --- a/source/code/systems/input_system/private/input_tracker.cxx +++ b/source/code/systems/input_system/private/input_tracker.cxx @@ -1,8 +1,8 @@ /// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT +#include #include -#include #include #include "input_devices.hxx" @@ -65,11 +65,8 @@ namespace ice::input ice::input::DeviceFactory* device_factory ) noexcept { - // #todo handle duplicate type case - if (_factories.missing(ice::hash(type))) - { - ice::hashmap::set(_factories, ice::hash(type), device_factory); - } + ICE_ASSERT_CORE(_factories.missing(type)); + _factories.set_if_missing(type, device_factory); } void SimpleInputTracker::process_device_events( @@ -91,49 +88,43 @@ namespace ice::input if (event.message == DeviceMessage::DeviceConnected) { - ICE_ASSERT_CORE(ice::hashmap::get(_devices, device_hash, nullptr) == nullptr); + ICE_ASSERT_CORE(_devices.get(device_hash, nullptr) == nullptr); Device const device = ice::input::make_device(event.device); - DeviceFactory* const factory_func = ice::hashmap::get( - _factories, - ice::hash(device.type), - nullptr - ); + DeviceFactory* const factory_func = _factories.get(device.type, nullptr); if (factory_func != nullptr) { InputDevice* const device_state = factory_func(_allocator, event.device); ICE_ASSERT_CORE(device_state != nullptr); - ice::hashmap::set(_devices, device_hash, device_state); + _devices.set(device_hash, device_state); if (device_state->max_count() > 1) { - ice::hashmap::set(_devices, ice::hash(device.type), device_state); + _devices.set(ice::hash(device.type), device_state); } // #todo log device connected (shard?) } } else if (event.message == DeviceMessage::DeviceDisconnected) { - ICE_ASSERT_CORE(ice::hashmap::get(_devices, device_hash, nullptr) != nullptr); + ICE_ASSERT_CORE(_devices.get(device_hash, nullptr) != nullptr); - _allocator.destroy( - ice::hashmap::get(_devices, device_hash, nullptr) - ); + _allocator.destroy(_devices.get(device_hash, nullptr)); - ice::hashmap::remove(_devices, device_hash); + _devices.remove(device_hash); // #todo log device disconnected (shard?) } else if (_devices.has(device_hash)) { - InputDevice* const device = ice::hashmap::get(_devices, device_hash, nullptr); + InputDevice* const device = _devices.get(device_hash, nullptr); device->on_event(event); } else { // Support multiple device handles in a single InputDevice Device const device_info = ice::input::make_device(event.device); - InputDevice* const* const device_ptr = ice::hashmap::try_get(_devices, ice::hash(device_info.type)); + InputDevice* const* const device_ptr = _devices.try_get(ice::hash(device_info.type)); if (device_ptr != nullptr) { InputDevice* const device = *device_ptr; diff --git a/source/code/systems/resource_system/private/resource_filesystem_baked.hxx b/source/code/systems/resource_system/private/resource_filesystem_baked.hxx index ebe67860..6304735a 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_baked.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_baked.hxx @@ -8,7 +8,6 @@ #include #include #include -#include #include #include "resource_filesystem.hxx" diff --git a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx index 396ecb3b..bf2e371f 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_filesystem_loose.hxx b/source/code/systems/resource_system/private/resource_filesystem_loose.hxx index 0e261a36..1aec7f37 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_loose.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_loose.hxx @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/source/code/systems/resource_system/private/resource_filesystem_traverser.hxx b/source/code/systems/resource_system/private/resource_filesystem_traverser.hxx index 9bb718b5..b400fdae 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_traverser.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_traverser.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx index 8a9aed08..963f60ab 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_filesystem_writable.hxx b/source/code/systems/resource_system/private/resource_filesystem_writable.hxx index 1c9021ae..3466de3c 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_writable.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_writable.hxx @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/source/code/systems/resource_system/private/resource_provider_custom.cxx b/source/code/systems/resource_system/private/resource_provider_custom.cxx index 259d4b9e..62d389ce 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.cxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.cxx @@ -57,15 +57,13 @@ namespace ice if (resource != nullptr) { - ice::u64 const hash = ice::hash(resource->origin()); ICE_ASSERT( - _resources.missing(hash), + _resources.missing(resource->origin()), "A resource cannot be a explicit resource AND part of another resource." ); - ice::hashmap::set( - _resources, - hash, + _resources.set( + resource->origin(), resource ); } @@ -149,7 +147,7 @@ namespace ice ice::u64 const resource_hash = ice::hash(ice::String{ predicted_path }); - ice::FileSystemResource const* found_resource = ice::hashmap::get(_resources, resource_hash, nullptr); + ice::FileSystemResource const* found_resource = _resources.get(resource_hash, nullptr); if (found_resource != nullptr) { return found_resource; diff --git a/source/code/systems/resource_system/private/resource_provider_custom.hxx b/source/code/systems/resource_system/private/resource_provider_custom.hxx index 15456f89..23ee93b1 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.hxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.hxx @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx index 19e87ce9..8f55dfc5 100644 --- a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx +++ b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -45,8 +45,7 @@ namespace ice ice::URI const& uri ) const noexcept -> ice::Resource* override { - ice::u64 const resource_hash = ice::hash(uri.path()); - return ice::hashmap::get(_resources, resource_hash, nullptr); + return _resources.get(uri.path(), nullptr); } void on_library_file( @@ -72,7 +71,7 @@ namespace ice } else { - ice::hashmap::set(_resources, resource_hash, resource); + _resources.set(resource_hash, resource); } } diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index b18b93fd..020c1b29 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -114,17 +114,12 @@ namespace ice resource->data_index = _resources_data.size().u32(); _resources_data.push_back(ice::Memory{}); - ice::u64 const hash = ice::hash(resource->uri().path()); ICE_ASSERT( - _resources.missing(hash), + _resources.missing(resource->uri().path()), "A resource cannot be a explicit resource AND part of another resource." ); - ice::hashmap::set( - _resources, - hash, - resource - ); + _resources.set(resource->uri().path(), resource); } } @@ -185,9 +180,7 @@ namespace ice ice::native_file::path_to_string(file_entry.path, predicted_path); ice::path::normalize(predicted_path); - ice::u64 const resource_hash = ice::hash(uri.path()); - found_resource = ice::hashmap::get(_resources, resource_hash, nullptr); - if (found_resource != nullptr) + if (found_resource = _resources.get(uri.path(), nullptr); found_resource != nullptr) { break; } @@ -238,9 +231,7 @@ namespace ice ice::path::join(predicted_path, relative_uri.path()); ice::path::normalize(predicted_path); - ice::u64 const resource_hash = ice::hash(ice::String{ predicted_path }); - - ice::FileSystemResource const* found_resource = ice::hashmap::get(_resources, resource_hash, nullptr); + ice::FileSystemResource const* found_resource = _resources.get(predicted_path, nullptr); if (found_resource != nullptr) { return found_resource; diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.hxx b/source/code/systems/resource_system/private/resource_provider_filelist.hxx index 3e14c78a..5038d1bc 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.hxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.hxx @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx index 798ab00a..6af10cbd 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx @@ -174,8 +174,7 @@ namespace ice ice::path::join(predicted_path, uri.path()); ice::path::normalize(predicted_path); - ice::u64 const resource_hash = ice::hash(ice::String{ predicted_path }); - found_resource = ice::hashmap::get(_resources, resource_hash, nullptr); + found_resource = _resources.get(predicted_path, nullptr); if (found_resource != nullptr) { break; @@ -227,17 +226,7 @@ namespace ice ice::path::join(predicted_path, relative_uri.path()); ice::path::normalize(predicted_path); - ice::u64 const resource_hash = ice::hash(ice::String{ predicted_path }); - - ice::FileSystemResource const* found_resource = ice::hashmap::get(_resources, resource_hash, nullptr); - if (found_resource != nullptr) - { - return found_resource; - } - else - { - return nullptr; - } + return _resources.get(predicted_path, nullptr); } #pragma region Implementation of: FileSystemTraverser @@ -288,18 +277,11 @@ namespace ice resource->data_index = _resources_data.size().u32(); _resources_data.push_back(ice::Memory{}); - ice::u64 const hash = ice::hash(resource->origin()); ICE_ASSERT( - _resources.missing(hash), + _resources.missing(resource->origin()), "A resource cannot be a explicit resource AND part of another resource." ); - - ice::hashmap::set( - _resources, - hash, - resource - ); - + _resources.set(resource->origin(), resource); return S_Ok; } diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.hxx b/source/code/systems/resource_system/private/resource_provider_filesystem.hxx index 7ca268ad..83c3f911 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.hxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.hxx @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx index a5542bc9..aaec5c8a 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx @@ -3,6 +3,7 @@ #include "resource_aio_request.hxx" #include "resource_provider_hailstorm.hxx" +#include namespace ice { @@ -162,8 +163,8 @@ namespace ice ice::u32 size ) noexcept { - ice::u32 const ptr_idx = ice::hashmap::get_or_set( - _offset_map, offset, _offset_map.size().u32() + ice::u32 const ptr_idx = _offset_map.get_or_set( + offset, _offset_map.size().u32() ); // Why would we free something that was never allocated? ICE_ASSERT_CORE(_pointers[ptr_idx] != nullptr); @@ -176,8 +177,8 @@ namespace ice ice::native_aio::AIOPort aioport ) noexcept -> ice::Task { - ice::u32 const ptr_idx = ice::hashmap::get_or_set( - _offset_map, offset, _offset_map.size().u32() + ice::u32 const ptr_idx = _offset_map.get_or_set( + offset, _offset_map.size().u32() ); if (_pointers[ptr_idx] == nullptr) { @@ -361,7 +362,7 @@ namespace ice ); } - ice::multi_hashmap::insert(_entrymap, ice::hash(res_uri.path()), idx); + _entrymap.insert(res_uri.path(), idx); out_changes.push_back(_entries[idx]); } @@ -375,14 +376,14 @@ namespace ice ) const noexcept -> ice::Resource* { u32 idx = ice::u32_max; - auto it = ice::multi_hashmap::find_first(_entrymap, ice::hash(uri.path())); - while (it != nullptr && idx == ice::u32_max) + auto it = _entrymap.find_values(uri.path()); + while (it.has_next() && idx == ice::u32_max) { if (_entries[it.value()]->name() == uri.path()) { idx = it.value(); } - it = ice::multi_hashmap::find_next(_entrymap, it); + it.next(); } if (idx != ice::u32_max) diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx index 4184bbb8..cdb367ba 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include #include #include #include @@ -206,7 +206,7 @@ namespace ice hailstorm::v1::HailstormData _pack; ice::Array _loaders; ice::Array _entries; - ice::HashMap _entrymap; + ice::MultiHashMap _entrymap; ice::UniquePtr _devui_widget; }; diff --git a/source/code/systems/resource_system/private/resource_tracker.cxx b/source/code/systems/resource_system/private/resource_tracker.cxx index a0c08a00..e6ff4a14 100644 --- a/source/code/systems/resource_system/private/resource_tracker.cxx +++ b/source/code/systems/resource_system/private/resource_tracker.cxx @@ -71,13 +71,7 @@ namespace ice ice::UniquePtr provider ) noexcept -> ice::ResourceProvider* { - ice::ResourceProvider* const result = provider.get(); - ice::multi_hashmap::insert( - _resource_providers, - ice::hash(provider->schemeid()), - ice::move(provider) - ); - return result; + return _resource_providers.insert(provider->schemeid(), ice::move(provider)).get(); } auto ResourceTrackerImplementation::attach_writer( @@ -88,12 +82,7 @@ namespace ice ice::ResourceProvider* const provider = attach_provider(ice::move(writer)); ICE_ASSERT_CORE(provider != nullptr); - ice::multi_hashmap::insert( - _resource_writers, - ice::hash(result->schemeid()), - result - ); - return result; + return _resource_writers.insert(result->schemeid(), result); } void ResourceTrackerImplementation::sync_resources() noexcept @@ -276,7 +265,7 @@ namespace ice ice::u64 const hash_scheme = ice::hash(resource_uri.scheme()); ice::ResourceWriter* writer = nullptr; - auto it = ice::multi_hashmap::find_first(_resource_writers, hash_scheme); + auto it = _resource_writers.find_values(hash_scheme); while (it != nullptr) { [[maybe_unused]] @@ -287,7 +276,7 @@ namespace ice { writer = candidate_writer; } - it = ice::multi_hashmap::find_next(_resource_writers, it); + it.next(); } if (writer == nullptr) @@ -303,7 +292,7 @@ namespace ice ); // TODO: Only save the new resource if it's not yet there. - ice::multi_hashmap::insert(_resources, ice::hash(resource->name()), resource); + _resources.insert(resource->name(), resource); } co_return ice::ResourceHandle{ resource }; @@ -359,11 +348,7 @@ namespace ice IPT_ZONE_SCOPED_NAMED("create_hash_entries"); for (ice::Resource* resource : out_resources) { - ice::multi_hashmap::insert( - _resources, - ice::hash(resource->name()), - resource - ); + _resources.insert(resource->name(), resource); } } @@ -382,8 +367,8 @@ namespace ice ice::u64 const hash_resouce = ice::hash(resource_urn.path()); // Just grab the first for now - auto it = ice::multi_hashmap::find_first(_resources, hash_resouce); - if (it != nullptr) + auto it = _resources.find_values(hash_resouce); + if (it.has_next()) { result = ice::ResourceHandle{ it.value() }; } @@ -406,7 +391,7 @@ namespace ice // TODO: Remove this abomination, we only need to remove the const'ness in the 'find' functions for the resource object. ice::u64 const hash_resouce = ice::hash(resource->name()); - auto it = ice::multi_hashmap::find_first(_resources, hash_resouce); + auto it = _resources.find_values(hash_resouce); while (it != nullptr && handle == nullptr) { if ((*it) == resource) @@ -415,7 +400,7 @@ namespace ice } else { - it = ice::multi_hashmap::find_next(_resources, it); + it.next(); } } @@ -430,7 +415,7 @@ namespace ice { ice::u64 const hash_scheme = ice::hash(resource_uri.scheme()); - auto it = ice::multi_hashmap::find_first(_resource_providers, hash_scheme); + auto it = _resource_providers.find_values(hash_scheme); while (it != nullptr && provider == nullptr) { if (resource = (*it)->find_resource(resource_uri); resource != nullptr) @@ -439,7 +424,7 @@ namespace ice } else { - it = ice::multi_hashmap::find_next(_resource_providers, it); + it.next(); } } diff --git a/source/code/systems/resource_system/private/resource_tracker.hxx b/source/code/systems/resource_system/private/resource_tracker.hxx index 88b8e4b2..b4af5b6a 100644 --- a/source/code/systems/resource_system/private/resource_tracker.hxx +++ b/source/code/systems/resource_system/private/resource_tracker.hxx @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -226,9 +226,9 @@ namespace ice ice::ProxyAllocator _allocator_data; ice::ResourceTrackerCreateInfo _info; - ice::HashMap _resources; - ice::HashMap, ContainerLogic::Complex> _resource_providers; - ice::HashMap _resource_writers; + ice::MultiHashMap _resources; + ice::MultiHashMap, ContainerLogic::Complex> _resource_providers; + ice::MultiHashMap _resource_writers; ice::UniquePtr _devui_widget; }; diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx index 3155c2f2..0c850fd9 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx @@ -166,8 +166,7 @@ namespace ice ice::path::join(predicted_path, uri.path()); ice::path::normalize(predicted_path); - ice::u64 const resource_hash = ice::hash(ice::String{ predicted_path }); - return ice::hashmap::get(_resources, resource_hash, nullptr); + return _resources.get(predicted_path, nullptr); } auto FileSystemResourceWriter::access_loose_resource( @@ -213,17 +212,7 @@ namespace ice ice::path::join(predicted_path, relative_uri.path()); ice::path::normalize(predicted_path); - ice::u64 const resource_hash = ice::hash(ice::String{ predicted_path }); - - ice::WritableFileSystemResource const* found_resource = ice::hashmap::get(_resources, resource_hash, nullptr); - if (found_resource != nullptr) - { - return found_resource; - } - else - { - return nullptr; - } + return _resources.get(predicted_path, nullptr); } auto FileSystemResourceWriter::create_resource( @@ -336,18 +325,11 @@ namespace ice resource->data_index = _resources_data.size().u32(); _resources_data.push_back(ice::Memory{}); - ice::u64 const hash = ice::hash(resource->origin()); ICE_ASSERT( - _resources.missing(hash), + _resources.missing(resource->origin()), "A resource cannot be a explicit resource AND part of another resource." ); - - ice::hashmap::set( - _resources, - hash, - resource - ); - + _resources.set(resource->origin(), resource); return S_Ok; } diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.hxx b/source/code/systems/resource_system/private/resource_writer_filesystem.hxx index 7fcc0968..de4820b2 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.hxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.hxx @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/public/ice/resource.hxx b/source/code/systems/resource_system/public/ice/resource.hxx index 8c639218..00ceee1f 100644 --- a/source/code/systems/resource_system/public/ice/resource.hxx +++ b/source/code/systems/resource_system/public/ice/resource.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace ice diff --git a/source/code/systems/resource_system/public/ice/resource_provider.hxx b/source/code/systems/resource_system/public/ice/resource_provider.hxx index e553dd7c..68a0f70a 100644 --- a/source/code/systems/resource_system/public/ice/resource_provider.hxx +++ b/source/code/systems/resource_system/public/ice/resource_provider.hxx @@ -3,10 +3,10 @@ #pragma once #include -#include +#include #include #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/public/ice/resource_tracker.hxx b/source/code/systems/resource_system/public/ice/resource_tracker.hxx index 78fb0e2d..8643160e 100644 --- a/source/code/systems/resource_system/public/ice/resource_tracker.hxx +++ b/source/code/systems/resource_system/public/ice/resource_tracker.hxx @@ -3,9 +3,9 @@ #pragma once #include +#include #include #include -#include #include #include #include diff --git a/source/code/systems/resource_system/tests/test_resource_meta.cxx b/source/code/systems/resource_system/tests/test_resource_meta.cxx index 772b9f27..a451da5b 100644 --- a/source/code/systems/resource_system/tests/test_resource_meta.cxx +++ b/source/code/systems/resource_system/tests/test_resource_meta.cxx @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include namespace Catch From 0078af48e3ffc15cbe9e323d357dac5e0fb1ec50 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sun, 18 Jan 2026 23:15:24 +0900 Subject: [PATCH 29/40] Fix missing license headers. --- source/code/core/collections/public/ice/multi_hashmap.hxx | 3 +++ source/code/core/collections/public/ice/static_array.hxx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/source/code/core/collections/public/ice/multi_hashmap.hxx b/source/code/core/collections/public/ice/multi_hashmap.hxx index dce02f3f..0f699278 100644 --- a/source/code/core/collections/public/ice/multi_hashmap.hxx +++ b/source/code/core/collections/public/ice/multi_hashmap.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include diff --git a/source/code/core/collections/public/ice/static_array.hxx b/source/code/core/collections/public/ice/static_array.hxx index c6b2a93b..3a763c4a 100644 --- a/source/code/core/collections/public/ice/static_array.hxx +++ b/source/code/core/collections/public/ice/static_array.hxx @@ -1,3 +1,6 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include From bbe30df922abab272f9403a3efbb8e83f5b149bd Mon Sep 17 00:00:00 2001 From: Dandielo Date: Mon, 19 Jan 2026 22:44:50 +0900 Subject: [PATCH 30/40] Refactor the 'ShardContainer' type. * Instead of a "Array" field it now derived from Array, since it's now just extending/specializing the API interface. * Additional smaller cleanup in other parts. --- .../ice/container/container_concepts.hxx | 12 +- .../ice/{ => container}/container_logic.hxx | 0 .../public/ice/container/hashmap_details.hxx | 21 +- .../public/ice/container/linked_queue.hxx | 2 +- .../public/ice/container_concepts.hxx | 15 - .../public/ice/shard_container.hxx | 428 +++++------------- .../code/core/collections/public/ice/span.hxx | 2 +- .../tests/test_shard_container.cxx | 263 +++++------ 8 files changed, 266 insertions(+), 477 deletions(-) rename source/code/core/collections/public/ice/{ => container}/container_logic.hxx (100%) delete mode 100644 source/code/core/collections/public/ice/container_concepts.hxx diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index a3cd3b11..230cc1c9 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -6,7 +6,17 @@ #include #include #include -#include +#include + +namespace ice +{ + + template + concept LinkedListNode = requires(Node node) { + { node.next } -> std::convertible_to; + }; + +} // namespace ice namespace ice::concepts { diff --git a/source/code/core/collections/public/ice/container_logic.hxx b/source/code/core/collections/public/ice/container/container_logic.hxx similarity index 100% rename from source/code/core/collections/public/ice/container_logic.hxx rename to source/code/core/collections/public/ice/container/container_logic.hxx diff --git a/source/code/core/collections/public/ice/container/hashmap_details.hxx b/source/code/core/collections/public/ice/container/hashmap_details.hxx index 70794b4d..c9621957 100644 --- a/source/code/core/collections/public/ice/container/hashmap_details.hxx +++ b/source/code/core/collections/public/ice/container/hashmap_details.hxx @@ -3,21 +3,12 @@ #pragma #include -#include +#include #include namespace ice { - namespace container - { - } - - namespace concepts::hashmap - { - - } // namespace concepts - namespace detail::hashmap { @@ -46,11 +37,6 @@ namespace ice ice::u32 entry_i; }; - constexpr auto calc_value_capacity(ice::ncount raw_capacity) noexcept -> ice::ncount - { - return static_cast(raw_capacity.native() * Constant_HashMapMaxFill); - } - constexpr auto calc_required_capacity(ice::ncount max_count) noexcept -> ice::ncount { return static_cast( @@ -63,11 +49,6 @@ namespace ice return calc_required_capacity(max_count); } - constexpr bool can_store_expected_size(ice::ncount raw_capacity, ice::ncount expected_size) noexcept - { - return calc_value_capacity(raw_capacity) >= expected_size; - } - template constexpr auto calc_meminfo(ice::ncount capacity) noexcept -> ice::meminfo { diff --git a/source/code/core/collections/public/ice/container/linked_queue.hxx b/source/code/core/collections/public/ice/container/linked_queue.hxx index b5aa9d06..266299ec 100644 --- a/source/code/core/collections/public/ice/container/linked_queue.hxx +++ b/source/code/core/collections/public/ice/container/linked_queue.hxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include namespace ice diff --git a/source/code/core/collections/public/ice/container_concepts.hxx b/source/code/core/collections/public/ice/container_concepts.hxx deleted file mode 100644 index 39a52f10..00000000 --- a/source/code/core/collections/public/ice/container_concepts.hxx +++ /dev/null @@ -1,15 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include - -namespace ice -{ - - template - concept LinkedListNode = requires(Node node) { - { node.next } -> std::convertible_to; - }; - -} // namespace ice diff --git a/source/code/core/collections/public/ice/shard_container.hxx b/source/code/core/collections/public/ice/shard_container.hxx index a7ca2622..5bfe5dde 100644 --- a/source/code/core/collections/public/ice/shard_container.hxx +++ b/source/code/core/collections/public/ice/shard_container.hxx @@ -8,369 +8,181 @@ namespace ice { - struct ShardContainer + struct ShardContainer : public ice::Array { - using Iterator = ice::Array::Iterator; - using ConstIterator = ice::Array::ConstIterator; + using ice::Array::Array; - inline explicit ShardContainer(ice::Allocator& alloc) noexcept; - inline ShardContainer(ice::ShardContainer&& other) noexcept; - inline ShardContainer(ice::ShardContainer const& other) noexcept; - inline ~ShardContainer() noexcept; + constexpr bool contains(ice::ShardID shardid) const noexcept; + constexpr auto count_of(ice::ShardID shardid) const noexcept -> ice::ncount; - inline auto operator=(ice::ShardContainer&& other) noexcept -> ice::ShardContainer&; - inline auto operator=(ice::ShardContainer const& other) noexcept -> ice::ShardContainer&; + constexpr auto find_first_of( + ice::ShardID shardid, + ice::nindex offset = ice::nindex_none + ) const noexcept -> ice::Shard; - inline operator ice::Span() const noexcept { return _data; } - - ice::Array _data; - }; - - namespace shards - { - - inline void reserve(ice::ShardContainer& container, ice::u32 new_capacity) noexcept; - - inline void resize(ice::ShardContainer& container, ice::u32 new_size) noexcept; - - inline void clear(ice::ShardContainer& container) noexcept; - - inline void push_back(ice::ShardContainer& container, ice::Shard value) noexcept; - - inline void push_back(ice::ShardContainer& container, ice::Span values) noexcept; - - inline void remove_all_of(ice::ShardContainer& container, ice::ShardID value) noexcept; - - inline auto begin(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator; - - inline auto end(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator; - - - inline auto empty(ice::ShardContainer const& container) noexcept -> bool; - - inline auto size(ice::ShardContainer const& container) noexcept -> ice::u32; - - inline auto capacity(ice::ShardContainer const& container) noexcept -> ice::u32; - - inline auto count(ice::ShardContainer const& container, ice::ShardID expected_shard) noexcept -> ice::u32; - - inline bool contains(ice::ShardContainer const& container, ice::ShardID expected_shard) noexcept; - - inline auto find_first_of(ice::ShardContainer const& container, ice::ShardID expected_shard, ice::u32 offset = ~0) noexcept -> ice::Shard; - - inline auto find_last_of(ice::ShardContainer const& container, ice::ShardID expected_shard, ice::u32 offset = ~0) noexcept -> ice::Shard; - - template - inline auto for_each(ice::ShardContainer const& container, ice::ShardID shard_type, Fn&& callback) noexcept -> ice::u32; + constexpr auto find_last_of( + ice::ShardID shardid, + ice::nindex offset = ice::nindex_none + ) const noexcept -> ice::Shard; template - inline auto for_each(ice::ShardContainer const& container, ice::ShardID shard_type, Fn&& callback, Args&&... args) noexcept -> ice::u32; + inline constexpr auto for_each( + ice::ShardID shardid, + Fn&& callback, + Args&&... args + ) const noexcept -> ice::ncount; template - inline auto inspect_all(ice::ShardContainer const& container, ice::ShardID shard_type, ice::Array& payloads) noexcept -> ice::u32; + inline constexpr auto inspect_all( + ice::ShardID shardid, + ice::Array& payloads + ) const noexcept -> ice::ncount; template - inline auto inspect_each(ice::ShardContainer const& container, ice::ShardID shard_type, Fn&& callback) noexcept -> ice::u32; + inline constexpr auto inspect_each( + ice::ShardID shardid, + Fn&& callback + ) noexcept -> ice::ncount; template - inline bool inspect_first(ice::ShardContainer const& container, ice::ShardID shard, T& payload) noexcept; - - template - inline bool inspect_first(ice::ShardContainer const& container, ice::ShardID shard_type, T(&payload)[Size]) noexcept; + inline constexpr bool inspect_first(ice::ShardID shardid, T& payload) const noexcept; template - inline bool inspect_last(ice::ShardContainer const& container, ice::ShardID shard, T& payload) noexcept; - - inline auto begin(ice::ShardContainer const& container) noexcept -> ice::ShardContainer::ConstIterator; - - inline auto end(ice::ShardContainer const& container) noexcept -> ice::ShardContainer::ConstIterator; - - } // namespace shard - - inline ShardContainer::ShardContainer(ice::Allocator& alloc) noexcept - : _data{ alloc } - { - } - - inline ShardContainer::ShardContainer(ShardContainer&& other) noexcept - : _data{ ice::move(other._data) } - { - } - - inline ShardContainer::ShardContainer(ShardContainer const& other) noexcept - : _data{ other._data } - { - } + inline constexpr bool inspect_last(ice::ShardID shard, T& payload) const noexcept; - inline ShardContainer::~ShardContainer() noexcept - { - } + inline constexpr void remove_all_of(this ShardContainer& self, ice::ShardID shardid) noexcept; + }; - inline auto ShardContainer::operator=(ShardContainer&& other) noexcept -> ice::ShardContainer& + inline constexpr bool ShardContainer::contains(ice::ShardID expected_shard) const noexcept { - if (this != &other) - { - _data = ice::move(other._data); - } - return *this; + return this->find_first_of(expected_shard) != Shard_Invalid; } - inline auto ShardContainer::operator=(ShardContainer const& other) noexcept -> ice::ShardContainer& + inline constexpr auto ShardContainer::count_of(ice::ShardID shardid) const noexcept -> ice::ncount { - if (this != &other) + ice::u32 count = 0; + for (ice::Shard const shard : (*this)) { - _data = other._data; + count += (shard == shardid); } - return *this; + return { count, sizeof(ice::Shard) }; } - namespace shards + inline constexpr auto ice::ShardContainer::find_first_of( + ice::ShardID shardid, + ice::nindex offset + ) const noexcept -> ice::Shard { - - inline void reserve(ice::ShardContainer& container, ice::u32 new_capacity) noexcept - { - container._data.reserve(new_capacity); - } - - inline void resize(ice::ShardContainer& container, ice::u32 new_size) noexcept - { - container._data.resize(new_size); - } - - inline void clear(ice::ShardContainer& container) noexcept - { - container._data.clear(); - } - - inline void push_back(ice::ShardContainer& container, ice::Shard value) noexcept - { - container._data.push_back(value); - } - - inline void push_back(ice::ShardContainer& container, ice::Span values) noexcept - { - container._data.push_back(values); - } - - inline void remove_all_of(ice::ShardContainer& container, ice::ShardID value) noexcept - { - ice::Array& data = container._data; - ice::ncount count = data.size(); - - for (ice::u32 idx = 0; idx < count; ++idx) - { - if (data[idx] == value) - { - count -= 1; - data[idx] = data[count]; - } - } - - data.resize(count); - } - - inline auto begin(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator - { - return container._data.begin(); - } - - inline auto end(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator - { - return container._data.end(); - } - - - inline auto empty(ice::ShardContainer const& container) noexcept -> bool - { - return container._data.is_empty(); - } - - inline auto size(ice::ShardContainer const& container) noexcept -> ice::u32 - { - return container._data.size().u32(); - } - - inline auto capacity(ice::ShardContainer const& container) noexcept -> ice::u32 + for (ice::Shard shard : tailspan(offset.min_value_or(size(), 0_index))) { - return container._data.capacity().u32(); - } - - inline auto count(ice::ShardContainer const& container, ice::ShardID expected_shard) noexcept -> ice::u32 - { - ice::u32 count = 0; - for (ice::Shard const shard : container._data) + if (shard == shardid) { - count += (shard == expected_shard); + return shard; } - return count; - } - - inline bool contains(ice::ShardContainer const& container, ice::ShardID expected_shard) noexcept - { - return ice::shards::count(container, expected_shard) > 0; } + return ice::Shard_Invalid; + } - inline auto find_first_of(ice::ShardContainer const& container, ice::ShardID shard, ice::u32 offset) noexcept -> ice::Shard - { - auto it = container._data.begin(); - auto const end = container._data.end(); - - if (offset != ~0) - { - it = std::next(it, ice::min(offset, ice::shards::size(container))); - } - - ice::Shard result = ice::Shard_Invalid; - while (it != end) - { - if ((*it) == shard) - { - result = *it; - it = end; - } - else - { - it += 1; - } - } - return result; - } + inline constexpr auto ShardContainer::find_last_of( + ice::ShardID shardid, + ice::nindex offset + ) const noexcept -> ice::Shard + { + ice::ncount const size = this->size(); + ice::Span const headlist = this->headspan(size - offset.min_value_or(size, 0_count)); - inline auto find_last_of(ice::ShardContainer const& container, ice::ShardID shard, ice::u32 offset) noexcept -> ice::Shard + auto it = headlist.rbegin(); + auto const end = headlist.rend(); + while (it != end && *it != shardid) { - auto it = container._data.rbegin(); - auto const end = container._data.rend(); - - if (offset != ~0) - { - it = std::next(it, ice::min(offset, ice::shards::size(container))); - } - - ice::Shard result = ice::Shard_Invalid; - while (it != end) - { - if ((*it) == shard) - { - result = *it; - it = end; - } - else - { - it += 1; - } - } - return result; + it += 1; } + return it != end ? *it : Shard_Invalid; + } - template - inline auto for_each(ice::ShardContainer const& container, ice::ShardID shard_type, Fn&& callback) noexcept -> ice::u32 + template + inline constexpr auto ShardContainer::for_each( + ice::ShardID shardid, + Fn&& callback, + Args&&... args + ) const noexcept -> ice::ncount + { + ice::u32 count = 0; + for (ice::Shard const shard : this->tailspan(0)) { - ice::u32 count = 0; - for (ice::Shard const shard : container._data) + if (shard == shardid) { - if (shard == shard_type) - { - ice::forward(callback)(shard); - } + ice::forward(callback)(shard, ice::forward(args)...); } - return count; } + return { count, sizeof(ice::Shard) }; + } - template - inline auto for_each(ice::ShardContainer const& container, ice::ShardID shard_type, Fn&& callback, Args&&... args) noexcept -> ice::u32 + template + inline constexpr auto ShardContainer::inspect_all( + ice::ShardID shardid, + ice::Array& payloads + ) const noexcept -> ice::ncount + { + T payload; + ice::u32 count = 0; + for (ice::Shard const shard : this->tailspan(0)) { - ice::u32 count = 0; - for (ice::Shard const shard : container._data) + if (shard == shardid && ice::shard_inspect(shard, payload)) { - if (shard == shard_type) - { - ice::forward(callback)(shard, ice::forward(args)...); - } + payloads.push_back(payload); + count += 1; } - return count; } + return { count, sizeof(ice::ShardID) }; + } - template - inline auto inspect_all(ice::ShardContainer const& container, ice::ShardID shard_type, ice::Array& payloads) noexcept -> ice::u32 + template + inline constexpr auto ShardContainer::inspect_each(ice::ShardID shardid, Fn&& callback) noexcept -> ice::ncount + { + T payload; + ice::u32 count = 0; + for (ice::Shard const shard : this->tailspan(0)) { - T payload; - ice::u32 count = 0; - for (ice::Shard const shard : container._data) + if (shard == shardid && ice::shard_inspect(shard, payload)) { - if (shard == shard_type && ice::shard_inspect(shard, payload)) - { - payloads.push_back(payload); - count += 1; - } + ice::forward(callback)(payload); } - return count; } + return { count, sizeof(ice::Shard) }; + } - template - inline auto inspect_each(ice::ShardContainer const& container, ice::ShardID shard_type, Fn&& callback) noexcept -> ice::u32 - { - T payload; - ice::u32 count = 0; - for (ice::Shard const shard : container._data) - { - if (shard == shard_type && ice::shard_inspect(shard, payload)) - { - ice::forward(callback)(payload); - } - } - return count; - } + template + inline constexpr bool ShardContainer::inspect_first(ice::ShardID shardid, T& payload) const noexcept + { + ice::Shard const shard = this->find_first_of(shardid); + return ice::shard_inspect(shard, payload); + } - template - inline bool inspect_first(ice::ShardContainer const& container, ice::ShardID shard_type, T& payload) noexcept - { - ice::Shard const shard = ice::shards::find_first_of(container, shard_type); - return ice::shard_inspect(shard, payload); - } + template + inline constexpr bool ShardContainer::inspect_last(ice::ShardID shardid, T& payload) const noexcept + { + ice::Shard const shard = this->find_last_of(shardid); + return ice::shard_inspect(shard, payload); + } - template - inline bool inspect_first(ice::ShardContainer const& container, ice::ShardID shard_type, T(&payload)[Size]) noexcept + inline constexpr void ShardContainer::remove_all_of( + this ShardContainer& self, + ice::ShardID shardid + ) noexcept + { + // We move shards from the end of the array to the locations we want to removed. + // Finaly we resize the array ensuring the tail values are no longer accessed. + ice::u32 count = self.size().u32(); + for (ice::u32 idx = 0; idx < count; ++idx) { - auto it = container._data.begin(); - auto const end = container._data.end(); - - ice::u32 idx = 0; - while (it != end && idx < Size) + if (self[idx] == shardid) { - if ((*it) == shard_type) - { - ice::shard_inspect(*it, payload[idx]); - it += 1; - idx += 1; - } - else - { - it += 1; - } + count -= 1; + self[idx] = self[count]; } - - return idx == Size; - } - - template - inline bool inspect_last(ice::ShardContainer const& container, ice::ShardID shard_type, T& payload) noexcept - { - ice::Shard const shard = ice::shards::find_last_of(container, shard_type); - return ice::shard_inspect(shard, payload); - } - - inline auto begin(ice::ShardContainer const& container) noexcept -> ice::ShardContainer::ConstIterator - { - return container._data.begin(); - } - - inline auto end(ice::ShardContainer const& container) noexcept -> ice::ShardContainer::ConstIterator - { - return container._data.end(); } + self.resize(count); } - using shards::begin; - using shards::end; - } // namespace ice diff --git a/source/code/core/collections/public/ice/span.hxx b/source/code/core/collections/public/ice/span.hxx index 5f4549a4..8e144057 100644 --- a/source/code/core/collections/public/ice/span.hxx +++ b/source/code/core/collections/public/ice/span.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include #include #include diff --git a/source/code/core/collections/tests/test_shard_container.cxx b/source/code/core/collections/tests/test_shard_container.cxx index edfc0aa3..7bf938d7 100644 --- a/source/code/core/collections/tests/test_shard_container.cxx +++ b/source/code/core/collections/tests/test_shard_container.cxx @@ -9,6 +9,7 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") { using ice::operator""_shard; + using ice::operator""_count; static constexpr ice::Shard test_shard_1 = "shard_1"_shard; static constexpr ice::Shard test_shard_2 = "shard_2"_shard; @@ -18,42 +19,42 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") GIVEN("an empty shard container") { - REQUIRE(ice::shards::empty(test_container)); - REQUIRE(ice::shards::capacity(test_container) == 0); + REQUIRE(test_container.is_empty()); + REQUIRE(test_container.capacity() == 0_count); WHEN("shard 'one' is pushed without a payload") { - ice::shards::push_back(test_container, test_shard_1); + test_container.push_back(test_shard_1); - CHECK(ice::shards::size(test_container) == 1); - CHECK(ice::shards::count(test_container, ice::Shard_Invalid) == 0); - CHECK(ice::shards::count(test_container, test_shard_1) == 1); - CHECK(ice::shards::count(test_container, test_shard_2) == 0); + CHECK(test_container.size() == 1_count); + CHECK(test_container.count_of(ice::Shard_Invalid) == 0); + CHECK(test_container.count_of(test_shard_1) == 1); + CHECK(test_container.count_of(test_shard_2) == 0); THEN("shards of type 'one' are removed") { - ice::shards::remove_all_of(test_container, test_shard_1); + test_container.remove_all_of(test_shard_1); - CHECK(ice::shards::size(test_container) == 0); - CHECK(ice::shards::count(test_container, ice::Shard_Invalid) == 0); - CHECK(ice::shards::count(test_container, test_shard_1) == 0); - CHECK(ice::shards::count(test_container, test_shard_2) == 0); + CHECK(test_container.size() == 0_count); + CHECK(test_container.count_of(ice::Shard_Invalid) == 0); + CHECK(test_container.count_of(test_shard_1) == 0); + CHECK(test_container.count_of(test_shard_2) == 0); } THEN("shards of type 'two' are removed") { - ice::shards::remove_all_of(test_container, test_shard_2); + test_container.remove_all_of(test_shard_2); - CHECK(ice::shards::size(test_container) == 1); - CHECK(ice::shards::count(test_container, ice::Shard_Invalid) == 0); - CHECK(ice::shards::count(test_container, test_shard_1) == 1); - CHECK(ice::shards::count(test_container, test_shard_2) == 0); + CHECK(test_container.size() == 1); + CHECK(test_container.count_of(ice::Shard_Invalid) == 0); + CHECK(test_container.count_of(test_shard_1) == 1); + CHECK(test_container.count_of(test_shard_2) == 0); } THEN("inspecting the container returns no results") { ice::Array payloads{ alloc }; - ice::u32 const payload_count = ice::shards::inspect_all(test_container, test_shard_1, payloads); + ice::ncount const payload_count = test_container.inspect_all(test_shard_1, payloads); CHECK(payload_count == 0); } @@ -62,37 +63,37 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") WHEN("shard 'two' is pushed with a payload") { constexpr ice::u32 test_payload_value = 0xD00D00; - ice::shards::push_back(test_container, test_shard_2 | test_payload_value); + test_container.push_back(test_shard_2 | test_payload_value); - CHECK(ice::shards::size(test_container) == 1); - CHECK(ice::shards::count(test_container, ice::Shard_Invalid) == 0); - CHECK(ice::shards::count(test_container, test_shard_1) == 0); - CHECK(ice::shards::count(test_container, test_shard_2) == 1); + CHECK(test_container.size() == 1); + CHECK(test_container.count_of(ice::Shard_Invalid) == 0); + CHECK(test_container.count_of(test_shard_1) == 0); + CHECK(test_container.count_of(test_shard_2) == 1); THEN("shards of type 'one' are removed") { - ice::shards::remove_all_of(test_container, test_shard_1); + test_container.remove_all_of(test_shard_1); - CHECK(ice::shards::size(test_container) == 1); - CHECK(ice::shards::count(test_container, ice::Shard_Invalid) == 0); - CHECK(ice::shards::count(test_container, test_shard_1) == 0); - CHECK(ice::shards::count(test_container, test_shard_2) == 1); + CHECK(test_container.size() == 1); + CHECK(test_container.count_of(ice::Shard_Invalid) == 0); + CHECK(test_container.count_of(test_shard_1) == 0); + CHECK(test_container.count_of(test_shard_2) == 1); } THEN("shards of type 'two' are removed") { - ice::shards::remove_all_of(test_container, test_shard_2); + test_container.remove_all_of(test_shard_2); - CHECK(ice::shards::size(test_container) == 0); - CHECK(ice::shards::count(test_container, ice::Shard_Invalid) == 0); - CHECK(ice::shards::count(test_container, test_shard_1) == 0); - CHECK(ice::shards::count(test_container, test_shard_2) == 0); + CHECK(test_container.size() == 0); + CHECK(test_container.count_of(ice::Shard_Invalid) == 0); + CHECK(test_container.count_of(test_shard_1) == 0); + CHECK(test_container.count_of(test_shard_2) == 0); } THEN("inspecting the container returns one result") { ice::Array payloads{ alloc }; - ice::u32 const payload_count = ice::shards::inspect_all(test_container, test_shard_2, payloads); + ice::ncount const payload_count = test_container.inspect_all(test_shard_2, payloads); REQUIRE(payload_count == 1); CHECK(payloads[0] == test_payload_value); @@ -111,34 +112,34 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") static constexpr ice::Shard test_shard_3 = "shard_3"_shard; static constexpr ice::Shard test_shard_4 = "shard_4"_shard; - ice::shards::push_back(test_container, test_shard_1 | test_i32_payload_value1); - ice::shards::push_back(test_container, test_shard_1 | test_u32_payload_value1); - ice::shards::push_back(test_container, test_shard_2 | test_i64_payload_value1); - ice::shards::push_back(test_container, test_shard_3 | test_i32_payload_value2); - ice::shards::push_back(test_container, test_shard_3 | test_u32_payload_value2); - ice::shards::push_back(test_container, test_shard_4 | test_i64_payload_value2); + test_container.push_back(test_shard_1 | test_i32_payload_value1); + test_container.push_back(test_shard_1 | test_u32_payload_value1); + test_container.push_back(test_shard_2 | test_i64_payload_value1); + test_container.push_back(test_shard_3 | test_i32_payload_value2); + test_container.push_back(test_shard_3 | test_u32_payload_value2); + test_container.push_back(test_shard_4 | test_i64_payload_value2); - CHECK(ice::shards::size(test_container) == 6); - CHECK(ice::shards::count(test_container, ice::Shard_Invalid) == 0); - CHECK(ice::shards::count(test_container, test_shard_1) == 2); - CHECK(ice::shards::count(test_container, test_shard_2) == 1); - CHECK(ice::shards::count(test_container, test_shard_3) == 2); - CHECK(ice::shards::count(test_container, test_shard_4) == 1); + CHECK(test_container.size() == 6); + CHECK(test_container.count_of(ice::Shard_Invalid) == 0); + CHECK(test_container.count_of(test_shard_1) == 2); + CHECK(test_container.count_of(test_shard_2) == 1); + CHECK(test_container.count_of(test_shard_3) == 2); + CHECK(test_container.count_of(test_shard_4) == 1); THEN("we add even more shards (without shard+payload duplicates)") { - ice::shards::push_back(test_container, test_shard_1 | test_i64_payload_value1); - ice::shards::push_back(test_container, test_shard_2 | test_i32_payload_value2); - ice::shards::push_back(test_container, test_shard_3 | test_i64_payload_value2); - ice::shards::push_back(test_container, test_shard_4 | test_u32_payload_value1); - - CHECK(ice::shards::size(test_container) == 10); - CHECK(ice::shards::count(test_container, ice::Shard_Invalid) == 0); - CHECK(ice::shards::count(test_container, test_shard_1) == 3); - CHECK(ice::shards::count(test_container, test_shard_2) == 2); - CHECK(ice::shards::count(test_container, test_shard_3) == 3); - CHECK(ice::shards::count(test_container, test_shard_4) == 2); + test_container.push_back(test_shard_1 | test_i64_payload_value1); + test_container.push_back(test_shard_2 | test_i32_payload_value2); + test_container.push_back(test_shard_3 | test_i64_payload_value2); + test_container.push_back(test_shard_4 | test_u32_payload_value1); + + CHECK(test_container.size() == 10); + CHECK(test_container.count_of(ice::Shard_Invalid) == 0); + CHECK(test_container.count_of(test_shard_1) == 3); + CHECK(test_container.count_of(test_shard_2) == 2); + CHECK(test_container.count_of(test_shard_3) == 3); + CHECK(test_container.count_of(test_shard_4) == 2); THEN("inspect using shards without payload-id's") { @@ -146,9 +147,9 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") ice::u32 payload_u32 = 1; ice::i64 payload_i64 = 1; - bool inspect_1 = ice::shards::inspect_first(test_container, test_shard_1, payload_i32); - bool inspect_2 = ice::shards::inspect_first(test_container, test_shard_2, payload_u32); - bool inspect_3 = ice::shards::inspect_first(test_container, test_shard_3, payload_i64); + bool inspect_1 = test_container.inspect_first(test_shard_1, payload_i32); + bool inspect_2 = test_container.inspect_first(test_shard_2, payload_u32); + bool inspect_3 = test_container.inspect_first(test_shard_3, payload_i64); CHECK(inspect_1 == true); CHECK(inspect_2 == false); @@ -157,9 +158,9 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") CHECK(payload_u32 == 1); CHECK(payload_i64 == 1); - inspect_1 = ice::shards::inspect_last(test_container, test_shard_4, payload_i32); - inspect_2 = ice::shards::inspect_last(test_container, test_shard_3, payload_u32); - inspect_3 = ice::shards::inspect_last(test_container, test_shard_2, payload_i64); + inspect_1 = test_container.inspect_last(test_shard_4, payload_i32); + inspect_2 = test_container.inspect_last(test_shard_3, payload_u32); + inspect_3 = test_container.inspect_last(test_shard_2, payload_i64); CHECK(inspect_1 == false); CHECK(inspect_2 == false); @@ -172,9 +173,9 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") ice::u32 payload_u32 = 1; ice::i64 payload_i64 = 1; - bool inspect_1 = ice::shards::inspect_first(test_container, test_shard_1 | ice::i32{}, payload_i32); - bool inspect_2 = ice::shards::inspect_first(test_container, test_shard_2 | ice::u32{}, payload_u32); - bool inspect_3 = ice::shards::inspect_first(test_container, test_shard_3 | ice::u64{}, payload_i64); + bool inspect_1 = test_container.inspect_first(test_shard_1 | ice::i32{}, payload_i32); + bool inspect_2 = test_container.inspect_first(test_shard_2 | ice::u32{}, payload_u32); + bool inspect_3 = test_container.inspect_first(test_shard_3 | ice::u64{}, payload_i64); CHECK(inspect_1 == true); CHECK(inspect_2 == false); @@ -183,9 +184,9 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") CHECK(payload_u32 == 1); CHECK(payload_i64 == 1); - inspect_1 = ice::shards::inspect_last(test_container, test_shard_4 | ice::i32{}, payload_i32); - inspect_2 = ice::shards::inspect_last(test_container, test_shard_3 | ice::u32{}, payload_u32); - inspect_3 = ice::shards::inspect_last(test_container, test_shard_2 | ice::u64{}, payload_i64); + inspect_1 = test_container.inspect_last(test_shard_4 | ice::i32{}, payload_i32); + inspect_2 = test_container.inspect_last(test_shard_3 | ice::u32{}, payload_u32); + inspect_3 = test_container.inspect_last(test_shard_2 | ice::u64{}, payload_i64); CHECK(inspect_1 == false); CHECK(inspect_2 == true); @@ -196,75 +197,75 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") THEN("we can remove all shards of a specific type (without payload-id)") { - ice::shards::remove_all_of(test_container, test_shard_1); - - CHECK(ice::shards::size(test_container) == 7); - CHECK(ice::shards::count(test_container, ice::Shard_Invalid) == 0); - CHECK(ice::shards::count(test_container, test_shard_1) == 0); - CHECK(ice::shards::count(test_container, test_shard_2) == 2); - CHECK(ice::shards::count(test_container, test_shard_3) == 3); - CHECK(ice::shards::count(test_container, test_shard_4) == 2); - - CHECK(ice::shards::contains(test_container, test_shard_1) == false); - CHECK(ice::shards::contains(test_container, test_shard_2) == true); - CHECK(ice::shards::contains(test_container, test_shard_3) == true); - CHECK(ice::shards::contains(test_container, test_shard_4) == true); + test_container.remove_all_of(test_shard_1); + + CHECK(test_container.size() == 7); + CHECK(test_container.count_of(ice::Shard_Invalid) == 0); + CHECK(test_container.count_of(test_shard_1) == 0); + CHECK(test_container.count_of(test_shard_2) == 2); + CHECK(test_container.count_of(test_shard_3) == 3); + CHECK(test_container.count_of(test_shard_4) == 2); + + CHECK(test_container.contains(test_shard_1) == false); + CHECK(test_container.contains(test_shard_2) == true); + CHECK(test_container.contains(test_shard_3) == true); + CHECK(test_container.contains(test_shard_4) == true); } THEN("we can remove shards of a specific type (without a payload-id)") { - ice::shards::remove_all_of(test_container, test_shard_1 | ice::u32{}); - ice::shards::remove_all_of(test_container, test_shard_2 | ice::u32{}); - ice::shards::remove_all_of(test_container, test_shard_3 | ice::u32{}); - ice::shards::remove_all_of(test_container, test_shard_4 | ice::u32{}); - - CHECK(ice::shards::size(test_container) == 7); - CHECK(ice::shards::count(test_container, ice::Shard_Invalid) == 0); - CHECK(ice::shards::count(test_container, test_shard_1) == 2); - CHECK(ice::shards::count(test_container, test_shard_2) == 2); - CHECK(ice::shards::count(test_container, test_shard_3) == 2); - CHECK(ice::shards::count(test_container, test_shard_4) == 1); - - CHECK(ice::shards::contains(test_container, test_shard_1) == true); - CHECK(ice::shards::contains(test_container, test_shard_2) == true); - CHECK(ice::shards::contains(test_container, test_shard_3) == true); - CHECK(ice::shards::contains(test_container, test_shard_4) == true); - - CHECK(ice::shards::contains(test_container, test_shard_1 | ice::u32{}) == false); - CHECK(ice::shards::contains(test_container, test_shard_2 | ice::u32{}) == false); - CHECK(ice::shards::contains(test_container, test_shard_3 | ice::u32{}) == false); - CHECK(ice::shards::contains(test_container, test_shard_4 | ice::u32{}) == false); + test_container.remove_all_of(test_shard_1 | ice::u32{}); + test_container.remove_all_of(test_shard_2 | ice::u32{}); + test_container.remove_all_of(test_shard_3 | ice::u32{}); + test_container.remove_all_of(test_shard_4 | ice::u32{}); + + CHECK(test_container.size() == 7); + CHECK(test_container.count_of(ice::Shard_Invalid) == 0); + CHECK(test_container.count_of(test_shard_1) == 2); + CHECK(test_container.count_of(test_shard_2) == 2); + CHECK(test_container.count_of(test_shard_3) == 2); + CHECK(test_container.count_of(test_shard_4) == 1); + + CHECK(test_container.contains(test_shard_1) == true); + CHECK(test_container.contains(test_shard_2) == true); + CHECK(test_container.contains(test_shard_3) == true); + CHECK(test_container.contains(test_shard_4) == true); + + CHECK(test_container.contains(test_shard_1 | ice::u32{}) == false); + CHECK(test_container.contains(test_shard_2 | ice::u32{}) == false); + CHECK(test_container.contains(test_shard_3 | ice::u32{}) == false); + CHECK(test_container.contains(test_shard_4 | ice::u32{}) == false); } } THEN("we add even more shards (with shard+payload duplicates)") { - ice::u32 const pre_push_size = ice::shards::size(test_container); - - ice::shards::push_back(test_container, test_shard_1 | test_i64_payload_value2); - ice::shards::push_back(test_container, test_shard_1 | test_i32_payload_value2); - ice::shards::push_back(test_container, test_shard_1 | test_u32_payload_value2); - ice::shards::push_back(test_container, test_shard_2 | test_i32_payload_value1); - ice::shards::push_back(test_container, test_shard_2 | test_i64_payload_value2); - ice::shards::push_back(test_container, test_shard_3 | test_i32_payload_value1); - ice::shards::push_back(test_container, test_shard_3 | test_u32_payload_value1); - ice::shards::push_back(test_container, test_shard_4 | test_u32_payload_value2); - ice::shards::push_back(test_container, test_shard_4 | test_i64_payload_value1); - - CHECK(ice::shards::count(test_container, test_shard_1) == 5); - CHECK(ice::shards::count(test_container, test_shard_2) == 3); - CHECK(ice::shards::count(test_container, test_shard_3) == 4); - CHECK(ice::shards::count(test_container, test_shard_4) == 3); + ice::ncount const pre_push_size = test_container.size(); + + test_container.push_back(test_shard_1 | test_i64_payload_value2); + test_container.push_back(test_shard_1 | test_i32_payload_value2); + test_container.push_back(test_shard_1 | test_u32_payload_value2); + test_container.push_back(test_shard_2 | test_i32_payload_value1); + test_container.push_back(test_shard_2 | test_i64_payload_value2); + test_container.push_back(test_shard_3 | test_i32_payload_value1); + test_container.push_back(test_shard_3 | test_u32_payload_value1); + test_container.push_back(test_shard_4 | test_u32_payload_value2); + test_container.push_back(test_shard_4 | test_i64_payload_value1); + + CHECK(test_container.count_of(test_shard_1) == 5); + CHECK(test_container.count_of(test_shard_2) == 3); + CHECK(test_container.count_of(test_shard_3) == 4); + CHECK(test_container.count_of(test_shard_4) == 3); THEN("we can inspect multiple payloads") { - CHECK(ice::shards::count(test_container, test_shard_1 | ice::u32{ }) == 2); - CHECK(ice::shards::count(test_container, test_shard_2 | ice::u32{ }) == 0); - CHECK(ice::shards::count(test_container, test_shard_3 | ice::u32{ }) == 2); - CHECK(ice::shards::count(test_container, test_shard_4 | ice::u32{ }) == 1); + CHECK(test_container.count_of(test_shard_1 | ice::u32{ }) == 2); + CHECK(test_container.count_of(test_shard_2 | ice::u32{ }) == 0); + CHECK(test_container.count_of(test_shard_3 | ice::u32{ }) == 2); + CHECK(test_container.count_of(test_shard_4 | ice::u32{ }) == 1); ice::Array payloads{ alloc }; - ice::shards::inspect_all(test_container, test_shard_1, payloads); + test_container.inspect_all(test_shard_1, payloads); REQUIRE(payloads.size() == 2); CHECK(payloads[0] == test_u32_payload_value1); @@ -273,8 +274,8 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") THEN("we check if we can find these payloads") { ice::u32 payload = 0; - ice::Shard first_shard = ice::shards::find_first_of(test_container, test_shard_1 | ice::u32{ }, 0); - ice::Shard last_shard = ice::shards::find_first_of(test_container, test_shard_1 | ice::u32{ }, pre_push_size); + ice::Shard first_shard = test_container.find_first_of(test_shard_1 | ice::u32{ }, 0); + ice::Shard last_shard = test_container.find_first_of(test_shard_1 | ice::u32{ }, pre_push_size.u32()); ice::shard_inspect(first_shard, payload); CHECK(payload == payloads[0]); @@ -282,8 +283,8 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") ice::shard_inspect(last_shard, payload); CHECK(payload == payloads[1]); - first_shard = ice::shards::find_last_of(test_container, test_shard_1 | ice::u32{ }, 0); - last_shard = ice::shards::find_last_of(test_container, test_shard_1 | ice::u32{ }, ice::shards::size(test_container) - pre_push_size); + first_shard = test_container.find_last_of(test_shard_1 | ice::u32{ }, 0); + last_shard = test_container.find_last_of(test_shard_1 | ice::u32{ }, (test_container.size() - pre_push_size).u32()); ice::shard_inspect(first_shard, payload); CHECK(payload == payloads[1]); @@ -293,19 +294,19 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") } payloads.clear(); - ice::shards::inspect_all(test_container, test_shard_2, payloads); + test_container.inspect_all(test_shard_2, payloads); REQUIRE(payloads.size() == 0); payloads.clear(); - ice::shards::inspect_all(test_container, test_shard_3, payloads); + test_container.inspect_all(test_shard_3, payloads); REQUIRE(payloads.size() == 2); CHECK(payloads[0] == test_u32_payload_value2); CHECK(payloads[1] == test_u32_payload_value1); payloads.clear(); - ice::shards::inspect_all(test_container, test_shard_4, payloads); + test_container.inspect_all(test_shard_4, payloads); REQUIRE(payloads.size() == 1); CHECK(payloads[0] == test_u32_payload_value2); From 9fc38d82dd09d01fed989089c826552475947e52 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Mon, 19 Jan 2026 22:45:38 +0900 Subject: [PATCH 31/40] Updating code affected after the refactor. --- source/code/core/tasks/public/ice/task.hxx | 1 - .../framework_base/private/framework_main.cxx | 21 ++++++++----------- .../engine/private/action/action_system.cxx | 14 ++++++------- .../private/engine_state_tracker_default.cxx | 15 +++++++------ .../private/engine_state_tracker_default.hxx | 2 +- .../iceshard/private/iceshard_frame.cxx | 2 +- .../iceshard/private/iceshard_runner.cxx | 2 +- .../private/iceshard_trait_context.cxx | 2 +- .../iceshard/private/iceshard_world.cxx | 2 +- .../private/iceshard_world_manager.cxx | 14 ++++++------- .../imgui_module/private/imgui_trait.cxx | 5 ++--- .../private/win32_sdl2_platform.cxx | 19 +++++++---------- .../private/input_action_stack.cxx | 8 +++---- source/code/test/private/game.cxx | 8 +++---- 14 files changed, 51 insertions(+), 64 deletions(-) diff --git a/source/code/core/tasks/public/ice/task.hxx b/source/code/core/tasks/public/ice/task.hxx index a36ec51a..162c2089 100644 --- a/source/code/core/tasks/public/ice/task.hxx +++ b/source/code/core/tasks/public/ice/task.hxx @@ -3,7 +3,6 @@ #pragma once #include -#include namespace ice { diff --git a/source/code/framework/framework_base/private/framework_main.cxx b/source/code/framework/framework_base/private/framework_main.cxx index 79177b37..2771c076 100644 --- a/source/code/framework/framework_base/private/framework_main.cxx +++ b/source/code/framework/framework_base/private/framework_main.cxx @@ -560,7 +560,7 @@ void ice_process_input_events(ice::Span events, ic { for (ice::input::InputEvent const input_event : events) { - ice::shards::push_back(out_shards, ice::ShardID_InputEvent | input_event); + out_shards.push_back(ice::ShardID_InputEvent | input_event); } } @@ -585,7 +585,7 @@ auto ice_game_frame( ICE_ASSERT(new_frame != nullptr, "Failed to aquire next frame!"); // Push system events - ice::shards::push_back(new_frame->shards(), system_events._data); + new_frame->shards().push_back(system_events); // Push previous frame events // Also runs other logic that should be done without interfeerence from @@ -667,7 +667,7 @@ auto ice_update( ice::ShardContainer const& system_events = state.platform.core->system_events(); // Query platform events into the frame and input device handler. - if (runtime.is_exiting || ice::shards::contains(system_events, ice::platform::Shard_AppQuit)) + if (runtime.is_exiting || system_events.contains(ice::platform::Shard_AppQuit)) { runtime.is_exiting = true; @@ -690,11 +690,11 @@ auto ice_update( return ice::app::S_ApplicationExit; } - bool const was_resized = ice::shards::contains(system_events, ice::platform::ShardID_WindowResized); - bool const was_minimized = ice::shards::contains(system_events, ice::platform::ShardID_WindowMinimized); - bool const was_maximized = ice::shards::contains(system_events, ice::platform::ShardID_WindowMaximized); + bool const was_resized = system_events.contains(ice::platform::ShardID_WindowResized); + bool const was_minimized = system_events.contains(ice::platform::ShardID_WindowMinimized); + bool const was_maximized = system_events.contains(ice::platform::ShardID_WindowMaximized); ice::vec2i window_size; // unused? - bool const was_restored = ice::shards::inspect_last(system_events, ice::platform::ShardID_WindowRestored, window_size); + bool const was_restored = system_events.inspect_last(ice::platform::ShardID_WindowRestored, window_size); // We should never run into a situation where minimizing and restoring happen ad the same time. // TODO: Might want to turn this into a state machine. @@ -747,16 +747,13 @@ auto ice_suspend( if (runtime.is_exiting) { - ice::shards::remove_all_of( - runtime.frame->shards(), - ice::ShardID_WorldActivate - ); + runtime.frame->shards().remove_all_of(ice::ShardID_WorldActivate); ice::Array worlds{ state.alloc }; state.engine->worlds().query_worlds(worlds); for (ice::StringID_Arg world : worlds) { - ice::shards::push_back(runtime.frame->shards(), ice::ShardID_WorldDeactivate | ice::stringid_hash(world)); + runtime.frame->shards().push_back(ice::ShardID_WorldDeactivate | ice::stringid_hash(world)); } // Apply state events so we can already get the events for the next frame diff --git a/source/code/iceshard/engine/private/action/action_system.cxx b/source/code/iceshard/engine/private/action/action_system.cxx index 197c28d8..e0a67aa3 100644 --- a/source/code/iceshard/engine/private/action/action_system.cxx +++ b/source/code/iceshard/engine/private/action/action_system.cxx @@ -172,7 +172,7 @@ namespace ice::action ) noexcept { ice::ShardContainer new_shards{ _step_shards_alloc }; - ice::shards::reserve(new_shards, 64); + new_shards.reserve(64); for (ActionInstance* const action : _actions) { @@ -208,12 +208,12 @@ namespace ice::action if (action->state == ActionState::Active) { ice::StringID_Hash action_name = ice::stringid_hash(action->name); - ice::shards::push_back(new_shards, ice::action::Shard_ActionEventReset | action_name); + new_shards.push_back(ice::action::Shard_ActionEventReset | action_name); current_stage = stages + action->current_stage_idx; if (current_stage->stage_shardid != ice::Shard_Invalid) { - ice::shards::push_back(new_shards, ice::shard(current_stage->stage_shardid) | action_name); + new_shards.push_back(ice::shard(current_stage->stage_shardid) | action_name); } } } @@ -276,7 +276,7 @@ namespace ice::action if (current_stage->stage_shardid != ice::Shard_Invalid) { - ice::shards::push_back(new_shards, ice::shard(current_stage->stage_shardid) | ice::stringid_hash(action->name)); + new_shards.push_back(ice::shard(current_stage->stage_shardid) | ice::stringid_hash(action->name)); } } } @@ -293,15 +293,15 @@ namespace ice::action { if (action->state == ActionState::FinishedSuccess) { - ice::shards::push_back(new_shards, ice::action::Shard_ActionEventSuccess | ice::stringid_hash(action->name)); + new_shards.push_back(ice::action::Shard_ActionEventSuccess | ice::stringid_hash(action->name)); } else if (action->state == ActionState::FinishedFailure) { - ice::shards::push_back(new_shards, ice::action::Shard_ActionEventFailed | ice::stringid_hash(action->name)); + new_shards.push_back(ice::action::Shard_ActionEventFailed | ice::stringid_hash(action->name)); } } - ice::shards::push_back(shards, new_shards._data); + shards.push_back(new_shards); } auto create_action_system( diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index 3b237e6b..4f1fcfcb 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -155,7 +155,7 @@ namespace ice { ice::StackAllocator<512_B> temp_alloc; ice::ShardContainer temp_shards{ temp_alloc }; - temp_shards._data.reserve( + temp_shards.reserve( ice::mem_max_capacity( ice::size_of, decltype(temp_alloc)::Constant_InternalCapacity @@ -170,8 +170,8 @@ namespace ice if (collect_pending_states(*input_shards)) { // Push back temporary shards into output shards - ice::shards::push_back(out_shards, temp_shards._data); - ice::shards::clear(temp_shards); + out_shards.push_back(temp_shards); + temp_shards.clear(); // Commit the new states and gather the new shards _pending_states.for_each([&temp_shards](EngineStatePending const& pending) noexcept @@ -200,17 +200,17 @@ namespace ice else { // Output temporary shards since they might trigger other events. - ice::shards::push_back(out_shards, temp_shards._data); + out_shards.push_back(temp_shards); // Clear temporary shards so we can escape the loop normally. - ice::shards::clear(temp_shards); + temp_shards.clear(); } // Set input shards to temp_shards input_shards = &temp_shards; // If we have any shards added, check if we can collect another set of states. - } while (ice::shards::empty(temp_shards) == false); + } while (temp_shards.not_empty()); return true; } @@ -292,8 +292,7 @@ namespace ice { for (ice::EngineStateTrigger const& trigger : _available_triggers) { - ice::shards::for_each( - shards, + shards.for_each( trigger.when, [&](ice::Shard shard) noexcept { diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx index 4f1f11c4..742ad2e1 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/source/code/iceshard/iceshard/private/iceshard_frame.cxx b/source/code/iceshard/iceshard/private/iceshard_frame.cxx index 626751c6..dee5ce7b 100644 --- a/source/code/iceshard/iceshard/private/iceshard_frame.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_frame.cxx @@ -124,7 +124,7 @@ namespace ice auto IceshardEngineFrame::extract_tasks() noexcept -> ice::Array> { - return ice::Array>{ *_shards._data._allocator }; + return ice::Array>{ *_shards._allocator }; } auto create_iceshard_frame( diff --git a/source/code/iceshard/iceshard/private/iceshard_runner.cxx b/source/code/iceshard/iceshard/private/iceshard_runner.cxx index 3cedd2eb..664bc391 100644 --- a/source/code/iceshard/iceshard/private/iceshard_runner.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_runner.cxx @@ -215,7 +215,7 @@ namespace ice if (trigger.to == State_WorldRuntimeActive) { ice::wait_for(world->activate(params)); - ice::shards::push_back(out_shards, trigger.results | world_name.value); + out_shards.push_back(trigger.results | world_name.value); } else if (trigger.to == State_WorldRuntimeInactive) { diff --git a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx index b2fd0cbb..e9e245ef 100644 --- a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx @@ -76,7 +76,7 @@ namespace ice // Push shards into the out container. (ice::detail::TraitEvent decays into ice::Shard) for (ice::Shard shard : _events_expired) { - ice::shards::push_back(out_shards, shard); + out_shards.push_back(shard); } } diff --git a/source/code/iceshard/iceshard/private/iceshard_world.cxx b/source/code/iceshard/iceshard/private/iceshard_world.cxx index 82353cb9..f15a3859 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world.cxx @@ -41,7 +41,7 @@ namespace ice if (_devui != nullptr && _devui->world_operation != ice::Shard_Invalid) { - ice::shards::push_back(out_shards, ice::exchange(_devui->world_operation, ice::Shard_Invalid)); + out_shards.push_back(ice::exchange(_devui->world_operation, ice::Shard_Invalid)); } } diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx index d493b748..bbb5a667 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx @@ -45,7 +45,7 @@ namespace ice ) noexcept -> ice::Task<> { co_await task; - ice::shards::push_back(out_shards, shard); + out_shards.push_back(shard); } } // namespace detail @@ -147,8 +147,7 @@ namespace ice Entry world_entry{ .context = ice::move(world_context), .world = world }; // Add a new pending event - ice::shards::push_back( - _pending_events, + _pending_events.push_back( ice::ShardID_WorldCreated | ice::stringid_hash(world_template.name) ); @@ -178,8 +177,7 @@ namespace ice ); // Add a new pending event - ice::shards::push_back( - _pending_events, + _pending_events.push_back( ice::ShardID_WorldDestroyed | ice::stringid_hash(name) ); @@ -199,8 +197,8 @@ namespace ice void IceshardWorldManager::query_pending_events(ice::ShardContainer& out_events) noexcept { - ice::shards::push_back(out_events, _pending_events._data); - ice::shards::clear(_pending_events); + out_events.push_back(_pending_events); + _pending_events.clear(); } void IceshardWorldManager::pre_update( @@ -260,7 +258,7 @@ namespace ice if (trigger.results != ice::Shard_Invalid) { - ice::shards::push_back(out_shards, trigger.results | world_name); + out_shards.push_back(trigger.results | world_name); } } diff --git a/source/code/modules/imgui_module/private/imgui_trait.cxx b/source/code/modules/imgui_module/private/imgui_trait.cxx index b9fdb713..31d3ddf4 100644 --- a/source/code/modules/imgui_module/private/imgui_trait.cxx +++ b/source/code/modules/imgui_module/private/imgui_trait.cxx @@ -290,7 +290,7 @@ namespace ice::devui auto& io = ImGui::GetIO(); char const* input_text; - if (ice::shards::inspect_last(update.frame.shards(), ice::platform::ShardID_InputText, input_text)) + if (update.frame.shards().inspect_last(ice::platform::ShardID_InputText, input_text)) { io.AddInputCharactersUTF8(input_text); } @@ -298,8 +298,7 @@ namespace ice::devui ice::vec2f temp_pos{}; io.AddMouseSourceEvent(ImGuiMouseSource_Mouse); - ice::shards::inspect_each( - update.frame.shards(), + update.frame.shards().inspect_each( ice::ShardID_InputEvent, [&](ice::input::InputEvent input) noexcept { diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx index 2db688f3..5938f5e9 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx @@ -19,7 +19,7 @@ namespace ice::platform::win32::sdl2 , _input_events{ _alloc } , _render_surface{ } { - ice::shards::reserve(_system_events, 32); + _system_events.reserve(32); _input_events._events.reserve(512); SDL_InitSubSystem(SDL_INIT_EVENTS); @@ -40,7 +40,7 @@ namespace ice::platform::win32::sdl2 using namespace ice::input; _input_events.clear(); - ice::shards::clear(_system_events); + _system_events.clear(); static bool first_refresh = true; if (first_refresh) @@ -64,7 +64,7 @@ namespace ice::platform::win32::sdl2 switch (current_event.type) { case SDL_QUIT: - ice::shards::push_back(_system_events, ice::platform::Shard_AppQuit); + _system_events.push_back(ice::platform::Shard_AppQuit); _input_events.push( make_device_handle(DeviceType::Keyboard, DeviceIndex(0)), @@ -83,17 +83,17 @@ namespace ice::platform::win32::sdl2 switch (current_event.window.event) { case SDL_WINDOWEVENT_MINIMIZED: - ice::shards::push_back(_system_events, { ice::platform::ShardID_WindowMinimized }); + _system_events.push_back({ ice::platform::ShardID_WindowMinimized }); break; case SDL_WINDOWEVENT_RESTORED: - ice::shards::push_back(_system_events, ice::platform::ShardID_WindowRestored | window_size); + _system_events.push_back(ice::platform::ShardID_WindowRestored | window_size); break; case SDL_WINDOWEVENT_MAXIMIZED: - ice::shards::push_back(_system_events, ice::platform::ShardID_WindowMaximized | window_size); + _system_events.push_back(ice::platform::ShardID_WindowMaximized | window_size); break; case SDL_WINDOWEVENT_SIZE_CHANGED: case SDL_WINDOWEVENT_RESIZED: - ice::shards::push_back(_system_events, ice::platform::ShardID_WindowResized | window_size); + _system_events.push_back(ice::platform::ShardID_WindowResized | window_size); break; } } @@ -110,10 +110,7 @@ namespace ice::platform::win32::sdl2 // [issue #33] case SDL_TEXTINPUT: ice::memcpy(text_buffer, current_event.text.text, 32); - ice::shards::push_back( - _system_events, - ice::platform::ShardID_InputText | (char const*)text_buffer - ); + _system_events.push_back(ice::platform::ShardID_InputText | (char const*)text_buffer); } } diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index eba3098b..e539b018 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -461,16 +461,16 @@ namespace ice { using enum InputActionDataType; case Bool: - ice::shards::push_back(out_shards, sid | bool(action.value.x > 0.0f)); + out_shards.push_back(sid | bool(action.value.x > 0.0f)); break; case Float1: - ice::shards::push_back(out_shards, sid | action.value.x); + out_shards.push_back(sid | action.value.x); break; case Float2: - ice::shards::push_back(out_shards, sid | action.value); + out_shards.push_back(sid | action.value); break; case ActionObject: - ice::shards::push_back(out_shards, sid | static_cast(ice::addressof(action))); + out_shards.push_back(sid | static_cast(ice::addressof(action))); break; default: ICE_ASSERT_CORE(false); break; } diff --git a/source/code/test/private/game.cxx b/source/code/test/private/game.cxx index 24581e21..11fa9051 100644 --- a/source/code/test/private/game.cxx +++ b/source/code/test/private/game.cxx @@ -99,11 +99,11 @@ struct WorldActivationTrait : ice::Trait, ice::DevUIWidget { if (do_active) { - shards::push_back(update.frame.shards(), ShardID_WorldActivate | "world2"_sid_hash); + update.frame.shards().push_back(ShardID_WorldActivate | "world2"_sid_hash); } else { - shards::push_back(update.frame.shards(), ShardID_WorldDeactivate | "world2"_sid_hash); + update.frame.shards().push_back(ShardID_WorldDeactivate | "world2"_sid_hash); } is_active = do_active; } @@ -318,9 +318,7 @@ void TestGame::on_resume(ice::Engine& engine) noexcept void TestGame::on_update(ice::Engine& engine, ice::EngineFrame& frame) noexcept { - using namespace ice; - - shards::push_back(frame.shards(), ShardID_WorldActivate | "world"_sid_hash); + frame.shards().push_back(ShardID_WorldActivate | "world"_sid_hash); } void TestGame::on_suspend(ice::Engine& engine) noexcept From 51c30f7d30e79cb3741075c7c51de79bac9c2af9 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Tue, 20 Jan 2026 01:02:27 +0900 Subject: [PATCH 32/40] Initial idea to implement paths as using a "mixin" approach on top of String and HeapString types. #ICE-214 State In Progress --- .../public/ice/shard_container.hxx | 40 +++++----- .../public/ice/string/string_concepts.hxx | 15 ++++ .../core/core/public/ice/build/platform.hxx | 6 ++ .../core/utils/public/ice/native_file.hxx | 10 ++- .../code/core/utils/public/ice/path_utils.hxx | 75 ++++++++++++++++++- .../private/resource_provider_filelist.cxx | 4 +- .../public/ice/resource_provider.hxx | 5 +- .../tools/hsc_packer/private/hsc_packer.cxx | 4 +- .../hsc_packer/private/hsc_packer_app.cxx | 4 +- .../hsc_packer/private/hsc_packer_app.hxx | 2 +- 10 files changed, 130 insertions(+), 35 deletions(-) diff --git a/source/code/core/collections/public/ice/shard_container.hxx b/source/code/core/collections/public/ice/shard_container.hxx index 5bfe5dde..03d59e09 100644 --- a/source/code/core/collections/public/ice/shard_container.hxx +++ b/source/code/core/collections/public/ice/shard_container.hxx @@ -32,6 +32,12 @@ namespace ice Args&&... args ) const noexcept -> ice::ncount; + template + inline constexpr bool inspect_first(ice::ShardID shardid, T& payload) const noexcept; + + template + inline constexpr bool inspect_last(ice::ShardID shard, T& payload) const noexcept; + template inline constexpr auto inspect_all( ice::ShardID shardid, @@ -44,12 +50,6 @@ namespace ice Fn&& callback ) noexcept -> ice::ncount; - template - inline constexpr bool inspect_first(ice::ShardID shardid, T& payload) const noexcept; - - template - inline constexpr bool inspect_last(ice::ShardID shard, T& payload) const noexcept; - inline constexpr void remove_all_of(this ShardContainer& self, ice::ShardID shardid) noexcept; }; @@ -137,6 +137,20 @@ namespace ice return { count, sizeof(ice::ShardID) }; } + template + inline constexpr bool ShardContainer::inspect_first(ice::ShardID shardid, T& payload) const noexcept + { + ice::Shard const shard = this->find_first_of(shardid); + return ice::shard_inspect(shard, payload); + } + + template + inline constexpr bool ShardContainer::inspect_last(ice::ShardID shardid, T& payload) const noexcept + { + ice::Shard const shard = this->find_last_of(shardid); + return ice::shard_inspect(shard, payload); + } + template inline constexpr auto ShardContainer::inspect_each(ice::ShardID shardid, Fn&& callback) noexcept -> ice::ncount { @@ -152,20 +166,6 @@ namespace ice return { count, sizeof(ice::Shard) }; } - template - inline constexpr bool ShardContainer::inspect_first(ice::ShardID shardid, T& payload) const noexcept - { - ice::Shard const shard = this->find_first_of(shardid); - return ice::shard_inspect(shard, payload); - } - - template - inline constexpr bool ShardContainer::inspect_last(ice::ShardID shardid, T& payload) const noexcept - { - ice::Shard const shard = this->find_last_of(shardid); - return ice::shard_inspect(shard, payload); - } - inline constexpr void ShardContainer::remove_all_of( this ShardContainer& self, ice::ShardID shardid diff --git a/source/code/core/collections/public/ice/string/string_concepts.hxx b/source/code/core/collections/public/ice/string/string_concepts.hxx index b9ee83e9..f44052ba 100644 --- a/source/code/core/collections/public/ice/string/string_concepts.hxx +++ b/source/code/core/collections/public/ice/string/string_concepts.hxx @@ -47,6 +47,21 @@ namespace ice::concepts } // namespace ice::concepts +namespace ice::string +{ + + template + using ConstCorrectCharType = std::conditional_t< + std::is_const_v>, + typename std::remove_reference_t::CharType const, + typename std::remove_reference_t::CharType + >; + + template + using CharType = ConstCorrectCharType; + +} // namespace ice::string + namespace ice::string::detail { diff --git a/source/code/core/core/public/ice/build/platform.hxx b/source/code/core/core/public/ice/build/platform.hxx index 44751078..bbda6549 100644 --- a/source/code/core/core/public/ice/build/platform.hxx +++ b/source/code/core/core/public/ice/build/platform.hxx @@ -164,6 +164,7 @@ namespace ice::build # define ISP_ARCHFAM_X86 1 # define ISP_ARCHFAM_ARM 0 # define ISP_ARCHFAM_WEBASM 0 +# define ISP_TEXT(val) L ## val #elif defined(__ANDROID__) # define ISP_UNIX 1 # define ISP_LINUX 0 @@ -185,6 +186,7 @@ namespace ice::build # define ISP_ARCHFAM_WEBASM 0 static constexpr Platform current_platform = platform_android_x64_clang; # endif +# define ISP_TEXT(val) val #elif defined(EMSCRIPTEN) # define ISP_UNIX 1 # define ISP_LINUX 0 @@ -200,6 +202,7 @@ namespace ice::build # define ISP_ARCHFAM_WEBASM 1 static constexpr Platform current_platform = platform_webapp_webasm32_clang; +# define ISP_TEXT(val) val #elif __unix__ && !__clang__ # define ISP_UNIX 1 # define ISP_LINUX 1 @@ -214,6 +217,7 @@ namespace ice::build # define ISP_ARCHFAM_WEBASM 0 static constexpr Platform current_platform = platform_unix_x64_gcc; +# define ISP_TEXT(val) val #elif __unix__ && __clang__ # define ISP_UNIX 1 # define ISP_LINUX 1 @@ -228,6 +232,7 @@ namespace ice::build # define ISP_ARCHFAM_WEBASM 0 static constexpr Platform current_platform = platform_linux_x64_clang; +# define ISP_TEXT(val) val #else # define ISP_UNIX 0 # define ISP_WINDOWS 0 @@ -241,6 +246,7 @@ namespace ice::build # define ISP_ARCHFAM_WEBASM 0 static_assert(false, "Unknow platform!"); +# define ISP_TEXT(val) ISP_UNDEFINED #endif constexpr auto arch_family(Architecture arch) noexcept -> ArchFamily diff --git a/source/code/core/utils/public/ice/native_file.hxx b/source/code/core/utils/public/ice/native_file.hxx index c5badeba..12a4f4d8 100644 --- a/source/code/core/utils/public/ice/native_file.hxx +++ b/source/code/core/utils/public/ice/native_file.hxx @@ -18,8 +18,14 @@ namespace ice::native_file #if ISP_WINDOWS using File = ice::win32::FileHandle; - using FilePath = ice::WString; - using HeapFilePath = ice::HeapString; + using FilePath = ice::BasicPath; + struct HeapFilePath : public ice::HeapString, public ice::PathString + { + using HeapString::HeapString; + using HeapString::operator ice::BasicString; + + constexpr operator FilePath() const noexcept { return { _data, _size }; } + }; # define ISP_PATH_LITERAL(val) L##val #elif ISP_UNIX using File = ice::unix_::FileHandle; diff --git a/source/code/core/utils/public/ice/path_utils.hxx b/source/code/core/utils/public/ice/path_utils.hxx index 01d1fe9b..12465f8a 100644 --- a/source/code/core/utils/public/ice/path_utils.hxx +++ b/source/code/core/utils/public/ice/path_utils.hxx @@ -4,13 +4,70 @@ #pragma once #include #include +#include -namespace ice::path +namespace ice { - //! \note On windows: starts with a drive letter, on linux: checks for starting backslash. - //! \return true If the path is absolute. - bool is_absolute(ice::String path) noexcept; + struct PathString + { + template + static constexpr ice::BasicString Separator_Dot; + template + static constexpr ice::BasicString Separator_Drive; + template + static constexpr ice::BasicString Separator_Directory; + + template<> constexpr ice::BasicString Separator_Dot = "."; + template<> constexpr ice::BasicString Separator_Drive = ":"; + template<> constexpr ice::BasicString Separator_Directory = "\\/"; + template<> constexpr ice::BasicString Separator_Dot = L"."; + template<> constexpr ice::BasicString Separator_Drive = L":"; + template<> constexpr ice::BasicString Separator_Directory = L"\\/"; + + template + bool is_absolute(this Self const& self) noexcept + { + using CharType = ice::string::CharType; + + if constexpr (ice::build::is_windows) + { + if (self.size() >= 3_count) + { + return self[1] == Separator_Drive[0] && Separator_Directory.find_first_of(self[2]) != ice::nindex_none; + } + return false; + } + else + { + return self.not_empty() && self.front() == Separator_Directory[1]; + } + } + + template + bool is_relative(this Self const& self) noexcept + { + return self.is_absolute() == false; + } + }; + + template + struct BasicPath : public ice::BasicString, public ice::PathString + { + using BasicString::BasicString; + using BasicString::operator std::basic_string_view; + + constexpr BasicPath(ice::BasicString str) noexcept + : BasicString{ str } + { } + }; + + using Path = ice::BasicPath; + +} // namespace + +namespace ice::path +{ //! \return true If the path is just the root part. (ex. 'C:/' or '/') bool is_absolute_root(ice::String path) noexcept; @@ -71,3 +128,13 @@ namespace ice::path auto replace_extension(ice::HeapString& path, ice::WString extension) noexcept -> ice::WString; } // namespace ice::path + +template +struct fmt::formatter> : public fmt::formatter> +{ + template + constexpr auto format(ice::BasicPath value, FormatContext& ctx) const noexcept + { + return fmt::formatter>::format(value, ctx); + } +}; diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index 020c1b29..a2c8a52e 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -26,7 +26,7 @@ namespace ice for (ice::ResourceFileEntry const& entry : entries) { using enum native_file::PathFlags; - if (ice::path::is_absolute(entry.path) == false) + if (entry.path.is_relative()) { file_path = ice::native_file::path_from_strings( _named_allocator, entry.basepath, entry.path @@ -44,7 +44,7 @@ namespace ice ); ice::native_file::FilePath const file_path_str = file_path; - ICE_ASSERT_CORE(file_path_str.starts_with((ice::native_file::FilePath)base_path)); + ICE_ASSERT_CORE(file_path_str.starts_with(base_path)); } ice::ncount const basepath_size = entry.basepath.is_empty() diff --git a/source/code/systems/resource_system/public/ice/resource_provider.hxx b/source/code/systems/resource_system/public/ice/resource_provider.hxx index 68a0f70a..0db08e49 100644 --- a/source/code/systems/resource_system/public/ice/resource_provider.hxx +++ b/source/code/systems/resource_system/public/ice/resource_provider.hxx @@ -11,6 +11,7 @@ #include #include #include +#include #include namespace ice @@ -85,8 +86,8 @@ namespace ice struct ResourceFileEntry { - ice::String path; - ice::String basepath = {}; + ice::Path path; + ice::Path basepath = {}; }; auto create_resource_provider( diff --git a/source/code/tools/hsc_packer/private/hsc_packer.cxx b/source/code/tools/hsc_packer/private/hsc_packer.cxx index 81146085..096735c2 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer.cxx @@ -188,7 +188,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp // } // Prepare the output file name. - _param_output = hscp_process_directory(_allocator, _param_output); + _param_output = hscp_process_directory(_allocator, ice::Path{ _param_output }); // The paths that will be searched for loose file resources. ice::UniquePtr fsprov = ice::create_resource_provider( @@ -234,7 +234,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp auto run_explicit() noexcept -> ice::i32 { // Prepare the output file name. - _param_output = hscp_process_directory(_allocator, _param_output); + _param_output = hscp_process_directory(_allocator, ice::Path{ _param_output }); // The paths that will be searched for loose file resources. ice::Array files{ _allocator }; diff --git a/source/code/tools/hsc_packer/private/hsc_packer_app.cxx b/source/code/tools/hsc_packer/private/hsc_packer_app.cxx index 3c756c1e..2167520d 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer_app.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer_app.cxx @@ -8,10 +8,10 @@ #include #include -auto hscp_process_directory(ice::Allocator& alloc, ice::String dir) noexcept -> ice::HeapString<> +auto hscp_process_directory(ice::Allocator& alloc, ice::Path dir) noexcept -> ice::HeapString<> { ice::HeapString<> searched_utf8_path{ alloc, dir }; - if (ice::path::is_absolute(dir) == false) + if (dir.is_relative()) { searched_utf8_path = ice::app::workingdir(); ice::path::join(searched_utf8_path, dir); diff --git a/source/code/tools/hsc_packer/private/hsc_packer_app.hxx b/source/code/tools/hsc_packer/private/hsc_packer_app.hxx index 2b16f585..19a3de91 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer_app.hxx +++ b/source/code/tools/hsc_packer/private/hsc_packer_app.hxx @@ -11,7 +11,7 @@ #include #include -auto hscp_process_directory(ice::Allocator& alloc, ice::String dir) noexcept -> ice::HeapString<>; +auto hscp_process_directory(ice::Allocator& alloc, ice::Path dir) noexcept -> ice::HeapString<>; static constexpr ice::LogTagDefinition LogTag_Main = ice::create_log_tag(ice::LogTag::None, "hsc-packer"); static constexpr ice::LogTagDefinition LogTag_Details = ice::create_log_tag(LogTag_Main, "details"); From 7b0990d28c30bdf1a67e6451d11fa5f274edebea Mon Sep 17 00:00:00 2001 From: Dandielo Date: Wed, 21 Jan 2026 17:31:52 +0900 Subject: [PATCH 33/40] Update README.md --- README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 75c03725..47f7b475 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,9 @@ Thid party tools and features: #### Linux _(Tested)_ ![Code validation result for Linux targets.](https://github.com/iceshard-engine/engine/actions/workflows/build-validate-linux.yaml/badge.svg) -#### Android _(Untested)_ +#### Android _(Tested)_ ![Code validation result for Android targets.](https://github.com/iceshard-engine/engine/actions/workflows/build-validate-android.yaml/badge.svg) -##### Known issues -* The x64 binaries do not load properly in emulators -* The binaries use outdated API Levels and NKD version -* The binaries are still build with 4 KiB page support instead of required 16 KiB - #### Emscripten _(Tested)_ ![Code validation result for WebAssembly targets.](https://github.com/iceshard-engine/engine/actions/workflows/build-validate-emscripten.yaml/badge.svg) @@ -60,9 +55,9 @@ To build this engine you will need the following tools and SDKs installed: * **Linux:** * Toolchain: Clang-20 * Vulkan SDK _(1.4.313.0 or later)_ -* **Android:** _(Outdated)_ - * Toolchain: NDK-27 - * AndroidAPI: 29 +* **Android:** + * Toolchain: NDK-28 + * AndroidAPI: 35 * **Web:** * Toolchain: Emscripten-v4.0.9 * **MacOS:** _(No plans)_ From dacfaa4bcb8158a0e0d3ed6ea1c5057dfc55edd8 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Wed, 21 Jan 2026 22:57:39 +0900 Subject: [PATCH 34/40] Continued refactor of Path related containers. --- .../public/ice/string/editable_operations.hxx | 2 + .../public/ice/string/string_concepts.hxx | 3 + source/code/core/utils/private/params.cxx | 37 ++++ .../core/utils/public/ice/native_file.hxx | 8 +- source/code/core/utils/public/ice/params.hxx | 6 +- .../code/core/utils/public/ice/path_utils.hxx | 182 ++++++++++++------ .../framework_base/private/framework_main.cxx | 2 +- .../private/shader_tools_glsl.cxx | 8 +- .../private/shader_tools_wgsl.cxx | 8 +- .../private/vk_shader_asset.cxx | 2 +- .../application/private/app_info.cxx | 12 +- .../application/public/ice/app_info.hxx | 6 +- .../platform/public/ice/platform_storage.hxx | 14 +- .../platform_win32/private/win32_storage.cxx | 8 +- .../platform_win32/private/win32_storage.hxx | 24 +-- .../private/resource_dynlib.cxx | 10 +- .../private/resource_dynlib.hxx | 8 +- .../private/resource_filesystem_baked.cxx | 6 +- .../private/resource_filesystem_baked.hxx | 6 +- .../private/resource_filesystem_loose.cxx | 12 +- .../private/resource_filesystem_loose.hxx | 6 +- .../private/resource_filesystem_traverser.cxx | 12 +- .../private/resource_filesystem_writable.cxx | 12 +- .../private/resource_filesystem_writable.hxx | 6 +- .../private/resource_hailstorm_entry.hxx | 2 +- .../private/resource_provider_custom.cxx | 10 +- .../private/resource_provider_dynlib.cxx | 4 +- .../private/resource_provider_filelist.cxx | 14 +- .../private/resource_provider_filesystem.cxx | 12 +- .../private/resource_provider_hailstorm.cxx | 4 +- .../private/resource_provider_hailstorm.hxx | 2 +- .../private/resource_tracker.cxx | 8 +- .../private/resource_tracker.hxx | 3 +- .../private/resource_writer_filesystem.cxx | 16 +- .../resource_system/public/ice/resource.hxx | 4 +- .../public/ice/resource_filter.hxx | 2 +- .../public/ice/resource_tracker.hxx | 4 +- .../resource_system/public/ice/uri.hxx | 7 +- .../private/asset_compiler_app.cxx | 12 +- .../asset_compiler_resource_provider.cxx | 5 +- .../asset_compiler_resource_provider.hxx | 4 +- .../tools/hsc_packer/private/hsc_packer.cxx | 6 +- .../hsc_packer/private/hsc_packer_app.cxx | 6 +- .../hsc_packer/private/hsc_packer_app.hxx | 2 +- source/code/tools/tool_base/private/tool.cxx | 2 +- 45 files changed, 314 insertions(+), 215 deletions(-) diff --git a/source/code/core/collections/public/ice/string/editable_operations.hxx b/source/code/core/collections/public/ice/string/editable_operations.hxx index f2957a7d..3f959999 100644 --- a/source/code/core/collections/public/ice/string/editable_operations.hxx +++ b/source/code/core/collections/public/ice/string/editable_operations.hxx @@ -118,6 +118,8 @@ namespace ice::string // Operators + using ReadOnlyOperations::operator[]; + template constexpr auto operator[](this Self& self, ice::nindex index) noexcept -> typename Self::ValueType& { diff --git a/source/code/core/collections/public/ice/string/string_concepts.hxx b/source/code/core/collections/public/ice/string/string_concepts.hxx index f44052ba..5128db71 100644 --- a/source/code/core/collections/public/ice/string/string_concepts.hxx +++ b/source/code/core/collections/public/ice/string/string_concepts.hxx @@ -60,6 +60,9 @@ namespace ice::string template using CharType = ConstCorrectCharType; + template + using String = typename StringT::StringType; + } // namespace ice::string namespace ice::string::detail diff --git a/source/code/core/utils/private/params.cxx b/source/code/core/utils/private/params.cxx index 679f4bd4..3e422555 100644 --- a/source/code/core/utils/private/params.cxx +++ b/source/code/core/utils/private/params.cxx @@ -324,6 +324,41 @@ namespace ice return true; } + template<> + bool params_define_internal( + CLI::App& app, + ice::Allocator&, + ice::ParamDefinition const& definition, + ice::Path& out_value + ) noexcept + { + auto fn_callback = [&out_value](CLI::results_t const& results) noexcept + { + out_value = ice::String{ results.front() }; + return true; + }; + params_setup(app.add_option(to_std(definition.name), ice::move(fn_callback)), definition); + return true; + } + + template<> + bool params_define_internal( + CLI::App& app, + ice::Allocator&, + ice::ParamDefinition const& definition, + ice::HeapPath& out_value + ) noexcept + { + auto fn_callback = [&out_value](CLI::results_t const& results) noexcept + { + std::string const& arg = results.front(); + out_value.push_back(ice::String{ std::string_view{ arg } }); + return true; + }; + params_setup(app.add_option(to_std(definition.name), ice::move(fn_callback)), definition); + return true; + } + template<> bool params_define_internal>( CLI::App& app, @@ -439,6 +474,8 @@ namespace ice IMPL_PARAMS_DEFINE(u64) IMPL_PARAMS_DEFINE(ice::String) IMPL_PARAMS_DEFINE(ice::HeapString<>) + IMPL_PARAMS_DEFINE(ice::Path) + IMPL_PARAMS_DEFINE(ice::HeapPath) IMPL_PARAMS_DEFINE(ice::Array) IMPL_PARAMS_DEFINE(ice::Array>) diff --git a/source/code/core/utils/public/ice/native_file.hxx b/source/code/core/utils/public/ice/native_file.hxx index 12a4f4d8..ac79c23c 100644 --- a/source/code/core/utils/public/ice/native_file.hxx +++ b/source/code/core/utils/public/ice/native_file.hxx @@ -19,13 +19,7 @@ namespace ice::native_file #if ISP_WINDOWS using File = ice::win32::FileHandle; using FilePath = ice::BasicPath; - struct HeapFilePath : public ice::HeapString, public ice::PathString - { - using HeapString::HeapString; - using HeapString::operator ice::BasicString; - - constexpr operator FilePath() const noexcept { return { _data, _size }; } - }; + using HeapFilePath = ice::BasicHeapPath; # define ISP_PATH_LITERAL(val) L##val #elif ISP_UNIX using File = ice::unix_::FileHandle; diff --git a/source/code/core/utils/public/ice/params.hxx b/source/code/core/utils/public/ice/params.hxx index fcf34f88..e8f5b5fd 100644 --- a/source/code/core/utils/public/ice/params.hxx +++ b/source/code/core/utils/public/ice/params.hxx @@ -2,9 +2,9 @@ /// SPDX-License-Identifier: MIT #pragma once -#include #include -#include +#include +#include namespace ice { @@ -93,6 +93,8 @@ namespace ice template<> bool params_define(ice::Params& params, ice::ParamDefinition const& definition, ice::i64& out_value) noexcept; template<> bool params_define(ice::Params& params, ice::ParamDefinition const& definition, ice::String& out_value) noexcept; template<> bool params_define(ice::Params& params, ice::ParamDefinition const& definition, ice::HeapString<>& out_value) noexcept; + template<> bool params_define(ice::Params& params, ice::ParamDefinition const& definition, ice::Path& out_value) noexcept; + template<> bool params_define(ice::Params& params, ice::ParamDefinition const& definition, ice::HeapPath& out_value) noexcept; template<> bool params_define(ice::Params& params, ice::ParamDefinition const& definition, ice::Array& out_values) noexcept; template<> bool params_define(ice::Params& params, ice::ParamDefinition const& definition, ice::Array>& out_values) noexcept; diff --git a/source/code/core/utils/public/ice/path_utils.hxx b/source/code/core/utils/public/ice/path_utils.hxx index 12465f8a..ef0f0c56 100644 --- a/source/code/core/utils/public/ice/path_utils.hxx +++ b/source/code/core/utils/public/ice/path_utils.hxx @@ -6,68 +6,11 @@ #include #include -namespace ice -{ - - struct PathString - { - template - static constexpr ice::BasicString Separator_Dot; - template - static constexpr ice::BasicString Separator_Drive; - template - static constexpr ice::BasicString Separator_Directory; - - template<> constexpr ice::BasicString Separator_Dot = "."; - template<> constexpr ice::BasicString Separator_Drive = ":"; - template<> constexpr ice::BasicString Separator_Directory = "\\/"; - template<> constexpr ice::BasicString Separator_Dot = L"."; - template<> constexpr ice::BasicString Separator_Drive = L":"; - template<> constexpr ice::BasicString Separator_Directory = L"\\/"; - - template - bool is_absolute(this Self const& self) noexcept - { - using CharType = ice::string::CharType; - - if constexpr (ice::build::is_windows) - { - if (self.size() >= 3_count) - { - return self[1] == Separator_Drive[0] && Separator_Directory.find_first_of(self[2]) != ice::nindex_none; - } - return false; - } - else - { - return self.not_empty() && self.front() == Separator_Directory[1]; - } - } - - template - bool is_relative(this Self const& self) noexcept - { - return self.is_absolute() == false; - } - }; - - template - struct BasicPath : public ice::BasicString, public ice::PathString - { - using BasicString::BasicString; - using BasicString::operator std::basic_string_view; - - constexpr BasicPath(ice::BasicString str) noexcept - : BasicString{ str } - { } - }; - - using Path = ice::BasicPath; - -} // namespace - namespace ice::path { + //! \note On windows: starts with a drive letter, on linux: checks for starting backslash. + //! \return true If the path is absolute. + bool is_absolute(ice::String path) noexcept; //! \return true If the path is just the root part. (ex. 'C:/' or '/') bool is_absolute_root(ice::String path) noexcept; @@ -127,8 +70,117 @@ namespace ice::path auto replace_filename(ice::HeapString& path, ice::WString filename) noexcept -> ice::WString; auto replace_extension(ice::HeapString& path, ice::WString extension) noexcept -> ice::WString; + template + using Path = typename StringT::PathType; + } // namespace ice::path +namespace ice +{ + + struct PathString + { + template + static constexpr ice::BasicString Separator_Dot; + template + static constexpr ice::BasicString Separator_Drive; + template + static constexpr ice::BasicString Separator_Directory; + + template<> constexpr ice::BasicString Separator_Dot = "."; + template<> constexpr ice::BasicString Separator_Drive = ":"; + template<> constexpr ice::BasicString Separator_Directory = "\\/"; + template<> constexpr ice::BasicString Separator_Dot = L"."; + template<> constexpr ice::BasicString Separator_Drive = L":"; + template<> constexpr ice::BasicString Separator_Directory = L"\\/"; + + template + bool is_absolute(this Self const& self) noexcept + { + return ice::path::is_absolute(self); + } + + template + bool is_relative(this Self const& self) noexcept + { + return self.is_absolute() == false; + } + + template + constexpr auto extension(this Self const& self) noexcept -> ice::string::String + { + return ice::path::extension(self); + } + + template + constexpr auto filename(this Self const& self) noexcept -> ice::string::String + { + return ice::path::filename(self); + } + + template + constexpr auto basename(this Self const& self) noexcept -> ice::string::String + { + return ice::path::basename(self); + } + + template + constexpr auto directory(this Self const& self) noexcept -> ice::path::Path + { + return ice::path::Path{ ice::path::directory(self) }; + } + }; + + struct HeapPathString : public PathString + { + template + auto append(this Self& self, ice::path::Path other) noexcept -> ice::path::Path + { + return ice::path::Path{ ice::path::join(self, other) }; + } + }; + + template + struct BasicPath : public ice::BasicString, public ice::PathString + { + using BasicString::BasicString; + using BasicString::operator std::basic_string_view; + using PathType = ice::BasicPath; + + constexpr BasicPath(ice::BasicString str) noexcept + : BasicString{ str } + {} + }; + + template + struct BasicHeapPath : public ice::HeapString, public ice::HeapPathString + { + using HeapString::HeapString; + using HeapString::operator ice::BasicString; + using HeapString::operator =; + using PathType = ice::BasicPath; + + constexpr operator ice::BasicPath() const noexcept { return { this->data(), this->size() }; } + }; + + using Path = ice::BasicPath; + using HeapPath = ice::BasicHeapPath; + + template + auto hash(ice::BasicPath path) noexcept + { + return ice::hash(ice::String{ path }); + } + + template + auto hash(ice::BasicHeapPath path) noexcept + { + return ice::hash(ice::String{ path }); + } + +} // namespace + + template struct fmt::formatter> : public fmt::formatter> { @@ -138,3 +190,13 @@ struct fmt::formatter> : public fmt::formatter>::format(value, ctx); } }; + +template +struct fmt::formatter> : public fmt::formatter> +{ + template + constexpr auto format(ice::BasicHeapPath value, FormatContext& ctx) const noexcept + { + return fmt::formatter>::format(value, ctx); + } +}; diff --git a/source/code/framework/framework_base/private/framework_main.cxx b/source/code/framework/framework_base/private/framework_main.cxx index 2771c076..4b5a1b29 100644 --- a/source/code/framework/framework_base/private/framework_main.cxx +++ b/source/code/framework/framework_base/private/framework_main.cxx @@ -329,7 +329,7 @@ auto ice_setup( ice::Array resource_paths{ alloc }; if constexpr (ice::build::is_release == false && (ice::build::is_windows || ice::build::is_linux)) { - dylib_path = ice::path::directory(ice::app::directory()); + dylib_path = ice::app::directory().directory(); config.dev_dirs.shaders = ice::app::workingdir(); config.dev_dirs.assets = ice::app::workingdir(); diff --git a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx index 60efa744..921d9c9c 100644 --- a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx @@ -502,9 +502,9 @@ namespace ice ) noexcept -> ice::TaskExpected { ice::ResourceResult const result = co_await tracker.load_resource(source); - ice::String const path = ice::resource_origin(source); + ice::Path const path = ice::resource_origin(source); - if (ice::path::extension(path) == ".asl") + if (path.extension() == ".asl") { auto import_loader = ice::create_script_loader(alloc, tracker); @@ -542,8 +542,8 @@ namespace ice { ShaderCompilerContext& sctx = *shader_context(ctx); - ice::String const path = ice::resource_origin(source); - ice::String const ext = ice::path::extension(path); + ice::Path const path = ice::resource_origin(source); + ice::String const ext = path.extension(); bool const is_vertex_shader = path.substr(path.size() - (4 + ext.size()), ext.size()) == "vert"; ice::render::ShaderStageFlags const shader_stage = is_vertex_shader diff --git a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx index 0ef1a12b..8d7b8254 100644 --- a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx @@ -404,9 +404,9 @@ namespace ice ) noexcept -> ice::TaskExpected { ice::ResourceResult const result = co_await tracker.load_resource(source); - ice::String const path = ice::resource_origin(source); + ice::Path const path = ice::resource_origin(source); - if (ice::path::extension(path) == ".asl") + if (path.extension() == ".asl") { auto import_loader = ice::create_script_loader(alloc, tracker); @@ -445,8 +445,8 @@ namespace ice { ShaderCompilerContext& sctx = *shader_context(ctx); - ice::String const path = ice::resource_origin(source); - ice::String const ext = ice::path::extension(path); + ice::Path const path = ice::resource_origin(source); + ice::String const ext = path.extension(); bool const is_vertex_shader = path.substr(path.size() - (4 + ext.size()), ext.size()) == "vert"; ice::render::ShaderStageFlags const shader_stage = is_vertex_shader diff --git a/source/code/modules/vulkan_renderer/private/vk_shader_asset.cxx b/source/code/modules/vulkan_renderer/private/vk_shader_asset.cxx index 947be154..ace3ab0a 100644 --- a/source/code/modules/vulkan_renderer/private/vk_shader_asset.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_shader_asset.cxx @@ -25,7 +25,7 @@ namespace ice::render::vk return AssetState::Baked; } - ice::String const ext = ice::path::extension(uri.path()); + ice::String const ext = uri.path().extension(); if (ext == ".glsl" || ext == ".asl") { return AssetState::Raw; diff --git a/source/code/platforms/application/private/app_info.cxx b/source/code/platforms/application/private/app_info.cxx index d6cc3190..9946864f 100644 --- a/source/code/platforms/application/private/app_info.cxx +++ b/source/code/platforms/application/private/app_info.cxx @@ -20,7 +20,7 @@ namespace ice::app } #if ISP_WINDOWS - auto location() noexcept -> ice::String + auto location() noexcept -> ice::Path { static ice::StaticString<256> app_location = []() noexcept { @@ -35,16 +35,16 @@ namespace ice::app return ice::StaticString<256>{ location_utf8 }; }(); - return app_location; + return ice::Path{ app_location }; } - auto directory() noexcept -> ice::String + auto directory() noexcept -> ice::Path { - static ice::String app_directory = ice::path::directory(location()); + static ice::Path app_directory = location().directory(); return app_directory; } - auto workingdir() noexcept -> ice::String + auto workingdir() noexcept -> ice::Path { static ice::StaticString<256> working_dir = []() noexcept { @@ -59,7 +59,7 @@ namespace ice::app return ice::StaticString<256>{ location_utf8 }; }(); - return working_dir; + return ice::Path{ working_dir }; } #elif ISP_LINUX auto location() noexcept -> ice::String diff --git a/source/code/platforms/application/public/ice/app_info.hxx b/source/code/platforms/application/public/ice/app_info.hxx index 4ee89db0..c0ed8b8c 100644 --- a/source/code/platforms/application/public/ice/app_info.hxx +++ b/source/code/platforms/application/public/ice/app_info.hxx @@ -19,10 +19,10 @@ namespace ice::app auto version() noexcept -> ice::app::Version; auto name() noexcept -> ice::String; - auto location() noexcept -> ice::String; + auto location() noexcept -> ice::Path; - auto directory() noexcept -> ice::String; + auto directory() noexcept -> ice::Path; - auto workingdir() noexcept -> ice::String; + auto workingdir() noexcept -> ice::Path; } // namespace ice::app diff --git a/source/code/platforms/platform/public/ice/platform_storage.hxx b/source/code/platforms/platform/public/ice/platform_storage.hxx index d83c3240..aaf4ab43 100644 --- a/source/code/platforms/platform/public/ice/platform_storage.hxx +++ b/source/code/platforms/platform/public/ice/platform_storage.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include namespace ice::platform @@ -19,19 +19,19 @@ namespace ice::platform { //! \brief This value should be used to create resource providers. //! \return One or multiple locations containing the applications data. - virtual auto data_locations() const noexcept -> ice::Span = 0; + virtual auto data_locations() const noexcept -> ice::Span = 0; //! \return Location for storing save data between game sessions. //! \note This location may be synced with the cloud on some platforms. - virtual auto save_location() const noexcept -> ice::String = 0; + virtual auto save_location() const noexcept -> ice::Path = 0; //! \return Location for persistent generated data between game sessions. //! \note May be cleared by the user manually. - virtual auto cache_location() const noexcept -> ice::String = 0; + virtual auto cache_location() const noexcept -> ice::Path = 0; //! \return Location for temporary generated data. //! \note Data stored here may be deleted by the system at any time. - virtual auto temp_location() const noexcept -> ice::String { return cache_location(); } + virtual auto temp_location() const noexcept -> ice::Path { return cache_location(); } enum class UserContentType : uint8_t { @@ -44,7 +44,7 @@ namespace ice::platform //! \return Location for storing user created data (ex.: screenshots). //! \note If a platform does not specify a custom location, any user-accessible location should be used. - virtual auto usercontent_location(UserContentType content_type) const noexcept -> ice::String + virtual auto usercontent_location(UserContentType content_type) const noexcept -> ice::Path { return save_location(); } @@ -52,7 +52,7 @@ namespace ice::platform //! \brief This value should be used to access shared libraries to be loaded. //! \note This location is unaffected by the AppName and is system dependent. //! \return Single location with additional shared libraries to be loaded. - virtual auto dylibs_location() const noexcept -> ice::String = 0; + virtual auto dylibs_location() const noexcept -> ice::Path = 0; }; template<> diff --git a/source/code/platforms/platform_win32/private/win32_storage.cxx b/source/code/platforms/platform_win32/private/win32_storage.cxx index 914ee54d..61ddec36 100644 --- a/source/code/platforms/platform_win32/private/win32_storage.cxx +++ b/source/code/platforms/platform_win32/private/win32_storage.cxx @@ -89,17 +89,17 @@ namespace ice::platform::win32 return false; } - auto win32::Win32Storage::data_locations() const noexcept -> ice::Span + auto win32::Win32Storage::data_locations() const noexcept -> ice::Span { - static ice::String paths[]{ + static ice::Path paths[]{ ice::app::directory() }; return paths; } - auto win32::Win32Storage::dylibs_location() const noexcept -> ice::String + auto win32::Win32Storage::dylibs_location() const noexcept -> ice::Path { - return ice::path::directory(ice::app::location()); + return ice::app::location().directory(); } void win32::Win32Storage::reload_paths(ice::String appname) noexcept diff --git a/source/code/platforms/platform_win32/private/win32_storage.hxx b/source/code/platforms/platform_win32/private/win32_storage.hxx index 03c40a50..ff7388eb 100644 --- a/source/code/platforms/platform_win32/private/win32_storage.hxx +++ b/source/code/platforms/platform_win32/private/win32_storage.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #if ISP_WINDOWS @@ -24,14 +24,14 @@ namespace ice::platform::win32 //! \return 'true' If the operation was supported and successful. bool set_appname(ice::String name) noexcept; - auto data_locations() const noexcept -> ice::Span override; - auto save_location() const noexcept -> ice::String override { return _save_location; } - auto cache_location() const noexcept -> ice::String override { return _cache_location; } + auto data_locations() const noexcept -> ice::Span override; + auto save_location() const noexcept -> ice::Path override { return _save_location; } + auto cache_location() const noexcept -> ice::Path override { return _cache_location; } - auto temp_location() const noexcept -> ice::String override { return _temp_location; } - auto usercontent_location(UserContentType content_type) const noexcept -> ice::String override { return {}; } + auto temp_location() const noexcept -> ice::Path override { return _temp_location; } + auto usercontent_location(UserContentType content_type) const noexcept -> ice::Path override { return {}; } - auto dylibs_location() const noexcept -> ice::String override; + auto dylibs_location() const noexcept -> ice::Path override; [[deprecated]] auto internal_data() const noexcept -> ice::String { return {}; } @@ -44,11 +44,11 @@ namespace ice::platform::win32 void reload_paths(ice::String appname) noexcept; private: - ice::HeapString<> _save_location; - ice::HeapString<> _cache_location; - ice::HeapString<> _temp_location; - ice::HeapString<> _pictures_location; - ice::HeapString<> _other_location; + ice::HeapPath _save_location; + ice::HeapPath _cache_location; + ice::HeapPath _temp_location; + ice::HeapPath _pictures_location; + ice::HeapPath _other_location; }; diff --git a/source/code/systems/resource_system/private/resource_dynlib.cxx b/source/code/systems/resource_system/private/resource_dynlib.cxx index 35ee123d..fa610608 100644 --- a/source/code/systems/resource_system/private/resource_dynlib.cxx +++ b/source/code/systems/resource_system/private/resource_dynlib.cxx @@ -9,12 +9,12 @@ namespace ice { Resource_DynLib::Resource_DynLib( - ice::HeapString<> origin_path, + ice::HeapPath origin_path, ice::String origin_name ) noexcept : _origin_path{ ice::move(origin_path) } , _origin_name{ origin_name } - , _uri{ ice::Scheme_Dynlib, ice::path::basename(_origin_name) } + , _uri{ ice::Scheme_Dynlib, _origin_name.basename() } { } @@ -33,7 +33,7 @@ namespace ice return _origin_name; } - auto Resource_DynLib::origin() const noexcept -> ice::String + auto Resource_DynLib::origin() const noexcept -> ice::Path { return _origin_path; } @@ -48,11 +48,11 @@ namespace ice if (ice::native_file::exists_file(dll_path)) { - ice::HeapString<> data_file_path{ alloc }; + ice::HeapPath data_file_path{ alloc }; ice::native_file::path_to_string(dll_path, data_file_path); // Need to get the string first before moving the HeapString path. - ice::String const utf8_origin_name = ice::path::filename(data_file_path); + ice::String const utf8_origin_name = data_file_path.filename(); result = ice::create_resource_object( alloc, provider, diff --git a/source/code/systems/resource_system/private/resource_dynlib.hxx b/source/code/systems/resource_system/private/resource_dynlib.hxx index a94e2dad..d9910034 100644 --- a/source/code/systems/resource_system/private/resource_dynlib.hxx +++ b/source/code/systems/resource_system/private/resource_dynlib.hxx @@ -15,7 +15,7 @@ namespace ice { public: Resource_DynLib( - ice::HeapString<> origin_path, + ice::HeapPath origin_path, ice::String origin_name ) noexcept; @@ -25,11 +25,11 @@ namespace ice auto flags() const noexcept -> ice::ResourceFlags override; auto name() const noexcept -> ice::String override; - auto origin() const noexcept -> ice::String override; + auto origin() const noexcept -> ice::Path override; private: - ice::HeapString<> _origin_path; - ice::String _origin_name; + ice::HeapPath _origin_path; + ice::Path _origin_name; ice::URI _uri; }; diff --git a/source/code/systems/resource_system/private/resource_filesystem_baked.cxx b/source/code/systems/resource_system/private/resource_filesystem_baked.cxx index 52e39d71..b450b9a4 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_baked.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_baked.cxx @@ -87,7 +87,7 @@ namespace ice BakedFileResource::BakedFileResource( ice::Allocator& alloc, ice::ResourceFormatHeader const& header, - ice::HeapString<> origin, + ice::HeapPath origin, ice::HeapString<> name ) noexcept : _allocator{ alloc } @@ -117,7 +117,7 @@ namespace ice return _uri.path().substr(1); } - auto BakedFileResource::origin() const noexcept -> ice::String + auto BakedFileResource::origin() const noexcept -> ice::Path { return _origin; } @@ -196,7 +196,7 @@ namespace ice return main_resource; } - ice::HeapString<> utf8_file_path{ alloc }; + ice::HeapPath utf8_file_path{ alloc }; ice::native_file::path_to_string(file_path, utf8_file_path); ice::path::normalize(utf8_file_path); IPT_ZONE_TEXT_STR(utf8_file_path); diff --git a/source/code/systems/resource_system/private/resource_filesystem_baked.hxx b/source/code/systems/resource_system/private/resource_filesystem_baked.hxx index 6304735a..ab4e537c 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_baked.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_baked.hxx @@ -21,7 +21,7 @@ namespace ice BakedFileResource( ice::Allocator& alloc, ice::ResourceFormatHeader const& header, - ice::HeapString<> origin, + ice::HeapPath origin, ice::HeapString<> name ) noexcept; @@ -31,7 +31,7 @@ namespace ice auto flags() const noexcept -> ice::ResourceFlags override; auto name() const noexcept -> ice::String override; - auto origin() const noexcept -> ice::String override; + auto origin() const noexcept -> ice::Path override; auto size() const noexcept -> ice::usize override; @@ -53,7 +53,7 @@ namespace ice private: ice::Allocator& _allocator; ice::ResourceFormatHeader const _header; - ice::HeapString<> _origin; + ice::HeapPath _origin; ice::HeapString<> _name; ice::URI _uri; }; diff --git a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx index bf2e371f..408dbd5a 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx @@ -135,7 +135,7 @@ namespace ice ice::Allocator& alloc, ice::usize meta_size, ice::usize data_size, - ice::HeapString<> origin_path, + ice::HeapPath origin_path, ice::String origin_name, ice::String uri_path ) noexcept @@ -170,7 +170,7 @@ namespace ice return _origin_name; } - auto LooseFilesResource::origin() const noexcept -> ice::String + auto LooseFilesResource::origin() const noexcept -> ice::Path { return _origin_path; } @@ -316,15 +316,15 @@ namespace ice // We create the main resource in a different scope so we dont accidentaly use data from there { - ice::HeapString<> utf8_file_path{ alloc }; + ice::HeapPath utf8_file_path{ alloc }; ice::native_file::path_to_string(data_filepath, utf8_file_path); ice::path::normalize(utf8_file_path); IPT_ZONE_TEXT_STR(utf8_file_path); // TODO: Decide how to handle the basepath naming. - bool const remove_slash = utf8_file_path[ice::path::length(base_path)] == '/'; - ice::String const utf8_origin_name = utf8_file_path.substr(ice::path::length(base_path) + remove_slash); - ice::String const utf8_uri_path = utf8_file_path.substr(ice::path::length(uri_base_path)); + bool const remove_slash = utf8_file_path[base_path.size()] == '/'; + ice::String const utf8_origin_name = utf8_file_path.substr(base_path.size() + remove_slash); + ice::String const utf8_uri_path = utf8_file_path.substr(uri_base_path.size()); IPT_ZONE_SCOPED_NAMED("stage: create_resource"); main_resource = ice::create_resource_object( diff --git a/source/code/systems/resource_system/private/resource_filesystem_loose.hxx b/source/code/systems/resource_system/private/resource_filesystem_loose.hxx index 1aec7f37..67017cc3 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_loose.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_loose.hxx @@ -22,7 +22,7 @@ namespace ice ice::Allocator& alloc, ice::usize meta_size, ice::usize data_size, - ice::HeapString<> origin_path, + ice::HeapPath origin_path, ice::String origin_name, ice::String uri_path ) noexcept; @@ -33,7 +33,7 @@ namespace ice auto flags() const noexcept -> ice::ResourceFlags override; auto name() const noexcept -> ice::String override; - auto origin() const noexcept -> ice::String override; + auto origin() const noexcept -> ice::Path override; auto load_named_part( ice::StringID_Arg part_name, @@ -58,7 +58,7 @@ namespace ice private: ice::Allocator& _allocator; - ice::HeapString<> _origin_path; + ice::HeapPath _origin_path; ice::String _origin_name; ice::String _uri_path; ice::URI _uri; diff --git a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx index 0198b6ad..667bcf26 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx @@ -33,21 +33,21 @@ namespace ice ) noexcept { // Early out for metadata files. - if (ice::path::extension(file_path) == ISP_PATH_LITERAL(".isrm")) + if (file_path.extension() == ISP_PATH_LITERAL(".isrm")) { return; } // Handle full .isr files ice::FileSystemResource* resource = nullptr; - if (ice::path::extension(file_path) == ISP_PATH_LITERAL(".isr")) + if (file_path.extension() == ISP_PATH_LITERAL(".isr")) { resource = _callbacks.create_baked_resource(file_path); } else { ice::StackAllocator_1024 temp_alloc; - ice::native_file::FilePath const uribase = ice::path::directory(base_path); + ice::native_file::FilePath const uribase = base_path.directory(); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; metafile.reserve(512); @@ -85,7 +85,7 @@ namespace ice ) noexcept -> ice::Task<> { // Early out for metadata files. - if (ice::path::extension(file_path) == ISP_PATH_LITERAL(".isrm")) + if (file_path.extension() == ISP_PATH_LITERAL(".isrm")) { request.remaining -= 1; co_return; @@ -93,14 +93,14 @@ namespace ice // Handle full .isr files ice::FileSystemResource* resource = nullptr; - if (ice::path::extension(file_path) == ISP_PATH_LITERAL(".isr")) + if (file_path.extension() == ISP_PATH_LITERAL(".isr")) { resource = _callbacks.create_baked_resource(file_path); } else { ice::StackAllocator_1024 temp_alloc; - ice::native_file::FilePath const uribase = ice::path::directory(base_path); + ice::native_file::FilePath const uribase = base_path.directory(); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; metafile.reserve(512); diff --git a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx index 963f60ab..8c6d1b9b 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx @@ -105,7 +105,7 @@ namespace ice ice::Allocator& alloc, ice::usize meta_size, ice::usize data_size, - ice::HeapString<> origin_path, + ice::HeapPath origin_path, ice::String origin_name, ice::String uri_path ) noexcept @@ -139,7 +139,7 @@ namespace ice return _origin_name; } - auto WritableFileResource::origin() const noexcept -> ice::String + auto WritableFileResource::origin() const noexcept -> ice::Path { return _origin_path; } @@ -261,15 +261,15 @@ namespace ice // We create the main resource in a different scope so we dont accidentaly use data from there { - ice::HeapString<> utf8_file_path{ alloc }; + ice::HeapPath utf8_file_path{ alloc }; ice::native_file::path_to_string(data_filepath, utf8_file_path); ice::path::normalize(utf8_file_path); IPT_ZONE_TEXT_STR(utf8_file_path); // TODO: Decide how to handle the basepath naming. - bool const remove_slash = utf8_file_path[ice::path::length(base_path)] == '/'; - ice::String const utf8_origin_name = utf8_file_path.substr(ice::path::length(base_path) + remove_slash); - ice::String const utf8_uri_path = utf8_file_path.substr(ice::path::length(uri_base_path)); + bool const remove_slash = utf8_file_path[base_path.size()] == '/'; + ice::String const utf8_origin_name = utf8_file_path.substr(base_path.size() + remove_slash); + ice::String const utf8_uri_path = utf8_file_path.substr(uri_base_path.size()); IPT_ZONE_SCOPED_NAMED("stage: create_writable_resource"); main_resource = ice::create_resource_object( diff --git a/source/code/systems/resource_system/private/resource_filesystem_writable.hxx b/source/code/systems/resource_system/private/resource_filesystem_writable.hxx index 3466de3c..5537a80e 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_writable.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_writable.hxx @@ -21,7 +21,7 @@ namespace ice ice::Allocator& alloc, ice::usize meta_size, ice::usize data_size, - ice::HeapString<> origin_path, + ice::HeapPath origin_path, ice::String origin_name, ice::String uri_path ) noexcept; @@ -32,7 +32,7 @@ namespace ice auto flags() const noexcept -> ice::ResourceFlags override; auto name() const noexcept -> ice::String override; - auto origin() const noexcept -> ice::String override; + auto origin() const noexcept -> ice::Path override; public: // ice::FileSystemResource auto size() const noexcept -> ice::usize override; @@ -66,7 +66,7 @@ namespace ice private: ice::Allocator& _allocator; - ice::HeapString<> _origin_path; + ice::HeapPath _origin_path; ice::String _origin_name; ice::String _uri_path; ice::URI _uri; diff --git a/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx b/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx index 7a6279ef..a9f51ed6 100644 --- a/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx +++ b/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx @@ -26,7 +26,7 @@ namespace ice { return _uri.path().substr(_uri.path().find_first_of('.') + 5); } - virtual auto origin() const noexcept -> ice::String override { return _uri.path(); } + virtual auto origin() const noexcept -> ice::Path override { return _uri.path(); } hailstorm::HailstormResource const& _handle; diff --git a/source/code/systems/resource_system/private/resource_provider_custom.cxx b/source/code/systems/resource_system/private/resource_provider_custom.cxx index 62d389ce..dd8b5706 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.cxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.cxx @@ -33,13 +33,13 @@ namespace ice ) noexcept { // Early out for metadata files. - if (ice::path::extension(file_path) == ISP_PATH_LITERAL(".isrm")) + if (file_path.extension() == ISP_PATH_LITERAL(".isrm")) { return; } ice::StackAllocator_1024 temp_alloc; - ice::native_file::FilePath const uribase = ice::path::directory(base_path); + ice::native_file::FilePath const uribase = base_path.directory(); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; metafile.reserve(512); @@ -135,14 +135,14 @@ namespace ice { ice::ncount const origin_size = root_resource->origin().size(); - ice::HeapString<> predicted_path{ _allocator }; + ice::HeapPath predicted_path{ _allocator }; predicted_path.reserve(origin_size + relative_uri.path().size()); predicted_path = root_resource->origin().substr( - 0, origin_size - ice::path::filename(root_resource->name()).size() + 0, origin_size - ice::Path{ root_resource->name() }.filename().size() ); - ice::path::join(predicted_path, relative_uri.path()); + predicted_path.append(relative_uri.path()); ice::path::normalize(predicted_path); ice::u64 const resource_hash = ice::hash(ice::String{ predicted_path }); diff --git a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx index 8f55dfc5..a01e644a 100644 --- a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx +++ b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx @@ -91,14 +91,14 @@ namespace ice ResourceProvider_DynLibs* const provider = reinterpret_cast(userdata); if constexpr (ice::build::is_windows) { - if (ice::path::extension(file_path) == ISP_PATH_LITERAL(".dll")) + if (file_path.extension() == ISP_PATH_LITERAL(".dll")) { provider->on_library_file(file_path); } } if constexpr (ice::build::is_unix) { - if (ice::path::extension(file_path) == ISP_PATH_LITERAL(".so")) + if (file_path.extension() == ISP_PATH_LITERAL(".so")) { provider->on_library_file(file_path); } diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index a2c8a52e..59b9fb63 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -48,7 +48,7 @@ namespace ice } ice::ncount const basepath_size = entry.basepath.is_empty() - ? entry.path.size() - ice::path::filename(entry.path).size() + ? entry.path.size() - entry.path.filename().size() : entry.basepath.size(); _file_paths.push_back({ .path = file_path, .basepath_size = basepath_size.u32() }); @@ -74,14 +74,14 @@ namespace ice ) noexcept { // Early out for metadata files. - if (ice::path::extension(file_path) == ISP_PATH_LITERAL(".isrm")) + if (file_path.extension() == ISP_PATH_LITERAL(".isrm")) { return; } // Handle full .isr files ice::FileSystemResource* resource = nullptr; - if (ice::path::extension(file_path) == ISP_PATH_LITERAL(".isr")) + if (file_path.extension() == ISP_PATH_LITERAL(".isr")) { ice::HeapString<> uri_base{ _named_allocator }; ice::string::push_format(uri_base, "file://{}/", _virtual_hostname); @@ -92,7 +92,7 @@ namespace ice { ice::StackAllocator_1024 temp_alloc; - ice::native_file::FilePath const uribase = ice::path::directory(base_path); + ice::native_file::FilePath const uribase = base_path.directory(); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; metafile.reserve(512); @@ -221,14 +221,14 @@ namespace ice { ice::ncount const origin_size = root_resource->origin().size(); - ice::HeapString<> predicted_path{ (ice::Allocator&) _data_allocator }; + ice::HeapPath predicted_path{ (ice::Allocator&) _data_allocator }; predicted_path.reserve(origin_size + relative_uri.path().size()); predicted_path = root_resource->origin().substr( - 0, origin_size - ice::path::filename(root_resource->name()).size() + 0, origin_size - ice::Path{ root_resource->name() }.filename().size() ); - ice::path::join(predicted_path, relative_uri.path()); + predicted_path.append(relative_uri.path()); ice::path::normalize(predicted_path); ice::FileSystemResource const* found_resource = _resources.get(predicted_path, nullptr); diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx index 6af10cbd..432340e5 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx @@ -157,7 +157,7 @@ namespace ice ice::FileSystemResource* found_resource = nullptr; ice::ncount const origin_size = uri.path().size(); - ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; + ice::HeapPath predicted_path{ (ice::Allocator&) _named_allocator }; for (ice::native_file::FilePath base_path : _base_paths) { predicted_path.resize(0); @@ -169,9 +169,9 @@ namespace ice // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' if (base_path.back() != '/') { - ice::path::join(predicted_path, ".."); + predicted_path.append(".."); } - ice::path::join(predicted_path, uri.path()); + predicted_path.append(uri.path()); ice::path::normalize(predicted_path); found_resource = _resources.get(predicted_path, nullptr); @@ -216,14 +216,14 @@ namespace ice { ice::ncount const origin_size = root_resource->origin().size(); - ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; + ice::HeapPath predicted_path{ (ice::Allocator&) _named_allocator }; predicted_path.reserve(origin_size + relative_uri.path().size()); predicted_path = root_resource->origin().substr( - 0, origin_size - ice::path::filename(root_resource->name()).size() + 0, origin_size - ice::Path{ root_resource->name() }.filename().size() ); - ice::path::join(predicted_path, relative_uri.path()); + predicted_path.append(relative_uri.path()); ice::path::normalize(predicted_path); return _resources.get(predicted_path, nullptr); diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx index aaec5c8a..78b27858 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx @@ -195,14 +195,14 @@ namespace ice HailStormResourceProvider::HailStormResourceProvider( ice::Allocator& alloc, - ice::String path, + ice::Path path, ice::native_aio::AIOPort aioport ) noexcept : _allocator{ alloc, "Hailstorm" } , _data_allocator{ alloc, "Data" } , _aioport{ aioport } , _hspack_path{ _allocator } - , _packname{ _allocator, ice::path::filename(path) } + , _packname{ _allocator, path.filename() } , _header_memory{ } , _paths_memory{ } , _loaders{ _allocator } diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx index cdb367ba..92a40204 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx @@ -157,7 +157,7 @@ namespace ice public: HailStormResourceProvider( ice::Allocator& alloc, - ice::String path, + ice::Path path, ice::native_aio::AIOPort aioport ) noexcept; ~HailStormResourceProvider() noexcept override; diff --git a/source/code/systems/resource_system/private/resource_tracker.cxx b/source/code/systems/resource_system/private/resource_tracker.cxx index e6ff4a14..b28933d3 100644 --- a/source/code/systems/resource_system/private/resource_tracker.cxx +++ b/source/code/systems/resource_system/private/resource_tracker.cxx @@ -15,12 +15,12 @@ namespace ice return handle->uri(); } - auto resource_origin(ice::ResourceHandle const& handle) noexcept -> ice::String + auto resource_origin(ice::ResourceHandle const& handle) noexcept -> ice::Path { return handle->origin(); } - auto resource_path(ice::ResourceHandle const& handle) noexcept -> ice::String + auto resource_path(ice::ResourceHandle const& handle) noexcept -> ice::Path { return handle->name(); } @@ -453,8 +453,8 @@ namespace ice } // ... next with a URN with the expected library file name. - ice::HeapString<> result{ alloc, name }; - if (ice::path::extension(name) == "") // Check that we have already a full file name. + ice::HeapPath result{ alloc, name }; + if (result.extension() == "") // Check that we have already a full file name. { if constexpr (ice::build::is_windows) { diff --git a/source/code/systems/resource_system/private/resource_tracker.hxx b/source/code/systems/resource_system/private/resource_tracker.hxx index b4af5b6a..1ecde8f4 100644 --- a/source/code/systems/resource_system/private/resource_tracker.hxx +++ b/source/code/systems/resource_system/private/resource_tracker.hxx @@ -9,8 +9,7 @@ #include #include -#include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx index 0c850fd9..8703f30a 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx @@ -151,7 +151,7 @@ namespace ice ice::ncount const origin_size = uri.path().size(); - ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; + ice::HeapPath predicted_path{ (ice::Allocator&) _named_allocator }; predicted_path.resize(0); predicted_path.reserve(origin_size + _base_path.size()); ice::native_file::path_to_string(_base_path, predicted_path); @@ -161,9 +161,9 @@ namespace ice // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' if (_base_path.back() != '/') { - ice::path::join(predicted_path, ".."); + predicted_path.append(".."); } - ice::path::join(predicted_path, uri.path()); + predicted_path.append(uri.path()); ice::path::normalize(predicted_path); return _resources.get(predicted_path, nullptr); @@ -202,14 +202,14 @@ namespace ice { ice::ncount const origin_size = root_resource->origin().size(); - ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; + ice::HeapPath predicted_path{ (ice::Allocator&) _named_allocator }; predicted_path.reserve(origin_size + relative_uri.path().size()); predicted_path = root_resource->origin().substr( - 0, origin_size - ice::path::filename(root_resource->name()).size() + 0, origin_size - ice::Path{ root_resource->name() }.filename().size() ); - ice::path::join(predicted_path, relative_uri.path()); + predicted_path.append(relative_uri.path()); ice::path::normalize(predicted_path); return _resources.get(predicted_path, nullptr); @@ -255,13 +255,13 @@ namespace ice // Create the final directory // #TODO: Research if checking for existance improves performance. - bool const success = ice::native_file::create_directory(ice::path::directory(predicted_metapath)); + bool const success = ice::native_file::create_directory(predicted_metapath.directory()); ICE_ASSERT_CORE(success); } ice::FileSystemResource* new_resource = this->create_loose_resource( _base_path, - ice::path::directory(_base_path), + _base_path.directory(), predicted_metapath, predicted_metapath.substr(0, predicted_path_len) ); diff --git a/source/code/systems/resource_system/public/ice/resource.hxx b/source/code/systems/resource_system/public/ice/resource.hxx index 00ceee1f..9c93b8bf 100644 --- a/source/code/systems/resource_system/public/ice/resource.hxx +++ b/source/code/systems/resource_system/public/ice/resource.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace ice @@ -20,7 +20,7 @@ namespace ice virtual auto flags() const noexcept -> ice::ResourceFlags = 0; virtual auto name() const noexcept -> ice::String = 0; - virtual auto origin() const noexcept -> ice::String = 0; + virtual auto origin() const noexcept -> ice::Path = 0; }; //! \todo Rethink how loose resources and their named parts can be accessed. diff --git a/source/code/systems/resource_system/public/ice/resource_filter.hxx b/source/code/systems/resource_system/public/ice/resource_filter.hxx index d537f535..5abf7ee3 100644 --- a/source/code/systems/resource_system/public/ice/resource_filter.hxx +++ b/source/code/systems/resource_system/public/ice/resource_filter.hxx @@ -49,7 +49,7 @@ namespace ice ice::Resource const* resource ) const noexcept override { - return _extension.is_empty() || ice::path::extension(resource->origin()) == _extension; + return _extension.is_empty() || resource->origin().extension() == _extension; } private: diff --git a/source/code/systems/resource_system/public/ice/resource_tracker.hxx b/source/code/systems/resource_system/public/ice/resource_tracker.hxx index 8643160e..808144ae 100644 --- a/source/code/systems/resource_system/public/ice/resource_tracker.hxx +++ b/source/code/systems/resource_system/public/ice/resource_tracker.hxx @@ -124,8 +124,8 @@ namespace ice }; auto resource_uri(ice::ResourceHandle const& handle) noexcept -> ice::URI const&; - auto resource_origin(ice::ResourceHandle const& handle) noexcept -> ice::String; - auto resource_path(ice::ResourceHandle const& handle) noexcept -> ice::String; + auto resource_origin(ice::ResourceHandle const& handle) noexcept -> ice::Path; + auto resource_path(ice::ResourceHandle const& handle) noexcept -> ice::Path; auto resource_meta(ice::ResourceHandle const& handle, ice::Data& out_metadata) noexcept -> ice::Task; auto get_loose_resource(ice::ResourceHandle const& handle) noexcept -> ice::LooseResource const*; diff --git a/source/code/systems/resource_system/public/ice/uri.hxx b/source/code/systems/resource_system/public/ice/uri.hxx index 505c2125..74a3e5f6 100644 --- a/source/code/systems/resource_system/public/ice/uri.hxx +++ b/source/code/systems/resource_system/public/ice/uri.hxx @@ -4,6 +4,7 @@ #pragma once #include #include +#include namespace ice { @@ -27,7 +28,7 @@ namespace ice constexpr auto scheme() const noexcept -> ice::StringID; - constexpr auto path() const noexcept -> ice::String; + constexpr auto path() const noexcept -> ice::Path; constexpr auto query() const noexcept -> ice::String; constexpr auto fragment() const noexcept -> ice::String; @@ -277,9 +278,9 @@ namespace ice : ice::stringid(ice::String{_uri, ice::u32(_scheme - 1)}); } - constexpr auto URI::path() const noexcept -> ice::String + constexpr auto URI::path() const noexcept -> ice::Path { - return ice::String{ _uri + _scheme + _authority, _path }; + return ice::Path{ _uri + _scheme + _authority, _path }; } constexpr auto URI::query() const noexcept -> ice::String diff --git a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx index 4b228e47..731a65ef 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx @@ -205,7 +205,7 @@ class AssetCompilerApp : public ice::tool::ToolApp return 1; } - ice::String const res_ext = ice::path::extension(ice::resource_origin(res)); + ice::String const res_ext = ice::resource_origin(res).extension(); ice::ResourceCompiler const* resource_compiler = nullptr; @@ -251,7 +251,7 @@ class AssetCompilerApp : public ice::tool::ToolApp ICE_LOG_IF(result == ice::E_Fail, ice::LogSeverity::Warning, ice::LogTag::Tool, "{}", result.error()); } - ice::HeapString<> final_asset_name{ _allocator, _asset_resource }; + ice::HeapPath final_asset_name{ _allocator, _asset_resource }; // If asset is in 'raw' format execute the resource compiler. // if (state == ice::AssetState::Raw) @@ -270,7 +270,7 @@ class AssetCompilerApp : public ice::tool::ToolApp } // Get the extension from the provided argument or empty - ice::String result_extension = ice::path::extension(final_asset_name); + ice::String result_extension = final_asset_name.extension(); // ... but replace it if bake results expects a specific extension. if (resource_compiler->fn_bake_result_extension != nullptr) @@ -290,17 +290,17 @@ class AssetCompilerApp : public ice::tool::ToolApp } } // If asset name has no extension, attach the result extension - else if (ice::path::extension(final_asset_name).is_empty()) + else if (final_asset_name.extension().is_empty()) { ice::path::replace_extension(final_asset_name, result_extension); } // Warn if the final extension is different than what the resource compiler expects. ICE_LOG_IF( - result_extension.not_empty() && ice::path::extension(final_asset_name) != result_extension, + result_extension.not_empty() && final_asset_name.extension() != result_extension, ice::LogSeverity::Warning, ice::LogTag::Tool, "Asset compiler result extension '{}' differs from provided asset name extension {}!", - result_extension, ice::path::extension(final_asset_name) + result_extension, final_asset_name.extension() ); ice::ResourceCompilerCtx ctx{ .userdata = nullptr }; diff --git a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx index 97ee3636..c419dd61 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx @@ -47,11 +47,10 @@ auto AssetCompilerResource::flags() const noexcept -> ice::ResourceFlags auto AssetCompilerResource::name() const noexcept -> ice::String { - // return ice::path::filename(_path); - return ice::path::basename(_path); + return _path.basename(); } -auto AssetCompilerResource::origin() const noexcept -> ice::String +auto AssetCompilerResource::origin() const noexcept -> ice::Path { return _path; } diff --git a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx index e06b09d3..ddd8aa2f 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx @@ -22,7 +22,7 @@ public: auto flags() const noexcept -> ice::ResourceFlags override; auto name() const noexcept -> ice::String override; - auto origin() const noexcept -> ice::String override; + auto origin() const noexcept -> ice::Path override; auto file() const noexcept -> ice::native_file::File const& { return _handle; } @@ -32,7 +32,7 @@ private: ice::Allocator& _allocator; ice::native_file::File _handle; ice::Memory _metadata; - ice::String _path; + ice::Path _path; ice::URI _uri; }; diff --git a/source/code/tools/hsc_packer/private/hsc_packer.cxx b/source/code/tools/hsc_packer/private/hsc_packer.cxx index 096735c2..63a16fc8 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer.cxx @@ -188,7 +188,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp // } // Prepare the output file name. - _param_output = hscp_process_directory(_allocator, ice::Path{ _param_output }); + _param_output = hscp_process_directory(_allocator, _param_output); // The paths that will be searched for loose file resources. ice::UniquePtr fsprov = ice::create_resource_provider( @@ -234,7 +234,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp auto run_explicit() noexcept -> ice::i32 { // Prepare the output file name. - _param_output = hscp_process_directory(_allocator, ice::Path{ _param_output }); + _param_output = hscp_process_directory(_allocator, _param_output); // The paths that will be searched for loose file resources. ice::Array files{ _allocator }; @@ -394,7 +394,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp // Params ice::Array _param_includes; ice::Array _param_configs; - ice::HeapString<> _param_output; + ice::HeapPath _param_output; bool _param_verbose; ice::Array _inputs; diff --git a/source/code/tools/hsc_packer/private/hsc_packer_app.cxx b/source/code/tools/hsc_packer/private/hsc_packer_app.cxx index 2167520d..dd3e955a 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer_app.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer_app.cxx @@ -8,13 +8,13 @@ #include #include -auto hscp_process_directory(ice::Allocator& alloc, ice::Path dir) noexcept -> ice::HeapString<> +auto hscp_process_directory(ice::Allocator& alloc, ice::Path dir) noexcept -> ice::HeapPath { - ice::HeapString<> searched_utf8_path{ alloc, dir }; + ice::HeapPath searched_utf8_path{ alloc, dir }; if (dir.is_relative()) { searched_utf8_path = ice::app::workingdir(); - ice::path::join(searched_utf8_path, dir); + searched_utf8_path.append(dir); } ice::path::normalize(searched_utf8_path); diff --git a/source/code/tools/hsc_packer/private/hsc_packer_app.hxx b/source/code/tools/hsc_packer/private/hsc_packer_app.hxx index 19a3de91..f98f6077 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer_app.hxx +++ b/source/code/tools/hsc_packer/private/hsc_packer_app.hxx @@ -11,7 +11,7 @@ #include #include -auto hscp_process_directory(ice::Allocator& alloc, ice::Path dir) noexcept -> ice::HeapString<>; +auto hscp_process_directory(ice::Allocator& alloc, ice::Path dir) noexcept -> ice::HeapPath; static constexpr ice::LogTagDefinition LogTag_Main = ice::create_log_tag(ice::LogTag::None, "hsc-packer"); static constexpr ice::LogTagDefinition LogTag_Details = ice::create_log_tag(LogTag_Main, "details"); diff --git a/source/code/tools/tool_base/private/tool.cxx b/source/code/tools/tool_base/private/tool.cxx index d4c7b6e7..68bee2c9 100644 --- a/source/code/tools/tool_base/private/tool.cxx +++ b/source/code/tools/tool_base/private/tool.cxx @@ -25,7 +25,7 @@ auto ice::tool::path_current_directory() noexcept -> ice::native_file::HeapFileP auto ice::tool::path_make_absolute(ice::native_file::FilePath path) noexcept -> ice::native_file::HeapFilePath { ice::native_file::HeapFilePath searched_utf8_path{ global_allocator(), path }; - if (ice::path::is_absolute(path) == false) + if (path.is_relative()) { searched_utf8_path.clear(); ice::path::join(searched_utf8_path, ice::tool::path_current_directory()); From 2924735fc5df2f113c4c5791e2ad96918b169db8 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Thu, 22 Jan 2026 23:25:59 +0900 Subject: [PATCH 35/40] Finalize the changes to ice::Path and ice::HeapPath types. #ICE-214 State In Review --- .../core/utils/public/ice/native_file.hxx | 2 +- .../code/core/utils/public/ice/path_utils.hxx | 20 ++++++++++++++++++- .../framework_base/private/framework_main.cxx | 12 +++++------ .../platform_win32/private/win32_storage.cxx | 6 +++--- .../private/resource_filesystem_baked.cxx | 2 +- .../private/resource_filesystem_loose.cxx | 2 +- .../private/resource_filesystem_writable.cxx | 2 +- .../private/resource_provider_custom.cxx | 4 ++-- .../private/resource_provider_dynlib.cxx | 2 +- .../private/resource_provider_filelist.cxx | 8 ++++---- .../private/resource_provider_filesystem.cxx | 12 +++++------ .../private/resource_writer_filesystem.cxx | 16 +++++++-------- .../private/asset_compiler_app.cxx | 4 ++-- .../hsc_packer/private/hsc_packer_app.cxx | 4 ++-- source/code/tools/tool_base/private/tool.cxx | 6 +++--- 15 files changed, 60 insertions(+), 42 deletions(-) diff --git a/source/code/core/utils/public/ice/native_file.hxx b/source/code/core/utils/public/ice/native_file.hxx index ac79c23c..37f7c023 100644 --- a/source/code/core/utils/public/ice/native_file.hxx +++ b/source/code/core/utils/public/ice/native_file.hxx @@ -166,7 +166,7 @@ namespace ice::native_file (ice::native_file::path_join_string(result, ice::forward(strings)), ...); if constexpr (ice::has_all(Flags, PathFlags::Normalized)) { - ice::path::normalize(result); + result.normalize(); } return result; } diff --git a/source/code/core/utils/public/ice/path_utils.hxx b/source/code/core/utils/public/ice/path_utils.hxx index ef0f0c56..ec1f5a90 100644 --- a/source/code/core/utils/public/ice/path_utils.hxx +++ b/source/code/core/utils/public/ice/path_utils.hxx @@ -134,10 +134,28 @@ namespace ice struct HeapPathString : public PathString { template - auto append(this Self& self, ice::path::Path other) noexcept -> ice::path::Path + auto join(this Self& self, ice::path::Path other) noexcept -> ice::path::Path { return ice::path::Path{ ice::path::join(self, other) }; } + + template + auto normalize(this Self& self) noexcept -> ice::path::Path + { + return ice::path::Path{ ice::path::normalize(self) }; + } + + template + auto replace_filename(this Self& self, ice::string::String filename) noexcept -> ice::path::Path + { + return ice::path::Path{ ice::path::replace_filename(self, filename) }; + } + + template + auto replace_extension(this Self& self, ice::string::String extension) noexcept -> ice::path::Path + { + return ice::path::Path{ ice::path::replace_extension(self, extension) }; + } }; template diff --git a/source/code/framework/framework_base/private/framework_main.cxx b/source/code/framework/framework_base/private/framework_main.cxx index 4b5a1b29..43b1bf2f 100644 --- a/source/code/framework/framework_base/private/framework_main.cxx +++ b/source/code/framework/framework_base/private/framework_main.cxx @@ -94,8 +94,8 @@ struct ice::app::Config , assets{ alloc } { } - ice::HeapString<> shaders; - ice::HeapString<> assets; + ice::HeapPath shaders; + ice::HeapPath assets; } dev_dirs; }; @@ -334,10 +334,10 @@ auto ice_setup( config.dev_dirs.assets = ice::app::workingdir(); // Assumes the apps working-dir is in 'build' and no changes where done to shader compilation step - ice::path::join(config.dev_dirs.shaders, "obj/VkShaders/GFX-Vulkan-Unoptimized-vk-glslc-1-3/data"); - ice::path::join(config.dev_dirs.assets, "../source/data"); - ice::path::normalize(config.dev_dirs.shaders); - ice::path::normalize(config.dev_dirs.assets); + config.dev_dirs.shaders.join("obj/VkShaders/GFX-Vulkan-Unoptimized-vk-glslc-1-3/data"); + config.dev_dirs.assets.join("../source/data"); + config.dev_dirs.shaders.normalize(); + config.dev_dirs.assets.normalize(); config.dev_dirs.shaders.push_back('/'); config.dev_dirs.assets.push_back('/'); resource_paths.push_back(config.dev_dirs.assets); diff --git a/source/code/platforms/platform_win32/private/win32_storage.cxx b/source/code/platforms/platform_win32/private/win32_storage.cxx index 61ddec36..37b7de79 100644 --- a/source/code/platforms/platform_win32/private/win32_storage.cxx +++ b/source/code/platforms/platform_win32/private/win32_storage.cxx @@ -22,7 +22,7 @@ namespace ice::platform::win32 namespace detail { - void get_known_path(ice::HeapString<>& out_path, const GUID& known_path_guid, ice::String appname = {}) + void get_known_path(ice::HeapPath& out_path, const GUID& known_path_guid, ice::String appname = {}) { PWSTR path; if (SHGetKnownFolderPath(known_path_guid, KF_FLAG_CREATE, NULL, &path) == S_OK) @@ -37,7 +37,7 @@ namespace ice::platform::win32 out_path.push_back(appname); out_path.push_back('\\'); } - ice::path::normalize(out_path); + out_path.normalize(); CoTaskMemFree(path); } } @@ -124,7 +124,7 @@ namespace ice::platform::win32 // GetTempPathW already returns a path ending with a slash character. DWORD const len = GetTempPathW(256, tempbuff); ice::wide_to_utf8_append({ tempbuff, ice::u32(len) }, _temp_location); - ice::path::normalize(_temp_location); + _temp_location.normalize(); } } // namespace ice diff --git a/source/code/systems/resource_system/private/resource_filesystem_baked.cxx b/source/code/systems/resource_system/private/resource_filesystem_baked.cxx index b450b9a4..69a829ba 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_baked.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_baked.cxx @@ -198,7 +198,7 @@ namespace ice ice::HeapPath utf8_file_path{ alloc }; ice::native_file::path_to_string(file_path, utf8_file_path); - ice::path::normalize(utf8_file_path); + utf8_file_path.normalize(); IPT_ZONE_TEXT_STR(utf8_file_path); ice::HeapString<> utf8_uri{ alloc }; diff --git a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx index 408dbd5a..b1fea467 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx @@ -318,7 +318,7 @@ namespace ice { ice::HeapPath utf8_file_path{ alloc }; ice::native_file::path_to_string(data_filepath, utf8_file_path); - ice::path::normalize(utf8_file_path); + utf8_file_path.normalize(); IPT_ZONE_TEXT_STR(utf8_file_path); // TODO: Decide how to handle the basepath naming. diff --git a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx index 8c6d1b9b..fd80929f 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx @@ -263,7 +263,7 @@ namespace ice { ice::HeapPath utf8_file_path{ alloc }; ice::native_file::path_to_string(data_filepath, utf8_file_path); - ice::path::normalize(utf8_file_path); + utf8_file_path.normalize(); IPT_ZONE_TEXT_STR(utf8_file_path); // TODO: Decide how to handle the basepath naming. diff --git a/source/code/systems/resource_system/private/resource_provider_custom.cxx b/source/code/systems/resource_system/private/resource_provider_custom.cxx index dd8b5706..a5a0787c 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.cxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.cxx @@ -142,8 +142,8 @@ namespace ice 0, origin_size - ice::Path{ root_resource->name() }.filename().size() ); - predicted_path.append(relative_uri.path()); - ice::path::normalize(predicted_path); + predicted_path.join(relative_uri.path()); + predicted_path.normalize(); ice::u64 const resource_hash = ice::hash(ice::String{ predicted_path }); diff --git a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx index a01e644a..9553e0e4 100644 --- a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx +++ b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx @@ -25,7 +25,7 @@ namespace ice , _resources{ _allocator } { ice::native_file::path_from_string(_base_path, path); - ice::path::normalize(_base_path); + _base_path.normalize(); } ~ResourceProvider_DynLibs() noexcept override diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index 59b9fb63..e79c5bc6 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -174,11 +174,11 @@ namespace ice ice::FileSystemResource* found_resource = nullptr; - ice::HeapString<> predicted_path{ (ice::Allocator&)_named_allocator }; + ice::HeapPath predicted_path{ (ice::Allocator&)_named_allocator }; for (ice::FileListEntry const& file_entry : _file_paths) { ice::native_file::path_to_string(file_entry.path, predicted_path); - ice::path::normalize(predicted_path); + predicted_path.normalize(); if (found_resource = _resources.get(uri.path(), nullptr); found_resource != nullptr) { @@ -228,8 +228,8 @@ namespace ice 0, origin_size - ice::Path{ root_resource->name() }.filename().size() ); - predicted_path.append(relative_uri.path()); - ice::path::normalize(predicted_path); + predicted_path.join(relative_uri.path()); + predicted_path.normalize(); ice::FileSystemResource const* found_resource = _resources.get(predicted_path, nullptr); if (found_resource != nullptr) diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx index 432340e5..f6470be9 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx @@ -32,7 +32,7 @@ namespace ice for (ice::String path : paths) { ice::native_file::path_from_string(base_path, path); - ice::path::normalize(base_path); + base_path.normalize(); _base_paths.push_back(base_path); } } @@ -169,10 +169,10 @@ namespace ice // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' if (base_path.back() != '/') { - predicted_path.append(".."); + predicted_path.join(".."); } - predicted_path.append(uri.path()); - ice::path::normalize(predicted_path); + predicted_path.join(uri.path()); + predicted_path.normalize(); found_resource = _resources.get(predicted_path, nullptr); if (found_resource != nullptr) @@ -223,8 +223,8 @@ namespace ice 0, origin_size - ice::Path{ root_resource->name() }.filename().size() ); - predicted_path.append(relative_uri.path()); - ice::path::normalize(predicted_path); + predicted_path.join(relative_uri.path()); + predicted_path.normalize(); return _resources.get(predicted_path, nullptr); } diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx index 8703f30a..09debc36 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx @@ -161,10 +161,10 @@ namespace ice // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' if (_base_path.back() != '/') { - predicted_path.append(".."); + predicted_path.join(".."); } - predicted_path.append(uri.path()); - ice::path::normalize(predicted_path); + predicted_path.join(uri.path()); + predicted_path.normalize(); return _resources.get(predicted_path, nullptr); } @@ -209,8 +209,8 @@ namespace ice 0, origin_size - ice::Path{ root_resource->name() }.filename().size() ); - predicted_path.append(relative_uri.path()); - ice::path::normalize(predicted_path); + predicted_path.join(relative_uri.path()); + predicted_path.normalize(); return _resources.get(predicted_path, nullptr); } @@ -236,17 +236,17 @@ namespace ice predicted_metapath.resize(0); predicted_metapath.reserve(origin_size + _base_path.size()); - ice::path::join(predicted_metapath, _base_path); + predicted_metapath.join(_base_path); // Remove one directory if neccessary, because it's may be the common value of the base path and the uri path. // Note: This is because if a base path like 'dir/subdir' is provided the uri is created against 'dir/' // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' if (_base_path.back() != '/') { - ice::path::join(predicted_metapath, ISP_PATH_LITERAL("..")); + predicted_metapath.join(ISP_PATH_LITERAL("..")); } ice::native_file::path_join_string(predicted_metapath, uri.path()); - ice::path::normalize(predicted_metapath); + predicted_metapath.normalize(); // Metapath is the actuall file path + .isrm, so we just save the lenght before the appending // to have access to both paths. diff --git a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx index 731a65ef..f2a0007e 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx @@ -286,13 +286,13 @@ class AssetCompilerApp : public ice::tool::ToolApp // Replace the extension if a result extension is provided. if (result_extension.not_empty()) { - ice::path::replace_extension(final_asset_name, result_extension); + final_asset_name.replace_extension(result_extension); } } // If asset name has no extension, attach the result extension else if (final_asset_name.extension().is_empty()) { - ice::path::replace_extension(final_asset_name, result_extension); + final_asset_name.replace_extension(result_extension); } // Warn if the final extension is different than what the resource compiler expects. diff --git a/source/code/tools/hsc_packer/private/hsc_packer_app.cxx b/source/code/tools/hsc_packer/private/hsc_packer_app.cxx index dd3e955a..74e4b46e 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer_app.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer_app.cxx @@ -14,9 +14,9 @@ auto hscp_process_directory(ice::Allocator& alloc, ice::Path dir) noexcept -> ic if (dir.is_relative()) { searched_utf8_path = ice::app::workingdir(); - searched_utf8_path.append(dir); + searched_utf8_path.join(dir); } - ice::path::normalize(searched_utf8_path); + searched_utf8_path.normalize(); return searched_utf8_path; } diff --git a/source/code/tools/tool_base/private/tool.cxx b/source/code/tools/tool_base/private/tool.cxx index 68bee2c9..d1864c7b 100644 --- a/source/code/tools/tool_base/private/tool.cxx +++ b/source/code/tools/tool_base/private/tool.cxx @@ -28,10 +28,10 @@ auto ice::tool::path_make_absolute(ice::native_file::FilePath path) noexcept -> if (path.is_relative()) { searched_utf8_path.clear(); - ice::path::join(searched_utf8_path, ice::tool::path_current_directory()); - ice::path::join(searched_utf8_path, path); + searched_utf8_path.join(ice::tool::path_current_directory()); + searched_utf8_path.join(path); } - ice::path::normalize(searched_utf8_path); + searched_utf8_path.normalize(); return searched_utf8_path; } From ca27968abbfd294ea639a766d22bcf2f7f25fad9 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Wed, 28 Jan 2026 23:43:39 +0900 Subject: [PATCH 36/40] Update used FastBuild version to latest released. --- tools/conanfile.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/conanfile.txt b/tools/conanfile.txt index 270a0025..9c6c2954 100644 --- a/tools/conanfile.txt +++ b/tools/conanfile.txt @@ -1,5 +1,5 @@ [requires] -fastbuild-installer/1.12@iceshard/stable +fastbuild-installer/1.18@iceshard/stable ice-build-tools/1.12.0-alpha@iceshard/stable [generators] From ff31d33e8ecd6f0d010ac35bbb747cbf77fb76c0 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Thu, 29 Jan 2026 00:27:40 +0900 Subject: [PATCH 37/40] Incorporate 'push_format' directly into the "EditableString" mix-in. - Moved 'fmt' dependency from 'utils' to 'collections' #ICE-200, #ICE-214 State Done --- source/code/core/collections/collections.bff | 3 + .../collections/public/ice/heap_string.hxx | 10 +++ .../public/ice/shard_container.hxx | 30 +++++++-- .../core/collections/public/ice/string.hxx | 11 ++++ .../public/ice/string/editable_operations.hxx | 36 ++++++++++ source/code/core/utils/private/params.cxx | 2 +- .../public/ice/config/config_builder.hxx | 30 --------- .../core/utils/public/ice/log_formatters.hxx | 19 ------ .../code/core/utils/public/ice/path_utils.hxx | 2 +- .../core/utils/public/ice/string_utils.hxx | 48 -------------- source/code/core/utils/utils.bff | 1 - .../imgui_module/private/imgui_trait.cxx | 2 +- .../private/shader_tools_asl_importer.cxx | 8 +-- .../private/shader_tools_glsl.cxx | 66 +++++++++---------- .../private/shader_tools_wgsl.cxx | 43 ++++++------ .../private/resource_provider_filelist.cxx | 2 +- .../private/resource_provider_filesystem.cxx | 2 +- 17 files changed, 145 insertions(+), 170 deletions(-) diff --git a/source/code/core/collections/collections.bff b/source/code/core/collections/collections.bff index 963d31dd..457f91b0 100644 --- a/source/code/core/collections/collections.bff +++ b/source/code/core/collections/collections.bff @@ -11,6 +11,9 @@ .Public = [ + .Modules = { + 'fmt' + } .Uses = { 'core' 'memsys' diff --git a/source/code/core/collections/public/ice/heap_string.hxx b/source/code/core/collections/public/ice/heap_string.hxx index 0e7015ca..c86bd47e 100644 --- a/source/code/core/collections/public/ice/heap_string.hxx +++ b/source/code/core/collections/public/ice/heap_string.hxx @@ -253,3 +253,13 @@ namespace ice } } // namespace ice + +template +struct fmt::formatter> : public fmt::formatter> +{ + template + constexpr auto format(ice::HeapString const& value, FormatContext& ctx) const noexcept + { + return fmt::formatter>::format({ value._data, value._size }, ctx); + } +}; diff --git a/source/code/core/collections/public/ice/shard_container.hxx b/source/code/core/collections/public/ice/shard_container.hxx index 03d59e09..094b458e 100644 --- a/source/code/core/collections/public/ice/shard_container.hxx +++ b/source/code/core/collections/public/ice/shard_container.hxx @@ -33,10 +33,16 @@ namespace ice ) const noexcept -> ice::ncount; template - inline constexpr bool inspect_first(ice::ShardID shardid, T& payload) const noexcept; + inline constexpr bool inspect_first( + ice::ShardID shardid, + T& payload + ) const noexcept; template - inline constexpr bool inspect_last(ice::ShardID shard, T& payload) const noexcept; + inline constexpr bool inspect_last( + ice::ShardID shard, + T& payload + ) const noexcept; template inline constexpr auto inspect_all( @@ -50,7 +56,10 @@ namespace ice Fn&& callback ) noexcept -> ice::ncount; - inline constexpr void remove_all_of(this ShardContainer& self, ice::ShardID shardid) noexcept; + inline constexpr void remove_all_of( + this ShardContainer& self, + ice::ShardID shardid + ) noexcept; }; inline constexpr bool ShardContainer::contains(ice::ShardID expected_shard) const noexcept @@ -138,21 +147,30 @@ namespace ice } template - inline constexpr bool ShardContainer::inspect_first(ice::ShardID shardid, T& payload) const noexcept + inline constexpr bool ShardContainer::inspect_first( + ice::ShardID shardid, + T& payload + ) const noexcept { ice::Shard const shard = this->find_first_of(shardid); return ice::shard_inspect(shard, payload); } template - inline constexpr bool ShardContainer::inspect_last(ice::ShardID shardid, T& payload) const noexcept + inline constexpr bool ShardContainer::inspect_last( + ice::ShardID shardid, + T& payload + ) const noexcept { ice::Shard const shard = this->find_last_of(shardid); return ice::shard_inspect(shard, payload); } template - inline constexpr auto ShardContainer::inspect_each(ice::ShardID shardid, Fn&& callback) noexcept -> ice::ncount + inline constexpr auto ShardContainer::inspect_each( + ice::ShardID shardid, + Fn&& callback + ) noexcept -> ice::ncount { T payload; ice::u32 count = 0; diff --git a/source/code/core/collections/public/ice/string.hxx b/source/code/core/collections/public/ice/string.hxx index d31c8255..9c31e23f 100644 --- a/source/code/core/collections/public/ice/string.hxx +++ b/source/code/core/collections/public/ice/string.hxx @@ -5,6 +5,7 @@ #include #include #include +#include namespace ice { @@ -112,3 +113,13 @@ namespace ice } } // namespace ice + +template +struct fmt::formatter> : public fmt::formatter> +{ + template + constexpr auto format(ice::BasicString value, FormatContext& ctx) const noexcept + { + return fmt::formatter>::format(value, ctx); + } +}; diff --git a/source/code/core/collections/public/ice/string/editable_operations.hxx b/source/code/core/collections/public/ice/string/editable_operations.hxx index 3f959999..8f9925b5 100644 --- a/source/code/core/collections/public/ice/string/editable_operations.hxx +++ b/source/code/core/collections/public/ice/string/editable_operations.hxx @@ -3,6 +3,7 @@ #pragma once #include +#include namespace ice::string { @@ -80,6 +81,41 @@ namespace ice::string } } + template + inline constexpr void push_format( + this Self& self, + fmt::format_string format, + Args&&... args + ) noexcept + { + ice::ncount const pushed_size = ::fmt::formatted_size(format, std::forward(args)...); + ice::ncount const final_size = self.size() + pushed_size; + ice::ncount const capacity = self.capacity() - 1; + + // Handle resizing if supported + if constexpr (ice::concepts::ResizableStringType) + { + if (final_size >= capacity) + { + self.grow(final_size + 1); + } + + ::fmt::format_to_n(self.end(), pushed_size, format, std::forward(args)...); + } + else + { + //ICE_ASSERT_CORE(final_size < capacity); + final_size = ice::min(final_size, capacity); + + ice::ncount const allowed_growth = capacity - self.size(); + if (allowed_growth > 0) + { + ::fmt::format_to_n(self.end(), allowed_growth, format, std::forward(args)...); + } + } + self.resize(final_size); + } + template inline void pop_back(this Self& self, ice::ncount count = 1) noexcept { diff --git a/source/code/core/utils/private/params.cxx b/source/code/core/utils/private/params.cxx index 3e422555..4523f043 100644 --- a/source/code/core/utils/private/params.cxx +++ b/source/code/core/utils/private/params.cxx @@ -83,7 +83,7 @@ namespace ice ) noexcept -> ice::Params { ice::HeapString<> description_with_version{ alloc, description }; - ice::string::push_format(description_with_version, " (v{})", version); + description_with_version.push_format(" (v{})", version); return ice::make_unique( delete_params, alloc.create(alloc, name, description_with_version) diff --git a/source/code/core/utils/public/ice/config/config_builder.hxx b/source/code/core/utils/public/ice/config/config_builder.hxx index c01061c0..362a9d86 100644 --- a/source/code/core/utils/public/ice/config/config_builder.hxx +++ b/source/code/core/utils/public/ice/config/config_builder.hxx @@ -66,34 +66,4 @@ namespace ice } // namespace config - // inline auto configbuilder_root(ConfigBuilder& b, ice::Allocator& alloc) noexcept -> ice::Memory - // { - // ConfigBuilderValue val = b["asd"]; - // b["asd"][0][1]; - // b["a"]["b"] = 31u; - // val = b["a"]; - // val["c"][2] = ice::u8{42}; - // b["b"] = 32; - // b["c"] = 33; - // val = b["asd"][0];//[0][1]["ad"]; - // // b.reset(); - // val = b["e"][3]; - // b["e"][4]; - // ice::HeapVarString<>& str = b["f"] = "Test string"; - // str = "Maybe not?"; - // b["my"]["holy"]["cow"] = 69.420; - - // ice::Memory mem = b.finalize(alloc); - - // ice::Config c = ice::config::from_data(ice::data_view(mem)); - // [[maybe_unused]] - // ice::u32 f; - // ice::config::get(c, "a.b", f); - // ice::String s = ice::config::get(c, "f").value(); - // f = 23; - - // alloc.deallocate(mem); - // return {}; - // } - } // namespace ice diff --git a/source/code/core/utils/public/ice/log_formatters.hxx b/source/code/core/utils/public/ice/log_formatters.hxx index 6d19466c..007d7576 100644 --- a/source/code/core/utils/public/ice/log_formatters.hxx +++ b/source/code/core/utils/public/ice/log_formatters.hxx @@ -9,25 +9,6 @@ #include #include -template -struct fmt::formatter> : public fmt::formatter> -{ - template - constexpr auto format(ice::BasicString value, FormatContext& ctx) const noexcept - { - return fmt::formatter>::format(value, ctx); - } -}; - -template -struct fmt::formatter> : public fmt::formatter> -{ - template - constexpr auto format(ice::HeapString const& value, FormatContext& ctx) const noexcept - { - return fmt::formatter>::format({ value._data, value._size }, ctx); - } -}; template<> struct fmt::formatter diff --git a/source/code/core/utils/public/ice/path_utils.hxx b/source/code/core/utils/public/ice/path_utils.hxx index ec1f5a90..88e27730 100644 --- a/source/code/core/utils/public/ice/path_utils.hxx +++ b/source/code/core/utils/public/ice/path_utils.hxx @@ -55,7 +55,7 @@ namespace ice::path //! \returns The given path as a String value. auto replace_extension(ice::HeapString<>& path, ice::String extension) noexcept -> ice::String; - // Wider character implementations + // Wide character implementations bool is_absolute(ice::WString path) noexcept; bool is_absolute_root(ice::WString path) noexcept; diff --git a/source/code/core/utils/public/ice/string_utils.hxx b/source/code/core/utils/public/ice/string_utils.hxx index bbe5d334..474251e1 100644 --- a/source/code/core/utils/public/ice/string_utils.hxx +++ b/source/code/core/utils/public/ice/string_utils.hxx @@ -17,20 +17,6 @@ namespace ice namespace string { - template - constexpr void push_format( - ice::string::ResizableStringType auto& str, - fmt::format_string format, - Args&&... args - ) noexcept; - - template - constexpr void push_format( - ice::StaticString& str, - fmt::format_string format, - Args&&... args - ) noexcept; - template constexpr auto for_each_split( ice::String contents, @@ -184,40 +170,6 @@ namespace ice namespace string { - template - constexpr void push_format( - ice::string::ResizableStringType auto& str, - fmt::format_string format, - Args&&... args - ) noexcept - { - ice::ncount const pushed_size = fmt::formatted_size(format, ice::forward(args)...); - ice::ncount const final_size = str.size() + pushed_size; - if (final_size + 1 >= str.capacity()) - { - str.grow(final_size + 1); - } - fmt::format_to_n(str.end(), pushed_size, format, ice::forward(args)...); - str.resize(final_size); - } - - template - constexpr void push_format( - ice::StaticString& str, - fmt::format_string format, - Args&&... args - ) noexcept - { - ice::ncount const pushed_size = fmt::formatted_size(format, ice::forward(args)...); - ice::ncount const final_size = str.size() + pushed_size; - if (final_size + 1 >= Capacity) - { - final_size = Capacity - 1; - } - fmt::format_to_n(str.end(), final_size, format, ice::forward(args)...); - str.resize(final_size); - } - template constexpr auto for_each_split(ice::String contents, ice::String separator, Fn&& fn) noexcept -> ice::u32 { diff --git a/source/code/core/utils/utils.bff b/source/code/core/utils/utils.bff index ff5414ff..6e7423e8 100644 --- a/source/code/core/utils/utils.bff +++ b/source/code/core/utils/utils.bff @@ -12,7 +12,6 @@ .Public = [ .Modules = { - 'fmt' 'cli11' } .Uses = { diff --git a/source/code/modules/imgui_module/private/imgui_trait.cxx b/source/code/modules/imgui_module/private/imgui_trait.cxx index 31d3ddf4..8e2c8cbb 100644 --- a/source/code/modules/imgui_module/private/imgui_trait.cxx +++ b/source/code/modules/imgui_module/private/imgui_trait.cxx @@ -409,7 +409,7 @@ namespace ice::devui IPT_ZONE_SCOPED_NAMED("ImGui - Load texture"); ice::HeapString<> texture_name{ _allocator }; - ice::string::push_format(texture_name, detail::TextureNameFormat, texture->UniqueID); + texture_name.push_format(detail::TextureNameFormat, texture->UniqueID); IPT_ZONE_TEXT_STR(texture_name); detail::ImTextureAssetDataBinding texture_binding{ _allocator, *texture }; diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx b/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx index c37272e5..eca2f004 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx @@ -28,16 +28,16 @@ namespace ice IPT_ZONE_SCOPED; // Imports don't specify the extension so we need to add it. - ice::HeapString<> import_path_final{ _allocator }; - ice::string::push_format(import_path_final, "{}.asl", import_path); + ice::HeapPath import_path_final{ _allocator }; + import_path_final.push_format("{}.asl", import_path); // Find the resource to he loaded. ice::ResourceHandle const import_resource = _tracker.find_resource( - ice::URI{ ice::Scheme_URN, { ice::String{ import_path_final } } } + ice::URI{ ice::Scheme_URN, import_path_final } ); if (import_resource == nullptr) { - ICE_LOG(LogSeverity::Error, LogTag::Tool, "Failed to import ASL file: {}", ice::String{ import_path_final }); + ICE_LOG(LogSeverity::Error, LogTag::Tool, "Failed to import ASL file: {}", import_path_final); return {}; } diff --git a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx index 921d9c9c..570bf128 100644 --- a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx @@ -51,8 +51,7 @@ namespace ice { if (type.is_array) { - ice::string::push_format( - out_code, + out_code.push_format( " {} {}[{}];\n", type.name.value, varname, @@ -61,8 +60,7 @@ namespace ice } else { - ice::string::push_format( - out_code, + out_code.push_format( " {} {};\n", type.name.value, varname @@ -86,13 +84,13 @@ namespace ice arctic::String var_base = atom.data().value.value; var_base = subs.get(detail::arc_hash(var_base), var_base); - ice::string::push_format(out_code, "{}.", var_base); + out_code.push_format("{}.", var_base); generate_expression(out_code, subs, func, arg, op.sibling()); } else { arctic::String const atom_sub = atom.data().value.value; - ice::string::push_format(out_code, "{}", atom_sub); + out_code.push_format("{}", atom_sub); } } @@ -139,11 +137,11 @@ namespace ice syntax::Operator const& op = node.to().data(); if (op.is_unary) { - ice::string::push_format(result, "{}", op.token.value); + result.push_format("{}", op.token.value); } else { - ice::string::push_format(result, " {} ", op.token.value); + result.push_format(" {} ", op.token.value); } if (node.child()) @@ -153,7 +151,7 @@ namespace ice break; } case SyntaxEntity::E_Call: - ice::string::push_format(result, "{}(", node.to().data().name.value); + result.push_format("{}(", node.to().data().name.value); // Call children groups generate_expression(result, subs, func, arg, node.child()); result.push_back(")"); @@ -187,7 +185,7 @@ namespace ice ICE_ASSERT_CORE(typenode); syntax::Type const& type = typenode.data(); - ice::string::push_format(result, "{} {}", type.name.value, var.name.value); + result.push_format("{} {}", type.name.value, var.name.value); if (SyntaxNode assignnode = typenode.sibling(); assignnode) { @@ -232,7 +230,7 @@ namespace ice ice::HeapString<> result{ alloc }; // Initial lines - ice::string::push_format(result, "#version 450\n\n"); + result.push_format("#version 450\n\n"); // Generate struct definitions for (SyntaxNode strct : shader._structs) @@ -253,12 +251,12 @@ namespace ice continue; } - ice::string::push_format(result, "struct {} {{\n", strct.data().name.value); + result.push_format("struct {} {{\n", strct.data().name.value); SyntaxNode member = strct.child(); while (member) { syntax::Type const& type = member.child().data(); - ice::string::push_format(result, " {} {};\n", type.name.value, member.data().name.value); + result.push_format(" {} {};\n", type.name.value, member.data().name.value); member = member.sibling(); } result.push_back("};\n\n"); @@ -283,8 +281,8 @@ namespace ice arctic::String location; if (detail::arc_annotation(member, "location", location)) { - ice::string::push_format( - result, "layout (location={}) in {} in_{};\n", + result.push_format( + "layout (location={}) in {} in_{};\n", location, type.name.value, /*func_arg_name, */ member.data().name.value ); } @@ -300,8 +298,8 @@ namespace ice arctic::String location; if (detail::arc_annotation(member, "location", location)) { - ice::string::push_format( - result, "layout (location={}) out {} out_{};\n", + result.push_format( + "layout (location={}) out {} out_{};\n", location, type.name.value, /*func_arg_name, */ member.data().name.value ); } @@ -323,7 +321,7 @@ namespace ice SyntaxNode strct = shader.find_struct(variable.child()); if (member = strct.child(); member) { - ice::string::push_format(result, "layout (std140, set={}, binding={}) uniform {} {{\n", + result.push_format("layout (std140, set={}, binding={}) uniform {} {{\n", set, binding, variable.child().data().name.value ); @@ -337,10 +335,10 @@ namespace ice member = member.sibling(); } - ice::string::push_format(result, "}} {}", variable.data().name.value); + result.push_format("}} {}", variable.data().name.value); if (vartype.is_array) { - ice::string::push_format(result, "[{}]", vartype.size_array.value); + result.push_format("[{}]", vartype.size_array.value); } result.push_back(";\n\n"); } @@ -348,7 +346,7 @@ namespace ice { arctic::String const type = variable.child().data().name.value; arctic::String const name = variable.data().name.value; - ice::string::push_format(result, "layout(set={}, binding={}) uniform {} {};\n", set, binding, type, name); + result.push_format("layout(set={}, binding={}) uniform {} {};\n", set, binding, type, name); } } @@ -356,17 +354,17 @@ namespace ice { SyntaxNode strct = shader.find_struct(shader._pushcontants.child()); - ice::string::push_format(result, "layout(push_constant) uniform {} {{\n", + result.push_format("layout(push_constant) uniform {} {{\n", shader._pushcontants.child().data().name.value ); member = strct.child(); while (member) { syntax::Type const& type = member.child().data(); - ice::string::push_format(result, " {} {};\n", type.name.value, member.data().name.value); + result.push_format(" {} {};\n", type.name.value, member.data().name.value); member = member.sibling(); } - ice::string::push_format(result, "}} {};\n\n", shader._pushcontants.data().name.value); + result.push_format("}} {};\n\n", shader._pushcontants.data().name.value); } // Generate shader main @@ -376,16 +374,16 @@ namespace ice ICE_ASSERT_CORE(ret && body); - ice::string::push_format(result, "\nvoid asl_proxy_{}(", shader._mainfunc.data().name.value); + result.push_format("\nvoid asl_proxy_{}(", shader._mainfunc.data().name.value); subs.set(detail::arc_hash(arg.data().name.value), arctic::String{ "_a_inputs" }); subs.set(detail::arc_hash(shader._mainfunc.data().name.value), arctic::String{ "_a_outputs" }); - ice::string::push_format(result, "in {} _a_inputs, ", shader._inputs.data().name.value, arg.data().name.value); - ice::string::push_format(result, "out {} _a_outputs) {{\n", shader._outputs.data().name.value, shader._mainfunc.data().name.value); + result.push_format("in {} _a_inputs, ", shader._inputs.data().name.value, arg.data().name.value); + result.push_format("out {} _a_outputs) {{\n", shader._outputs.data().name.value, shader._mainfunc.data().name.value); generate_function(result, subs, shader._mainfunc.data(), arg.data(), ret.data(), body.child<>()); result.push_back("}\n"); - ice::string::push_format(result, "\nvoid {}() {{\n", "main"); // GLSL requires 'main' as the function name - ice::string::push_format(result, " {0} inputs = {0}(", shader._inputs.data().name.value); + result.push_format("\nvoid {}() {{\n", "main"); // GLSL requires 'main' as the function name + result.push_format(" {0} inputs = {0}(", shader._inputs.data().name.value); { member = shader._inputs.child(); while (member) @@ -400,15 +398,15 @@ namespace ice } else { - ice::string::push_format(result, "in_{}, ", member.data().name.value); + result.push_format("in_{}, ", member.data().name.value); } member = member.sibling(); } result.pop_back(2); } result.push_back(");\n"); - ice::string::push_format(result, " {} outputs;\n", shader._outputs.data().name.value); - ice::string::push_format(result, " asl_proxy_{}(inputs, outputs);\n", shader._mainfunc.data().name.value); + result.push_format(" {} outputs;\n", shader._outputs.data().name.value); + result.push_format(" asl_proxy_{}(inputs, outputs);\n", shader._mainfunc.data().name.value); { member = shader._outputs.child(); while (member) @@ -418,12 +416,12 @@ namespace ice { if (builtin == "position") { - ice::string::push_format(result, " gl_Position = outputs.{};\n", member.data().name.value); + result.push_format(" gl_Position = outputs.{};\n", member.data().name.value); } } else { - ice::string::push_format(result, " out_{0} = outputs.{0};\n", member.data().name.value); + result.push_format(" out_{0} = outputs.{0};\n", member.data().name.value); } member = member.sibling(); } diff --git a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx index 8d7b8254..b0de515f 100644 --- a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx @@ -35,8 +35,7 @@ namespace ice { if (type.is_array) { - ice::string::push_format( - out_code, + out_code.push_format( "{}: array<{}, {}>,\n", varname, type.name.value, @@ -45,8 +44,7 @@ namespace ice } else { - ice::string::push_format( - out_code, + out_code.push_format( "{}: {},\n", varname, type.name.value @@ -79,13 +77,13 @@ namespace ice arctic::String var_base = atom.data().value.value; var_base = subs.get(detail::arc_hash(var_base), var_base); - ice::string::push_format(out_code, "{}.", var_base); + out_code.push_format("{}.", var_base); generate_expression(out_code, subs, func, arg, op.sibling()); } else { arctic::String const atom_sub = atom.data().value.value; - ice::string::push_format(out_code, "{}", atom_sub); + out_code.push_format("{}", atom_sub); } } @@ -132,11 +130,11 @@ namespace ice syntax::Operator const& op = node.to().data(); if (op.is_unary) { - ice::string::push_format(result, "{}", op.token.value); + result.push_format("{}", op.token.value); } else { - ice::string::push_format(result, " {} ", op.token.value); + result.push_format(" {} ", op.token.value); } if (node.child()) @@ -146,7 +144,7 @@ namespace ice break; } case SyntaxEntity::E_Call: - ice::string::push_format(result, "{}(", node.to().data().name.value); + result.push_format("{}(", node.to().data().name.value); // Call children groups generate_expression(result, subs, func, arg, node.child()); result.push_back(")"); @@ -180,7 +178,7 @@ namespace ice ICE_ASSERT_CORE(typenode); syntax::Type const& type = typenode.data(); - ice::string::push_format(result, "var {}: {}", var.name.value, type.name.value); + result.push_format("var {}: {}", var.name.value, type.name.value); if (SyntaxNode assignnode = typenode.sibling(); assignnode) { @@ -226,8 +224,8 @@ namespace ice ice::HeapString<> result{ alloc }; // Initial lines - ice::string::push_format(result, "\n"); - //ice::string::push_format(result, "\n/// Generated with IceShard - ShaderTools (target: WGSL)\n\n"); + result.push_format("\n"); + //result.push_format("\n/// Generated with IceShard - ShaderTools (target: WGSL)\n\n"); // Generate struct definitions for (SyntaxNode strct : shader._structs) @@ -244,7 +242,7 @@ namespace ice is_uniform |= variable.child().data().name.value == strct.data().name.value; } - ice::string::push_format(result, "struct {} {{\n", strct.data().name.value); + result.push_format("struct {} {{\n", strct.data().name.value); SyntaxNode member = strct.child(); while (member) { @@ -253,12 +251,12 @@ namespace ice if (arctic::String location; detail::arc_annotation(member, "location", location)) { is_inout = true; - ice::string::push_format(result, " @location({}) ", location); + result.push_format(" @location({}) ", location); } else if (detail::arc_annotation(member, "builtin", location)) { is_inout = true; - ice::string::push_format(result, " @builtin({}) ", location); + result.push_format(" @builtin({}) ", location); } else { @@ -267,7 +265,7 @@ namespace ice wgsl::generate_type(result, member.data().name.value, type); - //ice::string::push_format(result, " {} {};\n", type.name.value, member.data().name.value); + //result.push_format(" {} {};\n", type.name.value, member.data().name.value); member = member.sibling(); } result.push_back("};\n\n"); @@ -306,7 +304,7 @@ namespace ice { arctic::String const type = variable.child().data().name.value; arctic::String const name = variable.data().name.value; - ice::string::push_format(result, "@group({}) @binding({}) var {}: {};\n", + result.push_format("@group({}) @binding({}) var {}: {};\n", set, binding, name, type ); } @@ -314,7 +312,7 @@ namespace ice { arctic::String const type = variable.child().data().name.value; arctic::String const name = variable.data().name.value; - ice::string::push_format(result, "@group({}) @binding({}) var {}: {};\n", + result.push_format("@group({}) @binding({}) var {}: {};\n", set, binding, name, type ); } @@ -328,15 +326,14 @@ namespace ice SyntaxNode body = ret.sibling(); ICE_ASSERT_CORE(ret && body); - ice::string::push_format(result, "@{}\n", shader._shader_stage); - ice::string::push_format(result, "fn {}(", shader._mainfunc.data().name.value); - ice::string::push_format( - result, + result.push_format("@{}\n", shader._shader_stage); + result.push_format("fn {}(", shader._mainfunc.data().name.value); + result.push_format( "in: {}) -> {} {{\n", shader._inputs.data().name.value, shader._outputs.data().name.value ); - ice::string::push_format(result, " var out: {};\n", shader._outputs.data().name.value); + result.push_format(" var out: {};\n", shader._outputs.data().name.value); subs.set(detail::arc_hash(shader._mainfunc.data().name.value), arctic::String{ "out" }); generate_function(result, subs, shader._mainfunc.data(), arg.data(), ret.data(), body.child()); result.push_back(" return out;\n"); diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index e79c5bc6..9a530658 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -84,7 +84,7 @@ namespace ice if (file_path.extension() == ISP_PATH_LITERAL(".isr")) { ice::HeapString<> uri_base{ _named_allocator }; - ice::string::push_format(uri_base, "file://{}/", _virtual_hostname); + uri_base.push_format("file://{}/", _virtual_hostname); resource = create_resource_from_baked_file(_named_allocator, *this, uri_base, file_path); } diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx index f6470be9..b6ad887e 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx @@ -243,7 +243,7 @@ namespace ice if constexpr (false) { ice::HeapString<> uri_base{ _named_allocator }; - ice::string::push_format(uri_base, "file://{}/", _virtual_hostname); + uri_base.push_format("file://{}/", _virtual_hostname); return create_resource_from_baked_file(_named_allocator, *this, uri_base, filepath); } From 8760aa44971163dd1a6ba8aa081cfcf00130f574 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Thu, 29 Jan 2026 00:32:57 +0900 Subject: [PATCH 38/40] Update license headers. --- source/code/core/collections/collections.bff | 2 +- source/code/core/collections/collections_tests.bff | 2 +- .../code/core/collections/public/ice/container/linked_queue.hxx | 2 +- source/code/core/core/public/ice/build/platform.hxx | 2 +- source/code/core/tasks/public/ice/task.hxx | 2 +- source/code/core/utils/public/ice/native_file.hxx | 2 +- source/code/core/utils/utils.bff | 2 +- source/code/iceshard/iceshard/private/iceshard_runner.cxx | 2 +- .../modules/shader_tools/private/shader_tools_asl_allocator.hxx | 2 +- source/code/modules/vulkan_renderer/private/vk_shader_asset.cxx | 2 +- source/code/platforms/application/public/ice/app_info.hxx | 2 +- source/code/platforms/platform_win32/private/win32_main.cxx | 2 +- source/code/projects.bff | 2 +- source/code/systems/resource_system/private/resource_dynlib.cxx | 2 +- source/code/tools/hsc_packer/private/hsc_packer_app.cxx | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source/code/core/collections/collections.bff b/source/code/core/collections/collections.bff index 457f91b0..aa92b4d7 100644 --- a/source/code/core/collections/collections.bff +++ b/source/code/core/collections/collections.bff @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT .Project = diff --git a/source/code/core/collections/collections_tests.bff b/source/code/core/collections/collections_tests.bff index 848f37c5..7d522be2 100644 --- a/source/code/core/collections/collections_tests.bff +++ b/source/code/core/collections/collections_tests.bff @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT .Project = diff --git a/source/code/core/collections/public/ice/container/linked_queue.hxx b/source/code/core/collections/public/ice/container/linked_queue.hxx index 266299ec..3c24cbde 100644 --- a/source/code/core/collections/public/ice/container/linked_queue.hxx +++ b/source/code/core/collections/public/ice/container/linked_queue.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/core/public/ice/build/platform.hxx b/source/code/core/core/public/ice/build/platform.hxx index bbda6549..6393fb94 100644 --- a/source/code/core/core/public/ice/build/platform.hxx +++ b/source/code/core/core/public/ice/build/platform.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/tasks/public/ice/task.hxx b/source/code/core/tasks/public/ice/task.hxx index 162c2089..979f8d97 100644 --- a/source/code/core/tasks/public/ice/task.hxx +++ b/source/code/core/tasks/public/ice/task.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/utils/public/ice/native_file.hxx b/source/code/core/utils/public/ice/native_file.hxx index 37f7c023..08afc994 100644 --- a/source/code/core/utils/public/ice/native_file.hxx +++ b/source/code/core/utils/public/ice/native_file.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/utils/utils.bff b/source/code/core/utils/utils.bff index 6e7423e8..c5a7a136 100644 --- a/source/code/core/utils/utils.bff +++ b/source/code/core/utils/utils.bff @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT .Project = diff --git a/source/code/iceshard/iceshard/private/iceshard_runner.cxx b/source/code/iceshard/iceshard/private/iceshard_runner.cxx index 664bc391..ae89a775 100644 --- a/source/code/iceshard/iceshard/private/iceshard_runner.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_runner.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_runner.hxx" diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_allocator.hxx b/source/code/modules/shader_tools/private/shader_tools_asl_allocator.hxx index f2cca958..5e70f71d 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_allocator.hxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_allocator.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/modules/vulkan_renderer/private/vk_shader_asset.cxx b/source/code/modules/vulkan_renderer/private/vk_shader_asset.cxx index ace3ab0a..65a2495c 100644 --- a/source/code/modules/vulkan_renderer/private/vk_shader_asset.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_shader_asset.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_shader_asset.hxx" diff --git a/source/code/platforms/application/public/ice/app_info.hxx b/source/code/platforms/application/public/ice/app_info.hxx index c0ed8b8c..ca905410 100644 --- a/source/code/platforms/application/public/ice/app_info.hxx +++ b/source/code/platforms/application/public/ice/app_info.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/platforms/platform_win32/private/win32_main.cxx b/source/code/platforms/platform_win32/private/win32_main.cxx index 999eeea3..b12affb3 100644 --- a/source/code/platforms/platform_win32/private/win32_main.cxx +++ b/source/code/platforms/platform_win32/private/win32_main.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include diff --git a/source/code/projects.bff b/source/code/projects.bff index 4f035abf..b9a5e2bb 100644 --- a/source/code/projects.bff +++ b/source/code/projects.bff @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #once diff --git a/source/code/systems/resource_system/private/resource_dynlib.cxx b/source/code/systems/resource_system/private/resource_dynlib.cxx index fa610608..5f10ba09 100644 --- a/source/code/systems/resource_system/private/resource_dynlib.cxx +++ b/source/code/systems/resource_system/private/resource_dynlib.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_dynlib.hxx" diff --git a/source/code/tools/hsc_packer/private/hsc_packer_app.cxx b/source/code/tools/hsc_packer/private/hsc_packer_app.cxx index 74e4b46e..f358ca66 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer_app.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer_app.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "hsc_packer_app.hxx" From a960e5de9e477b2a91ba9e7446869ada21a7b1a7 Mon Sep 17 00:00:00 2001 From: Dandielo Date: Sat, 31 Jan 2026 02:16:47 +0900 Subject: [PATCH 39/40] Rename and refactor LinkedQueue and LinkedQueueRange types. - LinkedQueue(Range) -> AtomicLinkedQueue(Range) #ICE-215 State Done --- .../public/ice/atomic_linked_queue.hxx | 302 ++++++++++++++++++ .../ice/container/container_concepts.hxx | 23 +- .../ice/container/impl/linked_queue_impl.inl | 278 ---------------- .../public/ice/container/linked_queue.hxx | 104 ------ .../code/core/collections/public/ice/sort.hxx | 28 +- .../core/core/public/ice/build/platform.hxx | 6 + .../core/core/public/ice/build/warnings.hxx | 14 +- .../task_tracked_queue_promise.hxx | 6 +- .../private/internal_tasks/task_utils.hxx | 4 +- .../core/tasks/private/task_checkpoint.cxx | 4 +- .../core/tasks/private/task_native_thread.cxx | 12 +- .../core/tasks/private/task_native_thread.hxx | 2 +- source/code/core/tasks/private/task_queue.cxx | 37 +-- source/code/core/tasks/private/task_utils.cxx | 12 +- .../core/tasks/public/ice/task_awaitable.hxx | 2 +- .../code/core/tasks/public/ice/task_queue.hxx | 22 +- .../code/core/tasks/public/ice/task_stage.hxx | 2 +- .../tasks/public/ice/task_transaction.hxx | 2 +- source/code/core/utils/private/native_aio.hxx | 2 +- .../iceshard/private/iceshard_gfx_runner.cxx | 2 +- .../private/resource_internal.hxx | 2 +- .../private/resource_provider_hailstorm.cxx | 4 +- .../private/resource_provider_hailstorm.hxx | 2 +- .../private/resource_tracker.hxx | 6 +- 24 files changed, 403 insertions(+), 475 deletions(-) create mode 100644 source/code/core/collections/public/ice/atomic_linked_queue.hxx delete mode 100644 source/code/core/collections/public/ice/container/impl/linked_queue_impl.inl delete mode 100644 source/code/core/collections/public/ice/container/linked_queue.hxx diff --git a/source/code/core/collections/public/ice/atomic_linked_queue.hxx b/source/code/core/collections/public/ice/atomic_linked_queue.hxx new file mode 100644 index 00000000..c96d1c74 --- /dev/null +++ b/source/code/core/collections/public/ice/atomic_linked_queue.hxx @@ -0,0 +1,302 @@ +/// Copyright 2022 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include + +namespace ice +{ + + template + struct AtomicLinkedQueueRange; + + template + struct AtomicLinkedQueue + { + using ValueType = NodeType; + + std::atomic _head; + std::atomic _tail; + + constexpr AtomicLinkedQueue() noexcept; + constexpr ~AtomicLinkedQueue() noexcept = default; + + constexpr AtomicLinkedQueue(AtomicLinkedQueue&& other) noexcept; + constexpr AtomicLinkedQueue(AtomicLinkedQueue const& other) noexcept = delete; + + constexpr auto operator=(AtomicLinkedQueue&& other) noexcept -> AtomicLinkedQueue&; + constexpr auto operator=(AtomicLinkedQueue const& other) noexcept -> AtomicLinkedQueue& = delete; + + constexpr bool is_empty() const noexcept { return _head.load(std::memory_order_relaxed) == nullptr; } + constexpr bool not_empty() const noexcept { return is_empty() == false; } + + template + constexpr void push_back(DerivedNodeType* node) noexcept; + template + constexpr bool push_back(ice::AtomicLinkedQueueRange range) noexcept; + + [[nodiscard]] + constexpr auto take_front() noexcept -> NodeType*; + [[nodiscard]] + constexpr auto take_all() noexcept -> ice::AtomicLinkedQueueRange; + }; + + template + struct AtomicLinkedQueueRange + { + using ValueType = NodeType; + + NodeType* _head = nullptr; + NodeType* _tail = nullptr; + + struct Iterator + { + NodeType* _current; + NodeType* _next; + NodeType* _tail; + + constexpr auto operator*() const noexcept -> NodeType*; + constexpr void operator++() noexcept; + + constexpr bool operator==(Iterator other) const noexcept; + constexpr bool operator!=(Iterator other) const noexcept; + }; + + constexpr auto begin() const noexcept -> Iterator; + constexpr auto end() const noexcept -> Iterator; + + constexpr bool is_empty() const noexcept { return _head == nullptr; } + constexpr bool not_empty() const noexcept { return is_empty() == false; } + }; + + template + inline constexpr AtomicLinkedQueue::AtomicLinkedQueue() noexcept + : _head{ } + , _tail{ } + { + } + + template + inline constexpr AtomicLinkedQueue::AtomicLinkedQueue(AtomicLinkedQueue&& other) noexcept + : _head{ } + , _tail{ } + { + // We move atomically to this object + ice::AtomicLinkedQueueRange range = other.take_all(); + _head = range._head; + _tail = range._tail; + } + + template + inline constexpr auto AtomicLinkedQueue::operator=(AtomicLinkedQueue&& other) noexcept -> AtomicLinkedQueue& + { + if (this != &other) + { + // We move atomically to this object + ice::AtomicLinkedQueueRange range = other.take_all(); + _head = range._head; + _tail = range._tail; + } + return *this; + } + + template + template + inline constexpr void AtomicLinkedQueue::push_back(DerivedNodeType* node) noexcept + { + NodeType* const previous_tail = _tail.exchange(node, std::memory_order_relaxed); + + if (previous_tail == nullptr) + { + _head.store(node, std::memory_order_relaxed); + } + else + { + previous_tail->_next = node; + } + + std::atomic_thread_fence(std::memory_order_release); + } + + template + template + inline constexpr bool AtomicLinkedQueue::push_back( + ice::AtomicLinkedQueueRange range + ) noexcept + { + // If no TAIL, then the range is empty + if (range._tail == nullptr) + { + return false; + } + + // If we have a TAIL we need to also have a HEAD. + ICE_ASSERT_CORE(range._head != nullptr); + + // Appending a range is a simple as adding one node. + // - We take the tail of the range and push it as the new tail on the queue + // - We set the previous_tail->next pointer to the pushed range head or set is as the new head. + // - All other values are still intact and the operation is still atomic like it was in the single node case. + + NodeType* const previous_tail = _tail.exchange(range._tail, std::memory_order_relaxed); + + if (previous_tail == nullptr) + { + _head.store(range._head, std::memory_order_relaxed); + } + else + { + previous_tail->_next = range._head; + } + + std::atomic_thread_fence(std::memory_order_release); + return true; + } + + template + inline constexpr auto AtomicLinkedQueue::take_front() noexcept -> NodeType* + { + NodeType* volatile result_node = _head.exchange(nullptr, std::memory_order_relaxed); + + if (result_node == nullptr) + { + // TODO: Consider if we should spin 100 tries to get something if tail != nullptr. + // or let the caller always handle this case? + } + + if (result_node != nullptr) + { + NodeType* tail_node = _tail.load(std::memory_order_relaxed); + + // We only require a tail update if the result node (head) is different from the tail. + bool skip_tail_update = tail_node == result_node; + if (skip_tail_update) + { + // If tail and head are same we try to set the tail to nullptr. + // This indicates during a push that the head needs to be set again. + skip_tail_update = _tail.compare_exchange_strong( + tail_node, + nullptr, + std::memory_order_relaxed, + std::memory_order_relaxed + ); + } + + // If we failed the exchange, this means that a tail exists. + if (skip_tail_update == false) + { + // It might happen that the 'result_node' (former head) has it's '_next' pointer not yet set, + // requiring us to wait for the new 'head' pointer to be set from another thread. + NodeType volatile* next = result_node; + while (next->_next == nullptr) + { + std::atomic_thread_fence(std::memory_order_acquire); + } + + NodeType* previous = _head.exchange(next->_next, std::memory_order_relaxed); + // A '_head' pointer should never have value set during a 'take_front' operation. + ICE_ASSERT_CORE(previous == nullptr); + } + } + return result_node; + } + + template + inline constexpr auto AtomicLinkedQueue::take_all() noexcept -> ice::AtomicLinkedQueueRange + { + ice::AtomicLinkedQueueRange result{ ._head = nullptr, ._tail = nullptr }; + + NodeType* const head_result = _head.exchange(nullptr, std::memory_order_relaxed); + + // If a value existed at the '_head' that means when we take the current '_tail' + // all values are explicitly accessible only to us! + if (head_result != nullptr) + { + result._head = head_result; + result._tail = _tail.exchange(nullptr, std::memory_order_acquire); + ICE_ASSERT_CORE(result._tail != nullptr); + } + + return result; + } + + template + inline constexpr auto AtomicLinkedQueueRange::Iterator::operator*() const noexcept -> NodeType* + { + return _current; + } + + template + inline constexpr void AtomicLinkedQueueRange::Iterator::operator++() noexcept + { + if (_current != _tail) + { + ICE_ASSERT_CORE(_current != nullptr); + _current = _next; + + if (_current != _tail) + { + // TODO: Could be removed in non atomic linked queues become a thing. + // NOTE: Because we know that the 'next->next' pointer might change value from a different thread, + // it needs to be marked as volatile. + volatile NodeType* next = _next; + while (next->_next == nullptr) + { + std::atomic_thread_fence(std::memory_order_acquire); + } + + _next = next->_next; + } + } + else + { + ICE_ASSERT_CORE(_current == _tail); + _current = nullptr; + } + } + + template + inline constexpr bool AtomicLinkedQueueRange::Iterator::operator==(Iterator other) const noexcept + { + return (_tail == other._tail) && (_current == other._current); + } + + template + inline constexpr bool AtomicLinkedQueueRange::Iterator::operator!=(Iterator other) const noexcept + { + return !(*this == other); + } + + template + inline constexpr auto AtomicLinkedQueueRange::begin() const noexcept -> Iterator + { + if (_head != nullptr) + { + if (_head == _tail) + { + return { _head, nullptr, _tail }; + } + + // NOTE: Wait for the first 'next' pointer to be set from a different thread. + NodeType volatile* next = _head; + while (next->_next == nullptr) + { + std::atomic_thread_fence(std::memory_order_acquire); + } + + return { _head, next->_next, _tail }; + } + else + { + return end(); + } + } + + template + inline constexpr auto AtomicLinkedQueueRange::end() const noexcept -> Iterator + { + return { nullptr, nullptr, _tail }; + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx index 230cc1c9..4f62ae1c 100644 --- a/source/code/core/collections/public/ice/container/container_concepts.hxx +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -8,16 +8,6 @@ #include #include -namespace ice -{ - - template - concept LinkedListNode = requires(Node node) { - { node.next } -> std::convertible_to; - }; - -} // namespace ice - namespace ice::concepts { @@ -94,6 +84,19 @@ namespace ice::concepts { ice::hash(t) } -> std::convertible_to; }; + template + concept LinkedListNode = requires(Node node) { + { node._next } -> std::convertible_to; + { node._next->_next } -> std::convertible_to; + }; + + template + concept LinkedList = requires(T list) { + typename std::remove_reference_t::ValueType; + { list._head } -> std::convertible_to::ValueType>; + { list._tail } -> std::convertible_to::ValueType>; + }; + } // namespace ice::concepts namespace ice diff --git a/source/code/core/collections/public/ice/container/impl/linked_queue_impl.inl b/source/code/core/collections/public/ice/container/impl/linked_queue_impl.inl deleted file mode 100644 index 1fa3e7b1..00000000 --- a/source/code/core/collections/public/ice/container/impl/linked_queue_impl.inl +++ /dev/null @@ -1,278 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -namespace ice -{ - - template requires ice::LinkedListNode - inline AtomicLinkedQueue::AtomicLinkedQueue() noexcept - : _head{ } - , _tail{ } - { - } - - template requires ice::LinkedListNode - inline AtomicLinkedQueue::AtomicLinkedQueue(AtomicLinkedQueue&& other) noexcept - : _head{ } - , _tail{ } - { - // We move atomically to this object - ice::LinkedQueueRange range = ice::linked_queue::consume(other); - _head = range._head; - _tail = range._tail; - } - - template requires ice::LinkedListNode - inline auto AtomicLinkedQueue::operator=(AtomicLinkedQueue&& other) noexcept -> AtomicLinkedQueue& - { - if (this != &other) - { - // We move atomically to this object - ice::LinkedQueueRange range = ice::linked_queue::consume(other); - _head = range._head; - _tail = range._tail; - } - return *this; - } - - template requires ice::LinkedListNode - constexpr auto LinkedQueueRange::Iterator::operator*() const noexcept -> NodeType* - { - return _current; - } - - template requires ice::LinkedListNode - constexpr void LinkedQueueRange::Iterator::operator++() noexcept - { - if (_current != _tail) - { - ICE_ASSERT_CORE(_current != nullptr); - _current = _next; - - if (_current != _tail) - { - // TODO: Could be removed in non atomic linked queues become a thing. - // NOTE: Because we know that the 'next->next' pointer might change value from a different thread, - // it needs to be marked as volatile. - volatile NodeType* next = _next; - while (next->next == nullptr) - { - std::atomic_thread_fence(std::memory_order_acquire); - } - - _next = _next->next; - } - } - else - { - ICE_ASSERT_CORE(_current == _tail); - _current = nullptr; - } - } - - template requires ice::LinkedListNode - constexpr bool LinkedQueueRange::Iterator::operator==(Iterator other) const noexcept - { - return (_tail == other._tail) && (_current == other._current); - } - - template requires ice::LinkedListNode - constexpr bool LinkedQueueRange::Iterator::operator!=(Iterator other) const noexcept - { - return !(*this == other); - } - - namespace linked_queue - { - - template - constexpr bool any(ice::LinkedQueueRange const& queue_range) noexcept - { - return queue_range._head != nullptr; - } - - template - constexpr bool empty(ice::LinkedQueueRange const& queue_range) noexcept - { - return queue_range._head == nullptr; - } - - template - constexpr auto begin( - ice::LinkedQueueRange const& queue_range - ) noexcept -> typename ice::LinkedQueueRange::Iterator - { - if (queue_range._head != nullptr) - { - if (queue_range._head == queue_range._tail) - { - return { queue_range._head, nullptr, queue_range._tail }; - } - - // NOTE: Wait for the first 'next' pointer to be set from a different thread. - NodeType volatile* next = queue_range._head; - while (next->next == nullptr) - { - std::atomic_thread_fence(std::memory_order_acquire); - } - - return { queue_range._head, queue_range._head->next, queue_range._tail }; - } - else - { - return end(queue_range); - } - } - - template - constexpr auto end( - ice::LinkedQueueRange const& queue_range - ) noexcept -> typename ice::LinkedQueueRange::Iterator - { - return { nullptr, nullptr, queue_range._tail }; - } - - - template - inline bool any(ice::AtomicLinkedQueue const& queue) noexcept - { - return std::atomic_load_explicit(&queue._head, std::memory_order_relaxed) != nullptr; - } - - template - inline bool empty(ice::AtomicLinkedQueue const& queue) noexcept - { - return std::atomic_load_explicit(&queue._head, std::memory_order_relaxed) == nullptr; - } - - template - inline void push(ice::AtomicLinkedQueue& queue, DerivedNodeType* node) noexcept - { - NodeType* const previous_tail = std::atomic_exchange_explicit( - &queue._tail, node, std::memory_order_relaxed - ); - - if (previous_tail == nullptr) - { - std::atomic_store_explicit( - &queue._head, node, std::memory_order_relaxed - ); - } - else - { - previous_tail->next = node; - } - - std::atomic_thread_fence(std::memory_order_release); - } - - template - inline bool push(ice::AtomicLinkedQueue& queue, ice::LinkedQueueRange range) noexcept - { - // If not tail, then the range is empty - if (range._tail == nullptr) - { - return false; - } - - // If we have a tail we need to also have a head. - ICE_ASSERT_CORE(range._head != nullptr); - - // Appending a range is a simple as adding one node. - // - We take the tail of the range and push it as the new tail on the queue - // - We set the previous_tail->next pointer to the queue head or set is as the new head. - // - All other values are still intact and the operation is still atomic like it was in the single node case. - - NodeType* const previous_tail = std::atomic_exchange_explicit( - &queue._tail, range._tail, std::memory_order_relaxed - ); - - if (previous_tail == nullptr) - { - std::atomic_store_explicit( - &queue._head, range._head, std::memory_order_relaxed - ); - } - else - { - previous_tail->next = range._head; - } - - std::atomic_thread_fence(std::memory_order_release); - return true; - } - - template - inline auto pop(ice::AtomicLinkedQueue& queue) noexcept -> NodeType* - { - NodeType* result = std::atomic_exchange_explicit( - &queue._head, nullptr, std::memory_order_relaxed - ); - - if (result == nullptr) - { - // TODO: spin 100 tries to get something if tail != nullptr. - } - - if (result != nullptr) - { - NodeType* tail_node = std::atomic_load_explicit( - &queue._tail, std::memory_order_relaxed - ); - - // We 'fail' be default because `if (tail != head)` we need to update the head. - bool exchange_success = false; - if (tail_node == result) - { - // If tail and head are same we try to set the tail to nullptr. - // This indicates during a push that the head needs to be set again. - exchange_success = std::atomic_compare_exchange_strong_explicit( - &queue._tail, - &tail_node, - nullptr, - std::memory_order_relaxed, - std::memory_order_relaxed - ); - } - - // If we failed the exchange, this means that tail moved forward - if (exchange_success == false) - { - while (result->next == nullptr) - { - std::atomic_thread_fence(std::memory_order_acquire); - } - - NodeType* previous = std::atomic_exchange_explicit( - &queue._head, result->next, std::memory_order_relaxed - ); - ICE_ASSERT_CORE(previous == nullptr); - } - } - return result; - } - - template - inline auto consume(ice::AtomicLinkedQueue& queue) noexcept -> ice::LinkedQueueRange - { - ice::LinkedQueueRange result{ ._head = nullptr, ._tail = nullptr }; - - NodeType* const head_result = std::atomic_exchange_explicit( - &queue._head, nullptr, std::memory_order_relaxed - ); - - if (head_result != nullptr) - { - result._head = head_result; - result._tail = std::atomic_exchange_explicit( - &queue._tail, nullptr, std::memory_order_acquire - ); - ICE_ASSERT_CORE(result._tail != nullptr); - } - - return result; - } - - } // linked_queue - -} // namespace ice diff --git a/source/code/core/collections/public/ice/container/linked_queue.hxx b/source/code/core/collections/public/ice/container/linked_queue.hxx deleted file mode 100644 index 3c24cbde..00000000 --- a/source/code/core/collections/public/ice/container/linked_queue.hxx +++ /dev/null @@ -1,104 +0,0 @@ -/// Copyright 2022 - 2026, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -namespace ice -{ - - template - requires ice::LinkedListNode - struct AtomicLinkedQueue - { - using ValueType = NodeType; - - // TODO: BENCHMARK, Then add enough space between the atomic values to avoid false sharing. BENCHMARK AGAIN! - std::atomic _head; - std::atomic _tail; - - inline AtomicLinkedQueue() noexcept; - inline ~AtomicLinkedQueue() noexcept = default; - - inline AtomicLinkedQueue(AtomicLinkedQueue&& other) noexcept; - inline AtomicLinkedQueue(AtomicLinkedQueue const& other) noexcept = delete; - - inline auto operator=(AtomicLinkedQueue&& other) noexcept -> AtomicLinkedQueue&; - inline auto operator=(AtomicLinkedQueue const& other) noexcept -> AtomicLinkedQueue & = delete; - }; - - template - requires ice::LinkedListNode - struct LinkedQueueRange - { - using ValueType = NodeType; - - NodeType* _head; - NodeType* _tail; - - struct Iterator - { - NodeType* _current; - NodeType* _next; - NodeType* _tail; - - constexpr auto operator*() const noexcept -> NodeType*; - constexpr void operator++() noexcept; - - constexpr bool operator==(Iterator other) const noexcept; - constexpr bool operator!=(Iterator other) const noexcept; - }; - }; - - namespace linked_queue - { - - template - constexpr bool any(ice::LinkedQueueRange const& queue_range) noexcept; - - template - constexpr bool empty(ice::LinkedQueueRange const& queue_range) noexcept; - - template - constexpr auto begin( - ice::LinkedQueueRange const& queue_range - ) noexcept -> typename ice::LinkedQueueRange::Iterator; - - template - constexpr auto end( - ice::LinkedQueueRange const& queue_range - ) noexcept -> typename ice::LinkedQueueRange::Iterator; - - - template - inline bool any(ice::AtomicLinkedQueue const& queue) noexcept; - - template - inline bool empty(ice::AtomicLinkedQueue const& queue) noexcept; - - template - inline void push(ice::AtomicLinkedQueue& queue, DerivedNodeType* node) noexcept; - - template - inline bool push(ice::AtomicLinkedQueue& queue, ice::LinkedQueueRange range) noexcept; - - template - inline auto pop(ice::AtomicLinkedQueue& queue) noexcept -> NodeType*; - - template - inline auto consume(ice::AtomicLinkedQueue& queue) noexcept -> ice::LinkedQueueRange; - - } // namespace linked_queue - -} // namespace ice - -namespace ice -{ - - using ice::linked_queue::begin; - using ice::linked_queue::end; - -} // namespace ice - -#include "impl/linked_queue_impl.inl" diff --git a/source/code/core/collections/public/ice/sort.hxx b/source/code/core/collections/public/ice/sort.hxx index e3b42da0..6be99b1c 100644 --- a/source/code/core/collections/public/ice/sort.hxx +++ b/source/code/core/collections/public/ice/sort.hxx @@ -311,52 +311,52 @@ namespace ice Node* right_list = left_list; if (size == 1) { - left_list->next = nullptr; + left_list->_next = nullptr; return left_list; } else if (size == 2) { - right_list = right_list->next; - right_list->next = nullptr; - left_list->next = nullptr; + right_list = right_list->_next; + right_list->_next = nullptr; + left_list->_next = nullptr; } else { uint32_t const half_size = size / 2; for (uint32_t idx = half_size; idx > 0; --idx) { - right_list = right_list->next; + right_list = right_list->_next; } - Node* next = right_list->next; - right_list->next = nullptr; + Node* next = right_list->_next; + right_list->_next = nullptr; right_list = next; left_list = ice::sort_linked_list(left_list, half_size + 1, pred); right_list = ice::sort_linked_list(right_list, size - (half_size + 1), pred); } - Node result{ .next = left_list }; // Keep the head of the list + Node result{ ._next = left_list }; // Keep the head of the list left_list = &result; - while (left_list->next != nullptr && right_list != nullptr) + while (left_list->_next != nullptr && right_list != nullptr) { - Node* temp = left_list->next; + Node* temp = left_list->_next; if (pred(*temp, *right_list) == false) // TRUE == IS OKAY, FALSE == NEEDS SWAP { // We swapped the whole lists... - left_list->next = right_list; + left_list->_next = right_list; right_list = temp; } // We can advance the left list - left_list = left_list->next; + left_list = left_list->_next; } // Attach the rest of the right list - left_list->next = right_list; + left_list->_next = right_list; // Return the 'next' element of the result. - return result.next; + return result._next; } template diff --git a/source/code/core/core/public/ice/build/platform.hxx b/source/code/core/core/public/ice/build/platform.hxx index 6393fb94..d38f7d74 100644 --- a/source/code/core/core/public/ice/build/platform.hxx +++ b/source/code/core/core/public/ice/build/platform.hxx @@ -164,6 +164,7 @@ namespace ice::build # define ISP_ARCHFAM_X86 1 # define ISP_ARCHFAM_ARM 0 # define ISP_ARCHFAM_WEBASM 0 +# define ISP_HW_DESTRUCTIVE_INTERFERENCE 64 # define ISP_TEXT(val) L ## val #elif defined(__ANDROID__) # define ISP_UNIX 1 @@ -186,6 +187,7 @@ namespace ice::build # define ISP_ARCHFAM_WEBASM 0 static constexpr Platform current_platform = platform_android_x64_clang; # endif +# define ISP_HW_DESTRUCTIVE_INTERFERENCE 64 // NOT CHECKED # define ISP_TEXT(val) val #elif defined(EMSCRIPTEN) # define ISP_UNIX 1 @@ -202,6 +204,7 @@ namespace ice::build # define ISP_ARCHFAM_WEBASM 1 static constexpr Platform current_platform = platform_webapp_webasm32_clang; +# define ISP_HW_DESTRUCTIVE_INTERFERENCE 64 // NOT CHECKED # define ISP_TEXT(val) val #elif __unix__ && !__clang__ # define ISP_UNIX 1 @@ -217,6 +220,7 @@ namespace ice::build # define ISP_ARCHFAM_WEBASM 0 static constexpr Platform current_platform = platform_unix_x64_gcc; +# define ISP_HW_DESTRUCTIVE_INTERFERENCE 64 // NOT CHECKED # define ISP_TEXT(val) val #elif __unix__ && __clang__ # define ISP_UNIX 1 @@ -232,6 +236,7 @@ namespace ice::build # define ISP_ARCHFAM_WEBASM 0 static constexpr Platform current_platform = platform_linux_x64_clang; +# define ISP_HW_DESTRUCTIVE_INTERFERENCE 64 // NOT CHECKED # define ISP_TEXT(val) val #else # define ISP_UNIX 0 @@ -246,6 +251,7 @@ namespace ice::build # define ISP_ARCHFAM_WEBASM 0 static_assert(false, "Unknow platform!"); +# define ISP_HW_DESTRUCTIVE_INTERFERENCE ISP_UNDEFINED # define ISP_TEXT(val) ISP_UNDEFINED #endif diff --git a/source/code/core/core/public/ice/build/warnings.hxx b/source/code/core/core/public/ice/build/warnings.hxx index 63b552aa..e1156cc7 100644 --- a/source/code/core/core/public/ice/build/warnings.hxx +++ b/source/code/core/core/public/ice/build/warnings.hxx @@ -9,16 +9,19 @@ # define ISC_WARNING_PUSH __pragma(warning(push)) # define ISC_WARNING_SET(op, warn_value) __pragma(warning(op : warn_value)) # define ISC_WARNING_POP __pragma(warning(pop)) - # define ISCW_OP_DISABLE disable -// declaration of '<...>' hides class member +// warning C: ... +# define ISC_WARNING_DISABLE(id) ISC_WARNING_SET(ISCW_OP_DISABLE, id) +// warning C4324: '<...>': structure was padded due to alignment specifier +# define ISCW_STRUCTURE_WAS_PADDED_DUE_TO_ALIGNMENT_SPECIFIER(op) ISC_WARNING_SET(op, 4324) +// warning C4458: declaration of '<...>' hides class member # define ISCW_DECLARATION_HIDES_CLASS_MEMBER(op) ISC_WARNING_SET(op, 4458) -// '<...>': unreferenced function with internal linkage has been removed +// warning C4505: '<...>': unreferenced function with internal linkage has been removed # define ISCW_UNREFERENCED_INTERNAL_FUNCTION_REMOVED(op) ISC_WARNING_SET(op, 4505) -// '<...>': check operator precedence for possible error; use parentheses to clarify precedence +// warning C4554: '<...>': check operator precedence for possible error; use parentheses to clarify precedence # define ISCW_CHECK_OPERATOR_PRECEDENCE(op) ISC_WARNING_SET(op, 4554) -// operator '<...>': deprecated between enumerations of different types +// warning C5054: operator '<...>': deprecated between enumerations of different types # define ISCW_OPERATOR_DEPRECATED_BETWEEN_UNRELATED_ENUMERATIONS(op) ISC_WARNING_SET(op, 5054) #elif ISP_COMPILER_CLANG | ISP_COMPILER_GCC @@ -29,6 +32,7 @@ # define ISCW_OP_DISABLE disable +# define ISCW_STRUCTURE_WAS_PADDED_DUE_TO_ALIGNMENT_SPECIFIER(op) # define ISCW_DECLARATION_HIDES_CLASS_MEMBER(op) # define ISCW_UNREFERENCED_INTERNAL_FUNCTION_REMOVED(op) # define ISCW_CHECK_OPERATOR_PRECEDENCE(op) diff --git a/source/code/core/tasks/private/internal_tasks/task_tracked_queue_promise.hxx b/source/code/core/tasks/private/internal_tasks/task_tracked_queue_promise.hxx index d019ad05..d533232d 100644 --- a/source/code/core/tasks/private/internal_tasks/task_tracked_queue_promise.hxx +++ b/source/code/core/tasks/private/internal_tasks/task_tracked_queue_promise.hxx @@ -37,9 +37,9 @@ namespace ice // return sdone; } - inline auto pop() noexcept + inline auto take_front() noexcept { - return awaiting_queue.pop(); + return awaiting_queue.take_front(); } struct FinalAwaitable @@ -60,7 +60,7 @@ namespace ice // Can't access promise after it's destroyed. std::coroutine_handle<> continuation = coro; - if (ice::TaskAwaitableBase* awaitable = awaiting_queue->pop(); awaitable != nullptr) + if (ice::TaskAwaitableBase* awaitable = awaiting_queue->take_front(); awaitable != nullptr) { // We delete the detached coroutine here, since this would be normaly done when 'await_ready == true' after resuming // from the final suspension point. Since we are suspending, but we never resume again we just delete it here. diff --git a/source/code/core/tasks/private/internal_tasks/task_utils.hxx b/source/code/core/tasks/private/internal_tasks/task_utils.hxx index bceac42a..830e0fbe 100644 --- a/source/code/core/tasks/private/internal_tasks/task_utils.hxx +++ b/source/code/core/tasks/private/internal_tasks/task_utils.hxx @@ -188,7 +188,7 @@ namespace ice inline auto await_ready() const noexcept { // Only suspend if we actually have tasks - return queue.empty(); + return queue.is_empty(); } inline auto await_suspend(std::coroutine_handle<> coro) noexcept @@ -196,7 +196,7 @@ namespace ice ice::TaskQueue& scheduler_queue = scheduler.schedule()._queue; // We set the result value for each awaitable in the queue and nothing more. - ice::LinkedQueueRange tasks_awaitables = queue.consume(); + ice::AtomicLinkedQueueRange tasks_awaitables = queue.take_all(); for (ice::TaskAwaitableBase* task_awaitable : tasks_awaitables) { ICE_ASSERT_CORE(task_awaitable->result.ptr == nullptr); diff --git a/source/code/core/tasks/private/task_checkpoint.cxx b/source/code/core/tasks/private/task_checkpoint.cxx index 93722503..d183d845 100644 --- a/source/code/core/tasks/private/task_checkpoint.cxx +++ b/source/code/core/tasks/private/task_checkpoint.cxx @@ -51,8 +51,8 @@ namespace ice ICE_ASSERT_CORE(awaiting_count >= 0); if (awaiting_count > 0) { - ice::u32 const processed_count = _checkpoint_queue.process_all(); - ICE_ASSERT_CORE(ice::i32(processed_count) == awaiting_count); + ice::ncount const processed_count = _checkpoint_queue.process_all(); + ICE_ASSERT_CORE(processed_count == awaiting_count); } return awaiting_count > 0; } diff --git a/source/code/core/tasks/private/task_native_thread.cxx b/source/code/core/tasks/private/task_native_thread.cxx index 97aec1ec..7c5a0295 100644 --- a/source/code/core/tasks/private/task_native_thread.cxx +++ b/source/code/core/tasks/private/task_native_thread.cxx @@ -104,7 +104,7 @@ namespace ice if constexpr (BusyWait) { - if (_queue.empty()) + if (_queue.is_empty()) { if (busy_loop > 0) { @@ -159,19 +159,19 @@ namespace ice auto ThreadRuntime::exclusive_sorted_routine() noexcept -> ice::u32 { // Get the task nodes and ensure we are can access all of them. - ice::LinkedQueueRange tasks = _queue.consume(); + ice::AtomicLinkedQueueRange tasks = _queue.take_all(); ice::u32 count = 0; ice::TaskAwaitableBase volatile* head = tasks._head; while (head != tasks._tail) { // If we are not at 'tail' and encounter a nullptr, this means some thread did not write it's 'next' member yet. - while (head->next == nullptr) + while (head->_next == nullptr) { ice::thread_native::yield(); } - head = head->next; + head = head->_next; count += 1; } @@ -198,9 +198,9 @@ namespace ice // Update the head and tail pointers. tasks._tail = tasks._head; - while (tasks._tail->next != nullptr) + while (tasks._tail->_next != nullptr) { - tasks._tail = tasks._tail->next; + tasks._tail = tasks._tail->_next; } // Execute all tasks diff --git a/source/code/core/tasks/private/task_native_thread.hxx b/source/code/core/tasks/private/task_native_thread.hxx index 05d355bb..704a802f 100644 --- a/source/code/core/tasks/private/task_native_thread.hxx +++ b/source/code/core/tasks/private/task_native_thread.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include namespace ice { diff --git a/source/code/core/tasks/private/task_queue.cxx b/source/code/core/tasks/private/task_queue.cxx index f9585881..2738d570 100644 --- a/source/code/core/tasks/private/task_queue.cxx +++ b/source/code/core/tasks/private/task_queue.cxx @@ -14,14 +14,14 @@ namespace ice bool TaskQueue::push_back(ice::TaskAwaitableBase* awaitable) noexcept { - ice::linked_queue::push(_awaitables, awaitable); + _awaitables.push_back(awaitable); _awaitables._head.notify_one(); return true; } - bool TaskQueue::push_back(ice::LinkedQueueRange awaitable_range) noexcept + bool TaskQueue::push_back(ice::AtomicLinkedQueueRange awaitable_range) noexcept { - bool const result = ice::linked_queue::push(_awaitables, awaitable_range); + bool const result = _awaitables.push_back(awaitable_range); _awaitables._head.notify_all(); return result; } @@ -37,12 +37,12 @@ namespace ice while(it != end && it != awaitable) { // We wait for next pointer to be updated - while(it->next == nullptr) + while(it->_next == nullptr) { std::atomic_thread_fence(std::memory_order_acquire); } - it = it->next; + it = it->_next; } // Found our awaitable don't suspend @@ -54,19 +54,19 @@ namespace ice return true; } - auto TaskQueue::consume() noexcept -> ice::LinkedQueueRange + auto TaskQueue::take_all() noexcept -> ice::AtomicLinkedQueueRange { - return ice::linked_queue::consume(_awaitables); + return _awaitables.take_all(); } - auto TaskQueue::pop() noexcept -> ice::TaskAwaitableBase* + auto TaskQueue::take_front() noexcept -> ice::TaskAwaitableBase* { - return ice::linked_queue::pop(_awaitables); + return _awaitables.take_front(); } bool TaskQueue::process_one(void* result_value) noexcept { - ice::TaskAwaitableBase* const awaitable = ice::linked_queue::pop(_awaitables); + ice::TaskAwaitableBase* const awaitable = _awaitables.take_front(); if (awaitable != nullptr) { if (result_value != nullptr) @@ -85,10 +85,10 @@ namespace ice if (custom_resumer->fn_resumer(custom_resumer->ud_resumer, *awaitable) == false) { // Reset next pointer before puttng back onto the queue - awaitable->next = nullptr; + awaitable->_next = nullptr; // Push back at the end of the queue - ice::linked_queue::push(_awaitables, awaitable); + _awaitables.push_back(awaitable); return false; } } @@ -98,10 +98,10 @@ namespace ice return awaitable != nullptr; } - auto TaskQueue::process_all(void* result_value) noexcept -> ice::u32 + auto TaskQueue::process_all(void* result_value) noexcept -> ice::ncount { ice::u32 processed = 0; - for (ice::TaskAwaitableBase* const awaitable : ice::linked_queue::consume(_awaitables)) + for (ice::TaskAwaitableBase* const awaitable : _awaitables.take_all()) { if (result_value != nullptr) { @@ -119,10 +119,10 @@ namespace ice if (custom_resumer->fn_resumer(custom_resumer->ud_resumer, *awaitable) == false) { // Reset next pointer before puttng back onto the queue - awaitable->next = nullptr; + awaitable->_next = nullptr; // Push back at the end of the queue - ice::linked_queue::push(_awaitables, awaitable); + _awaitables.push_back(awaitable); continue; } } @@ -133,11 +133,6 @@ namespace ice return processed; } - // auto TaskQueue::prepare_all(void *result_value) noexcept -> ice::u32 - // { - // return ice::u32(); - // } - void TaskQueue::wait_any() noexcept { _awaitables._head.wait(nullptr, std::memory_order_relaxed); diff --git a/source/code/core/tasks/private/task_utils.cxx b/source/code/core/tasks/private/task_utils.cxx index 80ed1d5d..ea8dd296 100644 --- a/source/code/core/tasks/private/task_utils.cxx +++ b/source/code/core/tasks/private/task_utils.cxx @@ -108,13 +108,13 @@ namespace ice ice::TaskQueue& scheduler_queue = scheduler.schedule()._queue; // Move the queue task to the given scheduler. - return scheduler_queue.push_back(queue.consume()); + return scheduler_queue.push_back(queue.take_all()); } bool schedule_queue(ice::TaskQueue& queue, void* result, ice::TaskScheduler& scheduler) noexcept { // We set the result value for each awaitable in the queue and nothing more. - ice::LinkedQueueRange tasks_awaitables = queue.consume(); + ice::AtomicLinkedQueueRange tasks_awaitables = queue.take_all(); for (ice::TaskAwaitableBase* task_awaitable : tasks_awaitables) { ICE_ASSERT_CORE(task_awaitable->result.ptr == nullptr); @@ -206,7 +206,7 @@ namespace ice // Get all awaiting tasks bool result = false; - for (ice::TaskAwaitableBase* task_awaitable : queue.consume()) + for (ice::TaskAwaitableBase* task_awaitable : queue.take_all()) { ICE_ASSERT(task_awaitable->_params.modifier == TaskAwaitableModifier::CustomValue, "Unexpected modifier type!"); @@ -222,7 +222,7 @@ namespace ice last_remaining = task_awaitable; // Pushing awaitiable onto remaining task does not change the 'next' pointer so we don't invalidate this range. - ice::linked_queue::push(remaining_tasks, task_awaitable); + remaining_tasks.push_back(task_awaitable); } } @@ -230,10 +230,10 @@ namespace ice // We are safe to do so here because another task loading a "next" asset representation will wait for all awaiting tasks to be pushed. if (last_remaining != nullptr) { - last_remaining->next = nullptr; + last_remaining->_next = nullptr; // We don't need to find any 'next' pointer here fortunately - queue.push_back(ice::linked_queue::consume(remaining_tasks)); + queue.push_back(remaining_tasks.take_all()); } co_await awaitable; diff --git a/source/code/core/tasks/public/ice/task_awaitable.hxx b/source/code/core/tasks/public/ice/task_awaitable.hxx index 24c4dadc..dddfec3e 100644 --- a/source/code/core/tasks/public/ice/task_awaitable.hxx +++ b/source/code/core/tasks/public/ice/task_awaitable.hxx @@ -36,7 +36,7 @@ namespace ice { ice::TaskAwaitableParams const _params; ice::coroutine_handle<> _coro; - ice::TaskAwaitableBase* next; + ice::TaskAwaitableBase* _next; ice::TaskAwaitableResult result; }; diff --git a/source/code/core/tasks/public/ice/task_queue.hxx b/source/code/core/tasks/public/ice/task_queue.hxx index d91d2961..91c2c827 100644 --- a/source/code/core/tasks/public/ice/task_queue.hxx +++ b/source/code/core/tasks/public/ice/task_queue.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include namespace ice { @@ -14,28 +14,28 @@ namespace ice public: TaskQueue(ice::TaskFlags flags = {}) noexcept; - bool any() const noexcept { return ice::linked_queue::any(_awaitables); } - bool empty() const noexcept { return ice::linked_queue::empty(_awaitables); } + bool is_empty() const noexcept { return _awaitables.is_empty(); } + bool not_empty() const noexcept { return _awaitables.not_empty(); } bool push_back(ice::TaskAwaitableBase* awaitable) noexcept; - bool push_back(ice::LinkedQueueRange awaitable_range) noexcept; + bool push_back(ice::AtomicLinkedQueueRange awaitable_range) noexcept; bool contains(ice::TaskAwaitableBase* awaitable) const noexcept; [[nodiscard]] - auto pop() noexcept -> ice::TaskAwaitableBase*; + auto take_front() noexcept -> ice::TaskAwaitableBase*; [[nodiscard]] - auto consume() noexcept -> ice::LinkedQueueRange; + auto take_all() noexcept -> ice::AtomicLinkedQueueRange; bool process_one(void* result_value = nullptr) noexcept; - auto process_all(void* result_value = nullptr) noexcept -> ice::u32; + auto process_all(void* result_value = nullptr) noexcept -> ice::ncount; void wait_any() noexcept; template - inline bool process_one(Value& result_value) noexcept; + constexpr bool process_one(Value& result_value) noexcept; template - inline auto process_all(Value& result_value) noexcept -> ice::u32; + constexpr auto process_all(Value& result_value) noexcept -> ice::ncount; //! \brief Flags of task allowed to be pushed onto this queue. ice::TaskFlags const flags; @@ -45,13 +45,13 @@ namespace ice }; template - inline bool TaskQueue::process_one(Value& result_value) noexcept + inline constexpr bool TaskQueue::process_one(Value& result_value) noexcept { return this->process_one(reinterpret_cast(&result_value)); } template - inline auto TaskQueue::process_all(Value& result_value) noexcept -> ice::u32 + inline constexpr auto TaskQueue::process_all(Value& result_value) noexcept -> ice::ncount { return this->process_all(reinterpret_cast(&result_value)); } diff --git a/source/code/core/tasks/public/ice/task_stage.hxx b/source/code/core/tasks/public/ice/task_stage.hxx index 74612db9..7cd3940d 100644 --- a/source/code/core/tasks/public/ice/task_stage.hxx +++ b/source/code/core/tasks/public/ice/task_stage.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include namespace ice { diff --git a/source/code/core/tasks/public/ice/task_transaction.hxx b/source/code/core/tasks/public/ice/task_transaction.hxx index 86014de6..998918a5 100644 --- a/source/code/core/tasks/public/ice/task_transaction.hxx +++ b/source/code/core/tasks/public/ice/task_transaction.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include namespace ice { diff --git a/source/code/core/utils/private/native_aio.hxx b/source/code/core/utils/private/native_aio.hxx index 787f72e7..54f96094 100644 --- a/source/code/core/utils/private/native_aio.hxx +++ b/source/code/core/utils/private/native_aio.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace ice::native_aio diff --git a/source/code/iceshard/iceshard/private/iceshard_gfx_runner.cxx b/source/code/iceshard/iceshard/private/iceshard_gfx_runner.cxx index 6ae66dee..ad988bd0 100644 --- a/source/code/iceshard/iceshard/private/iceshard_gfx_runner.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_gfx_runner.cxx @@ -231,7 +231,7 @@ namespace ice::gfx ice::execute_tasks(tasks); } - if (_queue_transfer.any() || _gfx_tasks.running_tasks() > 0) + if (_queue_transfer.not_empty() || _gfx_tasks.running_tasks() > 0) { IPT_ZONE_SCOPED_NAMED("gfx_await_tasks"); diff --git a/source/code/systems/resource_system/private/resource_internal.hxx b/source/code/systems/resource_system/private/resource_internal.hxx index 27f07d34..6f71a754 100644 --- a/source/code/systems/resource_system/private/resource_internal.hxx +++ b/source/code/systems/resource_system/private/resource_internal.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include #include namespace ice diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx index 78b27858..b9099a0d 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx @@ -16,7 +16,7 @@ namespace ice ice::TaskQueue& queue; LoadAwaitable(ice::TaskQueue& queue) noexcept - : TaskAwaitableBase{ ._params{.task_flags = TaskFlags{}}, .next = nullptr, .result = {} } + : TaskAwaitableBase{ ._params{.task_flags = TaskFlags{}}, ._next = nullptr, .result = {} } , queue{ queue } { } @@ -110,7 +110,7 @@ namespace ice // Resume all awaiting coroutines even if we failed while (_awaitcount.load(std::memory_order_relaxed) > 0) { - for (auto const* awaiting : _awaiting_tasks.consume()) + for (auto const* awaiting : _awaiting_tasks.take_all()) { _awaitcount.fetch_sub(1, std::memory_order_relaxed); awaiting->_coro.resume(); diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx index 92a40204..abfa5c99 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_tracker.hxx b/source/code/systems/resource_system/private/resource_tracker.hxx index 1ecde8f4..7459d8b6 100644 --- a/source/code/systems/resource_system/private/resource_tracker.hxx +++ b/source/code/systems/resource_system/private/resource_tracker.hxx @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -72,7 +72,7 @@ namespace ice } _coro = coro; - ice::linked_queue::push(transaction.queue, this); + transaction.queue.push_back(this); return true; } @@ -104,7 +104,7 @@ namespace ice ice::u32 requests_processed = 1; // Includes "us" while(requests_processed < awaiting) { - for (ice::TaskAwaitableBase* awaitable : ice::linked_queue::consume(transaction.queue)) + for (ice::TaskAwaitableBase* awaitable : transaction.queue.take_all()) { // Resume to coroutine awaitable->_coro.resume(); From 2dd75681e3ae9f5622570f4de64788e8c75c1b6a Mon Sep 17 00:00:00 2001 From: Dandielo Date: Mon, 2 Feb 2026 20:40:45 +0900 Subject: [PATCH 40/40] Fixed WebAssembly targets. --- .../core/collections/public/ice/array.hxx | 1 + .../public/ice/container/hashmap_details.hxx | 10 ++-- .../collections/public/ice/heap_string.hxx | 1 + .../collections/public/ice/heap_varstring.hxx | 2 +- .../collections/public/ice/multi_hashmap.hxx | 20 +++++-- .../core/collections/public/ice/queue.hxx | 2 +- .../code/core/collections/public/ice/span.hxx | 10 ++-- .../public/ice/string/editable_operations.hxx | 2 +- .../collections/public/ice/types/ncount.hxx | 6 +-- .../collections/public/ice/types/nvalue.hxx | 6 +++ .../core/collections/public/ice/varstring.hxx | 2 +- .../core/collections/tests/test_hashmap.cxx | 2 +- .../code/core/core/natvis/shard_names.natvis | 54 ++++++++++++++++++- source/code/core/core/public/ice/utility.hxx | 2 +- .../memsys/public/ice/mem_allocator_host.hxx | 3 +- .../core/modules/private/module_native.cxx | 4 +- .../core/tasks/private/task_native_thread.cxx | 8 +-- source/code/core/utils/private/log_webasm.cxx | 2 +- source/code/core/utils/private/native_aio.cxx | 10 ++-- source/code/core/utils/private/native_aio.hxx | 4 +- .../code/core/utils/private/native_file.cxx | 38 ++++++------- .../code/core/utils/private/string_utils.cxx | 8 +-- .../core/utils/public/ice/native_file.hxx | 4 +- .../example/webasm/private/example_webasm.cxx | 14 ++--- .../private/engine_state_tracker_default.cxx | 2 +- .../public/ice/ecs/ecs_entity_operations.hxx | 16 +++--- .../public/ice/world/world_trait_details.hxx | 10 ++-- .../iceshard_gfx_shader_storage_trait.cxx | 4 +- .../private/iceshard_world_manager.cxx | 2 - .../private/iceshard_world_tasks_launcher.cxx | 4 +- .../shader_tools/public/ice/shader_tools.hxx | 2 +- .../private/webgpu_commands.cxx | 4 +- .../webgpu_renderer/private/webgpu_device.cxx | 18 +++---- .../webgpu_renderer/private/webgpu_driver.cxx | 3 +- .../webgpu_renderer/private/webgpu_queue.cxx | 18 ++++--- .../webgpu_renderer/private/webgpu_queue.hxx | 4 +- .../private/webgpu_renderpass.hxx | 24 ++++----- .../webgpu_renderer/private/webgpu_utils.hxx | 2 +- .../application/private/app_info.cxx | 12 ++--- .../platforms/application/public/ice/app.hxx | 4 +- .../platform_webasm/private/webasm_app.cxx | 18 +++---- .../platform_webasm/private/webasm_app.hxx | 2 +- .../private/webasm_core_app.hxx | 9 ++-- .../private/webasm_threads.cxx | 4 +- .../private/webasm_threads.hxx | 2 +- .../private/resource_provider_hailstorm.cxx | 2 +- .../private/resource_tracker.cxx | 2 +- source/configs.bff | 5 +- tools/natvis.moon | 22 ++++---- 49 files changed, 242 insertions(+), 168 deletions(-) diff --git a/source/code/core/collections/public/ice/array.hxx b/source/code/core/collections/public/ice/array.hxx index e43f97cf..490dca8e 100644 --- a/source/code/core/collections/public/ice/array.hxx +++ b/source/code/core/collections/public/ice/array.hxx @@ -4,6 +4,7 @@ #pragma once #include #include +#include #include #include diff --git a/source/code/core/collections/public/ice/container/hashmap_details.hxx b/source/code/core/collections/public/ice/container/hashmap_details.hxx index c9621957..a0c1c74b 100644 --- a/source/code/core/collections/public/ice/container/hashmap_details.hxx +++ b/source/code/core/collections/public/ice/container/hashmap_details.hxx @@ -250,7 +250,7 @@ namespace ice } template - inline auto find(ContainerT& map, typename ContainerT::ConstIterator it) noexcept -> FindResult + inline auto find(ContainerT& map, ice::u32 entry_index) noexcept -> FindResult { FindResult fr{ .hash_i = Constant_EndOfList, @@ -262,13 +262,15 @@ namespace ice { return fr; } + ICE_ASSERT_CORE(entry_index < map._count); + HashMapEntryType* const entry = map._entries + entry_index; - fr.hash_i = it._entry->key % map._capacity; + fr.hash_i = entry->key % map._capacity; fr.entry_i = map._hashes[fr.hash_i]; while (fr.entry_i != Constant_EndOfList) { - if ((map._entries + fr.entry_i) == it._entry) + if ((map._entries + fr.entry_i) == entry) { return fr; } @@ -276,6 +278,8 @@ namespace ice fr.entry_prev = fr.entry_i; fr.entry_i = map._entries[fr.entry_i].next; } + + ICE_ASSERT_CORE(fr.entry_i == entry_index); return fr; } diff --git a/source/code/core/collections/public/ice/heap_string.hxx b/source/code/core/collections/public/ice/heap_string.hxx index c86bd47e..b602660b 100644 --- a/source/code/core/collections/public/ice/heap_string.hxx +++ b/source/code/core/collections/public/ice/heap_string.hxx @@ -5,6 +5,7 @@ #include #include #include +#include namespace ice { diff --git a/source/code/core/collections/public/ice/heap_varstring.hxx b/source/code/core/collections/public/ice/heap_varstring.hxx index b10a069c..0a592c32 100644 --- a/source/code/core/collections/public/ice/heap_varstring.hxx +++ b/source/code/core/collections/public/ice/heap_varstring.hxx @@ -140,7 +140,7 @@ namespace ice template inline HeapVarString::operator ice::BasicString::CharType>() const noexcept { - ice::usize bytes = 0; + ice::usize bytes = 0_B; ice::ncount const size = ice::varstring::read_size(_data, bytes); if (size > 0) { diff --git a/source/code/core/collections/public/ice/multi_hashmap.hxx b/source/code/core/collections/public/ice/multi_hashmap.hxx index 0f699278..f3760097 100644 --- a/source/code/core/collections/public/ice/multi_hashmap.hxx +++ b/source/code/core/collections/public/ice/multi_hashmap.hxx @@ -43,6 +43,7 @@ namespace ice template constexpr void remove_all(HashableKeyT const& key) noexcept; + constexpr void remove_item(ConstMultiIterator& iterator); }; template @@ -68,10 +69,10 @@ namespace ice , _values{ values } { } - constexpr bool has_next() const noexcept { return _current != ice::detail::hashmap::Constant_EndOfList; } + constexpr bool valid() const noexcept { return _current != ice::detail::hashmap::Constant_EndOfList; } constexpr void next() noexcept { - ICE_ASSERT_CORE(has_next()); + ICE_ASSERT_CORE(valid()); _current = _entries[_current].next; if (_current == ice::detail::hashmap::Constant_EndOfList) @@ -84,7 +85,7 @@ namespace ice constexpr auto key() const noexcept -> ice::u64 const& { return _entries[_current].key; } constexpr auto value() const noexcept -> Type const& { return _values[_current]; } - constexpr auto operator==(ConstMultiIterator const& other) const noexcept + constexpr bool operator==(ConstMultiIterator const& other) const noexcept { return _entries == other._entries && _current == other._current; } @@ -102,7 +103,7 @@ namespace ice ice::u64 result = 0; auto it = find_values(key); - while (it.has_next()) + while (it.valid()) { result += 1; it.next(); @@ -169,4 +170,15 @@ namespace ice } } + template + inline constexpr void MultiHashMap::remove_item(ConstMultiIterator& iterator) + { + ice::detail::hashmap::FindResult const fr = ice::detail::hashmap::find(*this, iterator._current); + if (fr.entry_i != ice::detail::hashmap::Constant_EndOfList) + { + iterator._current = iterator._entries[fr.entry_i].next; + ice::detail::hashmap::erase(*this, fr); + } + } + } // namespace ice diff --git a/source/code/core/collections/public/ice/queue.hxx b/source/code/core/collections/public/ice/queue.hxx index bd2c8dd2..5e648302 100644 --- a/source/code/core/collections/public/ice/queue.hxx +++ b/source/code/core/collections/public/ice/queue.hxx @@ -501,7 +501,7 @@ namespace ice { if constexpr (Logic == ContainerLogic::Complex) { - ice::queue::detail::destroy_tail_items(queue, ice::min(count, this->size())); + ice::queue::detail::destroy_tail_items(*this, ice::min(count, this->size())); } if (_count > count) diff --git a/source/code/core/collections/public/ice/span.hxx b/source/code/core/collections/public/ice/span.hxx index 8e144057..f6a6e60b 100644 --- a/source/code/core/collections/public/ice/span.hxx +++ b/source/code/core/collections/public/ice/span.hxx @@ -59,9 +59,9 @@ namespace ice template typename Container> Span(Container const&) noexcept -> Span; template Span(T(&)[Size]) noexcept -> Span; - template + template static constexpr auto make_span(std::array& std_array) noexcept -> Span; - template + template static constexpr auto make_span(std::array const& std_array) noexcept -> Span; template @@ -103,20 +103,20 @@ namespace ice inline constexpr auto Span::memory_view(this Span const& self) noexcept -> ice::Memory requires(not std::is_const_v) { - return ice::Data{ + return ice::Memory{ .location = self.data(), .size = self.size(), .alignment = ice::align_of }; } - template + template inline constexpr auto make_span(std::array& std_array) noexcept -> Span { return Span{ std_array.data(), std_array.size() }; } - template + template inline constexpr auto make_span(std::array const& std_array) noexcept -> Span { return Span{ std_array.data(), std_array.size() }; diff --git a/source/code/core/collections/public/ice/string/editable_operations.hxx b/source/code/core/collections/public/ice/string/editable_operations.hxx index 8f9925b5..9e092e65 100644 --- a/source/code/core/collections/public/ice/string/editable_operations.hxx +++ b/source/code/core/collections/public/ice/string/editable_operations.hxx @@ -89,8 +89,8 @@ namespace ice::string ) noexcept { ice::ncount const pushed_size = ::fmt::formatted_size(format, std::forward(args)...); - ice::ncount const final_size = self.size() + pushed_size; ice::ncount const capacity = self.capacity() - 1; + ice::ncount final_size = self.size() + pushed_size; // Handle resizing if supported if constexpr (ice::concepts::ResizableStringType) diff --git a/source/code/core/collections/public/ice/types/ncount.hxx b/source/code/core/collections/public/ice/types/ncount.hxx index f8c32000..17be6efc 100644 --- a/source/code/core/collections/public/ice/types/ncount.hxx +++ b/source/code/core/collections/public/ice/types/ncount.hxx @@ -65,9 +65,7 @@ namespace ice } static constexpr ice::meminfo Test_Meminfo = ice::meminfo_of; - static_assert(Test_Meminfo.size == ice::size_of); - - static constexpr ice::meminfo Test_Meminfo_3 = Test_Meminfo * 3_count; - static_assert(Test_Meminfo_3.size == ice::size_of * 3); + // For x64 platforms, size of size_t, for x32 platforms 2x32 + static_assert(Test_Meminfo.size == 8_B); } // namespace ice diff --git a/source/code/core/collections/public/ice/types/nvalue.hxx b/source/code/core/collections/public/ice/types/nvalue.hxx index 991c2a82..9654830c 100644 --- a/source/code/core/collections/public/ice/types/nvalue.hxx +++ b/source/code/core/collections/public/ice/types/nvalue.hxx @@ -3,6 +3,7 @@ #pragma once #include +#include namespace ice { @@ -113,7 +114,12 @@ namespace ice constexpr auto u64() const noexcept { return static_cast(native()); } // Allow 'nvalue' types collaps to the 'base_type' +#if ISP_WEBAPP + // NOTE: We would like to capture us with a 'Self' value but on WebAsm this results in invalid codegen. + constexpr operator base_type() const noexcept { return this->native(); } +#else constexpr operator base_type(this nvalue self) noexcept { return self.native(); } +#endif // Equality is has two cases: // > when deriving from 'nvalue': diff --git a/source/code/core/collections/public/ice/varstring.hxx b/source/code/core/collections/public/ice/varstring.hxx index fb3a4026..fbc9fccd 100644 --- a/source/code/core/collections/public/ice/varstring.hxx +++ b/source/code/core/collections/public/ice/varstring.hxx @@ -137,7 +137,7 @@ namespace ice template inline VarStringBase::operator ice::BasicString::CharType>() const noexcept { - ice::usize bytes = 0; + ice::usize bytes = 0_B; ice::ncount const size = ice::varstring::read_size(_data, bytes); return { _data + bytes.value, size }; } diff --git a/source/code/core/collections/tests/test_hashmap.cxx b/source/code/core/collections/tests/test_hashmap.cxx index 24949af9..81c82214 100644 --- a/source/code/core/collections/tests/test_hashmap.cxx +++ b/source/code/core/collections/tests/test_hashmap.cxx @@ -188,7 +188,7 @@ SCENARIO("collections 'ice/container/hashmap.hxx' (POD)", "[collection][hash][po test_hash.insert(0, 0xd00b); CHECK(test_hash.count_values(0) == 1); CHECK(test_hash.find_values(0).value() == 0xd00b); - CHECK(test_hash.find_values(1).has_next() == false); + CHECK(test_hash.find_values(1).valid() == false); } WHEN("Setting multiple values") diff --git a/source/code/core/core/natvis/shard_names.natvis b/source/code/core/core/natvis/shard_names.natvis index 70da2469..46c0d300 100644 --- a/source/code/core/core/natvis/shard_names.natvis +++ b/source/code/core/core/natvis/shard_names.natvis @@ -31,22 +31,24 @@ Shard {{ event/gfx/suspend }} Shard {{ event/gfx/swapchain-reset }} Shard {{ event/input }} - Shard {{ event/input/text }} + Shard {{ event/render/frame-update }} Shard {{ event/trait/activate }} Shard {{ event/trait/deactivate }} Shard {{ event/trait/setup }} Shard {{ event/trait/shutdown }} Shard {{ event/trait/update }} Shard {{ event/window/maximized }} - Shard {{ event/window/minimized }} Shard {{ event/window/resized }} Shard {{ event/world-runtime/activated }} Shard {{ event/world/activated }} Shard {{ event/world/created }} Shard {{ event/world/deactivated }} Shard {{ event/world/destroyed }} + Shard {{ platform/core-webapp/input-selector-keyboard }} + Shard {{ platform/core-webapp/input-selector-mouse }} Shard {{ platform/storage/app }} Shard {{ platform/threads/thread-pool-size }} + Shard {{ shader }} Shard {{ test/shard }} Shard {{ test/shard2 }} Shard {{ {id.name.value,h}, unknown_name }} @@ -54,13 +56,19 @@ bool char const* + ice::Asset ice::DebugDrawCommandList const* ice::DrawTextCommand const* ice::EngineDevUI* ice::EngineFrameUpdate const* + ice::InputAction const* ice::RenderUIRequest const* + ice::ResourceHandle + ice::ShaderStage + ice::ShaderTargetPlatform ice::String const* ice::StringID_Hash + ice::Tns ice::UpdateUIResource const* ice::WorldStateParams const* ice::ecs::Entity @@ -68,40 +76,82 @@ ice::f64 ice::gfx::GfxFrameUpdate const* ice::gfx::GfxStateChange const* + ice::gfx::RenderFrameUpdate const* ice::i32 ice::i64 ice::input::InputEvent ice::u32 ice::u64 + ice::vec2f ice::vec2i ice::vec2u std::string_view const* {id.payload.value}, type_not_set {id.payload.value}, unknown_type + *(bool*)&payload.value + *(char const**)&payload.value + + *(ice::Asset*)&payload.value + *(ice::DebugDrawCommandList const**)&payload.value + *(ice::DrawTextCommand const**)&payload.value + *(ice::EngineDevUI**)&payload.value + *(ice::EngineFrameUpdate const**)&payload.value + + *(ice::InputAction const**)&payload.value + *(ice::RenderUIRequest const**)&payload.value + + *(ice::ResourceHandle*)&payload.value + + *(ice::ShaderStage*)&payload.value + + *(ice::ShaderTargetPlatform*)&payload.value + *(ice::String const**)&payload.value + *(ice::StringID_Hash*)&payload.value + + *(ice::Tns*)&payload.value + *(ice::UpdateUIResource const**)&payload.value + *(ice::WorldStateParams const**)&payload.value + *(ice::ecs::Entity*)&payload.value + *(ice::f32*)&payload.value + *(ice::f64*)&payload.value + *(ice::gfx::GfxFrameUpdate const**)&payload.value + *(ice::gfx::GfxStateChange const**)&payload.value + + *(ice::gfx::RenderFrameUpdate const**)&payload.value + *(ice::i32*)&payload.value + *(ice::i64*)&payload.value + *(ice::input::InputEvent*)&payload.value + *(ice::u32*)&payload.value + *(ice::u64*)&payload.value + + *(ice::vec2f*)&payload.value + *(ice::vec2i*)&payload.value + *(ice::vec2u*)&payload.value + *(std::string_view const**)&payload.value diff --git a/source/code/core/core/public/ice/utility.hxx b/source/code/core/core/public/ice/utility.hxx index f8cbf2f4..462773fa 100644 --- a/source/code/core/core/public/ice/utility.hxx +++ b/source/code/core/core/public/ice/utility.hxx @@ -17,7 +17,7 @@ namespace ice template struct const_correct { - using type = std::add_const_t; + using type = ValueT const; }; template diff --git a/source/code/core/memsys/public/ice/mem_allocator_host.hxx b/source/code/core/memsys/public/ice/mem_allocator_host.hxx index 605032ae..62e8a51f 100644 --- a/source/code/core/memsys/public/ice/mem_allocator_host.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator_host.hxx @@ -7,8 +7,9 @@ namespace ice { - struct HostAllocator final : ice::Allocator + class HostAllocator final : public ice::Allocator { + public: HostAllocator(std::source_location = std::source_location::current()) noexcept; protected: diff --git a/source/code/core/modules/private/module_native.cxx b/source/code/core/modules/private/module_native.cxx index 2e69033c..81b7420d 100644 --- a/source/code/core/modules/private/module_native.cxx +++ b/source/code/core/modules/private/module_native.cxx @@ -59,7 +59,7 @@ namespace ice::native_module auto module_open(ice::String path) noexcept -> ice::native_module::ModuleHandle { - return ice::native_module::ModuleHandle{ ::dlopen(ice::string::begin(path), RTLD_NOW) }; + return ice::native_module::ModuleHandle{ ::dlopen(path.begin(), RTLD_NOW) }; } void module_close(ice::native_module::ModuleHandle module) noexcept @@ -69,7 +69,7 @@ namespace ice::native_module auto module_find_address(ice::native_module::ModuleHandle const& module, ice::String symbol_name) noexcept -> void* { - return ::dlsym(module.native(), ice::string::begin(symbol_name)); + return ::dlsym(module.native(), symbol_name.begin()); } #endif diff --git a/source/code/core/tasks/private/task_native_thread.cxx b/source/code/core/tasks/private/task_native_thread.cxx index 7c5a0295..79b5b81e 100644 --- a/source/code/core/tasks/private/task_native_thread.cxx +++ b/source/code/core/tasks/private/task_native_thread.cxx @@ -324,12 +324,12 @@ namespace ice // For web apps we can only set thread names on their respective thread context. if constexpr (ice::build::is_release == false) { - emscripten_set_thread_name(pthread_self(), ice::string::begin(thread_info.debug_name)); + emscripten_set_thread_name(pthread_self(), thread_info.debug_name.begin()); } #elif ISP_LINUX if constexpr (ice::build::is_release == false) { - pthread_setname_np(pthread_self(), ice::string::begin(thread_info.debug_name)); + pthread_setname_np(pthread_self(), thread_info.debug_name.begin()); } #endif @@ -403,9 +403,9 @@ namespace ice if constexpr (ice::build::is_release == false && ice::build::is_webapp == false) { - if (ice::string::any(info.debug_name)) + if (info.debug_name.not_empty()) { - error = pthread_setname_np(thread_handle, ice::string::begin(info.debug_name)); + error = pthread_setname_np(thread_handle, info.debug_name.begin()); ICE_ASSERT(error == 0, "Failed to set name for native thread with error: {}!", error); } } diff --git a/source/code/core/utils/private/log_webasm.cxx b/source/code/core/utils/private/log_webasm.cxx index 03b242e6..66f0ba4b 100644 --- a/source/code/core/utils/private/log_webasm.cxx +++ b/source/code/core/utils/private/log_webasm.cxx @@ -163,7 +163,7 @@ namespace ice::detail::webasm ice::detail::local_time(), fmt_string(detail::severity_value[static_cast(severity)]), fmt_string(base_tag_name), - fmt_string(ice::string::empty(tag_name) || ice::string::empty(base_tag_name) ? "" : " | "), + fmt_string(tag_name.is_empty() || base_tag_name.is_empty() ? "" : " | "), fmt_string(tag_name) ); diff --git a/source/code/core/utils/private/native_aio.cxx b/source/code/core/utils/private/native_aio.cxx index 5b44a98f..133280c0 100644 --- a/source/code/core/utils/private/native_aio.cxx +++ b/source/code/core/utils/private/native_aio.cxx @@ -297,13 +297,13 @@ namespace ice::native_aio { ICE_ASSERT_CORE(memory.location != nullptr); AIORequestInternal& internal = reinterpret_cast(request); - internal.next = nullptr; + internal._next = nullptr; internal.native_file_handle = file.native(); internal.request_type = 1; // 1 = read, 2 = write internal.data_destination = memory.location; internal.data_offset = static_cast(requested_read_offset.value); internal.data_size = static_cast(requested_read_size.value); - ice::linked_queue::push(request._port->_requests, ice::addressof(internal)); + request._port->_requests.push_back(ice::addressof(internal)); // Increment the semaphore sem_post(&request._port->_semaphore); @@ -331,13 +331,13 @@ namespace ice::native_aio } AIORequestInternal& internal = reinterpret_cast(request); - internal.next = nullptr; + internal._next = nullptr; internal.native_file_handle = file.native(); internal.request_type = 2; // 1 = read, 2 = write internal.data_location = data.location; internal.data_size = ice::u32(data.size.value); internal.data_offset = ice::u32(requested_write_offset.value); - ice::linked_queue::push(request._port->_requests, ice::addressof(internal)); + request._port->_requests.push_back(ice::addressof(internal)); // Increment the semaphore sem_post(&request._port->_semaphore); @@ -370,7 +370,7 @@ namespace ice::native_aio return false; } - AIORequestInternal* internal = ice::linked_queue::pop(port->_requests); + AIORequestInternal* internal = port->_requests.take_front(); if (internal) { out_request = reinterpret_cast(internal); diff --git a/source/code/core/utils/private/native_aio.hxx b/source/code/core/utils/private/native_aio.hxx index 54f96094..dbb7ed2a 100644 --- a/source/code/core/utils/private/native_aio.hxx +++ b/source/code/core/utils/private/native_aio.hxx @@ -21,7 +21,7 @@ namespace ice::native_aio #elif ISP_ANDROID || ISP_WEBAPP || ISP_LINUX struct AIORequestInternal { - AIORequestInternal* next; + AIORequestInternal* _next; ice::i32 native_file_handle; ice::u32 request_type; // 1 == read, 2 == write union @@ -45,7 +45,7 @@ namespace ice::native_aio #else struct AIORequestInternal { - AIORequestInternal* next; + AIORequestInternal* _next; HANDLE native_file_handle; void* data_location; ice::u32 data_offset; diff --git a/source/code/core/utils/private/native_file.cxx b/source/code/core/utils/private/native_file.cxx index 4f6aa220..a2bdd936 100644 --- a/source/code/core/utils/private/native_file.cxx +++ b/source/code/core/utils/private/native_file.cxx @@ -552,7 +552,7 @@ namespace ice::native_file bool exists_file(ice::native_file::FilePath path) noexcept { struct stat file_stats; - return stat(ice::string::begin(path), &file_stats) == 0 && file_stats.st_size > 0; + return stat(path.begin(), &file_stats) == 0 && file_stats.st_size > 0; } auto open_file( @@ -564,7 +564,7 @@ namespace ice::native_file if constexpr (ice::build::is_unix) { result = ice::native_file::File{ - open(ice::string::begin(path), translate_flags(flags), Constant_ModeFile) + open(path.begin(), translate_flags(flags), Constant_ModeFile) }; } else @@ -605,7 +605,7 @@ namespace ice::native_file auto sizeof_file(ice::native_file::FilePath path) noexcept -> ice::usize { struct stat file_stats; - if (stat(ice::string::begin(path), &file_stats) == 0) + if (stat(path.begin(), &file_stats) == 0) { return { static_cast(file_stats.st_size) }; } @@ -702,18 +702,18 @@ namespace ice::native_file { bool traverse_success = false; - DIR* const directory = opendir(ice::string::begin(dirpath)); + DIR* const directory = opendir(dirpath.begin()); if (directory != nullptr) { // Just opening the dir is already a success for us traverse_success = true; // Store for later information about the current state of dirpath - if (ice::string::back(dirpath) != '/') + if (dirpath.back() != '/') { - ice::string::push_back(dirpath, '/'); + dirpath.push_back('/'); } - ice::ucount const size_dirpath = ice::string::size(dirpath); + ice::ncount const size_dirpath = dirpath.size(); while (dirent const* const entry = readdir(directory)) { @@ -734,8 +734,8 @@ namespace ice::native_file : EntityType::File; // Append the entry name to the path - ice::ucount const size_name = ice::ucount(strlen(entry->d_name)); - ice::string::push_back(dirpath, ice::native_file::FilePath{ entry->d_name, size_name }); + ice::ncount const size_name = strlen(entry->d_name); + dirpath.push_back(ice::native_file::FilePath{ entry->d_name, size_name }); // Call the callback for the next entry encountered... ice::native_file::TraverseAction const action = callback(basepath, dirpath, type, userdata); @@ -755,7 +755,7 @@ namespace ice::native_file } // Rollback the directory string to the base value - ice::string::resize(dirpath, size_dirpath); + dirpath.resize(size_dirpath); } closedir(directory); @@ -772,8 +772,8 @@ namespace ice::native_file { ice::StackAllocator_1024 temp_alloc; ice::native_file::HeapFilePath dirpath{ temp_alloc }; - ice::string::reserve(dirpath, 256 * 2); // 512 bytes for paths - ice::string::push_back(dirpath, starting_dir); + dirpath.reserve(256 * 2); // 512 bytes for paths + dirpath.push_back(starting_dir); return traverse_directories_internal(dirpath, dirpath, callback, userdata); } @@ -783,7 +783,7 @@ namespace ice::native_file ) noexcept { // If zero, we failed, check why. - if (mkdir(ice::string::begin(dirpath), Constant_ModeDirectory) == -1) + if (mkdir(dirpath.begin(), Constant_ModeDirectory) == -1) { // Try the next path before retrying this path. if (errno == EEXIST) @@ -793,7 +793,7 @@ namespace ice::native_file else if (errno == ENOENT) { // Remove the top-most the directory explicitly. - ice::nindex const dirslash = ice::string::find_last_of(dirpath, ice::String{ "/" }); + ice::nindex const dirslash = dirpath.find_last_of(ice::String{ "/" }); if (dirslash == ice::nindex_none) { return false; @@ -810,7 +810,7 @@ namespace ice::native_file dirpath[dirslash] = '/'; // Try again to create the directory - return mkdir(ice::string::begin(dirpath), Constant_ModeDirectory) != -1; + return mkdir(dirpath.begin(), Constant_ModeDirectory) != -1; } // else it's either 'ERROR_ALREADY_EXISTS' so we continue. } @@ -831,7 +831,7 @@ namespace ice::native_file bool is_directory(ice::native_file::FilePath path) noexcept { struct stat info; - if (stat(ice::string::begin(path), &info) != 0) { + if (stat(path.begin(), &info) != 0) { return false; } return S_ISDIR(info.st_mode); @@ -858,11 +858,11 @@ namespace ice::native_file ice::String string ) noexcept { - if (ice::string::any(path)) + if (path.not_empty()) { - ice::path::join(path, string); + path.join(string); } - else if (ice::string::any(string)) + else if (string.not_empty()) { path = string; } diff --git a/source/code/core/utils/private/string_utils.cxx b/source/code/core/utils/private/string_utils.cxx index 4310361c..9354c956 100644 --- a/source/code/core/utils/private/string_utils.cxx +++ b/source/code/core/utils/private/string_utils.cxx @@ -21,8 +21,8 @@ namespace ice : strnicmp(left.begin(), right.begin(), count); #elif ISP_UNIX ice::u32 const comp_result = check_case == CaseSensitive::Yes - ? strncmp(ice::string::begin(left), ice::string::begin(right), count) - : strncasecmp(ice::string::begin(left), ice::string::begin(right), count); + ? strncmp(left.begin(), right.begin(), count) + : strncasecmp(left.begin(), right.begin(), count); #endif return comp_result == 0 ? CompareResult::Equal : (comp_result < 0 ? CompareResult::Smaller : CompareResult::Larger); @@ -41,8 +41,8 @@ namespace ice : strnicmp(left.begin(), right.begin(), max_size); #elif ISP_UNIX ice::u32 const comp_result = check_case == CaseSensitive::Yes - ? strncmp(ice::string::begin(left), ice::string::begin(right), max_size) - : strncasecmp(ice::string::begin(left), ice::string::begin(right), max_size); + ? strncmp(left.begin(), right.begin(), max_size) + : strncasecmp(left.begin(), right.begin(), max_size); #endif return comp_result == 0 ? CompareResult::Equal : (comp_result < 0 ? CompareResult::Smaller : CompareResult::Larger); diff --git a/source/code/core/utils/public/ice/native_file.hxx b/source/code/core/utils/public/ice/native_file.hxx index 08afc994..9395ecc6 100644 --- a/source/code/core/utils/public/ice/native_file.hxx +++ b/source/code/core/utils/public/ice/native_file.hxx @@ -23,8 +23,8 @@ namespace ice::native_file # define ISP_PATH_LITERAL(val) L##val #elif ISP_UNIX using File = ice::unix_::FileHandle; - using FilePath = ice::String; - using HeapFilePath = ice::HeapString<>; + using FilePath = ice::BasicPath; + using HeapFilePath = ice::BasicHeapPath; # define ISP_PATH_LITERAL(val) val #endif diff --git a/source/code/example/webasm/private/example_webasm.cxx b/source/code/example/webasm/private/example_webasm.cxx index e054322a..b8616ac8 100644 --- a/source/code/example/webasm/private/example_webasm.cxx +++ b/source/code/example/webasm/private/example_webasm.cxx @@ -75,11 +75,11 @@ struct WorldActivationTrait : ice::Trait, ice::DevUIWidget { if (do_active) { - shards::push_back(update.frame.shards(), ShardID_WorldActivate | "world2"_sid_hash); + update.frame.shards().push_back(ShardID_WorldActivate | "world2"_sid_hash); } else { - shards::push_back(update.frame.shards(), ShardID_WorldDeactivate | "world2"_sid_hash); + update.frame.shards().push_back(ShardID_WorldDeactivate | "world2"_sid_hash); } is_active = do_active; } @@ -135,7 +135,7 @@ struct TestTrait : public ice::Trait update.engine.entity_index().destroy_many(_my_entity); query().tags().for_each_block( - [&](ice::ucount count, ice::ecs::Entity const* entities) noexcept + [&](ice::ncount count, ice::ecs::Entity const* entities) noexcept { _ops->destroy({ entities, count }); } @@ -150,13 +150,13 @@ struct TestTrait : public ice::Trait ice::ecs::Query q = query(); ice::Array> tasks{ update.frame.allocator() }; - ice::array::reserve(tasks, q.block_count()); + tasks.reserve(q.block_count()); std::atomic_uint32_t x = 0; q.for_each_block( - [&](ice::ucount count, C1* c1p, C2* c2p) noexcept + [&](ice::ncount count, C1* c1p, C2* c2p) noexcept { - ice::array::push_back(tasks, [](ice::ucount count, C1* c1p, C2* c2p, std::atomic_uint32_t& x) noexcept -> ice::Task<> + tasks.push_back([](ice::ncount count, C1* c1p, C2* c2p, std::atomic_uint32_t& x) noexcept -> ice::Task<> { IPT_ZONE_SCOPED_NAMED("block for-each"); for (ice::u32 idx = 0; idx < count; ++idx) @@ -318,7 +318,7 @@ void TestGame::on_update(ice::Engine& engine, ice::EngineFrame& frame) noexcept { using namespace ice; - shards::push_back(frame.shards(), ShardID_WorldActivate | "world"_sid_hash); + frame.shards().push_back(ShardID_WorldActivate | "world"_sid_hash); } void TestGame::on_suspend(ice::Engine& engine) noexcept diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index 4f1fcfcb..01825806 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -116,7 +116,7 @@ namespace ice ) const noexcept -> ice::EngineStateCurrent { auto it = _current_state_index.find_values(state_graph.value); - while (it.has_next()) + while (it.valid()) { ice::EngineStateCurrent const& current = _current_state[it.value()]; diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx index 4c269771..19aee164 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx @@ -335,16 +335,16 @@ namespace ice::ecs .offsets = ice::make_span(HelperArchetype.component_alignments).tailspan(1) }; - ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); + ice::u32 const entity_count = mode == 2 ? index_create_count : entities.size().u32(); ice::u32 constexpr component_count = sizeof...(Components); ice::meminfo additional_data_size = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; additional_data_size += ice::meminfo_of * entity_count; // Data for storing component info additional_data_size += ice::meminfo_of; - additional_data_size.size += ComponentsInfo.names.size(); - additional_data_size.size += ComponentsInfo.sizes.size(); - additional_data_size.size += ComponentsInfo.offsets.size(); + additional_data_size.size += ComponentsInfo.names.size().bytes(); + additional_data_size.size += ComponentsInfo.sizes.size().bytes(); + additional_data_size.size += ComponentsInfo.offsets.size().bytes(); // Use folded expression to calculate all the size for the components... additional_data_size.size += ((ice::usize{ alignof(Components) } + ice::size_of * entity_count) + ...); @@ -477,16 +477,16 @@ namespace ice::ecs .offsets = ice::make_span(HelperArchetype.component_alignments).tailspan(1) }; - ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); + ice::u32 const entity_count = mode == 2 ? index_create_count : entities.size().u32(); ice::u32 constexpr component_count = sizeof...(Components); ice::meminfo additional_data_size = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; additional_data_size += ice::meminfo_of * entity_count; // Data for storing component info additional_data_size += ice::meminfo_of; - additional_data_size.size += ComponentsInfo.names.size(); - additional_data_size.size += ComponentsInfo.sizes.size(); - additional_data_size.size += ComponentsInfo.offsets.size(); + additional_data_size.size += ComponentsInfo.names.size().bytes(); + additional_data_size.size += ComponentsInfo.sizes.size().bytes(); + additional_data_size.size += ComponentsInfo.offsets.size().bytes(); // Use folded expression to calculate all the size for the components... additional_data_size.size += ((ice::usize{ alignof(Components) } + ice::size_of * entity_count) + ...); diff --git a/source/code/iceshard/engine/public/ice/world/world_trait_details.hxx b/source/code/iceshard/engine/public/ice/world/world_trait_details.hxx index 3d52ce91..d4255fec 100644 --- a/source/code/iceshard/engine/public/ice/world/world_trait_details.hxx +++ b/source/code/iceshard/engine/public/ice/world/world_trait_details.hxx @@ -65,8 +65,9 @@ namespace ice::detail using ArgType = ice::clear_type_t; ICE_ASSERT( ice::Constant_ShardPayloadID == shard.id.payload, - "Shard payload ID incompatible with the argument. {} != {}", - ice::Constant_ShardPayloadID.value, shard.id.payload.value + "Shard '{}' payload ID incompatible with the argument. {} != {}", + shard.id.name.value, shard.id.payload.value, + ice::Constant_ShardPayloadID.value ); ArgType* shard_value = nullptr; @@ -82,8 +83,9 @@ namespace ice::detail using ArgType = ShardType; ICE_ASSERT( ice::Constant_ShardPayloadID == shard.id.payload, - "Shard payload ID incompatible with the argument. {} != {}", - ice::Constant_ShardPayloadID.value, shard.id.payload.value + "Shard '{}' payload ID incompatible with the argument. {} != {}", + shard.id.name.value, shard.id.payload.value, + ice::Constant_ShardPayloadID.value ); ArgType shard_value{ }; diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx index 6ff477aa..4cdb069d 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_shader_storage_trait.cxx @@ -35,7 +35,7 @@ namespace ice::gfx { _context.bind<&Trait_GfxShaderStorage::gfx_update, Render>(ice::gfx::ShardID_RenderFrameUpdate); _context.bind<&Trait_GfxShaderStorage::gfx_shutdown, Render>(ice::gfx::ShardID_GfxShutdown); - _context.bind<&Trait_GfxShaderStorage::on_asset_loaded>("iceshard:shaders-internal:loaded`ice::Asset"_shardid); + _context.bind<&Trait_GfxShaderStorage::on_asset_loaded>("event/iceshard-internal/shader-loaded"_shardid); } void Trait_GfxShaderStorage::build_content() noexcept @@ -120,7 +120,7 @@ namespace ice::gfx // Reslove the request (will resume all awaiting tasks) ice::Asset asset = request->resolve({ .resolver = this, .result = AssetRequestResult::Success, .memory = result }); - send("iceshard:shaders-internal:loaded"_shardid, asset); + send("event/iceshard-internal/shader-loaded"_shardid, asset); // Save the shader handle _loaded_shaders.set(shader_hash, { .asset = ice::move(asset), .shader = shader, }); diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx index bbb5a667..df76a359 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx @@ -100,8 +100,6 @@ namespace ice ice::WorldTemplate const& world_template ) noexcept -> World* { - static constexpr bool is_ass = ice::concepts::AssociativeContainer>; - ICE_ASSERT( _worlds.missing(world_template.name), "A world with this name {} was already created!", diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx index d762eb8d..81ffd98b 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx @@ -47,7 +47,7 @@ namespace ice auto out_it = tasks.begin(); auto it = handlers.find_values(shard.id); - while (it.has_next()) + while (it.valid()) { ice::IceshardEventHandler const& handler = it.value(); void* const userdata = handler.procedure_userdata != nullptr @@ -89,7 +89,7 @@ namespace ice ice::MultiHashMap& handlers = _world_context._frame_handlers[tasktype_idx]; auto it = handlers.find_values(shard.id); - while (it.has_next()) + while (it.valid()) { ice::IceshardEventHandler const& handler = it.value(); diff --git a/source/code/modules/shader_tools/public/ice/shader_tools.hxx b/source/code/modules/shader_tools/public/ice/shader_tools.hxx index 67d34c08..8cc3805a 100644 --- a/source/code/modules/shader_tools/public/ice/shader_tools.hxx +++ b/source/code/modules/shader_tools/public/ice/shader_tools.hxx @@ -38,7 +38,7 @@ namespace ice } // namespace ice template<> -constexpr inline ice::ShardPayloadID ice::Constant_ShardPayloadID = ice::shard_payloadid("ice::ShaderPlatformTarget"); +constexpr inline ice::ShardPayloadID ice::Constant_ShardPayloadID = ice::shard_payloadid("ice::ShaderTargetPlatform"); template<> constexpr inline ice::ShardPayloadID ice::Constant_ShardPayloadID = ice::shard_payloadid("ice::ShaderStage"); diff --git a/source/code/modules/webgpu_renderer/private/webgpu_commands.cxx b/source/code/modules/webgpu_renderer/private/webgpu_commands.cxx index 741a3e2d..3a4e9953 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_commands.cxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_commands.cxx @@ -43,7 +43,7 @@ namespace ice::render::webgpu WebGPURenderPass const* webgpu_rp = WebGPURenderPass::native(renderpass); // Max 4 attachments for now - ice::ucount attachment_count = 0; + ice::ncount attachment_count = 0; WGPURenderPassColorAttachment attachments[4]; RenderSubPass const& subpass = webgpu_rp->subpasses[0]; @@ -119,7 +119,7 @@ namespace ice::render::webgpu wgpuRenderPassEncoderEnd(webgpu_cmds->renderpass_encoder); // Max 4 attachments for now - ice::ucount attachment_count = 0; + ice::ncount attachment_count = 0; WGPURenderPassColorAttachment attachments[4]; RenderSubPass const& subpass = webgpu_rp->subpasses[webgpu_cmds->renderpass_subpass]; diff --git a/source/code/modules/webgpu_renderer/private/webgpu_device.cxx b/source/code/modules/webgpu_renderer/private/webgpu_device.cxx index 2e6e64cf..98da3938 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_device.cxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_device.cxx @@ -88,7 +88,7 @@ namespace ice::render::webgpu WGPUBindGroupLayoutDescriptor descriptor = WGPU_BIND_GROUP_LAYOUT_DESCRIPTOR_INIT; descriptor.label = wgpu_string("Resource Set Layout"); - descriptor.entryCount = ice::count(bindings); + descriptor.entryCount = bindings.size(); descriptor.entries = entries; ICE_ASSERT_CORE(descriptor.entryCount <= 16); @@ -140,10 +140,10 @@ namespace ice::render::webgpu ice::Span resource_sets_out ) noexcept { - ice::u32 const count = ice::count(resource_set_layouts); - ICE_ASSERT_CORE(count == ice::count(resource_sets_out)); + ice::ncount const count = resource_set_layouts.size(); + ICE_ASSERT_CORE(count == resource_sets_out.size()); - for (ice::u32 idx = 0; idx < count; ++idx) + for (ice::ncount idx = 0; idx < count; ++idx) { WebGPUResourceSet* resource_set = _allocator.create(); resource_set->_wgpu_group_layout = WebGPUResourceSet::native(resource_set_layouts[idx]); @@ -250,12 +250,12 @@ namespace ice::render::webgpu ice::render::PipelineLayoutInfo const& info ) noexcept -> ice::render::PipelineLayout { - if (ice::span::any(info.push_constants)) + if (info.push_constants.not_empty()) { ICE_LOG_WGPU(LogSeverity::Warning, "WebGPU Pipelines do not support push constants."); } - ice::ucount count = 0; + ice::u32 count = 0; WGPUBindGroupLayout layouts[8]{}; for (ResourceSetLayout resource_layout : info.resource_layouts) { @@ -374,11 +374,11 @@ namespace ice::render::webgpu { case ShaderStageFlags::VertexStage: vertex.module = WebGPUShader::native(program.shader)->_wgpu_shader; - vertex.entryPoint = wgpu_string(ice::string::begin(program.entry_point)); + vertex.entryPoint = wgpu_string(program.entry_point.begin()); break; case ShaderStageFlags::FragmentStage: fragment.module = WebGPUShader::native(program.shader)->_wgpu_shader; - fragment.entryPoint = wgpu_string(ice::string::begin(program.entry_point)); + fragment.entryPoint = wgpu_string(program.entry_point.begin()); break; default: ICE_ASSERT_CORE(false); @@ -499,7 +499,7 @@ namespace ice::render::webgpu ice::Array native_images{ _allocator }; for (ice::render::Image image : images) { - ice::array::push_back(native_images, WebGPUImage::native(image)); + native_images.push_back(WebGPUImage::native(image)); } return WebGPUFrameBuffer::handle(_allocator.create(ice::move(native_images))); diff --git a/source/code/modules/webgpu_renderer/private/webgpu_driver.cxx b/source/code/modules/webgpu_renderer/private/webgpu_driver.cxx index b3fcd6f2..c5a95009 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_driver.cxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_driver.cxx @@ -152,8 +152,7 @@ namespace ice::render::webgpu ice::Array& queue_info ) noexcept { - ice::array::push_back( - queue_info, + queue_info.push_back( QueueFamilyInfo { .id = QueueID{ 1 }, .flags = QueueFlags::Transfer | QueueFlags::Graphics | QueueFlags::Present, diff --git a/source/code/modules/webgpu_renderer/private/webgpu_queue.cxx b/source/code/modules/webgpu_renderer/private/webgpu_queue.cxx index 8e33538d..07e24e2c 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_queue.cxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_queue.cxx @@ -53,7 +53,7 @@ namespace ice::render::webgpu webgpu_cmds->command_encoder = wgpuDeviceCreateCommandEncoder(_wgpu_device, &descriptor); out_buffer = WebGPUCommandBuffer::handle(webgpu_cmds); - ice::multi_hashmap::insert(_wgpu_command_buffers, pool_index, webgpu_cmds); + _wgpu_command_buffers.set(pool_index, webgpu_cmds); } } @@ -76,16 +76,18 @@ namespace ice::render::webgpu descriptor.label = wgpu_string(type == CommandBufferType::Primary ? "Primary Command Encoded" : "Secondary Command Encoder"); webgpu_cmds->command_encoder = wgpuDeviceCreateCommandEncoder(_wgpu_device, &descriptor); - auto it = ice::multi_hashmap::find_first(_wgpu_command_buffers, pool_index); + auto it = _wgpu_command_buffers.find_values(pool_index); while (it != nullptr) { - auto next = ice::multi_hashmap::find_next(_wgpu_command_buffers, it); if (it.value() == webgpu_cmds) { - ice::multi_hashmap::remove(_wgpu_command_buffers, it); + _wgpu_command_buffers.remove_item(it); _allocator.destroy(webgpu_cmds); } - it = next; + else + { + it.next(); + } } } } @@ -94,7 +96,7 @@ namespace ice::render::webgpu ice::u32 pool_index ) noexcept { - auto it = ice::multi_hashmap::find_first(_wgpu_command_buffers, pool_index); + auto it = _wgpu_command_buffers.find_values(pool_index); while (it != nullptr) { // if (it.value()->type == CommandBufferType::Secondary) @@ -128,7 +130,7 @@ namespace ice::render::webgpu } it.value()->command_encoder = wgpuDeviceCreateCommandEncoder(_wgpu_device, &descriptor); - it = ice::multi_hashmap::find_next(_wgpu_command_buffers, it); + it.next(); } } @@ -141,7 +143,7 @@ namespace ice::render::webgpu { WebGPUCallbackFence* wgpu_fence = static_cast(fence); - ice::ucount wgpu_cb_count = 0; + ice::ncount wgpu_cb_count = 0; WGPUCommandBuffer wgpu_cb_list[16]; for (ice::render::CommandBuffer cmdbuff : buffers) diff --git a/source/code/modules/webgpu_renderer/private/webgpu_queue.hxx b/source/code/modules/webgpu_renderer/private/webgpu_queue.hxx index 30d91f2c..b8360cd9 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_queue.hxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_queue.hxx @@ -7,7 +7,7 @@ #include "webgpu_command_buffer.hxx" #include -#include +#include namespace ice::render::webgpu { @@ -51,7 +51,7 @@ namespace ice::render::webgpu ice::Allocator& _allocator; WGPUDevice _wgpu_device; WGPUQueue _wgpu_queue; - ice::HashMap _wgpu_command_buffers; + ice::MultiHashMap _wgpu_command_buffers; }; } // namespace ice::render::webgpu diff --git a/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx b/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx index 40aacbb1..36b475af 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx @@ -24,27 +24,27 @@ namespace ice::render::webgpu , references{ alloc } , subpasses{ alloc } { - ice::array::push_back(attachments, info.attachments); - ice::array::reserve(subpasses, ice::count(info.subpasses)); + attachments.push_back(info.attachments); + subpasses.reserve(info.subpasses.size()); - ice::ucount num_references = 0; + ice::ncount num_references = 0; for (ice::render::RenderSubPass const& subpass : info.subpasses) { - num_references += ice::count(subpass.input_attachments); - num_references += ice::count(subpass.color_attachments); + num_references += subpass.input_attachments.size(); + num_references += subpass.color_attachments.size(); } - ice::array::reserve(references, num_references); + references.reserve(num_references); for (ice::render::RenderSubPass const& subpass : info.subpasses) { - ice::ucount const offset = ice::array::count(references); - ice::array::push_back(references, subpass.input_attachments); - ice::array::push_back(references, subpass.color_attachments); + ice::ncount const offset = references.size(); + references.push_back(subpass.input_attachments); + references.push_back(subpass.color_attachments); - ice::array::push_back(subpasses, + subpasses.push_back( RenderSubPass { - .input_attachments = ice::array::slice(references, offset, ice::count(subpass.input_attachments)), - .color_attachments = ice::array::slice(references, offset + ice::count(subpass.input_attachments), ice::count(subpass.color_attachments)), + .input_attachments = references.subspan(offset, subpass.input_attachments.size()), + .color_attachments = references.subspan(offset + subpass.input_attachments.size(), subpass.color_attachments.size()), .depth_stencil_attachment = subpass.depth_stencil_attachment } ); diff --git a/source/code/modules/webgpu_renderer/private/webgpu_utils.hxx b/source/code/modules/webgpu_renderer/private/webgpu_utils.hxx index fd4f3b6b..ad27d429 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_utils.hxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_utils.hxx @@ -15,7 +15,7 @@ namespace ice::render::webgpu constexpr auto wgpu_string(ice::String value) noexcept -> WGPUStringView { - return WGPUStringView{ .data = value._data, .length = value._size }; + return WGPUStringView{ .data = value.data(), .length = value.size() }; } #define ICE_LOG_WGPU(severity, message, ...) \ diff --git a/source/code/platforms/application/private/app_info.cxx b/source/code/platforms/application/private/app_info.cxx index 9946864f..f4175906 100644 --- a/source/code/platforms/application/private/app_info.cxx +++ b/source/code/platforms/application/private/app_info.cxx @@ -96,21 +96,21 @@ namespace ice::app return working_dir; } #else - auto location() noexcept -> ice::String + auto location() noexcept -> ice::Path { - // TODO: Deprecate or return a valid value + ICE_ASSERT_CORE(false); return {}; } - auto directory() noexcept -> ice::String + auto directory() noexcept -> ice::Path { - // TODO: Deprecate or return a valid value + ICE_ASSERT_CORE(false); return {}; } - auto workingdir() noexcept -> ice::String + auto workingdir() noexcept -> ice::Path { - // TODO: Deprecate or return a valid value + ICE_ASSERT_CORE(false); return {}; } #endif diff --git a/source/code/platforms/application/public/ice/app.hxx b/source/code/platforms/application/public/ice/app.hxx index 8d27c8d6..0a424add 100644 --- a/source/code/platforms/application/public/ice/app.hxx +++ b/source/code/platforms/application/public/ice/app.hxx @@ -17,8 +17,8 @@ namespace ice::app struct Factories { - template - using FactoryFn = auto(*)(ice::Allocator&, Args...) noexcept -> ice::UniquePtr; + template + using FactoryFn = auto(*)(ice::Allocator&) noexcept -> ice::UniquePtr; FactoryFn factory_config; FactoryFn factory_state; diff --git a/source/code/platforms/platform_webasm/private/webasm_app.cxx b/source/code/platforms/platform_webasm/private/webasm_app.cxx index 0519e38a..8c90a5e0 100644 --- a/source/code/platforms/platform_webasm/private/webasm_app.cxx +++ b/source/code/platforms/platform_webasm/private/webasm_app.cxx @@ -40,8 +40,8 @@ namespace ice::platform::webasm _temporary_inputs.push(Constant_Mouse, ice::input::DeviceMessage::DeviceConnected); _temporary_inputs.push(Constant_Keyboard, ice::input::DeviceMessage::DeviceConnected); - ice::queue::reserve(_text_events, 4); - ice::queue::reserve(_temp_text_events, 4); + _text_events.reserve(4); + _temp_text_events.reserve(4); } WebAsmApp::~WebAsmApp() noexcept @@ -81,21 +81,19 @@ namespace ice::platform::webasm auto WebAsmApp::refresh_events() noexcept -> ice::Result { pthread_mutex_lock(&_mutex); - ice::shards::clear(_system_events); + _system_events.clear(); _input_events._events = _temporary_inputs._events; - ice::array::clear(_temporary_inputs._events); + _temporary_inputs._events.clear(); _text_events = _temp_text_events; - ice::queue::clear(_temp_text_events); + _temp_text_events.clear(); - ice::queue::for_each( - _text_events, + _text_events.for_each( [this](WebAsmTextEvent const& ev) noexcept { ICE_LOG(LogSeverity::Warning, LogTag::Core, "{}", ev.input); - ice::shards::push_back( - _system_events, + _system_events.push_back( ice::platform::ShardID_InputText | (char const*)ev.input ); } @@ -168,7 +166,7 @@ namespace ice::platform::webasm { WebAsmTextEvent text_event{.input = {}}; ice::memcpy(text_event.input, event.key, sizeof(event.key)); - ice::queue::push_back(_temp_text_events, text_event); + _temp_text_events.push_back(text_event); } if (mod != KeyboardMod::None) { diff --git a/source/code/platforms/platform_webasm/private/webasm_app.hxx b/source/code/platforms/platform_webasm/private/webasm_app.hxx index ae139693..4f9067de 100644 --- a/source/code/platforms/platform_webasm/private/webasm_app.hxx +++ b/source/code/platforms/platform_webasm/private/webasm_app.hxx @@ -3,7 +3,7 @@ #pragma once #include "webasm_core_app.hxx" -#include +#include namespace ice::platform::webasm { diff --git a/source/code/platforms/platform_webasm/private/webasm_core_app.hxx b/source/code/platforms/platform_webasm/private/webasm_core_app.hxx index 303f1689..d3794871 100644 --- a/source/code/platforms/platform_webasm/private/webasm_core_app.hxx +++ b/source/code/platforms/platform_webasm/private/webasm_core_app.hxx @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -39,10 +40,10 @@ namespace ice::platform::webasm auto input_events() noexcept -> ice::Span override { return _input_events._events; } public: - auto data_locations() const noexcept -> ice::Span override { static ice::String paths[]{ "/" }; return paths; } - auto save_location() const noexcept -> ice::String override { return "/saves"; } - auto cache_location() const noexcept -> ice::String override { return "/cache"; } - auto dylibs_location() const noexcept -> ice::String override { return {}; } + auto data_locations() const noexcept -> ice::Span override { static ice::Path paths[]{ "/" }; return paths; } + auto save_location() const noexcept -> ice::Path override { return "/saves"; } + auto cache_location() const noexcept -> ice::Path override { return "/cache"; } + auto dylibs_location() const noexcept -> ice::Path override { return {}; } private: static auto native_webapp_thread(void* userdata, ice::TaskQueue& queue) noexcept -> ice::u32; diff --git a/source/code/platforms/platform_webasm/private/webasm_threads.cxx b/source/code/platforms/platform_webasm/private/webasm_threads.cxx index 2c13864c..769c2e1a 100644 --- a/source/code/platforms/platform_webasm/private/webasm_threads.cxx +++ b/source/code/platforms/platform_webasm/private/webasm_threads.cxx @@ -26,9 +26,9 @@ namespace ice::platform::webasm , _scheduler_tasks{ queue_tasks } , _threads{ } { - ice::ucount const hw_concurrency = browser_hardware_concurrency(); + ice::i32 const hw_concurrency = browser_hardware_concurrency(); ICE_LOG(LogSeverity::Info, LogTag::System, "Logical Processors: {}", hw_concurrency); - ice::ucount tp_size = ice::max(ice::min(hw_concurrency, 4u), 2u); // min 2 task threads + ice::i32 tp_size = ice::max(ice::min(hw_concurrency, 4), 2); // min 2 task threads for (ice::Shard const option : params) { diff --git a/source/code/platforms/platform_webasm/private/webasm_threads.hxx b/source/code/platforms/platform_webasm/private/webasm_threads.hxx index 2f18fbe5..bd1c1611 100644 --- a/source/code/platforms/platform_webasm/private/webasm_threads.hxx +++ b/source/code/platforms/platform_webasm/private/webasm_threads.hxx @@ -22,7 +22,7 @@ namespace ice::platform::webasm auto graphics() noexcept -> ice::TaskScheduler& override { return _scheduler_gfx; } auto threadpool() noexcept -> ice::TaskScheduler& override { return _scheduler_tasks; } - auto threadpool_size() const noexcept -> ice::u32 override { return _threads->managed_thread_count(); } + auto threadpool_size() const noexcept -> ice::ncount override { return _threads->managed_thread_count(); } auto threadpool_object() noexcept -> ice::TaskThreadPool* override { return _threads.get(); } ice::TaskQueue queue_main; diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx index b9099a0d..3aaf3e50 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx @@ -377,7 +377,7 @@ namespace ice { u32 idx = ice::u32_max; auto it = _entrymap.find_values(uri.path()); - while (it.has_next() && idx == ice::u32_max) + while (it.valid() && idx == ice::u32_max) { if (_entries[it.value()]->name() == uri.path()) { diff --git a/source/code/systems/resource_system/private/resource_tracker.cxx b/source/code/systems/resource_system/private/resource_tracker.cxx index b28933d3..0a110961 100644 --- a/source/code/systems/resource_system/private/resource_tracker.cxx +++ b/source/code/systems/resource_system/private/resource_tracker.cxx @@ -368,7 +368,7 @@ namespace ice // Just grab the first for now auto it = _resources.find_values(hash_resouce); - if (it.has_next()) + if (it.valid()) { result = ice::ResourceHandle{ it.value() }; } diff --git a/source/configs.bff b/source/configs.bff index 01abce75..8cc81c84 100644 --- a/source/configs.bff +++ b/source/configs.bff @@ -224,10 +224,9 @@ '-sPTHREAD_POOL_SIZE=8' '-sPTHREADS_PROFILING=0' '-sSHARED_MEMORY=1' - '-sSTACK_SIZE=65536' // 64KiB - // '-sSTACK_SIZE=262144' // 64KiB + '-sSTACK_SIZE=4194304' // 4MiB '-sINITIAL_MEMORY=268435456' // 256MiB - // '-sINITIAL_MEMORY=1073741824' // 1GiB + //'-sINITIAL_MEMORY=1073741824' // 1GiB '-sMALLOC=mimalloc' '-sABORTING_MALLOC=1' '-sUSE_GLFW=3' diff --git a/tools/natvis.moon b/tools/natvis.moon index df31a60f..287a35c4 100644 --- a/tools/natvis.moon +++ b/tools/natvis.moon @@ -16,34 +16,34 @@ class NatvisCommand extends Command prepare: (args, project) => os.chdir "source/code" - iterate_over_headers: (path, shard_names) => + iterate_over_headers: (path, shard_names, locations) => return unless path\match "%.hxx" if f = io.open path, "rb" + idx = 0 for line in f\lines! + idx += 1 var, val = line\match 'static constexpr ice::Shard ([%w_:]+) = "([%w/-]+)[%w_:*` ]*"_shard' var, val = line\match 'static constexpr ice::ShardID ([%w_:]+) = "([%w/-]+)[%w_:*` ]*"_shardid' unless var and val if var and val print "Warning: Shard with this name '#{var}' already exists!" if shard_names.shard[var] shard_names.shard[var] = val + locations[val] = "#{path}(#{idx})" continue var, val = line\match 'Constant_ShardPayloadID<([%w_:* ]+)> = ice::shard_payloadid%("([%w_:* ]+)"%)' if var or val shard_names.payloadid[var] = val + locations[val] = "#{path}(#{idx})" f\close! - iterate_over_directory: (path, shard_names) => - for name, mode in (Dir\list path, 'mode') - continue if name == '.' or name == '..' - - @iterate_over_directory "#{path}/#{name}", shard_names if mode == 'directory' - @iterate_over_headers "#{path}/#{name}", shard_names - execute: (args) => + locations = { } names = { shard: { }, payloadid: {} } - @iterate_over_directory ".", names + + for path in Dir\list ".", recursive:true + @iterate_over_headers path, names, locations generate_hashes = (names, py3_hash_script) -> all_hashes = "" @@ -82,7 +82,9 @@ class NatvisCommand extends Command f\write ' {id.payload.value}, type_not_set\n' f\write ' {id.payload.value}, unknown_type\n' f\write ' \n' - f\write ' *(' .. name .. '*)&payload.value\n' for { :name, :hash } in *payload_hashes + for { :name, :hash } in *payload_hashes + f\write ' \n' + f\write ' *(' .. name .. '*)&payload.value\n' f\write ' \n' f\write ' \n' f\write '\n'