Jelajahi Sumber

doc: updated meta.md

Michele Caini 1 tahun lalu
induk
melakukan
197ba29276
2 mengubah file dengan 14 tambahan dan 22 penghapusan
  1. 0 3
      TODO
  2. 14 19
      docs/md/meta.md

+ 0 - 3
TODO

@@ -45,6 +45,3 @@ TODO:
 * natvis for meta_custom
 * meta: vectors for details and props
 * suppress -Wself-move on CI with g++13
-* meta: custom data can be attached to wrong func if overloaded and re-run/seek (fix and test)
-* meta: use common base node class in the factory for custom/prop
-* meta: drop seek functions, too tricky to support unfortunately

+ 14 - 19
docs/md/meta.md

@@ -880,17 +880,14 @@ entt::meta<my_type>().prop(my_enum::key_only);
 To attach multiple properties to a meta object, just invoke `prop` more than
 once.<br/>
 It's also possible to call `prop` at different times, as long as the factory is
-reset to the meta object of interest. For example, to attach a property to an
-already existing meta data object:
+reset to the meta object of interest:
 
 ```cpp
-entt::meta<my_type>().data("member"_hs).prop("key"_hs, value);
+entt::meta<my_type>()
+    .data<&my_type::data_member, entt::as_ref_t>("member"_hs)
+    .prop("key"_hs, value);
 ```
 
-The `data` and `func` overloads which accept only the name of the member to be
-searched for assume that it already exists and make it the _current element_ for
-subsequent calls.
-
 Once created, all meta objects offer a couple of member functions named `prop`
 to iterate all properties at once or to search a specific property by key:
 
@@ -922,16 +919,15 @@ It's not possible to assign traits at different times. Therefore, multiple calls
 to the `traits` function overwrite previous values. However, traits can be read
 from meta objects and used to update existing data with a factory, effectively
 extending them as needed.<br/>
-Likewise, users can also set traits on meta objects later if needed:
+Likewise, users can also set traits on meta objects later if needed, as long as
+the factory is reset to the meta object of interest:
 
 ```cpp
-entt::meta<my_type>().data("member"_hs).traits(my_traits::internal);
+entt::meta<my_type>()
+    .data<&my_type::data_member, entt::as_ref_t>("member"_hs)
+    .traits(my_traits::internal);
 ```
 
-The `data` and `func` overloads which accept only the name of the member to be
-searched for assume that it already exists and make it the _current element_ for
-subsequent calls.
-
 Once created, all meta objects offer a member function named `traits` to get the
 currently set value:
 
@@ -957,16 +953,15 @@ It's not possible to assign custom data at different times. Therefore, multiple
 calls to the `custom` function overwrite previous values. However, this value
 can be read from meta objects and used to update existing data with a factory,
 effectively extending them as needed.<br/>
-Likewise, users can also set custom data on meta objects later if needed:
+Likewise, users can also set custom data on meta objects later if needed, as
+long as the factory is reset to the meta object of interest:
 
 ```cpp
-entt::meta<my_type>().func("invoke"_hs).custom<function_data>("tooltip");
+entt::meta<my_type>()
+    .func<&my_type::member_function>("member"_hs)
+    .custom<function_data>("tooltip");
 ```
 
-The `data` and `func` overloads which accept only the name of the member to be
-searched for assume that it already exists and make it the _current element_ for
-subsequent calls.
-
 Once created, all meta objects offer a member function named `custom` to get the
 currently set value as a const reference or as a pointer to a const element: