ソースを参照

meta: internal changes

Michele Caini 1 年間 前
コミット
27f7e43b05
3 ファイル変更11 行追加7 行削除
  1. 2 2
      src/entt/meta/meta.hpp
  2. 5 5
      src/entt/meta/node.hpp
  3. 4 0
      src/entt/meta/range.hpp

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

@@ -1180,7 +1180,7 @@ class meta_type {
 
                         if(!can_continue && type.node.details) {
                             for(std::size_t idx{}, last = type.node.details->base.size(); !can_continue && idx != last; ++idx) {
-                                can_continue = (type.node.details->base[idx].id == info.hash());
+                                can_continue = (type.node.details->base[idx].type == info.hash());
                             }
 
                             for(std::size_t idx{}, last = type.node.details->conv.size(); !can_continue && idx != last; ++idx) {
@@ -1240,7 +1240,7 @@ public:
      * @param curr The underlying node with which to construct the instance.
      */
     meta_type(const meta_ctx &area, const internal::meta_base_node &curr) noexcept
-        : meta_type{area, curr.type(internal::meta_context::from(area))} {}
+        : meta_type{area, curr.resolve(internal::meta_context::from(area))} {}
 
     /**
      * @brief Returns the type info object of the underlying type.

+ 5 - 5
src/entt/meta/node.hpp

@@ -74,8 +74,8 @@ struct meta_prop_node {
 };
 
 struct meta_base_node {
-    id_type id{};
-    meta_type_node (*type)(const meta_context &) noexcept {};
+    id_type type{};
+    meta_type_node (*resolve)(const meta_context &) noexcept {};
     const void *(*cast)(const void *) noexcept {};
 };
 
@@ -170,7 +170,7 @@ auto *look_for(const meta_context &context, const meta_type_node &node, const id
         }
 
         for(auto &&curr: node.details->base) {
-            if(auto *elem = look_for<Member>(context, curr.type(context), id); elem) {
+            if(auto *elem = look_for<Member>(context, curr.resolve(context), id); elem) {
                 return elem;
             }
         }
@@ -198,7 +198,7 @@ template<typename... Args>
 
     if(from.details) {
         for(auto &&curr: from.details->base) {
-            if(const void *elem = try_cast(context, curr.type(context), to, curr.cast(instance)); elem) {
+            if(const void *elem = try_cast(context, curr.resolve(context), to, curr.cast(instance)); elem) {
                 return elem;
             }
         }
@@ -221,7 +221,7 @@ template<typename Func>
         }
 
         for(auto &&curr: from.details->base) {
-            if(auto other = try_convert(context, curr.type(context), to, arithmetic_or_enum, curr.cast(instance), func); other) {
+            if(auto other = try_convert(context, curr.resolve(context), to, arithmetic_or_enum, curr.cast(instance), func); other) {
                 return other;
             }
         }

+ 4 - 0
src/entt/meta/range.hpp

@@ -13,6 +13,8 @@ namespace entt {
 /*! @cond TURN_OFF_DOXYGEN */
 namespace internal {
 
+struct meta_base_node;
+
 template<typename Type, typename It>
 struct meta_range_iterator final {
     using value_type = std::pair<id_type, Type>;
@@ -69,6 +71,8 @@ struct meta_range_iterator final {
     [[nodiscard]] constexpr reference operator[](const difference_type value) const noexcept {
         if constexpr(std::is_same_v<It, typename decltype(meta_context::value)::const_iterator>) {
             return {it[value].first, Type{*ctx, it[value].second}};
+        } else if constexpr(std::is_same_v<typename std::iterator_traits<It>::value_type, meta_base_node>) {
+            return {it[value].type, Type{*ctx, it[value]}};
         } else {
             return {it[value].id, Type{*ctx, it[value]}};
         }