From 03e046f88011a6806e48d4fdfdfff396caac2c17 Mon Sep 17 00:00:00 2001 From: skypjack Date: Mon, 4 Aug 2025 16:13:44 +0200 Subject: [PATCH] davey: revert recent changes, move towards multiple tools with shared functions instead --- src/entt/tools/davey.hpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/entt/tools/davey.hpp b/src/entt/tools/davey.hpp index 52b8149d7..13729b3d8 100644 --- a/src/entt/tools/davey.hpp +++ b/src/entt/tools/davey.hpp @@ -25,10 +25,10 @@ namespace internal { #define LABEL_OR(elem) label ? label : std::string{elem.info().name()}.data() template -static void present_element(entt::meta_any obj, OnEntity on_entity) { +static void present_element(const entt::meta_any &obj, OnEntity on_entity) { for([[maybe_unused]] const auto [id, data]: obj.type().data()) { + const auto elem = data.get(obj); const char *label = data.name(); - auto elem = data.get(obj); if(auto type = data.type(); type.info() == entt::type_id()) { ImGui::Text("%s: %s", LABEL_OR(type), elem.template cast()); @@ -53,7 +53,7 @@ static void present_element(entt::meta_any obj, OnEntity on_entity) { if(as_string) { ImGui::Text("%s: %s", LABEL_OR(type), as_string); } else { - ImGui::Text("%s: %zu", LABEL_OR(type), std::as_const(elem).template allow_cast().template cast()); + ImGui::Text("%s: %zu", LABEL_OR(type), elem.template allow_cast().template cast()); } } else if(type.is_arithmetic()) { if(type.info() == entt::type_id()) { @@ -63,14 +63,14 @@ static void present_element(entt::meta_any obj, OnEntity on_entity) { } else if(type.info() == entt::type_id()) { ImGui::Text("%s: %c", LABEL_OR(type), elem.template cast()); } else if(type.is_integral()) { - ImGui::Text("%s: %zu", LABEL_OR(type), std::as_const(elem).template allow_cast().template cast()); + ImGui::Text("%s: %zu", LABEL_OR(type), elem.template allow_cast().template cast()); } else { - ImGui::Text("%s: %f", LABEL_OR(type), std::as_const(elem).template allow_cast().template cast()); + ImGui::Text("%s: %f", LABEL_OR(type), elem.template allow_cast().template cast()); } } else if(type.is_pointer_like()) { - if(auto deref = *elem; deref) { + if(auto deref = *obj; deref) { if(ImGui::TreeNode(LABEL_OR(type))) { - present_element(deref.as_ref(), on_entity); + present_element(*obj, on_entity); ImGui::TreePop(); } } else { @@ -102,15 +102,15 @@ static void present_element(entt::meta_any obj, OnEntity on_entity) { ImGui::PushID(static_cast(pos)); if(ImGui::TreeNode(LABEL_OR(type), "%zu", pos)) { - auto [key, value] = *it; + const auto [key, value] = *it; if(ImGui::TreeNode("key")) { - present_element(key.as_ref(), on_entity); + present_element(key, on_entity); ImGui::TreePop(); } if(ImGui::TreeNode("value")) { - present_element(value.as_ref(), on_entity); + present_element(value, on_entity); ImGui::TreePop(); } @@ -142,7 +142,7 @@ static void present_storage(const meta_ctx &ctx, const entt::basic_sparse_set::entity_type>(obj.as_ref(), [](const char *name, const Entity entt) { + present_element::entity_type>(obj, [](const char *name, const Entity entt) { ImGui::Text("%s: %d [%d/%d]", name, entt::to_integral(entt), entt::to_entity(entt), entt::to_version(entt)); }); } @@ -166,7 +166,7 @@ static void present_entity(const meta_ctx &ctx, const Entity entt, const It from if(auto type = entt::resolve(ctx, storage.info()); type) { if(const char *label = type.name(); ImGui::TreeNode(&storage.info(), "%s", LABEL_OR(storage))) { if(const auto obj = type.from_void(storage.value(entt)); obj) { - present_element(obj.as_ref(), [&ctx, from, to](const char *name, const Entity other) { + present_element(obj, [&ctx, from, to](const char *name, const Entity other) { if(ImGui::TreeNode(name, "%s: %d [%d/%d]", name, entt::to_integral(other), entt::to_entity(other), entt::to_version(other))) { present_entity(ctx, other, from, to); ImGui::TreePop(); @@ -198,7 +198,7 @@ static void present_view(const meta_ctx &ctx, const entt::basic_viewinfo()); type) { if(const char *label = type.name(); ImGui::TreeNode(&storage->info(), "%s", LABEL_OR((*storage)))) { if(const auto obj = type.from_void(storage->value(entt)); obj) { - present_element(obj.as_ref(), [](const char *name, const typename view_type::entity_type entt) { + present_element(obj, [](const char *name, const typename view_type::entity_type entt) { ImGui::Text("%s: %d [%d/%d]", name, entt::to_integral(entt), entt::to_entity(entt), entt::to_version(entt)); }); }