Skip to content

Commit

Permalink
meta data: drop deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Oct 28, 2024
1 parent 42bae0d commit f6159bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 88 deletions.
23 changes: 0 additions & 23 deletions src/entt/meta/meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,29 +934,6 @@ struct meta_data {
*/
[[nodiscard]] inline meta_type arg(size_type index) const noexcept;

/**
* @brief Returns a range to visit registered meta properties.
* @return An iterable range to visit registered meta properties.
*/
[[nodiscard]] [[deprecated("use ::custom() instead")]] meta_range<meta_prop, typename decltype(internal::meta_data_node::prop)::const_iterator> prop() const noexcept {
return {{*ctx, node->prop.cbegin()}, {*ctx, node->prop.cend()}};
}

/**
* @brief Lookup utility for meta properties.
* @param key The key to use to search for a property.
* @return The registered meta property for the given key, if any.
*/
[[nodiscard]] [[deprecated("use ::custom() instead")]] meta_prop prop(const id_type key) const {
for(auto &&elem: node->prop) {
if(elem.id == key) {
return meta_prop{*ctx, elem};
}
}

return meta_prop{};
}

/**
* @brief Returns all meta traits for a given meta object.
* @tparam Type The type to convert the meta traits to.
Expand Down
74 changes: 9 additions & 65 deletions test/entt/meta/meta_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ struct array {
int local[4]; // NOLINT
};

enum class property_type : entt::id_type {
random,
value
};

struct MetaData: ::testing::Test {
void SetUp() override {
using namespace entt::literals;
Expand All @@ -112,17 +107,13 @@ struct MetaData: ::testing::Test {
.data<&clazz::i, entt::as_ref_t>("i"_hs)
.custom<char>('c')
.traits(test::meta_traits::one | test::meta_traits::two | test::meta_traits::three)
.prop(3u, 0)
.data<&clazz::i, entt::as_cref_t>("ci"_hs)
.data<&clazz::j>("j"_hs)
.traits(test::meta_traits::one)
.prop("true"_hs, 1)
.data<&clazz::h>("h"_hs)
.traits(test::meta_traits::two)
.prop(static_cast<entt::id_type>(property_type::random), 2)
.data<&clazz::k>("k"_hs)
.traits(test::meta_traits::three)
.prop(static_cast<entt::id_type>(property_type::value), 3)
.data<&clazz::instance>("base"_hs)
.data<&clazz::i, entt::as_void_t>("void"_hs)
.conv<int>();
Expand Down Expand Up @@ -192,19 +183,26 @@ ENTT_DEBUG_TEST_F(MetaDataDeathTest, Custom) {
ASSERT_DEATH([[maybe_unused]] char value = entt::resolve<clazz>().data("j"_hs).custom(), "");
}

TEST_F(MetaData, NonConst) {
TEST_F(MetaData, Comparison) {
using namespace entt::literals;

auto data = entt::resolve<clazz>().data("i"_hs);
clazz instance{};

ASSERT_TRUE(data);

ASSERT_EQ(data, data);
ASSERT_NE(data, entt::meta_data{});
ASSERT_FALSE(data != data);
ASSERT_TRUE(data == data);
}

TEST_F(MetaData, NonConst) {
using namespace entt::literals;

auto data = entt::resolve<clazz>().data("i"_hs);
clazz instance{};

ASSERT_TRUE(data);
ASSERT_EQ(data.arity(), 1u);
ASSERT_EQ(data.type(), entt::resolve<int>());
ASSERT_EQ(data.arg(0u), entt::resolve<int>());
Expand All @@ -213,19 +211,6 @@ TEST_F(MetaData, NonConst) {
ASSERT_EQ(data.get(instance).cast<int>(), 0);
ASSERT_TRUE(data.set(instance, 1));
ASSERT_EQ(data.get(instance).cast<int>(), 1);

for(auto curr: data.prop()) {
ASSERT_EQ(curr.first, 3u);
ASSERT_EQ(curr.second.value(), 0);
}

ASSERT_FALSE(data.prop(2));
ASSERT_FALSE(data.prop('c'));

auto prop = data.prop(3u);

ASSERT_TRUE(prop);
ASSERT_EQ(prop.value(), 0);
}

TEST_F(MetaData, Const) {
Expand All @@ -243,19 +228,6 @@ TEST_F(MetaData, Const) {
ASSERT_EQ(data.get(instance).cast<int>(), 1);
ASSERT_FALSE(data.set(instance, 1));
ASSERT_EQ(data.get(instance).cast<int>(), 1);

for(auto curr: data.prop()) {
ASSERT_EQ(curr.first, "true"_hs);
ASSERT_EQ(curr.second.value(), 1);
}

ASSERT_FALSE(data.prop(false));
ASSERT_FALSE(data.prop('c'));

auto prop = data.prop("true"_hs);

ASSERT_TRUE(prop);
ASSERT_EQ(prop.value(), 1);
}

TEST_F(MetaData, Static) {
Expand All @@ -272,19 +244,6 @@ TEST_F(MetaData, Static) {
ASSERT_EQ(data.get({}).cast<int>(), 2);
ASSERT_TRUE(data.set({}, 1));
ASSERT_EQ(data.get({}).cast<int>(), 1);

for(auto curr: data.prop()) {
ASSERT_EQ(curr.first, static_cast<entt::id_type>(property_type::random));
ASSERT_EQ(curr.second.value(), 2);
}

ASSERT_FALSE(data.prop(static_cast<entt::id_type>(property_type::value)));
ASSERT_FALSE(data.prop('c'));

auto prop = data.prop(static_cast<entt::id_type>(property_type::random));

ASSERT_TRUE(prop);
ASSERT_EQ(prop.value(), 2);
}

TEST_F(MetaData, ConstStatic) {
Expand All @@ -301,19 +260,6 @@ TEST_F(MetaData, ConstStatic) {
ASSERT_EQ(data.get({}).cast<int>(), 3);
ASSERT_FALSE(data.set({}, 1));
ASSERT_EQ(data.get({}).cast<int>(), 3);

for(auto curr: data.prop()) {
ASSERT_EQ(curr.first, static_cast<entt::id_type>(property_type::value));
ASSERT_EQ(curr.second.value(), 3);
}

ASSERT_FALSE(data.prop(static_cast<entt::id_type>(property_type::random)));
ASSERT_FALSE(data.prop('c'));

auto prop = data.prop(static_cast<entt::id_type>(property_type::value));

ASSERT_TRUE(prop);
ASSERT_EQ(prop.value(), 3);
}

TEST_F(MetaData, GetMetaAnyArg) {
Expand Down Expand Up @@ -622,7 +568,6 @@ TEST_F(MetaData, AsRef) {
ASSERT_EQ(data.arity(), 1u);
ASSERT_EQ(data.type(), entt::resolve<int>());
ASSERT_EQ(data.arg(0u), entt::resolve<int>());
ASSERT_NE(data.prop().cbegin(), data.prop().cend());
ASSERT_EQ(instance.i, 0);

data.get(instance).cast<int &>() = 3;
Expand All @@ -642,7 +587,6 @@ TEST_F(MetaData, AsConstRef) {
ASSERT_EQ(data.arg(0u), entt::resolve<int>());
ASSERT_EQ(data.get(instance).cast<const int &>(), 0);
ASSERT_EQ(data.get(instance).cast<int>(), 0);
ASSERT_EQ(data.prop().cbegin(), data.prop().cend());
ASSERT_EQ(instance.i, 0);
}

Expand Down

0 comments on commit f6159bb

Please sign in to comment.