Selaa lähdekoodia

meta: make meta_ctor_node and meta_func_node partially context aware

Michele Caini 3 vuotta sitten
vanhempi
commit
e7762980ec
3 muutettua tiedostoa jossa 13 lisäystä ja 10 poistoa
  1. 4 4
      src/entt/meta/factory.hpp
  2. 6 3
      src/entt/meta/meta.hpp
  3. 3 3
      src/entt/meta/node.hpp

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

@@ -241,7 +241,7 @@ public:
             type_id<typename descriptor::args_type>().hash(),
             internal::meta_ctor_node{
                 descriptor::args_type::size,
-                &meta_arg_TODO<typename descriptor::args_type>,
+                &meta_arg<typename descriptor::args_type>,
                 &meta_construct<Type, Candidate, Policy>});
 
         bucket = nullptr;
@@ -267,7 +267,7 @@ public:
             type_id<typename descriptor::args_type>().hash(),
             internal::meta_ctor_node{
                 descriptor::args_type::size,
-                &meta_arg_TODO<typename descriptor::args_type>,
+                &meta_arg<typename descriptor::args_type>,
                 &meta_construct<Type, Args...>});
 
         bucket = nullptr;
@@ -463,8 +463,8 @@ public:
             internal::meta_func_node{
                 (descriptor::is_const ? internal::meta_traits::is_const : internal::meta_traits::is_none) | (descriptor::is_static ? internal::meta_traits::is_static : internal::meta_traits::is_none),
                 descriptor::args_type::size,
-                &internal::resolve_TODO<std::conditional_t<std::is_same_v<Policy, as_void_t>, void, std::remove_cv_t<std::remove_reference_t<typename descriptor::return_type>>>>,
-                &meta_arg_TODO<typename descriptor::args_type>,
+                &internal::resolve<std::conditional_t<std::is_same_v<Policy, as_void_t>, void, std::remove_cv_t<std::remove_reference_t<typename descriptor::return_type>>>>,
+                &meta_arg<typename descriptor::args_type>,
                 &meta_invoke<Type, Candidate, Policy>});
 
         bucket = &elem.prop;

+ 6 - 3
src/entt/meta/meta.hpp

@@ -926,7 +926,8 @@ class meta_type {
 
                 for(; pos < sz && args[pos]; ++pos) {
                     const auto type = args[pos].type();
-                    const auto other = curr->arg(pos);
+                    const auto &ctx_TODO = locator<meta_ctx>::value_or();
+                    const auto other = curr->arg(pos, ctx_TODO);
 
                     if(const auto &info = other.info(); info == type.info()) {
                         ++match;
@@ -1488,11 +1489,13 @@ inline bool meta_any::assign(meta_any &&other) {
 }
 
 [[nodiscard]] inline meta_type meta_func::ret() const noexcept {
-    return node->ret();
+    const auto &ctx_TODO = internal::meta_context::from(locator<meta_ctx>::value_or());
+    return node->ret(ctx_TODO);
 }
 
 [[nodiscard]] inline meta_type meta_func::arg(const size_type index) const noexcept {
-    return index < arity() ? node->arg(index) : meta_type{};
+    const auto &ctx_TODO = locator<meta_ctx>::value_or();
+    return index < arity() ? node->arg(index, ctx_TODO) : meta_type{};
 }
 
 /**

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

@@ -66,7 +66,7 @@ struct meta_ctor_node {
     using size_type = std::size_t;
 
     size_type arity{0u};
-    meta_type (*arg)(const size_type) noexcept {};
+    meta_type (*arg)(const size_type, const meta_ctx &) noexcept {};
     meta_any (*invoke)(meta_any *const){};
 };
 
@@ -91,8 +91,8 @@ struct meta_func_node {
 
     meta_traits traits{meta_traits::is_none};
     size_type arity{0u};
-    meta_type_node (*ret)() noexcept {};
-    meta_type (*arg)(const size_type) noexcept {};
+    meta_type_node (*ret)(const meta_context &) noexcept {};
+    meta_type (*arg)(const size_type, const meta_ctx &) noexcept {};
     meta_any (*invoke)(meta_handle, meta_any *const){};
     std::shared_ptr<meta_func_node> next{};
     dense_map<id_type, meta_prop_node, identity> prop{};