Flecs v4.0
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
meta.h
Go to the documentation of this file.
1
57#ifdef FLECS_META
58
67#include <stddef.h>
68
69#ifndef FLECS_MODULE
70#define FLECS_MODULE
71#endif
72
73#ifndef FLECS_META_H
74#define FLECS_META_H
75
76#ifdef __cplusplus
77extern "C" {
78#endif
79
81#define ECS_MEMBER_DESC_CACHE_SIZE (32)
82
97typedef bool ecs_bool_t;
98typedef char ecs_char_t;
99typedef unsigned char ecs_byte_t;
100typedef uint8_t ecs_u8_t;
101typedef uint16_t ecs_u16_t;
102typedef uint32_t ecs_u32_t;
103typedef uint64_t ecs_u64_t;
104typedef uintptr_t ecs_uptr_t;
105typedef int8_t ecs_i8_t;
106typedef int16_t ecs_i16_t;
107typedef int32_t ecs_i32_t;
108typedef int64_t ecs_i64_t;
109typedef intptr_t ecs_iptr_t;
110typedef float ecs_f32_t;
111typedef double ecs_f64_t;
112typedef char* ecs_string_t;
114/* Meta module component ids */
115FLECS_API extern const ecs_entity_t ecs_id(EcsType);
116FLECS_API extern const ecs_entity_t ecs_id(EcsTypeSerializer);
117FLECS_API extern const ecs_entity_t ecs_id(EcsPrimitive);
118FLECS_API extern const ecs_entity_t ecs_id(EcsEnum);
119FLECS_API extern const ecs_entity_t ecs_id(EcsBitmask);
120FLECS_API extern const ecs_entity_t ecs_id(EcsMember);
121FLECS_API extern const ecs_entity_t ecs_id(EcsMemberRanges);
122FLECS_API extern const ecs_entity_t ecs_id(EcsStruct);
123FLECS_API extern const ecs_entity_t ecs_id(EcsArray);
124FLECS_API extern const ecs_entity_t ecs_id(EcsVector);
125FLECS_API extern const ecs_entity_t ecs_id(EcsOpaque);
126FLECS_API extern const ecs_entity_t ecs_id(EcsUnit);
127FLECS_API extern const ecs_entity_t ecs_id(EcsUnitPrefix);
128FLECS_API extern const ecs_entity_t EcsConstant;
129FLECS_API extern const ecs_entity_t EcsQuantity;
131/* Primitive type component ids */
132
133FLECS_API extern const ecs_entity_t ecs_id(ecs_bool_t);
134FLECS_API extern const ecs_entity_t ecs_id(ecs_char_t);
135FLECS_API extern const ecs_entity_t ecs_id(ecs_byte_t);
136FLECS_API extern const ecs_entity_t ecs_id(ecs_u8_t);
137FLECS_API extern const ecs_entity_t ecs_id(ecs_u16_t);
138FLECS_API extern const ecs_entity_t ecs_id(ecs_u32_t);
139FLECS_API extern const ecs_entity_t ecs_id(ecs_u64_t);
140FLECS_API extern const ecs_entity_t ecs_id(ecs_uptr_t);
141FLECS_API extern const ecs_entity_t ecs_id(ecs_i8_t);
142FLECS_API extern const ecs_entity_t ecs_id(ecs_i16_t);
143FLECS_API extern const ecs_entity_t ecs_id(ecs_i32_t);
144FLECS_API extern const ecs_entity_t ecs_id(ecs_i64_t);
145FLECS_API extern const ecs_entity_t ecs_id(ecs_iptr_t);
146FLECS_API extern const ecs_entity_t ecs_id(ecs_f32_t);
147FLECS_API extern const ecs_entity_t ecs_id(ecs_f64_t);
148FLECS_API extern const ecs_entity_t ecs_id(ecs_string_t);
149FLECS_API extern const ecs_entity_t ecs_id(ecs_entity_t);
150FLECS_API extern const ecs_entity_t ecs_id(ecs_id_t);
153typedef enum ecs_type_kind_t {
154 EcsPrimitiveType,
155 EcsBitmaskType,
156 EcsEnumType,
157 EcsStructType,
158 EcsArrayType,
159 EcsVectorType,
160 EcsOpaqueType,
161 EcsTypeKindLast = EcsOpaqueType
163
170
173 EcsBool = 1,
174 EcsChar,
175 EcsByte,
176 EcsU8,
177 EcsU16,
178 EcsU32,
179 EcsU64,
180 EcsI8,
181 EcsI16,
182 EcsI32,
183 EcsI64,
184 EcsF32,
185 EcsF64,
186 EcsUPtr,
187 EcsIPtr,
188 EcsString,
189 EcsEntity,
190 EcsId,
191 EcsPrimitiveKindLast = EcsId
193
198
207
213
220
263
265typedef struct EcsStruct {
267 ecs_vec_t members; /* vector<ecs_member_t> */
269
281
283typedef struct EcsEnum {
285 ecs_map_t constants;
287
291 const char *name;
292
294 ecs_flags32_t value;
295
299
301typedef struct EcsBitmask {
302 /* Populated from child entities with Constant component */
303 ecs_map_t constants;
305
311
316
317
318/* Opaque type support */
319
320#if !defined(__cplusplus) || !defined(FLECS_CPP)
321
323typedef struct ecs_serializer_t {
324 /* Serialize value */
325 int (*value)(
326 const struct ecs_serializer_t *ser,
327 ecs_entity_t type,
328 const void *value);
330 /* Serialize member */
331 int (*member)(
332 const struct ecs_serializer_t *ser,
333 const char *member);
336 void *ctx;
338
339#elif defined(__cplusplus)
340
341} /* extern "C" { */
342
344typedef struct ecs_serializer_t {
345 /* Serialize value */
346 int (*value_)(
347 const struct ecs_serializer_t *ser,
348 ecs_entity_t type,
349 const void *value);
350
351 /* Serialize member */
352 int (*member_)(
353 const struct ecs_serializer_t *ser,
354 const char *name);
355
356 /* Serialize value */
357 int value(ecs_entity_t type, const void *value) const;
358
359 /* Serialize value */
360 template <typename T>
361 int value(const T& value) const;
362
363 /* Serialize member */
364 int member(const char *name) const;
365
366 const ecs_world_t *world;
367 void *ctx;
369
370extern "C" {
371#endif
372
374typedef int (*ecs_meta_serialize_t)(
375 const ecs_serializer_t *ser,
376 const void *src);
382typedef struct EcsOpaque {
386 /* Deserializer interface
387 * Only override the callbacks that are valid for the opaque type. If a
388 * deserializer attempts to assign a value type that is not supported by the
389 * interface, a conversion error is thrown.
390 */
391
393 void (*assign_bool)(
394 void *dst,
395 bool value);
396
398 void (*assign_char)(
399 void *dst,
400 char value);
401
403 void (*assign_int)(
404 void *dst,
405 int64_t value);
406
408 void (*assign_uint)(
409 void *dst,
410 uint64_t value);
411
414 void *dst,
415 double value);
416
419 void *dst,
420 const char *value);
421
424 void *dst,
425 ecs_world_t *world,
426 ecs_entity_t entity);
427
429 void (*assign_id)(
430 void *dst,
431 ecs_world_t *world,
432 ecs_id_t id);
433
435 void (*assign_null)(
436 void *dst);
437
439 void (*clear)(
440 void *dst);
441
443 void* (*ensure_element)(
444 void *dst,
445 size_t elem);
446
448 void* (*ensure_member)(
449 void *dst,
450 const char *member);
451
453 size_t (*count)(
454 const void *dst);
455
457 void (*resize)(
458 void *dst,
459 size_t count);
461
462
463/* Units */
464
476
485
491
492
493/* Serializer utilities */
494
501 EcsOpArray,
502 EcsOpVector,
503 EcsOpOpaque,
504 EcsOpPush,
505 EcsOpPop,
506
509 EcsOpEnum,
510 EcsOpBitmask,
511
514 EcsOpBool,
515 EcsOpChar,
516 EcsOpByte,
517 EcsOpU8,
518 EcsOpU16,
519 EcsOpU32,
520 EcsOpU64,
521 EcsOpI8,
522 EcsOpI16,
523 EcsOpI32,
524 EcsOpI64,
525 EcsOpF32,
526 EcsOpF64,
527 EcsOpUPtr,
528 EcsOpIPtr,
529 EcsOpString,
530 EcsOpEntity,
531 EcsOpId,
532 EcsMetaTypeOpKindLast = EcsOpId
534
536typedef struct ecs_meta_type_op_t {
538 ecs_size_t offset;
539 int32_t count;
540 const char *name;
541 int32_t op_count;
542 ecs_size_t size;
544 int32_t member_index;
545 ecs_hashmap_t *members;
547
551typedef struct EcsTypeSerializer {
552 ecs_vec_t ops;
554
555
556/* Deserializer utilities */
557
561#define ECS_META_MAX_SCOPE_DEPTH (32)
562
580
593
608FLECS_API
610 const ecs_world_t *world,
611 ecs_entity_t type,
612 void *ptr);
613
619FLECS_API
621 ecs_meta_cursor_t *cursor);
622
628FLECS_API
630 ecs_meta_cursor_t *cursor);
631
637FLECS_API
639 ecs_meta_cursor_t *cursor,
640 int32_t elem);
641
648FLECS_API
650 ecs_meta_cursor_t *cursor,
651 const char *name);
652
660FLECS_API
662 ecs_meta_cursor_t *cursor,
663 const char *name);
664
670FLECS_API
672 ecs_meta_cursor_t *cursor);
673
679FLECS_API
681 ecs_meta_cursor_t *cursor);
682
688FLECS_API
690 const ecs_meta_cursor_t *cursor);
691
697FLECS_API
699 const ecs_meta_cursor_t *cursor);
700
706FLECS_API
708 const ecs_meta_cursor_t *cursor);
709
715FLECS_API
717 const ecs_meta_cursor_t *cursor);
718
724FLECS_API
726 const ecs_meta_cursor_t *cursor);
727
728/* The set functions assign the field with the specified value. If the value
729 * does not have the same type as the field, it will be cased to the field type.
730 * If no valid conversion is available, the operation will fail. */
731
738FLECS_API
740 ecs_meta_cursor_t *cursor,
741 bool value);
742
749FLECS_API
751 ecs_meta_cursor_t *cursor,
752 char value);
753
760FLECS_API
762 ecs_meta_cursor_t *cursor,
763 int64_t value);
764
771FLECS_API
773 ecs_meta_cursor_t *cursor,
774 uint64_t value);
775
782FLECS_API
784 ecs_meta_cursor_t *cursor,
785 double value);
786
793FLECS_API
795 ecs_meta_cursor_t *cursor,
796 const char *value);
797
804FLECS_API
806 ecs_meta_cursor_t *cursor,
807 const char *value);
808
815FLECS_API
817 ecs_meta_cursor_t *cursor,
818 ecs_entity_t value);
819
826FLECS_API
828 ecs_meta_cursor_t *cursor,
829 ecs_id_t value);
830
836FLECS_API
838 ecs_meta_cursor_t *cursor);
839
846FLECS_API
848 ecs_meta_cursor_t *cursor,
849 const ecs_value_t *value);
850
851/* Functions for getting members. */
852
858FLECS_API
860 const ecs_meta_cursor_t *cursor);
861
867FLECS_API
869 const ecs_meta_cursor_t *cursor);
870
876FLECS_API
878 const ecs_meta_cursor_t *cursor);
879
885FLECS_API
887 const ecs_meta_cursor_t *cursor);
888
894FLECS_API
896 const ecs_meta_cursor_t *cursor);
897
905FLECS_API
907 const ecs_meta_cursor_t *cursor);
908
915FLECS_API
917 const ecs_meta_cursor_t *cursor);
918
926 const ecs_meta_cursor_t *cursor);
927
934FLECS_API
936 ecs_primitive_kind_t type_kind,
937 const void *ptr);
938
939/* API functions for creating meta types */
940
946
953FLECS_API
955 ecs_world_t *world,
956 const ecs_primitive_desc_t *desc);
957
958
964
971FLECS_API
973 ecs_world_t *world,
974 const ecs_enum_desc_t *desc);
975
976
982
989FLECS_API
991 ecs_world_t *world,
992 const ecs_bitmask_desc_t *desc);
993
994
1001
1008FLECS_API
1010 ecs_world_t *world,
1011 const ecs_array_desc_t *desc);
1012
1013
1019
1026FLECS_API
1028 ecs_world_t *world,
1029 const ecs_vector_desc_t *desc);
1030
1031
1037
1044FLECS_API
1046 ecs_world_t *world,
1047 const ecs_struct_desc_t *desc);
1048
1049
1055
1078FLECS_API
1080 ecs_world_t *world,
1081 const ecs_opaque_desc_t *desc);
1082
1083
1112
1119FLECS_API
1121 ecs_world_t *world,
1122 const ecs_unit_desc_t *desc);
1123
1124
1136
1143FLECS_API
1145 ecs_world_t *world,
1146 const ecs_unit_prefix_desc_t *desc);
1147
1148
1155FLECS_API
1157 ecs_world_t *world,
1158 const ecs_entity_desc_t *desc);
1159
1160/* Convenience macros */
1161
1163#define ecs_primitive(world, ...)\
1164 ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ )
1165
1167#define ecs_enum(world, ...)\
1168 ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ )
1169
1171#define ecs_bitmask(world, ...)\
1172 ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ )
1173
1175#define ecs_array(world, ...)\
1176 ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ )
1177
1179#define ecs_vector(world, ...)\
1180 ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ )
1181
1183#define ecs_opaque(world, ...)\
1184 ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ )
1185
1187#define ecs_struct(world, ...)\
1188 ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ )
1189
1191#define ecs_unit(world, ...)\
1192 ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ )
1193
1195#define ecs_unit_prefix(world, ...)\
1196 ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ )
1197
1199#define ecs_quantity(world, ...)\
1200 ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ )
1201
1202
1211FLECS_API
1213 ecs_world_t *world);
1214
1215#ifdef __cplusplus
1216}
1217#endif
1218
1219#include "meta_c.h"
1220
1221#endif
1222
1225#endif
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_next(ecs_meta_cursor_t *cursor)
Move cursor to next field.
FLECS_API int ecs_meta_set_uint(ecs_meta_cursor_t *cursor, uint64_t value)
Set field with uint value.
struct EcsMember EcsMember
Component added to member entities.
ecs_id_t ecs_meta_get_id(const ecs_meta_cursor_t *cursor)
Get field value as (component) id.
FLECS_API bool ecs_meta_get_bool(const ecs_meta_cursor_t *cursor)
Get field value as boolean.
struct EcsPrimitive EcsPrimitive
Component added to primitive types.
bool ecs_bool_t
Primitive type definitions.
Definition meta.h:97
struct ecs_vector_desc_t ecs_vector_desc_t
Used with ecs_vector_init().
FLECS_API const ecs_entity_t ecs_id(EcsType)
Id for component added to all types with reflection data.
FLECS_API ecs_entity_t ecs_bitmask_init(ecs_world_t *world, const ecs_bitmask_desc_t *desc)
Create a new bitmask type.
struct EcsEnum EcsEnum
Component added to enum type entities.
uint32_t ecs_u32_t
Builtin u32 type.
Definition meta.h:102
struct ecs_meta_type_op_t ecs_meta_type_op_t
Meta type serializer instruction data.
FLECS_API double ecs_meta_ptr_to_float(ecs_primitive_kind_t type_kind, const void *ptr)
Convert pointer of primitive kind to float.
struct ecs_bitmask_constant_t ecs_bitmask_constant_t
Type that describes an bitmask constant.
int16_t ecs_i16_t
Builtin i16 type.
Definition meta.h:106
struct ecs_meta_cursor_t ecs_meta_cursor_t
Type that enables iterating/populating a value using reflection data.
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 ecs_entity_t ecs_opaque_init(ecs_world_t *world, const ecs_opaque_desc_t *desc)
Create a new opaque type.
FLECS_API int ecs_meta_set_float(ecs_meta_cursor_t *cursor, double value)
Set field with float value.
struct ecs_enum_desc_t ecs_enum_desc_t
Used with ecs_enum_init().
FLECS_API int ecs_meta_dotmember(ecs_meta_cursor_t *cursor, const char *name)
Move cursor to member.
struct EcsStruct EcsStruct
Component added to struct type entities.
FLECS_API ecs_entity_t ecs_meta_get_entity(const ecs_meta_cursor_t *cursor)
Get field value as entity.
uint8_t ecs_u8_t
Builtin u8 type.
Definition meta.h:100
struct ecs_member_t ecs_member_t
Element type of members vector in EcsStruct.
struct EcsVector EcsVector
Component added to vector type entities.
int64_t ecs_i64_t
Builtin i64 type.
Definition meta.h:108
FLECS_API bool ecs_meta_is_collection(const ecs_meta_cursor_t *cursor)
Is the current scope a collection?.
struct ecs_serializer_t ecs_serializer_t
Serializer interface.
char * ecs_string_t
Builtin string type.
Definition meta.h:112
struct EcsBitmask EcsBitmask
Component added to bitmask type entities.
struct ecs_member_value_range_t ecs_member_value_range_t
Type expressing a range for a member value.
FLECS_API const ecs_entity_t EcsConstant
Tag added to enum/bitmask constants.
uint64_t ecs_u64_t
Builtin u64 type.
Definition meta.h:103
intptr_t ecs_iptr_t
Builtin iptr type.
Definition meta.h:109
struct EcsOpaque EcsOpaque
Opaque type reflection data.
FLECS_API ecs_entity_t ecs_quantity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Create a new quantity.
FLECS_API int ecs_meta_set_id(ecs_meta_cursor_t *cursor, ecs_id_t value)
Set field with (component) id value.
uintptr_t ecs_uptr_t
Builtin uptr type.
Definition meta.h:104
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 ecs_entity_t ecs_meta_get_unit(const ecs_meta_cursor_t *cursor)
Get unit of current field.
FLECS_API const ecs_entity_t EcsQuantity
Tag added to unit quantities.
float ecs_f32_t
Builtin f32 type.
Definition meta.h:110
FLECS_API void FlecsMetaImport(ecs_world_t *world)
Meta module import function.
ecs_primitive_kind_t
Primitive type kinds supported by meta addon.
Definition meta.h:172
FLECS_API ecs_entity_t ecs_meta_get_member_id(const ecs_meta_cursor_t *cursor)
Get member entity of current field.
FLECS_API const char * ecs_meta_get_string(const ecs_meta_cursor_t *cursor)
Get field value as string.
FLECS_API const char * ecs_meta_get_member(const ecs_meta_cursor_t *cursor)
Get member name of current field.
struct EcsArray EcsArray
Component added to array type entities.
struct ecs_array_desc_t ecs_array_desc_t
Used with ecs_array_init().
FLECS_API double ecs_meta_get_float(const ecs_meta_cursor_t *cursor)
Get field value as float.
FLECS_API int ecs_meta_pop(ecs_meta_cursor_t *cursor)
Pop a struct or collection scope (must follow a push).
FLECS_API ecs_entity_t ecs_meta_get_type(const ecs_meta_cursor_t *cursor)
Get type of current field.
FLECS_API uint64_t ecs_meta_get_uint(const ecs_meta_cursor_t *cursor)
Get field value as unsigned integer.
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 char ecs_meta_get_char(const ecs_meta_cursor_t *cursor)
Get field value as char.
ecs_meta_type_op_kind_t
Serializer instruction opcodes.
Definition meta.h:500
double ecs_f64_t
Builtin f64 type.
Definition meta.h:111
char ecs_char_t
Builtin char type.
Definition meta.h:98
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.
struct ecs_opaque_desc_t ecs_opaque_desc_t
Used with ecs_opaque_init().
FLECS_API int ecs_meta_elem(ecs_meta_cursor_t *cursor, int32_t elem)
Move cursor to a field.
struct ecs_enum_constant_t ecs_enum_constant_t
Type that describes an enum constant.
FLECS_API int64_t ecs_meta_get_int(const ecs_meta_cursor_t *cursor)
Get field value as signed integer.
struct ecs_primitive_desc_t ecs_primitive_desc_t
Used with ecs_primitive_init().
ecs_type_kind_t
Type kinds supported by meta addon.
Definition meta.h:153
struct ecs_unit_translation_t ecs_unit_translation_t
Helper type to describe translation between two units.
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_unit_init(ecs_world_t *world, const ecs_unit_desc_t *desc)
Create a new unit.
uint16_t ecs_u16_t
Builtin u16 type.
Definition meta.h:101
int(* ecs_meta_serialize_t)(const ecs_serializer_t *ser, const void *src)
Callback invoked serializing an opaque type.
Definition meta.h:374
FLECS_API int ecs_meta_set_string(ecs_meta_cursor_t *cursor, const char *value)
Set field with string value.
struct ecs_struct_desc_t ecs_struct_desc_t
Used with ecs_struct_init().
#define ECS_META_MAX_SCOPE_DEPTH
Maximum level of type nesting.
Definition meta.h:561
int32_t ecs_i32_t
Builtin i32 type.
Definition meta.h:107
FLECS_API int ecs_meta_member(ecs_meta_cursor_t *cursor, const char *name)
Move cursor to member.
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_struct_init(ecs_world_t *world, const ecs_struct_desc_t *desc)
Create a new struct type.
struct EcsType EcsType
Component that is automatically added to every type with the right kind.
FLECS_API int ecs_meta_set_bool(ecs_meta_cursor_t *cursor, bool value)
Set field with boolean value.
int8_t ecs_i8_t
Builtin i8 type.
Definition meta.h:105
unsigned char ecs_byte_t
Builtin ecs_byte type.
Definition meta.h:99
struct EcsUnitPrefix EcsUnitPrefix
Component that stores unit prefix data.
FLECS_API int ecs_meta_set_char(ecs_meta_cursor_t *cursor, char value)
Set field with char value.
struct ecs_unit_desc_t ecs_unit_desc_t
Used with ecs_unit_init().
struct ecs_meta_scope_t ecs_meta_scope_t
Type with information about currently serialized scope.
#define ECS_MEMBER_DESC_CACHE_SIZE
Max number of constants/members that can be specified in desc structs.
Definition meta.h:81
FLECS_API void * ecs_meta_get_ptr(ecs_meta_cursor_t *cursor)
Get pointer to current field.
struct EcsMemberRanges EcsMemberRanges
Component added to member entities to express valid value ranges.
struct EcsTypeSerializer EcsTypeSerializer
Component that stores the type serializer.
struct EcsUnit EcsUnit
Component that stores unit data.
FLECS_API int ecs_meta_set_value(ecs_meta_cursor_t *cursor, const ecs_value_t *value)
Set field with dynamic value.
FLECS_API int ecs_meta_set_null(ecs_meta_cursor_t *cursor)
Set field with null value.
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 int ecs_meta_set_entity(ecs_meta_cursor_t *cursor, ecs_entity_t value)
Set field with entity value.
struct ecs_unit_prefix_desc_t ecs_unit_prefix_desc_t
Used with ecs_unit_prefix_init().
struct ecs_bitmask_desc_t ecs_bitmask_desc_t
Used with ecs_bitmask_init().
FLECS_API int ecs_meta_push(ecs_meta_cursor_t *cursor)
Push a scope (required/only valid for structs & collections).
@ EcsOpPrimitive
Marks first constant that's a primitive.
Definition meta.h:512
@ EcsOpScope
Marks last constant that can open/close a scope.
Definition meta.h:507
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:347
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:391
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:340
Utility macros for populating reflection data in C.
Component added to array type entities.
Definition meta.h:307
int32_t count
Number of elements.
Definition meta.h:309
ecs_entity_t type
Element type.
Definition meta.h:308
Component added to bitmask type entities.
Definition meta.h:301
ecs_map_t constants
map<u32_t, ecs_bitmask_constant_t>
Definition meta.h:303
Component information.
Definition flecs.h:1450
Component added to enum type entities.
Definition meta.h:283
ecs_map_t constants
Populated from child entities with Constant component.
Definition meta.h:285
Component added to member entities to express valid value ranges.
Definition meta.h:215
ecs_member_value_range_t warning
Member value warning range.
Definition meta.h:217
ecs_member_value_range_t value
Member value range.
Definition meta.h:216
ecs_member_value_range_t error
Member value error range.
Definition meta.h:218
Component added to member entities.
Definition meta.h:200
ecs_entity_t unit
Member unit.
Definition meta.h:203
bool use_offset
If offset should be explicitly used.
Definition meta.h:205
ecs_entity_t type
Member type.
Definition meta.h:201
int32_t offset
Member offset.
Definition meta.h:204
int32_t count
Number of elements (for inline arrays).
Definition meta.h:202
Opaque type reflection data.
Definition meta.h:382
size_t(* count)(const void *dst)
Return number of elements.
Definition meta.h:453
void(* assign_null)(void *dst)
Assign null value.
Definition meta.h:435
void(* clear)(void *dst)
Clear collection elements.
Definition meta.h:439
void(* assign_uint)(void *dst, uint64_t value)
Assign unsigned int value.
Definition meta.h:408
ecs_meta_serialize_t serialize
Serialize action.
Definition meta.h:384
void(* assign_char)(void *dst, char value)
Assign char value.
Definition meta.h:398
ecs_entity_t as_type
Type that describes the serialized output.
Definition meta.h:383
void(* assign_bool)(void *dst, bool value)
Assign bool value.
Definition meta.h:393
void(* assign_string)(void *dst, const char *value)
Assign string value.
Definition meta.h:418
void(* resize)(void *dst, size_t count)
Resize to number of elements.
Definition meta.h:457
void(* assign_int)(void *dst, int64_t value)
Assign int value.
Definition meta.h:403
void(* assign_float)(void *dst, double value)
Assign float value.
Definition meta.h:413
void(* assign_entity)(void *dst, ecs_world_t *world, ecs_entity_t entity)
Assign entity value.
Definition meta.h:423
void(* assign_id)(void *dst, ecs_world_t *world, ecs_id_t id)
Assign (component) id value.
Definition meta.h:429
Component added to primitive types.
Definition meta.h:195
ecs_primitive_kind_t kind
Primitive type kind.
Definition meta.h:196
Component added to struct type entities.
Definition meta.h:265
ecs_vec_t members
Populated from child entities with Member component.
Definition meta.h:267
Component that stores the type serializer.
Definition meta.h:551
ecs_vec_t ops
vector<ecs_meta_type_op_t>
Definition meta.h:552
Component that is automatically added to every type with the right kind.
Definition meta.h:165
bool existing
Did the type exist or is it populated from reflection.
Definition meta.h:167
bool partial
Is the reflection data a partial type description.
Definition meta.h:168
ecs_type_kind_t kind
Type kind.
Definition meta.h:166
Component that stores unit prefix data.
Definition meta.h:487
ecs_unit_translation_t translation
Translation of prefix.
Definition meta.h:489
char * symbol
Symbol of prefix (e.g.
Definition meta.h:488
Component that stores unit data.
Definition meta.h:478
ecs_unit_translation_t translation
Translation for derived unit.
Definition meta.h:483
ecs_entity_t prefix
Order of magnitude prefix relative to derived.
Definition meta.h:480
char * symbol
Unit symbol.
Definition meta.h:479
ecs_entity_t base
Base unit (e.g.
Definition meta.h:481
ecs_entity_t over
Over unit (e.g.
Definition meta.h:482
Component added to vector type entities.
Definition meta.h:313
ecs_entity_t type
Element type.
Definition meta.h:314
Used with ecs_array_init().
Definition meta.h:996
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:997
ecs_entity_t type
Element type.
Definition meta.h:998
int32_t count
Number of elements.
Definition meta.h:999
Type that describes an bitmask constant.
Definition meta.h:289
ecs_entity_t constant
Should not be set by ecs_bitmask_desc_t.
Definition meta.h:297
ecs_flags32_t value
May be set when used with ecs_bitmask_desc_t.
Definition meta.h:294
const char * name
Must be set when used with ecs_bitmask_desc_t.
Definition meta.h:291
Used with ecs_bitmask_init().
Definition meta.h:978
ecs_bitmask_constant_t constants[(32)]
Bitmask constants.
Definition meta.h:980
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:979
Used with ecs_entity_init().
Definition flecs.h:938
Type that describes an enum constant.
Definition meta.h:271
ecs_entity_t constant
Should not be set by ecs_enum_desc_t.
Definition meta.h:279
int32_t value
May be set when used with ecs_enum_desc_t.
Definition meta.h:276
const char * name
Must be set when used with ecs_enum_desc_t.
Definition meta.h:273
Used with ecs_enum_init().
Definition meta.h:960
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:961
ecs_enum_constant_t constants[(32)]
Enum constants.
Definition meta.h:962
Element type of members vector in EcsStruct.
Definition meta.h:222
ecs_member_value_range_t warning_range
Numerical range outside of which the value represents an warning.
Definition meta.h:255
const char * name
Must be set when used with ecs_struct_desc_t.
Definition meta.h:224
ecs_size_t size
Should not be set by ecs_struct_desc_t.
Definition meta.h:258
bool use_offset
Set to true to prevent automatic offset computation.
Definition meta.h:242
ecs_entity_t type
Member type.
Definition meta.h:227
ecs_entity_t member
Should not be set by ecs_struct_desc_t.
Definition meta.h:261
int32_t offset
May be set when used with ecs_struct_desc_t.
Definition meta.h:233
ecs_entity_t unit
May be set when used with ecs_struct_desc_t, will be auto-populated if type entity is also a unit.
Definition meta.h:237
ecs_member_value_range_t range
Numerical range that specifies which values member can assume.
Definition meta.h:247
int32_t count
Element count (for inline arrays).
Definition meta.h:230
ecs_member_value_range_t error_range
Numerical range outside of which the value represents an error.
Definition meta.h:251
Type expressing a range for a member value.
Definition meta.h:209
double min
Min member value.
Definition meta.h:210
double max
Max member value.
Definition meta.h:211
Type that enables iterating/populating a value using reflection data.
Definition meta.h:582
ecs_meta_scope_t scope[(32)]
Cursor scope stack.
Definition meta.h:584
bool valid
Does the cursor point to a valid field.
Definition meta.h:586
const ecs_world_t * world
The world.
Definition meta.h:583
void * lookup_ctx
Context for lookup_action.
Definition meta.h:591
int32_t depth
Current scope depth.
Definition meta.h:585
bool is_primitive_scope
If in root scope, this allows for a push for primitive types.
Definition meta.h:587
ecs_entity_t(* lookup_action)(const ecs_world_t *, const char *, void *)
Custom entity lookup action for overriding default ecs_lookup.
Definition meta.h:590
Type with information about currently serialized scope.
Definition meta.h:564
const EcsOpaque * opaque
Opaque type interface.
Definition meta.h:573
int32_t prev_depth
Depth to restore, in case dotmember was used.
Definition meta.h:570
const EcsComponent * comp
Pointer to component, in case size/alignment is needed.
Definition meta.h:572
void * ptr
Pointer to the value being iterated.
Definition meta.h:571
bool is_empty_scope
Was scope populated (for collections)
Definition meta.h:578
ecs_vec_t * vector
Current vector, in case a vector is iterated.
Definition meta.h:574
int32_t elem_cur
Current element (for collections)
Definition meta.h:569
int32_t op_cur
Current operation.
Definition meta.h:568
bool is_inline_array
Is the scope iterating an inline array?
Definition meta.h:577
ecs_hashmap_t * members
string -> member index
Definition meta.h:575
ecs_meta_type_op_t * ops
The type operations (see ecs_meta_type_op_t)
Definition meta.h:566
int32_t op_count
Number of operations in ops array to process.
Definition meta.h:567
ecs_entity_t type
The type being iterated.
Definition meta.h:565
bool is_collection
Is the scope iterating elements?
Definition meta.h:576
Meta type serializer instruction data.
Definition meta.h:536
ecs_meta_type_op_kind_t kind
Instruction opcode.
Definition meta.h:537
ecs_entity_t type
Type entity.
Definition meta.h:543
int32_t count
Number of elements (for inline arrays).
Definition meta.h:539
ecs_size_t size
Size of type of operation.
Definition meta.h:542
ecs_size_t offset
Offset of current field.
Definition meta.h:538
const char * name
Name of value (only used for struct members)
Definition meta.h:540
int32_t member_index
Index of member in struct.
Definition meta.h:544
ecs_hashmap_t * members
string -> member index (structs only)
Definition meta.h:545
int32_t op_count
Number of operations until next field or end.
Definition meta.h:541
Used with ecs_opaque_init().
Definition meta.h:1051
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1052
EcsOpaque type
Type that the opaque type maps to.
Definition meta.h:1053
Used with ecs_primitive_init().
Definition meta.h:942
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:943
ecs_primitive_kind_t kind
Primitive type kind.
Definition meta.h:944
Serializer interface.
Definition meta.h:323
void * ctx
Serializer context.
Definition meta.h:336
int(* value)(const struct ecs_serializer_t *ser, ecs_entity_t type, const void *value)
Pointer to the value to serialize.
Definition meta.h:325
int(* member)(const struct ecs_serializer_t *ser, const char *member)
Member name.
Definition meta.h:331
const ecs_world_t * world
The world.
Definition meta.h:335
Used with ecs_struct_init().
Definition meta.h:1033
ecs_member_t members[(32)]
Struct members.
Definition meta.h:1035
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1034
Used with ecs_unit_init().
Definition meta.h:1085
ecs_entity_t base
Base unit, e.g.
Definition meta.h:1096
ecs_entity_t over
Over unit, e.g.
Definition meta.h:1099
const char * symbol
Unit symbol, e.g.
Definition meta.h:1090
ecs_entity_t prefix
Prefix indicating order of magnitude relative to the derived unit.
Definition meta.h:1110
ecs_entity_t quantity
Unit quantity, e.g.
Definition meta.h:1093
ecs_unit_translation_t translation
Translation to apply to derived unit (optional).
Definition meta.h:1102
ecs_entity_t entity
Existing entity to associate with unit (optional).
Definition meta.h:1087
Used with ecs_unit_prefix_init().
Definition meta.h:1126
ecs_entity_t entity
Existing entity to associate with unit prefix (optional).
Definition meta.h:1128
const char * symbol
Unit symbol, e.g.
Definition meta.h:1131
ecs_unit_translation_t translation
Translation to apply to derived unit (optional).
Definition meta.h:1134
Helper type to describe translation between two units.
Definition meta.h:472
int32_t power
Power to apply to factor (e.g.
Definition meta.h:474
int32_t factor
Factor to apply (e.g.
Definition meta.h:473
Utility to hold a value of a dynamic type.
Definition flecs.h:929
Used with ecs_vector_init().
Definition meta.h:1015
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1016
ecs_entity_t type
Element type.
Definition meta.h:1017