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

Flecs reflection framework. More...

Collaboration diagram for Meta:

Classes

struct  EcsType
 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
 Type that describes an enum constant. More...
 
struct  EcsEnum
 Component added to enum type entities. More...
 
struct  ecs_bitmask_constant_t
 Type that describes an bitmask constant. More...
 
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
 Opaque type reflection data. More...
 
struct  ecs_unit_translation_t
 Helper type to describe translation between two units. More...
 
struct  EcsUnit
 Component that stores unit data. More...
 
struct  EcsUnitPrefix
 Component that stores unit prefix data. More...
 
struct  ecs_meta_type_op_t
 Meta type serializer instruction data. More...
 
struct  EcsTypeSerializer
 Component that stores the type serializer. More...
 
struct  ecs_meta_scope_t
 Type with information about currently serialized scope. More...
 
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)
 Max number of constants/members that can be specified in desc structs.
 
#define ECS_META_MAX_SCOPE_DEPTH   (32)
 Maximum level of type nesting.
 
#define ecs_primitive(world, ...)    ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ )
 Create a primitive type.
 
#define ecs_enum(world, ...)    ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ )
 Create an enum type.
 
#define ecs_bitmask(world, ...)    ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ )
 Create a bitmask type.
 
#define ecs_array(world, ...)    ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ )
 Create an array type.
 
#define ecs_vector(world, ...)    ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ )
 Create a vector type.
 
#define ecs_opaque(world, ...)    ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ )
 Create an opaque type.
 
#define ecs_struct(world, ...)    ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ )
 Create a struct type.
 
#define ecs_unit(world, ...)    ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ )
 Create a unit.
 
#define ecs_unit_prefix(world, ...)    ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ )
 Create a unit prefix.
 
#define ecs_quantity(world, ...)    ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ )
 Create a unit quantity.
 

Typedefs

typedef bool ecs_bool_t
 Primitive type definitions.
 
typedef char ecs_char_t
 Builtin char type.
 
typedef unsigned char ecs_byte_t
 Builtin ecs_byte type.
 
typedef uint8_t ecs_u8_t
 Builtin u8 type.
 
typedef uint16_t ecs_u16_t
 Builtin u16 type.
 
typedef uint32_t ecs_u32_t
 Builtin u32 type.
 
typedef uint64_t ecs_u64_t
 Builtin u64 type.
 
typedef uintptr_t ecs_uptr_t
 Builtin uptr type.
 
typedef int8_t ecs_i8_t
 Builtin i8 type.
 
typedef int16_t ecs_i16_t
 Builtin i16 type.
 
typedef int32_t ecs_i32_t
 Builtin i32 type.
 
typedef int64_t ecs_i64_t
 Builtin i64 type.
 
typedef intptr_t ecs_iptr_t
 Builtin iptr type.
 
typedef float ecs_f32_t
 Builtin f32 type.
 
typedef double ecs_f64_t
 Builtin f64 type.
 
typedef char * ecs_string_t
 Builtin string type.
 
typedef enum ecs_type_kind_t ecs_type_kind_t
 Type kinds supported by meta addon.
 
typedef struct EcsType EcsType
 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
 Type that describes an enum constant.
 
typedef struct EcsEnum EcsEnum
 Component added to enum type entities.
 
typedef struct ecs_bitmask_constant_t ecs_bitmask_constant_t
 Type that describes an bitmask constant.
 
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
 Opaque type reflection data.
 
typedef struct ecs_unit_translation_t ecs_unit_translation_t
 Helper type to describe translation between two units.
 
typedef struct EcsUnit EcsUnit
 Component that stores unit data.
 
typedef struct EcsUnitPrefix EcsUnitPrefix
 Component that stores unit prefix data.
 
typedef enum ecs_meta_type_op_kind_t ecs_meta_type_op_kind_t
 Serializer instruction opcodes.
 
typedef struct ecs_meta_type_op_t ecs_meta_type_op_t
 Meta type serializer instruction data.
 
typedef struct EcsTypeSerializer EcsTypeSerializer
 Component that stores the type serializer.
 
typedef struct ecs_meta_scope_t ecs_meta_scope_t
 Type with information about currently serialized scope.
 
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 , EcsId , EcsPrimitiveKindLast = EcsId
}
 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 , EcsOpId , EcsMetaTypeOpKindLast = EcsOpId
}
 Serializer instruction opcodes. More...
 

Functions

FLECS_API const ecs_entity_t ecs_id (EcsType)
 Id for component added to all types with reflection data.
 
FLECS_API const ecs_entity_t ecs_id (EcsTypeSerializer)
 Id for component that stores a type specific serializer.
 
FLECS_API const ecs_entity_t ecs_id (EcsPrimitive)
 Id for component that stores reflection data for a primitive type.
 
FLECS_API const ecs_entity_t ecs_id (EcsEnum)
 Id for component that stores reflection data for an enum type.
 
FLECS_API const ecs_entity_t ecs_id (EcsBitmask)
 Id for component that stores reflection data for a bitmask type.
 
FLECS_API const ecs_entity_t ecs_id (EcsMember)
 Id for component that stores reflection data for struct members.
 
FLECS_API const ecs_entity_t ecs_id (EcsMemberRanges)
 Id for component that stores min/max ranges for member values.
 
FLECS_API const ecs_entity_t ecs_id (EcsStruct)
 Id for component that stores reflection data for a struct type.
 
FLECS_API const ecs_entity_t ecs_id (EcsArray)
 Id for component that stores reflection data for an array type.
 
FLECS_API const ecs_entity_t ecs_id (EcsVector)
 Id for component that stores reflection data for a vector type.
 
FLECS_API const ecs_entity_t ecs_id (EcsOpaque)
 Id for component that stores reflection data for an opaque type.
 
FLECS_API const ecs_entity_t ecs_id (EcsUnit)
 Id for component that stores unit data.
 
FLECS_API const ecs_entity_t ecs_id (EcsUnitPrefix)
 Id for component that stores unit prefix data.
 
FLECS_API const ecs_entity_t ecs_id (ecs_bool_t)
 Builtin boolean type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_char_t)
 Builtin char type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_byte_t)
 Builtin byte type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_u8_t)
 Builtin 8 bit unsigned int type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_u16_t)
 Builtin 16 bit unsigned int type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_u32_t)
 Builtin 32 bit unsigned int type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_u64_t)
 Builtin 64 bit unsigned int type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_uptr_t)
 Builtin pointer sized unsigned int type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_i8_t)
 Builtin 8 bit signed int type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_i16_t)
 Builtin 16 bit signed int type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_i32_t)
 Builtin 32 bit signed int type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_i64_t)
 Builtin 64 bit signed int type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_iptr_t)
 Builtin pointer sized signed int type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_f32_t)
 Builtin 32 bit floating point type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_f64_t)
 Builtin 64 bit floating point type.
 
FLECS_API const ecs_entity_t ecs_id (ecs_string_t)
 Builtin string type.
 
FLECS_API ecs_meta_cursor_t ecs_meta_cursor (const ecs_world_t *world, ecs_entity_t type, void *ptr)
 Create meta cursor.
 
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 field.
 
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.
 
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 field.
 
FLECS_API ecs_entity_t ecs_meta_get_unit (const ecs_meta_cursor_t *cursor)
 Get unit of current field.
 
FLECS_API const char * ecs_meta_get_member (const ecs_meta_cursor_t *cursor)
 Get member name of current field.
 
FLECS_API ecs_entity_t ecs_meta_get_member_id (const ecs_meta_cursor_t *cursor)
 Get member entity of current field.
 
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_id (ecs_meta_cursor_t *cursor, ecs_id_t value)
 Set field with (component) id 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.
 
ecs_id_t ecs_meta_get_id (const ecs_meta_cursor_t *cursor)
 Get field value as (component) id.
 
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)
 Meta module import function.
 

Variables

FLECS_API const ecs_entity_t EcsConstant
 Tag added to enum/bitmask constants.
 
FLECS_API const ecs_entity_t EcsQuantity
 Tag added to unit quantities.
 

Detailed Description

Flecs reflection framework.

Macro Definition Documentation

◆ ecs_array

#define ecs_array ( world,
... )    ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ )

Create an array type.

Definition at line 1184 of file meta.h.

◆ ecs_bitmask

#define ecs_bitmask ( world,
... )    ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ )

Create a bitmask type.

Definition at line 1180 of file meta.h.

◆ ecs_enum

#define ecs_enum ( world,
... )    ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ )

Create an enum type.

Definition at line 1176 of file meta.h.

◆ ECS_MEMBER_DESC_CACHE_SIZE

#define ECS_MEMBER_DESC_CACHE_SIZE   (32)

Max number of constants/members that can be specified in desc structs.

Definition at line 81 of file meta.h.

◆ ECS_META_MAX_SCOPE_DEPTH

#define ECS_META_MAX_SCOPE_DEPTH   (32)

Maximum level of type nesting.

>32 levels of nesting is not sane.

Definition at line 569 of file meta.h.

◆ ecs_opaque

#define ecs_opaque ( world,
... )    ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ )

Create an opaque type.

Definition at line 1192 of file meta.h.

◆ ecs_primitive

#define ecs_primitive ( world,
... )    ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ )

Create a primitive type.

Definition at line 1172 of file meta.h.

◆ ecs_quantity

#define ecs_quantity ( world,
... )    ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ )

Create a unit quantity.

Definition at line 1208 of file meta.h.

◆ ecs_struct

#define ecs_struct ( world,
... )    ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ )

Create a struct type.

Definition at line 1196 of file meta.h.

◆ ecs_unit

#define ecs_unit ( world,
... )    ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ )

Create a unit.

Definition at line 1200 of file meta.h.

◆ ecs_unit_prefix

#define ecs_unit_prefix ( world,
... )    ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ )

Create a unit prefix.

Definition at line 1204 of file meta.h.

◆ ecs_vector

#define ecs_vector ( world,
... )    ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ )

Create a vector type.

Definition at line 1188 of file meta.h.

◆ FLECS_META_H

#define FLECS_META_H

Definition at line 74 of file meta.h.

Typedef Documentation

◆ ecs_bool_t

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});
int32_t ecs_i32_t
Builtin i32 type.
Definition meta.h:107

Or a more useful example (create an enum constant with a manual value):

ecs_set_pair_second(world, e, EcsConstant, ecs_i32_t, {10});
FLECS_API const ecs_entity_t EcsConstant
Tag added to enum/bitmask constants.

Builtin bool type

Definition at line 97 of file meta.h.

◆ ecs_byte_t

typedef unsigned char ecs_byte_t

Builtin ecs_byte type.

Definition at line 99 of file meta.h.

◆ ecs_char_t

typedef char ecs_char_t

Builtin char type.

Definition at line 98 of file meta.h.

◆ ecs_f32_t

typedef float ecs_f32_t

Builtin f32 type.

Definition at line 110 of file meta.h.

◆ ecs_f64_t

typedef double ecs_f64_t

Builtin f64 type.

Definition at line 111 of file meta.h.

◆ ecs_i16_t

typedef int16_t ecs_i16_t

Builtin i16 type.

Definition at line 106 of file meta.h.

◆ ecs_i32_t

typedef int32_t ecs_i32_t

Builtin i32 type.

Definition at line 107 of file meta.h.

◆ ecs_i64_t

typedef int64_t ecs_i64_t

Builtin i64 type.

Definition at line 108 of file meta.h.

◆ ecs_i8_t

typedef int8_t ecs_i8_t

Builtin i8 type.

Definition at line 105 of file meta.h.

◆ ecs_iptr_t

typedef intptr_t ecs_iptr_t

Builtin iptr type.

Definition at line 109 of file meta.h.

◆ ecs_meta_serialize_t

typedef int(* ecs_meta_serialize_t) (const ecs_serializer_t *ser, const void *src)

Callback invoked serializing an opaque type.

Pointer to value to serialize

Definition at line 382 of file meta.h.

◆ ecs_meta_type_op_kind_t

Serializer instruction opcodes.

The meta type serializer works by generating a flattened array with instructions that tells a serializer what kind of fields can be found in a type at which offsets.

◆ ecs_string_t

typedef char* ecs_string_t

Builtin string type.

Definition at line 112 of file meta.h.

◆ ecs_u16_t

typedef uint16_t ecs_u16_t

Builtin u16 type.

Definition at line 101 of file meta.h.

◆ ecs_u32_t

typedef uint32_t ecs_u32_t

Builtin u32 type.

Definition at line 102 of file meta.h.

◆ ecs_u64_t

typedef uint64_t ecs_u64_t

Builtin u64 type.

Definition at line 103 of file meta.h.

◆ ecs_u8_t

typedef uint8_t ecs_u8_t

Builtin u8 type.

Definition at line 100 of file meta.h.

◆ ecs_unit_translation_t

typedef struct ecs_unit_translation_t ecs_unit_translation_t

Helper type to describe translation between two units.

Note that this is not intended as a generic approach to unit conversions (e.g. from celsius to fahrenheit) but to translate between units that derive from the same base (e.g. meters to kilometers).

Note that power is applied to the factor. When describing a translation of 1000, either use {factor = 1000, power = 1} or {factor = 1, power = 3}.

◆ ecs_uptr_t

typedef uintptr_t ecs_uptr_t

Builtin uptr type.

Definition at line 104 of file meta.h.

◆ EcsOpaque

typedef struct EcsOpaque EcsOpaque

Opaque type reflection data.

An opaque type is a type with an unknown layout that can be mapped to a type known to the reflection framework. See the opaque type reflection examples.

◆ EcsTypeSerializer

typedef struct EcsTypeSerializer EcsTypeSerializer

Component that stores the type serializer.

Added to all types with reflection data.

Enumeration Type Documentation

◆ ecs_meta_type_op_kind_t

Serializer instruction opcodes.

The meta type serializer works by generating a flattened array with instructions that tells a serializer what kind of fields can be found in a type at which offsets.

Enumerator
EcsOpScope 

Marks last constant that can open/close a scope.

EcsOpPrimitive 

Marks first constant that's a primitive.

Definition at line 508 of file meta.h.

◆ ecs_primitive_kind_t

Primitive type kinds supported by meta addon.

Definition at line 172 of file meta.h.

◆ ecs_type_kind_t

Type kinds supported by meta addon.

Definition at line 153 of file meta.h.

Function Documentation

◆ ecs_array_init()

FLECS_API ecs_entity_t ecs_array_init ( ecs_world_t * world,
const ecs_array_desc_t * desc )

Create a new array type.

Parameters
worldThe world.
descThe type descriptor.
Returns
The new type, 0 if failed.

◆ ecs_bitmask_init()

FLECS_API ecs_entity_t ecs_bitmask_init ( ecs_world_t * world,
const ecs_bitmask_desc_t * desc )

Create a new bitmask type.

Parameters
worldThe world.
descThe type descriptor.
Returns
The new type, 0 if failed.

◆ ecs_enum_init()

FLECS_API ecs_entity_t ecs_enum_init ( ecs_world_t * world,
const ecs_enum_desc_t * desc )

Create a new enum type.

Parameters
worldThe world.
descThe type descriptor.
Returns
The new type, 0 if failed.

◆ ecs_id()

FLECS_API const ecs_entity_t ecs_id ( ecs_u64_t )
extern

Builtin 64 bit unsigned int type.

Builtin (component) id type.

Builtin entity type.

◆ ecs_meta_cursor()

FLECS_API ecs_meta_cursor_t ecs_meta_cursor ( const ecs_world_t * world,
ecs_entity_t type,
void * ptr )

Create meta cursor.

A meta cursor allows for walking over, reading and writing a value without having to know its type at compile time.

When a value is assigned through the cursor API, it will get converted to the actual value of the underlying type. This allows the underlying type to change without having to update the serialized data. For example, an integer field can be set by a string, a floating point can be set as integer etc.

Parameters
worldThe world.
typeThe type of the value.
ptrPointer to the value.
Returns
A meta cursor for the value.

◆ ecs_meta_dotmember()

FLECS_API int ecs_meta_dotmember ( ecs_meta_cursor_t * cursor,
const char * name )

Move cursor to member.

Same as ecs_meta_member(), but with support for "foo.bar" syntax.

Parameters
cursorThe cursor.
nameThe name of the member.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_elem()

FLECS_API int ecs_meta_elem ( ecs_meta_cursor_t * cursor,
int32_t elem )

Move cursor to a field.

Parameters
cursorThe cursor.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_get_bool()

FLECS_API bool ecs_meta_get_bool ( const ecs_meta_cursor_t * cursor)

Get field value as boolean.

Parameters
cursorThe cursor.
Returns
The value of the current field.

◆ ecs_meta_get_char()

FLECS_API char ecs_meta_get_char ( const ecs_meta_cursor_t * cursor)

Get field value as char.

Parameters
cursorThe cursor.
Returns
The value of the current field.

◆ ecs_meta_get_entity()

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.

Parameters
cursorThe cursor.
Returns
The value of the current field.

◆ ecs_meta_get_float()

FLECS_API double ecs_meta_get_float ( const ecs_meta_cursor_t * cursor)

Get field value as float.

Parameters
cursorThe cursor.
Returns
The value of the current field.

◆ ecs_meta_get_id()

ecs_id_t ecs_meta_get_id ( const ecs_meta_cursor_t * cursor)

Get field value as (component) id.

This operation can convert from an entity.

Parameters
cursorThe cursor.
Returns
The value of the current field.

◆ ecs_meta_get_int()

FLECS_API int64_t ecs_meta_get_int ( const ecs_meta_cursor_t * cursor)

Get field value as signed integer.

Parameters
cursorThe cursor.
Returns
The value of the current field.

◆ ecs_meta_get_member()

FLECS_API const char * ecs_meta_get_member ( const ecs_meta_cursor_t * cursor)

Get member name of current field.

Parameters
cursorThe cursor.
Returns
The member name of the current field.

◆ ecs_meta_get_member_id()

FLECS_API ecs_entity_t ecs_meta_get_member_id ( const ecs_meta_cursor_t * cursor)

Get member entity of current field.

Parameters
cursorThe cursor.
Returns
The member entity of the current field.

◆ ecs_meta_get_ptr()

FLECS_API void * ecs_meta_get_ptr ( ecs_meta_cursor_t * cursor)

Get pointer to current field.

Parameters
cursorThe cursor.
Returns
A pointer to the current field.

◆ ecs_meta_get_string()

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.

Parameters
cursorThe cursor.
Returns
The value of the current field.

◆ ecs_meta_get_type()

FLECS_API ecs_entity_t ecs_meta_get_type ( const ecs_meta_cursor_t * cursor)

Get type of current field.

Parameters
cursorThe cursor.
Returns
The type of the current field.

◆ ecs_meta_get_uint()

FLECS_API uint64_t ecs_meta_get_uint ( const ecs_meta_cursor_t * cursor)

Get field value as unsigned integer.

Parameters
cursorThe cursor.
Returns
The value of the current field.

◆ ecs_meta_get_unit()

FLECS_API ecs_entity_t ecs_meta_get_unit ( const ecs_meta_cursor_t * cursor)

Get unit of current field.

Parameters
cursorThe cursor.
Returns
The unit of the current field.

◆ ecs_meta_is_collection()

FLECS_API bool ecs_meta_is_collection ( const ecs_meta_cursor_t * cursor)

Is the current scope a collection?.

Parameters
cursorThe cursor.
Returns
True if current scope is a collection, false if not.

◆ ecs_meta_member()

FLECS_API int ecs_meta_member ( ecs_meta_cursor_t * cursor,
const char * name )

Move cursor to member.

Parameters
cursorThe cursor.
nameThe name of the member.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_next()

FLECS_API int ecs_meta_next ( ecs_meta_cursor_t * cursor)

Move cursor to next field.

Parameters
cursorThe cursor.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_pop()

FLECS_API int ecs_meta_pop ( ecs_meta_cursor_t * cursor)

Pop a struct or collection scope (must follow a push).

Parameters
cursorThe cursor.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_ptr_to_float()

FLECS_API double ecs_meta_ptr_to_float ( ecs_primitive_kind_t type_kind,
const void * ptr )

Convert pointer of primitive kind to float.

Parameters
type_kindThe primitive type kind of the value.
ptrPointer to a value of a primitive type.
Returns
The value in floating point format.

◆ ecs_meta_push()

FLECS_API int ecs_meta_push ( ecs_meta_cursor_t * cursor)

Push a scope (required/only valid for structs & collections).

Parameters
cursorThe cursor.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_bool()

FLECS_API int ecs_meta_set_bool ( ecs_meta_cursor_t * cursor,
bool value )

Set field with boolean value.

Parameters
cursorThe cursor.
valueThe value to set.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_char()

FLECS_API int ecs_meta_set_char ( ecs_meta_cursor_t * cursor,
char value )

Set field with char value.

Parameters
cursorThe cursor.
valueThe value to set.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_entity()

FLECS_API int ecs_meta_set_entity ( ecs_meta_cursor_t * cursor,
ecs_entity_t value )

Set field with entity value.

Parameters
cursorThe cursor.
valueThe value to set.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_float()

FLECS_API int ecs_meta_set_float ( ecs_meta_cursor_t * cursor,
double value )

Set field with float value.

Parameters
cursorThe cursor.
valueThe value to set.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_id()

FLECS_API int ecs_meta_set_id ( ecs_meta_cursor_t * cursor,
ecs_id_t value )

Set field with (component) id value.

Parameters
cursorThe cursor.
valueThe value to set.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_int()

FLECS_API int ecs_meta_set_int ( ecs_meta_cursor_t * cursor,
int64_t value )

Set field with int value.

Parameters
cursorThe cursor.
valueThe value to set.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_null()

FLECS_API int ecs_meta_set_null ( ecs_meta_cursor_t * cursor)

Set field with null value.

Parameters
cursorThe cursor.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_string()

FLECS_API int ecs_meta_set_string ( ecs_meta_cursor_t * cursor,
const char * value )

Set field with string value.

Parameters
cursorThe cursor.
valueThe value to set.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_string_literal()

FLECS_API int ecs_meta_set_string_literal ( ecs_meta_cursor_t * cursor,
const char * value )

Set field with string literal value (has enclosing "").

Parameters
cursorThe cursor.
valueThe value to set.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_uint()

FLECS_API int ecs_meta_set_uint ( ecs_meta_cursor_t * cursor,
uint64_t value )

Set field with uint value.

Parameters
cursorThe cursor.
valueThe value to set.
Returns
Zero if success, non-zero if failed.

◆ ecs_meta_set_value()

FLECS_API int ecs_meta_set_value ( ecs_meta_cursor_t * cursor,
const ecs_value_t * value )

Set field with dynamic value.

Parameters
cursorThe cursor.
valueThe value to set.
Returns
Zero if success, non-zero if failed.

◆ ecs_opaque_init()

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:

  • value, which serializes a value (such as .c_str())
  • member, which specifies a member to be serialized (in the case of a struct)
Parameters
worldThe world.
descThe type descriptor.
Returns
The new type, 0 if failed.

◆ ecs_primitive_init()

FLECS_API ecs_entity_t ecs_primitive_init ( ecs_world_t * world,
const ecs_primitive_desc_t * desc )

Create a new primitive type.

Parameters
worldThe world.
descThe type descriptor.
Returns
The new type, 0 if failed.

◆ ecs_quantity_init()

FLECS_API ecs_entity_t ecs_quantity_init ( ecs_world_t * world,
const ecs_entity_desc_t * desc )

Create a new quantity.

Parameters
worldThe world.
descThe quantity descriptor.
Returns
The new quantity, 0 if failed.

◆ ecs_struct_init()

FLECS_API ecs_entity_t ecs_struct_init ( ecs_world_t * world,
const ecs_struct_desc_t * desc )

Create a new struct type.

Parameters
worldThe world.
descThe type descriptor.
Returns
The new type, 0 if failed.

◆ ecs_unit_init()

FLECS_API ecs_entity_t ecs_unit_init ( ecs_world_t * world,
const ecs_unit_desc_t * desc )

Create a new unit.

Parameters
worldThe world.
descThe unit descriptor.
Returns
The new unit, 0 if failed.

◆ ecs_unit_prefix_init()

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.

Parameters
worldThe world.
descThe type descriptor.
Returns
The new unit prefix, 0 if failed.

◆ ecs_vector_init()

FLECS_API ecs_entity_t ecs_vector_init ( ecs_world_t * world,
const ecs_vector_desc_t * desc )

Create a new vector type.

Parameters
worldThe world.
descThe type descriptor.
Returns
The new type, 0 if failed.

◆ FlecsMetaImport()

FLECS_API void FlecsMetaImport ( ecs_world_t * world)

Meta module import function.

Usage:

ECS_IMPORT(world, FlecsMeta)
#define ECS_IMPORT(world, id)
Wrapper around ecs_import().
Definition module.h:119
Parameters
worldThe world.