Prechádzať zdrojové kódy

meta: get rid of meta_dtor_node

Michele Caini 5 rokov pred
rodič
commit
932e681d22

+ 5 - 9
src/entt/meta/factory.hpp

@@ -540,18 +540,14 @@ public:
         static_assert(std::is_invocable_v<decltype(Func), Type &>, "The function doesn't accept an object of the type provided");
         auto * const type = internal::meta_info<Type>::resolve();
 
-        static internal::meta_dtor_node node{
-            type,
-            [](void *instance) {
-                if(instance) {
-                    std::invoke(Func, *static_cast<Type *>(instance));
-                }
+        ENTT_ASSERT(!type->dtor);
+
+        type->dtor = [](void *instance) {
+            if(instance) {
+                std::invoke(Func, *static_cast<Type *>(instance));
             }
         };
 
-        ENTT_ASSERT(!type->dtor);
-        type->dtor = &node;
-
         return meta_factory<Type>{};
     }
 

+ 1 - 7
src/entt/meta/internal.hpp

@@ -228,12 +228,6 @@ struct meta_ctor_node {
 };
 
 
-struct meta_dtor_node {
-    meta_type_node * const parent;
-    void(* const invoke)(void *);
-};
-
-
 struct meta_data_node {
     id_type id;
     meta_type_node * const parent;
@@ -289,9 +283,9 @@ struct meta_type_node {
     meta_base_node *base{nullptr};
     meta_conv_node *conv{nullptr};
     meta_ctor_node *ctor{nullptr};
-    meta_dtor_node *dtor{nullptr};
     meta_data_node *data{nullptr};
     meta_func_node *func{nullptr};
+    void(* dtor)(void *){nullptr};
 };
 
 

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

@@ -294,7 +294,7 @@ public:
     /*! @brief Frees the internal storage, whatever it means. */
     ~meta_any() {
         if(node && node->dtor) {
-            node->dtor->invoke(storage.data());
+            node->dtor(storage.data());
         }
     }