Browse Source

meta: removed parent link from meta nodes

Michele Caini 4 years ago
parent
commit
ad61b0c84e

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

@@ -216,7 +216,6 @@ struct meta_factory<Type> {
         auto * const type = internal::meta_info<Type>::resolve();
 
         static internal::meta_base_node node{
-            type,
             nullptr,
             internal::meta_info<Base>::resolve(),
             [](const void *instance) ENTT_NOEXCEPT -> const void * {
@@ -250,7 +249,6 @@ struct meta_factory<Type> {
         auto * const type = internal::meta_info<Type>::resolve();
 
         static internal::meta_conv_node node{
-            type,
             nullptr,
             internal::meta_info<conv_type>::resolve(),
             [](const void *instance) -> meta_any {
@@ -273,7 +271,6 @@ struct meta_factory<Type> {
         auto * const type = internal::meta_info<Type>::resolve();
 
         static internal::meta_conv_node node{
-            type,
             nullptr,
             internal::meta_info<conv_type>::resolve(),
             [](const void *instance) -> meta_any {
@@ -304,7 +301,6 @@ struct meta_factory<Type> {
         auto * const type = internal::meta_info<Type>::resolve();
 
         static internal::meta_conv_node node{
-            type,
             nullptr,
             internal::meta_info<To>::resolve(),
             [](const void *instance) -> meta_any {
@@ -340,7 +336,6 @@ struct meta_factory<Type> {
         auto * const type = internal::meta_info<Type>::resolve();
 
         static internal::meta_ctor_node node{
-            type,
             nullptr,
             nullptr,
             descriptor::args_type::size,
@@ -372,7 +367,6 @@ struct meta_factory<Type> {
         auto * const type = internal::meta_info<Type>::resolve();
 
         static internal::meta_ctor_node node{
-            type,
             nullptr,
             nullptr,
             descriptor::args_type::size,
@@ -439,7 +433,6 @@ struct meta_factory<Type> {
 
             static internal::meta_data_node node{
                 {},
-                type,
                 nullptr,
                 nullptr,
                 std::is_same_v<Type, data_type> || std::is_const_v<data_type>,
@@ -488,7 +481,6 @@ struct meta_factory<Type> {
 
         static internal::meta_data_node node{
             {},
-            type,
             nullptr,
             nullptr,
             std::is_same_v<decltype(Setter), std::nullptr_t> || (std::is_member_object_pointer_v<decltype(Setter)> && std::is_const_v<underlying_type>),
@@ -529,7 +521,6 @@ struct meta_factory<Type> {
 
         static internal::meta_func_node node{
             {},
-            type,
             nullptr,
             nullptr,
             descriptor::args_type::size,

+ 0 - 27
src/entt/meta/meta.hpp

@@ -730,12 +730,6 @@ struct meta_ctor {
         : node{curr}
     {}
 
-    /**
-     * @brief Returns the type to which an object belongs.
-     * @return The type to which the object belongs.
-     */
-    [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT;
-
     /**
      * @brief Returns the number of arguments accepted by a constructor.
      * @return The number of arguments accepted by the constructor.
@@ -831,9 +825,6 @@ struct meta_data {
         return node->id;
     }
 
-    /*! @copydoc meta_ctor::parent */
-    [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT;
-
     /**
      * @brief Indicates whether a data member is constant or not.
      * @return True if the data member is constant, false otherwise.
@@ -935,9 +926,6 @@ struct meta_func {
         return node->id;
     }
 
-    /*! @copydoc meta_ctor::parent */
-    [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT;
-
     /**
      * @brief Returns the number of arguments accepted by a member function.
      * @return The number of arguments accepted by the member function.
@@ -1682,31 +1670,16 @@ inline bool meta_any::allow_cast(const meta_type &type) {
 }
 
 
-[[nodiscard]] inline meta_type meta_ctor::parent() const ENTT_NOEXCEPT {
-    return node->parent;
-}
-
-
 [[nodiscard]] inline meta_type meta_ctor::arg(const size_type index) const ENTT_NOEXCEPT {
     return index < arity() ? node->arg(index) : meta_type{};
 }
 
 
-[[nodiscard]] inline meta_type meta_data::parent() const ENTT_NOEXCEPT {
-    return node->parent;
-}
-
-
 [[nodiscard]] inline meta_type meta_data::type() const ENTT_NOEXCEPT {
     return node->type;
 }
 
 
-[[nodiscard]] inline meta_type meta_func::parent() const ENTT_NOEXCEPT {
-    return node->parent;
-}
-
-
 [[nodiscard]] inline meta_type meta_func::ret() const ENTT_NOEXCEPT {
     return node->ret;
 }

+ 0 - 6
src/entt/meta/node.hpp

@@ -41,7 +41,6 @@ struct meta_prop_node {
 
 
 struct meta_base_node {
-    meta_type_node * const parent;
     meta_base_node * next;
     meta_type_node * const type;
     const void *(* const cast)(const void *) ENTT_NOEXCEPT;
@@ -49,7 +48,6 @@ struct meta_base_node {
 
 
 struct meta_conv_node {
-    meta_type_node * const parent;
     meta_conv_node * next;
     meta_type_node * const type;
     meta_any(* const conv)(const void *);
@@ -58,7 +56,6 @@ struct meta_conv_node {
 
 struct meta_ctor_node {
     using size_type = std::size_t;
-    meta_type_node * const parent;
     meta_ctor_node * next;
     meta_prop_node * prop;
     const size_type arity;
@@ -69,7 +66,6 @@ struct meta_ctor_node {
 
 struct meta_data_node {
     id_type id;
-    meta_type_node * const parent;
     meta_data_node * next;
     meta_prop_node * prop;
     const bool is_const;
@@ -83,7 +79,6 @@ struct meta_data_node {
 struct meta_func_node {
     using size_type = std::size_t;
     id_type id;
-    meta_type_node * const parent;
     meta_func_node * next;
     meta_prop_node * prop;
     const size_type arity;
@@ -156,7 +151,6 @@ class ENTT_API meta_node {
     [[nodiscard]] static meta_ctor_node * meta_default_constructor([[maybe_unused]] meta_type_node *type) ENTT_NOEXCEPT {
         if constexpr(std::is_default_constructible_v<Type>) {
             static meta_ctor_node node{
-                type,
                 nullptr,
                 nullptr,
                 0u,

+ 0 - 3
test/entt/meta/meta_ctor.cpp

@@ -67,7 +67,6 @@ TEST_F(MetaCtor, Functionalities) {
     auto ctor = entt::resolve<clazz_t>().ctor<const int &, char>();
 
     ASSERT_TRUE(ctor);
-    ASSERT_EQ(ctor.parent(), entt::resolve("clazz"_hs));
     ASSERT_EQ(ctor.arity(), 2u);
     ASSERT_EQ(ctor.arg(0u), entt::resolve<int>());
     ASSERT_EQ(ctor.arg(1u), entt::resolve<char>());
@@ -102,7 +101,6 @@ TEST_F(MetaCtor, Func) {
     auto ctor = entt::resolve<clazz_t>().ctor<int>();
 
     ASSERT_TRUE(ctor);
-    ASSERT_EQ(ctor.parent(), entt::resolve("clazz"_hs));
     ASSERT_EQ(ctor.arity(), 1u);
     ASSERT_EQ(ctor.arg(0u), entt::resolve<int>());
     ASSERT_FALSE(ctor.arg(1u));
@@ -202,7 +200,6 @@ TEST_F(MetaCtor, ExternalMemberFunction) {
     auto ctor = entt::resolve<clazz_t>().ctor<entt::registry &, entt::entity, const int &, const char &>();
 
     ASSERT_TRUE(ctor);
-    ASSERT_EQ(ctor.parent(), entt::resolve("clazz"_hs));
     ASSERT_EQ(ctor.arity(), 4u);
     ASSERT_EQ(ctor.arg(0u), entt::resolve<entt::registry>());
     ASSERT_EQ(ctor.arg(1u), entt::resolve<entt::entity>());

+ 0 - 12
test/entt/meta/meta_data.cpp

@@ -131,7 +131,6 @@ TEST_F(MetaData, Functionalities) {
     clazz_t instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("clazz"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.id(), "i"_hs);
     ASSERT_FALSE(data.is_const());
@@ -162,7 +161,6 @@ TEST_F(MetaData, Const) {
     clazz_t instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("clazz"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.id(), "j"_hs);
     ASSERT_TRUE(data.is_const());
@@ -192,7 +190,6 @@ TEST_F(MetaData, Static) {
     auto data = entt::resolve<clazz_t>().data("h"_hs);
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("clazz"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.id(), "h"_hs);
     ASSERT_FALSE(data.is_const());
@@ -222,7 +219,6 @@ TEST_F(MetaData, ConstStatic) {
     auto data = entt::resolve<clazz_t>().data("k"_hs);
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("clazz"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.id(), "k"_hs);
     ASSERT_TRUE(data.is_const());
@@ -343,7 +339,6 @@ TEST_F(MetaData, SetterGetterAsFreeFunctions) {
     setter_getter_t instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.id(), "x"_hs);
     ASSERT_FALSE(data.is_const());
@@ -360,7 +355,6 @@ TEST_F(MetaData, SetterGetterAsMemberFunctions) {
     setter_getter_t instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.id(), "y"_hs);
     ASSERT_FALSE(data.is_const());
@@ -377,7 +371,6 @@ TEST_F(MetaData, SetterGetterWithRefAsMemberFunctions) {
     setter_getter_t instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.id(), "w"_hs);
     ASSERT_FALSE(data.is_const());
@@ -394,7 +387,6 @@ TEST_F(MetaData, SetterGetterMixed) {
     setter_getter_t instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.id(), "z"_hs);
     ASSERT_FALSE(data.is_const());
@@ -411,7 +403,6 @@ TEST_F(MetaData, SetterGetterReadOnly) {
     setter_getter_t instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.id(), "z_ro"_hs);
     ASSERT_TRUE(data.is_const());
@@ -428,7 +419,6 @@ TEST_F(MetaData, SetterGetterReadOnlyDataMember) {
     setter_getter_t instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.id(), "value"_hs);
     ASSERT_TRUE(data.is_const());
@@ -471,7 +461,6 @@ TEST_F(MetaData, ArrayStatic) {
     auto data = entt::resolve<array_t>().data("global"_hs);
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("array"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int[3]>());
     ASSERT_EQ(data.id(), "global"_hs);
     ASSERT_FALSE(data.is_const());
@@ -488,7 +477,6 @@ TEST_F(MetaData, Array) {
     array_t instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_EQ(data.parent(), entt::resolve("array"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int[5]>());
     ASSERT_EQ(data.id(), "local"_hs);
     ASSERT_FALSE(data.is_const());

+ 0 - 7
test/entt/meta/meta_func.cpp

@@ -109,7 +109,6 @@ TEST_F(MetaFunc, Functionalities) {
     func_t instance{};
 
     ASSERT_TRUE(func);
-    ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
     ASSERT_EQ(func.id(), "f2"_hs);
     ASSERT_EQ(func.arity(), 2u);
     ASSERT_FALSE(func.is_const());
@@ -150,7 +149,6 @@ TEST_F(MetaFunc, Const) {
     func_t instance{};
 
     ASSERT_TRUE(func);
-    ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
     ASSERT_EQ(func.id(), "f1"_hs);
     ASSERT_EQ(func.arity(), 1u);
     ASSERT_TRUE(func.is_const());
@@ -189,7 +187,6 @@ TEST_F(MetaFunc, RetVoid) {
     func_t instance{};
 
     ASSERT_TRUE(func);
-    ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
     ASSERT_EQ(func.id(), "g"_hs);
     ASSERT_EQ(func.arity(), 1u);
     ASSERT_FALSE(func.is_const());
@@ -226,7 +223,6 @@ TEST_F(MetaFunc, Static) {
     func_t::value = 2;
 
     ASSERT_TRUE(func);
-    ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
     ASSERT_EQ(func.id(), "h"_hs);
     ASSERT_EQ(func.arity(), 1u);
     ASSERT_FALSE(func.is_const());
@@ -264,7 +260,6 @@ TEST_F(MetaFunc, StaticRetVoid) {
     auto func = entt::resolve<func_t>().func("k"_hs);
 
     ASSERT_TRUE(func);
-    ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
     ASSERT_EQ(func.id(), "k"_hs);
     ASSERT_EQ(func.arity(), 1u);
     ASSERT_FALSE(func.is_const());
@@ -405,7 +400,6 @@ TEST_F(MetaFunc, FromBase) {
     derived_t instance{};
 
     ASSERT_TRUE(type.func("func"_hs));
-    ASSERT_EQ(type.func("func"_hs).parent(), entt::resolve<base_t>());
     ASSERT_EQ(instance.value, 3);
 
     type.func("func"_hs).invoke(instance, 42);
@@ -419,7 +413,6 @@ TEST_F(MetaFunc, ExternalMemberFunction) {
     auto func = entt::resolve<func_t>().func("emplace"_hs);
 
     ASSERT_TRUE(func);
-    ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
     ASSERT_EQ(func.id(), "emplace"_hs);
     ASSERT_EQ(func.arity(), 2u);
     ASSERT_FALSE(func.is_const());