Browse Source

meta: self contained meta_factory, prepare to deprecate meta<T>

Michele Caini 1 year ago
parent
commit
f330c305bb
1 changed files with 9 additions and 10 deletions
  1. 9 10
      src/entt/meta/factory.hpp

+ 9 - 10
src/entt/meta/factory.hpp

@@ -119,17 +119,16 @@ protected:
     }
     }
 
 
 public:
 public:
-    basic_meta_factory(const id_type id, meta_ctx &area)
+    basic_meta_factory(meta_ctx &area, meta_type_node node)
         : ctx{&area},
         : ctx{&area},
-          parent{id},
-          bucket{id} {
-        auto &&elem = meta_context::from(*ctx).value[parent];
-
-        if(!elem.details) {
-            elem.details = std::make_shared<meta_type_descriptor>();
+          parent{node.info->hash()},
+          bucket{parent} {
+        if(!node.details) {
+            node.details = std::make_shared<meta_type_descriptor>();
         }
         }
 
 
-        details = elem.details.get();
+        details = node.details.get();
+        meta_context::from(*ctx).value.try_emplace(parent, std::move(node));
     }
     }
 
 
 private:
 private:
@@ -172,14 +171,14 @@ class meta_factory: private internal::basic_meta_factory {
 public:
 public:
     /*! @brief Default constructor. */
     /*! @brief Default constructor. */
     meta_factory() noexcept
     meta_factory() noexcept
-        : internal::basic_meta_factory{type_id<Type>().hash(), locator<meta_ctx>::value_or()} {}
+        : meta_factory{locator<meta_ctx>::value_or()} {}
 
 
     /**
     /**
      * @brief Context aware constructor.
      * @brief Context aware constructor.
      * @param area The context into which to construct meta types.
      * @param area The context into which to construct meta types.
      */
      */
     meta_factory(meta_ctx &area) noexcept
     meta_factory(meta_ctx &area) noexcept
-        : internal::basic_meta_factory{type_id<Type>().hash(), area} {}
+        : base_type{area, internal::resolve<Type>(internal::meta_context::from(area))} {}
 
 
     /**
     /**
      * @brief Assigns a custom unique identifier to a meta type.
      * @brief Assigns a custom unique identifier to a meta type.