diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 15:30:15 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 15:30:15 +0200 |
commit | 82ab34aa83463179339eb8382edf1c22cacdad61 (patch) | |
tree | 3d02aaa7458a4f00e38527c7cfe0f8559398b5d5 /editor | |
parent | c3bebd8c3263d67f3b66cab7437bc24f5ea724c8 (diff) |
use array_size instead of std::size/arraySize
Diffstat (limited to 'editor')
-rw-r--r-- | editor/imgui-editors.cpp | 3 | ||||
-rw-r--r-- | editor/inspect-draw.cpp | 3 | ||||
-rw-r--r-- | editor/tests.cpp | 5 | ||||
-rw-r--r-- | editor/tests/path-test.cpp | 11 | ||||
-rw-r--r-- | editor/tests/raycast-test.cpp | 21 | ||||
-rw-r--r-- | editor/wall-editor.cpp | 3 |
6 files changed, 26 insertions, 20 deletions
diff --git a/editor/imgui-editors.cpp b/editor/imgui-editors.cpp index 4872f9a2..a2ddbf5b 100644 --- a/editor/imgui-editors.cpp +++ b/editor/imgui-editors.cpp @@ -1,5 +1,6 @@ #include "app.hpp" #include "src/tile-constants.hpp" +#include "compat/array-size.hpp" #include "compat/format.hpp" #include "imgui-raii.hpp" #include "ground-editor.hpp" @@ -83,7 +84,7 @@ void draw_editor_tile_pane_atlas(ground_editor& ed, StringView name, const std:: text(" (selected)"); } const auto len = snformat(buf, "{:d}"_cf, N); - fm_assert(len < std::size(buf)); + fm_assert(len < array_size(buf)); ImGui::SameLine(window_width - ImGui::CalcTextSize(buf).x - style.FramePadding.x - 4*dpi[0]); text({buf, len}); }; diff --git a/editor/inspect-draw.cpp b/editor/inspect-draw.cpp index e495e7ad..c420c03e 100644 --- a/editor/inspect-draw.cpp +++ b/editor/inspect-draw.cpp @@ -1,4 +1,5 @@ #include "app.hpp" +#include "compat/array-size.hpp" #include "compat/format.hpp" #include "inspect.hpp" #include "floormat/main.hpp" @@ -47,7 +48,7 @@ auto z = e.coord.z(); #else entity_inspector_name(buf2, sizeof buf2, e.id); entity_friendly_name(buf3, sizeof buf3, e); - std::snprintf(buf, std::size(buf), "%s###%s", buf3, buf2); + std::snprintf(buf, array_size(buf), "%s###%s", buf3, buf2); #endif bool is_open = true; diff --git a/editor/tests.cpp b/editor/tests.cpp index d55da0c8..077e03dd 100644 --- a/editor/tests.cpp +++ b/editor/tests.cpp @@ -1,4 +1,5 @@ #include "tests-private.hpp" +#include "compat/array-size.hpp" #include "compat/safe-ptr.hpp" #include "app.hpp" #include "floormat/main.hpp" @@ -20,7 +21,7 @@ namespace floormat::tests { -static_assert(arraySize(tests_data::fields) <= (size_t)Test::COUNT); +static_assert(array_size(tests_data::fields) <= (size_t)Test::COUNT); Pointer<base_test> tests_data::make_test_none() { return {}; } @@ -42,7 +43,7 @@ using namespace floormat::imgui; void tests_data::switch_to(Test i) { - fm_assert((size_t)i < arraySize(fields)); + fm_assert((size_t)i < array_size(fields)); current_index = Test::none; current_test = make_test_none(); if (i < Test::COUNT) diff --git a/editor/tests/path-test.cpp b/editor/tests/path-test.cpp index 4558fedd..63b59dd4 100644 --- a/editor/tests/path-test.cpp +++ b/editor/tests/path-test.cpp @@ -1,5 +1,6 @@ #include "../tests-private.hpp" #include "../app.hpp" +#include "compat/array-size.hpp" #include "compat/shared-ptr-wrapper.hpp" #include "compat/vector-wrapper.hpp" #include "floormat/main.hpp" @@ -187,7 +188,7 @@ void path_test::draw_ui(app&, float) constexpr auto print_coord = [](auto&& buf, Vector3i c, Vector2i l, Vector2i p) { - std::snprintf(buf, std::size(buf), "(ch %dx%d) <%dx%d> {%dx%d px}", c.x(), c.y(), l.x(), l.y(), p.x(), p.y()); + std::snprintf(buf, array_size(buf), "(ch %dx%d) <%dx%d> {%dx%d px}", c.x(), c.y(), l.x(), l.y(), p.x(), p.y()); }; constexpr auto do_column = [](StringView name) @@ -226,21 +227,21 @@ void path_test::draw_ui(app&, float) { auto b = push_style_color(ImGuiCol_Text, 0xffff00ff_rgbaf); do_column("dist"); - std::snprintf(buf, std::size(buf), "%d", (int)res.distance()); + std::snprintf(buf, array_size(buf), "%d", (int)res.distance()); text(buf); } } do_column("cost"); - std::snprintf(buf, std::size(buf), "%d", (int)res.cost()); + std::snprintf(buf, array_size(buf), "%d", (int)res.cost()); text(buf); do_column("length"); - std::snprintf(buf, std::size(buf), "%d", (int)res.path().size()); + std::snprintf(buf, array_size(buf), "%d", (int)res.path().size()); text(buf); do_column("time"); - std::snprintf(buf, std::size(buf), "%.1f ms", (double)(1000 * res.time())); + std::snprintf(buf, array_size(buf), "%.1f ms", (double)(1000 * res.time())); text(buf); } } diff --git a/editor/tests/raycast-test.cpp b/editor/tests/raycast-test.cpp index d1f72b70..6596303f 100644 --- a/editor/tests/raycast-test.cpp +++ b/editor/tests/raycast-test.cpp @@ -1,6 +1,7 @@ #include "../tests-private.hpp" #include "editor/app.hpp" #include "floormat/main.hpp" +#include "compat/array-size.hpp" #include "compat/shared-ptr-wrapper.hpp" #include "../imgui-raii.hpp" #include "src/critter.hpp" @@ -27,7 +28,7 @@ struct pending_s void print_coord(auto&& buf, Vector3i c, Vector2i l, Vector2i p) { - std::snprintf(buf, std::size(buf), "(ch %dx%d) <%dx%d> {%dx%d px}", c.x(), c.y(), l.x(), l.y(), p.x(), p.y()); + std::snprintf(buf, array_size(buf), "(ch %dx%d) <%dx%d> {%dx%d px}", c.x(), c.y(), l.x(), l.y(), p.x(), p.y()); } void print_coord_(auto&& buf, point pt) @@ -40,7 +41,7 @@ void print_coord_(auto&& buf, point pt) void print_vec2(auto&& buf, Vector2 vec) { - std::snprintf(buf, std::size(buf), "(%.2f x %.2f)", (double)vec.x(), (double)vec.y()); + std::snprintf(buf, array_size(buf), "(%.2f x %.2f)", (double)vec.x(), (double)vec.y()); } void do_column(StringView name) @@ -197,7 +198,7 @@ struct raycast_test final : base_test } do_column("collider"); - std::snprintf(buf, std::size(buf), "%s @ %" PRIu64, + std::snprintf(buf, array_size(buf), "%s @ %" PRIu64, type, uint64_t{result.collider.data}); { auto b = push_style_color(ImGuiCol_Text, 0xffff00ff_rgbaf); text(buf); @@ -207,13 +208,13 @@ struct raycast_test final : base_test ImGui::NewLine(); do_column("dir"); - std::snprintf(buf, std::size(buf), "%.4f x %.4f", (double)diag.dir.x(), (double)diag.dir.y()); + std::snprintf(buf, array_size(buf), "%.4f x %.4f", (double)diag.dir.x(), (double)diag.dir.y()); text(buf); if (!result.success) { do_column("tmin"); - std::snprintf(buf, std::size(buf), "%f / %f", + std::snprintf(buf, array_size(buf), "%f / %f", (double)diag.tmin, (double)(diag.tmin / diag.V.length())); text(buf); @@ -221,7 +222,7 @@ struct raycast_test final : base_test else { do_column("tmin"); - std::snprintf(buf, std::size(buf), "%f / %f", + std::snprintf(buf, array_size(buf), "%f / %f", (double)diag.V.length(), 1.0); text(buf); } @@ -231,7 +232,7 @@ struct raycast_test final : base_test text(buf); do_column("||dir^-1||"); - std::snprintf(buf, std::size(buf), "%f x %f", + std::snprintf(buf, array_size(buf), "%f x %f", (double)diag.dir_inv_norm.x(), (double)diag.dir_inv_norm.y()); text(buf); @@ -239,15 +240,15 @@ struct raycast_test final : base_test ImGui::NewLine(); do_column("bbox-size"); - std::snprintf(buf, std::size(buf), "(%u x %u)", diag.size.x(), diag.size.y()); + std::snprintf(buf, array_size(buf), "(%u x %u)", diag.size.x(), diag.size.y()); text(buf); do_column("path-len"); - std::snprintf(buf, std::size(buf), "%zu", diag.path.size()); + std::snprintf(buf, array_size(buf), "%zu", diag.path.size()); text(buf); do_column("time"); - std::snprintf(buf, std::size(buf), "%.3f ms", (double)(1000 * result.time)); + std::snprintf(buf, array_size(buf), "%.3f ms", (double)(1000 * result.time)); text(buf); } } diff --git a/editor/wall-editor.cpp b/editor/wall-editor.cpp index 99d47643..57cdb8ed 100644 --- a/editor/wall-editor.cpp +++ b/editor/wall-editor.cpp @@ -1,4 +1,5 @@ #include "wall-editor.hpp" +#include "compat/array-size.hpp" #include "src/wall-defs.hpp" #include "src/wall-atlas.hpp" #include "src/world.hpp" @@ -18,7 +19,7 @@ constexpr inline rot_pair rot_map[] = { { rotation::N, Direction_::N }, { rotation::W, Direction_::W }, }; -static_assert(std::size(rot_map) == Direction_COUNT); +static_assert(array_size(rot_map) == Direction_COUNT); constexpr rotation dir_to_rot(Direction_ D) { |