meta: removed some deprecated functions (semantics had changed, it was already a breaking change in itself)
This commit is contained in:
@@ -678,20 +678,6 @@ struct meta_ctor {
|
||||
return node->prop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all meta properties assigned to a meta constructor.
|
||||
* @tparam Op Type of the function object to invoke.
|
||||
* @param op A valid function object.
|
||||
*/
|
||||
template<typename Op>
|
||||
[[deprecated("use prop() and entt::meta_range<meta_prop> instead")]]
|
||||
std::enable_if_t<std::is_invocable_v<Op, meta_prop>>
|
||||
prop(Op op) const {
|
||||
for(auto curr: prop()) {
|
||||
op(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the property associated with a given key.
|
||||
* @param key The key to use to search for a property.
|
||||
@@ -789,20 +775,6 @@ struct meta_data {
|
||||
return node->prop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all meta properties assigned to a meta data.
|
||||
* @tparam Op Type of the function object to invoke.
|
||||
* @param op A valid function object.
|
||||
*/
|
||||
template<typename Op>
|
||||
[[deprecated("use prop() and entt::meta_range<meta_prop> instead")]]
|
||||
std::enable_if_t<std::is_invocable_v<Op, meta_prop>>
|
||||
prop(Op op) const {
|
||||
for(auto curr: prop()) {
|
||||
op(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the property associated with a given key.
|
||||
* @param key The key to use to search for a property.
|
||||
@@ -913,20 +885,6 @@ struct meta_func {
|
||||
return node->prop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all meta properties assigned to a meta function.
|
||||
* @tparam Op Type of the function object to invoke.
|
||||
* @param op A valid function object.
|
||||
*/
|
||||
template<typename Op>
|
||||
[[deprecated("use prop() and entt::meta_range<meta_prop> instead")]]
|
||||
std::enable_if_t<std::is_invocable_v<Op, meta_prop>>
|
||||
prop(Op op) const {
|
||||
for(auto curr: prop()) {
|
||||
op(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the property associated with a given key.
|
||||
* @param key The key to use to search for a property.
|
||||
@@ -1159,20 +1117,6 @@ public:
|
||||
return node->base;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all top-level meta bases of a meta type.
|
||||
* @tparam Op Type of the function object to invoke.
|
||||
* @param op A valid function object.
|
||||
*/
|
||||
template<typename Op>
|
||||
[[deprecated("use base() and entt::meta_range<meta_base> instead")]]
|
||||
std::enable_if_t<std::is_invocable_v<Op, meta_base>>
|
||||
base(Op op) const {
|
||||
for(auto curr: base()) {
|
||||
op(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the meta base associated with a given identifier.
|
||||
* @param id Unique identifier.
|
||||
@@ -1194,19 +1138,6 @@ public:
|
||||
return node->conv;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all top-level meta conversion functions of a meta type.
|
||||
* @tparam Op Type of the function object to invoke.
|
||||
* @param op A valid function object.
|
||||
*/
|
||||
template<typename Op>
|
||||
[[deprecated("use conv() and entt::meta_range<meta_conv> instead")]]
|
||||
void conv(Op op) const {
|
||||
for(auto curr: conv()) {
|
||||
op(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the meta conversion function associated with a given type.
|
||||
* @tparam Type The type to use to search for a meta conversion function.
|
||||
@@ -1228,19 +1159,6 @@ public:
|
||||
return node->ctor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all top-level meta constructors of a meta type.
|
||||
* @tparam Op Type of the function object to invoke.
|
||||
* @param op A valid function object.
|
||||
*/
|
||||
template<typename Op>
|
||||
[[deprecated("use ctor() and entt::meta_range<meta_ctor> instead")]]
|
||||
void ctor(Op op) const {
|
||||
for(auto curr: ctor()) {
|
||||
op(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the meta constructor that accepts a given list of types of
|
||||
* arguments.
|
||||
@@ -1259,20 +1177,6 @@ public:
|
||||
return node->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all top-level meta data of a meta type.
|
||||
* @tparam Op Type of the function object to invoke.
|
||||
* @param op A valid function object.
|
||||
*/
|
||||
template<typename Op>
|
||||
[[deprecated("use ctor() and entt::meta_range<meta_ctor> instead")]]
|
||||
std::enable_if_t<std::is_invocable_v<Op, meta_data>>
|
||||
data(Op op) const {
|
||||
for(auto curr: data()) {
|
||||
op(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the meta data associated with a given identifier.
|
||||
*
|
||||
@@ -1295,20 +1199,6 @@ public:
|
||||
return node->func;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all top-level meta functions of a meta type.
|
||||
* @tparam Op Type of the function object to invoke.
|
||||
* @param op A valid function object.
|
||||
*/
|
||||
template<typename Op>
|
||||
[[deprecated("use ctor() and entt::meta_range<meta_ctor> instead")]]
|
||||
std::enable_if_t<std::is_invocable_v<Op, meta_func>>
|
||||
func(Op op) const {
|
||||
for(auto curr: func()) {
|
||||
op(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the meta function associated with a given identifier.
|
||||
*
|
||||
@@ -1354,20 +1244,6 @@ public:
|
||||
return node->prop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all top-level meta properties assigned to a meta type.
|
||||
* @tparam Op Type of the function object to invoke.
|
||||
* @param op A valid function object.
|
||||
*/
|
||||
template<typename Op>
|
||||
[[deprecated("use prop() and entt::meta_range<meta_prop> instead")]]
|
||||
std::enable_if_t<std::is_invocable_v<Op, meta_prop>>
|
||||
prop(Op op) const {
|
||||
for(auto curr: prop()) {
|
||||
op(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the property associated with a given key.
|
||||
*
|
||||
|
||||
@@ -31,34 +31,6 @@ template<typename Type>
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Iterates all the reflected types.
|
||||
* @tparam Op Type of the function object to invoke.
|
||||
* @param op A valid function object.
|
||||
*/
|
||||
template<typename Op>
|
||||
[[deprecated("use resolve() and entt::meta_range<meta_type> instead")]]
|
||||
void resolve(Op op) {
|
||||
for(auto curr: resolve()) {
|
||||
op(curr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns the first meta type that satisfies specific criteria, if any.
|
||||
* @tparam Func Type of the unary predicate to use to test the meta types.
|
||||
* @param func Unary predicate which returns true for the required element.
|
||||
* @return The first meta type satisfying the condition, if any.
|
||||
*/
|
||||
template<typename Func>
|
||||
[[deprecated("use std::find_if and entt::meta_range<meta_type> instead")]]
|
||||
[[nodiscard]] meta_type resolve_if(Func func) ENTT_NOEXCEPT {
|
||||
internal::meta_range range{*internal::meta_context::global()};
|
||||
return std::find_if(range.begin(), range.end(), [&func](const auto &curr) { return func(meta_type{&curr}); }).operator->();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns the meta type associated with a given identifier, if any.
|
||||
* @param id Unique identifier.
|
||||
|
||||
@@ -60,10 +60,10 @@ TEST_F(MetaCtor, Functionalities) {
|
||||
ASSERT_EQ(any.cast<clazz_t>().i, 42);
|
||||
ASSERT_EQ(any.cast<clazz_t>().c, 'c');
|
||||
|
||||
ctor.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), 3);
|
||||
ASSERT_FALSE(prop.value().template cast<bool>());
|
||||
});
|
||||
for(auto curr: ctor.prop()) {
|
||||
ASSERT_EQ(curr.key(), 3);
|
||||
ASSERT_FALSE(curr.value().template cast<bool>());
|
||||
}
|
||||
|
||||
ASSERT_FALSE(ctor.prop(2));
|
||||
ASSERT_FALSE(ctor.prop('c'));
|
||||
@@ -92,10 +92,10 @@ TEST_F(MetaCtor, Func) {
|
||||
ASSERT_EQ(any.cast<clazz_t>().i, 42);
|
||||
ASSERT_EQ(any.cast<clazz_t>().c, 'c');
|
||||
|
||||
ctor.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), 'c');
|
||||
ASSERT_EQ(prop.value(), 42);
|
||||
});
|
||||
for(auto curr: ctor.prop()) {
|
||||
ASSERT_EQ(curr.key(), 'c');
|
||||
ASSERT_EQ(curr.value(), 42);
|
||||
}
|
||||
|
||||
ASSERT_FALSE(ctor.prop('d'));
|
||||
ASSERT_FALSE(ctor.prop(3));
|
||||
|
||||
@@ -110,10 +110,10 @@ TEST_F(MetaData, Functionalities) {
|
||||
ASSERT_TRUE(data.set(instance, 42));
|
||||
ASSERT_EQ(data.get(instance).cast<int>(), 42);
|
||||
|
||||
data.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), 3);
|
||||
ASSERT_EQ(prop.value(), 0);
|
||||
});
|
||||
for(auto curr: data.prop()) {
|
||||
ASSERT_EQ(curr.key(), 3);
|
||||
ASSERT_EQ(curr.value(), 0);
|
||||
}
|
||||
|
||||
ASSERT_FALSE(data.prop(2));
|
||||
ASSERT_FALSE(data.prop('c'));
|
||||
@@ -139,10 +139,10 @@ TEST_F(MetaData, Const) {
|
||||
ASSERT_FALSE(data.set(instance, 42));
|
||||
ASSERT_EQ(data.get(instance).cast<int>(), 1);
|
||||
|
||||
data.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), true);
|
||||
ASSERT_EQ(prop.value(), 1);
|
||||
});
|
||||
for(auto curr: data.prop()) {
|
||||
ASSERT_EQ(curr.key(), true);
|
||||
ASSERT_EQ(curr.value(), 1);
|
||||
}
|
||||
|
||||
ASSERT_FALSE(data.prop(false));
|
||||
ASSERT_FALSE(data.prop('c'));
|
||||
@@ -167,10 +167,10 @@ TEST_F(MetaData, Static) {
|
||||
ASSERT_TRUE(data.set({}, 42));
|
||||
ASSERT_EQ(data.get({}).cast<int>(), 42);
|
||||
|
||||
data.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), property_t::random);
|
||||
ASSERT_EQ(prop.value(), 2);
|
||||
});
|
||||
for(auto curr: data.prop()) {
|
||||
ASSERT_EQ(curr.key(), property_t::random);
|
||||
ASSERT_EQ(curr.value(), 2);
|
||||
}
|
||||
|
||||
ASSERT_FALSE(data.prop(property_t::value));
|
||||
ASSERT_FALSE(data.prop('c'));
|
||||
@@ -195,10 +195,10 @@ TEST_F(MetaData, ConstStatic) {
|
||||
ASSERT_FALSE(data.set({}, 42));
|
||||
ASSERT_EQ(data.get({}).cast<int>(), 3);
|
||||
|
||||
data.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), property_t::value);
|
||||
ASSERT_EQ(prop.value(), 3);
|
||||
});
|
||||
for(auto curr: data.prop()) {
|
||||
ASSERT_EQ(curr.key(), property_t::value);
|
||||
ASSERT_EQ(curr.value(), 3);
|
||||
}
|
||||
|
||||
ASSERT_FALSE(data.prop(property_t::random));
|
||||
ASSERT_FALSE(data.prop('c'));
|
||||
|
||||
@@ -104,10 +104,10 @@ TEST_F(MetaFunc, Functionalities) {
|
||||
ASSERT_EQ(any.cast<int>(), 4);
|
||||
ASSERT_EQ(func_t::value, 3);
|
||||
|
||||
func.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), true);
|
||||
ASSERT_FALSE(prop.value().template cast<bool>());
|
||||
});
|
||||
for(auto curr: func.prop()) {
|
||||
ASSERT_EQ(curr.key(), true);
|
||||
ASSERT_FALSE(curr.value().template cast<bool>());
|
||||
}
|
||||
|
||||
ASSERT_FALSE(func.prop(false));
|
||||
ASSERT_FALSE(func.prop('c'));
|
||||
@@ -141,10 +141,10 @@ TEST_F(MetaFunc, Const) {
|
||||
ASSERT_EQ(any.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(any.cast<int>(), 16);
|
||||
|
||||
func.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), true);
|
||||
ASSERT_FALSE(prop.value().template cast<bool>());
|
||||
});
|
||||
for(auto curr: func.prop()) {
|
||||
ASSERT_EQ(curr.key(), true);
|
||||
ASSERT_FALSE(curr.value().template cast<bool>());
|
||||
}
|
||||
|
||||
ASSERT_FALSE(func.prop(false));
|
||||
ASSERT_FALSE(func.prop('c'));
|
||||
@@ -176,10 +176,10 @@ TEST_F(MetaFunc, RetVoid) {
|
||||
ASSERT_EQ(any.type(), entt::resolve<void>());
|
||||
ASSERT_EQ(func_t::value, 25);
|
||||
|
||||
func.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), true);
|
||||
ASSERT_FALSE(prop.value().template cast<bool>());
|
||||
});
|
||||
for(auto curr: func.prop()) {
|
||||
ASSERT_EQ(curr.key(), true);
|
||||
ASSERT_FALSE(curr.value().template cast<bool>());
|
||||
}
|
||||
|
||||
ASSERT_FALSE(func.prop(false));
|
||||
ASSERT_FALSE(func.prop('c'));
|
||||
@@ -213,10 +213,10 @@ TEST_F(MetaFunc, Static) {
|
||||
ASSERT_EQ(any.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(any.cast<int>(), 6);
|
||||
|
||||
func.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), true);
|
||||
ASSERT_FALSE(prop.value().template cast<bool>());
|
||||
});
|
||||
for(auto curr: func.prop()) {
|
||||
ASSERT_EQ(curr.key(), true);
|
||||
ASSERT_FALSE(curr.value().template cast<bool>());
|
||||
}
|
||||
|
||||
ASSERT_FALSE(func.prop(false));
|
||||
ASSERT_FALSE(func.prop('c'));
|
||||
@@ -247,11 +247,11 @@ TEST_F(MetaFunc, StaticRetVoid) {
|
||||
ASSERT_EQ(any.type(), entt::resolve<void>());
|
||||
ASSERT_EQ(func_t::value, 42);
|
||||
|
||||
func.prop([](auto prop) {
|
||||
ASSERT_TRUE(prop);
|
||||
ASSERT_EQ(prop.key(), true);
|
||||
ASSERT_FALSE(prop.value().template cast<bool>());
|
||||
});
|
||||
for(auto curr: func.prop()) {
|
||||
ASSERT_TRUE(curr);
|
||||
ASSERT_EQ(curr.key(), true);
|
||||
ASSERT_FALSE(curr.value().template cast<bool>());
|
||||
}
|
||||
|
||||
ASSERT_FALSE(func.prop(false));
|
||||
ASSERT_FALSE(func.prop('c'));
|
||||
|
||||
@@ -95,14 +95,19 @@ struct MetaType: ::testing::Test {
|
||||
TEST_F(MetaType, Resolve) {
|
||||
ASSERT_EQ(entt::resolve<double>(), entt::resolve_id("double"_hs));
|
||||
ASSERT_EQ(entt::resolve<double>(), entt::resolve_type(entt::type_info<double>::id()));
|
||||
|
||||
auto range = entt::resolve();
|
||||
// it could be "char"_hs rather than entt::hashed_string::value("char") if it weren't for a bug in VS2017
|
||||
ASSERT_EQ(entt::resolve_if([](auto type) { return type.id() == entt::hashed_string::value("clazz"); }), entt::resolve<clazz_t>());
|
||||
const auto it = std::find_if(range.begin(), range.end(), [](auto type) { return type.id() == entt::hashed_string::value("clazz"); });
|
||||
|
||||
ASSERT_NE(it, range.end());
|
||||
ASSERT_EQ(*it, entt::resolve<clazz_t>());
|
||||
|
||||
bool found = false;
|
||||
|
||||
entt::resolve([&found](auto type) {
|
||||
found = found || type == entt::resolve<double>();
|
||||
});
|
||||
for(auto curr: entt::resolve()) {
|
||||
found = found || curr == entt::resolve<double>();
|
||||
}
|
||||
|
||||
ASSERT_TRUE(found);
|
||||
}
|
||||
@@ -115,10 +120,10 @@ TEST_F(MetaType, Functionalities) {
|
||||
ASSERT_EQ(type.id(), "clazz"_hs);
|
||||
ASSERT_EQ(type.type_id(), entt::type_info<clazz_t>::id());
|
||||
|
||||
type.prop([](auto prop) {
|
||||
ASSERT_EQ(prop.key(), property_t::value);
|
||||
ASSERT_EQ(prop.value(), 42);
|
||||
});
|
||||
for(auto curr: type.prop()) {
|
||||
ASSERT_EQ(curr.key(), property_t::value);
|
||||
ASSERT_EQ(curr.value(), 42);
|
||||
}
|
||||
|
||||
ASSERT_FALSE(type.prop(property_t::key_only));
|
||||
ASSERT_FALSE(type.prop("property"_hs));
|
||||
@@ -199,10 +204,10 @@ TEST_F(MetaType, Base) {
|
||||
auto type = entt::resolve<derived_t>();
|
||||
bool iterate = false;
|
||||
|
||||
type.base([&iterate](auto base) {
|
||||
ASSERT_EQ(base.type(), entt::resolve<base_t>());
|
||||
for(auto curr: type.base()) {
|
||||
ASSERT_EQ(curr.type(), entt::resolve<base_t>());
|
||||
iterate = true;
|
||||
});
|
||||
}
|
||||
|
||||
ASSERT_TRUE(iterate);
|
||||
ASSERT_EQ(type.base("base"_hs).type(), entt::resolve<base_t>());
|
||||
@@ -212,10 +217,10 @@ TEST_F(MetaType, Conv) {
|
||||
auto type = entt::resolve<double>();
|
||||
bool iterate = false;
|
||||
|
||||
type.conv([&iterate](auto conv) {
|
||||
ASSERT_EQ(conv.type(), entt::resolve<int>());
|
||||
for(auto curr: type.conv()) {
|
||||
ASSERT_EQ(curr.type(), entt::resolve<int>());
|
||||
iterate = true;
|
||||
});
|
||||
}
|
||||
|
||||
ASSERT_TRUE(iterate);
|
||||
|
||||
@@ -229,9 +234,9 @@ TEST_F(MetaType, Ctor) {
|
||||
auto type = entt::resolve<clazz_t>();
|
||||
int counter{};
|
||||
|
||||
type.ctor([&counter](auto) {
|
||||
for([[maybe_unused]] auto curr: type.ctor()) {
|
||||
++counter;
|
||||
});
|
||||
}
|
||||
|
||||
ASSERT_EQ(counter, 2);
|
||||
ASSERT_TRUE((type.ctor<>()));
|
||||
@@ -243,9 +248,9 @@ TEST_F(MetaType, Data) {
|
||||
auto type = entt::resolve<clazz_t>();
|
||||
int counter{};
|
||||
|
||||
type.data([&counter](auto) {
|
||||
for([[maybe_unused]] auto curr: type.data()) {
|
||||
++counter;
|
||||
});
|
||||
}
|
||||
|
||||
ASSERT_EQ(counter, 1);
|
||||
ASSERT_TRUE(type.data("value"_hs));
|
||||
@@ -256,9 +261,9 @@ TEST_F(MetaType, Func) {
|
||||
clazz_t instance{};
|
||||
int counter{};
|
||||
|
||||
type.func([&counter](auto) {
|
||||
for([[maybe_unused]] auto curr: type.func()) {
|
||||
++counter;
|
||||
});
|
||||
}
|
||||
|
||||
ASSERT_EQ(counter, 2);
|
||||
ASSERT_TRUE(type.func("member"_hs));
|
||||
@@ -306,11 +311,12 @@ TEST_F(MetaType, ConstructCastAndConvert) {
|
||||
TEST_F(MetaType, Detach) {
|
||||
ASSERT_TRUE(entt::resolve_id("clazz"_hs));
|
||||
|
||||
entt::resolve([](auto type) {
|
||||
if(type.id() == "clazz"_hs) {
|
||||
type.detach();
|
||||
for(auto curr: entt::resolve()) {
|
||||
if(curr.id() == "clazz"_hs) {
|
||||
curr.detach();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ASSERT_FALSE(entt::resolve_id("clazz"_hs));
|
||||
ASSERT_EQ(entt::resolve<clazz_t>().id(), "clazz"_hs);
|
||||
|
||||
Reference in New Issue
Block a user