Selaa lähdekoodia

meta: further refine meta_type_node to make it context aware

Michele Caini 3 vuotta sitten
vanhempi
commit
a3f66387b2
2 muutettua tiedostoa jossa 5 lisäystä ja 4 poistoa
  1. 3 2
      src/entt/meta/meta.hpp
  2. 2 2
      src/entt/meta/node.hpp

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

@@ -656,8 +656,9 @@ struct meta_prop {
      * @return A wrapper containing the value stored with the property.
      * @return A wrapper containing the value stored with the property.
      */
      */
     [[nodiscard]] meta_any value() const {
     [[nodiscard]] meta_any value() const {
-        const auto &context_TODO = internal::meta_context::from(locator<meta_ctx>::value_or());
-        return node->value ? node->type(context_TODO).from_void(nullptr, node->value.get()) : meta_any{};
+        const auto &ctx = locator<meta_ctx>::value_or();
+        const auto &context_TODO = internal::meta_context::from(ctx);
+        return node->value ? node->type(context_TODO).from_void(nullptr, node->value.get(), ctx) : meta_any{};
     }
     }
 
 
     /**
     /**

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

@@ -125,7 +125,7 @@ struct meta_type_node {
     meta_type_node (*remove_pointer)(const meta_context &) noexcept {};
     meta_type_node (*remove_pointer)(const meta_context &) noexcept {};
     meta_any (*default_constructor)(const meta_ctx &){};
     meta_any (*default_constructor)(const meta_ctx &){};
     double (*conversion_helper)(void *, const void *){};
     double (*conversion_helper)(void *, const void *){};
-    meta_any (*from_void)(void *, const void *){};
+    meta_any (*from_void)(void *, const void *, const meta_ctx &){};
     meta_template_node templ{};
     meta_template_node templ{};
     meta_dtor_node dtor{};
     meta_dtor_node dtor{};
     std::shared_ptr<meta_type_descriptor> details{};
     std::shared_ptr<meta_type_descriptor> details{};
@@ -209,7 +209,7 @@ template<typename Type>
     }
     }
 
 
     if constexpr(!std::is_same_v<Type, void> && !std::is_function_v<Type>) {
     if constexpr(!std::is_same_v<Type, void> && !std::is_function_v<Type>) {
-        node.from_void = +[](void *element, const void *as_const) {
+        node.from_void = +[](void *element, const void *as_const, const meta_ctx &ctx_TODO) {
             if(element) {
             if(element) {
                 return meta_any{std::in_place_type<std::decay_t<Type> &>, *static_cast<std::decay_t<Type> *>(element)};
                 return meta_any{std::in_place_type<std::decay_t<Type> &>, *static_cast<std::decay_t<Type> *>(element)};
             }
             }