From 1013c6a50e7aeb43412f146bc32c672311e8ea1c Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 12 Aug 2021 19:13:06 +0200 Subject: [PATCH] meta: removed annotation support for meta properties --- docs/md/meta.md | 13 ++----------- src/entt/meta/factory.hpp | 23 ++++++++--------------- test/entt/meta/meta_type.cpp | 2 +- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/docs/md/meta.md b/docs/md/meta.md index c54121f7f..bb35f0782 100644 --- a/docs/md/meta.md +++ b/docs/md/meta.md @@ -888,23 +888,14 @@ Multiple formats are supported when it comes to defining a property: A tuple contains one or more properties. All of them are treated individually. -* Annotations: - - ```cpp - entt::meta().type("reflected_type"_hs).prop(&property_generator); - ``` - - An annotation is an invocable object that returns one or more properties. All - of them are treated individually. - Note that it's not possible to invoke `prop` multiple times for the same meta object and trying to do that will result in a compilation error.
However, the `props` function is available to associate several properties at once. In this case, properties in the key/value form aren't allowed, since they would be interpreted as two different properties rather than a single one. -The meta objects for which properties are supported are currently the meta -types, meta constructors, meta data and meta functions.
+The meta objects for which properties are supported are currently meta types, +meta constructors, meta data and meta functions.
These types also offer a couple of member functions named `prop` to iterate all properties at once or to search a specific property by key: diff --git a/src/entt/meta/factory.hpp b/src/entt/meta/factory.hpp index 21d35447d..e421b3589 100644 --- a/src/entt/meta/factory.hpp +++ b/src/entt/meta/factory.hpp @@ -42,27 +42,21 @@ template struct meta_factory: public meta_factory { private: template - void unroll(choice_t<3>, std::tuple property, Other &&... other) { - std::apply([this](auto &&... property) { (unroll(choice<3>, std::forward(property)), ...); }, property); - unroll(choice<3>, std::forward(other)...); + void unroll(choice_t<2>, std::tuple property, Other &&... other) { + std::apply([this](auto &&... curr) { (unroll(choice<2>, std::forward(curr)), ...); }, property); + unroll(choice<2>, std::forward(other)...); } template - void unroll(choice_t<2>, std::pair property, Other &&... other) { + void unroll(choice_t<1>, std::pair property, Other &&... other) { assign(std::move(property.first), std::move(property.second)); - unroll(choice<3>, std::forward(other)...); + unroll(choice<2>, std::forward(other)...); } template - std::enable_if_t> - unroll(choice_t<1>, Property &&property, Other &&... other) { + void unroll(choice_t<0>, Property &&property, Other &&... other) { assign(std::forward(property)); - unroll(choice<3>, std::forward(other)...); - } - - template - void unroll(choice_t<0>, Func &&invocable, Other &&... other) { - unroll(choice<3>, std::forward(invocable)(), std::forward(other)...); + unroll(choice<2>, std::forward(other)...); } template @@ -123,8 +117,7 @@ public: /** * @brief Assigns properties to the last meta object created. * - * Both the keys and the values (if any) must be at least copy - * constructible. + * Both key and value (if any) must be at least copy constructible. * * @tparam Property Types of the properties. * @param property Properties to assign to the last meta object created. diff --git a/test/entt/meta/meta_type.cpp b/test/entt/meta/meta_type.cpp index 4632b4e47..dce13ef65 100644 --- a/test/entt/meta/meta_type.cpp +++ b/test/entt/meta/meta_type.cpp @@ -135,7 +135,7 @@ struct MetaType: ::testing::Test { .data("value"_hs) .props(std::make_pair(property_t::random, true), std::make_pair(property_t::value, 0), property_t::key_only, property_t::list) .data("key_only"_hs) - .prop([]() { return property_t::key_only; }) + .prop(property_t::key_only) .data("list"_hs) .props(std::make_pair(property_t::random, false), std::make_pair(property_t::value, 0), property_t::key_only) .data, get>("var"_hs);