1
0
Эх сурвалжийг харах

meta: reduce indirection for meta_prop

Michele Caini 1 жил өмнө
parent
commit
a4a87995af
2 өөрчлөгдсөн 8 нэмэгдсэн , 8 устгасан
  1. 1 1
      TODO
  2. 7 7
      src/entt/meta/meta.hpp

+ 1 - 1
TODO

@@ -32,7 +32,7 @@ TODO:
 * cleanup common view from tricks to handle single swap-only and in-place, if constexpr branches
 * entity based component_traits
 * review cmake warning about FetchContent_Populate (need .28 and EXCLUDE_FROM_ALL for FetchContent)
-* make meta objects safe to use with null nodes
+* after removing meta prop vectors, copy meta objects in their handles directly
 * suppress -Wself-move on CI with g++13
 * view and view iterator specializations for multi, single and filtered elements
 * organizer support to groups

+ 7 - 7
src/entt/meta/meta.hpp

@@ -774,8 +774,8 @@ struct [[deprecated("use meta_custom instead")]] meta_prop {
      * @param area The context from which to search for meta types.
      * @param curr The underlying node with which to construct the instance.
      */
-    meta_prop(const meta_ctx &area, const internal::meta_prop_node &curr) noexcept
-        : node{&curr},
+    meta_prop(const meta_ctx &area, internal::meta_prop_node curr) noexcept
+        : node{curr},
           ctx{&area} {}
 
     /**
@@ -783,7 +783,7 @@ struct [[deprecated("use meta_custom instead")]] meta_prop {
      * @return A wrapper containing the value stored with the property.
      */
     [[nodiscard]] meta_any value() const {
-        return node->value ? node->type(internal::meta_context::from(*ctx)).from_void(*ctx, nullptr, node->value.get()) : meta_any{meta_ctx_arg, *ctx};
+        return node.value ? node.type(internal::meta_context::from(*ctx)).from_void(*ctx, nullptr, node.value.get()) : meta_any{meta_ctx_arg, *ctx};
     }
 
     /**
@@ -791,7 +791,7 @@ struct [[deprecated("use meta_custom instead")]] meta_prop {
      * @return A wrapper containing the value stored with the property.
      */
     [[nodiscard]] meta_any value() {
-        return node->value ? node->type(internal::meta_context::from(*ctx)).from_void(*ctx, node->value.get(), nullptr) : meta_any{meta_ctx_arg, *ctx};
+        return node.value ? node.type(internal::meta_context::from(*ctx)).from_void(*ctx, node.value.get(), nullptr) : meta_any{meta_ctx_arg, *ctx};
     }
 
     /**
@@ -799,7 +799,7 @@ struct [[deprecated("use meta_custom instead")]] meta_prop {
      * @return True if the object is valid, false otherwise.
      */
     [[nodiscard]] explicit operator bool() const noexcept {
-        return (node != nullptr);
+        return static_cast<bool>(node.type);
     }
 
     /**
@@ -808,11 +808,11 @@ struct [[deprecated("use meta_custom instead")]] meta_prop {
      * @return True if the objects refer to the same type, false otherwise.
      */
     [[nodiscard]] bool operator==(const meta_prop &other) const noexcept {
-        return (ctx == other.ctx && node == other.node);
+        return (ctx == other.ctx && node.value == other.node.value);
     }
 
 private:
-    const internal::meta_prop_node *node{};
+    internal::meta_prop_node node{};
     const meta_ctx *ctx{};
 };