فهرست منبع

meta: removed annotation support for meta properties

Michele Caini 4 سال پیش
والد
کامیت
1013c6a50e
3فایلهای تغییر یافته به همراه11 افزوده شده و 27 حذف شده
  1. 2 11
      docs/md/meta.md
  2. 8 15
      src/entt/meta/factory.hpp
  3. 1 1
      test/entt/meta/meta_type.cpp

+ 2 - 11
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<my_type>().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.<br/>
 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.<br/>
+The meta objects for which properties are supported are currently meta types,
+meta constructors, meta data and meta functions.<br/>
 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:
 

+ 8 - 15
src/entt/meta/factory.hpp

@@ -42,27 +42,21 @@ template<typename Type, typename... Spec>
 struct meta_factory<Type, Spec...>: public meta_factory<Type> {
 private:
     template<std::size_t Step = 0, typename... Property, typename... Other>
-    void unroll(choice_t<3>, std::tuple<Property...> property, Other &&... other) {
-        std::apply([this](auto &&... property) { (unroll<Step>(choice<3>, std::forward<Property>(property)), ...); }, property);
-        unroll<Step + sizeof...(Property)>(choice<3>, std::forward<Other>(other)...);
+    void unroll(choice_t<2>, std::tuple<Property...> property, Other &&... other) {
+        std::apply([this](auto &&... curr) { (unroll<Step>(choice<2>, std::forward<Property>(curr)), ...); }, property);
+        unroll<Step + sizeof...(Property)>(choice<2>, std::forward<Other>(other)...);
     }
 
     template<std::size_t Step = 0, typename... Property, typename... Other>
-    void unroll(choice_t<2>, std::pair<Property...> property, Other &&... other) {
+    void unroll(choice_t<1>, std::pair<Property...> property, Other &&... other) {
         assign<Step>(std::move(property.first), std::move(property.second));
-        unroll<Step+1>(choice<3>, std::forward<Other>(other)...);
+        unroll<Step+1>(choice<2>, std::forward<Other>(other)...);
     }
 
     template<std::size_t Step = 0, typename Property, typename... Other>
-    std::enable_if_t<!std::is_invocable_v<Property>>
-    unroll(choice_t<1>, Property &&property, Other &&... other) {
+    void unroll(choice_t<0>, Property &&property, Other &&... other) {
         assign<Step>(std::forward<Property>(property));
-        unroll<Step+1>(choice<3>, std::forward<Other>(other)...);
-    }
-
-    template<std::size_t Step = 0, typename Func, typename... Other>
-    void unroll(choice_t<0>, Func &&invocable, Other &&... other) {
-        unroll<Step>(choice<3>, std::forward<Func>(invocable)(), std::forward<Other>(other)...);
+        unroll<Step+1>(choice<2>, std::forward<Other>(other)...);
     }
 
     template<std::size_t>
@@ -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.

+ 1 - 1
test/entt/meta/meta_type.cpp

@@ -135,7 +135,7 @@ struct MetaType: ::testing::Test {
             .data<property_t::value>("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<property_t::key_only>("key_only"_hs)
-                .prop([]() { return property_t::key_only; })
+                .prop(property_t::key_only)
             .data<property_t::list>("list"_hs)
                 .props(std::make_pair(property_t::random, false), std::make_pair(property_t::value, 0), property_t::key_only)
             .data<set<property_t>, get<property_t>>("var"_hs);