Skip to content

Commit

Permalink
#1152 Add query info json serializer
Browse files Browse the repository at this point in the history
* Add query info JSON serializer

* Add symbol name to field info

* Fix meson build

* Change behavior of ecs_lookup to match ecs_lookup_fullpath, mark ecs_lookup_fullpath as deprecated

* Replace occurrences of ecs_lookup_fullpath with ecs_lookup

* Allow '$var' notation in C query descriptors
  • Loading branch information
SanderMertens authored Feb 19, 2024
1 parent 6420cfa commit 44feea4
Show file tree
Hide file tree
Showing 53 changed files with 2,574 additions and 1,105 deletions.
2 changes: 1 addition & 1 deletion docs/DesignWithFlecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Entities can be created and deleted dynamically. When entities are deleted, the
### Entity Names
Flecs entities can be named. This makes it easy to identify entities in editors or while debugging, and also allows you to lookup entities by name. Names must be unique inside a scope, which is determined by the `ChildOf` relationship. For example, two entities with the same parent must have different names.

Names can be looked up using a relative path or absolute path using the `ecs_lookup_fullpath` or `entity::lookup` functions. The default scope separator for C applications is a dot (`.`), whereas in C++ it is a double colon (`::`). Lookups use a hashmap internally, which provides O(1) performance.
Names can be looked up using a relative path or absolute path using the `ecs_lookup` or `entity::lookup` functions. The default scope separator for C applications is a dot (`.`), whereas in C++ it is a double colon (`::`). Lookups use a hashmap internally, which provides O(1) performance.

Entities can be assigned user friendly names with the doc addon, using the `ecs_doc_set_name` or `entity::set_doc_name` functions. Names assigned by the doc framework do not have to be unique.

Expand Down
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ You can! Systems are an optional addon that can be disabled. You can build appli
This is likely because the entity has a parent. A lookup by name requires you to provide the full path to an entity, like:

```c
ecs_lookup_fullpath(world, "parent.child");
ecs_lookup(world, "parent.child");
```
or in C++:
Expand Down
2 changes: 1 addition & 1 deletion docs/FlecsScriptTutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ We could save this script as is, load it into our game, and instantiate the pref
// In C
ecs_plecs_from_file(world, "fence.flecs");

ecs_entity_t fence = ecs_lookup_fullpath(world, "Fence");
ecs_entity_t fence = ecs_lookup(world, "Fence");
ecs_entity_t fence_a = ecs_new_w_pair(world, EcsIsA, fence);
ecs_entity_t fence_b = ecs_new_w_pair(world, EcsIsA, fence);

Expand Down
10 changes: 5 additions & 5 deletions docs/Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ ecs_os_free(path);
Paths can be used to lookup an entity:

```c
ecs_entity_t e = ecs_lookup_fullpath(world, "Parent.Child.GrandChild");
ecs_entity_t e = ecs_lookup(world, "Parent.Child.GrandChild");
```

Path lookups may be relative:
Expand Down Expand Up @@ -790,7 +790,7 @@ ecs_entity_t e = ecs_new(world, Car);
Module contents are namespaced, which means that the identifiers of the content of the module (components, tags, systems) are stored in the scope of the module. For the above example module, everything would be stored in the `vehicles` scope. To resolve the `Car` component by name, an application would have to do:
```c
ecs_entity_t car_entity = ecs_lookup_fullpath(world, "vehicles.Car");
ecs_entity_t car_entity = ecs_lookup(world, "vehicles.Car");
```

Note that even though the module name is specified with uppercase, the name is stored with lowercase. This is because the naming convention for modules in C is PascalCase, whereas the stored identifiers use snake_case. If a module name contains several uppercase letters, this will be translated to a nested module. For example, the C module name `MySimpleModule` will be translated to `my.simple.module`.
Expand Down Expand Up @@ -908,10 +908,10 @@ printf("%s\n", path); // Prints "parent.child"
free(path);
```
To lookup an entity using a path, use `ecs_lookup_fullpath`:
To lookup an entity using a path, use `ecs_lookup`:
```c
ecs_entity_t e = ecs_lookup_fullpath(world, "parent.child");
ecs_entity_t e = ecs_lookup(world, "parent.child");
```

Applications can also lookup entities using a relative path expression:
Expand Down Expand Up @@ -946,7 +946,7 @@ ecs_entity_t prev_scope = ecs_set_scope(world, parent);
ecs_entity_t child = ecs_new(world, 0);

// Look for "child" relative to parent
ecs_entity_t e = ecs_lookup_fullpath(world, "child");
ecs_entity_t e = ecs_lookup(world, "child");

// It's good practice to restore the previous scope
ecs_set_scope(prev_scope);
Expand Down
2 changes: 1 addition & 1 deletion docs/Queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ flecs::filter<> f = world.filter_builder()
```

#### Query DSL
To query for a components in the query DSL they can be specified in a comma separated list of identifiers. The rules for resolving identifiers are the same as the `ecs_lookup_fullpath` / `world.lookup` functions. An example:
To query for a components in the query DSL they can be specified in a comma separated list of identifiers. The rules for resolving identifiers are the same as the `ecs_lookup` / `world.lookup` functions. An example:

```
Position, Velocity
Expand Down
2 changes: 1 addition & 1 deletion docs/Relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ ecs_entity_t child = ecs_entity(world, {
// Create the hierarchy
ecs_add_pair(world, child, EcsChildOf, parent);

child = ecs_lookup_fullpath(world, "Parent::Child"); // true
child = ecs_lookup(world, "Parent::Child"); // true
child = ecs_lookup_path(world, parent, "Child"); // true
```
```cpp
Expand Down
Loading

0 comments on commit 44feea4

Please sign in to comment.