avoid global shadowing to an extent (close #207)

This commit is contained in:
Michele Caini
2019-03-20 08:33:26 +01:00
parent 5ec38b44b0
commit 6ab0b60f12
23 changed files with 410 additions and 405 deletions

View File

@@ -59,13 +59,13 @@ class hashed_string {
struct const_wrapper {
// non-explicit constructor on purpose
constexpr const_wrapper(const char *str) ENTT_NOEXCEPT: str{str} {}
constexpr const_wrapper(const char *curr) ENTT_NOEXCEPT: str{curr} {}
const char *str;
};
// FowlerNollVo hash function v. 1a - the good
inline static constexpr ENTT_ID_TYPE helper(ENTT_ID_TYPE partial, const char *str) ENTT_NOEXCEPT {
return str[0] == 0 ? partial : helper((partial^str[0])*traits_type::prime, str+1);
inline static constexpr ENTT_ID_TYPE helper(ENTT_ID_TYPE partial, const char *curr) ENTT_NOEXCEPT {
return curr[0] == 0 ? partial : helper((partial^curr[0])*traits_type::prime, curr+1);
}
public:
@@ -118,11 +118,11 @@ public:
* @endcode
*
* @tparam N Number of characters of the identifier.
* @param str Human-readable identifer.
* @param curr Human-readable identifer.
*/
template<std::size_t N>
constexpr hashed_string(const char (&str)[N]) ENTT_NOEXCEPT
: hash{helper(traits_type::offset, str)}, str{str}
constexpr hashed_string(const char (&curr)[N]) ENTT_NOEXCEPT
: hash{helper(traits_type::offset, curr)}, str{curr}
{}
/**

View File

@@ -31,10 +31,10 @@ struct basic_actor {
/**
* @brief Constructs an actor by using the given registry.
* @param reg An entity-component system properly initialized.
* @param ref An entity-component system properly initialized.
*/
basic_actor(registry_type &reg)
: reg{&reg}, entt{reg.create()}
basic_actor(registry_type &ref)
: reg{&ref}, entt{ref.create()}
{}
/*! @brief Default destructor. */

View File

@@ -89,9 +89,9 @@ class basic_group<Entity, get_t<Get...>> {
using pool_type = std::conditional_t<std::is_const_v<Component>, const sparse_set<Entity, std::remove_const_t<Component>>, sparse_set<Entity, Component>>;
// we could use pool_type<Get> *..., but vs complains about it and refuses to compile for unknown reasons (likely a bug)
basic_group(sparse_set<Entity> *handler, sparse_set<Entity, std::remove_const_t<Get>> *... pools) ENTT_NOEXCEPT
: handler{handler},
pools{pools...}
basic_group(sparse_set<Entity> *ref, sparse_set<Entity, std::remove_const_t<Get>> *... get) ENTT_NOEXCEPT
: handler{ref},
pools{get...}
{}
public:
@@ -237,13 +237,13 @@ public:
/**
* @brief Finds an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return An iterator to the given entity if it's found, past the end
* iterator otherwise.
*/
iterator_type find(const entity_type entity) const ENTT_NOEXCEPT {
const auto it = handler->find(entity);
return it != end() && *it == entity ? it : end();
iterator_type find(const entity_type entt) const ENTT_NOEXCEPT {
const auto it = handler->find(entt);
return it != end() && *it == entt ? it : end();
}
/**
@@ -257,11 +257,11 @@ public:
/**
* @brief Checks if a group contains an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return True if the group contains the given entity, false otherwise.
*/
bool contains(const entity_type entity) const ENTT_NOEXCEPT {
return find(entity) != end();
bool contains(const entity_type entt) const ENTT_NOEXCEPT {
return find(entt) != end();
}
/**
@@ -278,18 +278,18 @@ public:
* group doesn't contain the given entity.
*
* @tparam Component Types of components to get.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return The components assigned to the entity.
*/
template<typename... Component>
std::conditional_t<sizeof...(Component) == 1, std::tuple_element_t<0, std::tuple<Component &...>>, std::tuple<Component &...>>
get([[maybe_unused]] const entity_type entity) const ENTT_NOEXCEPT {
assert(contains(entity));
get([[maybe_unused]] const entity_type entt) const ENTT_NOEXCEPT {
assert(contains(entt));
if constexpr(sizeof...(Component) == 1) {
return (std::get<pool_type<Component> *>(pools)->get(entity), ...);
return (std::get<pool_type<Component> *>(pools)->get(entt), ...);
} else {
return std::tuple<Component &...>{get<Component>(entity)...};
return std::tuple<Component &...>{get<Component>(entt)...};
}
}
@@ -313,11 +313,11 @@ public:
*/
template<typename Func>
inline void each(Func func) const {
for(const auto entity: *handler) {
for(const auto entt: *handler) {
if constexpr(std::is_invocable_v<Func, std::add_lvalue_reference_t<Get>...>) {
func(std::get<pool_type<Get> *>(pools)->get(entity)...);
func(std::get<pool_type<Get> *>(pools)->get(entt)...);
} else {
func(entity, std::get<pool_type<Get> *>(pools)->get(entity)...);
func(entt, std::get<pool_type<Get> *>(pools)->get(entt)...);
}
};
}
@@ -405,9 +405,9 @@ class basic_group<Entity, get_t<Get...>, Owned...> {
using component_iterator_type = decltype(std::declval<pool_type<Component>>().begin());
// we could use pool_type<Type> *..., but vs complains about it and refuses to compile for unknown reasons (likely a bug)
basic_group(const typename basic_registry<Entity>::size_type *length, sparse_set<Entity, std::remove_const_t<Owned>> *... owned, sparse_set<Entity, std::remove_const_t<Get>> *... others) ENTT_NOEXCEPT
: length{length},
pools{owned..., others...}
basic_group(const typename basic_registry<Entity>::size_type *sz, sparse_set<Entity, std::remove_const_t<Owned>> *... owned, sparse_set<Entity, std::remove_const_t<Get>> *... get) ENTT_NOEXCEPT
: length{sz},
pools{owned..., get...}
{}
public:
@@ -559,13 +559,13 @@ public:
/**
* @brief Finds an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return An iterator to the given entity if it's found, past the end
* iterator otherwise.
*/
iterator_type find(const entity_type entity) const ENTT_NOEXCEPT {
const auto it = std::get<0>(pools)->find(entity);
return it != end() && it >= begin() && *it == entity ? it : end();
iterator_type find(const entity_type entt) const ENTT_NOEXCEPT {
const auto it = std::get<0>(pools)->find(entt);
return it != end() && it >= begin() && *it == entt ? it : end();
}
/**
@@ -579,11 +579,11 @@ public:
/**
* @brief Checks if a group contains an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return True if the group contains the given entity, false otherwise.
*/
bool contains(const entity_type entity) const ENTT_NOEXCEPT {
return find(entity) != end();
bool contains(const entity_type entt) const ENTT_NOEXCEPT {
return find(entt) != end();
}
/**
@@ -600,18 +600,18 @@ public:
* group doesn't contain the given entity.
*
* @tparam Component Types of components to get.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return The components assigned to the entity.
*/
template<typename... Component>
std::conditional_t<sizeof...(Component) == 1, std::tuple_element_t<0, std::tuple<Component &...>>, std::tuple<Component &...>>
get([[maybe_unused]] const entity_type entity) const ENTT_NOEXCEPT {
assert(contains(entity));
get([[maybe_unused]] const entity_type entt) const ENTT_NOEXCEPT {
assert(contains(entt));
if constexpr(sizeof...(Component) == 1) {
return (std::get<pool_type<Component> *>(pools)->get(entity), ...);
return (std::get<pool_type<Component> *>(pools)->get(entt), ...);
} else {
return std::tuple<Component &...>{get<Component>(entity)...};
return std::tuple<Component &...>{get<Component>(entt)...};
}
}
@@ -643,12 +643,12 @@ public:
if constexpr(sizeof...(Get) == 0) {
func(*(std::get<component_iterator_type<Owned>>(raw)++)...);
} else {
const auto entity = *(data++);
func(*(std::get<component_iterator_type<Owned>>(raw)++)..., std::get<pool_type<Get> *>(pools)->get(entity)...);
const auto entt = *(data++);
func(*(std::get<component_iterator_type<Owned>>(raw)++)..., std::get<pool_type<Get> *>(pools)->get(entt)...);
}
} else {
const auto entity = *(data++);
func(entity, *(std::get<component_iterator_type<Owned>>(raw)++)..., std::get<pool_type<Get> *>(pools)->get(entity)...);
const auto entt = *(data++);
func(entt, *(std::get<component_iterator_type<Owned>>(raw)++)..., std::get<pool_type<Get> *>(pools)->get(entt)...);
}
}
}

View File

@@ -24,9 +24,9 @@ struct as_view {
/**
* @brief Constructs a converter for a given registry.
* @param reg A valid reference to a registry.
* @param source A valid reference to a registry.
*/
as_view(registry_type &reg) ENTT_NOEXCEPT: reg{reg} {}
as_view(registry_type &source) ENTT_NOEXCEPT: reg{source} {}
/**
* @brief Conversion function from a registry to a view.
@@ -72,9 +72,9 @@ struct as_group {
/**
* @brief Constructs a converter for a given registry.
* @param reg A valid reference to a registry.
* @param source A valid reference to a registry.
*/
as_group(registry_type &reg) ENTT_NOEXCEPT: reg{reg} {}
as_group(registry_type &source) ENTT_NOEXCEPT: reg{source} {}
/**
* @brief Conversion function from a registry to a group.
@@ -124,12 +124,12 @@ as_group(const basic_registry<Entity> &) ENTT_NOEXCEPT -> as_group<true, Entity>
*
* @tparam Entity A valid entity type (see entt_traits for more details).
* @tparam Component Types of components to assign to an entity if triggered.
* @param registry A valid reference to a registry.
* @param entity A valid entity identifier.
* @param reg A valid reference to a registry.
* @param entt A valid entity identifier.
*/
template<typename Entity, typename... Component>
void dependency(basic_registry<Entity> &registry, const Entity entity) {
((registry.template has<Component>(entity) ? void() : (registry.template assign<Component>(entity), void())), ...);
void dependency(basic_registry<Entity> &reg, const Entity entt) {
((reg.template has<Component>(entt) ? void() : (reg.template assign<Component>(entt), void())), ...);
}

View File

@@ -66,11 +66,11 @@ public:
/**
* @brief Constructs a prototype that is bound to a given registry.
* @param reg A valid reference to a registry.
* @param ref A valid reference to a registry.
*/
basic_prototype(registry_type &reg)
: reg{&reg},
entity{reg.create()}
basic_prototype(registry_type &ref)
: reg{&ref},
entity{ref.create()}
{}
/**
@@ -127,19 +127,21 @@ public:
*/
template<typename Component, typename... Args>
Component & set(Args &&... args) {
basic_fn_type *assign_or_replace = [](const basic_prototype &prototype, registry_type &other, const Entity dst) {
const auto &wrapper = prototype.reg->template get<component_wrapper<Component>>(prototype.entity);
component_handler handler;
handler.assign_or_replace = [](const basic_prototype &proto, registry_type &other, const Entity dst) {
const auto &wrapper = proto.reg->template get<component_wrapper<Component>>(proto.entity);
other.template assign_or_replace<Component>(dst, wrapper.component);
};
basic_fn_type *assign = [](const basic_prototype &prototype, registry_type &other, const Entity dst) {
handler.assign = [](const basic_prototype &proto, registry_type &other, const Entity dst) {
if(!other.template has<Component>(dst)) {
const auto &wrapper = prototype.reg->template get<component_wrapper<Component>>(prototype.entity);
const auto &wrapper = proto.reg->template get<component_wrapper<Component>>(proto.entity);
other.template assign<Component>(dst, wrapper.component);
}
};
handlers[reg->template type<Component>()] = component_handler{assign_or_replace, assign};
handlers[reg->template type<Component>()] = handler;
auto &wrapper = reg->template assign_or_replace<component_wrapper<Component>>(entity, Component{std::forward<Args>(args)...});
return wrapper.component;
}
@@ -239,9 +241,9 @@ public:
* @return A valid entity identifier.
*/
entity_type create(registry_type &other) const {
const auto entity = other.create();
assign(other, entity);
return entity;
const auto entt = other.create();
assign(other, entt);
return entt;
}
/**

View File

@@ -65,9 +65,9 @@ class basic_registry {
template<typename Component>
struct pool_wrapper: sparse_set<Entity, Component> {
template<typename... Args>
Component & construct(Entity entity, Args &&... args) {
auto &component = sparse_set<Entity, Component>::construct(entity, std::forward<Args>(args)...);
construction.publish(*owner, entity);
Component & construct(Entity entt, Args &&... args) {
auto &component = sparse_set<Entity, Component>::construct(entt, std::forward<Args>(args)...);
construction.publish(*owner, entt);
return component;
}
@@ -76,17 +76,17 @@ class basic_registry {
auto *component = sparse_set<Entity, Component>::batch(first, last, hint);
if(!construction.empty()) {
std::for_each(first, last, [this](const auto entity) {
construction.publish(*owner, entity);
std::for_each(first, last, [this](const auto entt) {
construction.publish(*owner, entt);
});
}
return component;
}
void destroy(Entity entity) override {
destruction.publish(*owner, entity);
sparse_set<Entity, Component>::destroy(entity);
void destroy(Entity entt) override {
destruction.publish(*owner, entt);
sparse_set<Entity, Component>::destroy(entt);
}
signal_type construction;
@@ -103,15 +103,15 @@ class basic_registry {
template<typename... Get, typename... Exclude>
struct non_owning_group<type_list<Exclude...>, type_list<Get...>>: sparse_set<Entity> {
template<auto Accepted>
void construct_if(basic_registry &reg, const Entity entity) {
if(reg.has<Get...>(entity) && (0 + ... + reg.has<Exclude>(entity)) == Accepted) {
this->construct(entity);
void construct_if(basic_registry &reg, const Entity entt) {
if(reg.has<Get...>(entt) && (0 + ... + reg.has<Exclude>(entt)) == Accepted) {
this->construct(entt);
}
}
void destroy_if(basic_registry &, const Entity entity) {
if(this->has(entity)) {
this->destroy(entity);
void destroy_if(basic_registry &, const Entity entt) {
if(this->has(entt)) {
this->destroy(entt);
}
}
};
@@ -126,22 +126,22 @@ class basic_registry {
template<typename... Owned, typename... Get, typename... Exclude>
struct owning_group<type_list<Exclude...>, type_list<Get...>, Owned...>: boxed_owned {
template<auto Accepted>
void induce_if(basic_registry &reg, const Entity entity) {
if(reg.has<Owned..., Get...>(entity) && (0 + ... + reg.has<Exclude>(entity)) == Accepted) {
void induce_if(basic_registry &reg, const Entity entt) {
if(reg.has<Owned..., Get...>(entt) && (0 + ... + reg.has<Exclude>(entt)) == Accepted) {
const auto curr = this->owned++;
const auto cpools = std::make_tuple(reg.pool<Owned>()...);
(std::swap(std::get<pool_type<Owned> *>(cpools)->get(entity), std::get<pool_type<Owned> *>(cpools)->raw()[curr]), ...);
(std::get<pool_type<Owned> *>(cpools)->swap(std::get<pool_type<Owned> *>(cpools)->sparse_set<Entity>::get(entity), curr), ...);
(std::swap(std::get<pool_type<Owned> *>(cpools)->get(entt), std::get<pool_type<Owned> *>(cpools)->raw()[curr]), ...);
(std::get<pool_type<Owned> *>(cpools)->swap(std::get<pool_type<Owned> *>(cpools)->sparse_set<Entity>::get(entt), curr), ...);
}
}
void discard_if(basic_registry &reg, const Entity entity) {
void discard_if(basic_registry &reg, const Entity entt) {
const auto cpools = std::make_tuple(reg.pool<Owned>()...);
if(std::get<0>(cpools)->has(entity) && std::get<0>(cpools)->sparse_set<Entity>::get(entity) < this->owned) {
if(std::get<0>(cpools)->has(entt) && std::get<0>(cpools)->sparse_set<Entity>::get(entt) < this->owned) {
const auto curr = --this->owned;
(std::swap(std::get<pool_type<Owned> *>(cpools)->get(entity), std::get<pool_type<Owned> *>(cpools)->raw()[curr]), ...);
(std::get<pool_type<Owned> *>(cpools)->swap(std::get<pool_type<Owned> *>(cpools)->sparse_set<Entity>::get(entity), curr), ...);
(std::swap(std::get<pool_type<Owned> *>(cpools)->get(entt), std::get<pool_type<Owned> *>(cpools)->raw()[curr]), ...);
(std::get<pool_type<Owned> *>(cpools)->swap(std::get<pool_type<Owned> *>(cpools)->sparse_set<Entity>::get(entt), curr), ...);
}
}
};
@@ -183,8 +183,8 @@ class basic_registry {
const auto ctype = type<Component>();
if constexpr(is_named_type_v<Component>) {
const auto it = std::find_if(pools.begin(), pools.end(), [ctype](const auto &pdata) {
return pdata.pool && pdata.runtime_type == ctype;
const auto it = std::find_if(pools.begin(), pools.end(), [ctype](const auto &candidate) {
return candidate.pool && candidate.runtime_type == ctype;
});
return (it != pools.cend() && it->pool)
@@ -208,8 +208,8 @@ class basic_registry {
pool_data *pdata = nullptr;
if constexpr(is_named_type_v<Component>) {
const auto it = std::find_if(pools.begin(), pools.end(), [ctype](const auto &pdata) {
return pdata.pool && pdata.runtime_type == ctype;
const auto it = std::find_if(pools.begin(), pools.end(), [ctype](const auto &candidate) {
return candidate.pool && candidate.runtime_type == ctype;
});
pdata = (it == pools.cend() ? &pools.emplace_back() : &(*it));
@@ -1499,10 +1499,10 @@ public:
const entity_type seed = available ? (next | (entities[next] & (traits_type::version_mask << traits_type::entity_shift))) : next;
follow_fn_type *follow = [](const basic_registry &reg, const entity_type entity) -> entity_type {
const auto &entities = reg.entities;
const auto &others = reg.entities;
const auto entt = entity & traits_type::entity_mask;
const auto next = entities[entt] & traits_type::entity_mask;
return (next | (entities[next] & (traits_type::version_mask << traits_type::entity_shift)));
const auto curr = others[entt] & traits_type::entity_mask;
return (curr | (others[curr] & (traits_type::version_mask << traits_type::entity_shift)));
};
return { *this, seed, follow };
@@ -1524,30 +1524,30 @@ public:
* @return A temporary object to use to load snasphosts.
*/
basic_snapshot_loader<Entity> loader() ENTT_NOEXCEPT {
using assure_fn_type = void(basic_registry &, const entity_type, const bool);
using force_fn_type = void(basic_registry &, const entity_type, const bool);
assure_fn_type *assure = [](basic_registry &registry, const entity_type entity, const bool destroyed) {
force_fn_type *force = [](basic_registry &reg, const entity_type entity, const bool destroyed) {
using promotion_type = std::conditional_t<sizeof(size_type) >= sizeof(entity_type), size_type, entity_type>;
// explicit promotion to avoid warnings with std::uint16_t
const auto entt = promotion_type{entity} & traits_type::entity_mask;
auto &entities = registry.entities;
auto &others = reg.entities;
if(!(entt < entities.size())) {
auto curr = entities.size();
entities.resize(entt + 1);
std::iota(entities.data() + curr, entities.data() + entt, entity_type(curr));
if(!(entt < others.size())) {
auto curr = others.size();
others.resize(entt + 1);
std::iota(others.data() + curr, others.data() + entt, entity_type(curr));
}
entities[entt] = entity;
others[entt] = entity;
if(destroyed) {
registry.destroy(entity);
reg.destroy(entity);
const auto version = entity & (traits_type::version_mask << traits_type::entity_shift);
entities[entt] = ((entities[entt] & traits_type::entity_mask) | version);
others[entt] = ((others[entt] & traits_type::entity_mask) | version);
}
};
return { (*this = {}), assure };
return { (*this = {}), force };
}
private:

View File

@@ -35,10 +35,10 @@ class basic_snapshot {
using follow_fn_type = Entity(const basic_registry<Entity> &, const Entity);
basic_snapshot(const basic_registry<Entity> &reg, Entity seed, follow_fn_type *follow) ENTT_NOEXCEPT
: reg{reg},
seed{seed},
follow{follow}
basic_snapshot(const basic_registry<Entity> &source, Entity init, follow_fn_type *fn) ENTT_NOEXCEPT
: reg{source},
seed{init},
follow{fn}
{}
template<typename Component, typename Archive, typename It>
@@ -46,10 +46,10 @@ class basic_snapshot {
archive(static_cast<Entity>(sz));
while(first != last) {
const auto entity = *(first++);
const auto entt = *(first++);
if(reg.template has<Component>(entity)) {
archive(entity, reg.template get<Component>(entity));
if(reg.template has<Component>(entt)) {
archive(entt, reg.template get<Component>(entt));
}
}
}
@@ -60,8 +60,8 @@ class basic_snapshot {
auto begin = first;
while(begin != last) {
const auto entity = *(begin++);
((reg.template has<Component>(entity) ? ++size[Indexes] : size[Indexes]), ...);
const auto entt = *(begin++);
((reg.template has<Component>(entt) ? ++size[Indexes] : size[Indexes]), ...);
}
(get<Component>(archive, size[Indexes], first, last), ...);
@@ -87,7 +87,7 @@ public:
template<typename Archive>
const basic_snapshot & entities(Archive &archive) const {
archive(static_cast<Entity>(reg.alive()));
reg.each([&archive](const auto entity) { archive(entity); });
reg.each([&archive](const auto entt) { archive(entt); });
return *this;
}
@@ -139,8 +139,8 @@ public:
archive(static_cast<Entity>(sz));
for(std::remove_const_t<decltype(sz)> i{}; i < sz; ++i) {
const auto entity = entities[i];
archive(entity, reg.template get<Component...>(entity));
const auto entt = entities[i];
archive(entt, reg.template get<Component...>(entt));
};
} else {
(component<Component>(archive), ...);
@@ -193,9 +193,9 @@ class basic_snapshot_loader {
using force_fn_type = void(basic_registry<Entity> &, const Entity, const bool);
basic_snapshot_loader(basic_registry<Entity> &reg, force_fn_type *force) ENTT_NOEXCEPT
: reg{reg},
force{force}
basic_snapshot_loader(basic_registry<Entity> &source, force_fn_type *fn) ENTT_NOEXCEPT
: reg{source},
force{fn}
{
// to restore a snapshot as a whole requires a clean registry
assert(!reg.capacity());
@@ -207,9 +207,9 @@ class basic_snapshot_loader {
archive(length);
while(length--) {
Entity entity{};
archive(entity);
force(reg, entity, destroyed);
Entity entt{};
archive(entt);
force(reg, entt, destroyed);
}
}
@@ -219,12 +219,12 @@ class basic_snapshot_loader {
archive(length);
while(length--) {
Entity entity{};
Entity entt{};
Type instance{};
archive(entity, instance);
archive(entt, instance);
static constexpr auto destroyed = false;
force(reg, entity, destroyed);
reg.template assign<Type>(args..., entity, std::as_const(instance));
force(reg, entt, destroyed);
reg.template assign<Type>(args..., entt, std::as_const(instance));
}
}
@@ -299,8 +299,8 @@ public:
* @return A valid loader to continue restoring data.
*/
const basic_snapshot_loader & orphans() const {
reg.orphans([this](const auto entity) {
reg.destroy(entity);
reg.orphans([this](const auto entt) {
reg.destroy(entt);
});
return *this;
@@ -332,30 +332,30 @@ template<typename Entity>
class basic_continuous_loader {
using traits_type = entt_traits<Entity>;
void destroy(Entity entity) {
const auto it = remloc.find(entity);
void destroy(Entity entt) {
const auto it = remloc.find(entt);
if(it == remloc.cend()) {
const auto local = reg.create();
remloc.emplace(entity, std::make_pair(local, true));
remloc.emplace(entt, std::make_pair(local, true));
reg.destroy(local);
}
}
void restore(Entity entity) {
const auto it = remloc.find(entity);
void restore(Entity entt) {
const auto it = remloc.find(entt);
if(it == remloc.cend()) {
const auto local = reg.create();
remloc.emplace(entity, std::make_pair(local, true));
remloc.emplace(entt, std::make_pair(local, true));
} else {
remloc[entity].first =
reg.valid(remloc[entity].first)
? remloc[entity].first
remloc[entt].first =
reg.valid(remloc[entt].first)
? remloc[entt].first
: reg.create();
// set the dirty flag
remloc[entity].second = true;
remloc[entt].second = true;
}
}
@@ -367,8 +367,8 @@ class basic_continuous_loader {
instance.*member = map(instance.*member);
} else {
// maybe a container? let's try...
for(auto &entity: instance.*member) {
entity = map(entity);
for(auto &entt: instance.*member) {
entt = map(entt);
}
}
}
@@ -379,9 +379,9 @@ class basic_continuous_loader {
archive(length);
while(length--) {
Entity entity{};
archive(entity);
(this->*member)(entity);
Entity entt{};
archive(entt);
(this->*member)(entt);
}
}
@@ -402,12 +402,12 @@ class basic_continuous_loader {
archive(length);
while(length--) {
Entity entity{};
Entity entt{};
Other instance{};
archive(entity, instance);
restore(entity);
archive(entt, instance);
restore(entt);
(update(instance, member), ...);
func(map(entity), instance);
func(map(entt), instance);
}
}
@@ -417,10 +417,10 @@ public:
/**
* @brief Constructs a loader that is bound to a given registry.
* @param reg A valid reference to a registry.
* @param source A valid reference to a registry.
*/
basic_continuous_loader(basic_registry<entity_type> &reg) ENTT_NOEXCEPT
: reg{reg}
basic_continuous_loader(basic_registry<entity_type> &source) ENTT_NOEXCEPT
: reg{source}
{}
/*! @brief Default move constructor. */
@@ -482,8 +482,8 @@ public:
*/
template<typename... Component, typename Archive, typename... Type, typename... Member>
basic_continuous_loader & component(Archive &archive, Member Type:: *... member) {
auto apply = [this](const auto entity, const auto &component) {
reg.template assign_or_replace<std::decay_t<decltype(component)>>(entity, component);
auto apply = [this](const auto entt, const auto &component) {
reg.template assign_or_replace<std::decay_t<decltype(component)>>(entt, component);
};
(reset<Component>(), ...);
@@ -532,8 +532,8 @@ public:
* @return A non-const reference to this loader.
*/
basic_continuous_loader & orphans() {
reg.orphans([this](const auto entity) {
reg.destroy(entity);
reg.orphans([this](const auto entt) {
reg.destroy(entt);
});
return *this;
@@ -541,20 +541,20 @@ public:
/**
* @brief Tests if a loader knows about a given entity.
* @param entity An entity identifier.
* @param entt An entity identifier.
* @return True if `entity` is managed by the loader, false otherwise.
*/
bool has(entity_type entity) const ENTT_NOEXCEPT {
return (remloc.find(entity) != remloc.cend());
bool has(entity_type entt) const ENTT_NOEXCEPT {
return (remloc.find(entt) != remloc.cend());
}
/**
* @brief Returns the identifier to which an entity refers.
* @param entity An entity identifier.
* @param entt An entity identifier.
* @return The local identifier if any, the null entity otherwise.
*/
entity_type map(entity_type entity) const ENTT_NOEXCEPT {
const auto it = remloc.find(entity);
entity_type map(entity_type entt) const ENTT_NOEXCEPT {
const auto it = remloc.find(entt);
entity_type other = null;
if(it != remloc.cend()) {

View File

@@ -67,8 +67,8 @@ class sparse_set<Entity> {
using direct_type = const std::vector<Entity>;
using index_type = typename traits_type::difference_type;
iterator(direct_type *direct, index_type index) ENTT_NOEXCEPT
: direct{direct}, index{index}
iterator(direct_type *ref, index_type idx) ENTT_NOEXCEPT
: direct{ref}, index{idx}
{}
public:
@@ -285,21 +285,21 @@ public:
/**
* @brief Finds an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return An iterator to the given entity if it's found, past the end
* iterator otherwise.
*/
iterator_type find(const entity_type entity) const ENTT_NOEXCEPT {
return has(entity) ? --(end() - get(entity)) : end();
iterator_type find(const entity_type entt) const ENTT_NOEXCEPT {
return has(entt) ? --(end() - get(entt)) : end();
}
/**
* @brief Checks if a sparse set contains an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return True if the sparse set contains the entity, false otherwise.
*/
bool has(const entity_type entity) const ENTT_NOEXCEPT {
const auto pos = size_type(entity & traits_type::entity_mask);
bool has(const entity_type entt) const ENTT_NOEXCEPT {
const auto pos = size_type(entt & traits_type::entity_mask);
// testing against null permits to avoid accessing the direct vector
return (pos < reverse.size()) && (reverse[pos] != null);
}
@@ -318,11 +318,11 @@ public:
* An assertion will abort the execution at runtime in debug mode in case of
* bounds violation.
*
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return True if the sparse set contains the entity, false otherwise.
*/
bool fast(const entity_type entity) const ENTT_NOEXCEPT {
const auto pos = size_type(entity & traits_type::entity_mask);
bool fast(const entity_type entt) const ENTT_NOEXCEPT {
const auto pos = size_type(entt & traits_type::entity_mask);
assert(pos < reverse.size());
// testing against null permits to avoid accessing the direct vector
return (reverse[pos] != null);
@@ -337,12 +337,12 @@ public:
* An assertion will abort the execution at runtime in debug mode if the
* sparse set doesn't contain the given entity.
*
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return The position of the entity in the sparse set.
*/
size_type get(const entity_type entity) const ENTT_NOEXCEPT {
assert(has(entity));
const auto pos = size_type(entity & traits_type::entity_mask);
size_type get(const entity_type entt) const ENTT_NOEXCEPT {
assert(has(entt));
const auto pos = size_type(entt & traits_type::entity_mask);
return size_type(reverse[pos]);
}
@@ -355,11 +355,11 @@ public:
* An assertion will abort the execution at runtime in debug mode if the
* sparse set already contains the given entity.
*
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
*/
void construct(const entity_type entity) {
assert(!has(entity));
const auto pos = size_type(entity & traits_type::entity_mask);
void construct(const entity_type entt) {
assert(!has(entt));
const auto pos = size_type(entt & traits_type::entity_mask);
if(!(pos < reverse.size())) {
// null is safe in all cases for our purposes
@@ -367,7 +367,7 @@ public:
}
reverse[pos] = entity_type(direct.size());
direct.push_back(entity);
direct.push_back(entt);
}
/**
@@ -395,9 +395,9 @@ public:
reverse.resize(hint, null);
}
std::for_each(first, last, [next = entity_type(direct.size()), this](const auto entity) mutable {
assert(!has(entity));
const auto pos = size_type(entity & traits_type::entity_mask);
std::for_each(first, last, [next = entity_type(direct.size()), this](const auto entt) mutable {
assert(!has(entt));
const auto pos = size_type(entt & traits_type::entity_mask);
assert(pos < reverse.size());
reverse[pos] = next++;
});
@@ -414,12 +414,12 @@ public:
* An assertion will abort the execution at runtime in debug mode if the
* sparse set doesn't contain the given entity.
*
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
*/
virtual void destroy(const entity_type entity) {
assert(has(entity));
virtual void destroy(const entity_type entt) {
assert(has(entt));
const auto back = direct.back();
auto &candidate = reverse[size_type(entity & traits_type::entity_mask)];
auto &candidate = reverse[size_type(entt & traits_type::entity_mask)];
// swapping isn't required here, we are getting rid of the last element
reverse[back & traits_type::entity_mask] = candidate;
direct[size_type(candidate)] = back;
@@ -549,8 +549,8 @@ class sparse_set<Entity, Type>: public sparse_set<Entity> {
using instance_type = std::conditional_t<Const, const std::vector<Type>, std::vector<Type>>;
using index_type = typename traits_type::difference_type;
iterator(instance_type *instances, index_type index) ENTT_NOEXCEPT
: instances{instances}, index{index}
iterator(instance_type *ref, index_type idx) ENTT_NOEXCEPT
: instances{ref}, index{idx}
{}
public:
@@ -651,8 +651,8 @@ class sparse_set<Entity, Type>: public sparse_set<Entity> {
using instance_type = std::conditional_t<Const, const Type, Type>;
using index_type = typename traits_type::difference_type;
iterator(instance_type *instance, index_type index) ENTT_NOEXCEPT
: instance{instance}, index{index}
iterator(instance_type *ref, index_type idx) ENTT_NOEXCEPT
: instance{ref}, index{idx}
{}
public:
@@ -870,39 +870,39 @@ public:
* An assertion will abort the execution at runtime in debug mode if the
* sparse set doesn't contain the given entity.
*
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return The object associated with the entity.
*/
const object_type & get([[maybe_unused]] const entity_type entity) const ENTT_NOEXCEPT {
const object_type & get([[maybe_unused]] const entity_type entt) const ENTT_NOEXCEPT {
if constexpr(std::is_empty_v<object_type>) {
assert(underlying_type::has(entity));
assert(underlying_type::has(entt));
return instances;
} else {
return instances[underlying_type::get(entity)];
return instances[underlying_type::get(entt)];
}
}
/*! @copydoc get */
inline object_type & get(const entity_type entity) ENTT_NOEXCEPT {
return const_cast<object_type &>(std::as_const(*this).get(entity));
inline object_type & get(const entity_type entt) ENTT_NOEXCEPT {
return const_cast<object_type &>(std::as_const(*this).get(entt));
}
/**
* @brief Returns a pointer to the object associated with an entity, if any.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return The object associated with the entity, if any.
*/
const object_type * try_get(const entity_type entity) const ENTT_NOEXCEPT {
const object_type * try_get(const entity_type entt) const ENTT_NOEXCEPT {
if constexpr(std::is_empty_v<object_type>) {
return underlying_type::has(entity) ? &instances : nullptr;
return underlying_type::has(entt) ? &instances : nullptr;
} else {
return underlying_type::has(entity) ? (instances.data() + underlying_type::get(entity)) : nullptr;
return underlying_type::has(entt) ? (instances.data() + underlying_type::get(entt)) : nullptr;
}
}
/*! @copydoc try_get */
inline object_type * try_get(const entity_type entity) ENTT_NOEXCEPT {
return const_cast<object_type *>(std::as_const(*this).try_get(entity));
inline object_type * try_get(const entity_type entt) ENTT_NOEXCEPT {
return const_cast<object_type *>(std::as_const(*this).try_get(entt));
}
/**
@@ -919,14 +919,14 @@ public:
* sparse set already contains the given entity.
*
* @tparam Args Types of arguments to use to construct the object.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @param args Parameters to use to construct an object for the entity.
* @return The object associated with the entity.
*/
template<typename... Args>
object_type & construct(const entity_type entity, [[maybe_unused]] Args &&... args) {
object_type & construct(const entity_type entt, [[maybe_unused]] Args &&... args) {
if constexpr(std::is_empty_v<object_type>) {
underlying_type::construct(entity);
underlying_type::construct(entt);
return instances;
} else {
if constexpr(std::is_aggregate_v<object_type>) {
@@ -936,7 +936,7 @@ public:
}
// entity goes after component in case constructor throws
underlying_type::construct(entity);
underlying_type::construct(entt);
return instances.back();
}
}
@@ -994,18 +994,18 @@ public:
* An assertion will abort the execution at runtime in debug mode if the
* sparse set doesn't contain the given entity.
*
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
*/
void destroy(const entity_type entity) override {
void destroy(const entity_type entt) override {
if constexpr(!std::is_empty_v<object_type>) {
// swapping isn't required here, we are getting rid of the last element
// however, we must protect ourselves from self assignments (see #37)
auto tmp = std::move(instances.back());
instances[underlying_type::get(entity)] = std::move(tmp);
instances[underlying_type::get(entt)] = std::move(tmp);
instances.pop_back();
}
underlying_type::destroy(entity);
underlying_type::destroy(entt);
}
/**

View File

@@ -78,11 +78,11 @@ class basic_view {
using extent_type = typename sparse_set<Entity>::size_type;
iterator(unchecked_type unchecked, underlying_iterator_type begin, underlying_iterator_type end) ENTT_NOEXCEPT
: unchecked{unchecked},
begin{begin},
end{end},
extent{min(std::make_index_sequence<unchecked.size()>{})}
iterator(unchecked_type other, underlying_iterator_type first, underlying_iterator_type last) ENTT_NOEXCEPT
: unchecked{other},
begin{first},
end{last},
extent{min(std::make_index_sequence<other.size()>{})}
{
if(begin != end && !valid()) {
++(*this);
@@ -95,11 +95,11 @@ class basic_view {
}
bool valid() const ENTT_NOEXCEPT {
const auto entity = *begin;
const auto sz = size_type(entity & traits_type::entity_mask);
const auto entt = *begin;
const auto sz = size_type(entt& traits_type::entity_mask);
return sz < extent && std::all_of(unchecked.cbegin(), unchecked.cend(), [entity](const sparse_set<Entity> *view) {
return view->fast(entity);
return sz < extent && std::all_of(unchecked.cbegin(), unchecked.cend(), [entt](const sparse_set<Entity> *view) {
return view->fast(entt);
});
}
@@ -145,8 +145,8 @@ class basic_view {
};
// we could use pool_type<Component> *..., but vs complains about it and refuses to compile for unknown reasons (likely a bug)
basic_view(sparse_set<Entity, std::remove_const_t<Component>> *... pools) ENTT_NOEXCEPT
: pools{pools...}
basic_view(sparse_set<Entity, std::remove_const_t<Component>> *... ref) ENTT_NOEXCEPT
: pools{ref...}
{}
const sparse_set<Entity> * candidate() const ENTT_NOEXCEPT {
@@ -163,11 +163,11 @@ class basic_view {
}
template<typename Comp, typename Other>
inline Other & get([[maybe_unused]] component_iterator_type<Comp> it, [[maybe_unused]] const Entity entity) const ENTT_NOEXCEPT {
inline Other & get([[maybe_unused]] component_iterator_type<Comp> it, [[maybe_unused]] const Entity entt) const ENTT_NOEXCEPT {
if constexpr(std::is_same_v<Comp, Other>) {
return *it;
} else {
return std::get<pool_type<Other> *>(pools)->get(entity);
return std::get<pool_type<Other> *>(pools)->get(entt);
}
}
@@ -193,16 +193,16 @@ class basic_view {
// fallback to visit what remains using indirections
while(begin != end) {
const auto entity = *(begin++);
const auto entt = *(begin++);
const auto it = std::get<component_iterator_type<Comp>>(raw)++;
const auto sz = size_type(entity & traits_type::entity_mask);
const auto sz = size_type(entt & traits_type::entity_mask);
if(((sz < extent) && ... && std::get<Indexes>(other)->fast(entity))) {
if(((sz < extent) && ... && std::get<Indexes>(other)->fast(entt))) {
// avoided at least the indirection due to the sparse set for the pivot type (see get for more details)
if constexpr(std::is_invocable_v<Func, std::add_lvalue_reference_t<Component>...>) {
func(get<Comp, Component>(it, entity)...);
func(get<Comp, Component>(it, entt)...);
} else {
func(entity, get<Comp, Component>(it, entity)...);
func(entt, get<Comp, Component>(it, entt)...);
}
}
}
@@ -337,23 +337,23 @@ public:
/**
* @brief Finds an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return An iterator to the given entity if it's found, past the end
* iterator otherwise.
*/
iterator_type find(const entity_type entity) const ENTT_NOEXCEPT {
iterator_type find(const entity_type entt) const ENTT_NOEXCEPT {
const auto *view = candidate();
iterator_type it{unchecked(view), view->find(entity), view->end()};
return (it != end() && *it == entity) ? it : end();
iterator_type it{unchecked(view), view->find(entt), view->end()};
return (it != end() && *it == entt) ? it : end();
}
/**
* @brief Checks if a view contains an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return True if the view contains the given entity, false otherwise.
*/
bool contains(const entity_type entity) const ENTT_NOEXCEPT {
return find(entity) != end();
bool contains(const entity_type entt) const ENTT_NOEXCEPT {
return find(entt) != end();
}
/**
@@ -370,18 +370,18 @@ public:
* view doesn't contain the given entity.
*
* @tparam Comp Types of components to get.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return The components assigned to the entity.
*/
template<typename... Comp>
std::conditional_t<sizeof...(Comp) == 1, std::tuple_element_t<0, std::tuple<Comp &...>>, std::tuple<Comp &...>>
get([[maybe_unused]] const entity_type entity) const ENTT_NOEXCEPT {
assert(contains(entity));
get([[maybe_unused]] const entity_type entt) const ENTT_NOEXCEPT {
assert(contains(entt));
if constexpr(sizeof...(Comp) == 1) {
return (std::get<pool_type<Comp> *>(pools)->get(entity), ...);
return (std::get<pool_type<Comp> *>(pools)->get(entt), ...);
} else {
return std::tuple<Comp &...>{get<Comp>(entity)...};
return std::tuple<Comp &...>{get<Comp>(entt)...};
}
}
@@ -483,8 +483,8 @@ class basic_view<Entity, Component> {
using pool_type = std::conditional_t<std::is_const_v<Component>, const sparse_set<Entity, std::remove_const_t<Component>>, sparse_set<Entity, Component>>;
basic_view(pool_type *pool) ENTT_NOEXCEPT
: pool{pool}
basic_view(pool_type *ref) ENTT_NOEXCEPT
: pool{ref}
{}
public:
@@ -589,13 +589,13 @@ public:
/**
* @brief Finds an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return An iterator to the given entity if it's found, past the end
* iterator otherwise.
*/
iterator_type find(const entity_type entity) const ENTT_NOEXCEPT {
const auto it = pool->find(entity);
return it != end() && *it == entity ? it : end();
iterator_type find(const entity_type entt) const ENTT_NOEXCEPT {
const auto it = pool->find(entt);
return it != end() && *it == entt ? it : end();
}
/**
@@ -609,11 +609,11 @@ public:
/**
* @brief Checks if a view contains an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return True if the view contains the given entity, false otherwise.
*/
bool contains(const entity_type entity) const ENTT_NOEXCEPT {
return find(entity) != end();
bool contains(const entity_type entt) const ENTT_NOEXCEPT {
return find(entt) != end();
}
/**
@@ -628,12 +628,12 @@ public:
* An assertion will abort the execution at runtime in debug mode if the
* view doesn't contain the given entity.
*
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return The component assigned to the entity.
*/
raw_type & get(const entity_type entity) const ENTT_NOEXCEPT {
assert(contains(entity));
return pool->get(entity);
raw_type & get(const entity_type entt) const ENTT_NOEXCEPT {
assert(contains(entt));
return pool->get(entt);
}
/**
@@ -659,8 +659,8 @@ public:
if constexpr(std::is_invocable_v<Func, std::add_lvalue_reference_t<Component>>) {
std::for_each(pool->begin(), pool->end(), std::move(func));
} else {
std::for_each(pool->sparse_set<Entity>::begin(), pool->sparse_set<Entity>::end(), [func = std::move(func), raw = pool->begin()](const auto entity) mutable {
func(entity, *(raw++));
std::for_each(pool->sparse_set<Entity>::begin(), pool->sparse_set<Entity>::end(), [func = std::move(func), raw = pool->begin()](const auto entt) mutable {
func(entt, *(raw++));
});
}
}
@@ -719,12 +719,12 @@ class basic_runtime_view {
class iterator {
friend class basic_runtime_view<Entity>;
iterator(underlying_iterator_type begin, underlying_iterator_type end, const sparse_set<Entity> * const *first, const sparse_set<Entity> * const *last, extent_type extent) ENTT_NOEXCEPT
: begin{begin},
end{end},
first{first},
last{last},
extent{extent}
iterator(underlying_iterator_type first, underlying_iterator_type last, const sparse_set<Entity> * const *others, const sparse_set<Entity> * const *length, extent_type ext) ENTT_NOEXCEPT
: begin{first},
end{last},
from{others},
to{length},
extent{ext}
{
if(begin != end && !valid()) {
++(*this);
@@ -732,11 +732,11 @@ class basic_runtime_view {
}
bool valid() const ENTT_NOEXCEPT {
const auto entity = *begin;
const auto sz = size_type(entity & traits_type::entity_mask);
const auto entt = *begin;
const auto sz = size_type(entt & traits_type::entity_mask);
return sz < extent && std::all_of(first, last, [entity](const auto *view) {
return view->fast(entity);
return sz < extent && std::all_of(from, to, [entt](const auto *view) {
return view->fast(entt);
});
}
@@ -777,8 +777,8 @@ class basic_runtime_view {
private:
underlying_iterator_type begin;
underlying_iterator_type end;
const sparse_set<Entity> * const *first;
const sparse_set<Entity> * const *last;
const sparse_set<Entity> * const *from;
const sparse_set<Entity> * const *to;
extent_type extent;
};
@@ -889,12 +889,12 @@ public:
/**
* @brief Checks if a view contains an entity.
* @param entity A valid entity identifier.
* @param entt A valid entity identifier.
* @return True if the view contains the given entity, false otherwise.
*/
bool contains(const entity_type entity) const ENTT_NOEXCEPT {
return valid() && std::all_of(pools.cbegin(), pools.cend(), [entity](const auto *view) {
return view->has(entity) && view->data()[view->get(entity)] == entity;
bool contains(const entity_type entt) const ENTT_NOEXCEPT {
return valid() && std::all_of(pools.cbegin(), pools.cend(), [entt](const auto *view) {
return view->has(entt) && view->data()[view->get(entt)] == entt;
});
}

View File

@@ -397,8 +397,8 @@ public:
template<auto Setter, auto Getter, typename... Property>
meta_factory data(const char *str, Property &&... property) ENTT_NOEXCEPT {
using owner_type = std::tuple<std::integral_constant<decltype(Setter), Setter>, std::integral_constant<decltype(Getter), Getter>>;
using data_type = std::invoke_result_t<decltype(Getter), Type *>;
static_assert(std::is_invocable_v<decltype(Setter), Type *, data_type>);
using underlying_type = std::invoke_result_t<decltype(Getter), Type *>;
static_assert(std::is_invocable_v<decltype(Setter), Type *, underlying_type>);
auto * const type = internal::meta_info<Type>::resolve();
static internal::meta_data_node node{
@@ -408,7 +408,7 @@ public:
properties<owner_type>(std::forward<Property>(property)...),
false,
false,
&internal::meta_info<data_type>::resolve,
&internal::meta_info<underlying_type>::resolve,
&internal::setter<false, Type, Setter>,
&internal::getter<Type, Getter>,
[]() -> meta_data {

View File

@@ -240,8 +240,8 @@ const Type * try_cast(const meta_type_node *node, void *instance) ENTT_NOEXCEPT
if(node == type) {
ret = instance;
} else {
const auto *base = find_if<&meta_type_node::base>([type](auto *node) {
return node->type() == type;
const auto *base = find_if<&meta_type_node::base>([type](auto *candidate) {
return candidate->type() == type;
}, node);
ret = base ? base->cast(instance) : nullptr;
@@ -261,12 +261,12 @@ inline bool can_cast_or_convert(const meta_type_node *from, const meta_type_node
template<typename... Args, std::size_t... Indexes>
inline auto ctor(std::index_sequence<Indexes...>, const meta_type_node *node) ENTT_NOEXCEPT {
return internal::find_if([](auto *node) {
return node->size == sizeof...(Args) &&
return internal::find_if([](auto *candidate) {
return candidate->size == sizeof...(Args) &&
(([](auto *from, auto *to) {
return internal::can_cast_or_convert<&internal::meta_type_node::base>(from, to)
|| internal::can_cast_or_convert<&internal::meta_type_node::conv>(from, to);
}(internal::meta_info<Args>::resolve(), node->arg(Indexes))) && ...);
}(internal::meta_info<Args>::resolve(), candidate->arg(Indexes))) && ...);
}, node->ctor);
}
@@ -524,8 +524,8 @@ public:
if(node == type) {
any = *static_cast<const Type *>(instance);
} else {
const auto *conv = internal::find_if<&internal::meta_type_node::conv>([type](auto *node) {
return node->type() == type;
const auto *conv = internal::find_if<&internal::meta_type_node::conv>([type](auto *other) {
return other->type() == type;
}, node);
if(conv) {
@@ -634,9 +634,9 @@ class meta_handle {
{}
template<typename Type>
meta_handle(char, Type &&instance) ENTT_NOEXCEPT
meta_handle(char, Type &&obj) ENTT_NOEXCEPT
: node{internal::meta_info<Type>::resolve()},
instance{&instance}
instance{&obj}
{}
public:
@@ -649,11 +649,11 @@ public:
/**
* @brief Constructs a meta handle from a given instance.
* @tparam Type Type of object to use to initialize the handle.
* @param instance A reference to an object to use to initialize the handle.
* @param obj A reference to an object to use to initialize the handle.
*/
template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_handle>>>
meta_handle(Type &&instance) ENTT_NOEXCEPT
: meta_handle{0, std::forward<Type>(instance)}
meta_handle(Type &&obj) ENTT_NOEXCEPT
: meta_handle{0, std::forward<Type>(obj)}
{}
/**
@@ -735,8 +735,8 @@ class meta_prop {
/*! @brief A meta factory is allowed to create meta objects. */
template<typename> friend class meta_factory;
inline meta_prop(const internal::meta_prop_node *node) ENTT_NOEXCEPT
: node{node}
inline meta_prop(const internal::meta_prop_node *curr) ENTT_NOEXCEPT
: node{curr}
{}
public:
@@ -805,8 +805,8 @@ class meta_base {
/*! @brief A meta factory is allowed to create meta objects. */
template<typename> friend class meta_factory;
inline meta_base(const internal::meta_base_node *node) ENTT_NOEXCEPT
: node{node}
inline meta_base(const internal::meta_base_node *curr) ENTT_NOEXCEPT
: node{curr}
{}
public:
@@ -880,8 +880,8 @@ class meta_conv {
/*! @brief A meta factory is allowed to create meta objects. */
template<typename> friend class meta_factory;
inline meta_conv(const internal::meta_conv_node *node) ENTT_NOEXCEPT
: node{node}
inline meta_conv(const internal::meta_conv_node *curr) ENTT_NOEXCEPT
: node{curr}
{}
public:
@@ -955,8 +955,8 @@ class meta_ctor {
/*! @brief A meta factory is allowed to create meta objects. */
template<typename> friend class meta_factory;
inline meta_ctor(const internal::meta_ctor_node *node) ENTT_NOEXCEPT
: node{node}
inline meta_ctor(const internal::meta_ctor_node *curr) ENTT_NOEXCEPT
: node{curr}
{}
public:
@@ -1020,8 +1020,8 @@ public:
template<typename Op>
inline std::enable_if_t<std::is_invocable_v<Op, meta_prop>, void>
prop(Op op) const ENTT_NOEXCEPT {
internal::iterate([op = std::move(op)](auto *node) {
op(node->meta());
internal::iterate([op = std::move(op)](auto *curr) {
op(curr->meta());
}, node->prop);
}
@@ -1034,8 +1034,8 @@ public:
template<typename Key>
inline std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
prop(Key &&key) const ENTT_NOEXCEPT {
const auto *curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *curr) {
return curr->key() == key;
const auto *curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
return candidate->key() == key;
}, node->prop);
return curr ? curr->meta() : meta_prop{};
@@ -1085,8 +1085,8 @@ class meta_dtor {
/*! @brief A meta factory is allowed to create meta objects. */
template<typename> friend class meta_factory;
inline meta_dtor(const internal::meta_dtor_node *node) ENTT_NOEXCEPT
: node{node}
inline meta_dtor(const internal::meta_dtor_node *curr) ENTT_NOEXCEPT
: node{curr}
{}
public:
@@ -1159,8 +1159,8 @@ class meta_data {
/*! @brief A meta factory is allowed to create meta objects. */
template<typename> friend class meta_factory;
inline meta_data(const internal::meta_data_node *node) ENTT_NOEXCEPT
: node{node}
inline meta_data(const internal::meta_data_node *curr) ENTT_NOEXCEPT
: node{curr}
{}
public:
@@ -1251,8 +1251,8 @@ public:
template<typename Op>
inline std::enable_if_t<std::is_invocable_v<Op, meta_prop>, void>
prop(Op op) const ENTT_NOEXCEPT {
internal::iterate([op = std::move(op)](auto *node) {
op(node->meta());
internal::iterate([op = std::move(op)](auto *curr) {
op(curr->meta());
}, node->prop);
}
@@ -1265,8 +1265,8 @@ public:
template<typename Key>
inline std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
prop(Key &&key) const ENTT_NOEXCEPT {
const auto *curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *curr) {
return curr->key() == key;
const auto *curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
return candidate->key() == key;
}, node->prop);
return curr ? curr->meta() : meta_prop{};
@@ -1316,8 +1316,8 @@ class meta_func {
/*! @brief A meta factory is allowed to create meta objects. */
template<typename> friend class meta_factory;
inline meta_func(const internal::meta_func_node *node) ENTT_NOEXCEPT
: node{node}
inline meta_func(const internal::meta_func_node *curr) ENTT_NOEXCEPT
: node{curr}
{}
public:
@@ -1419,8 +1419,8 @@ public:
template<typename Op>
inline std::enable_if_t<std::is_invocable_v<Op, meta_prop>, void>
prop(Op op) const ENTT_NOEXCEPT {
internal::iterate([op = std::move(op)](auto *node) {
op(node->meta());
internal::iterate([op = std::move(op)](auto *curr) {
op(curr->meta());
}, node->prop);
}
@@ -1433,8 +1433,8 @@ public:
template<typename Key>
inline std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
prop(Key &&key) const ENTT_NOEXCEPT {
const auto *curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *curr) {
return curr->key() == key;
const auto *curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
return candidate->key() == key;
}, node->prop);
return curr ? curr->meta() : meta_prop{};
@@ -1487,8 +1487,8 @@ class meta_type {
/*! @brief A meta node is allowed to create meta objects. */
template<typename...> friend struct internal::meta_node;
inline meta_type(const internal::meta_type_node *node) ENTT_NOEXCEPT
: node{node}
inline meta_type(const internal::meta_type_node *curr) ENTT_NOEXCEPT
: node{curr}
{}
public:
@@ -1612,8 +1612,8 @@ public:
*/
template<typename Op>
inline void base(Op op) const ENTT_NOEXCEPT {
internal::iterate<&internal::meta_type_node::base>([op = std::move(op)](auto *node) {
op(node->meta());
internal::iterate<&internal::meta_type_node::base>([op = std::move(op)](auto *curr) {
op(curr->meta());
}, node);
}
@@ -1626,8 +1626,8 @@ public:
* @return The meta base associated with the given name, if any.
*/
inline meta_base base(const char *str) const ENTT_NOEXCEPT {
const auto *curr = internal::find_if<&internal::meta_type_node::base>([name = hashed_string{str}](auto *node) {
return node->type()->name == name;
const auto *curr = internal::find_if<&internal::meta_type_node::base>([name = hashed_string{str}](auto *candidate) {
return candidate->type()->name == name;
}, node);
return curr ? curr->meta() : meta_base{};
@@ -1644,8 +1644,8 @@ public:
*/
template<typename Op>
inline void conv(Op op) const ENTT_NOEXCEPT {
internal::iterate<&internal::meta_type_node::conv>([op = std::move(op)](auto *node) {
op(node->meta());
internal::iterate<&internal::meta_type_node::conv>([op = std::move(op)](auto *curr) {
op(curr->meta());
}, node);
}
@@ -1661,8 +1661,8 @@ public:
*/
template<typename Type>
inline meta_conv conv() const ENTT_NOEXCEPT {
const auto *curr = internal::find_if<&internal::meta_type_node::conv>([type = internal::meta_info<Type>::resolve()](auto *node) {
return node->type() == type;
const auto *curr = internal::find_if<&internal::meta_type_node::conv>([type = internal::meta_info<Type>::resolve()](auto *candidate) {
return candidate->type() == type;
}, node);
return curr ? curr->meta() : meta_conv{};
@@ -1675,8 +1675,8 @@ public:
*/
template<typename Op>
inline void ctor(Op op) const ENTT_NOEXCEPT {
internal::iterate([op = std::move(op)](auto *node) {
op(node->meta());
internal::iterate([op = std::move(op)](auto *curr) {
op(curr->meta());
}, node->ctor);
}
@@ -1710,8 +1710,8 @@ public:
*/
template<typename Op>
inline void data(Op op) const ENTT_NOEXCEPT {
internal::iterate<&internal::meta_type_node::data>([op = std::move(op)](auto *node) {
op(node->meta());
internal::iterate<&internal::meta_type_node::data>([op = std::move(op)](auto *curr) {
op(curr->meta());
}, node);
}
@@ -1726,8 +1726,8 @@ public:
* @return The meta data associated with the given name, if any.
*/
inline meta_data data(const char *str) const ENTT_NOEXCEPT {
const auto *curr = internal::find_if<&internal::meta_type_node::data>([name = hashed_string{str}](auto *node) {
return node->name == name;
const auto *curr = internal::find_if<&internal::meta_type_node::data>([name = hashed_string{str}](auto *candidate) {
return candidate->name == name;
}, node);
return curr ? curr->meta() : meta_data{};
@@ -1745,8 +1745,8 @@ public:
*/
template<typename Op>
inline void func(Op op) const ENTT_NOEXCEPT {
internal::iterate<&internal::meta_type_node::func>([op = std::move(op)](auto *node) {
op(node->meta());
internal::iterate<&internal::meta_type_node::func>([op = std::move(op)](auto *curr) {
op(curr->meta());
}, node);
}
@@ -1761,8 +1761,8 @@ public:
* @return The meta function associated with the given name, if any.
*/
inline meta_func func(const char *str) const ENTT_NOEXCEPT {
const auto *curr = internal::find_if<&internal::meta_type_node::func>([name = hashed_string{str}](auto *node) {
return node->name == name;
const auto *curr = internal::find_if<&internal::meta_type_node::func>([name = hashed_string{str}](auto *candidate) {
return candidate->name == name;
}, node);
return curr ? curr->meta() : meta_func{};
@@ -1784,8 +1784,8 @@ public:
std::array<meta_any, sizeof...(Args)> arguments{{std::forward<Args>(args)...}};
meta_any any{};
internal::iterate<&internal::meta_type_node::ctor>([data = arguments.data(), &any](auto *node) -> bool {
any = node->invoke(data);
internal::iterate<&internal::meta_type_node::ctor>([data = arguments.data(), &any](auto *curr) -> bool {
any = curr->invoke(data);
return static_cast<bool>(any);
}, node);
@@ -1817,8 +1817,8 @@ public:
template<typename Op>
inline std::enable_if_t<std::is_invocable_v<Op, meta_prop>, void>
prop(Op op) const ENTT_NOEXCEPT {
internal::iterate<&internal::meta_type_node::prop>([op = std::move(op)](auto *node) {
op(node->meta());
internal::iterate<&internal::meta_type_node::prop>([op = std::move(op)](auto *curr) {
op(curr->meta());
}, node);
}
@@ -1836,8 +1836,8 @@ public:
template<typename Key>
inline std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
prop(Key &&key) const ENTT_NOEXCEPT {
const auto *curr = internal::find_if<&internal::meta_type_node::prop>([key = meta_any{std::forward<Key>(key)}](auto *curr) {
return curr->key() == key;
const auto *curr = internal::find_if<&internal::meta_type_node::prop>([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
return candidate->key() == key;
}, node);
return curr ? curr->meta() : meta_prop{};

View File

@@ -56,8 +56,8 @@ class scheduler {
};
struct continuation {
continuation(process_handler *handler)
: handler{handler}
continuation(process_handler *ref)
: handler{ref}
{
assert(handler);
}

View File

@@ -153,17 +153,17 @@ public:
static_assert(std::is_invocable_r_v<Ret, decltype(Candidate), Type *, Args...>);
data = value_or_instance;
fn = [](const void *data, Args... args) -> Ret {
Type *value_or_instance = nullptr;
fn = [](const void *payload, Args... args) -> Ret {
Type *curr = nullptr;
if constexpr(std::is_const_v<Type>) {
value_or_instance = static_cast<Type *>(data);
curr = static_cast<Type *>(payload);
} else {
value_or_instance = static_cast<Type *>(const_cast<void *>(data));
curr = static_cast<Type *>(const_cast<void *>(payload));
}
// this allows void(...) to eat return values and avoid errors
return Ret(std::invoke(Candidate, value_or_instance, args...));
return Ret(std::invoke(Candidate, curr, args...));
};
}

View File

@@ -93,8 +93,8 @@ class dispatcher {
wrapper_data *wdata = nullptr;
if constexpr(is_named_type_v<Event>) {
const auto it = std::find_if(wrappers.begin(), wrappers.end(), [wtype](const auto &wdata) {
return wdata.wrapper && wdata.runtime_type == wtype;
const auto it = std::find_if(wrappers.begin(), wrappers.end(), [wtype](const auto &candidate) {
return candidate.wrapper && candidate.runtime_type == wtype;
});
wdata = (it == wrappers.cend() ? &wrappers.emplace_back() : &(*it));

View File

@@ -135,8 +135,8 @@ class emitter {
handler_data *hdata = nullptr;
if constexpr(is_named_type_v<Event>) {
const auto it = std::find_if(handlers.begin(), handlers.end(), [htype](const auto &hdata) {
return hdata.handler && hdata.runtime_type == htype;
const auto it = std::find_if(handlers.begin(), handlers.end(), [htype](const auto &candidate) {
return candidate.handler && candidate.runtime_type == htype;
});
hdata = (it == handlers.cend() ? &handlers.emplace_back() : &(*it));
@@ -240,12 +240,12 @@ public:
* instances for later uses.
*
* @tparam Event Type of event to which to connect the listener.
* @param listener The listener to register.
* @param instance The listener to register.
* @return Connection object that can be used to disconnect the listener.
*/
template<typename Event>
connection<Event> on(listener<Event> listener) {
return assure<Event>()->on(std::move(listener));
connection<Event> on(listener<Event> instance) {
return assure<Event>()->on(std::move(instance));
}
/**
@@ -265,12 +265,12 @@ public:
* instances for later uses.
*
* @tparam Event Type of event to which to connect the listener.
* @param listener The listener to register.
* @param instance The listener to register.
* @return Connection object that can be used to disconnect the listener.
*/
template<typename Event>
connection<Event> once(listener<Event> listener) {
return assure<Event>()->once(std::move(listener));
connection<Event> once(listener<Event> instance) {
return assure<Event>()->once(std::move(instance));
}
/**

View File

@@ -133,8 +133,8 @@ class sink<Ret(Args...)> {
template<typename Type>
Type * payload_type(Ret(*)(Type *, Args...));
sink(std::vector<delegate<Ret(Args...)>> *calls) ENTT_NOEXCEPT
: calls{calls}
sink(std::vector<delegate<Ret(Args...)>> *ref) ENTT_NOEXCEPT
: calls{ref}
{}
public:

View File

@@ -990,7 +990,7 @@ TEST(Benchmark, IteratePathological) {
if(i % 17) { registry.destroy(entity); }
});
for(std::uint64_t i = 0; i < 50000L; i++) {
for(std::uint64_t j = 0; j < 50000L; j++) {
const auto entity = registry.create();
registry.assign<position>(entity);
registry.assign<velocity>(entity);
@@ -1031,7 +1031,7 @@ TEST(Benchmark, IteratePathologicalNonOwningGroup) {
if(i % 17) { registry.destroy(entity); }
});
for(std::uint64_t i = 0; i < 50000L; i++) {
for(std::uint64_t j = 0; j < 50000L; j++) {
const auto entity = registry.create();
registry.assign<position>(entity);
registry.assign<velocity>(entity);
@@ -1072,7 +1072,7 @@ TEST(Benchmark, IteratePathologicalFullOwningGroup) {
if(i % 17) { registry.destroy(entity); }
});
for(std::uint64_t i = 0; i < 50000L; i++) {
for(std::uint64_t j = 0; j < 50000L; j++) {
const auto entity = registry.create();
registry.assign<position>(entity);
registry.assign<velocity>(entity);
@@ -1113,7 +1113,7 @@ TEST(Benchmark, IteratePathologicalPartialOwningGroup) {
if(i % 17) { registry.destroy(entity); }
});
for(std::uint64_t i = 0; i < 50000L; i++) {
for(std::uint64_t j = 0; j < 50000L; j++) {
const auto entity = registry.create();
registry.assign<position>(entity);
registry.assign<velocity>(entity);

View File

@@ -90,15 +90,15 @@ TEST(Helper, Tag) {
ASSERT_FALSE(registry.has<entt::tag<"barfoo"_hs>>(entity));
ASSERT_TRUE(registry.has<entt::tag<"foobar"_hs>>(entity));
for(auto entity: registry.view<int, entt::tag<"foobar"_hs>>()) {
(void)entity;
for(auto entt: registry.view<int, entt::tag<"foobar"_hs>>()) {
(void)entt;
++counter;
}
ASSERT_NE(counter, 0);
for(auto entity: registry.view<entt::tag<"foobar"_hs>>()) {
(void)entity;
for(auto entt: registry.view<entt::tag<"foobar"_hs>>()) {
(void)entt;
--counter;
}

View File

@@ -752,7 +752,7 @@ TEST(Registry, MergeTwoRegistries) {
std::unordered_map<entt::entity, entt::entity> ref;
auto merge = [&ref](const auto &view, auto &dst) {
auto merge = [&ref, &dst](const auto &view) {
view.each([&](auto entity, const auto &component) {
if(ref.find(entity) == ref.cend()) {
const auto other = dst.create();
@@ -790,10 +790,10 @@ TEST(Registry, MergeTwoRegistries) {
eq(dst.view<int, float, double>().begin(), dst.view<int, float, double>().end());
eq(dst.view<char, float, int>().begin(), dst.view<char, float, int>().end());
merge(src.view<int>(), dst);
merge(src.view<char>(), dst);
merge(src.view<double>(), dst);
merge(src.view<float>(), dst);
merge(src.view<int>());
merge(src.view<char>());
merge(src.view<double>());
merge(src.view<float>());
ne(dst.view<int, float, double>().begin(), dst.view<int, float, double>().end());
ne(dst.view<char, float, int>().begin(), dst.view<char, float, int>().end());

View File

@@ -7,8 +7,8 @@
template<typename Storage>
struct output_archive {
output_archive(Storage &storage)
: storage{storage}
output_archive(Storage &instance)
: storage{instance}
{}
template<typename... Value>
@@ -22,15 +22,15 @@ private:
template<typename Storage>
struct input_archive {
input_archive(Storage &storage)
: storage{storage}
input_archive(Storage &instance)
: storage{instance}
{}
template<typename... Value>
void operator()(Value &... value) {
auto assign = [this](auto &value) {
auto &queue = std::get<std::queue<std::decay_t<decltype(value)>>>(storage);
value = queue.front();
auto assign = [this](auto &val) {
auto &queue = std::get<std::queue<std::decay_t<decltype(val)>>>(storage);
val = queue.front();
queue.pop();
};
@@ -298,8 +298,8 @@ TEST(Snapshot, Continuous) {
decltype(dst.size()) another_component_cnt{};
decltype(dst.size()) what_a_component_cnt{};
dst.each([&dst, &a_component_cnt](auto entity) {
ASSERT_TRUE(dst.has<a_component>(entity));
dst.each([&dst, &a_component_cnt](auto entt) {
ASSERT_TRUE(dst.has<a_component>(entt));
++a_component_cnt;
});
@@ -308,11 +308,11 @@ TEST(Snapshot, Continuous) {
++another_component_cnt;
});
dst.view<what_a_component>().each([&dst, &what_a_component_cnt](auto entity, const auto &component) {
ASSERT_EQ(entity, component.bar);
dst.view<what_a_component>().each([&dst, &what_a_component_cnt](auto entt, const auto &component) {
ASSERT_EQ(entt, component.bar);
for(auto entity: component.quux) {
ASSERT_TRUE(dst.valid(entity));
for(auto child: component.quux) {
ASSERT_TRUE(dst.valid(child));
}
++what_a_component_cnt;
@@ -365,8 +365,8 @@ TEST(Snapshot, Continuous) {
});
entities.clear();
for(auto entity: src.view<a_component>()) {
entities.push_back(entity);
for(auto entt: src.view<a_component>()) {
entities.push_back(entt);
}
src.destroy(entity);

View File

@@ -50,7 +50,10 @@ struct base_type {
struct derived_type: base_type {
derived_type() = default;
derived_type(const base_type &, int i, char c): i{i}, c{c} {}
derived_type(const base_type &, int value, char character)
: i{value}, c{character}
{}
const int i{};
const char c{};
@@ -83,10 +86,10 @@ struct func_type {
struct setter_getter_type {
int value{};
int setter(int value) { return this->value = value; }
int setter(int val) { return value = val; }
int getter() { return value; }
int setter_with_ref(const int &value) { return this->value = value; }
int setter_with_ref(const int &val) { return value = val; }
const int & getter_with_ref() { return value; }
static int static_setter(setter_getter_type *type, int value) { return type->value = value; }

View File

@@ -4,8 +4,8 @@
#include <entt/process/process.hpp>
struct foo_process: entt::process<foo_process, int> {
foo_process(std::function<void()> on_update, std::function<void()> on_aborted)
: on_update{on_update}, on_aborted{on_aborted}
foo_process(std::function<void()> upd, std::function<void()> abort)
: on_update{upd}, on_aborted{abort}
{}
void update(delta_type, void *) { on_update(); }

View File

@@ -172,8 +172,8 @@ class duktape_registry {
}
public:
duktape_registry(entt::registry &registry)
: registry{registry}
duktape_registry(entt::registry &ref)
: registry{ref}
{
reg<position, renderable, duktape_runtime>();
}
@@ -237,9 +237,9 @@ public:
duk_push_uint(ctx, entity);
duk_put_prop_index(ctx, -2, pos++);
} else {
const auto &components = dreg.registry.get<duktape_runtime>(entity).components;
const auto match = std::all_of(runtime.cbegin(), runtime.cend(), [&components](const auto type) {
return components.find(type) != components.cend();
const auto &others = dreg.registry.get<duktape_runtime>(entity).components;
const auto match = std::all_of(runtime.cbegin(), runtime.cend(), [&others](const auto type) {
return others.find(type) != others.cend();
});
if(match) {
@@ -268,19 +268,19 @@ const duk_function_list_entry js_duktape_registry_methods[] = {
{ nullptr, nullptr, 0 }
};
void export_types(duk_context *ctx, entt::registry &registry) {
auto export_type = [](auto *ctx, auto &registry, auto idx, auto type, const auto *name) {
void export_types(duk_context *context, entt::registry &registry) {
auto export_type = [](auto *ctx, auto &reg, auto idx, auto type, const auto *name) {
duk_push_string(ctx, name);
duk_push_uint(ctx, registry.template type<typename decltype(type)::type>());
duk_push_uint(ctx, reg.template type<typename decltype(type)::type>());
duk_def_prop(ctx, idx, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_CLEAR_WRITABLE);
};
auto idx = duk_push_object(ctx);
auto idx = duk_push_object(context);
export_type(ctx, registry, idx, tag<position>{}, "position");
export_type(ctx, registry, idx, tag<renderable>{}, "renderable");
export_type(context, registry, idx, tag<position>{}, "position");
export_type(context, registry, idx, tag<renderable>{}, "renderable");
duk_put_global_string(ctx, "Types");
duk_put_global_string(context, "Types");
}
void export_duktape_registry(duk_context *ctx, duktape_registry &dreg) {