diff --git a/docs/md/meta.md b/docs/md/meta.md index 6e509e9e4..6965b22d9 100644 --- a/docs/md/meta.md +++ b/docs/md/meta.md @@ -344,11 +344,11 @@ member function in its API. Destructors are invoked implicitly by `meta_any` behind the scenes and users have not to deal with them explicitly. Furthermore, they have no name, cannot be searched and wouldn't have member functions to expose anyway.
-Similarly, conversion functions aren't directly accessible. They are used under -the hood by `meta_any` and the other meta objects when needed.
-It wouldn't make sense to give direct access to these objects and to open the +Similarly, conversion functions and base types aren't directly accessible. They +are used internally by `meta_any` and the meta objects when needed.
+It wouldn't make sense to give direct access to these elements and to open the doors to the possibility of making mistakes. On the other side, the library -already offers enough methods to use them correctly. +already offers enough ways to use them correctly. Meta types and meta objects in general contain much more than what is said: a plethora of functions in addition to those listed whose purposes and uses go diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index 7313dfc41..82b79d32c 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -661,47 +661,6 @@ private: }; -/*! @brief Opaque wrapper for base classes. */ -struct meta_base { - /*! @brief Node type. */ - using node_type = internal::meta_base_node; - - /*! @copydoc meta_prop::meta_prop */ - meta_base(const node_type *curr = nullptr) ENTT_NOEXCEPT - : 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; - - /*! @copydoc meta_any::type */ - [[nodiscard]] inline meta_type type() const ENTT_NOEXCEPT; - - /** - * @brief Casts an instance from a parent type to a base type. - * @param instance The instance to cast. - * @return An opaque pointer to the base type. - */ - [[nodiscard]] const void * cast(const void *instance) const ENTT_NOEXCEPT { - return node->cast(instance); - } - - /** - * @brief Returns true if an object is valid, false otherwise. - * @return True if the object is valid, false otherwise. - */ - [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT { - return !(node == nullptr); - } - -private: - const node_type *node; -}; - - /*! @brief Opaque wrapper for constructors. */ struct meta_ctor { /*! @brief Node type. */ @@ -714,7 +673,10 @@ struct meta_ctor { : node{curr} {} - /*! @copydoc meta_base::parent */ + /** + * @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; /** @@ -807,7 +769,7 @@ struct meta_data { return node->id; } - /*! @copydoc meta_base::parent */ + /*! @copydoc meta_ctor::parent */ [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT; /** @@ -906,7 +868,7 @@ struct meta_func { return node->id; } - /*! @copydoc meta_base::parent */ + /*! @copydoc meta_ctor::parent */ [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT; /** @@ -1232,25 +1194,6 @@ public: return node->remove_extent(); } - /** - * @brief Returns a range to use to visit top-level bases. - * @return An iterable range to use to visit top-level bases. - */ - [[nodiscard]] meta_range base() const ENTT_NOEXCEPT { - return node->base; - } - - /** - * @brief Returns the base associated with a given identifier. - * @param id Unique identifier. - * @return The base associated with the given identifier, if any. - */ - [[nodiscard]] meta_base base(const id_type id) const { - return internal::find_if<&node_type::base>([id](const auto *curr) { - return curr->type()->id == id; - }, node); - } - /** * @brief Returns a range to use to visit top-level constructors. * @return An iterable range to use to visit top-level constructors. @@ -1577,16 +1520,6 @@ bool meta_any::set(const id_type id, Type &&value) { } -[[nodiscard]] inline meta_type meta_base::parent() const ENTT_NOEXCEPT { - return node->parent; -} - - -[[nodiscard]] inline meta_type meta_base::type() const ENTT_NOEXCEPT { - return node->type(); -} - - [[nodiscard]] inline meta_type meta_ctor::parent() const ENTT_NOEXCEPT { return node->parent; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8f93b5270..922d98410 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -187,7 +187,6 @@ SETUP_BASIC_TEST(locator entt/locator/locator.cpp) # Test meta SETUP_BASIC_TEST(meta_any entt/meta/meta_any.cpp) -SETUP_BASIC_TEST(meta_base entt/meta/meta_base.cpp) SETUP_BASIC_TEST(meta_container entt/meta/meta_container.cpp) SETUP_BASIC_TEST(meta_ctor entt/meta/meta_ctor.cpp) SETUP_BASIC_TEST(meta_data entt/meta/meta_data.cpp) diff --git a/test/entt/meta/meta_base.cpp b/test/entt/meta/meta_base.cpp deleted file mode 100644 index ef97b1ce6..000000000 --- a/test/entt/meta/meta_base.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include -#include - -struct base_t {}; -struct derived_t: base_t {}; - -struct MetaBase: ::testing::Test { - static void SetUpTestCase() { - using namespace entt::literals; - - entt::meta().type("base"_hs); - entt::meta().type("derived"_hs).base(); - } -}; - -TEST_F(MetaBase, Functionalities) { - using namespace entt::literals; - - auto base = entt::resolve().base("base"_hs); - derived_t derived{}; - - ASSERT_TRUE(base); - ASSERT_EQ(base.parent(), entt::resolve("derived"_hs)); - ASSERT_EQ(base.type(), entt::resolve()); - ASSERT_EQ(base.cast(&derived), static_cast(&derived)); -} diff --git a/test/entt/meta/meta_type.cpp b/test/entt/meta/meta_type.cpp index ff5ee2366..b74f4b726 100644 --- a/test/entt/meta/meta_type.cpp +++ b/test/entt/meta/meta_type.cpp @@ -251,21 +251,6 @@ TEST_F(MetaType, RemoveExtent) { ASSERT_EQ(entt::resolve().remove_extent(), entt::resolve()); } -TEST_F(MetaType, Base) { - using namespace entt::literals; - - auto type = entt::resolve(); - bool iterate = false; - - for(auto curr: type.base()) { - ASSERT_EQ(curr.type(), entt::resolve()); - iterate = true; - } - - ASSERT_TRUE(iterate); - ASSERT_EQ(type.base("base"_hs).type(), entt::resolve()); -} - TEST_F(MetaType, Ctor) { auto type = entt::resolve(); int counter{};