meta: use type info objects rather than plain hashes (breaking changes)
This commit is contained in:
@@ -260,7 +260,7 @@ struct meta_func_node {
|
||||
|
||||
struct meta_type_node {
|
||||
using size_type = std::size_t;
|
||||
const id_type type_hash;
|
||||
const type_info info;
|
||||
id_type id;
|
||||
meta_type_node * next;
|
||||
meta_prop_node * prop;
|
||||
@@ -405,7 +405,7 @@ class ENTT_API meta_node {
|
||||
public:
|
||||
[[nodiscard]] static meta_type_node * resolve() ENTT_NOEXCEPT {
|
||||
static meta_type_node node{
|
||||
type_hash<Type>::value(),
|
||||
type_id<Type>(),
|
||||
{},
|
||||
nullptr,
|
||||
nullptr,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "../config/config.h"
|
||||
#include "../core/fwd.hpp"
|
||||
#include "../core/utility.hpp"
|
||||
#include "../core/type_info.hpp"
|
||||
#include "ctx.hpp"
|
||||
#include "internal.hpp"
|
||||
#include "range.hpp"
|
||||
@@ -342,9 +343,9 @@ public:
|
||||
template<typename Type>
|
||||
[[nodiscard]] const Type * try_cast() const {
|
||||
if(node) {
|
||||
if(const auto type_hash = internal::meta_info<Type>::resolve()->type_hash; node->type_hash == type_hash) {
|
||||
if(const auto info = internal::meta_info<Type>::resolve()->info; node->info == info) {
|
||||
return static_cast<const Type *>(storage.data());
|
||||
} else if(const auto *base = internal::find_if<&internal::meta_type_node::base>([type_hash](const auto *curr) { return curr->type()->type_hash == type_hash; }, node); base) {
|
||||
} else if(const auto *base = internal::find_if<&internal::meta_type_node::base>([info](const auto *curr) { return curr->type()->info == info; }, node); base) {
|
||||
return static_cast<const Type *>(base->cast(storage.data()));
|
||||
}
|
||||
}
|
||||
@@ -394,9 +395,9 @@ public:
|
||||
template<typename Type>
|
||||
[[nodiscard]] meta_any convert() const {
|
||||
if(node) {
|
||||
if(const auto type_hash = internal::meta_info<Type>::resolve()->type_hash; node->type_hash == type_hash) {
|
||||
if(const auto info = internal::meta_info<Type>::resolve()->info; node->info == info) {
|
||||
return *this;
|
||||
} else if(const auto * const conv = internal::find_if<&internal::meta_type_node::conv>([type_hash](const auto *curr) { return curr->type()->type_hash == type_hash; }, node); conv) {
|
||||
} else if(const auto * const conv = internal::find_if<&internal::meta_type_node::conv>([info](const auto *curr) { return curr->type()->info == info; }, node); conv) {
|
||||
return conv->conv(storage.data());
|
||||
}
|
||||
}
|
||||
@@ -411,7 +412,7 @@ public:
|
||||
*/
|
||||
template<typename Type>
|
||||
bool convert() {
|
||||
bool valid = (node && node->type_hash == internal::meta_info<Type>::resolve()->type_hash);
|
||||
bool valid = (node && node->info == internal::meta_info<Type>::resolve()->info);
|
||||
|
||||
if(!valid) {
|
||||
if(auto any = std::as_const(*this).convert<Type>(); any) {
|
||||
@@ -487,7 +488,7 @@ public:
|
||||
* @return False if the two objects differ in their content, true otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool operator==(const meta_any &other) const {
|
||||
return (!node && !other.node) || (node && other.node && node->type_hash == other.node->type_hash && node->compare(storage.data(), other.storage.data()));
|
||||
return (!node && !other.node) || (node && other.node && node->info == other.node->info && node->compare(storage.data(), other.storage.data()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1009,9 +1010,9 @@ class meta_type {
|
||||
|
||||
return std::find_if(range.begin(), range.end(), [](const auto &candidate) {
|
||||
return candidate.size == sizeof...(Args) && ([](auto *from, auto *to) {
|
||||
return (from->type_hash == to->type_hash)
|
||||
|| internal::find_if<&node_type::base>([to](const auto *curr) { return curr->type()->type_hash == to->type_hash; }, from)
|
||||
|| internal::find_if<&node_type::conv>([to](const auto *curr) { return curr->type()->type_hash == to->type_hash; }, from);
|
||||
return (from->info == to->info)
|
||||
|| internal::find_if<&node_type::base>([to](const auto *curr) { return curr->type()->info == to->info; }, from)
|
||||
|| internal::find_if<&node_type::conv>([to](const auto *curr) { return curr->type()->info == to->info; }, from);
|
||||
}(internal::meta_info<Args>::resolve(), candidate.arg(Indexes)) && ...);
|
||||
}).operator->();
|
||||
}
|
||||
@@ -1028,11 +1029,11 @@ public:
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Returns the type hash of the underlying type.
|
||||
* @return The type hash of the underlying type.
|
||||
* @brief Returns the type info object of the underlying type.
|
||||
* @return The type info object of the underlying type.
|
||||
*/
|
||||
[[nodiscard]] id_type hash() const ENTT_NOEXCEPT {
|
||||
return node->type_hash;
|
||||
[[nodiscard]] type_info info() const ENTT_NOEXCEPT {
|
||||
return node->info;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1247,8 +1248,8 @@ public:
|
||||
*/
|
||||
template<typename Type>
|
||||
[[nodiscard]] meta_conv conv() const {
|
||||
return internal::find_if<&node_type::conv>([type_hash = internal::meta_info<Type>::resolve()->type_hash](const auto *curr) {
|
||||
return curr->type()->type_hash == type_hash;
|
||||
return internal::find_if<&node_type::conv>([info = internal::meta_info<Type>::resolve()->info](const auto *curr) {
|
||||
return curr->type()->info == info;
|
||||
}, node);
|
||||
}
|
||||
|
||||
@@ -1461,7 +1462,7 @@ public:
|
||||
* otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool operator==(const meta_type &other) const ENTT_NOEXCEPT {
|
||||
return (!node && !other.node) || (node && other.node && node->type_hash == other.node->type_hash);
|
||||
return (!node && !other.node) || (node && other.node && node->info == other.node->info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include "../core/type_info.hpp"
|
||||
#include "ctx.hpp"
|
||||
#include "meta.hpp"
|
||||
#include "range.hpp"
|
||||
@@ -36,20 +37,21 @@ template<typename Type>
|
||||
* @param id Unique identifier.
|
||||
* @return The meta type associated with the given identifier, if any.
|
||||
*/
|
||||
[[nodiscard]] inline meta_type resolve_id(const id_type id) ENTT_NOEXCEPT {
|
||||
[[nodiscard]] inline meta_type resolve(const id_type id) ENTT_NOEXCEPT {
|
||||
internal::meta_range range{*internal::meta_context::global()};
|
||||
return std::find_if(range.begin(), range.end(), [id](const auto &curr) { return curr.id == id; }).operator->();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns the meta type associated with a given type hash, if any.
|
||||
* @param id Unique identifier.
|
||||
* @return The meta type associated with the given type hash, if any.
|
||||
* @brief Returns the meta type associated with a given type info object, if
|
||||
* any.
|
||||
* @param info The type info object of the requested type.
|
||||
* @return The meta type associated with the given type info object, if any.
|
||||
*/
|
||||
[[nodiscard]] inline meta_type resolve_type(const id_type id) ENTT_NOEXCEPT {
|
||||
[[nodiscard]] inline meta_type resolve(const type_info info) ENTT_NOEXCEPT {
|
||||
internal::meta_range range{*internal::meta_context::global()};
|
||||
return std::find_if(range.begin(), range.end(), [id](const auto &curr) { return curr.type_hash == id; }).operator->();
|
||||
return std::find_if(range.begin(), range.end(), [info](const auto &curr) { return curr.info == info; }).operator->();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ TEST_F(MetaBase, Functionalities) {
|
||||
derived_t derived{};
|
||||
|
||||
ASSERT_TRUE(base);
|
||||
ASSERT_EQ(base.parent(), entt::resolve_id("derived"_hs));
|
||||
ASSERT_EQ(base.parent(), entt::resolve("derived"_hs));
|
||||
ASSERT_EQ(base.type(), entt::resolve<base_t>());
|
||||
ASSERT_EQ(base.cast(&derived), static_cast<base_t *>(&derived));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ TEST_F(MetaCtor, Functionalities) {
|
||||
auto ctor = entt::resolve<clazz_t>().ctor<const int &, char>();
|
||||
|
||||
ASSERT_TRUE(ctor);
|
||||
ASSERT_EQ(ctor.parent(), entt::resolve_id("clazz"_hs));
|
||||
ASSERT_EQ(ctor.parent(), entt::resolve("clazz"_hs));
|
||||
ASSERT_EQ(ctor.size(), 2u);
|
||||
ASSERT_EQ(ctor.arg(0u), entt::resolve<int>());
|
||||
ASSERT_EQ(ctor.arg(1u), entt::resolve<char>());
|
||||
@@ -79,7 +79,7 @@ TEST_F(MetaCtor, Func) {
|
||||
auto ctor = entt::resolve<clazz_t>().ctor<int>();
|
||||
|
||||
ASSERT_TRUE(ctor);
|
||||
ASSERT_EQ(ctor.parent(), entt::resolve_id("clazz"_hs));
|
||||
ASSERT_EQ(ctor.parent(), entt::resolve("clazz"_hs));
|
||||
ASSERT_EQ(ctor.size(), 1u);
|
||||
ASSERT_EQ(ctor.arg(0u), entt::resolve<int>());
|
||||
ASSERT_FALSE(ctor.arg(1u));
|
||||
|
||||
@@ -101,7 +101,7 @@ TEST_F(MetaData, Functionalities) {
|
||||
clazz_t instance{};
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("clazz"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("clazz"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.id(), "i"_hs);
|
||||
ASSERT_FALSE(data.is_const());
|
||||
@@ -130,7 +130,7 @@ TEST_F(MetaData, Const) {
|
||||
clazz_t instance{};
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("clazz"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("clazz"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.id(), "j"_hs);
|
||||
ASSERT_TRUE(data.is_const());
|
||||
@@ -158,7 +158,7 @@ TEST_F(MetaData, Static) {
|
||||
auto data = entt::resolve<clazz_t>().data("h"_hs);
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("clazz"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("clazz"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.id(), "h"_hs);
|
||||
ASSERT_FALSE(data.is_const());
|
||||
@@ -186,7 +186,7 @@ TEST_F(MetaData, ConstStatic) {
|
||||
auto data = entt::resolve<clazz_t>().data("k"_hs);
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("clazz"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("clazz"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.id(), "k"_hs);
|
||||
ASSERT_TRUE(data.is_const());
|
||||
@@ -259,7 +259,7 @@ TEST_F(MetaData, SetterGetterAsFreeFunctions) {
|
||||
setter_getter_t instance{};
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("setter_getter"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.id(), "x"_hs);
|
||||
ASSERT_FALSE(data.is_const());
|
||||
@@ -274,7 +274,7 @@ TEST_F(MetaData, SetterGetterAsMemberFunctions) {
|
||||
setter_getter_t instance{};
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("setter_getter"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.id(), "y"_hs);
|
||||
ASSERT_FALSE(data.is_const());
|
||||
@@ -289,7 +289,7 @@ TEST_F(MetaData, SetterGetterWithRefAsMemberFunctions) {
|
||||
setter_getter_t instance{};
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("setter_getter"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.id(), "w"_hs);
|
||||
ASSERT_FALSE(data.is_const());
|
||||
@@ -304,7 +304,7 @@ TEST_F(MetaData, SetterGetterMixed) {
|
||||
setter_getter_t instance{};
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("setter_getter"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.id(), "z"_hs);
|
||||
ASSERT_FALSE(data.is_const());
|
||||
@@ -319,7 +319,7 @@ TEST_F(MetaData, SetterGetterReadOnly) {
|
||||
setter_getter_t instance{};
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("setter_getter"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.id(), "z_ro"_hs);
|
||||
ASSERT_TRUE(data.is_const());
|
||||
@@ -334,7 +334,7 @@ TEST_F(MetaData, SetterGetterReadOnlyDataMember) {
|
||||
setter_getter_t instance{};
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("setter_getter"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.id(), "value"_hs);
|
||||
ASSERT_TRUE(data.is_const());
|
||||
@@ -348,7 +348,7 @@ TEST_F(MetaData, ArrayStatic) {
|
||||
auto data = entt::resolve<array_t>().data("global"_hs);
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("array"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("array"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int[3]>());
|
||||
ASSERT_EQ(data.id(), "global"_hs);
|
||||
ASSERT_FALSE(data.is_const());
|
||||
@@ -363,7 +363,7 @@ TEST_F(MetaData, Array) {
|
||||
array_t instance;
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
ASSERT_EQ(data.parent(), entt::resolve_id("array"_hs));
|
||||
ASSERT_EQ(data.parent(), entt::resolve("array"_hs));
|
||||
ASSERT_EQ(data.type(), entt::resolve<int[5]>());
|
||||
ASSERT_EQ(data.id(), "local"_hs);
|
||||
ASSERT_FALSE(data.is_const());
|
||||
|
||||
@@ -85,7 +85,7 @@ TEST_F(MetaFunc, Functionalities) {
|
||||
func_t instance{};
|
||||
|
||||
ASSERT_TRUE(func);
|
||||
ASSERT_EQ(func.parent(), entt::resolve_id("func"_hs));
|
||||
ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
|
||||
ASSERT_EQ(func.id(), "f2"_hs);
|
||||
ASSERT_EQ(func.size(), 2u);
|
||||
ASSERT_FALSE(func.is_const());
|
||||
@@ -124,7 +124,7 @@ TEST_F(MetaFunc, Const) {
|
||||
func_t instance{};
|
||||
|
||||
ASSERT_TRUE(func);
|
||||
ASSERT_EQ(func.parent(), entt::resolve_id("func"_hs));
|
||||
ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
|
||||
ASSERT_EQ(func.id(), "f1"_hs);
|
||||
ASSERT_EQ(func.size(), 1u);
|
||||
ASSERT_TRUE(func.is_const());
|
||||
@@ -161,7 +161,7 @@ TEST_F(MetaFunc, RetVoid) {
|
||||
func_t instance{};
|
||||
|
||||
ASSERT_TRUE(func);
|
||||
ASSERT_EQ(func.parent(), entt::resolve_id("func"_hs));
|
||||
ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
|
||||
ASSERT_EQ(func.id(), "g"_hs);
|
||||
ASSERT_EQ(func.size(), 1u);
|
||||
ASSERT_FALSE(func.is_const());
|
||||
@@ -196,7 +196,7 @@ TEST_F(MetaFunc, Static) {
|
||||
func_t::value = 2;
|
||||
|
||||
ASSERT_TRUE(func);
|
||||
ASSERT_EQ(func.parent(), entt::resolve_id("func"_hs));
|
||||
ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
|
||||
ASSERT_EQ(func.id(), "h"_hs);
|
||||
ASSERT_EQ(func.size(), 1u);
|
||||
ASSERT_FALSE(func.is_const());
|
||||
@@ -232,7 +232,7 @@ TEST_F(MetaFunc, StaticRetVoid) {
|
||||
auto func = entt::resolve<func_t>().func("k"_hs);
|
||||
|
||||
ASSERT_TRUE(func);
|
||||
ASSERT_EQ(func.parent(), entt::resolve_id("func"_hs));
|
||||
ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
|
||||
ASSERT_EQ(func.id(), "k"_hs);
|
||||
ASSERT_EQ(func.size(), 1u);
|
||||
ASSERT_FALSE(func.is_const());
|
||||
|
||||
@@ -20,9 +20,9 @@ TEST_F(MetaRange, Range) {
|
||||
ASSERT_TRUE(it != range.end());
|
||||
ASSERT_FALSE(it == range.end());
|
||||
|
||||
ASSERT_EQ((*it).hash(), entt::resolve<double>().hash());
|
||||
ASSERT_EQ((*(++it)).hash(), entt::resolve_id("int"_hs).hash());
|
||||
ASSERT_EQ((*it++).hash(), entt::resolve<int>().hash());
|
||||
ASSERT_EQ((*it).info(), entt::resolve<double>().info());
|
||||
ASSERT_EQ((*(++it)).info(), entt::resolve("int"_hs).info());
|
||||
ASSERT_EQ((*it++).info(), entt::resolve<int>().info());
|
||||
|
||||
ASSERT_EQ(it, range.end());
|
||||
}
|
||||
|
||||
@@ -93,8 +93,8 @@ 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_hash<double>::value()));
|
||||
ASSERT_EQ(entt::resolve<double>(), entt::resolve("double"_hs));
|
||||
ASSERT_EQ(entt::resolve<double>(), entt::resolve(entt::type_id<double>()));
|
||||
|
||||
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
|
||||
@@ -118,7 +118,7 @@ TEST_F(MetaType, Functionalities) {
|
||||
ASSERT_TRUE(type);
|
||||
ASSERT_NE(type, entt::meta_type{});
|
||||
ASSERT_EQ(type.id(), "clazz"_hs);
|
||||
ASSERT_EQ(type.hash(), entt::type_hash<clazz_t>::value());
|
||||
ASSERT_EQ(type.info(), entt::type_id<clazz_t>());
|
||||
|
||||
for(auto curr: type.prop()) {
|
||||
ASSERT_EQ(curr.key(), property_t::value);
|
||||
@@ -337,25 +337,25 @@ TEST_F(MetaType, ConstructCastAndConvert) {
|
||||
}
|
||||
|
||||
TEST_F(MetaType, Reset) {
|
||||
ASSERT_TRUE(entt::resolve_id("clazz"_hs));
|
||||
ASSERT_TRUE(entt::resolve("clazz"_hs));
|
||||
|
||||
entt::resolve_id("clazz"_hs).reset();
|
||||
entt::resolve("clazz"_hs).reset();
|
||||
|
||||
ASSERT_FALSE(entt::resolve_id("clazz"_hs));
|
||||
ASSERT_FALSE(entt::resolve("clazz"_hs));
|
||||
ASSERT_NE(entt::resolve<clazz_t>().id(), "clazz"_hs);
|
||||
ASSERT_FALSE(entt::resolve<clazz_t>().prop(property_t::value));
|
||||
ASSERT_FALSE(entt::resolve<clazz_t>().data("value"_hs));
|
||||
|
||||
entt::meta<clazz_t>().type("clazz"_hs);
|
||||
|
||||
ASSERT_TRUE(entt::resolve_id("clazz"_hs));
|
||||
ASSERT_TRUE(entt::resolve("clazz"_hs));
|
||||
}
|
||||
|
||||
TEST_F(MetaType, AbstractClass) {
|
||||
auto type = entt::resolve<abstract_t>();
|
||||
concrete_t instance;
|
||||
|
||||
ASSERT_EQ(type.hash(), entt::type_hash<abstract_t>::value());
|
||||
ASSERT_EQ(type.info(), entt::type_id<abstract_t>());
|
||||
ASSERT_EQ(instance.base_t::value, 'c');
|
||||
ASSERT_EQ(instance.value, 3);
|
||||
|
||||
@@ -399,7 +399,7 @@ TEST_F(MetaType, ArithmeticTypeAndNamedConstants) {
|
||||
|
||||
TEST_F(MetaType, Variables) {
|
||||
auto p_data = entt::resolve<property_t>().data("var"_hs);
|
||||
auto d_data = entt::resolve_id("double"_hs).data("var"_hs);
|
||||
auto d_data = entt::resolve("double"_hs).data("var"_hs);
|
||||
|
||||
property_t prop{property_t::key_only};
|
||||
double d = 3.;
|
||||
@@ -445,10 +445,10 @@ TEST_F(MetaType, ResetAndReRegistrationAfterReset) {
|
||||
entt::resolve<property_t>().reset();
|
||||
entt::resolve<clazz_t>().reset();
|
||||
|
||||
ASSERT_FALSE(entt::resolve_id("double"_hs));
|
||||
ASSERT_FALSE(entt::resolve_id("base"_hs));
|
||||
ASSERT_FALSE(entt::resolve_id("derived"_hs));
|
||||
ASSERT_FALSE(entt::resolve_id("clazz"_hs));
|
||||
ASSERT_FALSE(entt::resolve("double"_hs));
|
||||
ASSERT_FALSE(entt::resolve("base"_hs));
|
||||
ASSERT_FALSE(entt::resolve("derived"_hs));
|
||||
ASSERT_FALSE(entt::resolve("clazz"_hs));
|
||||
|
||||
ASSERT_EQ(*entt::internal::meta_context::global(), nullptr);
|
||||
|
||||
@@ -464,8 +464,8 @@ TEST_F(MetaType, ResetAndReRegistrationAfterReset) {
|
||||
ASSERT_FALSE(any.convert<int>());
|
||||
ASSERT_TRUE(any.convert<float>());
|
||||
|
||||
ASSERT_FALSE(entt::resolve_id("derived"_hs));
|
||||
ASSERT_TRUE(entt::resolve_id("double"_hs));
|
||||
ASSERT_FALSE(entt::resolve("derived"_hs));
|
||||
ASSERT_TRUE(entt::resolve("double"_hs));
|
||||
|
||||
entt::meta<property_t>().data<property_t::random>("rand"_hs).prop(property_t::value, 42).prop(property_t::random, 3);
|
||||
|
||||
|
||||
@@ -10,20 +10,20 @@ ENTT_API void tear_down();
|
||||
ENTT_API entt::meta_any wrap_int(int);
|
||||
|
||||
TEST(Lib, Meta) {
|
||||
ASSERT_FALSE(entt::resolve_id("position"_hs));
|
||||
ASSERT_FALSE(entt::resolve_id("velocity"_hs));
|
||||
ASSERT_FALSE(entt::resolve("position"_hs));
|
||||
ASSERT_FALSE(entt::resolve("velocity"_hs));
|
||||
|
||||
set_up();
|
||||
entt::meta<double>().conv<int>();
|
||||
|
||||
ASSERT_TRUE(entt::resolve_id("position"_hs));
|
||||
ASSERT_TRUE(entt::resolve_id("velocity"_hs));
|
||||
ASSERT_TRUE(entt::resolve("position"_hs));
|
||||
ASSERT_TRUE(entt::resolve("velocity"_hs));
|
||||
|
||||
ASSERT_EQ(entt::resolve<position>(), entt::resolve_id("position"_hs));
|
||||
ASSERT_EQ(entt::resolve<velocity>(), entt::resolve_id("velocity"_hs));
|
||||
ASSERT_EQ(entt::resolve<position>(), entt::resolve("position"_hs));
|
||||
ASSERT_EQ(entt::resolve<velocity>(), entt::resolve("velocity"_hs));
|
||||
|
||||
auto pos = entt::resolve_id("position"_hs).construct(42., 3.);
|
||||
auto vel = entt::resolve_id("velocity"_hs).ctor<>().invoke();
|
||||
auto pos = entt::resolve("position"_hs).construct(42., 3.);
|
||||
auto vel = entt::resolve("velocity"_hs).ctor<>().invoke();
|
||||
|
||||
ASSERT_TRUE(pos && vel);
|
||||
|
||||
@@ -42,6 +42,6 @@ TEST(Lib, Meta) {
|
||||
|
||||
tear_down();
|
||||
|
||||
ASSERT_FALSE(entt::resolve_id("position"_hs));
|
||||
ASSERT_FALSE(entt::resolve_id("velocity"_hs));
|
||||
ASSERT_FALSE(entt::resolve("position"_hs));
|
||||
ASSERT_FALSE(entt::resolve("velocity"_hs));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "types.h"
|
||||
|
||||
TEST(Lib, Meta) {
|
||||
ASSERT_FALSE(entt::resolve_id("position"_hs));
|
||||
ASSERT_FALSE(entt::resolve("position"_hs));
|
||||
|
||||
userdata ud{};
|
||||
|
||||
@@ -20,11 +20,11 @@ TEST(Lib, Meta) {
|
||||
|
||||
entt::meta<double>().conv<int>();
|
||||
|
||||
ASSERT_TRUE(entt::resolve_id("position"_hs));
|
||||
ASSERT_TRUE(entt::resolve_id("velocity"_hs));
|
||||
ASSERT_TRUE(entt::resolve("position"_hs));
|
||||
ASSERT_TRUE(entt::resolve("velocity"_hs));
|
||||
|
||||
auto pos = entt::resolve_id("position"_hs).construct(42., 3.);
|
||||
auto vel = entt::resolve_id("velocity"_hs).ctor<>().invoke();
|
||||
auto pos = entt::resolve("position"_hs).construct(42., 3.);
|
||||
auto vel = entt::resolve("velocity"_hs).ctor<>().invoke();
|
||||
|
||||
ASSERT_TRUE(pos && vel);
|
||||
|
||||
@@ -48,6 +48,6 @@ TEST(Lib, Meta) {
|
||||
|
||||
cr_plugin_close(ctx);
|
||||
|
||||
ASSERT_FALSE(entt::resolve_id("position"_hs));
|
||||
ASSERT_FALSE(entt::resolve_id("velocity"_hs));
|
||||
ASSERT_FALSE(entt::resolve("position"_hs));
|
||||
ASSERT_FALSE(entt::resolve("velocity"_hs));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "types.h"
|
||||
|
||||
TEST(Lib, Meta) {
|
||||
ASSERT_FALSE(entt::resolve_id("position"_hs));
|
||||
ASSERT_FALSE(entt::resolve("position"_hs));
|
||||
|
||||
userdata ud{};
|
||||
|
||||
@@ -20,11 +20,11 @@ TEST(Lib, Meta) {
|
||||
|
||||
entt::meta<double>().conv<int>();
|
||||
|
||||
ASSERT_TRUE(entt::resolve_id("position"_hs));
|
||||
ASSERT_TRUE(entt::resolve_id("velocity"_hs));
|
||||
ASSERT_TRUE(entt::resolve("position"_hs));
|
||||
ASSERT_TRUE(entt::resolve("velocity"_hs));
|
||||
|
||||
auto pos = entt::resolve_id("position"_hs).construct(42., 3.);
|
||||
auto vel = entt::resolve_id("velocity"_hs).ctor<>().invoke();
|
||||
auto pos = entt::resolve("position"_hs).construct(42., 3.);
|
||||
auto vel = entt::resolve("velocity"_hs).ctor<>().invoke();
|
||||
|
||||
ASSERT_TRUE(pos && vel);
|
||||
|
||||
@@ -48,6 +48,6 @@ TEST(Lib, Meta) {
|
||||
|
||||
cr_plugin_close(ctx);
|
||||
|
||||
ASSERT_FALSE(entt::resolve_id("position"_hs));
|
||||
ASSERT_FALSE(entt::resolve_id("velocity"_hs));
|
||||
ASSERT_FALSE(entt::resolve("position"_hs));
|
||||
ASSERT_FALSE(entt::resolve("velocity"_hs));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user