Skip to content

Commit

Permalink
#1054 Fix incorrect documentation comments in C++ API
Browse files Browse the repository at this point in the history
* fix some comments, group add and remove functions

* Update flecs.h

* change comment to @see for set_lookup_path

* Update flecs.h
  • Loading branch information
Indra-db authored Oct 3, 2023
1 parent 6ea0596 commit fd9fd1e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 68 deletions.
71 changes: 37 additions & 34 deletions flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19789,6 +19789,7 @@ struct world {
flecs::entity set_scope() const;

/** Set search path.
* @see ecs_set_lookup_path
*/
flecs::entity_t* set_lookup_path(const flecs::entity_t *search_path) const {
return ecs_set_lookup_path(m_world, search_path);
Expand Down Expand Up @@ -19952,23 +19953,23 @@ struct world {
template <typename T>
void remove() const;

/** Adds a pair to the singleton component.
/** Removes the pair singleton component.
*
* @tparam First The first element of the pair
* @tparam Second The second element of the pair
*/
template <typename First, typename Second>
void remove() const;

/** Adds a pair to the singleton component.
/** Removes the pair singleton component.
*
* @tparam First The first element of the pair
* @param second The second element of the pair.
*/
template <typename First>
void remove(flecs::entity_t second) const;

/** Adds a pair to the singleton entity.
/** Removes the pair singleton component.
*
* @param first The first element of the pair
* @param second The second element of the pair
Expand Down Expand Up @@ -22388,6 +22389,23 @@ struct entity_builder : entity_view {
return to_base();
}

/** Add pair for enum constant.
* This operation will add a pair to the entity where the first element is
* the enumeration type, and the second element the enumeration constant.
*
* The operation may be used with regular (C style) enumerations as well as
* enum classes.
*
* @param value The enumeration value.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& add(E value) {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
const auto& et = enum_type<E>(this->m_world);
flecs::entity_t second = et.entity(value);
return this->add(first, second);
}

/** Add an entity to an entity.
* Add an entity to the entity. This is typically used for tagging.
*
Expand Down Expand Up @@ -22634,6 +22652,17 @@ struct entity_builder : entity_view {
return to_base();
}

/** Remove pair for enum.
* This operation will remove any (Enum, *) pair from the entity.
*
* @tparam E The enumeration type.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& remove() {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
return this->remove(first, flecs::Wildcard);
}

/** Remove an entity from an entity.
*
* @param entity The entity to remove.
Expand Down Expand Up @@ -22666,7 +22695,7 @@ struct entity_builder : entity_view {
}

/** Remove a pair.
* This operation adds a pair to the entity.
* This operation removes the pair from the entity.
*
* @tparam First The first element of the pair
* @param second The second element of the pair.
Expand All @@ -22688,7 +22717,7 @@ struct entity_builder : entity_view {
}

/** Remove a pair.
* This operation adds a pair to the entity.
* This operation removes the pair from the entity.
*
* @tparam First The first element of the pair
* @param constant the enum constant.
Expand Down Expand Up @@ -22860,34 +22889,6 @@ struct entity_builder : entity_view {
return to_base();
}

/** Add pair for enum constant.
* This operation will add a pair to the entity where the first element is
* the enumeration type, and the second element the enumeration constant.
*
* The operation may be used with regular (C style) enumerations as well as
* enum classes.
*
* @param value The enumeration value.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& add(E value) {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
const auto& et = enum_type<E>(this->m_world);
flecs::entity_t second = et.entity(value);
return this->add(first, second);
}

/** Remove pair for enum.
* This operation will remove any (Enum, *) pair from the entity.
*
* @tparam E The enumeration type.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& remove() {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
return this->remove(first, flecs::Wildcard);
}

/** Enable an entity.
* Enabled entities are matched with systems and can be searched with
* queries.
Expand Down Expand Up @@ -23240,6 +23241,7 @@ struct entity_builder : entity_view {
}

/** Entities created in function will have the current entity.
* This operation is thread safe.
*
* @param func The function to call.
*/
Expand All @@ -23264,6 +23266,7 @@ struct entity_builder : entity_view {
}

/** Entities created in function will have (first, this).
* This operation is thread safe.
*
* @param first The first element of the pair.
* @param func The function to call.
Expand Down Expand Up @@ -23582,7 +23585,7 @@ struct entity : entity_builder<entity>
_::cpp_type<Second>::id(m_world))));
}

/** Get mutable pointer for a pair.
/** Get mutable pointer for the first element of a pair.
* This operation gets the value for a pair from the entity.
*
* @tparam First The first part of the pair.
Expand Down
2 changes: 1 addition & 1 deletion include/flecs/addons/cpp/entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct entity : entity_builder<entity>
_::cpp_type<Second>::id(m_world))));
}

/** Get mutable pointer for a pair.
/** Get mutable pointer for the first element of a pair.
* This operation gets the value for a pair from the entity.
*
* @tparam First The first part of the pair.
Expand Down
62 changes: 32 additions & 30 deletions include/flecs/addons/cpp/mixins/entity/builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ struct entity_builder : entity_view {
return to_base();
}

/** Add pair for enum constant.
* This operation will add a pair to the entity where the first element is
* the enumeration type, and the second element the enumeration constant.
*
* The operation may be used with regular (C style) enumerations as well as
* enum classes.
*
* @param value The enumeration value.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& add(E value) {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
const auto& et = enum_type<E>(this->m_world);
flecs::entity_t second = et.entity(value);
return this->add(first, second);
}

/** Add an entity to an entity.
* Add an entity to the entity. This is typically used for tagging.
*
Expand Down Expand Up @@ -275,6 +292,17 @@ struct entity_builder : entity_view {
return to_base();
}

/** Remove pair for enum.
* This operation will remove any (Enum, *) pair from the entity.
*
* @tparam E The enumeration type.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& remove() {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
return this->remove(first, flecs::Wildcard);
}

/** Remove an entity from an entity.
*
* @param entity The entity to remove.
Expand Down Expand Up @@ -307,7 +335,7 @@ struct entity_builder : entity_view {
}

/** Remove a pair.
* This operation adds a pair to the entity.
* This operation removes the pair from the entity.
*
* @tparam First The first element of the pair
* @param second The second element of the pair.
Expand All @@ -329,7 +357,7 @@ struct entity_builder : entity_view {
}

/** Remove a pair.
* This operation adds a pair to the entity.
* This operation removes the pair from the entity.
*
* @tparam First The first element of the pair
* @param constant the enum constant.
Expand Down Expand Up @@ -501,34 +529,6 @@ struct entity_builder : entity_view {
return to_base();
}

/** Add pair for enum constant.
* This operation will add a pair to the entity where the first element is
* the enumeration type, and the second element the enumeration constant.
*
* The operation may be used with regular (C style) enumerations as well as
* enum classes.
*
* @param value The enumeration value.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& add(E value) {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
const auto& et = enum_type<E>(this->m_world);
flecs::entity_t second = et.entity(value);
return this->add(first, second);
}

/** Remove pair for enum.
* This operation will remove any (Enum, *) pair from the entity.
*
* @tparam E The enumeration type.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& remove() {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
return this->remove(first, flecs::Wildcard);
}

/** Enable an entity.
* Enabled entities are matched with systems and can be searched with
* queries.
Expand Down Expand Up @@ -881,6 +881,7 @@ struct entity_builder : entity_view {
}

/** Entities created in function will have the current entity.
* This operation is thread safe.
*
* @param func The function to call.
*/
Expand All @@ -905,6 +906,7 @@ struct entity_builder : entity_view {
}

/** Entities created in function will have (first, this).
* This operation is thread safe.
*
* @param first The first element of the pair.
* @param func The function to call.
Expand Down
7 changes: 4 additions & 3 deletions include/flecs/addons/cpp/world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ struct world {
flecs::entity set_scope() const;

/** Set search path.
* @see ecs_set_lookup_path
*/
flecs::entity_t* set_lookup_path(const flecs::entity_t *search_path) const {
return ecs_set_lookup_path(m_world, search_path);
Expand Down Expand Up @@ -706,23 +707,23 @@ struct world {
template <typename T>
void remove() const;

/** Adds a pair to the singleton component.
/** Removes the pair singleton component.
*
* @tparam First The first element of the pair
* @tparam Second The second element of the pair
*/
template <typename First, typename Second>
void remove() const;

/** Adds a pair to the singleton component.
/** Removes the pair singleton component.
*
* @tparam First The first element of the pair
* @param second The second element of the pair.
*/
template <typename First>
void remove(flecs::entity_t second) const;

/** Adds a pair to the singleton entity.
/** Removes the pair singleton component.
*
* @param first The first element of the pair
* @param second The second element of the pair
Expand Down

0 comments on commit fd9fd1e

Please sign in to comment.