![]() |
Flecs v3.2
A fast entity component system (ECS) for C & C++
|
Flecs reflection framework. More...
Classes | |
| struct | EcsMetaType |
| Component that is automatically added to every type with the right kind. More... | |
| struct | EcsPrimitive |
| Component added to primitive types. More... | |
| struct | EcsMember |
| Component added to member entities. More... | |
| struct | ecs_member_value_range_t |
| Type expressing a range for a member value. More... | |
| struct | EcsMemberRanges |
| Component added to member entities to express valid value ranges. More... | |
| struct | ecs_member_t |
| Element type of members vector in EcsStruct. More... | |
| struct | EcsStruct |
| Component added to struct type entities. More... | |
| struct | ecs_enum_constant_t |
| struct | EcsEnum |
| Component added to enum type entities. More... | |
| struct | ecs_bitmask_constant_t |
| struct | EcsBitmask |
| Component added to bitmask type entities. More... | |
| struct | EcsArray |
| Component added to array type entities. More... | |
| struct | EcsVector |
| Component added to vector type entities. More... | |
| struct | ecs_serializer_t |
| Serializer interface. More... | |
| struct | EcsOpaque |
| struct | ecs_unit_translation_t |
| struct | EcsUnit |
| struct | EcsUnitPrefix |
| struct | ecs_meta_type_op_t |
| struct | EcsMetaTypeSerialized |
| struct | ecs_meta_scope_t |
| struct | ecs_meta_cursor_t |
| Type that enables iterating/populating a value using reflection data. More... | |
| struct | ecs_primitive_desc_t |
| Used with ecs_primitive_init. More... | |
| struct | ecs_enum_desc_t |
| Used with ecs_enum_init. More... | |
| struct | ecs_bitmask_desc_t |
| Used with ecs_bitmask_init. More... | |
| struct | ecs_array_desc_t |
| Used with ecs_array_init. More... | |
| struct | ecs_vector_desc_t |
| Used with ecs_vector_init. More... | |
| struct | ecs_struct_desc_t |
| Used with ecs_struct_init. More... | |
| struct | ecs_opaque_desc_t |
| Used with ecs_opaque_init. More... | |
| struct | ecs_unit_desc_t |
| Used with ecs_unit_init. More... | |
| struct | ecs_unit_prefix_desc_t |
| Used with ecs_unit_prefix_init. More... | |
Macros | |
| #define | FLECS_META_H |
| #define | ECS_MEMBER_DESC_CACHE_SIZE (32) |
| #define | ECS_META_MAX_SCOPE_DEPTH (32) /* >32 levels of nesting is not sane */ |
| #define | ecs_primitive(world, ...) ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ ) |
| #define | ecs_enum(world, ...) ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ ) |
| #define | ecs_bitmask(world, ...) ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ ) |
| #define | ecs_array(world, ...) ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ ) |
| #define | ecs_vector(world, ...) ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ ) |
| #define | ecs_opaque(world, ...) ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ ) |
| #define | ecs_struct(world, ...) ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ ) |
| #define | ecs_unit(world, ...) ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ ) |
| #define | ecs_unit_prefix(world, ...) ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ ) |
| #define | ecs_quantity(world, ...) ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ ) |
Typedefs | |
| typedef bool | ecs_bool_t |
| Primitive type definitions. | |
| typedef char | ecs_char_t |
| typedef unsigned char | ecs_byte_t |
| typedef uint8_t | ecs_u8_t |
| typedef uint16_t | ecs_u16_t |
| typedef uint32_t | ecs_u32_t |
| typedef uint64_t | ecs_u64_t |
| typedef uintptr_t | ecs_uptr_t |
| typedef int8_t | ecs_i8_t |
| typedef int16_t | ecs_i16_t |
| typedef int32_t | ecs_i32_t |
| typedef int64_t | ecs_i64_t |
| typedef intptr_t | ecs_iptr_t |
| typedef float | ecs_f32_t |
| typedef double | ecs_f64_t |
| typedef char * | ecs_string_t |
| typedef enum ecs_type_kind_t | ecs_type_kind_t |
| Type kinds supported by meta addon. | |
| typedef struct EcsMetaType | EcsMetaType |
| Component that is automatically added to every type with the right kind. | |
| typedef enum ecs_primitive_kind_t | ecs_primitive_kind_t |
| Primitive type kinds supported by meta addon. | |
| typedef struct EcsPrimitive | EcsPrimitive |
| Component added to primitive types. | |
| typedef struct EcsMember | EcsMember |
| Component added to member entities. | |
| typedef struct ecs_member_value_range_t | ecs_member_value_range_t |
| Type expressing a range for a member value. | |
| typedef struct EcsMemberRanges | EcsMemberRanges |
| Component added to member entities to express valid value ranges. | |
| typedef struct ecs_member_t | ecs_member_t |
| Element type of members vector in EcsStruct. | |
| typedef struct EcsStruct | EcsStruct |
| Component added to struct type entities. | |
| typedef struct ecs_enum_constant_t | ecs_enum_constant_t |
| typedef struct EcsEnum | EcsEnum |
| Component added to enum type entities. | |
| typedef struct ecs_bitmask_constant_t | ecs_bitmask_constant_t |
| typedef struct EcsBitmask | EcsBitmask |
| Component added to bitmask type entities. | |
| typedef struct EcsArray | EcsArray |
| Component added to array type entities. | |
| typedef struct EcsVector | EcsVector |
| Component added to vector type entities. | |
| typedef struct ecs_serializer_t | ecs_serializer_t |
| Serializer interface. | |
| typedef int(* | ecs_meta_serialize_t) (const ecs_serializer_t *ser, const void *src) |
| Callback invoked serializing an opaque type. | |
| typedef struct EcsOpaque | EcsOpaque |
| typedef struct ecs_unit_translation_t | ecs_unit_translation_t |
| typedef struct EcsUnit | EcsUnit |
| typedef struct EcsUnitPrefix | EcsUnitPrefix |
| typedef enum ecs_meta_type_op_kind_t | ecs_meta_type_op_kind_t |
| typedef struct ecs_meta_type_op_t | ecs_meta_type_op_t |
| typedef struct EcsMetaTypeSerialized | EcsMetaTypeSerialized |
| typedef struct ecs_meta_scope_t | ecs_meta_scope_t |
| typedef struct ecs_meta_cursor_t | ecs_meta_cursor_t |
| Type that enables iterating/populating a value using reflection data. | |
| typedef struct ecs_primitive_desc_t | ecs_primitive_desc_t |
| Used with ecs_primitive_init. | |
| typedef struct ecs_enum_desc_t | ecs_enum_desc_t |
| Used with ecs_enum_init. | |
| typedef struct ecs_bitmask_desc_t | ecs_bitmask_desc_t |
| Used with ecs_bitmask_init. | |
| typedef struct ecs_array_desc_t | ecs_array_desc_t |
| Used with ecs_array_init. | |
| typedef struct ecs_vector_desc_t | ecs_vector_desc_t |
| Used with ecs_vector_init. | |
| typedef struct ecs_struct_desc_t | ecs_struct_desc_t |
| Used with ecs_struct_init. | |
| typedef struct ecs_opaque_desc_t | ecs_opaque_desc_t |
| Used with ecs_opaque_init. | |
| typedef struct ecs_unit_desc_t | ecs_unit_desc_t |
| Used with ecs_unit_init. | |
| typedef struct ecs_unit_prefix_desc_t | ecs_unit_prefix_desc_t |
| Used with ecs_unit_prefix_init. | |
Enumerations | |
| enum | ecs_type_kind_t { EcsPrimitiveType , EcsBitmaskType , EcsEnumType , EcsStructType , EcsArrayType , EcsVectorType , EcsOpaqueType , EcsTypeKindLast = EcsOpaqueType } |
| Type kinds supported by meta addon. More... | |
| enum | ecs_primitive_kind_t { EcsBool = 1 , EcsChar , EcsByte , EcsU8 , EcsU16 , EcsU32 , EcsU64 , EcsI8 , EcsI16 , EcsI32 , EcsI64 , EcsF32 , EcsF64 , EcsUPtr , EcsIPtr , EcsString , EcsEntity , EcsPrimitiveKindLast = EcsEntity } |
| Primitive type kinds supported by meta addon. More... | |
| enum | ecs_meta_type_op_kind_t { EcsOpArray , EcsOpVector , EcsOpOpaque , EcsOpPush , EcsOpPop , EcsOpScope , EcsOpEnum , EcsOpBitmask , EcsOpPrimitive , EcsOpBool , EcsOpChar , EcsOpByte , EcsOpU8 , EcsOpU16 , EcsOpU32 , EcsOpU64 , EcsOpI8 , EcsOpI16 , EcsOpI32 , EcsOpI64 , EcsOpF32 , EcsOpF64 , EcsOpUPtr , EcsOpIPtr , EcsOpString , EcsOpEntity , EcsMetaTypeOpKindLast = EcsOpEntity } |
Functions | |
| FLECS_API const ecs_entity_t | ecs_id (EcsMetaType) |
| FLECS_API const ecs_entity_t | ecs_id (EcsMetaTypeSerialized) |
| FLECS_API const ecs_entity_t | ecs_id (EcsPrimitive) |
| FLECS_API const ecs_entity_t | ecs_id (EcsEnum) |
| FLECS_API const ecs_entity_t | ecs_id (EcsBitmask) |
| FLECS_API const ecs_entity_t | ecs_id (EcsMember) |
| FLECS_API const ecs_entity_t | ecs_id (EcsMemberRanges) |
| FLECS_API const ecs_entity_t | ecs_id (EcsStruct) |
| FLECS_API const ecs_entity_t | ecs_id (EcsArray) |
| FLECS_API const ecs_entity_t | ecs_id (EcsVector) |
| FLECS_API const ecs_entity_t | ecs_id (EcsOpaque) |
| FLECS_API const ecs_entity_t | ecs_id (EcsUnit) |
| FLECS_API const ecs_entity_t | ecs_id (EcsUnitPrefix) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_bool_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_char_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_byte_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_u8_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_u16_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_u32_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_u64_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_uptr_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_i8_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_i16_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_i32_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_i64_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_iptr_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_f32_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_f64_t) |
| FLECS_API const ecs_entity_t | ecs_id (ecs_string_t) |
| FLECS_API ecs_meta_cursor_t | ecs_meta_cursor (const ecs_world_t *world, ecs_entity_t type, void *ptr) |
| FLECS_API void * | ecs_meta_get_ptr (ecs_meta_cursor_t *cursor) |
| Get pointer to current field. | |
| FLECS_API int | ecs_meta_next (ecs_meta_cursor_t *cursor) |
| Move cursor to next field. | |
| FLECS_API int | ecs_meta_elem (ecs_meta_cursor_t *cursor, int32_t elem) |
| Move cursor to a element. | |
| FLECS_API int | ecs_meta_member (ecs_meta_cursor_t *cursor, const char *name) |
| Move cursor to member. | |
| FLECS_API int | ecs_meta_dotmember (ecs_meta_cursor_t *cursor, const char *name) |
| Move cursor to member, supports dot-separated nested members. | |
| FLECS_API int | ecs_meta_push (ecs_meta_cursor_t *cursor) |
| Push a scope (required/only valid for structs & collections) | |
| FLECS_API int | ecs_meta_pop (ecs_meta_cursor_t *cursor) |
| Pop a struct or collection scope (must follow a push) | |
| FLECS_API bool | ecs_meta_is_collection (const ecs_meta_cursor_t *cursor) |
| Is the current scope a collection? | |
| FLECS_API ecs_entity_t | ecs_meta_get_type (const ecs_meta_cursor_t *cursor) |
| Get type of current element. | |
| FLECS_API ecs_entity_t | ecs_meta_get_unit (const ecs_meta_cursor_t *cursor) |
| Get unit of current element. | |
| FLECS_API const char * | ecs_meta_get_member (const ecs_meta_cursor_t *cursor) |
| Get member name of current member. | |
| FLECS_API ecs_entity_t | ecs_meta_get_member_id (const ecs_meta_cursor_t *cursor) |
| Get member entity of current member. | |
| FLECS_API int | ecs_meta_set_bool (ecs_meta_cursor_t *cursor, bool value) |
| Set field with boolean value. | |
| FLECS_API int | ecs_meta_set_char (ecs_meta_cursor_t *cursor, char value) |
| Set field with char value. | |
| FLECS_API int | ecs_meta_set_int (ecs_meta_cursor_t *cursor, int64_t value) |
| Set field with int value. | |
| FLECS_API int | ecs_meta_set_uint (ecs_meta_cursor_t *cursor, uint64_t value) |
| Set field with uint value. | |
| FLECS_API int | ecs_meta_set_float (ecs_meta_cursor_t *cursor, double value) |
| Set field with float value. | |
| FLECS_API int | ecs_meta_set_string (ecs_meta_cursor_t *cursor, const char *value) |
| Set field with string value. | |
| FLECS_API int | ecs_meta_set_string_literal (ecs_meta_cursor_t *cursor, const char *value) |
| Set field with string literal value (has enclosing "") | |
| FLECS_API int | ecs_meta_set_entity (ecs_meta_cursor_t *cursor, ecs_entity_t value) |
| Set field with entity value. | |
| FLECS_API int | ecs_meta_set_null (ecs_meta_cursor_t *cursor) |
| Set field with null value. | |
| FLECS_API int | ecs_meta_set_value (ecs_meta_cursor_t *cursor, const ecs_value_t *value) |
| Set field with dynamic value. | |
| FLECS_API bool | ecs_meta_get_bool (const ecs_meta_cursor_t *cursor) |
| Get field value as boolean. | |
| FLECS_API char | ecs_meta_get_char (const ecs_meta_cursor_t *cursor) |
| Get field value as char. | |
| FLECS_API int64_t | ecs_meta_get_int (const ecs_meta_cursor_t *cursor) |
| Get field value as signed integer. | |
| FLECS_API uint64_t | ecs_meta_get_uint (const ecs_meta_cursor_t *cursor) |
| Get field value as unsigned integer. | |
| FLECS_API double | ecs_meta_get_float (const ecs_meta_cursor_t *cursor) |
| Get field value as float. | |
| FLECS_API const char * | ecs_meta_get_string (const ecs_meta_cursor_t *cursor) |
| Get field value as string. | |
| FLECS_API ecs_entity_t | ecs_meta_get_entity (const ecs_meta_cursor_t *cursor) |
| Get field value as entity. | |
| FLECS_API double | ecs_meta_ptr_to_float (ecs_primitive_kind_t type_kind, const void *ptr) |
| Convert pointer of primitive kind to float. | |
| FLECS_API ecs_entity_t | ecs_primitive_init (ecs_world_t *world, const ecs_primitive_desc_t *desc) |
| Create a new primitive type. | |
| FLECS_API ecs_entity_t | ecs_enum_init (ecs_world_t *world, const ecs_enum_desc_t *desc) |
| Create a new enum type. | |
| FLECS_API ecs_entity_t | ecs_bitmask_init (ecs_world_t *world, const ecs_bitmask_desc_t *desc) |
| Create a new bitmask type. | |
| FLECS_API ecs_entity_t | ecs_array_init (ecs_world_t *world, const ecs_array_desc_t *desc) |
| Create a new array type. | |
| FLECS_API ecs_entity_t | ecs_vector_init (ecs_world_t *world, const ecs_vector_desc_t *desc) |
| Create a new vector type. | |
| FLECS_API ecs_entity_t | ecs_struct_init (ecs_world_t *world, const ecs_struct_desc_t *desc) |
| Create a new struct type. | |
| FLECS_API ecs_entity_t | ecs_opaque_init (ecs_world_t *world, const ecs_opaque_desc_t *desc) |
| Create a new opaque type. | |
| FLECS_API ecs_entity_t | ecs_unit_init (ecs_world_t *world, const ecs_unit_desc_t *desc) |
| Create a new unit. | |
| FLECS_API ecs_entity_t | ecs_unit_prefix_init (ecs_world_t *world, const ecs_unit_prefix_desc_t *desc) |
| Create a new unit prefix. | |
| FLECS_API ecs_entity_t | ecs_quantity_init (ecs_world_t *world, const ecs_entity_desc_t *desc) |
| Create a new quantity. | |
| FLECS_API void | FlecsMetaImport (ecs_world_t *world) |
Variables | |
| FLECS_API const ecs_entity_t | EcsConstant |
| FLECS_API const ecs_entity_t | EcsQuantity |
Flecs reflection framework.
| #define ecs_array | ( | world, | |
| ... | |||
| ) | ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ ) |
| #define ecs_bitmask | ( | world, | |
| ... | |||
| ) | ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ ) |
| #define ecs_enum | ( | world, | |
| ... | |||
| ) | ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ ) |
| #define ECS_META_MAX_SCOPE_DEPTH (32) /* >32 levels of nesting is not sane */ |
| #define ecs_opaque | ( | world, | |
| ... | |||
| ) | ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ ) |
| #define ecs_primitive | ( | world, | |
| ... | |||
| ) | ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ ) |
| #define ecs_quantity | ( | world, | |
| ... | |||
| ) | ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ ) |
| #define ecs_struct | ( | world, | |
| ... | |||
| ) | ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ ) |
| #define ecs_unit | ( | world, | |
| ... | |||
| ) | ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ ) |
| #define ecs_unit_prefix | ( | world, | |
| ... | |||
| ) | ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ ) |
| #define ecs_vector | ( | world, | |
| ... | |||
| ) | ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ ) |
| typedef bool ecs_bool_t |
Primitive type definitions.
These typedefs allow the builtin primitives to be used as regular components: ecs_set(world, e, ecs_i32_t, {10});
Or a more useful example (create an enum constant with a manual value): ecs_set_pair_object(world, e, EcsConstant, ecs_i32_t, {10});
| typedef int(* ecs_meta_serialize_t) (const ecs_serializer_t *ser, const void *src) |
| enum ecs_primitive_kind_t |
| enum ecs_type_kind_t |
| FLECS_API ecs_entity_t ecs_meta_get_entity | ( | const ecs_meta_cursor_t * | cursor | ) |
Get field value as entity.
This operation does not perform conversions.
| FLECS_API const char * ecs_meta_get_string | ( | const ecs_meta_cursor_t * | cursor | ) |
Get field value as string.
This operation does not perform conversions. If the field is not a string, this operation will fail.
| FLECS_API ecs_entity_t ecs_opaque_init | ( | ecs_world_t * | world, |
| const ecs_opaque_desc_t * | desc | ||
| ) |
Create a new opaque type.
Opaque types are types of which the layout doesn't match what can be modelled with the primitives of the meta framework, but which have a structure that can be described with meta primitives. Typical examples are STL types such as std::string or std::vector, types with a nontrivial layout, and types that only expose getter/setter methods.
An opaque type is a combination of a serialization function, and a handle to a meta type which describes the structure of the serialized output. For example, an opaque type for std::string would have a serializer function that accesses .c_str(), and with type ecs_string_t.
The serializer callback accepts a serializer object and a pointer to the value of the opaque type to be serialized. The serializer has two methods: