Flecs: include/flecs/addons/script.h Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.1 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
script.h
Go to the documentation of this file.
1
7
8#ifdef FLECS_SCRIPT
9
17
18#ifndef FLECS_META
19#define FLECS_META
20#endif
21
22#ifndef FLECS_DOC
23#define FLECS_DOC
24#endif
25
26#ifndef FLECS_PARSER
27#define FLECS_PARSER
28#endif
29
30#ifndef FLECS_SCRIPT_H
31#define FLECS_SCRIPT_H
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#define FLECS_SCRIPT_FUNCTION_ARGS_MAX (16)
38
39/* Must be the same as EcsPrimitiveKindLast */
40#define FLECS_SCRIPT_VECTOR_FUNCTION_COUNT (18)
41
42FLECS_API
43extern ECS_COMPONENT_DECLARE(EcsScript);
44
45FLECS_API
46extern ECS_DECLARE(EcsScriptTemplate);
47
48FLECS_API
49extern ECS_COMPONENT_DECLARE(EcsScriptConstVar);
50
51FLECS_API
52extern ECS_COMPONENT_DECLARE(EcsScriptFunction);
53
54FLECS_API
55extern ECS_COMPONENT_DECLARE(EcsScriptMethod);
56
57FLECS_API
58extern ECS_DECLARE(EcsScriptVectorType);
59
60/* Script template. */
61typedef struct ecs_script_template_t ecs_script_template_t;
62
64 typedef struct ecs_script_var_t {
65 const char *name;
66 ecs_value_t value;
67 const ecs_type_info_t *type_info;
68 int32_t sp;
69 bool is_const;
70} ecs_script_var_t;
71
73 typedef struct ecs_script_vars_t {
74 struct ecs_script_vars_t *parent;
75 int32_t sp;
76
77 ecs_hashmap_t var_index;
78 ecs_vec_t vars;
79
80 const ecs_world_t *world;
81 struct ecs_stack_t *stack;
82 ecs_stack_cursor_t *cursor;
83 ecs_allocator_t *allocator;
84} ecs_script_vars_t;
85
87 typedef struct ecs_script_t {
88 ecs_world_t *world;
89 const char *name;
90 const char *code;
91} ecs_script_t;
92
94 typedef struct ecs_script_runtime_t ecs_script_runtime_t;
95
99 typedef struct EcsScript {
100 char *filename;
101 char *code;
102 char *error;
103 ecs_script_t *script;
104 ecs_script_template_t *template_;
105} EcsScript;
106
108 typedef struct ecs_function_ctx_t {
109 ecs_world_t *world;
110 ecs_entity_t function;
111 void *ctx;
112} ecs_function_ctx_t;
113
115 typedef void(*ecs_function_callback_t)(
116 const ecs_function_ctx_t *ctx,
117 int32_t argc,
118 const ecs_value_t *argv,
119 ecs_value_t *result);
120
122 typedef void(*ecs_vector_function_callback_t)(
123 const ecs_function_ctx_t *ctx,
124 int32_t argc,
125 const ecs_value_t *argv,
126 ecs_value_t *result,
127 int32_t elem_count);
128
130 typedef struct ecs_script_parameter_t {
131 const char *name;
132 ecs_entity_t type;
133} ecs_script_parameter_t;
134
138 typedef struct EcsScriptConstVar {
139 ecs_value_t value;
140 const ecs_type_info_t *type_info;
141} EcsScriptConstVar;
142
143 struct ecs_script_function_t {
144 ecs_entity_t return_type;
145 ecs_vec_t params; /* vec<ecs_script_parameter_t> */
146 ecs_function_callback_t callback;
147 ecs_vector_function_callback_t vector_callbacks[FLECS_SCRIPT_VECTOR_FUNCTION_COUNT];
148 void *ctx;
149 void *binding_ctx;
150 ecs_ctx_free_t binding_ctx_free;
151};
152
156 typedef struct ecs_script_function_t EcsScriptFunction;
157
163 typedef struct ecs_script_function_t EcsScriptMethod;
164
165/* Parsing and running scripts */
166
168 typedef struct ecs_script_eval_desc_t {
169 ecs_script_vars_t *vars;
170 ecs_script_runtime_t *runtime;
171} ecs_script_eval_desc_t;
172
174 typedef struct ecs_script_eval_result_t {
175 char *error;
176 int32_t line;
177 int32_t column;
178} ecs_script_eval_result_t;
179
199FLECS_API
200 ecs_script_t* ecs_script_parse(
201 ecs_world_t *world,
202 const char *name,
203 const char *code,
204 const ecs_script_eval_desc_t *desc,
205 ecs_script_eval_result_t *result);
206
223FLECS_API
224 int ecs_script_eval(
225 const ecs_script_t *script,
226 const ecs_script_eval_desc_t *desc,
227 ecs_script_eval_result_t *result);
228
238FLECS_API
239 void ecs_script_free(
240 ecs_script_t *script);
241
258FLECS_API
259 int ecs_script_run(
260 ecs_world_t *world,
261 const char *name,
262 const char *code,
263 ecs_script_eval_result_t *result);
264
274FLECS_API
275 int ecs_script_run_file(
276 ecs_world_t *world,
277 const char *filename);
278
292FLECS_API
293 ecs_script_runtime_t* ecs_script_runtime_new(void);
294
300FLECS_API
301 void ecs_script_runtime_free(
302 ecs_script_runtime_t *runtime);
303
313FLECS_API
314 int ecs_script_ast_to_buf(
315 ecs_script_t *script,
316 ecs_strbuf_t *buf,
317 bool colors);
318
327FLECS_API
328 char* ecs_script_ast_to_str(
329 ecs_script_t *script,
330 bool colors);
331
332
333/* Managed scripts (script associated with entity that outlives the function) */
334
336 typedef struct ecs_script_desc_t {
337 ecs_entity_t entity;
338 const char *filename;
339 const char *code;
340} ecs_script_desc_t;
341
353FLECS_API
354 ecs_entity_t ecs_script_init(
355 ecs_world_t *world,
356 const ecs_script_desc_t *desc);
357
358#define ecs_script(world, ...)\
359 ecs_script_init(world, &(ecs_script_desc_t) __VA_ARGS__)
360
369FLECS_API
370 int ecs_script_update(
371 ecs_world_t *world,
372 ecs_entity_t script,
373 ecs_entity_t instance,
374 const char *code);
375
382FLECS_API
383 void ecs_script_clear(
384 ecs_world_t *world,
385 ecs_entity_t script,
386 ecs_entity_t instance);
387
388
389/* Script variables */
390
408FLECS_API
409 ecs_script_vars_t* ecs_script_vars_init(
410 ecs_world_t *world);
411
418FLECS_API
419 void ecs_script_vars_fini(
420 ecs_script_vars_t *vars);
421
433FLECS_API
434 ecs_script_vars_t* ecs_script_vars_push(
435 ecs_script_vars_t *parent);
436
445FLECS_API
446 ecs_script_vars_t* ecs_script_vars_pop(
447 ecs_script_vars_t *vars);
448
461FLECS_API
462 ecs_script_var_t* ecs_script_vars_declare(
463 ecs_script_vars_t *vars,
464 const char *name);
465
481FLECS_API
482 ecs_script_var_t* ecs_script_vars_define_id(
483 ecs_script_vars_t *vars,
484 const char *name,
485 ecs_entity_t type);
486
487#define ecs_script_vars_define(vars, name, type)\
488 ecs_script_vars_define_id(vars, name, ecs_id(type))
489
499FLECS_API
500 ecs_script_var_t* ecs_script_vars_lookup(
501 const ecs_script_vars_t *vars,
502 const char *name);
503
516FLECS_API
517 ecs_script_var_t* ecs_script_vars_from_sp(
518 const ecs_script_vars_t *vars,
519 int32_t sp);
520
526FLECS_API
527 void ecs_script_vars_print(
528 const ecs_script_vars_t *vars);
529
538FLECS_API
539 void ecs_script_vars_set_size(
540 ecs_script_vars_t *vars,
541 int32_t count);
542
575FLECS_API
576 void ecs_script_vars_from_iter(
577 const ecs_iter_t *it,
578 ecs_script_vars_t *vars,
579 int offset);
580
581
582/* Standalone expression evaluation */
583
585 typedef struct ecs_expr_eval_desc_t {
586 const char *name;
587 const char *expr;
588 const ecs_script_vars_t *vars;
589 ecs_entity_t type;
590 ecs_entity_t (*lookup_action)(
591 const ecs_world_t*,
592 const char *value,
593 void *ctx);
594 void *lookup_ctx;
595
597 bool disable_folding;
598
602 bool disable_dynamic_variable_binding;
603
606 bool allow_unresolved_identifiers;
607
608 ecs_script_runtime_t *runtime;
609
610 void *script_visitor;
611
612 bool (*unresolved_identifier_action)(
613 const ecs_world_t*,
614 const char *value,
615 void *ctx);
616} ecs_expr_eval_desc_t;
617
632FLECS_API
633 const char* ecs_expr_run(
634 ecs_world_t *world,
635 const char *ptr,
636 ecs_value_t *value,
637 const ecs_expr_eval_desc_t *desc);
638
648FLECS_API
649 ecs_script_t* ecs_expr_parse(
650 ecs_world_t *world,
651 const char *expr,
652 const ecs_expr_eval_desc_t *desc);
653
668FLECS_API
669 int ecs_expr_eval(
670 const ecs_script_t *script,
671 ecs_value_t *value,
672 const ecs_expr_eval_desc_t *desc);
673
687FLECS_API
688 char* ecs_script_string_interpolate(
689 ecs_world_t *world,
690 const char *str,
691 const ecs_script_vars_t *vars);
692
693
694/* Global const variables */
695
697 typedef struct ecs_const_var_desc_t {
699 const char *name;
700
702 ecs_entity_t parent;
703
705 ecs_entity_t type;
706
709 void *value;
710} ecs_const_var_desc_t;
711
718FLECS_API
719 ecs_entity_t ecs_const_var_init(
720 ecs_world_t *world,
721 ecs_const_var_desc_t *desc);
722
723#define ecs_const_var(world, ...)\
724 ecs_const_var_init(world, &(ecs_const_var_desc_t)__VA_ARGS__)
725
726
735FLECS_API
736 ecs_value_t ecs_const_var_get(
737 const ecs_world_t *world,
738 ecs_entity_t var);
739
740/* Functions */
741
743 typedef struct ecs_vector_fn_callbacks_t {
744 ecs_vector_function_callback_t i8;
745 ecs_vector_function_callback_t i32;
746} ecs_vector_fn_callbacks_t;
747
749 typedef struct ecs_function_desc_t {
751 const char *name;
752
755 ecs_entity_t parent;
756
758 ecs_script_parameter_t params[FLECS_SCRIPT_FUNCTION_ARGS_MAX];
759
761 ecs_entity_t return_type;
762
764 ecs_function_callback_t callback;
765
813 ecs_vector_function_callback_t vector_callbacks[FLECS_SCRIPT_VECTOR_FUNCTION_COUNT];
814
816 void *ctx;
817} ecs_function_desc_t;
818
826FLECS_API
827 ecs_entity_t ecs_function_init(
828 ecs_world_t *world,
829 const ecs_function_desc_t *desc);
830
831#define ecs_function(world, ...)\
832 ecs_function_init(world, &(ecs_function_desc_t)__VA_ARGS__)
833
846FLECS_API
847 ecs_entity_t ecs_method_init(
848 ecs_world_t *world,
849 const ecs_function_desc_t *desc);
850
851#define ecs_method(world, ...)\
852 ecs_method_init(world, &(ecs_function_desc_t)__VA_ARGS__)
853
854
855/* Value serialization */
856
866FLECS_API
867 char* ecs_ptr_to_expr(
868 const ecs_world_t *world,
869 ecs_entity_t type,
870 const void *data);
871
881FLECS_API
882 int ecs_ptr_to_expr_buf(
883 const ecs_world_t *world,
884 ecs_entity_t type,
885 const void *data,
886 ecs_strbuf_t *buf);
887
899FLECS_API
900 char* ecs_ptr_to_str(
901 const ecs_world_t *world,
902 ecs_entity_t type,
903 const void *data);
904
914FLECS_API
915 int ecs_ptr_to_str_buf(
916 const ecs_world_t *world,
917 ecs_entity_t type,
918 const void *data,
919 ecs_strbuf_t *buf);
920
921typedef struct ecs_expr_node_t ecs_expr_node_t;
922
931FLECS_API
932 void FlecsScriptImport(
933 ecs_world_t *world);
934
935#ifdef __cplusplus
936}
937#endif
938
939#endif
940
942
943#endif
ecs_script_runtime_free
FLECS_API void ecs_script_runtime_free(ecs_script_runtime_t *runtime)
Free script runtime.
ecs_script_eval
FLECS_API int ecs_script_eval(const ecs_script_t *script, const ecs_script_eval_desc_t *desc, ecs_script_eval_result_t *result)
Evaluate script.
ecs_script_vars_print
FLECS_API void ecs_script_vars_print(const ecs_script_vars_t *vars)
Print variables.
ecs_vector_function_callback_t
void(* ecs_vector_function_callback_t)(const ecs_function_ctx_t *ctx, int32_t argc, const ecs_value_t *argv, ecs_value_t *result, int32_t elem_count)
Script vector function callback.
Definition script.h:122
ecs_script_vars_set_size
FLECS_API void ecs_script_vars_set_size(ecs_script_vars_t *vars, int32_t count)
Preallocate space for variables.
ecs_ptr_to_expr_buf
FLECS_API int ecs_ptr_to_expr_buf(const ecs_world_t *world, ecs_entity_t type, const void *data, ecs_strbuf_t *buf)
Serialize value into expression buffer.
ecs_expr_parse
FLECS_API ecs_script_t * ecs_expr_parse(ecs_world_t *world, const char *expr, const ecs_expr_eval_desc_t *desc)
Parse expression.
ecs_script_vars_fini
FLECS_API void ecs_script_vars_fini(ecs_script_vars_t *vars)
Free variable scope.
ecs_script_runtime_new
FLECS_API ecs_script_runtime_t * ecs_script_runtime_new(void)
Create runtime for script.
ecs_ptr_to_expr
FLECS_API char * ecs_ptr_to_expr(const ecs_world_t *world, ecs_entity_t type, const void *data)
Serialize value into expression string.
ecs_function_init
FLECS_API ecs_entity_t ecs_function_init(ecs_world_t *world, const ecs_function_desc_t *desc)
Create new function.
ecs_ptr_to_str
FLECS_API char * ecs_ptr_to_str(const ecs_world_t *world, ecs_entity_t type, const void *data)
Similar to ecs_ptr_to_expr(), but serializes values to string.
EcsScriptMethod
struct ecs_script_function_t EcsScriptMethod
Method component.
Definition script.h:163
ecs_script_update
FLECS_API int ecs_script_update(ecs_world_t *world, ecs_entity_t script, ecs_entity_t instance, const char *code)
Update script with new code.
ecs_script_ast_to_str
FLECS_API char * ecs_script_ast_to_str(ecs_script_t *script, bool colors)
Convert script AST to string.
ecs_function_callback_t
void(* ecs_function_callback_t)(const ecs_function_ctx_t *ctx, int32_t argc, const ecs_value_t *argv, ecs_value_t *result)
Script function callback.
Definition script.h:115
ecs_script_init
FLECS_API ecs_entity_t ecs_script_init(ecs_world_t *world, const ecs_script_desc_t *desc)
Load managed script.
ecs_script_vars_pop
FLECS_API ecs_script_vars_t * ecs_script_vars_pop(ecs_script_vars_t *vars)
Pop variable scope.
ecs_script_vars_from_sp
FLECS_API ecs_script_var_t * ecs_script_vars_from_sp(const ecs_script_vars_t *vars, int32_t sp)
Lookup a variable by stack pointer.
ecs_script_clear
FLECS_API void ecs_script_clear(ecs_world_t *world, ecs_entity_t script, ecs_entity_t instance)
Clear all entities associated with script.
ecs_script_vars_declare
FLECS_API ecs_script_var_t * ecs_script_vars_declare(ecs_script_vars_t *vars, const char *name)
Declare a variable.
ecs_const_var_get
FLECS_API ecs_value_t ecs_const_var_get(const ecs_world_t *world, ecs_entity_t var)
Return the value for a const variable.
ecs_script_vars_define_id
FLECS_API ecs_script_var_t * ecs_script_vars_define_id(ecs_script_vars_t *vars, const char *name, ecs_entity_t type)
Define a variable.
EcsScriptFunction
struct ecs_script_function_t EcsScriptFunction
Function component.
Definition script.h:156
ecs_script_vars_from_iter
FLECS_API void ecs_script_vars_from_iter(const ecs_iter_t *it, ecs_script_vars_t *vars, int offset)
Convert iterator to vars.
ecs_script_free
FLECS_API void ecs_script_free(ecs_script_t *script)
Free script.
ecs_script_ast_to_buf
FLECS_API int ecs_script_ast_to_buf(ecs_script_t *script, ecs_strbuf_t *buf, bool colors)
Convert script AST to string.
ecs_method_init
FLECS_API ecs_entity_t ecs_method_init(ecs_world_t *world, const ecs_function_desc_t *desc)
Create new method.
ecs_ptr_to_str_buf
FLECS_API int ecs_ptr_to_str_buf(const ecs_world_t *world, ecs_entity_t type, const void *data, ecs_strbuf_t *buf)
Serialize value into string buffer.
ecs_script_run
FLECS_API int ecs_script_run(ecs_world_t *world, const char *name, const char *code, ecs_script_eval_result_t *result)
Parse script.
ecs_script_vars_init
FLECS_API ecs_script_vars_t * ecs_script_vars_init(ecs_world_t *world)
Create new variable scope.
ecs_expr_eval
FLECS_API int ecs_expr_eval(const ecs_script_t *script, ecs_value_t *value, const ecs_expr_eval_desc_t *desc)
Evaluate expression.
ecs_script_vars_push
FLECS_API ecs_script_vars_t * ecs_script_vars_push(ecs_script_vars_t *parent)
Push new variable scope.
ecs_script_parse
FLECS_API ecs_script_t * ecs_script_parse(ecs_world_t *world, const char *name, const char *code, const ecs_script_eval_desc_t *desc, ecs_script_eval_result_t *result)
Parse script.
ecs_script_runtime_t
struct ecs_script_runtime_t ecs_script_runtime_t
Runtime for executing scripts.
Definition script.h:94
ecs_const_var_init
FLECS_API ecs_entity_t ecs_const_var_init(ecs_world_t *world, ecs_const_var_desc_t *desc)
Create a const variable that can be accessed by scripts.
FlecsScriptImport
FLECS_API void FlecsScriptImport(ecs_world_t *world)
Script module import function.
ecs_script_string_interpolate
FLECS_API char * ecs_script_string_interpolate(ecs_world_t *world, const char *str, const ecs_script_vars_t *vars)
Evaluate interpolated expressions in string.
ecs_script_run_file
FLECS_API int ecs_script_run_file(ecs_world_t *world, const char *filename)
Parse script file.
ecs_script_vars_lookup
FLECS_API ecs_script_var_t * ecs_script_vars_lookup(const ecs_script_vars_t *vars, const char *name)
Lookup a variable.
ecs_expr_run
FLECS_API const char * ecs_expr_run(ecs_world_t *world, const char *ptr, ecs_value_t *value, const ecs_expr_eval_desc_t *desc)
Run expression.
ecs_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:385
ecs_world_t
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:429
script
script_builder script(const char *name=nullptr) const
Build a script.
Definition mixin.inl:31
ECS_DECLARE
#define ECS_DECLARE(id)
Forward declare an entity, tag, prefab, or any other entity identifier.
Definition flecs_c.h:25
ECS_COMPONENT_DECLARE
#define ECS_COMPONENT_DECLARE(id)
Forward declare a component.
Definition flecs_c.h:112
ecs_ctx_free_t
void(* ecs_ctx_free_t)(void *ctx)
Function to clean up context data.
Definition flecs.h:650
EcsScriptConstVar
Const component.
Definition script.h:138
EcsScript
Script component.
Definition script.h:99
EcsScript::template_
ecs_script_template_t * template_
Only set for template scripts.
Definition script.h:104
EcsScript::error
char * error
Set if script evaluation had errors.
Definition script.h:102
EcsScript::code
char * code
Script source code.
Definition script.h:101
EcsScript::script
ecs_script_t * script
Parsed script object.
Definition script.h:103
EcsScript::filename
char * filename
Script filename.
Definition script.h:100
ecs_const_var_desc_t
Used with ecs_const_var_init().
Definition script.h:697
ecs_const_var_desc_t::parent
ecs_entity_t parent
Variable parent (namespace).
Definition script.h:702
ecs_const_var_desc_t::name
const char * name
Variable name.
Definition script.h:699
ecs_const_var_desc_t::type
ecs_entity_t type
Variable type.
Definition script.h:705
ecs_const_var_desc_t::value
void * value
Pointer to value of variable.
Definition script.h:709
ecs_expr_eval_desc_t
Used with ecs_expr_run().
Definition script.h:585
ecs_expr_eval_desc_t::disable_folding
bool disable_folding
Disable constant folding (slower evaluation, faster parsing).
Definition script.h:597
ecs_expr_eval_desc_t::script_visitor
void * script_visitor
For internal usage.
Definition script.h:610
ecs_expr_eval_desc_t::type
ecs_entity_t type
Type of parsed value (optional).
Definition script.h:589
ecs_expr_eval_desc_t::vars
const ecs_script_vars_t * vars
Variables accessible in expression.
Definition script.h:588
ecs_expr_eval_desc_t::runtime
ecs_script_runtime_t * runtime
Reusable runtime (optional).
Definition script.h:608
ecs_expr_eval_desc_t::allow_unresolved_identifiers
bool allow_unresolved_identifiers
Allow for unresolved identifiers when parsing.
Definition script.h:606
ecs_expr_eval_desc_t::name
const char * name
Script name.
Definition script.h:586
ecs_expr_eval_desc_t::expr
const char * expr
Full expression string.
Definition script.h:587
ecs_expr_eval_desc_t::disable_dynamic_variable_binding
bool disable_dynamic_variable_binding
This option instructs the expression runtime to lookup variables by stack pointer instead of by name,...
Definition script.h:602
ecs_expr_eval_desc_t::lookup_ctx
void * lookup_ctx
Context passed to lookup function.
Definition script.h:594
ecs_function_ctx_t
Script function context.
Definition script.h:108
ecs_function_ctx_t::ctx
void * ctx
User context.
Definition script.h:111
ecs_function_ctx_t::function
ecs_entity_t function
The function entity.
Definition script.h:110
ecs_function_ctx_t::world
ecs_world_t * world
The world.
Definition script.h:109
ecs_function_desc_t
Used with ecs_function_init() and ecs_method_init().
Definition script.h:749
ecs_function_desc_t::return_type
ecs_entity_t return_type
Function return type.
Definition script.h:761
ecs_function_desc_t::name
const char * name
Function name.
Definition script.h:751
ecs_function_desc_t::params
ecs_script_parameter_t params[(16)]
Function parameters.
Definition script.h:758
ecs_function_desc_t::ctx
void * ctx
Context passed to function implementation.
Definition script.h:816
ecs_function_desc_t::callback
ecs_function_callback_t callback
Function implementation.
Definition script.h:764
ecs_function_desc_t::vector_callbacks
ecs_vector_function_callback_t vector_callbacks[(18)]
Vector function implementations.
Definition script.h:813
ecs_function_desc_t::parent
ecs_entity_t parent
Parent of function.
Definition script.h:755
ecs_iter_t
Iterator.
Definition flecs.h:1170
ecs_script_desc_t
Used with ecs_script_init().
Definition script.h:336
ecs_script_desc_t::code
const char * code
Set to parse script from string.
Definition script.h:339
ecs_script_desc_t::entity
ecs_entity_t entity
Set to customize entity handle associated with script.
Definition script.h:337
ecs_script_desc_t::filename
const char * filename
Set to load script from file.
Definition script.h:338
ecs_script_eval_desc_t
Used with ecs_script_parse() and ecs_script_eval().
Definition script.h:168
ecs_script_eval_desc_t::runtime
ecs_script_runtime_t * runtime
Reusable runtime (optional).
Definition script.h:170
ecs_script_eval_desc_t::vars
ecs_script_vars_t * vars
Variables used by script.
Definition script.h:169
ecs_script_eval_result_t
Used to capture error output from script evaluation.
Definition script.h:174
ecs_script_eval_result_t::error
char * error
Error message, or NULL if no error.
Definition script.h:175
ecs_script_eval_result_t::line
int32_t line
Line number (1-based) of first error, or 0 if not available.
Definition script.h:176
ecs_script_eval_result_t::column
int32_t column
Column number (1-based) of first error, or 0 if not available.
Definition script.h:177
ecs_script_function_t
Definition script.h:143
ecs_script_parameter_t
Function argument type.
Definition script.h:130
ecs_script_parameter_t::name
const char * name
Parameter name.
Definition script.h:131
ecs_script_parameter_t::type
ecs_entity_t type
Parameter type.
Definition script.h:132
ecs_script_t
Script object.
Definition script.h:87
ecs_script_t::code
const char * code
Script source code.
Definition script.h:90
ecs_script_t::name
const char * name
Script name.
Definition script.h:89
ecs_script_t::world
ecs_world_t * world
The world.
Definition script.h:88
ecs_script_var_t
Script variable.
Definition script.h:64
ecs_script_var_t::is_const
bool is_const
Whether the variable is constant.
Definition script.h:69
ecs_script_var_t::value
ecs_value_t value
Variable value.
Definition script.h:66
ecs_script_var_t::name
const char * name
Variable name.
Definition script.h:65
ecs_script_var_t::type_info
const ecs_type_info_t * type_info
Type information.
Definition script.h:67
ecs_script_var_t::sp
int32_t sp
Stack pointer.
Definition script.h:68
ecs_script_vars_t
Script variable scope.
Definition script.h:73
ecs_script_vars_t::sp
int32_t sp
Stack pointer for this scope.
Definition script.h:75
ecs_script_vars_t::allocator
ecs_allocator_t * allocator
General purpose allocator.
Definition script.h:83
ecs_script_vars_t::parent
struct ecs_script_vars_t * parent
Parent variable scope.
Definition script.h:74
ecs_script_vars_t::stack
struct ecs_stack_t * stack
Stack allocator for variable storage.
Definition script.h:81
ecs_script_vars_t::cursor
ecs_stack_cursor_t * cursor
Cursor into the stack allocator.
Definition script.h:82
ecs_script_vars_t::var_index
ecs_hashmap_t var_index
Index for variable name lookups.
Definition script.h:77
ecs_script_vars_t::world
const ecs_world_t * world
The world.
Definition script.h:80
ecs_script_vars_t::vars
ecs_vec_t vars
Vector of variables in this scope.
Definition script.h:78
ecs_type_info_t
Type that contains component information (passed to ctors/dtors/...).
Definition flecs.h:1023
ecs_value_t
Utility to hold a value of a dynamic type.
Definition flecs.h:1037
ecs_vector_fn_callbacks_t
Vector function callbacks for different element types.
Definition script.h:743
ecs_vector_fn_callbacks_t::i8
ecs_vector_function_callback_t i8
Callback for i8 element type.
Definition script.h:744
ecs_vector_fn_callbacks_t::i32
ecs_vector_function_callback_t i32
Callback for i32 element type.
Definition script.h:745