Skip to content

Commit

Permalink
meta: meta_any vtable cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Nov 6, 2024
1 parent afb6bfc commit a217be7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/entt/meta/meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ using meta_any_policy [[deprecated("use any_policy instead")]] = any_policy;

/*! @brief Opaque wrapper for values of any type. */
class meta_any {
using vtable_type = void(const internal::meta_traits op, const bool, const meta_any &, void *);
using vtable_type = void(const internal::meta_traits op, const meta_any &, void *);

template<typename Type>
static void basic_vtable([[maybe_unused]] const internal::meta_traits req, [[maybe_unused]] const bool const_only, [[maybe_unused]] const meta_any &self, [[maybe_unused]] void *other) {
static void basic_vtable([[maybe_unused]] const internal::meta_traits req, [[maybe_unused]] const meta_any &self, [[maybe_unused]] void *other) {
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_meta_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,14 +189,14 @@ class meta_any {
}

if constexpr(is_complete_v<meta_sequence_container_traits<Type>>) {
if(req == internal::meta_traits::is_meta_sequence_container) {
*static_cast<meta_sequence_container *>(other) = const_only ? 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(!!(req & internal::meta_traits::is_meta_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) {
*static_cast<meta_associative_container *>(other) = const_only ? meta_associative_container{*self.ctx, *static_cast<const Type *>(self.data())} : meta_associative_container{*self.ctx, *static_cast<Type *>(const_cast<void *>(self.data()))};
if(!!(req & internal::meta_traits::is_meta_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, *this, &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);
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, true, *this, &proxy);
vtable(internal::meta_traits::is_meta_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, *this, &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);
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, true, *this, &proxy);
vtable(internal::meta_traits::is_meta_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, true, *this, &ret);
vtable(internal::meta_traits::is_meta_pointer_like, *this, &ret);
return ret;
}

Expand Down

0 comments on commit a217be7

Please sign in to comment.