*: review enums
This commit is contained in:
@@ -21,18 +21,18 @@ namespace entt {
|
||||
template<std::size_t Len, std::size_t Align>
|
||||
class basic_any {
|
||||
enum class operation : std::uint8_t {
|
||||
COPY,
|
||||
MOVE,
|
||||
DTOR,
|
||||
COMP,
|
||||
GET,
|
||||
TYPE
|
||||
copy,
|
||||
move,
|
||||
dtor,
|
||||
comp,
|
||||
get,
|
||||
type
|
||||
};
|
||||
|
||||
enum class policy : std::uint8_t {
|
||||
OWNER,
|
||||
REF,
|
||||
CREF
|
||||
owner,
|
||||
ref,
|
||||
cref
|
||||
};
|
||||
|
||||
using storage_type = std::aligned_storage_t<Len + !Len, Align>;
|
||||
@@ -47,26 +47,26 @@ class basic_any {
|
||||
const Type *instance = nullptr;
|
||||
|
||||
if constexpr(in_situ<Type>) {
|
||||
instance = (from.mode == policy::OWNER) ? ENTT_LAUNDER(reinterpret_cast<const Type *>(&from.storage)) : static_cast<const Type *>(from.instance);
|
||||
instance = (from.mode == policy::owner) ? ENTT_LAUNDER(reinterpret_cast<const Type *>(&from.storage)) : static_cast<const Type *>(from.instance);
|
||||
} else {
|
||||
instance = static_cast<const Type *>(from.instance);
|
||||
}
|
||||
|
||||
switch(op) {
|
||||
case operation::COPY:
|
||||
case operation::copy:
|
||||
if constexpr(std::is_copy_constructible_v<Type>) {
|
||||
static_cast<basic_any *>(const_cast<void *>(to))->initialize<Type>(*instance);
|
||||
}
|
||||
break;
|
||||
case operation::MOVE:
|
||||
case operation::move:
|
||||
if constexpr(in_situ<Type>) {
|
||||
if(from.mode == policy::OWNER) {
|
||||
if(from.mode == policy::owner) {
|
||||
return new(&static_cast<basic_any *>(const_cast<void *>(to))->storage) Type{std::move(*const_cast<Type *>(instance))};
|
||||
}
|
||||
}
|
||||
|
||||
return (static_cast<basic_any *>(const_cast<void *>(to))->instance = std::exchange(const_cast<basic_any &>(from).instance, nullptr));
|
||||
case operation::DTOR:
|
||||
case operation::dtor:
|
||||
if constexpr(in_situ<Type>) {
|
||||
instance->~Type();
|
||||
} else if constexpr(std::is_array_v<Type>) {
|
||||
@@ -75,7 +75,7 @@ class basic_any {
|
||||
delete instance;
|
||||
}
|
||||
break;
|
||||
case operation::COMP: {
|
||||
case operation::comp: {
|
||||
const auto info = type_id<Type>();
|
||||
auto *value = static_cast<const basic_any *>(to)->data(&info);
|
||||
|
||||
@@ -85,9 +85,9 @@ class basic_any {
|
||||
return (instance == value) ? to : nullptr;
|
||||
}
|
||||
}
|
||||
case operation::GET:
|
||||
case operation::get:
|
||||
return (!to || (*static_cast<const type_info *>(to) == type_id<Type>())) ? instance : nullptr;
|
||||
case operation::TYPE:
|
||||
case operation::type:
|
||||
*static_cast<type_info *>(const_cast<void *>(to)) = type_id<Type>();
|
||||
break;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ class basic_any {
|
||||
|
||||
if constexpr(std::is_lvalue_reference_v<Type>) {
|
||||
static_assert(sizeof...(Args) == 1u && (std::is_lvalue_reference_v<Args> && ...), "Invalid arguments");
|
||||
mode = std::is_const_v<std::remove_reference_t<Type>> ? policy::CREF : policy::REF;
|
||||
mode = std::is_const_v<std::remove_reference_t<Type>> ? policy::cref : policy::ref;
|
||||
instance = (std::addressof(args), ...);
|
||||
} else if constexpr(in_situ<Type>) {
|
||||
if constexpr(sizeof...(Args) != 0u && std::is_aggregate_v<Type>) {
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
basic_any() ENTT_NOEXCEPT
|
||||
: instance{},
|
||||
vtable{},
|
||||
mode{policy::OWNER} {}
|
||||
mode{policy::owner} {}
|
||||
|
||||
/**
|
||||
* @brief Constructs a wrapper by directly initializing the new object.
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
basic_any(const basic_any &other)
|
||||
: basic_any{} {
|
||||
if(other.vtable) {
|
||||
other.vtable(operation::COPY, other, this);
|
||||
other.vtable(operation::copy, other, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,14 +180,14 @@ public:
|
||||
vtable{other.vtable},
|
||||
mode{other.mode} {
|
||||
if(other.vtable) {
|
||||
other.vtable(operation::MOVE, other, this);
|
||||
other.vtable(operation::move, other, this);
|
||||
}
|
||||
}
|
||||
|
||||
/*! @brief Frees the internal storage, whatever it means. */
|
||||
~basic_any() {
|
||||
if(vtable && mode == policy::OWNER) {
|
||||
vtable(operation::DTOR, *this, nullptr);
|
||||
if(vtable && mode == policy::owner) {
|
||||
vtable(operation::dtor, *this, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
reset();
|
||||
|
||||
if(other.vtable) {
|
||||
other.vtable(operation::COPY, other, this);
|
||||
other.vtable(operation::copy, other, this);
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
reset();
|
||||
|
||||
if(other.vtable) {
|
||||
other.vtable(operation::MOVE, other, this);
|
||||
other.vtable(operation::move, other, this);
|
||||
vtable = other.vtable;
|
||||
mode = other.mode;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public:
|
||||
[[nodiscard]] type_info type() const ENTT_NOEXCEPT {
|
||||
if(vtable) {
|
||||
type_info info{};
|
||||
vtable(operation::TYPE, *this, &info);
|
||||
vtable(operation::type, *this, &info);
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -256,12 +256,12 @@ public:
|
||||
* @return An opaque pointer the contained instance, if any.
|
||||
*/
|
||||
[[nodiscard]] const void *data(const type_info *req = nullptr) const ENTT_NOEXCEPT {
|
||||
return vtable ? vtable(operation::GET, *this, req) : nullptr;
|
||||
return vtable ? vtable(operation::get, *this, req) : nullptr;
|
||||
}
|
||||
|
||||
/*! @copydoc data */
|
||||
[[nodiscard]] void *data(const type_info *req = nullptr) ENTT_NOEXCEPT {
|
||||
return (!vtable || mode == policy::CREF) ? nullptr : const_cast<void *>(vtable(operation::GET, *this, req));
|
||||
return (!vtable || mode == policy::cref) ? nullptr : const_cast<void *>(vtable(operation::get, *this, req));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,12 +278,12 @@ public:
|
||||
|
||||
/*! @brief Destroys contained object */
|
||||
void reset() {
|
||||
if(vtable && mode == policy::OWNER) {
|
||||
vtable(operation::DTOR, *this, nullptr);
|
||||
if(vtable && mode == policy::owner) {
|
||||
vtable(operation::dtor, *this, nullptr);
|
||||
}
|
||||
|
||||
vtable = nullptr;
|
||||
mode = policy::OWNER;
|
||||
mode = policy::owner;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,7 +301,7 @@ public:
|
||||
*/
|
||||
bool operator==(const basic_any &other) const ENTT_NOEXCEPT {
|
||||
if(vtable && other.vtable) {
|
||||
return (vtable(operation::COMP, *this, &other) != nullptr);
|
||||
return (vtable(operation::comp, *this, &other) != nullptr);
|
||||
}
|
||||
|
||||
return (!vtable && !other.vtable);
|
||||
@@ -312,12 +312,12 @@ public:
|
||||
* @return A wrapper that shares a reference to an unmanaged object.
|
||||
*/
|
||||
[[nodiscard]] basic_any as_ref() ENTT_NOEXCEPT {
|
||||
return basic_any{*this, (mode == policy::CREF ? policy::CREF : policy::REF)};
|
||||
return basic_any{*this, (mode == policy::cref ? policy::cref : policy::ref)};
|
||||
}
|
||||
|
||||
/*! @copydoc as_ref */
|
||||
[[nodiscard]] basic_any as_ref() const ENTT_NOEXCEPT {
|
||||
return basic_any{*this, policy::CREF};
|
||||
return basic_any{*this, policy::cref};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,7 +325,7 @@ public:
|
||||
* @return True if the wrapper owns its object, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool owner() const ENTT_NOEXCEPT {
|
||||
return (mode == policy::OWNER);
|
||||
return (mode == policy::owner);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -189,7 +189,7 @@ class meta_factory<Type> {
|
||||
nullptr,
|
||||
Setter::size,
|
||||
/* this is never static */
|
||||
(std::is_member_object_pointer_v<decltype(value_list_element_v<Index, Setter>)> && ... && std::is_const_v<data_type>) ? internal::meta_traits::IS_CONST : internal::meta_traits::IS_NONE,
|
||||
(std::is_member_object_pointer_v<decltype(value_list_element_v<Index, Setter>)> && ... && std::is_const_v<data_type>) ? internal::meta_traits::is_const : internal::meta_traits::is_none,
|
||||
internal::meta_node<std::remove_const_t<std::remove_reference_t<data_type>>>::resolve(),
|
||||
&meta_arg<type_list<type_list_element_t<type_list_element_t<Index, args_type>::size != 1u, type_list_element_t<Index, args_type>>...>>,
|
||||
[](meta_handle instance, meta_any value) -> bool { return (meta_setter<Type, value_list_element_v<Index, Setter>>(*instance.operator->(), value) || ...); },
|
||||
@@ -418,7 +418,7 @@ public:
|
||||
nullptr,
|
||||
nullptr,
|
||||
1u,
|
||||
((std::is_same_v<Type, data_type> || std::is_const_v<data_type>) ? internal::meta_traits::IS_CONST : internal::meta_traits::IS_NONE) | internal::meta_traits::IS_STATIC,
|
||||
((std::is_same_v<Type, data_type> || std::is_const_v<data_type>) ? internal::meta_traits::is_const : internal::meta_traits::is_none) | internal::meta_traits::is_static,
|
||||
internal::meta_node<std::remove_const_t<std::remove_reference_t<data_type>>>::resolve(),
|
||||
&meta_arg<type_list<data_type>>,
|
||||
&meta_setter<Type, Data>,
|
||||
@@ -462,7 +462,7 @@ public:
|
||||
nullptr,
|
||||
0u,
|
||||
/* this is never static */
|
||||
internal::meta_traits::IS_CONST,
|
||||
internal::meta_traits::is_const,
|
||||
internal::meta_node<std::remove_const_t<std::remove_reference_t<data_type>>>::resolve(),
|
||||
&meta_arg<type_list<>>,
|
||||
&meta_setter<Type, Setter>,
|
||||
@@ -481,7 +481,7 @@ public:
|
||||
nullptr,
|
||||
1u,
|
||||
/* this is never static */
|
||||
(std::is_member_object_pointer_v<decltype(Setter)> && std::is_const_v<data_type>) ? internal::meta_traits::IS_CONST : internal::meta_traits::IS_NONE,
|
||||
(std::is_member_object_pointer_v<decltype(Setter)> && std::is_const_v<data_type>) ? internal::meta_traits::is_const : internal::meta_traits::is_none,
|
||||
internal::meta_node<std::remove_const_t<std::remove_reference_t<data_type>>>::resolve(),
|
||||
&meta_arg<type_list<type_list_element_t<args_type::size != 1u, args_type>>>,
|
||||
&meta_setter<Type, Setter>,
|
||||
@@ -538,7 +538,7 @@ public:
|
||||
nullptr,
|
||||
nullptr,
|
||||
descriptor::args_type::size,
|
||||
(descriptor::is_const ? internal::meta_traits::IS_CONST : internal::meta_traits::IS_NONE) | (descriptor::is_static ? internal::meta_traits::IS_STATIC : internal::meta_traits::IS_NONE),
|
||||
(descriptor::is_const ? internal::meta_traits::is_const : internal::meta_traits::is_none) | (descriptor::is_static ? internal::meta_traits::is_static : internal::meta_traits::is_none),
|
||||
internal::meta_node<std::conditional_t<std::is_same_v<Policy, as_void_t>, void, std::remove_const_t<std::remove_reference_t<typename descriptor::return_type>>>>::resolve(),
|
||||
&meta_arg<typename descriptor::args_type>,
|
||||
&meta_invoke<Type, Candidate, Policy>
|
||||
|
||||
@@ -146,9 +146,9 @@ private:
|
||||
/*! @brief Opaque wrapper for values of any type. */
|
||||
class meta_any {
|
||||
enum class operation : std::uint8_t {
|
||||
DEREF,
|
||||
SEQ,
|
||||
ASSOC
|
||||
deref,
|
||||
seq,
|
||||
assoc
|
||||
};
|
||||
|
||||
using vtable_type = void(const operation, const any &, void *);
|
||||
@@ -159,7 +159,7 @@ class meta_any {
|
||||
|
||||
if constexpr(!std::is_void_v<Type>) {
|
||||
switch(op) {
|
||||
case operation::DEREF:
|
||||
case operation::deref:
|
||||
if constexpr(is_meta_pointer_like_v<Type>) {
|
||||
if constexpr(std::is_function_v<std::remove_const_t<typename std::pointer_traits<Type>::element_type>>) {
|
||||
*static_cast<meta_any *>(to) = any_cast<Type>(from);
|
||||
@@ -169,12 +169,12 @@ class meta_any {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case operation::SEQ:
|
||||
case operation::seq:
|
||||
if constexpr(is_complete_v<meta_sequence_container_traits<Type>>) {
|
||||
*static_cast<meta_sequence_container *>(to) = {std::in_place_type<Type>, std::move(const_cast<any &>(from))};
|
||||
}
|
||||
break;
|
||||
case operation::ASSOC:
|
||||
case operation::assoc:
|
||||
if constexpr(is_complete_v<meta_associative_container_traits<Type>>) {
|
||||
*static_cast<meta_associative_container *>(to) = {std::in_place_type<Type>, std::move(const_cast<any &>(from))};
|
||||
}
|
||||
@@ -489,14 +489,14 @@ public:
|
||||
*/
|
||||
[[nodiscard]] meta_sequence_container as_sequence_container() ENTT_NOEXCEPT {
|
||||
meta_sequence_container proxy;
|
||||
vtable(operation::SEQ, storage.as_ref(), &proxy);
|
||||
vtable(operation::seq, storage.as_ref(), &proxy);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/*! @copydoc as_sequence_container */
|
||||
[[nodiscard]] meta_sequence_container as_sequence_container() const ENTT_NOEXCEPT {
|
||||
meta_sequence_container proxy;
|
||||
vtable(operation::SEQ, storage.as_ref(), &proxy);
|
||||
vtable(operation::seq, storage.as_ref(), &proxy);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -506,14 +506,14 @@ public:
|
||||
*/
|
||||
[[nodiscard]] meta_associative_container as_associative_container() ENTT_NOEXCEPT {
|
||||
meta_associative_container proxy;
|
||||
vtable(operation::ASSOC, storage.as_ref(), &proxy);
|
||||
vtable(operation::assoc, storage.as_ref(), &proxy);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/*! @copydoc as_associative_container */
|
||||
[[nodiscard]] meta_associative_container as_associative_container() const ENTT_NOEXCEPT {
|
||||
meta_associative_container proxy;
|
||||
vtable(operation::ASSOC, storage.as_ref(), &proxy);
|
||||
vtable(operation::assoc, storage.as_ref(), &proxy);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -524,7 +524,7 @@ public:
|
||||
*/
|
||||
[[nodiscard]] meta_any operator*() const ENTT_NOEXCEPT {
|
||||
meta_any ret{};
|
||||
vtable(operation::DEREF, storage, &ret);
|
||||
vtable(operation::deref, storage, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ struct meta_data {
|
||||
* @return True if the data member is constant, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_const() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_CONST);
|
||||
return !!(node->traits & internal::meta_traits::is_const);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -743,7 +743,7 @@ struct meta_data {
|
||||
* @return True if the data member is static, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_static() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_STATIC);
|
||||
return !!(node->traits & internal::meta_traits::is_static);
|
||||
}
|
||||
|
||||
/*! @copydoc meta_any::type */
|
||||
@@ -852,7 +852,7 @@ struct meta_func {
|
||||
* @return True if the member function is constant, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_const() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_CONST);
|
||||
return !!(node->traits & internal::meta_traits::is_const);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -860,7 +860,7 @@ struct meta_func {
|
||||
* @return True if the member function is static, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_static() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_STATIC);
|
||||
return !!(node->traits & internal::meta_traits::is_static);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1026,7 +1026,7 @@ public:
|
||||
* otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_arithmetic() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_ARITHMETIC);
|
||||
return !!(node->traits & internal::meta_traits::is_arithmetic);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1034,7 +1034,7 @@ public:
|
||||
* @return True if the underlying type is an array type, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_array() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_ARRAY);
|
||||
return !!(node->traits & internal::meta_traits::is_array);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1042,7 +1042,7 @@ public:
|
||||
* @return True if the underlying type is an enum, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_enum() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_ENUM);
|
||||
return !!(node->traits & internal::meta_traits::is_enum);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1050,7 +1050,7 @@ public:
|
||||
* @return True if the underlying type is a class, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_class() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_CLASS);
|
||||
return !!(node->traits & internal::meta_traits::is_class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1058,7 +1058,7 @@ public:
|
||||
* @return True if the underlying type is a pointer, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_pointer() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_POINTER);
|
||||
return !!(node->traits & internal::meta_traits::is_pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1067,7 +1067,7 @@ public:
|
||||
* otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_pointer_like() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_META_POINTER_LIKE);
|
||||
return !!(node->traits & internal::meta_traits::is_meta_pointer_like);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1075,7 +1075,7 @@ public:
|
||||
* @return True if the type is a sequence container, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_sequence_container() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_META_SEQUENCE_CONTAINER);
|
||||
return !!(node->traits & internal::meta_traits::is_meta_sequence_container);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1083,7 +1083,7 @@ public:
|
||||
* @return True if the type is an associative container, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_associative_container() const ENTT_NOEXCEPT {
|
||||
return !!(node->traits & internal::meta_traits::IS_META_ASSOCIATIVE_CONTAINER);
|
||||
return !!(node->traits & internal::meta_traits::is_meta_associative_container);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1400,8 +1400,8 @@ bool meta_any::set(const id_type id, Type &&value) {
|
||||
/*! @brief Opaque iterator for sequence containers. */
|
||||
class meta_sequence_container::meta_iterator {
|
||||
enum class operation : std::uint8_t {
|
||||
INCR,
|
||||
DEREF
|
||||
incr,
|
||||
deref
|
||||
};
|
||||
|
||||
using vtable_type = void(const operation, const any &, void *);
|
||||
@@ -1409,10 +1409,10 @@ class meta_sequence_container::meta_iterator {
|
||||
template<typename It>
|
||||
static void basic_vtable(const operation op, const any &from, void *to) {
|
||||
switch(op) {
|
||||
case operation::INCR:
|
||||
case operation::incr:
|
||||
++any_cast<It &>(const_cast<any &>(from));
|
||||
break;
|
||||
case operation::DEREF:
|
||||
case operation::deref:
|
||||
static_cast<meta_any *>(to)->emplace<typename std::iterator_traits<It>::reference>(*any_cast<const It &>(from));
|
||||
break;
|
||||
}
|
||||
@@ -1445,7 +1445,7 @@ public:
|
||||
|
||||
/*! @brief Pre-increment operator. @return This iterator. */
|
||||
meta_iterator &operator++() ENTT_NOEXCEPT {
|
||||
return vtable(operation::INCR, handle, nullptr), *this;
|
||||
return vtable(operation::incr, handle, nullptr), *this;
|
||||
}
|
||||
|
||||
/*! @brief Post-increment operator. @return This iterator. */
|
||||
@@ -1478,7 +1478,7 @@ public:
|
||||
*/
|
||||
[[nodiscard]] reference operator*() const {
|
||||
meta_any other;
|
||||
vtable(operation::DEREF, handle, &other);
|
||||
vtable(operation::deref, handle, &other);
|
||||
return other;
|
||||
}
|
||||
|
||||
@@ -1592,8 +1592,8 @@ inline meta_sequence_container::iterator meta_sequence_container::erase(iterator
|
||||
/*! @brief Opaque iterator for associative containers. */
|
||||
class meta_associative_container::meta_iterator {
|
||||
enum class operation : std::uint8_t {
|
||||
INCR,
|
||||
DEREF
|
||||
incr,
|
||||
deref
|
||||
};
|
||||
|
||||
using vtable_type = void(const operation, const any &, void *);
|
||||
@@ -1601,10 +1601,10 @@ class meta_associative_container::meta_iterator {
|
||||
template<bool KeyOnly, typename It>
|
||||
static void basic_vtable(const operation op, const any &from, void *to) {
|
||||
switch(op) {
|
||||
case operation::INCR:
|
||||
case operation::incr:
|
||||
++any_cast<It &>(const_cast<any &>(from));
|
||||
break;
|
||||
case operation::DEREF:
|
||||
case operation::deref:
|
||||
const auto &it = any_cast<const It &>(from);
|
||||
if constexpr(KeyOnly) {
|
||||
static_cast<std::pair<meta_any, meta_any> *>(to)->first.emplace<decltype(*it)>(*it);
|
||||
@@ -1644,7 +1644,7 @@ public:
|
||||
|
||||
/*! @brief Pre-increment operator. @return This iterator. */
|
||||
meta_iterator &operator++() ENTT_NOEXCEPT {
|
||||
return vtable(operation::INCR, handle, nullptr), *this;
|
||||
return vtable(operation::incr, handle, nullptr), *this;
|
||||
}
|
||||
|
||||
/*! @brief Post-increment operator. @return This iterator. */
|
||||
@@ -1677,7 +1677,7 @@ public:
|
||||
*/
|
||||
[[nodiscard]] reference operator*() const {
|
||||
reference other;
|
||||
vtable(operation::DEREF, handle, &other);
|
||||
vtable(operation::deref, handle, &other);
|
||||
return other;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,17 +26,17 @@ struct meta_handle;
|
||||
namespace internal {
|
||||
|
||||
enum class meta_traits : std::uint32_t {
|
||||
IS_NONE = 0x0000,
|
||||
IS_CONST = 0x0001,
|
||||
IS_STATIC = 0x0002,
|
||||
IS_ARITHMETIC = 0x0004,
|
||||
IS_ARRAY = 0x0008,
|
||||
IS_ENUM = 0x0010,
|
||||
IS_CLASS = 0x0020,
|
||||
IS_POINTER = 0x0040,
|
||||
IS_META_POINTER_LIKE = 0x0080,
|
||||
IS_META_SEQUENCE_CONTAINER = 0x0100,
|
||||
IS_META_ASSOCIATIVE_CONTAINER = 0x0200,
|
||||
is_none = 0x0000,
|
||||
is_const = 0x0001,
|
||||
is_static = 0x0002,
|
||||
is_arithmetic = 0x0004,
|
||||
is_array = 0x0008,
|
||||
is_enum = 0x0010,
|
||||
is_class = 0x0020,
|
||||
is_pointer = 0x0040,
|
||||
is_meta_pointer_like = 0x0080,
|
||||
is_meta_sequence_container = 0x0100,
|
||||
is_meta_associative_container = 0x0200,
|
||||
_entt_enum_as_bitmask
|
||||
};
|
||||
|
||||
@@ -171,15 +171,15 @@ public:
|
||||
nullptr,
|
||||
nullptr,
|
||||
size_of_v<Type>,
|
||||
internal::meta_traits::IS_NONE
|
||||
| (std::is_arithmetic_v<Type> ? internal::meta_traits::IS_ARITHMETIC : internal::meta_traits::IS_NONE)
|
||||
| (std::is_array_v<Type> ? internal::meta_traits::IS_ARRAY : internal::meta_traits::IS_NONE)
|
||||
| (std::is_enum_v<Type> ? internal::meta_traits::IS_ENUM : internal::meta_traits::IS_NONE)
|
||||
| (std::is_class_v<Type> ? internal::meta_traits::IS_CLASS : internal::meta_traits::IS_NONE)
|
||||
| (std::is_pointer_v<Type> ? internal::meta_traits::IS_POINTER : internal::meta_traits::IS_NONE)
|
||||
| (is_meta_pointer_like_v<Type> ? internal::meta_traits::IS_META_POINTER_LIKE : internal::meta_traits::IS_NONE)
|
||||
| (is_complete_v<meta_sequence_container_traits<Type>> ? internal::meta_traits::IS_META_SEQUENCE_CONTAINER : internal::meta_traits::IS_NONE)
|
||||
| (is_complete_v<meta_associative_container_traits<Type>> ? internal::meta_traits::IS_META_ASSOCIATIVE_CONTAINER : internal::meta_traits::IS_NONE),
|
||||
internal::meta_traits::is_none
|
||||
| (std::is_arithmetic_v<Type> ? internal::meta_traits::is_arithmetic : internal::meta_traits::is_none)
|
||||
| (std::is_array_v<Type> ? internal::meta_traits::is_array : internal::meta_traits::is_none)
|
||||
| (std::is_enum_v<Type> ? internal::meta_traits::is_enum : internal::meta_traits::is_none)
|
||||
| (std::is_class_v<Type> ? internal::meta_traits::is_class : internal::meta_traits::is_none)
|
||||
| (std::is_pointer_v<Type> ? internal::meta_traits::is_pointer : internal::meta_traits::is_none)
|
||||
| (is_meta_pointer_like_v<Type> ? internal::meta_traits::is_meta_pointer_like : internal::meta_traits::is_none)
|
||||
| (is_complete_v<meta_sequence_container_traits<Type>> ? internal::meta_traits::is_meta_sequence_container : internal::meta_traits::is_none)
|
||||
| (is_complete_v<meta_associative_container_traits<Type>> ? internal::meta_traits::is_meta_associative_container : internal::meta_traits::is_none),
|
||||
meta_default_constructor(),
|
||||
meta_conversion_helper(),
|
||||
meta_template_info()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef ENTT_PROCESS_PROCESS_HPP
|
||||
#define ENTT_PROCESS_PROCESS_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include "../config/config.h"
|
||||
@@ -68,43 +69,43 @@ namespace entt {
|
||||
*/
|
||||
template<typename Derived, typename Delta>
|
||||
class process {
|
||||
enum class state : unsigned int {
|
||||
UNINITIALIZED = 0,
|
||||
RUNNING,
|
||||
PAUSED,
|
||||
SUCCEEDED,
|
||||
FAILED,
|
||||
ABORTED,
|
||||
FINISHED,
|
||||
REJECTED
|
||||
enum class state : std::uint8_t {
|
||||
uninitialized = 0,
|
||||
running,
|
||||
paused,
|
||||
succeeded,
|
||||
failed,
|
||||
aborted,
|
||||
finished,
|
||||
rejected
|
||||
};
|
||||
|
||||
template<typename Target = Derived>
|
||||
auto next(std::integral_constant<state, state::UNINITIALIZED>)
|
||||
auto next(std::integral_constant<state, state::uninitialized>)
|
||||
-> decltype(std::declval<Target>().init(), void()) {
|
||||
static_cast<Target *>(this)->init();
|
||||
}
|
||||
|
||||
template<typename Target = Derived>
|
||||
auto next(std::integral_constant<state, state::RUNNING>, Delta delta, void *data)
|
||||
auto next(std::integral_constant<state, state::running>, Delta delta, void *data)
|
||||
-> decltype(std::declval<Target>().update(delta, data), void()) {
|
||||
static_cast<Target *>(this)->update(delta, data);
|
||||
}
|
||||
|
||||
template<typename Target = Derived>
|
||||
auto next(std::integral_constant<state, state::SUCCEEDED>)
|
||||
auto next(std::integral_constant<state, state::succeeded>)
|
||||
-> decltype(std::declval<Target>().succeeded(), void()) {
|
||||
static_cast<Target *>(this)->succeeded();
|
||||
}
|
||||
|
||||
template<typename Target = Derived>
|
||||
auto next(std::integral_constant<state, state::FAILED>)
|
||||
auto next(std::integral_constant<state, state::failed>)
|
||||
-> decltype(std::declval<Target>().failed(), void()) {
|
||||
static_cast<Target *>(this)->failed();
|
||||
}
|
||||
|
||||
template<typename Target = Derived>
|
||||
auto next(std::integral_constant<state, state::ABORTED>)
|
||||
auto next(std::integral_constant<state, state::aborted>)
|
||||
-> decltype(std::declval<Target>().aborted(), void()) {
|
||||
static_cast<Target *>(this)->aborted();
|
||||
}
|
||||
@@ -120,7 +121,7 @@ protected:
|
||||
*/
|
||||
void succeed() ENTT_NOEXCEPT {
|
||||
if(alive()) {
|
||||
current = state::SUCCEEDED;
|
||||
current = state::succeeded;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +133,7 @@ protected:
|
||||
*/
|
||||
void fail() ENTT_NOEXCEPT {
|
||||
if(alive()) {
|
||||
current = state::FAILED;
|
||||
current = state::failed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,8 +144,8 @@ protected:
|
||||
* running.
|
||||
*/
|
||||
void pause() ENTT_NOEXCEPT {
|
||||
if(current == state::RUNNING) {
|
||||
current = state::PAUSED;
|
||||
if(current == state::running) {
|
||||
current = state::paused;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +156,8 @@ protected:
|
||||
* paused.
|
||||
*/
|
||||
void unpause() ENTT_NOEXCEPT {
|
||||
if(current == state::PAUSED) {
|
||||
current = state::RUNNING;
|
||||
if(current == state::paused) {
|
||||
current = state::running;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +180,7 @@ public:
|
||||
*/
|
||||
void abort(const bool immediately = false) {
|
||||
if(alive()) {
|
||||
current = state::ABORTED;
|
||||
current = state::aborted;
|
||||
|
||||
if(immediately) {
|
||||
tick({});
|
||||
@@ -192,7 +193,7 @@ public:
|
||||
* @return True if the process is still alive, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool alive() const ENTT_NOEXCEPT {
|
||||
return current == state::RUNNING || current == state::PAUSED;
|
||||
return current == state::running || current == state::paused;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +201,7 @@ public:
|
||||
* @return True if the process is terminated, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool finished() const ENTT_NOEXCEPT {
|
||||
return current == state::FINISHED;
|
||||
return current == state::finished;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,7 +209,7 @@ public:
|
||||
* @return True if the process is paused, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool paused() const ENTT_NOEXCEPT {
|
||||
return current == state::PAUSED;
|
||||
return current == state::paused;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,7 +217,7 @@ public:
|
||||
* @return True if the process terminated with errors, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool rejected() const ENTT_NOEXCEPT {
|
||||
return current == state::REJECTED;
|
||||
return current == state::rejected;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,12 +227,12 @@ public:
|
||||
*/
|
||||
void tick(const Delta delta, void *data = nullptr) {
|
||||
switch(current) {
|
||||
case state::UNINITIALIZED:
|
||||
next(std::integral_constant<state, state::UNINITIALIZED>{});
|
||||
current = state::RUNNING;
|
||||
case state::uninitialized:
|
||||
next(std::integral_constant<state, state::uninitialized>{});
|
||||
current = state::running;
|
||||
break;
|
||||
case state::RUNNING:
|
||||
next(std::integral_constant<state, state::RUNNING>{}, delta, data);
|
||||
case state::running:
|
||||
next(std::integral_constant<state, state::running>{}, delta, data);
|
||||
break;
|
||||
default:
|
||||
// suppress warnings
|
||||
@@ -240,17 +241,17 @@ public:
|
||||
|
||||
// if it's dead, it must be notified and removed immediately
|
||||
switch(current) {
|
||||
case state::SUCCEEDED:
|
||||
next(std::integral_constant<state, state::SUCCEEDED>{});
|
||||
current = state::FINISHED;
|
||||
case state::succeeded:
|
||||
next(std::integral_constant<state, state::succeeded>{});
|
||||
current = state::finished;
|
||||
break;
|
||||
case state::FAILED:
|
||||
next(std::integral_constant<state, state::FAILED>{});
|
||||
current = state::REJECTED;
|
||||
case state::failed:
|
||||
next(std::integral_constant<state, state::failed>{});
|
||||
current = state::rejected;
|
||||
break;
|
||||
case state::ABORTED:
|
||||
next(std::integral_constant<state, state::ABORTED>{});
|
||||
current = state::REJECTED;
|
||||
case state::aborted:
|
||||
next(std::integral_constant<state, state::aborted>{});
|
||||
current = state::rejected;
|
||||
break;
|
||||
default:
|
||||
// suppress warnings
|
||||
@@ -259,7 +260,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
state current{state::UNINITIALIZED};
|
||||
state current{state::uninitialized};
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user