Browse Source

meta: drop multi-setter support for meta data

Michele Caini 1 year ago
parent
commit
d45c2aca8a
3 changed files with 0 additions and 104 deletions
  1. 0 43
      src/entt/meta/factory.hpp
  2. 0 40
      test/entt/meta/meta_data.cpp
  3. 0 21
      test/entt/meta/meta_factory.cpp

+ 0 - 43
src/entt/meta/factory.hpp

@@ -150,25 +150,6 @@ template<typename Type>
 class meta_factory: private internal::basic_meta_factory {
 class meta_factory: private internal::basic_meta_factory {
     using base_type = internal::basic_meta_factory;
     using base_type = internal::basic_meta_factory;
 
 
-    template<typename Setter, auto Getter, typename Policy, std::size_t... Index>
-    [[deprecated("use variant types or conversion support")]]
-    void data(const id_type id, std::index_sequence<Index...>) noexcept {
-        using data_type = std::invoke_result_t<decltype(Getter), Type &>;
-        using args_type = type_list<typename meta_function_helper_t<Type, decltype(value_list_element_v<Index, Setter>)>::args_type...>;
-        static_assert(Policy::template value<data_type>, "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<decltype(value_list_element_v<Index, Setter>)> && ... && std::is_const_v<std::remove_reference_t<data_type>>) ? internal::meta_traits::is_const : internal::meta_traits::is_none,
-                Setter::size,
-                &internal::resolve<std::remove_cv_t<std::remove_reference_t<data_type>>>,
-                &meta_arg<type_list<type_list_element_t<static_cast<std::size_t>(type_list_element_t<Index, args_type>::size != 1u), type_list_element_t<Index, args_type>>...>>,
-                +[](meta_handle instance, meta_any value) { return (meta_setter<Type, value_list_element_v<Index, Setter>>(*instance.operator->(), value.as_ref()) || ...); },
-                &meta_getter<Type, Getter, Policy>});
-    }
-
 public:
 public:
     /*! @brief Default constructor. */
     /*! @brief Default constructor. */
     meta_factory() noexcept
     meta_factory() noexcept
@@ -419,30 +400,6 @@ public:
         return *this;
         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.<br/>
-     * 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<typename Setter, auto Getter, typename Policy = as_is_t>
-    [[deprecated("use variant types or conversion support")]]
-    meta_factory data(const id_type id) noexcept {
-        data<Setter, Getter, Policy>(id, std::make_index_sequence<Setter::size>{});
-        return *this;
-    }
-
     /**
     /**
      * @brief Assigns a meta function to a meta type.
      * @brief Assigns a meta function to a meta type.
      *
      *

+ 0 - 40
test/entt/meta/meta_data.cpp

@@ -70,18 +70,6 @@ struct setter_getter {
     int value{0};
     int value{0};
 };
 };
 
 
-struct multi_setter {
-    void from_double(double val) {
-        value = static_cast<int>(val);
-    }
-
-    void from_string(const char *val) {
-        value = std::atoi(val);
-    }
-
-    int value{0};
-};
-
 struct array {
 struct array {
     inline static int global[2]; // NOLINT
     inline static int global[2]; // NOLINT
     int local[4];                // NOLINT
     int local[4];                // NOLINT
@@ -128,10 +116,6 @@ struct MetaData: ::testing::Test {
             .data<nullptr, &setter_getter::getter>("z_ro"_hs)
             .data<nullptr, &setter_getter::getter>("z_ro"_hs)
             .data<nullptr, &setter_getter::value>("value"_hs);
             .data<nullptr, &setter_getter::value>("value"_hs);
 
 
-        entt::meta_factory<multi_setter>{}
-            .type("multi_setter"_hs)
-            .data<entt::value_list<&multi_setter::from_double, &multi_setter::from_string>, &multi_setter::value>("value"_hs);
-
         entt::meta_factory<array>{}
         entt::meta_factory<array>{}
             .type("array"_hs)
             .type("array"_hs)
             .data<&array::global>("global"_hs)
             .data<&array::global>("global"_hs)
@@ -490,30 +474,6 @@ TEST_F(MetaData, SetterGetterReadOnlyDataMember) {
     ASSERT_EQ(data.get(instance).cast<int>(), 0);
     ASSERT_EQ(data.get(instance).cast<int>(), 0);
 }
 }
 
 
-TEST_F(MetaData, MultiSetter) {
-    using namespace entt::literals;
-
-    auto data = entt::resolve<multi_setter>().data("value"_hs);
-    multi_setter instance{};
-
-    ASSERT_TRUE(data);
-    ASSERT_EQ(data.arity(), 2u);
-    ASSERT_EQ(data.type(), entt::resolve<int>());
-    ASSERT_EQ(data.arg(0u), entt::resolve<double>());
-    ASSERT_EQ(data.arg(1u), entt::resolve<const char *>());
-    ASSERT_EQ(data.arg(2u), entt::meta_type{});
-    ASSERT_FALSE(data.is_const());
-    ASSERT_FALSE(data.is_static());
-    ASSERT_EQ(data.get(instance).cast<int>(), 0);
-    ASSERT_TRUE(data.set(instance, 1));
-    ASSERT_EQ(data.get(instance).cast<int>(), 1);
-    ASSERT_TRUE(data.set(instance, 2.));
-    ASSERT_EQ(data.get(instance).cast<int>(), 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<int>(), 3);
-}
-
 TEST_F(MetaData, ConstInstance) {
 TEST_F(MetaData, ConstInstance) {
     using namespace entt::literals;
     using namespace entt::literals;
 
 

+ 0 - 21
test/entt/meta/meta_factory.cpp

@@ -282,27 +282,6 @@ TEST_F(MetaFactory, DataSetterGetter) {
     ASSERT_TRUE(type.set("value"_hs, instance, instance.get_int()));
     ASSERT_TRUE(type.set("value"_hs, instance, instance.get_int()));
 }
 }
 
 
-TEST_F(MetaFactory, DataMultiSetterGetter) {
-    using namespace entt::literals;
-
-    clazz instance{1};
-    entt::meta_factory<clazz> factory{};
-    entt::meta_type type = entt::resolve<clazz>();
-
-    ASSERT_FALSE(type.data("value"_hs));
-
-    factory.data<entt::value_list<&clazz::set_int, &clazz::set_boxed_int>, &clazz::get_int>("value"_hs);
-    type = entt::resolve<clazz>();
-
-    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) {
 TEST_F(MetaFactory, DataOverwrite) {
     using namespace entt::literals;
     using namespace entt::literals;