Skip to content

Commit

Permalink
meta: internal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Nov 6, 2024
1 parent a217be7 commit 0177383
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions natvis/entt/meta.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@
<Item Name="[is_enum]">has_trait(entt::internal::meta_traits::is_enum)</Item>
<Item Name="[is_class]">has_trait(entt::internal::meta_traits::is_class)</Item>
<Item Name="[is_pointer]">has_trait(entt::internal::meta_traits::is_pointer)</Item>
<Item Name="[is_meta_pointer_like]">has_trait(entt::internal::meta_traits::is_meta_pointer_like)</Item>
<Item Name="[is_meta_sequence_container]">has_trait(entt::internal::meta_traits::is_meta_sequence_container)</Item>
<Item Name="[is_meta_associative_container]">has_trait(entt::internal::meta_traits::is_meta_associative_container)</Item>
<Item Name="[is_pointer_like]">has_trait(entt::internal::meta_traits::is_pointer_like)</Item>
<Item Name="[is_sequence_container]">has_trait(entt::internal::meta_traits::is_sequence_container)</Item>
<Item Name="[is_associative_container]">has_trait(entt::internal::meta_traits::is_associative_container)</Item>
<Item Name="[default_constructor]">default_constructor != nullptr</Item>
<Item Name="[conversion_helper]">conversion_helper != nullptr</Item>
<Item Name="[from_void]">from_void != nullptr</Item>
Expand Down
22 changes: 11 additions & 11 deletions src/entt/meta/meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class meta_any {
static_assert(std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, Type>, "Invalid type");

if constexpr(is_meta_pointer_like_v<Type>) {
if(!!(req & internal::meta_traits::is_meta_pointer_like)) {
if(!!(req & internal::meta_traits::is_pointer_like)) {
if constexpr(std::is_function_v<typename std::pointer_traits<Type>::element_type>) {
static_cast<meta_any *>(other)->emplace<Type>(*static_cast<const Type *>(self.data()));
} else if constexpr(!std::is_void_v<std::remove_const_t<typename std::pointer_traits<Type>::element_type>>) {
Expand All @@ -189,13 +189,13 @@ class meta_any {
}

if constexpr(is_complete_v<meta_sequence_container_traits<Type>>) {
if(!!(req & internal::meta_traits::is_meta_sequence_container)) {
if(!!(req & internal::meta_traits::is_sequence_container)) {
*static_cast<meta_sequence_container *>(other) = !!(req & internal::meta_traits::is_const) ? meta_sequence_container{*self.ctx, *static_cast<const Type *>(self.data())} : meta_sequence_container{*self.ctx, *static_cast<Type *>(const_cast<void *>(self.data()))};
}
}

if constexpr(is_complete_v<meta_associative_container_traits<Type>>) {
if(!!(req & internal::meta_traits::is_meta_associative_container)) {
if(!!(req & internal::meta_traits::is_associative_container)) {
*static_cast<meta_associative_container *>(other) = !!(req & internal::meta_traits::is_const) ? meta_associative_container{*self.ctx, *static_cast<const Type *>(self.data())} : meta_associative_container{*self.ctx, *static_cast<Type *>(const_cast<void *>(self.data()))};
}
}
Expand Down Expand Up @@ -526,14 +526,14 @@ class meta_any {
*/
[[nodiscard]] meta_sequence_container as_sequence_container() noexcept {
meta_sequence_container proxy{};
vtable(internal::meta_traits::is_meta_sequence_container | (storage.policy() == any_policy::cref ? internal::meta_traits::is_const : internal::meta_traits::is_none), *this, &proxy);
vtable(internal::meta_traits::is_sequence_container | (storage.policy() == any_policy::cref ? internal::meta_traits::is_const : internal::meta_traits::is_none), *this, &proxy);
return proxy;
}

/*! @copydoc as_sequence_container */
[[nodiscard]] meta_sequence_container as_sequence_container() const noexcept {
meta_sequence_container proxy{};
vtable(internal::meta_traits::is_meta_sequence_container | internal::meta_traits::is_const, *this, &proxy);
vtable(internal::meta_traits::is_sequence_container | internal::meta_traits::is_const, *this, &proxy);
return proxy;
}

Expand All @@ -543,14 +543,14 @@ class meta_any {
*/
[[nodiscard]] meta_associative_container as_associative_container() noexcept {
meta_associative_container proxy{};
vtable(internal::meta_traits::is_meta_associative_container | (storage.policy() == any_policy::cref ? internal::meta_traits::is_const : internal::meta_traits::is_none), *this, &proxy);
vtable(internal::meta_traits::is_associative_container | (storage.policy() == any_policy::cref ? internal::meta_traits::is_const : internal::meta_traits::is_none), *this, &proxy);
return proxy;
}

/*! @copydoc as_associative_container */
[[nodiscard]] meta_associative_container as_associative_container() const noexcept {
meta_associative_container proxy{};
vtable(internal::meta_traits::is_meta_associative_container | internal::meta_traits::is_const, *this, &proxy);
vtable(internal::meta_traits::is_associative_container | internal::meta_traits::is_const, *this, &proxy);
return proxy;
}

Expand All @@ -561,7 +561,7 @@ class meta_any {
*/
[[nodiscard]] meta_any operator*() const noexcept {
meta_any ret{meta_ctx_arg, *ctx};
vtable(internal::meta_traits::is_meta_pointer_like, *this, &ret);
vtable(internal::meta_traits::is_pointer_like, *this, &ret);
return ret;
}

Expand Down Expand Up @@ -1219,23 +1219,23 @@ class meta_type {
* @return True if the underlying type is pointer-like, false otherwise.
*/
[[nodiscard]] bool is_pointer_like() const noexcept {
return static_cast<bool>(node.traits & internal::meta_traits::is_meta_pointer_like);
return static_cast<bool>(node.traits & internal::meta_traits::is_pointer_like);
}

/**
* @brief Checks whether a type refers to a sequence container or not.
* @return True if the type is a sequence container, false otherwise.
*/
[[nodiscard]] bool is_sequence_container() const noexcept {
return static_cast<bool>(node.traits & internal::meta_traits::is_meta_sequence_container);
return static_cast<bool>(node.traits & internal::meta_traits::is_sequence_container);
}

/**
* @brief Checks whether a type refers to an associative container or not.
* @return True if the type is an associative container, false otherwise.
*/
[[nodiscard]] bool is_associative_container() const noexcept {
return static_cast<bool>(node.traits & internal::meta_traits::is_meta_associative_container);
return static_cast<bool>(node.traits & internal::meta_traits::is_associative_container);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/entt/meta/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ enum class meta_traits : std::uint32_t {
is_enum = 0x0040,
is_class = 0x0080,
is_pointer = 0x0100,
is_meta_pointer_like = 0x0200,
is_meta_sequence_container = 0x0400,
is_meta_associative_container = 0x0800,
is_pointer_like = 0x0200,
is_sequence_container = 0x0400,
is_associative_container = 0x0800,
_user_defined_traits = 0xFFFF,
_entt_enum_as_bitmask = 0xFFFF
};
Expand Down Expand Up @@ -264,9 +264,9 @@ template<typename Type>
| (std::is_enum_v<Type> ? meta_traits::is_enum : meta_traits::is_none)
| (std::is_class_v<Type> ? meta_traits::is_class : meta_traits::is_none)
| (std::is_pointer_v<Type> ? meta_traits::is_pointer : meta_traits::is_none)
| (is_meta_pointer_like_v<Type> ? meta_traits::is_meta_pointer_like : meta_traits::is_none)
| (is_complete_v<meta_sequence_container_traits<Type>> ? meta_traits::is_meta_sequence_container : meta_traits::is_none)
| (is_complete_v<meta_associative_container_traits<Type>> ? meta_traits::is_meta_associative_container : meta_traits::is_none),
| (is_meta_pointer_like_v<Type> ? meta_traits::is_pointer_like : meta_traits::is_none)
| (is_complete_v<meta_sequence_container_traits<Type>> ? meta_traits::is_sequence_container : meta_traits::is_none)
| (is_complete_v<meta_associative_container_traits<Type>> ? meta_traits::is_associative_container : meta_traits::is_none),
size_of_v<Type>,
&resolve<Type>,
&resolve<std::remove_cv_t<std::remove_pointer_t<Type>>>};
Expand Down

0 comments on commit 0177383

Please sign in to comment.