From d45c2aca8a715c709799e5620b10b35cb80d8e63 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 20 Mar 2025 09:26:25 +0100 Subject: [PATCH] meta: drop multi-setter support for meta data --- src/entt/meta/factory.hpp | 43 --------------------------------- test/entt/meta/meta_data.cpp | 40 ------------------------------ test/entt/meta/meta_factory.cpp | 21 ---------------- 3 files changed, 104 deletions(-) diff --git a/src/entt/meta/factory.hpp b/src/entt/meta/factory.hpp index 4ce10b6a9..412be6732 100644 --- a/src/entt/meta/factory.hpp +++ b/src/entt/meta/factory.hpp @@ -150,25 +150,6 @@ template class meta_factory: private internal::basic_meta_factory { using base_type = internal::basic_meta_factory; - template - [[deprecated("use variant types or conversion support")]] - void data(const id_type id, std::index_sequence) noexcept { - using data_type = std::invoke_result_t; - using args_type = type_list)>::args_type...>; - static_assert(Policy::template value, "Invalid return type for the given policy"); - - base_type::data( - internal::meta_data_node{ - id, - /* this is never static */ - (std::is_member_object_pointer_v)> && ... && std::is_const_v>) ? internal::meta_traits::is_const : internal::meta_traits::is_none, - Setter::size, - &internal::resolve>>, - &meta_arg(type_list_element_t::size != 1u), type_list_element_t>...>>, - +[](meta_handle instance, meta_any value) { return (meta_setter>(*instance.operator->(), value.as_ref()) || ...); }, - &meta_getter}); - } - public: /*! @brief Default constructor. */ meta_factory() noexcept @@ -419,30 +400,6 @@ public: return *this; } - /** - * @brief Assigns a meta data to a meta type by means of its setters and - * getter. - * - * Multi-setter support for meta data members. All setters are tried in the - * order of definition before returning to the caller.
- * Setters can be either free functions, member functions or a mix of them - * and are provided via a `value_list` type. - * - * @sa data - * - * @tparam Setter The actual functions to use as setters. - * @tparam Getter The actual getter function. - * @tparam Policy Optional policy (no policy set by default). - * @param id Unique identifier. - * @return A meta factory for the parent type. - */ - template - [[deprecated("use variant types or conversion support")]] - meta_factory data(const id_type id) noexcept { - data(id, std::make_index_sequence{}); - return *this; - } - /** * @brief Assigns a meta function to a meta type. * diff --git a/test/entt/meta/meta_data.cpp b/test/entt/meta/meta_data.cpp index 5772d27b0..103b84142 100644 --- a/test/entt/meta/meta_data.cpp +++ b/test/entt/meta/meta_data.cpp @@ -70,18 +70,6 @@ struct setter_getter { int value{0}; }; -struct multi_setter { - void from_double(double val) { - value = static_cast(val); - } - - void from_string(const char *val) { - value = std::atoi(val); - } - - int value{0}; -}; - struct array { inline static int global[2]; // NOLINT int local[4]; // NOLINT @@ -128,10 +116,6 @@ struct MetaData: ::testing::Test { .data("z_ro"_hs) .data("value"_hs); - entt::meta_factory{} - .type("multi_setter"_hs) - .data, &multi_setter::value>("value"_hs); - entt::meta_factory{} .type("array"_hs) .data<&array::global>("global"_hs) @@ -490,30 +474,6 @@ TEST_F(MetaData, SetterGetterReadOnlyDataMember) { ASSERT_EQ(data.get(instance).cast(), 0); } -TEST_F(MetaData, MultiSetter) { - using namespace entt::literals; - - auto data = entt::resolve().data("value"_hs); - multi_setter instance{}; - - ASSERT_TRUE(data); - ASSERT_EQ(data.arity(), 2u); - ASSERT_EQ(data.type(), entt::resolve()); - ASSERT_EQ(data.arg(0u), entt::resolve()); - ASSERT_EQ(data.arg(1u), entt::resolve()); - ASSERT_EQ(data.arg(2u), entt::meta_type{}); - ASSERT_FALSE(data.is_const()); - ASSERT_FALSE(data.is_static()); - ASSERT_EQ(data.get(instance).cast(), 0); - ASSERT_TRUE(data.set(instance, 1)); - ASSERT_EQ(data.get(instance).cast(), 1); - ASSERT_TRUE(data.set(instance, 2.)); - ASSERT_EQ(data.get(instance).cast(), 2); - ASSERT_FALSE(data.set(instance, std::string{"3"})); - ASSERT_TRUE(data.set(instance, std::string{"3"}.c_str())); - ASSERT_EQ(data.get(instance).cast(), 3); -} - TEST_F(MetaData, ConstInstance) { using namespace entt::literals; diff --git a/test/entt/meta/meta_factory.cpp b/test/entt/meta/meta_factory.cpp index e93ad83c3..cb8416ff2 100644 --- a/test/entt/meta/meta_factory.cpp +++ b/test/entt/meta/meta_factory.cpp @@ -282,27 +282,6 @@ TEST_F(MetaFactory, DataSetterGetter) { ASSERT_TRUE(type.set("value"_hs, instance, instance.get_int())); } -TEST_F(MetaFactory, DataMultiSetterGetter) { - using namespace entt::literals; - - clazz instance{1}; - entt::meta_factory factory{}; - entt::meta_type type = entt::resolve(); - - ASSERT_FALSE(type.data("value"_hs)); - - factory.data, &clazz::get_int>("value"_hs); - type = entt::resolve(); - - ASSERT_TRUE(type.data("value"_hs)); - ASSERT_EQ(type.get("value"_hs, std::as_const(instance)), instance.get_int()); - ASSERT_EQ(type.get("value"_hs, instance), instance.get_int()); - ASSERT_FALSE(type.set("value"_hs, std::as_const(instance), instance.get_int())); - ASSERT_TRUE(type.set("value"_hs, instance, instance.get_int())); - ASSERT_FALSE(type.set("value"_hs, std::as_const(instance), test::boxed_int{instance.get_int()})); - ASSERT_TRUE(type.set("value"_hs, instance, test::boxed_int{instance.get_int()})); -} - TEST_F(MetaFactory, DataOverwrite) { using namespace entt::literals;