1#include <expr_w_vars.h>
2#include <stdio.h>
3
4
5
6
7
8
9int main(int argc, char *argv[]) {
11
12
16
17
19 *(int32_t*)y->value.ptr = 20;
20
21
22
23
24 int32_t result = 0;
27 .ptr = &result
28 };
29
30
33 if (!s) {
34 printf("failed to parse expression\n");
35 return -1;
36 }
37
38
40 printf("failed to evaluate expression\n");
41 return -1;
42 }
43
44 printf("result = %d\n", result);
45
46
47 *(int32_t*)y->value.ptr = 30;
49 printf("failed to evaluate expression\n");
50 return -1;
51 }
52
53 printf("result = %d\n", result);
54
55
58
60
61
62
63
64}
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
FLECS_API ecs_script_t * ecs_expr_parse(ecs_world_t *world, const char *expr, const ecs_expr_eval_desc_t *desc)
Parse expression.
FLECS_API void ecs_script_vars_fini(ecs_script_vars_t *vars)
Free variable scope.
FLECS_API void ecs_script_free(ecs_script_t *script)
Free script.
FLECS_API ecs_script_vars_t * ecs_script_vars_init(ecs_world_t *world)
Create new variable scope.
FLECS_API int ecs_expr_eval(const ecs_script_t *script, ecs_value_t *value, const ecs_expr_eval_desc_t *desc)
Evaluate expression.
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
int ecs_fini(ecs_world_t *world)
Delete a world.
ecs_world_t * ecs_init_w_args(int argc, char *argv[])
Create a new world with arguments.
Used with ecs_expr_run().
ecs_value_t value
Variable value.
void * ptr
Pointer to value.