Просмотр исходного кода

meta: make meta_template_node context aware

Michele Caini 3 лет назад
Родитель
Сommit
9ee084fc40
2 измененных файлов с 8 добавлено и 6 удалено
  1. 4 2
      src/entt/meta/meta.hpp
  2. 4 4
      src/entt/meta/node.hpp

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

@@ -1129,7 +1129,8 @@ public:
      * @return The tag for the class template of the underlying type.
      */
     [[nodiscard]] inline meta_type template_type() const noexcept {
-        return node.templ.type ? meta_type{node.templ.type()} : meta_type{};
+        const auto &ctx_TODO = internal::meta_context::from(locator<meta_ctx>::value_or());
+        return node.templ.type ? meta_type{node.templ.type(ctx_TODO)} : meta_type{};
     }
 
     /**
@@ -1138,7 +1139,8 @@ public:
      * @return The type of the i-th template argument of a type.
      */
     [[nodiscard]] inline meta_type template_arg(const size_type index) const noexcept {
-        return index < template_arity() ? meta_type{node.templ.arg(index)} : meta_type{};
+        const auto &ctx_TODO = internal::meta_context::from(locator<meta_ctx>::value_or());
+        return index < template_arity() ? meta_type{node.templ.arg(ctx_TODO, index)} : meta_type{};
     }
 
     /**

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

@@ -102,8 +102,8 @@ struct meta_template_node {
     using size_type = std::size_t;
 
     size_type arity{0u};
-    meta_type_node (*type)() noexcept {};
-    meta_type_node (*arg)(const size_type) noexcept {};
+    meta_type_node (*type)(const meta_context &) noexcept {};
+    meta_type_node (*arg)(const meta_context &, const size_type) noexcept {};
 };
 
 struct meta_type_descriptor {
@@ -224,8 +224,8 @@ template<typename Type>
     if constexpr(is_complete_v<meta_template_traits<Type>>) {
         node.templ = meta_template_node{
             meta_template_traits<Type>::args_type::size,
-            &resolve_TODO<typename meta_template_traits<Type>::class_type>,
-            +[](const std::size_t index) noexcept { return meta_arg_node_TODO(typename meta_template_traits<Type>::args_type{}, index); }};
+            &resolve<typename meta_template_traits<Type>::class_type>,
+            +[](const meta_context &context, const std::size_t index) noexcept { return meta_arg_node(typename meta_template_traits<Type>::args_type{}, context, index); }};
     }
 
     return node;