Browse Source

meta: prepare migration to entt::type_id

Michele Caini 6 years ago
parent
commit
0f0aeb6d47
2 changed files with 12 additions and 92 deletions
  1. 12 78
      src/entt/meta/meta.hpp
  2. 0 14
      test/entt/meta/meta.cpp

+ 12 - 78
src/entt/meta/meta.hpp

@@ -699,32 +699,11 @@ struct meta_prop {
         return node;
     }
 
-    /**
-     * @brief Checks if two meta objects refer to the same node.
-     * @param other The meta object with which to compare.
-     * @return True if the two meta objects refer to the same node, false
-     * otherwise.
-     */
-    bool operator==(const meta_prop &other) const ENTT_NOEXCEPT {
-        return node == other.node;
-    }
-
 private:
     const internal::meta_prop_node *node;
 };
 
 
-/**
- * @brief Checks if two meta objects refer to the same node.
- * @param lhs A meta object, either valid or not.
- * @param rhs A meta object, either valid or not.
- * @return True if the two meta objects refer to the same node, false otherwise.
- */
-inline bool operator!=(const meta_prop &lhs, const meta_prop &rhs) ENTT_NOEXCEPT {
-    return !(lhs == rhs);
-}
-
-
 /*! @brief Opaque container for meta base classes. */
 struct meta_base {
     /*! @copydoc meta_prop::meta_prop */
@@ -758,22 +737,11 @@ struct meta_base {
         return node;
     }
 
-    /*! @copydoc meta_prop::operator== */
-    bool operator==(const meta_base &other) const ENTT_NOEXCEPT {
-        return node == other.node;
-    }
-
 private:
     const internal::meta_base_node *node;
 };
 
 
-/*! @copydoc operator!=(const meta_prop &, const meta_prop &) */
-inline bool operator!=(const meta_base &lhs, const meta_base &rhs) ENTT_NOEXCEPT {
-    return !(lhs == rhs);
-}
-
-
 /*! @brief Opaque container for meta conversion functions. */
 struct meta_conv {
     /*! @copydoc meta_prop::meta_prop */
@@ -804,22 +772,11 @@ struct meta_conv {
         return node;
     }
 
-    /*! @copydoc meta_prop::operator== */
-    bool operator==(const meta_conv &other) const ENTT_NOEXCEPT {
-        return node == other.node;
-    }
-
 private:
     const internal::meta_conv_node *node;
 };
 
 
-/*! @copydoc operator!=(const meta_prop &, const meta_prop &) */
-inline bool operator!=(const meta_conv &lhs, const meta_conv &rhs) ENTT_NOEXCEPT {
-    return !(lhs == rhs);
-}
-
-
 /*! @brief Opaque container for meta constructors. */
 struct meta_ctor {
     /*! @brief Unsigned integer type. */
@@ -899,22 +856,11 @@ struct meta_ctor {
         return node;
     }
 
-    /*! @copydoc meta_prop::operator== */
-    bool operator==(const meta_ctor &other) const ENTT_NOEXCEPT {
-        return node == other.node;
-    }
-
 private:
     const internal::meta_ctor_node *node;
 };
 
 
-/*! @copydoc operator!=(const meta_prop &, const meta_prop &) */
-inline bool operator!=(const meta_ctor &lhs, const meta_ctor &rhs) ENTT_NOEXCEPT {
-    return !(lhs == rhs);
-}
-
-
 /*! @brief Opaque container for meta data. */
 struct meta_data {
     /*! @copydoc meta_prop::meta_prop */
@@ -1047,22 +993,11 @@ struct meta_data {
         return node;
     }
 
-    /*! @copydoc meta_prop::operator== */
-    bool operator==(const meta_data &other) const ENTT_NOEXCEPT {
-        return node == other.node;
-    }
-
 private:
     const internal::meta_data_node *node;
 };
 
 
-/*! @copydoc operator!=(const meta_prop &, const meta_prop &) */
-inline bool operator!=(const meta_data &lhs, const meta_data &rhs) ENTT_NOEXCEPT {
-    return !(lhs == rhs);
-}
-
-
 /*! @brief Opaque container for meta functions. */
 struct meta_func {
     /*! @brief Unsigned integer type. */
@@ -1169,22 +1104,11 @@ struct meta_func {
         return node;
     }
 
-    /*! @copydoc meta_prop::operator== */
-    bool operator==(const meta_func &other) const ENTT_NOEXCEPT {
-        return node == other.node;
-    }
-
 private:
     const internal::meta_func_node *node;
 };
 
 
-/*! @copydoc operator!=(const meta_prop &, const meta_prop &) */
-inline bool operator!=(const meta_func &lhs, const meta_func &rhs) ENTT_NOEXCEPT {
-    return !(lhs == rhs);
-}
-
-
 /*! @brief Opaque container for meta types. */
 class meta_type {
     template<typename... Args, std::size_t... Indexes>
@@ -1528,7 +1452,12 @@ public:
         return node;
     }
 
-    /*! @copydoc meta_prop::operator== */
+    /**
+     * @brief Checks if two meta objects refer to the same type.
+     * @param other The meta object with which to compare.
+     * @return True if the two meta objects refer to the same type, false
+     * otherwise.
+     */
     bool operator==(const meta_type &other) const ENTT_NOEXCEPT {
         return node == other.node;
     }
@@ -1538,7 +1467,12 @@ private:
 };
 
 
-/*! @copydoc operator!=(const meta_prop &, const meta_prop &) */
+/**
+ * @brief Checks if two meta objects refer to the same type.
+ * @param lhs A meta object, either valid or not.
+ * @param rhs A meta object, either valid or not.
+ * @return False if the two meta objects refer to the same node, true otherwise.
+ */
 inline bool operator!=(const meta_type &lhs, const meta_type &rhs) ENTT_NOEXCEPT {
     return !(lhs == rhs);
 }

+ 0 - 14
test/entt/meta/meta.cpp

@@ -889,7 +889,6 @@ TEST_F(Meta, MetaProp) {
     auto prop = entt::resolve<char>().prop(props::prop_int);
 
     ASSERT_TRUE(prop);
-    ASSERT_NE(prop, entt::meta_prop{});
     ASSERT_EQ(prop.key(), props::prop_int);
     ASSERT_EQ(prop.value(), 42);
 }
@@ -899,7 +898,6 @@ TEST_F(Meta, MetaBase) {
     derived_type derived{};
 
     ASSERT_TRUE(base);
-    ASSERT_NE(base, entt::meta_base{});
     ASSERT_EQ(base.parent(), entt::resolve("derived"_hs));
     ASSERT_EQ(base.type(), entt::resolve<base_type>());
     ASSERT_EQ(base.cast(&derived), static_cast<base_type *>(&derived));
@@ -910,7 +908,6 @@ TEST_F(Meta, MetaConv) {
     double value = 3.;
 
     ASSERT_TRUE(conv);
-    ASSERT_NE(conv, entt::meta_conv{});
     ASSERT_EQ(conv.parent(), entt::resolve<double>());
     ASSERT_EQ(conv.type(), entt::resolve<int>());
 
@@ -926,7 +923,6 @@ TEST_F(Meta, MetaConvAsFreeFunctions) {
     derived_type derived{derived_type{}, 42, 'c'};
 
     ASSERT_TRUE(conv);
-    ASSERT_NE(conv, entt::meta_conv{});
     ASSERT_EQ(conv.parent(), entt::resolve<derived_type>());
     ASSERT_EQ(conv.type(), entt::resolve<int>());
 
@@ -942,7 +938,6 @@ TEST_F(Meta, MetaConvAsMemberFunctions) {
     derived_type derived{derived_type{}, 42, 'c'};
 
     ASSERT_TRUE(conv);
-    ASSERT_NE(conv, entt::meta_conv{});
     ASSERT_EQ(conv.parent(), entt::resolve<derived_type>());
     ASSERT_EQ(conv.type(), entt::resolve<char>());
 
@@ -957,7 +952,6 @@ TEST_F(Meta, MetaCtor) {
     auto ctor = entt::resolve<derived_type>().ctor<const base_type &, int, char>();
 
     ASSERT_TRUE(ctor);
-    ASSERT_NE(ctor, entt::meta_ctor{});
     ASSERT_EQ(ctor.parent(), entt::resolve("derived"_hs));
     ASSERT_EQ(ctor.size(), entt::meta_ctor::size_type{3});
     ASSERT_EQ(ctor.arg(entt::meta_ctor::size_type{0}), entt::resolve<base_type>());
@@ -1078,7 +1072,6 @@ TEST_F(Meta, MetaData) {
     data_type instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_NE(data, entt::meta_data{});
     ASSERT_EQ(data.parent(), entt::resolve("data"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.identifier(), "i"_hs);
@@ -1241,7 +1234,6 @@ TEST_F(Meta, MetaDataSetterGetterAsFreeFunctions) {
     setter_getter_type instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_NE(data, entt::meta_data{});
     ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.identifier(), "x"_hs);
@@ -1257,7 +1249,6 @@ TEST_F(Meta, MetaDataSetterGetterAsMemberFunctions) {
     setter_getter_type instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_NE(data, entt::meta_data{});
     ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.identifier(), "y"_hs);
@@ -1273,7 +1264,6 @@ TEST_F(Meta, MetaDataSetterGetterWithRefAsMemberFunctions) {
     setter_getter_type instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_NE(data, entt::meta_data{});
     ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.identifier(), "w"_hs);
@@ -1289,7 +1279,6 @@ TEST_F(Meta, MetaDataSetterGetterMixed) {
     setter_getter_type instance{};
 
     ASSERT_TRUE(data);
-    ASSERT_NE(data, entt::meta_data{});
     ASSERT_EQ(data.parent(), entt::resolve("setter_getter"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int>());
     ASSERT_EQ(data.identifier(), "z"_hs);
@@ -1308,7 +1297,6 @@ TEST_F(Meta, MetaDataArrayStatic) {
     array_type::global[2] = 7;
 
     ASSERT_TRUE(data);
-    ASSERT_NE(data, entt::meta_data{});
     ASSERT_EQ(data.parent(), entt::resolve("array"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int[3]>());
     ASSERT_EQ(data.identifier(), "global"_hs);
@@ -1338,7 +1326,6 @@ TEST_F(Meta, MetaDataArray) {
     instance.local[2] = 7;
 
     ASSERT_TRUE(data);
-    ASSERT_NE(data, entt::meta_data{});
     ASSERT_EQ(data.parent(), entt::resolve("array"_hs));
     ASSERT_EQ(data.type(), entt::resolve<int[3]>());
     ASSERT_EQ(data.identifier(), "local"_hs);
@@ -1387,7 +1374,6 @@ TEST_F(Meta, MetaFunc) {
     func_type instance{};
 
     ASSERT_TRUE(func);
-    ASSERT_NE(func, entt::meta_func{});
     ASSERT_EQ(func.parent(), entt::resolve("func"_hs));
     ASSERT_EQ(func.identifier(), "f2"_hs);
     ASSERT_EQ(func.size(), entt::meta_func::size_type{2});