Flecs v4.0
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
script.h File Reference

Flecs script module. More...

Go to the source code of this file.

Classes

struct  ecs_script_var_t
 Script variable. More...
 
struct  ecs_script_vars_t
 Script variable scope. More...
 
struct  ecs_script_t
 Script object. More...
 
struct  EcsScript
 Script component. More...
 
struct  ecs_script_desc_t
 Used with ecs_script_init() More...
 
struct  ecs_script_expr_run_desc_t
 Used with ecs_script_expr_run(). More...
 

Macros

#define FLECS_SCRIPT_H
 
#define ecs_script(world, ...)    ecs_script_init(world, &(ecs_script_desc_t) __VA_ARGS__)
 
#define ecs_script_vars_define(vars, name, type)    ecs_script_vars_define_id(vars, name, ecs_id(type))
 

Typedefs

typedef struct ecs_script_template_t ecs_script_template_t
 
typedef struct ecs_script_var_t ecs_script_var_t
 Script variable.
 
typedef struct ecs_script_vars_t ecs_script_vars_t
 Script variable scope.
 
typedef struct ecs_script_t ecs_script_t
 Script object.
 
typedef struct EcsScript EcsScript
 Script component.
 
typedef struct ecs_script_desc_t ecs_script_desc_t
 Used with ecs_script_init()
 
typedef struct ecs_script_expr_run_desc_t ecs_script_expr_run_desc_t
 Used with ecs_script_expr_run().
 

Functions

FLECS_API ECS_COMPONENT_DECLARE (EcsScript)
 
FLECS_API ecs_script_tecs_script_parse (ecs_world_t *world, const char *name, const char *code)
 Parse script.
 
FLECS_API int ecs_script_eval (ecs_script_t *script)
 Evaluate script.
 
FLECS_API void ecs_script_free (ecs_script_t *script)
 Free script.
 
FLECS_API int ecs_script_run (ecs_world_t *world, const char *name, const char *code)
 Parse script.
 
FLECS_API int ecs_script_run_file (ecs_world_t *world, const char *filename)
 Parse script file.
 
FLECS_API int ecs_script_ast_to_buf (ecs_script_t *script, ecs_strbuf_t *buf)
 Convert script AST to string.
 
FLECS_API char * ecs_script_ast_to_str (ecs_script_t *script)
 Convert script AST to string.
 
FLECS_API ecs_entity_t ecs_script_init (ecs_world_t *world, const ecs_script_desc_t *desc)
 Load managed script.
 
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.
 
FLECS_API void ecs_script_clear (ecs_world_t *world, ecs_entity_t script, ecs_entity_t instance)
 Clear all entities associated with script.
 
FLECS_API ecs_script_vars_tecs_script_vars_init (ecs_world_t *world)
 Create new variable scope.
 
FLECS_API void ecs_script_vars_fini (ecs_script_vars_t *vars)
 Free variable scope.
 
FLECS_API ecs_script_vars_tecs_script_vars_push (ecs_script_vars_t *parent)
 Push new variable scope.
 
FLECS_API ecs_script_vars_tecs_script_vars_pop (ecs_script_vars_t *vars)
 Pop variable scope.
 
FLECS_API ecs_script_var_tecs_script_vars_declare (ecs_script_vars_t *vars, const char *name)
 Declare a variable.
 
FLECS_API ecs_script_var_tecs_script_vars_define_id (ecs_script_vars_t *vars, const char *name, ecs_entity_t type)
 Define a variable.
 
FLECS_API ecs_script_var_tecs_script_vars_lookup (const ecs_script_vars_t *vars, const char *name)
 Lookup a variable.
 
FLECS_API void ecs_script_vars_from_iter (const ecs_iter_t *it, ecs_script_vars_t *vars, int offset)
 Convert iterator to vars This operation converts an iterator to a variable array.
 
FLECS_API const char * ecs_script_expr_run (ecs_world_t *world, const char *ptr, ecs_value_t *value, const ecs_script_expr_run_desc_t *desc)
 Parse standalone expression into value.
 
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.
 
FLECS_API char * ecs_ptr_to_expr (const ecs_world_t *world, ecs_entity_t type, const void *data)
 Serialize value into expression string.
 
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.
 
FLECS_API char * ecs_ptr_to_str (const ecs_world_t *world, ecs_entity_t type, const void *data)
 Similar as ecs_ptr_to_expr(), but serializes values to string.
 
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.
 
FLECS_API void FlecsScriptImport (ecs_world_t *world)
 Script module import function.
 

Detailed Description

Flecs script module.

For script, see examples/script.

Definition in file script.h.