10struct function_builder {
16 , is_method_(is_method)
28 desc_.return_type =
type;
33 function_builder& return_type() {
38 ecs_assert(param_count_ < FLECS_SCRIPT_FUNCTION_ARGS_MAX - is_method_,
40 desc_.params[param_count_++] = {name,
type};
45 function_builder& param(
const char *name) {
50 desc_.callback = value;
57 ecs_assert(kind > 0 && kind < FLECS_SCRIPT_VECTOR_FUNCTION_COUNT,
59 desc_.vector_callbacks[kind] = value;
68 "vector element type is not a primitive");
69 return vector_callback(
primitive->kind, value);
72 function_builder& ctx(
void *value) {
101 if (name !=
nullptr) {
103 entity_desc.
name = name;
104 entity_desc.
sep =
"::";
#define ecs_assert(condition, error_code,...)
Assert.
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
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.
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.
ecs_entity_t entity_t
Entity type.
ecs_world_t world_t
World type.
ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Find or create an entity.
#define ecs_get(world, entity, T)
Get a component.
ecs_entity_t ecs_get_scope(const ecs_world_t *world)
Get the current scope.
Component added to primitive types.
Used with ecs_entity_init().
const char * sep
Optional custom separator for hierarchical names.
const char * root_sep
Optional, used for identifiers relative to the root.
const char * name
Name of the entity.
Used with ecs_function_init() and ecs_method_init().
Used with ecs_script_init().
script_builder(flecs::world_t *world, const char *name=nullptr)
Construct a script builder.
flecs::entity run() const
Run the script and return the script entity.
script_builder & filename(const char *str)
Set the script filename.
script_builder & code(const char *str)
Set the script code.
flecs::entity primitive(flecs::meta::primitive_kind_t kind)
Create a primitive type.