diff --git a/flecs.c b/flecs.c index 0c7aa75047..30d38d9561 100644 --- a/flecs.c +++ b/flecs.c @@ -503,7 +503,7 @@ extern "C" { /** * @file table_graph.h - * @brief Table graph types. + * @brief Table graph types and functions. */ #ifndef FLECS_TABLE_GRAPH_H diff --git a/flecs.h b/flecs.h index d9941e9bef..b54171b4fa 100644 --- a/flecs.h +++ b/flecs.h @@ -19784,6 +19784,8 @@ struct world { template flecs::scoped_world scope() const; + flecs::scoped_world scope(const char* name) const; + /** Delete all entities with specified id. */ void delete_with(id_t the_id) const { ecs_delete_with(m_world, the_id); @@ -30178,6 +30180,10 @@ inline flecs::scoped_world world::scope() const { return scoped_world(m_world, parent); } +inline flecs::scoped_world world::scope(const char* name) const { + return scope(entity(name)); +} + } // namespace flecs diff --git a/src/storage/table_graph.h b/src/storage/table_graph.h index b174486995..18fcf0a344 100644 --- a/src/storage/table_graph.h +++ b/src/storage/table_graph.h @@ -1,6 +1,6 @@ /** * @file table_graph.h - * @brief Table graph types. + * @brief Table graph types and functions. */ #ifndef FLECS_TABLE_GRAPH_H diff --git a/test/cpp_api/project.json b/test/cpp_api/project.json index 66a9a384f9..b70be640d9 100644 --- a/test/cpp_api/project.json +++ b/test/cpp_api/project.json @@ -1146,7 +1146,8 @@ "component_w_low_id", "get_set_log_level", "reset_world", - "id_from_pair_type" + "id_from_pair_type", + "scope_w_name" ] }, { "id": "Singleton", diff --git a/test/cpp_api/src/World.cpp b/test/cpp_api/src/World.cpp index 74dd19a283..083cd49bf6 100644 --- a/test/cpp_api/src/World.cpp +++ b/test/cpp_api/src/World.cpp @@ -1715,3 +1715,12 @@ void World_id_from_pair_type(void) { test_assert(id.second() == ecs.id()); } + +void World_scope_w_name(void) { + flecs::world ecs; + + flecs::entity parent = ecs.entity("parent"); + flecs::entity child = ecs.scope("parent").entity(); + + test_assert(child.has(flecs::ChildOf, parent)); +} diff --git a/test/cpp_api/src/main.cpp b/test/cpp_api/src/main.cpp index f6089fd8d3..7771c4d3dc 100644 --- a/test/cpp_api/src/main.cpp +++ b/test/cpp_api/src/main.cpp @@ -1097,6 +1097,7 @@ void World_component_w_low_id(void); void World_get_set_log_level(void); void World_reset_world(void); void World_id_from_pair_type(void); +void World_scope_w_name(void); // Testsuite 'Singleton' void Singleton_set_get_singleton(void); @@ -5500,6 +5501,10 @@ bake_test_case World_testcases[] = { { "id_from_pair_type", World_id_from_pair_type + }, + { + "scope_w_name", + World_scope_w_name } }; @@ -6273,7 +6278,7 @@ static bake_test_suite suites[] = { "World", NULL, NULL, - 97, + 98, World_testcases }, {