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
206
212
219
257
259typedef struct EcsStruct {
261 ecs_vec_t members; /* vector<ecs_member_t> */
263
275
277typedef struct EcsEnum {
279 ecs_map_t constants;
281
285 const char *name;
286
288 ecs_flags32_t value;
289
293
295typedef struct EcsBitmask {
296 /* Populated from child entities with Constant component */
297 ecs_map_t constants;
299
305
310
311
312/* Opaque type support */
313
314#if !defined(__cplusplus) || !defined(FLECS_CPP)
315
317typedef struct ecs_serializer_t {
318 /* Serialize value */
319 int (*value)(
320 const struct ecs_serializer_t *ser,
321 ecs_entity_t type,
322 const void *value);
324 /* Serialize member */
325 int (*member)(
326 const struct ecs_serializer_t *ser,
327 const char *member);
330 void *ctx;
332
333#elif defined(__cplusplus)
334
335} /* extern "C" { */
336
338typedef struct ecs_serializer_t {
339 /* Serialize value */
340 int (*value_)(
341 const struct ecs_serializer_t *ser,
342 ecs_entity_t type,
343 const void *value);
344
345 /* Serialize member */
346 int (*member_)(
347 const struct ecs_serializer_t *ser,
348 const char *name);
349
350 /* Serialize value */
351 int value(ecs_entity_t type, const void *value) const;
352
353 /* Serialize value */
354 template <typename T>
355 int value(const T& value) const;
356
357 /* Serialize member */
358 int member(const char *name) const;
359
360 const ecs_world_t *world;
361 void *ctx;
363
364extern "C" {
365#endif
366
368typedef int (*ecs_meta_serialize_t)(
369 const ecs_serializer_t *ser,
370 const void *src);
376typedef struct EcsOpaque {
380 /* Deserializer interface
381 * Only override the callbacks that are valid for the opaque type. If a
382 * deserializer attempts to assign a value type that is not supported by the
383 * interface, a conversion error is thrown.
384 */
385
387 void (*assign_bool)(
388 void *dst,
389 bool value);
390
392 void (*assign_char)(
393 void *dst,
394 char value);
395
397 void (*assign_int)(
398 void *dst,
399 int64_t value);
400
402 void (*assign_uint)(
403 void *dst,
404 uint64_t value);
405
408 void *dst,
409 double value);
410
413 void *dst,
414 const char *value);
415
418 void *dst,
419 ecs_world_t *world,
420 ecs_entity_t entity);
421
423 void (*assign_id)(
424 void *dst,
425 ecs_world_t *world,
426 ecs_id_t id);
427
429 void (*assign_null)(
430 void *dst);
431
433 void (*clear)(
434 void *dst);
435
437 void* (*ensure_element)(
438 void *dst,
439 size_t elem);
440
442 void* (*ensure_member)(
443 void *dst,
444 const char *member);
445
447 size_t (*count)(
448 const void *dst);
449
451 void (*resize)(
452 void *dst,
453 size_t count);
455
456
457/* Units */
458
470
479
485
486
487/* Serializer utilities */
488
495 EcsOpArray,
496 EcsOpVector,
497 EcsOpOpaque,
498 EcsOpPush,
499 EcsOpPop,
500
503 EcsOpEnum,
504 EcsOpBitmask,
505
508 EcsOpBool,
509 EcsOpChar,
510 EcsOpByte,
511 EcsOpU8,
512 EcsOpU16,
513 EcsOpU32,
514 EcsOpU64,
515 EcsOpI8,
516 EcsOpI16,
517 EcsOpI32,
518 EcsOpI64,
519 EcsOpF32,
520 EcsOpF64,
521 EcsOpUPtr,
522 EcsOpIPtr,
523 EcsOpString,
524 EcsOpEntity,
525 EcsOpId,
526 EcsMetaTypeOpKindLast = EcsOpId
528
530typedef struct ecs_meta_type_op_t {
532 ecs_size_t offset;
533 int32_t count;
534 const char *name;
535 int32_t op_count;
536 ecs_size_t size;
538 int32_t member_index;
539 ecs_hashmap_t *members;
541
545typedef struct EcsTypeSerializer {
546 ecs_vec_t ops;
548
549
550/* Deserializer utilities */
551
555#define ECS_META_MAX_SCOPE_DEPTH (32)
556
574
587
602FLECS_API
604 const ecs_world_t *world,
605 ecs_entity_t type,
606 void *ptr);
607
613FLECS_API
615 ecs_meta_cursor_t *cursor);
616
622FLECS_API
624 ecs_meta_cursor_t *cursor);
625
631FLECS_API
633 ecs_meta_cursor_t *cursor,
634 int32_t elem);
635
642FLECS_API
644 ecs_meta_cursor_t *cursor,
645 const char *name);
646
654FLECS_API
656 ecs_meta_cursor_t *cursor,
657 const char *name);
658
664FLECS_API
666 ecs_meta_cursor_t *cursor);
667
673FLECS_API
675 ecs_meta_cursor_t *cursor);
676
682FLECS_API
684 const ecs_meta_cursor_t *cursor);
685
691FLECS_API
693 const ecs_meta_cursor_t *cursor);
694
700FLECS_API
702 const ecs_meta_cursor_t *cursor);
703
709FLECS_API
711 const ecs_meta_cursor_t *cursor);
712
718FLECS_API
720 const ecs_meta_cursor_t *cursor);
721
722/* The set functions assign the field with the specified value. If the value
723 * does not have the same type as the field, it will be cased to the field type.
724 * If no valid conversion is available, the operation will fail. */
725
732FLECS_API
734 ecs_meta_cursor_t *cursor,
735 bool value);
736
743FLECS_API
745 ecs_meta_cursor_t *cursor,
746 char value);
747
754FLECS_API
756 ecs_meta_cursor_t *cursor,
757 int64_t value);
758
765FLECS_API
767 ecs_meta_cursor_t *cursor,
768 uint64_t value);
769
776FLECS_API
778 ecs_meta_cursor_t *cursor,
779 double value);
780
787FLECS_API
789 ecs_meta_cursor_t *cursor,
790 const char *value);
791
798FLECS_API
800 ecs_meta_cursor_t *cursor,
801 const char *value);
802
809FLECS_API
811 ecs_meta_cursor_t *cursor,
812 ecs_entity_t value);
813
820FLECS_API
822 ecs_meta_cursor_t *cursor,
823 ecs_id_t value);
824
830FLECS_API
832 ecs_meta_cursor_t *cursor);
833
840FLECS_API
842 ecs_meta_cursor_t *cursor,
843 const ecs_value_t *value);
844
845/* Functions for getting members. */
846
852FLECS_API
854 const ecs_meta_cursor_t *cursor);
855
861FLECS_API
863 const ecs_meta_cursor_t *cursor);
864
870FLECS_API
872 const ecs_meta_cursor_t *cursor);
873
879FLECS_API
881 const ecs_meta_cursor_t *cursor);
882
888FLECS_API
890 const ecs_meta_cursor_t *cursor);
891
899FLECS_API
901 const ecs_meta_cursor_t *cursor);
902
909FLECS_API
911 const ecs_meta_cursor_t *cursor);
912
920 const ecs_meta_cursor_t *cursor);
921
928FLECS_API
930 ecs_primitive_kind_t type_kind,
931 const void *ptr);
932
933/* API functions for creating meta types */
934
940
947FLECS_API
949 ecs_world_t *world,
950 const ecs_primitive_desc_t *desc);
951
952
958
965FLECS_API
967 ecs_world_t *world,
968 const ecs_enum_desc_t *desc);
969
970
976
983FLECS_API
985 ecs_world_t *world,
986 const ecs_bitmask_desc_t *desc);
987
988
995
1002FLECS_API
1004 ecs_world_t *world,
1005 const ecs_array_desc_t *desc);
1006
1007
1013
1020FLECS_API
1022 ecs_world_t *world,
1023 const ecs_vector_desc_t *desc);
1024
1025
1031
1038FLECS_API
1040 ecs_world_t *world,
1041 const ecs_struct_desc_t *desc);
1042
1043
1049
1072FLECS_API
1074 ecs_world_t *world,
1075 const ecs_opaque_desc_t *desc);
1076
1077
1106
1113FLECS_API
1115 ecs_world_t *world,
1116 const ecs_unit_desc_t *desc);
1117
1118
1130
1137FLECS_API
1139 ecs_world_t *world,
1140 const ecs_unit_prefix_desc_t *desc);
1141
1142
1149FLECS_API
1151 ecs_world_t *world,
1152 const ecs_entity_desc_t *desc);
1153
1154/* Convenience macros */
1155
1157#define ecs_primitive(world, ...)\
1158 ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ )
1159
1161#define ecs_enum(world, ...)\
1162 ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ )
1163
1165#define ecs_bitmask(world, ...)\
1166 ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ )
1167
1169#define ecs_array(world, ...)\
1170 ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ )
1171
1173#define ecs_vector(world, ...)\
1174 ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ )
1175
1177#define ecs_opaque(world, ...)\
1178 ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ )
1179
1181#define ecs_struct(world, ...)\
1182 ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ )
1183
1185#define ecs_unit(world, ...)\
1186 ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ )
1187
1189#define ecs_unit_prefix(world, ...)\
1190 ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ )
1191
1193#define ecs_quantity(world, ...)\
1194 ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ )
1195
1196
1205FLECS_API
1207 ecs_world_t *world);
1208
1209#ifdef __cplusplus
1210}
1211#endif
1212
1213#include "meta_c.h"
1214
1215#endif
1216
1219#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:494
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:368
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:555
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:506
@ EcsOpScope
Marks last constant that can open/close a scope.
Definition meta.h:501
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:339
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:383
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:332
Utility macros for populating reflection data in C.
Component added to array type entities.
Definition meta.h:301
int32_t count
Number of elements.
Definition meta.h:303
ecs_entity_t type
Element type.
Definition meta.h:302
Component added to bitmask type entities.
Definition meta.h:295
ecs_map_t constants
map<u32_t, ecs_bitmask_constant_t>
Definition meta.h:297
Component information.
Definition flecs.h:1425
Component added to enum type entities.
Definition meta.h:277
ecs_map_t constants
Populated from child entities with Constant component.
Definition meta.h:279
Component added to member entities to express valid value ranges.
Definition meta.h:214
ecs_member_value_range_t warning
Member value warning range.
Definition meta.h:216
ecs_member_value_range_t value
Member value range.
Definition meta.h:215
ecs_member_value_range_t error
Member value error range.
Definition meta.h:217
Component added to member entities.
Definition meta.h:200
ecs_entity_t unit
Member unit.
Definition meta.h:203
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:376
size_t(* count)(const void *dst)
Return number of elements.
Definition meta.h:447
void(* assign_null)(void *dst)
Assign null value.
Definition meta.h:429
void(* clear)(void *dst)
Clear collection elements.
Definition meta.h:433
void(* assign_uint)(void *dst, uint64_t value)
Assign unsigned int value.
Definition meta.h:402
ecs_meta_serialize_t serialize
Serialize action.
Definition meta.h:378
void(* assign_char)(void *dst, char value)
Assign char value.
Definition meta.h:392
ecs_entity_t as_type
Type that describes the serialized output.
Definition meta.h:377
void(* assign_bool)(void *dst, bool value)
Assign bool value.
Definition meta.h:387
void(* assign_string)(void *dst, const char *value)
Assign string value.
Definition meta.h:412
void(* resize)(void *dst, size_t count)
Resize to number of elements.
Definition meta.h:451
void(* assign_int)(void *dst, int64_t value)
Assign int value.
Definition meta.h:397
void(* assign_float)(void *dst, double value)
Assign float value.
Definition meta.h:407
void(* assign_entity)(void *dst, ecs_world_t *world, ecs_entity_t entity)
Assign entity value.
Definition meta.h:417
void(* assign_id)(void *dst, ecs_world_t *world, ecs_id_t id)
Assign (component) id value.
Definition meta.h:423
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:259
ecs_vec_t members
Populated from child entities with Member component.
Definition meta.h:261
Component that stores the type serializer.
Definition meta.h:545
ecs_vec_t ops
vector<ecs_meta_type_op_t>
Definition meta.h:546
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:481
ecs_unit_translation_t translation
Translation of prefix.
Definition meta.h:483
char * symbol
Symbol of prefix (e.g.
Definition meta.h:482
Component that stores unit data.
Definition meta.h:472
ecs_unit_translation_t translation
Translation for derived unit.
Definition meta.h:477
ecs_entity_t prefix
Order of magnitude prefix relative to derived.
Definition meta.h:474
char * symbol
Unit symbol.
Definition meta.h:473
ecs_entity_t base
Base unit (e.g.
Definition meta.h:475
ecs_entity_t over
Over unit (e.g.
Definition meta.h:476
Component added to vector type entities.
Definition meta.h:307
ecs_entity_t type
Element type.
Definition meta.h:308
Used with ecs_array_init().
Definition meta.h:990
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:991
ecs_entity_t type
Element type.
Definition meta.h:992
int32_t count
Number of elements.
Definition meta.h:993
Type that describes an bitmask constant.
Definition meta.h:283
ecs_entity_t constant
Should not be set by ecs_bitmask_desc_t.
Definition meta.h:291
ecs_flags32_t value
May be set when used with ecs_bitmask_desc_t.
Definition meta.h:288
const char * name
Must be set when used with ecs_bitmask_desc_t.
Definition meta.h:285
Used with ecs_bitmask_init().
Definition meta.h:972
ecs_bitmask_constant_t constants[(32)]
Bitmask constants.
Definition meta.h:974
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:973
Used with ecs_entity_init().
Definition flecs.h:901
Type that describes an enum constant.
Definition meta.h:265
ecs_entity_t constant
Should not be set by ecs_enum_desc_t.
Definition meta.h:273
int32_t value
May be set when used with ecs_enum_desc_t.
Definition meta.h:270
const char * name
Must be set when used with ecs_enum_desc_t.
Definition meta.h:267
Used with ecs_enum_init().
Definition meta.h:954
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:955
ecs_enum_constant_t constants[(32)]
Enum constants.
Definition meta.h:956
Element type of members vector in EcsStruct.
Definition meta.h:221
ecs_member_value_range_t warning_range
Numerical range outside of which the value represents an warning.
Definition meta.h:249
const char * name
Must be set when used with ecs_struct_desc_t.
Definition meta.h:223
ecs_size_t size
Should not be set by ecs_struct_desc_t.
Definition meta.h:252
ecs_entity_t type
Member type.
Definition meta.h:226
ecs_entity_t member
Should not be set by ecs_struct_desc_t.
Definition meta.h:255
int32_t offset
May be set when used with ecs_struct_desc_t.
Definition meta.h:232
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:236
ecs_member_value_range_t range
Numerical range that specifies which values member can assume.
Definition meta.h:241
int32_t count
Element count (for inline arrays).
Definition meta.h:229
ecs_member_value_range_t error_range
Numerical range outside of which the value represents an error.
Definition meta.h:245
Type expressing a range for a member value.
Definition meta.h:208
double min
Min member value.
Definition meta.h:209
double max
Max member value.
Definition meta.h:210
Type that enables iterating/populating a value using reflection data.
Definition meta.h:576
ecs_meta_scope_t scope[(32)]
Cursor scope stack.
Definition meta.h:578
bool valid
Does the cursor point to a valid field.
Definition meta.h:580
const ecs_world_t * world
The world.
Definition meta.h:577
void * lookup_ctx
Context for lookup_action.
Definition meta.h:585
int32_t depth
Current scope depth.
Definition meta.h:579
bool is_primitive_scope
If in root scope, this allows for a push for primitive types.
Definition meta.h:581
ecs_entity_t(* lookup_action)(const ecs_world_t *, const char *, void *)
Custom entity lookup action for overriding default ecs_lookup.
Definition meta.h:584
Type with information about currently serialized scope.
Definition meta.h:558
const EcsOpaque * opaque
Opaque type interface.
Definition meta.h:567
int32_t prev_depth
Depth to restore, in case dotmember was used.
Definition meta.h:564
const EcsComponent * comp
Pointer to component, in case size/alignment is needed.
Definition meta.h:566
void * ptr
Pointer to the value being iterated.
Definition meta.h:565
bool is_empty_scope
Was scope populated (for collections)
Definition meta.h:572
ecs_vec_t * vector
Current vector, in case a vector is iterated.
Definition meta.h:568
int32_t elem_cur
Current element (for collections)
Definition meta.h:563
int32_t op_cur
Current operation.
Definition meta.h:562
bool is_inline_array
Is the scope iterating an inline array?
Definition meta.h:571
ecs_hashmap_t * members
string -> member index
Definition meta.h:569
ecs_meta_type_op_t * ops
The type operations (see ecs_meta_type_op_t)
Definition meta.h:560
int32_t op_count
Number of operations in ops array to process.
Definition meta.h:561
ecs_entity_t type
The type being iterated.
Definition meta.h:559
bool is_collection
Is the scope iterating elements?
Definition meta.h:570
Meta type serializer instruction data.
Definition meta.h:530
ecs_meta_type_op_kind_t kind
Instruction opcode.
Definition meta.h:531
ecs_entity_t type
Type entity.
Definition meta.h:537
int32_t count
Number of elements (for inline arrays).
Definition meta.h:533
ecs_size_t size
Size of type of operation.
Definition meta.h:536
ecs_size_t offset
Offset of current field.
Definition meta.h:532
const char * name
Name of value (only used for struct members)
Definition meta.h:534
int32_t member_index
Index of member in struct.
Definition meta.h:538
ecs_hashmap_t * members
string -> member index (structs only)
Definition meta.h:539
int32_t op_count
Number of operations until next field or end.
Definition meta.h:535
Used with ecs_opaque_init().
Definition meta.h:1045
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1046
EcsOpaque type
Type that the opaque type maps to.
Definition meta.h:1047
Used with ecs_primitive_init().
Definition meta.h:936
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:937
ecs_primitive_kind_t kind
Primitive type kind.
Definition meta.h:938
Serializer interface.
Definition meta.h:317
void * ctx
Serializer context.
Definition meta.h:330
int(* value)(const struct ecs_serializer_t *ser, ecs_entity_t type, const void *value)
Pointer to the value to serialize.
Definition meta.h:319
int(* member)(const struct ecs_serializer_t *ser, const char *member)
Member name.
Definition meta.h:325
const ecs_world_t * world
The world.
Definition meta.h:329
Used with ecs_struct_init().
Definition meta.h:1027
ecs_member_t members[(32)]
Struct members.
Definition meta.h:1029
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1028
Used with ecs_unit_init().
Definition meta.h:1079
ecs_entity_t base
Base unit, e.g.
Definition meta.h:1090
ecs_entity_t over
Over unit, e.g.
Definition meta.h:1093
const char * symbol
Unit symbol, e.g.
Definition meta.h:1084
ecs_entity_t prefix
Prefix indicating order of magnitude relative to the derived unit.
Definition meta.h:1104
ecs_entity_t quantity
Unit quantity, e.g.
Definition meta.h:1087
ecs_unit_translation_t translation
Translation to apply to derived unit (optional).
Definition meta.h:1096
ecs_entity_t entity
Existing entity to associate with unit (optional).
Definition meta.h:1081
Used with ecs_unit_prefix_init().
Definition meta.h:1120
ecs_entity_t entity
Existing entity to associate with unit prefix (optional).
Definition meta.h:1122
const char * symbol
Unit symbol, e.g.
Definition meta.h:1125
ecs_unit_translation_t translation
Translation to apply to derived unit (optional).
Definition meta.h:1128
Helper type to describe translation between two units.
Definition meta.h:466
int32_t power
Power to apply to factor (e.g.
Definition meta.h:468
int32_t factor
Factor to apply (e.g.
Definition meta.h:467
Utility to hold a value of a dynamic type.
Definition flecs.h:892
Used with ecs_vector_init().
Definition meta.h:1009
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1010
ecs_entity_t type
Element type.
Definition meta.h:1011