/** * @file addons/script/script.h * @brief Flecs script implementation. */ #ifndef FLECS_SCRIPT_PRIVATE_H #define FLECS_SCRIPT_PRIVATE_H #include "../../private_api.h" #include "../parser/parser.h" #ifdef FLECS_SCRIPT typedef struct ecs_script_entity_t ecs_script_entity_t; #define flecs_script_impl(script) ((ecs_script_impl_t*)script) struct ecs_script_impl_t { ecs_script_t pub; ecs_allocator_t allocator; ecs_script_scope_t *root; ecs_expr_node_t *expr; /* Only set if script is just an expression */ char *token_buffer; char *token_remaining; /* Remaining space in token buffer */ const char *next_token; /* First character after expression */ int32_t token_buffer_size; int32_t refcount; }; typedef struct ecs_function_calldata_t { ecs_entity_t function; ecs_function_callback_t callback; void *ctx; } ecs_function_calldata_t; #include "ast.h" #include "expr/expr.h" #include "visit.h" #include "visit_eval.h" #include "template.h" struct ecs_script_runtime_t { ecs_allocator_t allocator; ecs_expr_stack_t expr_stack; ecs_stack_t stack; ecs_vec_t using; ecs_vec_t with; ecs_vec_t with_type_info; ecs_vec_t annot; }; ecs_script_t* flecs_script_new( ecs_world_t *world); ecs_script_scope_t* flecs_script_scope_new( ecs_parser_t *parser); int flecs_script_visit_free( ecs_script_t *script); int flecs_script_visit_free_node( ecs_script_t *script, ecs_script_node_t *node); ecs_script_vars_t* flecs_script_vars_push( ecs_script_vars_t *parent, ecs_stack_t *stack, ecs_allocator_t *allocator); ecs_script_runtime_t* flecs_script_runtime_get( ecs_world_t *world); void flecs_script_register_builtin_functions( ecs_world_t *world); void flecs_function_import( ecs_world_t *world); int flecs_script_check( const ecs_script_t *script, const ecs_script_eval_desc_t *desc); const char* flecs_script_stmt( ecs_parser_t *parser, const char *pos); int ecs_script_ast_node_to_buf( const ecs_script_t *script, ecs_script_node_t *node, ecs_strbuf_t *buf, bool colors, int32_t depth); void ecs_script_runtime_clear( ecs_script_runtime_t *r); #endif // FLECS_SCRIPT #endif // FLECS_SCRIPT_PRIVATE_H