From 556ff733d5e2e1184e73847fe4e9d4804ee7f0a8 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 21 Mar 2025 08:08:45 +0100 Subject: [PATCH] meta: drop deprecated utilities --- src/entt/meta/utility.hpp | 45 --------------------------------- test/entt/meta/meta_utility.cpp | 34 ++++++++++++------------- 2 files changed, 17 insertions(+), 62 deletions(-) diff --git a/src/entt/meta/utility.hpp b/src/entt/meta/utility.hpp index 78062088f..5c9213155 100644 --- a/src/entt/meta/utility.hpp +++ b/src/entt/meta/utility.hpp @@ -342,20 +342,6 @@ template } } -/** - * @brief Gets the value of a given variable. - * @tparam Type Reflected type to which the variable is associated. - * @tparam Data The actual variable to get. - * @tparam Policy Optional policy (no policy set by default). - * @param ctx The context from which to search for meta types. - * @param instance An opaque instance of the underlying type, if required. - * @return A meta any containing the value of the underlying variable. - */ -template -[[deprecated("a context is no longer required, it is inferred from the meta_handle")]] [[nodiscard]] std::enable_if_t, meta_any> meta_getter(const meta_ctx &ctx, meta_handle instance) { - return meta_getter(meta_handle{ctx, std::move(instance)}); -} - /** * @brief Tries to _invoke_ an object given a list of erased parameters. * @tparam Type Reflected type to which the object to _invoke_ is associated. @@ -371,22 +357,6 @@ template return internal::meta_invoke(std::move(instance), std::forward(candidate), args, std::make_index_sequence>::args_type::size>{}); } -/** - * @brief Tries to _invoke_ an object given a list of erased parameters. - * @tparam Type Reflected type to which the object to _invoke_ is associated. - * @tparam Policy Optional policy (no policy set by default). - * @param ctx The context from which to search for meta types. - * @tparam Candidate The type of the actual object to _invoke_. - * @param instance An opaque instance of the underlying type, if required. - * @param candidate The actual object to _invoke_. - * @param args Parameters to use to _invoke_ the object. - * @return A meta any containing the returned value, if any. - */ -template -[[deprecated("a context is no longer required, it is inferred from the meta_handle")]] [[nodiscard]] std::enable_if_t, meta_any> meta_invoke(const meta_ctx &ctx, meta_handle instance, Candidate &&candidate, meta_any *const args) { - return meta_invoke(meta_handle{ctx, std::move(instance)}, std::forward(candidate), args); -} - /** * @brief Tries to invoke a function given a list of erased parameters. * @tparam Type Reflected type to which the function is associated. @@ -401,21 +371,6 @@ template return internal::meta_invoke(std::move(instance), Candidate, args, std::make_index_sequence>::args_type::size>{}); } -/** - * @brief Tries to invoke a function given a list of erased parameters. - * @tparam Type Reflected type to which the function is associated. - * @tparam Candidate The actual function to invoke. - * @tparam Policy Optional policy (no policy set by default). - * @param ctx The context from which to search for meta types. - * @param instance An opaque instance of the underlying type, if required. - * @param args Parameters to use to invoke the function. - * @return A meta any containing the returned value, if any. - */ -template -[[deprecated("a context is no longer required, it is inferred from the meta_handle")]] [[nodiscard]] std::enable_if_t, meta_any> meta_invoke(const meta_ctx &ctx, meta_handle instance, meta_any *const args) { - return meta_invoke(meta_handle{ctx, std::move(instance)}, args); -} - /** * @brief Tries to construct an instance given a list of erased parameters. * diff --git a/test/entt/meta/meta_utility.cpp b/test/entt/meta/meta_utility.cpp index 5695b9b61..e8cab8cf5 100644 --- a/test/entt/meta/meta_utility.cpp +++ b/test/entt/meta/meta_utility.cpp @@ -162,30 +162,30 @@ TEST_F(MetaUtility, MetaGetter) { clazz instance{}; ASSERT_FALSE((entt::meta_getter(invalid))); - ASSERT_EQ((entt::meta_getter(entt::meta_any{}.context(), instance)).cast(), 0); + ASSERT_EQ((entt::meta_getter(instance)).cast(), 0); ASSERT_FALSE((entt::meta_getter(invalid))); - ASSERT_EQ((entt::meta_getter(entt::meta_any{}.context(), instance)).cast(), 0); + ASSERT_EQ((entt::meta_getter(instance)).cast(), 0); ASSERT_FALSE((entt::meta_getter(invalid))); - ASSERT_EQ((entt::meta_getter(entt::meta_any{}.context(), instance)).cast(), 0); + ASSERT_EQ((entt::meta_getter(instance)).cast(), 0); ASSERT_EQ((entt::meta_getter(std::as_const(instance))).cast(), 0); ASSERT_FALSE((entt::meta_getter(invalid))); - ASSERT_EQ((entt::meta_getter(entt::meta_any{}.context(), instance)).cast(), 0); + ASSERT_EQ((entt::meta_getter(instance)).cast(), 0); ASSERT_EQ((entt::meta_getter(std::as_const(instance))).cast(), 0); ASSERT_FALSE((entt::meta_getter(invalid))); - ASSERT_FALSE((entt::meta_getter(entt::meta_any{}.context(), instance))); + ASSERT_FALSE((entt::meta_getter(instance))); ASSERT_EQ((entt::meta_getter(invalid)).cast(), 0); - ASSERT_EQ((entt::meta_getter(entt::meta_any{}.context(), instance)).cast(), 0); + ASSERT_EQ((entt::meta_getter(instance)).cast(), 0); ASSERT_EQ((entt::meta_getter(invalid)).cast(), 0); - ASSERT_EQ((entt::meta_getter(entt::meta_any{}.context(), instance)).cast(), 0); + ASSERT_EQ((entt::meta_getter(instance)).cast(), 0); ASSERT_EQ((entt::meta_getter(invalid)).cast(), 1); - ASSERT_EQ((entt::meta_getter(entt::meta_any{}.context(), instance)).cast(), 1); + ASSERT_EQ((entt::meta_getter(instance)).cast(), 1); } TEST_F(MetaUtility, MetaInvokeWithCandidate) { @@ -194,22 +194,22 @@ TEST_F(MetaUtility, MetaInvokeWithCandidate) { clazz::value = 3; ASSERT_FALSE((entt::meta_invoke({}, &clazz::setter, std::next(args.data())))); - ASSERT_FALSE((entt::meta_invoke(entt::meta_any{}.context(), {}, &clazz::getter, nullptr))); + ASSERT_FALSE((entt::meta_invoke({}, &clazz::getter, nullptr))); ASSERT_TRUE((entt::meta_invoke(args[0u], &clazz::setter, std::next(args.data())))); - ASSERT_FALSE((entt::meta_invoke(entt::meta_any{}.context(), args[0u], &clazz::setter, args.data()))); + ASSERT_FALSE((entt::meta_invoke(args[0u], &clazz::setter, args.data()))); ASSERT_EQ((entt::meta_invoke(args[0u], &clazz::getter, nullptr)).cast(), 4); - ASSERT_FALSE((entt::meta_invoke(entt::meta_any{}.context(), args[1u], &clazz::getter, nullptr))); + ASSERT_FALSE((entt::meta_invoke(args[1u], &clazz::getter, nullptr))); ASSERT_EQ((entt::meta_invoke({}, &clazz::get_value, nullptr)).cast(), 3); - ASSERT_TRUE((entt::meta_invoke(entt::meta_any{}.context(), {}, &clazz::reset_value, nullptr))); + ASSERT_TRUE((entt::meta_invoke({}, &clazz::reset_value, nullptr))); ASSERT_EQ(args[0u].cast().value, 0); const auto setter = [](int &value) { value = 3; }; const auto getter = [](int value) { return value * 2; }; ASSERT_TRUE(entt::meta_invoke({}, setter, std::next(args.data()))); - ASSERT_EQ(entt::meta_invoke(entt::meta_any{}.context(), {}, getter, std::next(args.data())).cast(), 6); + ASSERT_EQ(entt::meta_invoke({}, getter, std::next(args.data())).cast(), 6); } TEST_F(MetaUtility, MetaInvoke) { @@ -218,15 +218,15 @@ TEST_F(MetaUtility, MetaInvoke) { clazz::value = 3; ASSERT_FALSE((entt::meta_invoke({}, std::next(args.data())))); - ASSERT_FALSE((entt::meta_invoke(entt::meta_any{}.context(), {}, nullptr))); + ASSERT_FALSE((entt::meta_invoke({}, nullptr))); ASSERT_TRUE((entt::meta_invoke(args[0u], std::next(args.data())))); - ASSERT_FALSE((entt::meta_invoke(entt::meta_any{}.context(), args[0u], args.data()))); + ASSERT_FALSE((entt::meta_invoke(args[0u], args.data()))); ASSERT_EQ((entt::meta_invoke(args[0u], nullptr)).cast(), 4); - ASSERT_FALSE((entt::meta_invoke(entt::meta_any{}.context(), args[1u], nullptr))); + ASSERT_FALSE((entt::meta_invoke(args[1u], nullptr))); ASSERT_EQ((entt::meta_invoke({}, nullptr)).cast(), 3); - ASSERT_TRUE((entt::meta_invoke(entt::meta_any{}.context(), {}, nullptr))); + ASSERT_TRUE((entt::meta_invoke({}, nullptr))); ASSERT_EQ(args[0u].cast().value, 0); }