type_id -> type info + allow also fully runtime ids
This commit is contained in:
@@ -14,13 +14,13 @@ namespace entt {
|
||||
* @tparam Type Type for which to generate an identifier.
|
||||
*/
|
||||
template<typename Type, typename = void>
|
||||
struct type_id {
|
||||
struct type_info {
|
||||
#if defined _MSC_VER
|
||||
/**
|
||||
* @brief Returns the numeric representation of a given type.
|
||||
* @return The numeric representation of the given type.
|
||||
*/
|
||||
static constexpr ENTT_ID_TYPE value() ENTT_NOEXCEPT {
|
||||
static constexpr ENTT_ID_TYPE id() ENTT_NOEXCEPT {
|
||||
return entt::hashed_string{__FUNCSIG__};
|
||||
}
|
||||
#elif defined __GNUC__
|
||||
@@ -28,21 +28,13 @@ struct type_id {
|
||||
* @brief Returns the numeric representation of a given type.
|
||||
* @return The numeric representation of the given type.
|
||||
*/
|
||||
static constexpr ENTT_ID_TYPE value() ENTT_NOEXCEPT {
|
||||
static constexpr ENTT_ID_TYPE id() ENTT_NOEXCEPT {
|
||||
return entt::hashed_string{__PRETTY_FUNCTION__};
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Helper variable template.
|
||||
* @tparam Type Type for which to generate an identifier.
|
||||
*/
|
||||
template<typename Type>
|
||||
static constexpr auto type_id_v = type_id<Type>::value();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ class basic_registry {
|
||||
{}
|
||||
|
||||
ENTT_ID_TYPE id() const ENTT_NOEXCEPT override {
|
||||
return type_id_v<Type>;
|
||||
return type_info<Type>::id();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -213,15 +213,15 @@ class basic_registry {
|
||||
static_assert(std::is_same_v<Component, std::decay_t<Component>>);
|
||||
static std::size_t index{pools.size()};
|
||||
|
||||
if(!(index < pools.size()) || pools[index].type_id != type_id_v<Component>) {
|
||||
if(!(index < pools.size()) || pools[index].type_id != type_info<Component>::id()) {
|
||||
index = std::find_if(pools.cbegin(), pools.cend(), [](auto &&cpool) {
|
||||
return cpool.type_id == type_id_v<Component>;
|
||||
return cpool.type_id == type_info<Component>::id();
|
||||
}) - pools.cbegin();
|
||||
|
||||
if(index == pools.size()) {
|
||||
auto &&pdata = pools.emplace_back();
|
||||
|
||||
pdata.type_id = type_id_v<Component>;
|
||||
pdata.type_id = type_info<Component>::id();
|
||||
pdata.pool = std::make_unique<pool_type<Component>>(std::forward<Args>(args)...);
|
||||
|
||||
pdata.remove = [](sparse_set<Entity> &cpool, basic_registry &owner, const Entity entt) {
|
||||
@@ -273,7 +273,7 @@ public:
|
||||
*/
|
||||
template<typename Component, typename... Args>
|
||||
void prepare(Args &&... args) {
|
||||
ENTT_ASSERT(std::none_of(pools.cbegin(), pools.cend(), [](auto &&pdata) { return pdata.type_id == type_id_v<Component>; }));
|
||||
ENTT_ASSERT(std::none_of(pools.cbegin(), pools.cend(), [](auto &&pdata) { return pdata.type_id == type_info<Component>::id(); }));
|
||||
assure<Component>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public:
|
||||
template<typename... Component>
|
||||
void discard() {
|
||||
pools.erase(std::remove_if(pools.begin(), pools.end(), [](auto &&pdata) {
|
||||
return ((pdata.type_id == type_id_v<Component>) || ...);
|
||||
return ((pdata.type_id == type_info<Component>::id()) || ...);
|
||||
}), pools.end());
|
||||
}
|
||||
|
||||
@@ -1276,9 +1276,9 @@ public:
|
||||
|
||||
if(auto it = std::find_if(groups.cbegin(), groups.cend(), [&extent](const auto &gdata) {
|
||||
return std::equal(std::begin(extent), std::end(extent), std::begin(gdata.extent))
|
||||
&& (gdata.owned(type_id_v<std::decay_t<Owned>>) && ...)
|
||||
&& (gdata.get(type_id_v<std::decay_t<Get>>) && ...)
|
||||
&& (gdata.exclude(type_id_v<Exclude>) && ...);
|
||||
&& (gdata.owned(type_info<std::decay_t<Owned>>::id()) && ...)
|
||||
&& (gdata.get(type_info<std::decay_t<Get>>::id()) && ...)
|
||||
&& (gdata.exclude(type_info<Exclude>::id()) && ...);
|
||||
}); it != groups.cend())
|
||||
{
|
||||
handler = static_cast<handler_type *>(it->group.get());
|
||||
@@ -1291,9 +1291,9 @@ public:
|
||||
group_data gdata{
|
||||
{ sizeof...(Owned), sizeof...(Get), sizeof...(Exclude) },
|
||||
decltype(group_data::group){new handler_type{cpools}, [](void *gptr) { delete static_cast<handler_type *>(gptr); }},
|
||||
[](const auto ctype) ENTT_NOEXCEPT { return ((ctype == type_id_v<std::decay_t<Owned>>) || ...); },
|
||||
[](const auto ctype) ENTT_NOEXCEPT { return ((ctype == type_id_v<std::decay_t<Get>>) || ...); },
|
||||
[](const auto ctype) ENTT_NOEXCEPT { return ((ctype == type_id_v<Exclude>) || ...); }
|
||||
[](const auto ctype) ENTT_NOEXCEPT { return ((ctype == type_info<std::decay_t<Owned>>::id()) || ...); },
|
||||
[](const auto ctype) ENTT_NOEXCEPT { return ((ctype == type_info<std::decay_t<Get>>::id()) || ...); },
|
||||
[](const auto ctype) ENTT_NOEXCEPT { return ((ctype == type_info<Exclude>::id()) || ...); }
|
||||
};
|
||||
|
||||
if constexpr(sizeof...(Owned) == 0) {
|
||||
@@ -1301,21 +1301,21 @@ public:
|
||||
} else {
|
||||
ENTT_ASSERT(std::all_of(groups.cbegin(), groups.cend(), [&extent](const auto &curr) {
|
||||
const std::size_t diff[3]{
|
||||
(0u + ... + curr.owned(type_id_v<std::decay_t<Owned>>)),
|
||||
(0u + ... + curr.get(type_id_v<std::decay_t<Get>>)),
|
||||
(0u + ... + curr.exclude(type_id_v<Exclude>))
|
||||
(0u + ... + curr.owned(type_info<std::decay_t<Owned>>::id())),
|
||||
(0u + ... + curr.get(type_info<std::decay_t<Get>>::id())),
|
||||
(0u + ... + curr.exclude(type_info<Exclude>::id()))
|
||||
};
|
||||
|
||||
return !diff[0] || ((std::equal(std::begin(diff), std::end(diff), extent) || std::equal(std::begin(diff), std::end(diff), curr.extent)));
|
||||
}));
|
||||
|
||||
const auto next = std::find_if_not(groups.cbegin(), groups.cend(), [&size](const auto &curr) {
|
||||
const std::size_t diff = (0u + ... + curr.owned(type_id_v<std::decay_t<Owned>>));
|
||||
const std::size_t diff = (0u + ... + curr.owned(type_info<std::decay_t<Owned>>::id()));
|
||||
return !diff || (size > (curr.extent[0] + curr.extent[1] + curr.extent[2]));
|
||||
});
|
||||
|
||||
const auto prev = std::find_if(std::make_reverse_iterator(next), groups.crend(), [](const auto &curr) {
|
||||
return (0u + ... + curr.owned(type_id_v<std::decay_t<Owned>>));
|
||||
return (0u + ... + curr.owned(type_info<std::decay_t<Owned>>::id()));
|
||||
});
|
||||
|
||||
maybe_valid_if = (next == groups.cend() ? maybe_valid_if : next->group.get());
|
||||
@@ -1487,7 +1487,7 @@ public:
|
||||
|
||||
if constexpr(sizeof...(Component) == 0) {
|
||||
for(size_type pos{}; pos < pools.size(); ++pos) {
|
||||
if(const auto &pdata = pools[pos]; pdata.assure && ((pdata.type_id != type_id_v<Exclude>) && ...)) {
|
||||
if(const auto &pdata = pools[pos]; pdata.assure && ((pdata.type_id != type_info<Exclude>::id()) && ...)) {
|
||||
pdata.assure(other, *pdata.pool);
|
||||
}
|
||||
}
|
||||
@@ -1540,7 +1540,7 @@ public:
|
||||
void stomp(const entity_type dst, const basic_registry &other, const entity_type src, exclude_t<Exclude...> = {}) {
|
||||
if constexpr(sizeof...(Component) == 0) {
|
||||
for(size_type pos{}; pos < other.pools.size(); ++pos) {
|
||||
if(const auto &pdata = other.pools[pos]; pdata.stomp && ((pdata.type_id != type_id_v<Exclude>) && ...) && pdata.pool->has(src)) {
|
||||
if(const auto &pdata = other.pools[pos]; pdata.stomp && ((pdata.type_id != type_info<Exclude>::id()) && ...) && pdata.pool->has(src)) {
|
||||
pdata.stomp(*this, dst, *pdata.pool, src);
|
||||
}
|
||||
}
|
||||
@@ -1648,7 +1648,7 @@ public:
|
||||
template<typename Type>
|
||||
void unset() {
|
||||
vars.erase(std::remove_if(vars.begin(), vars.end(), [](auto &&handler) {
|
||||
return handler->id() == type_id_v<Type>;
|
||||
return handler->id() == type_info<Type>::id();
|
||||
}), vars.end());
|
||||
}
|
||||
|
||||
@@ -1678,7 +1678,7 @@ public:
|
||||
template<typename Type>
|
||||
const Type * try_ctx() const {
|
||||
auto it = std::find_if(vars.cbegin(), vars.cend(), [](auto &&handler) {
|
||||
return handler->id() == type_id_v<Type>;
|
||||
return handler->id() == type_info<Type>::id();
|
||||
});
|
||||
|
||||
return it == vars.cend() ? nullptr : &static_cast<const variable_handler<Type> &>(*it->get()).value;
|
||||
|
||||
@@ -196,7 +196,7 @@ struct meta_node {
|
||||
|
||||
inline static meta_type_node * resolve() ENTT_NOEXCEPT {
|
||||
static meta_type_node node{
|
||||
type_id_v<Type...>,
|
||||
type_info<Type...>::id(),
|
||||
{},
|
||||
nullptr,
|
||||
nullptr,
|
||||
|
||||
@@ -34,7 +34,7 @@ class dispatcher {
|
||||
virtual ~basic_pool() = default;
|
||||
virtual void publish() = 0;
|
||||
virtual void clear() ENTT_NOEXCEPT = 0;
|
||||
virtual ENTT_ID_TYPE id() const ENTT_NOEXCEPT = 0;
|
||||
virtual ENTT_ID_TYPE type_id() const ENTT_NOEXCEPT = 0;
|
||||
};
|
||||
|
||||
template<typename Event>
|
||||
@@ -70,8 +70,8 @@ class dispatcher {
|
||||
events.emplace_back(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
ENTT_ID_TYPE id() const ENTT_NOEXCEPT override {
|
||||
return type_id_v<Event>;
|
||||
ENTT_ID_TYPE type_id() const ENTT_NOEXCEPT override {
|
||||
return type_info<Event>::id();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -84,9 +84,9 @@ class dispatcher {
|
||||
static_assert(std::is_same_v<Event, std::decay_t<Event>>);
|
||||
static std::size_t index{pools.size()};
|
||||
|
||||
if(!(index < pools.size()) || pools[index]->id() != type_id_v<Event>) {
|
||||
if(!(index < pools.size()) || pools[index]->type_id() != type_info<Event>::id()) {
|
||||
index = std::find_if(pools.cbegin(), pools.cend(), [](auto &&cpool) {
|
||||
return cpool->id() == type_id_v<Event>;
|
||||
return cpool->type_id() == type_info<Event>::id();
|
||||
}) - pools.cbegin();
|
||||
|
||||
if(index == pools.size()) {
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
template<typename... Event>
|
||||
void discard() {
|
||||
pools.erase(std::remove_if(pools.begin(), pools.end(), [](auto &&cpool) {
|
||||
return ((cpool->id() == type_id_v<Event>) || ...);
|
||||
return ((cpool->type_id() == type_info<Event>::id()) || ...);
|
||||
}), pools.end());
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class emitter {
|
||||
virtual ~basic_pool() = default;
|
||||
virtual bool empty() const ENTT_NOEXCEPT = 0;
|
||||
virtual void clear() ENTT_NOEXCEPT = 0;
|
||||
virtual ENTT_ID_TYPE id() const ENTT_NOEXCEPT = 0;
|
||||
virtual ENTT_ID_TYPE type_id() const ENTT_NOEXCEPT = 0;
|
||||
};
|
||||
|
||||
template<typename Event>
|
||||
@@ -108,8 +108,8 @@ class emitter {
|
||||
on_list.remove_if([](auto &&element) { return element.first; });
|
||||
}
|
||||
|
||||
ENTT_ID_TYPE id() const ENTT_NOEXCEPT override {
|
||||
return type_id_v<Event>;
|
||||
ENTT_ID_TYPE type_id() const ENTT_NOEXCEPT override {
|
||||
return type_info<Event>::id();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -123,9 +123,9 @@ class emitter {
|
||||
static_assert(std::is_same_v<Event, std::decay_t<Event>>);
|
||||
static std::size_t index{pools.size()};
|
||||
|
||||
if(!(index < pools.size()) || pools[index]->id() != type_id_v<Event>) {
|
||||
if(!(index < pools.size()) || pools[index]->type_id() != type_info<Event>::id()) {
|
||||
index = std::find_if(pools.cbegin(), pools.cend(), [](auto &&cpool) {
|
||||
return cpool->id() == type_id_v<Event>;
|
||||
return cpool->type_id() == type_info<Event>::id();
|
||||
}) - pools.cbegin();
|
||||
|
||||
if(index == pools.size()) {
|
||||
@@ -193,7 +193,7 @@ public:
|
||||
template<typename... Event>
|
||||
void discard() {
|
||||
pools.erase(std::remove_if(pools.begin(), pools.end(), [](auto &&cpool) {
|
||||
return ((cpool->id() == type_id_v<Event>) || ...);
|
||||
return ((cpool->type_id() == type_info<Event>::id()) || ...);
|
||||
}), pools.end());
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ TEST(Benchmark, IterateSingleComponentRuntime1M) {
|
||||
}
|
||||
|
||||
auto test = [®istry](auto func) {
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<position> };
|
||||
ENTT_ID_TYPE types[] = { entt::type_info<position>::id() };
|
||||
|
||||
timer timer;
|
||||
registry.runtime_view(std::begin(types), std::end(types)).each(func);
|
||||
@@ -333,7 +333,10 @@ TEST(Benchmark, IterateTwoComponentsRuntime1M) {
|
||||
}
|
||||
|
||||
auto test = [®istry](auto func) {
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<position>, entt::type_id_v<velocity> };
|
||||
ENTT_ID_TYPE types[] = {
|
||||
entt::type_info<position>::id(),
|
||||
entt::type_info<velocity>::id()
|
||||
};
|
||||
|
||||
timer timer;
|
||||
registry.runtime_view(std::begin(types), std::end(types)).each(func);
|
||||
@@ -361,7 +364,10 @@ TEST(Benchmark, IterateTwoComponentsRuntime1MHalf) {
|
||||
}
|
||||
|
||||
auto test = [®istry](auto func) {
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<position>, entt::type_id_v<velocity> };
|
||||
ENTT_ID_TYPE types[] = {
|
||||
entt::type_info<position>::id(),
|
||||
entt::type_info<velocity>::id()
|
||||
};
|
||||
|
||||
timer timer;
|
||||
registry.runtime_view(std::begin(types), std::end(types)).each(func);
|
||||
@@ -389,7 +395,10 @@ TEST(Benchmark, IterateTwoComponentsRuntime1MOne) {
|
||||
}
|
||||
|
||||
auto test = [®istry](auto func) {
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<position>, entt::type_id_v<velocity> };
|
||||
ENTT_ID_TYPE types[] = {
|
||||
entt::type_info<position>::id(),
|
||||
entt::type_info<velocity>::id()
|
||||
};
|
||||
|
||||
timer timer;
|
||||
registry.runtime_view(std::begin(types), std::end(types)).each(func);
|
||||
@@ -562,7 +571,11 @@ TEST(Benchmark, IterateThreeComponentsRuntime1M) {
|
||||
}
|
||||
|
||||
auto test = [®istry](auto func) {
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<position>, entt::type_id_v<velocity>, entt::type_id_v<comp<0>> };
|
||||
ENTT_ID_TYPE types[] = {
|
||||
entt::type_info<position>::id(),
|
||||
entt::type_info<velocity>::id(),
|
||||
entt::type_info<comp<0>>::id()
|
||||
};
|
||||
|
||||
timer timer;
|
||||
registry.runtime_view(std::begin(types), std::end(types)).each(func);
|
||||
@@ -592,7 +605,11 @@ TEST(Benchmark, IterateThreeComponentsRuntime1MHalf) {
|
||||
}
|
||||
|
||||
auto test = [®istry](auto func) {
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<position>, entt::type_id_v<velocity>, entt::type_id_v<comp<0>> };
|
||||
ENTT_ID_TYPE types[] = {
|
||||
entt::type_info<position>::id(),
|
||||
entt::type_info<velocity>::id(),
|
||||
entt::type_info<comp<0>>::id()
|
||||
};
|
||||
|
||||
timer timer;
|
||||
registry.runtime_view(std::begin(types), std::end(types)).each(func);
|
||||
@@ -622,7 +639,11 @@ TEST(Benchmark, IterateThreeComponentsRuntime1MOne) {
|
||||
}
|
||||
|
||||
auto test = [®istry](auto func) {
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<position>, entt::type_id_v<velocity>, entt::type_id_v<comp<0>> };
|
||||
ENTT_ID_TYPE types[] = {
|
||||
entt::type_info<position>::id(),
|
||||
entt::type_info<velocity>::id(),
|
||||
entt::type_info<comp<0>>::id()
|
||||
};
|
||||
|
||||
timer timer;
|
||||
registry.runtime_view(std::begin(types), std::end(types)).each(func);
|
||||
@@ -837,11 +858,11 @@ TEST(Benchmark, IterateFiveComponentsRuntime1M) {
|
||||
|
||||
auto test = [®istry](auto func) {
|
||||
ENTT_ID_TYPE types[] = {
|
||||
entt::type_id_v<position>,
|
||||
entt::type_id_v<velocity>,
|
||||
entt::type_id_v<comp<0>>,
|
||||
entt::type_id_v<comp<1>>,
|
||||
entt::type_id_v<comp<2>>
|
||||
entt::type_info<position>::id(),
|
||||
entt::type_info<velocity>::id(),
|
||||
entt::type_info<comp<0>>::id(),
|
||||
entt::type_info<comp<1>>::id(),
|
||||
entt::type_info<comp<2>>::id()
|
||||
};
|
||||
|
||||
timer timer;
|
||||
@@ -877,11 +898,11 @@ TEST(Benchmark, IterateFiveComponentsRuntime1MHalf) {
|
||||
|
||||
auto test = [®istry](auto func) {
|
||||
ENTT_ID_TYPE types[] = {
|
||||
entt::type_id_v<position>,
|
||||
entt::type_id_v<velocity>,
|
||||
entt::type_id_v<comp<0>>,
|
||||
entt::type_id_v<comp<1>>,
|
||||
entt::type_id_v<comp<2>>
|
||||
entt::type_info<position>::id(),
|
||||
entt::type_info<velocity>::id(),
|
||||
entt::type_info<comp<0>>::id(),
|
||||
entt::type_info<comp<1>>::id(),
|
||||
entt::type_info<comp<2>>::id()
|
||||
};
|
||||
|
||||
timer timer;
|
||||
@@ -917,11 +938,11 @@ TEST(Benchmark, IterateFiveComponentsRuntime1MOne) {
|
||||
|
||||
auto test = [®istry](auto func) {
|
||||
ENTT_ID_TYPE types[] = {
|
||||
entt::type_id_v<position>,
|
||||
entt::type_id_v<velocity>,
|
||||
entt::type_id_v<comp<0>>,
|
||||
entt::type_id_v<comp<1>>,
|
||||
entt::type_id_v<comp<2>>
|
||||
entt::type_info<position>::id(),
|
||||
entt::type_info<velocity>::id(),
|
||||
entt::type_info<comp<0>>::id(),
|
||||
entt::type_info<comp<1>>::id(),
|
||||
entt::type_info<comp<2>>::id()
|
||||
};
|
||||
|
||||
timer timer;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <entt/core/type_info.hpp>
|
||||
|
||||
TEST(TypeId, Functionalities) {
|
||||
ASSERT_NE(entt::type_id_v<int>, entt::type_id_v<const int>);
|
||||
ASSERT_NE(entt::type_id_v<int>, entt::type_id_v<char>);
|
||||
ASSERT_EQ(entt::type_id_v<int>, entt::type_id_v<int>);
|
||||
ASSERT_NE(entt::type_info<int>::id(), entt::type_info<const int>::id());
|
||||
ASSERT_NE(entt::type_info<int>::id(), entt::type_info<char>::id());
|
||||
ASSERT_EQ(entt::type_info<int>::id(), entt::type_info<int>::id());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <gtest/gtest.h>
|
||||
#include <entt/core/type_info.hpp>
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/runtime_view.hpp>
|
||||
|
||||
@@ -11,7 +12,7 @@ TEST(RuntimeView, Functionalities) {
|
||||
registry.reserve<int>(0);
|
||||
registry.reserve<char>(0);
|
||||
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<int>, entt::type_id_v<char> };
|
||||
ENTT_ID_TYPE types[] = { entt::type_info<int>::id(), entt::type_info<char>::id() };
|
||||
auto view = registry.runtime_view(std::begin(types), std::end(types));
|
||||
|
||||
ASSERT_TRUE(view.empty());
|
||||
@@ -54,7 +55,7 @@ TEST(RuntimeView, Iterator) {
|
||||
registry.assign<int>(entity);
|
||||
registry.assign<char>(entity);
|
||||
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<int>, entt::type_id_v<char> };
|
||||
ENTT_ID_TYPE types[] = { entt::type_info<int>::id(), entt::type_info<char>::id() };
|
||||
auto view = registry.runtime_view(std::begin(types), std::end(types));
|
||||
using iterator_type = typename decltype(view)::iterator_type;
|
||||
|
||||
@@ -90,7 +91,7 @@ TEST(RuntimeView, Contains) {
|
||||
|
||||
registry.destroy(e0);
|
||||
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<int>, entt::type_id_v<char> };
|
||||
ENTT_ID_TYPE types[] = { entt::type_info<int>::id(), entt::type_info<char>::id() };
|
||||
auto view = registry.runtime_view(std::begin(types), std::end(types));
|
||||
|
||||
ASSERT_FALSE(view.contains(e0));
|
||||
@@ -109,7 +110,7 @@ TEST(RuntimeView, Empty) {
|
||||
registry.assign<char>(e1);
|
||||
registry.assign<float>(e1);
|
||||
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<int>, entt::type_id_v<char>, entt::type_id_v<float> };
|
||||
ENTT_ID_TYPE types[] = { entt::type_info<int>::id(), entt::type_info<char>::id(), entt::type_info<float>::id() };
|
||||
auto view = registry.runtime_view(std::begin(types), std::end(types));
|
||||
|
||||
view.each([](auto) { FAIL(); });
|
||||
@@ -129,7 +130,7 @@ TEST(RuntimeView, Each) {
|
||||
registry.assign<int>(e1);
|
||||
registry.assign<char>(e1);
|
||||
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<int>, entt::type_id_v<char> };
|
||||
ENTT_ID_TYPE types[] = { entt::type_info<int>::id(), entt::type_info<char>::id() };
|
||||
auto view = registry.runtime_view(std::begin(types), std::end(types));
|
||||
std::size_t cnt = 0;
|
||||
|
||||
@@ -151,7 +152,7 @@ TEST(RuntimeView, EachWithHoles) {
|
||||
registry.assign<int>(e0, 0);
|
||||
registry.assign<int>(e2, 2);
|
||||
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<int>, entt::type_id_v<char> };
|
||||
ENTT_ID_TYPE types[] = { entt::type_info<int>::id(), entt::type_info<char>::id() };
|
||||
auto view = registry.runtime_view(std::begin(types), std::end(types));
|
||||
|
||||
view.each([e0](auto entity) {
|
||||
@@ -165,7 +166,7 @@ TEST(RuntimeView, MissingPool) {
|
||||
const auto e0 = registry.create();
|
||||
registry.assign<int>(e0);
|
||||
|
||||
ENTT_ID_TYPE types[] = { entt::type_id_v<int>, entt::type_id_v<char> };
|
||||
ENTT_ID_TYPE types[] = { entt::type_info<int>::id(), entt::type_info<char>::id() };
|
||||
auto view = registry.runtime_view(std::begin(types), std::end(types));
|
||||
|
||||
ASSERT_TRUE(view.empty());
|
||||
|
||||
@@ -134,7 +134,7 @@ class duktape_registry {
|
||||
|
||||
template<typename... Comp>
|
||||
void reg() {
|
||||
((func[entt::type_id_v<Comp>] = {
|
||||
((func[entt::type_info<Comp>::id()] = {
|
||||
&::set<Comp>,
|
||||
&::unset<Comp>,
|
||||
&::has<Comp>,
|
||||
@@ -163,7 +163,7 @@ class duktape_registry {
|
||||
const auto it = func.find(type);
|
||||
|
||||
return (it == func.cend())
|
||||
? (func[entt::type_id_v<duktape_runtime>].*Op)(ctx, registry)
|
||||
? (func[entt::type_info<duktape_runtime>::id()].*Op)(ctx, registry)
|
||||
: (it->second.*Op)(ctx, registry);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
|
||||
if(dreg.func.find(type) == dreg.func.cend()) {
|
||||
if(runtime.empty()) {
|
||||
components.push_back(entt::type_id_v<duktape_runtime>);
|
||||
components.push_back(entt::type_info<duktape_runtime>::id());
|
||||
}
|
||||
|
||||
runtime.push_back(type);
|
||||
@@ -268,7 +268,7 @@ const duk_function_list_entry js_duktape_registry_methods[] = {
|
||||
void export_types(duk_context *context) {
|
||||
auto export_type = [idx = duk_push_object(context)](auto *ctx, auto type, const auto *name) {
|
||||
duk_push_string(ctx, name);
|
||||
duk_push_uint(ctx, entt::type_id_v<typename decltype(type)::type>);
|
||||
duk_push_uint(ctx, entt::type_info<typename decltype(type)::type>::id());
|
||||
duk_def_prop(ctx, idx, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_CLEAR_WRITABLE);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user