skypjack 5 месяцев назад
Родитель
Сommit
9347e91db6
4 измененных файлов с 9 добавлено и 8 удалено
  1. 2 1
      src/entt/meta/context.hpp
  2. 4 4
      src/entt/meta/factory.hpp
  3. 2 2
      src/entt/meta/node.hpp
  4. 1 1
      src/entt/meta/range.hpp

+ 2 - 1
src/entt/meta/context.hpp

@@ -1,6 +1,7 @@
 #ifndef ENTT_META_CTX_HPP
 #define ENTT_META_CTX_HPP
 
+#include <memory>
 #include "../container/dense_map.hpp"
 #include "../core/fwd.hpp"
 #include "../core/utility.hpp"
@@ -14,7 +15,7 @@ namespace internal {
 struct meta_type_node;
 
 struct meta_context {
-    dense_map<id_type, meta_type_node, identity> value;
+    dense_map<id_type, std::unique_ptr<meta_type_node>, identity> value;
 
     [[nodiscard]] inline static meta_context &from(meta_ctx &ctx);
     [[nodiscard]] inline static const meta_context &from(const meta_ctx &ctx);

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

@@ -33,7 +33,7 @@ class basic_meta_factory {
     using invoke_type = std::remove_pointer_t<decltype(meta_func_node::invoke)>;
 
     [[nodiscard]] auto &fetch_node() noexcept {
-        return meta_context::from(*ctx).value[parent];
+        return *meta_context::from(*ctx).value[parent];
     }
 
     [[nodiscard]] auto *find_member_or_assert() {
@@ -131,8 +131,8 @@ public:
         : ctx{&area},
           parent{node.info->hash()},
           bucket{parent} {
-        if(auto &curr = meta_context::from(*ctx).value.try_emplace(parent, std::move(node)).first->second; curr.details == nullptr) {
-            curr.details = std::make_shared<meta_type_descriptor>();
+        if(auto *curr = meta_context::from(*ctx).value.try_emplace(parent, std::make_unique<meta_type_node>(std::move(node))).first->second.get(); curr->details == nullptr) {
+            curr->details = std::make_unique<meta_type_descriptor>();
         }
     }
 
@@ -513,7 +513,7 @@ inline void meta_reset(meta_ctx &ctx, const id_type id) noexcept {
     auto &&context = internal::meta_context::from(ctx);
 
     for(auto it = context.value.begin(); it != context.value.end();) {
-        if(it->second.id == id) {
+        if(it->second->id == id) {
             it = context.value.erase(it);
         } else {
             ++it;

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

@@ -145,7 +145,7 @@ struct meta_type_node {
     double (*conversion_helper)(void *, const void *){};
     meta_any (*from_void)(const meta_ctx &, void *, const void *){};
     meta_template_node templ{};
-    std::shared_ptr<meta_type_descriptor> details;
+    std::unique_ptr<meta_type_descriptor> details;
 };
 
 template<auto Member, typename Type, typename Value>
@@ -302,7 +302,7 @@ auto setup_node_for() noexcept {
 
 [[nodiscard]] inline const meta_type_node *try_resolve(const meta_context &context, const type_info &info) noexcept {
     const auto it = context.value.find(info.hash());
-    return it != context.value.end() ? &it->second : nullptr;
+    return it != context.value.end() ? it->second.get() : nullptr;
 }
 
 template<typename Type>

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

@@ -70,7 +70,7 @@ struct meta_range_iterator final {
 
     [[nodiscard]] constexpr reference operator[](const difference_type value) const noexcept {
         if constexpr(std::is_same_v<It, typename decltype(meta_context::value)::const_iterator>) {
-            return {it[value].first, Type{*ctx, it[value].second}};
+            return {it[value].first, Type{*ctx, *it[value].second}};
         } else if constexpr(std::is_same_v<typename std::iterator_traits<It>::value_type, meta_base_node>) {
             return {it[value].type, Type{*ctx, it[value]}};
         } else {