Ver Fonte

meta: make meta_ctor_node context aware

Michele Caini há 3 anos atrás
pai
commit
f50a03dcb4
3 ficheiros alterados com 12 adições e 5 exclusões
  1. 1 1
      src/entt/meta/factory.hpp
  2. 7 2
      src/entt/meta/meta.hpp
  3. 4 2
      src/entt/meta/node.hpp

+ 1 - 1
src/entt/meta/factory.hpp

@@ -155,7 +155,7 @@ public:
             *info,
             type_id<Base>().hash(),
             internal::meta_base_node{
-                &internal::resolve_TODO<Base>,
+                &internal::resolve<Base>,
                 +[](const void *instance) noexcept {
                     return static_cast<const void *>(static_cast<const Base *>(static_cast<const Type *>(instance)));
                 }});

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

@@ -987,7 +987,11 @@ public:
      * @param curr The base node with which to construct the instance.
      */
     meta_type(const internal::meta_base_node &curr) noexcept
-        : meta_type{curr.type ? curr.type() : meta_type{}} {}
+        : meta_type{} {
+        if(const auto &ctx_TODO = internal::meta_context::from(locator<meta_ctx>::value_or()); curr.type) {
+            node = curr.type(ctx_TODO);
+        }
+    }
 
     /**
      * @brief Returns the type info object of the underlying type.
@@ -1441,7 +1445,8 @@ bool meta_any::set(const id_type id, Type &&value) {
 
     if(const auto *value = data(); node.details) {
         for(auto &&curr: node.details->base) {
-            const auto &as_const = curr.second.type().from_void(nullptr, curr.second.cast(value));
+            const auto &ctx_TODO = internal::meta_context::from(locator<meta_ctx>::value_or());
+            const auto &as_const = curr.second.type(ctx_TODO).from_void(nullptr, curr.second.cast(value));
 
             if(auto other = as_const.allow_cast(type); other) {
                 return other;

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

@@ -54,7 +54,7 @@ struct meta_prop_node {
 };
 
 struct meta_base_node {
-    meta_type_node (*type)() noexcept {};
+    meta_type_node (*type)(const meta_context &) noexcept {};
     const void *(*cast)(const void *) noexcept {};
 };
 
@@ -154,8 +154,10 @@ template<typename... Args>
     }
 
     if(from.details) {
+        const auto &ctx_TODO = meta_context::from(locator<meta_ctx>::value_or());
+
         for(auto &&curr: from.details->base) {
-            if(const void *elem = try_cast(curr.second.type(), to, curr.second.cast(instance)); elem) {
+            if(const void *elem = try_cast(curr.second.type(ctx_TODO), to, curr.second.cast(instance)); elem) {
                 return elem;
             }
         }