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#ifndef FLECS_MODULE
68#define FLECS_MODULE
69#endif
70
71#ifndef FLECS_META_H
72#define FLECS_META_H
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
79#define ECS_MEMBER_DESC_CACHE_SIZE (32)
80
95typedef bool ecs_bool_t;
96typedef char ecs_char_t;
97typedef unsigned char ecs_byte_t;
98typedef uint8_t ecs_u8_t;
99typedef uint16_t ecs_u16_t;
100typedef uint32_t ecs_u32_t;
101typedef uint64_t ecs_u64_t;
102typedef uintptr_t ecs_uptr_t;
103typedef int8_t ecs_i8_t;
104typedef int16_t ecs_i16_t;
105typedef int32_t ecs_i32_t;
106typedef int64_t ecs_i64_t;
107typedef intptr_t ecs_iptr_t;
108typedef float ecs_f32_t;
109typedef double ecs_f64_t;
110typedef char* ecs_string_t;
112/* Meta module component ids */
113FLECS_API extern const ecs_entity_t ecs_id(EcsType);
114FLECS_API extern const ecs_entity_t ecs_id(EcsTypeSerializer);
115FLECS_API extern const ecs_entity_t ecs_id(EcsPrimitive);
116FLECS_API extern const ecs_entity_t ecs_id(EcsEnum);
117FLECS_API extern const ecs_entity_t ecs_id(EcsBitmask);
118FLECS_API extern const ecs_entity_t ecs_id(EcsMember);
119FLECS_API extern const ecs_entity_t ecs_id(EcsMemberRanges);
120FLECS_API extern const ecs_entity_t ecs_id(EcsStruct);
121FLECS_API extern const ecs_entity_t ecs_id(EcsArray);
122FLECS_API extern const ecs_entity_t ecs_id(EcsVector);
123FLECS_API extern const ecs_entity_t ecs_id(EcsOpaque);
124FLECS_API extern const ecs_entity_t ecs_id(EcsUnit);
125FLECS_API extern const ecs_entity_t ecs_id(EcsUnitPrefix);
126FLECS_API extern const ecs_entity_t EcsQuantity;
128/* Primitive type component ids */
129
130FLECS_API extern const ecs_entity_t ecs_id(ecs_bool_t);
131FLECS_API extern const ecs_entity_t ecs_id(ecs_char_t);
132FLECS_API extern const ecs_entity_t ecs_id(ecs_byte_t);
133FLECS_API extern const ecs_entity_t ecs_id(ecs_u8_t);
134FLECS_API extern const ecs_entity_t ecs_id(ecs_u16_t);
135FLECS_API extern const ecs_entity_t ecs_id(ecs_u32_t);
136FLECS_API extern const ecs_entity_t ecs_id(ecs_u64_t);
137FLECS_API extern const ecs_entity_t ecs_id(ecs_uptr_t);
138FLECS_API extern const ecs_entity_t ecs_id(ecs_i8_t);
139FLECS_API extern const ecs_entity_t ecs_id(ecs_i16_t);
140FLECS_API extern const ecs_entity_t ecs_id(ecs_i32_t);
141FLECS_API extern const ecs_entity_t ecs_id(ecs_i64_t);
142FLECS_API extern const ecs_entity_t ecs_id(ecs_iptr_t);
143FLECS_API extern const ecs_entity_t ecs_id(ecs_f32_t);
144FLECS_API extern const ecs_entity_t ecs_id(ecs_f64_t);
145FLECS_API extern const ecs_entity_t ecs_id(ecs_string_t);
146FLECS_API extern const ecs_entity_t ecs_id(ecs_entity_t);
147FLECS_API extern const ecs_entity_t ecs_id(ecs_id_t);
150typedef enum ecs_type_kind_t {
151 EcsPrimitiveType,
152 EcsBitmaskType,
153 EcsEnumType,
154 EcsStructType,
155 EcsArrayType,
156 EcsVectorType,
157 EcsOpaqueType,
158 EcsTypeKindLast = EcsOpaqueType
160
167
170 EcsBool = 1,
171 EcsChar,
172 EcsByte,
173 EcsU8,
174 EcsU16,
175 EcsU32,
176 EcsU64,
177 EcsI8,
178 EcsI16,
179 EcsI32,
180 EcsI64,
181 EcsF32,
182 EcsF64,
183 EcsUPtr,
184 EcsIPtr,
185 EcsString,
186 EcsEntity,
187 EcsId,
188 EcsPrimitiveKindLast = EcsId
190
195
204
210
217
261
263typedef struct EcsStruct {
265 ecs_vec_t members; /* vector<ecs_member_t> */
267
269typedef struct ecs_enum_constant_t {
271 const char *name;
272
274 int64_t value;
275
278
282
284typedef struct EcsEnum {
285 ecs_entity_t underlying_type;
286
288 ecs_map_t *constants;
293
297 const char *name;
298
300 ecs_flags64_t value;
301
303 int64_t _unused;
304
308
310typedef struct EcsBitmask {
311 /* Populated from child entities with Constant component */
312 ecs_map_t *constants;
316
322
327
328
329/* Opaque type support */
330
331#if !defined(__cplusplus) || !defined(FLECS_CPP)
332
334typedef struct ecs_serializer_t {
335 /* Serialize value */
336 int (*value)(
337 const struct ecs_serializer_t *ser,
338 ecs_entity_t type,
339 const void *value);
341 /* Serialize member */
342 int (*member)(
343 const struct ecs_serializer_t *ser,
344 const char *member);
347 void *ctx;
349
350#elif defined(__cplusplus)
351
352} /* extern "C" { */
353
355typedef struct ecs_serializer_t {
356 /* Serialize value */
357 int (*value_)(
358 const struct ecs_serializer_t *ser,
359 ecs_entity_t type,
360 const void *value);
361
362 /* Serialize member */
363 int (*member_)(
364 const struct ecs_serializer_t *ser,
365 const char *name);
366
367 /* Serialize value */
368 int value(ecs_entity_t type, const void *value) const;
369
370 /* Serialize value */
371 template <typename T>
372 int value(const T& value) const;
373
374 /* Serialize member */
375 int member(const char *name) const;
376
377 const ecs_world_t *world;
378 void *ctx;
380
381extern "C" {
382#endif
383
385typedef int (*ecs_meta_serialize_t)(
386 const ecs_serializer_t *ser,
387 const void *src);
392 const ecs_serializer_t *ser,
393 const void *src,
394 const char* name);
398 const ecs_serializer_t *ser,
399 const void *src,
400 size_t elem);
406typedef struct EcsOpaque {
412 /* Deserializer interface
413 * Only override the callbacks that are valid for the opaque type. If a
414 * deserializer attempts to assign a value type that is not supported by the
415 * interface, a conversion error is thrown.
416 */
417
419 void (*assign_bool)(
420 void *dst,
421 bool value);
422
424 void (*assign_char)(
425 void *dst,
426 char value);
427
429 void (*assign_int)(
430 void *dst,
431 int64_t value);
432
434 void (*assign_uint)(
435 void *dst,
436 uint64_t value);
437
440 void *dst,
441 double value);
442
445 void *dst,
446 const char *value);
447
450 void *dst,
451 ecs_world_t *world,
452 ecs_entity_t entity);
453
455 void (*assign_id)(
456 void *dst,
457 ecs_world_t *world,
458 ecs_id_t id);
459
461 void (*assign_null)(
462 void *dst);
463
465 void (*clear)(
466 void *dst);
467
469 void* (*ensure_element)(
470 void *dst,
471 size_t elem);
472
474 void* (*ensure_member)(
475 void *dst,
476 const char *member);
477
479 size_t (*count)(
480 const void *dst);
481
483 void (*resize)(
484 void *dst,
485 size_t count);
487
488
489/* Units */
490
502
511
517
518
519/* Serializer utilities */
520
526typedef enum ecs_meta_op_kind_t {
540 EcsOpEnum,
541 EcsOpBitmask,
542
545 EcsOpBool,
546 EcsOpChar,
547 EcsOpByte,
548 EcsOpU8,
549 EcsOpU16,
550 EcsOpU32,
551 EcsOpU64,
552 EcsOpI8,
553 EcsOpI16,
554 EcsOpI32,
555 EcsOpI64,
556 EcsOpF32,
557 EcsOpF64,
558 EcsOpUPtr,
559 EcsOpIPtr,
560 EcsOpString,
561 EcsOpEntity,
562 EcsOpId,
563 EcsMetaTypeOpKindLast = EcsOpId
565
583
590
591
592/* Deserializer utilities */
593
597#define ECS_META_MAX_SCOPE_DEPTH (32)
598
614
627
629FLECS_API
631 ecs_world_t *world,
632 ecs_entity_t type);
633
648FLECS_API
650 const ecs_world_t *world,
651 ecs_entity_t type,
652 void *ptr);
653
659FLECS_API
661 ecs_meta_cursor_t *cursor);
662
668FLECS_API
670 ecs_meta_cursor_t *cursor);
671
677FLECS_API
679 ecs_meta_cursor_t *cursor,
680 int32_t elem);
681
688FLECS_API
690 ecs_meta_cursor_t *cursor,
691 const char *name);
692
700FLECS_API
702 ecs_meta_cursor_t *cursor,
703 const char *name);
704
710FLECS_API
712 ecs_meta_cursor_t *cursor);
713
719FLECS_API
721 ecs_meta_cursor_t *cursor);
722
728FLECS_API
730 const ecs_meta_cursor_t *cursor);
731
737FLECS_API
739 const ecs_meta_cursor_t *cursor);
740
746FLECS_API
748 const ecs_meta_cursor_t *cursor);
749
755FLECS_API
757 const ecs_meta_cursor_t *cursor);
758
764FLECS_API
766 const ecs_meta_cursor_t *cursor);
767
768/* The set functions assign the field with the specified value. If the value
769 * does not have the same type as the field, it will be cased to the field type.
770 * If no valid conversion is available, the operation will fail. */
771
778FLECS_API
780 ecs_meta_cursor_t *cursor,
781 bool value);
782
789FLECS_API
791 ecs_meta_cursor_t *cursor,
792 char value);
793
800FLECS_API
802 ecs_meta_cursor_t *cursor,
803 int64_t value);
804
811FLECS_API
813 ecs_meta_cursor_t *cursor,
814 uint64_t value);
815
822FLECS_API
824 ecs_meta_cursor_t *cursor,
825 double value);
826
833FLECS_API
835 ecs_meta_cursor_t *cursor,
836 const char *value);
837
844FLECS_API
846 ecs_meta_cursor_t *cursor,
847 const char *value);
848
855FLECS_API
857 ecs_meta_cursor_t *cursor,
858 ecs_entity_t value);
859
866FLECS_API
868 ecs_meta_cursor_t *cursor,
869 ecs_id_t value);
870
876FLECS_API
878 ecs_meta_cursor_t *cursor);
879
886FLECS_API
888 ecs_meta_cursor_t *cursor,
889 const ecs_value_t *value);
890
891/* Functions for getting members. */
892
898FLECS_API
900 const ecs_meta_cursor_t *cursor);
901
907FLECS_API
909 const ecs_meta_cursor_t *cursor);
910
916FLECS_API
918 const ecs_meta_cursor_t *cursor);
919
925FLECS_API
927 const ecs_meta_cursor_t *cursor);
928
934FLECS_API
936 const ecs_meta_cursor_t *cursor);
937
945FLECS_API
947 const ecs_meta_cursor_t *cursor);
948
955FLECS_API
957 const ecs_meta_cursor_t *cursor);
958
965FLECS_API
967 const ecs_meta_cursor_t *cursor);
968
975FLECS_API
977 ecs_primitive_kind_t type_kind,
978 const void *ptr);
979
988FLECS_API
990 const ecs_meta_op_t *op,
991 const void *ptr);
992
993/* API functions for creating meta types */
994
1000
1007FLECS_API
1009 ecs_world_t *world,
1010 const ecs_primitive_desc_t *desc);
1011
1012
1019
1026FLECS_API
1028 ecs_world_t *world,
1029 const ecs_enum_desc_t *desc);
1030
1031
1037
1044FLECS_API
1046 ecs_world_t *world,
1047 const ecs_bitmask_desc_t *desc);
1048
1049
1056
1063FLECS_API
1065 ecs_world_t *world,
1066 const ecs_array_desc_t *desc);
1067
1068
1074
1081FLECS_API
1083 ecs_world_t *world,
1084 const ecs_vector_desc_t *desc);
1085
1086
1092
1099FLECS_API
1101 ecs_world_t *world,
1102 const ecs_struct_desc_t *desc);
1103
1104
1110
1133FLECS_API
1135 ecs_world_t *world,
1136 const ecs_opaque_desc_t *desc);
1137
1138
1167
1174FLECS_API
1176 ecs_world_t *world,
1177 const ecs_unit_desc_t *desc);
1178
1179
1191
1198FLECS_API
1200 ecs_world_t *world,
1201 const ecs_unit_prefix_desc_t *desc);
1202
1203
1210FLECS_API
1212 ecs_world_t *world,
1213 const ecs_entity_desc_t *desc);
1214
1215/* Convenience macros */
1216
1218#define ecs_primitive(world, ...)\
1219 ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ )
1220
1222#define ecs_enum(world, ...)\
1223 ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ )
1224
1226#define ecs_bitmask(world, ...)\
1227 ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ )
1228
1230#define ecs_array(world, ...)\
1231 ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ )
1232
1234#define ecs_vector(world, ...)\
1235 ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ )
1236
1238#define ecs_opaque(world, ...)\
1239 ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ )
1240
1242#define ecs_struct(world, ...)\
1243 ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ )
1244
1246#define ecs_unit(world, ...)\
1247 ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ )
1248
1250#define ecs_unit_prefix(world, ...)\
1251 ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ )
1252
1254#define ecs_quantity(world, ...)\
1255 ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ )
1256
1257
1266FLECS_API
1268 ecs_world_t *world);
1269
1270#ifdef __cplusplus
1271}
1272#endif
1273
1274#include "meta_c.h"
1275
1276#endif
1277
1280#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.
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:95
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.
int(* ecs_meta_serialize_member_t)(const ecs_serializer_t *ser, const void *src, const char *name)
Callback invoked to serialize an opaque struct member.
Definition meta.h:391
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:100
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:104
struct ecs_meta_cursor_t ecs_meta_cursor_t
Type that enables iterating/populating a value using reflection data.
ecs_meta_op_kind_t
Serializer instruction opcodes.
Definition meta.h:526
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:98
struct ecs_member_t ecs_member_t
Element type of members vector in EcsStruct.
int(* ecs_meta_serialize_element_t)(const ecs_serializer_t *ser, const void *src, size_t elem)
Callback invoked to serialize an opaque vector/array element.
Definition meta.h:397
struct EcsVector EcsVector
Component added to vector type entities.
int64_t ecs_i64_t
Builtin i64 type.
Definition meta.h:106
FLECS_API char * ecs_meta_serializer_to_str(ecs_world_t *world, ecs_entity_t type)
Convert serializer to string.
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:110
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.
uint64_t ecs_u64_t
Builtin u64 type.
Definition meta.h:101
intptr_t ecs_iptr_t
Builtin iptr type.
Definition meta.h:107
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 ecs_size_t ecs_meta_op_get_elem_count(const ecs_meta_op_t *op, const void *ptr)
Get element count for array/vector operations.
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:102
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:108
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:169
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.
double ecs_f64_t
Builtin f64 type.
Definition meta.h:109
char ecs_char_t
Builtin char type.
Definition meta.h:96
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:150
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:99
int(* ecs_meta_serialize_t)(const ecs_serializer_t *ser, const void *src)
Callback invoked serializing an opaque type.
Definition meta.h:385
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:597
int32_t ecs_i32_t
Builtin i32 type.
Definition meta.h:105
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 ecs_meta_op_t ecs_meta_op_t
Meta type serializer instruction data.
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:103
unsigned char ecs_byte_t
Builtin ecs_byte type.
Definition meta.h:97
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:79
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.
FLECS_API ecs_id_t ecs_meta_get_id(const ecs_meta_cursor_t *cursor)
Get field value as (component) id.
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:543
@ EcsOpOpaqueArray
Opaque array.
Definition meta.h:533
@ EcsOpOpaqueStruct
Opaque struct.
Definition meta.h:532
@ EcsOpScope
Marks last constant that can open/close a scope.
Definition meta.h:537
@ EcsOpPop
Pop scope.
Definition meta.h:530
@ EcsOpPushVector
Push vector.
Definition meta.h:529
@ EcsOpOpaqueVector
Opaque vector.
Definition meta.h:534
@ EcsOpPushStruct
Push struct.
Definition meta.h:527
@ EcsOpOpaqueValue
Opaque value.
Definition meta.h:539
@ EcsOpPushArray
Push array.
Definition meta.h:528
@ EcsOpForward
Forward to type.
Definition meta.h:535
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:365
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:409
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:358
Utility macros for populating reflection data in C.
Component added to array type entities.
Definition meta.h:318
int32_t count
Number of elements.
Definition meta.h:320
ecs_entity_t type
Element type.
Definition meta.h:319
Component added to bitmask type entities.
Definition meta.h:310
ecs_vec_t ordered_constants
Stores the constants in registration order.
Definition meta.h:314
ecs_map_t * constants
map<u32_t, ecs_bitmask_constant_t>
Definition meta.h:312
Component added to enum type entities.
Definition meta.h:284
ecs_map_t * constants
Populated from child entities with Constant component.
Definition meta.h:288
ecs_vec_t ordered_constants
Stores the constants in registration order.
Definition meta.h:291
Component added to member entities to express valid value ranges.
Definition meta.h:212
ecs_member_value_range_t warning
Member value warning range.
Definition meta.h:214
ecs_member_value_range_t value
Member value range.
Definition meta.h:213
ecs_member_value_range_t error
Member value error range.
Definition meta.h:215
Component added to member entities.
Definition meta.h:197
ecs_entity_t unit
Member unit.
Definition meta.h:200
bool use_offset
If offset should be explicitly used.
Definition meta.h:202
ecs_entity_t type
Member type.
Definition meta.h:198
int32_t offset
Member offset.
Definition meta.h:201
int32_t count
Number of elements for inline arrays.
Definition meta.h:199
Opaque type reflection data.
Definition meta.h:406
size_t(* count)(const void *dst)
Return number of elements.
Definition meta.h:479
void(* assign_null)(void *dst)
Assign null value.
Definition meta.h:461
ecs_meta_serialize_member_t serialize_member
Serialize member action.
Definition meta.h:409
void(* clear)(void *dst)
Clear collection elements.
Definition meta.h:465
void(* assign_uint)(void *dst, uint64_t value)
Assign unsigned int value.
Definition meta.h:434
ecs_meta_serialize_t serialize
Serialize action.
Definition meta.h:408
void(* assign_char)(void *dst, char value)
Assign char value.
Definition meta.h:424
ecs_entity_t as_type
Type that describes the serialized output.
Definition meta.h:407
void(* assign_bool)(void *dst, bool value)
Assign bool value.
Definition meta.h:419
void(* assign_string)(void *dst, const char *value)
Assign string value.
Definition meta.h:444
void(* resize)(void *dst, size_t count)
Resize to number of elements.
Definition meta.h:483
void(* assign_int)(void *dst, int64_t value)
Assign int value.
Definition meta.h:429
void(* assign_float)(void *dst, double value)
Assign float value.
Definition meta.h:439
void(* assign_entity)(void *dst, ecs_world_t *world, ecs_entity_t entity)
Assign entity value.
Definition meta.h:449
void(* assign_id)(void *dst, ecs_world_t *world, ecs_id_t id)
Assign (component) id value.
Definition meta.h:455
ecs_meta_serialize_element_t serialize_element
Serialize element action.
Definition meta.h:410
Component added to primitive types.
Definition meta.h:192
ecs_primitive_kind_t kind
Primitive type kind.
Definition meta.h:193
Component added to struct type entities.
Definition meta.h:263
ecs_vec_t members
Populated from child entities with Member component.
Definition meta.h:265
Component that stores the type serializer.
Definition meta.h:586
ecs_type_kind_t kind
Quick access to type kind (same as EcsType)
Definition meta.h:587
ecs_vec_t ops
vector<ecs_meta_op_t>
Definition meta.h:588
Component that is automatically added to every type with the right kind.
Definition meta.h:162
bool existing
Did the type exist or is it populated from reflection.
Definition meta.h:164
bool partial
Is the reflection data a partial type description.
Definition meta.h:165
ecs_type_kind_t kind
Type kind.
Definition meta.h:163
Component that stores unit prefix data.
Definition meta.h:513
ecs_unit_translation_t translation
Translation of prefix.
Definition meta.h:515
char * symbol
Symbol of prefix (e.g.
Definition meta.h:514
Component that stores unit data.
Definition meta.h:504
ecs_unit_translation_t translation
Translation for derived unit.
Definition meta.h:509
ecs_entity_t prefix
Order of magnitude prefix relative to derived.
Definition meta.h:506
char * symbol
Unit symbol.
Definition meta.h:505
ecs_entity_t base
Base unit (e.g.
Definition meta.h:507
ecs_entity_t over
Over unit (e.g.
Definition meta.h:508
Component added to vector type entities.
Definition meta.h:324
ecs_entity_t type
Element type.
Definition meta.h:325
Used with ecs_array_init().
Definition meta.h:1051
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1052
ecs_entity_t type
Element type.
Definition meta.h:1053
int32_t count
Number of elements.
Definition meta.h:1054
Type that describes an bitmask constant.
Definition meta.h:295
ecs_flags64_t value
May be set when used with ecs_bitmask_desc_t.
Definition meta.h:300
int64_t _unused
Keep layout the same with ecs_enum_constant_t.
Definition meta.h:303
ecs_entity_t constant
Should not be set by ecs_bitmask_desc_t.
Definition meta.h:306
const char * name
Must be set when used with ecs_bitmask_desc_t.
Definition meta.h:297
Used with ecs_bitmask_init().
Definition meta.h:1033
ecs_bitmask_constant_t constants[(32)]
Bitmask constants.
Definition meta.h:1035
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1034
Used with ecs_entity_init().
Definition flecs.h:1023
Type that describes an enum constant.
Definition meta.h:269
ecs_entity_t constant
Should not be set by ecs_enum_desc_t.
Definition meta.h:280
uint64_t value_unsigned
For when the underlying type is unsigned.
Definition meta.h:277
int64_t value
May be set when used with ecs_enum_desc_t.
Definition meta.h:274
const char * name
Must be set when used with ecs_enum_desc_t.
Definition meta.h:271
Used with ecs_enum_init().
Definition meta.h:1014
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1015
ecs_enum_constant_t constants[(32)]
Enum constants.
Definition meta.h:1016
Element type of members vector in EcsStruct.
Definition meta.h:219
ecs_member_value_range_t warning_range
Numerical range outside of which the value represents an warning.
Definition meta.h:253
const char * name
Must be set when used with ecs_struct_desc_t.
Definition meta.h:221
ecs_size_t size
Should not be set by ecs_struct_desc_t.
Definition meta.h:256
bool use_offset
Set to true to prevent automatic offset computation.
Definition meta.h:240
ecs_entity_t type
Member type.
Definition meta.h:224
ecs_entity_t member
Should not be set by ecs_struct_desc_t.
Definition meta.h:259
int32_t offset
May be set when used with ecs_struct_desc_t.
Definition meta.h:231
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:235
ecs_member_value_range_t range
Numerical range that specifies which values member can assume.
Definition meta.h:245
int32_t count
Element count (for inline arrays).
Definition meta.h:228
ecs_member_value_range_t error_range
Numerical range outside of which the value represents an error.
Definition meta.h:249
Type expressing a range for a member value.
Definition meta.h:206
double min
Min member value.
Definition meta.h:207
double max
Max member value.
Definition meta.h:208
Type that enables iterating/populating a value using reflection data.
Definition meta.h:616
ecs_meta_scope_t scope[(32)]
Cursor scope stack.
Definition meta.h:618
bool valid
Does the cursor point to a valid field.
Definition meta.h:620
const ecs_world_t * world
The world.
Definition meta.h:617
void * lookup_ctx
Context for lookup_action.
Definition meta.h:625
int16_t depth
Current scope depth.
Definition meta.h:619
ecs_entity_t(* lookup_action)(ecs_world_t *, const char *, void *)
Custom entity lookup action for overriding default ecs_lookup.
Definition meta.h:624
bool is_primitive_scope
If in root scope, this allows for a push for primitive types.
Definition meta.h:621
Meta type serializer instruction data.
Definition meta.h:567
const char * name
Name of value (only used for struct members)
Definition meta.h:571
ecs_meta_op_kind_t kind
Instruction opcode.
Definition meta.h:568
ecs_hashmap_t * members
string -> member index (structs)
Definition meta.h:578
ecs_meta_serialize_t opaque
Serialize callback for opaque types.
Definition meta.h:580
const ecs_type_info_t * type_info
Type info.
Definition meta.h:576
ecs_map_t * constants
(u)int -> constant entity (enums/bitmasks)
Definition meta.h:579
int16_t member_index
Index of member in struct.
Definition meta.h:574
ecs_entity_t type
Type entity.
Definition meta.h:575
int16_t op_count
Number of operations until next field or end.
Definition meta.h:573
ecs_meta_op_kind_t underlying_kind
Underlying type kind (for enums).
Definition meta.h:569
ecs_size_t elem_size
Element size (for PushArray/PushVector) and element count (for PopArray)
Definition meta.h:572
ecs_size_t offset
Offset of current field.
Definition meta.h:570
Type with information about currently serialized scope.
Definition meta.h:600
bool is_moved_scope
Was scope moved in (with ecs_meta_elem, for vectors)
Definition meta.h:611
int16_t ops_cur
Current element in ops.
Definition meta.h:604
const EcsOpaque * opaque
Opaque type interface.
Definition meta.h:607
int32_t elem_count
Set for collections.
Definition meta.h:612
void * ptr
Pointer to ops[0].
Definition meta.h:606
bool is_empty_scope
Was scope populated (for vectors)
Definition meta.h:610
int16_t ops_count
Number of elements in ops.
Definition meta.h:603
ecs_meta_op_t * ops
The type operations (see ecs_meta_op_t)
Definition meta.h:602
ecs_hashmap_t * members
string -> member index
Definition meta.h:608
int16_t prev_depth
Depth to restore, in case dotmember was used.
Definition meta.h:605
ecs_entity_t type
The type being iterated.
Definition meta.h:601
bool is_collection
Is the scope iterating elements?
Definition meta.h:609
Used with ecs_opaque_init().
Definition meta.h:1106
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1107
EcsOpaque type
Type that the opaque type maps to.
Definition meta.h:1108
Used with ecs_primitive_init().
Definition meta.h:996
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:997
ecs_primitive_kind_t kind
Primitive type kind.
Definition meta.h:998
Serializer interface.
Definition meta.h:334
void * ctx
Serializer context.
Definition meta.h:347
int(* value)(const struct ecs_serializer_t *ser, ecs_entity_t type, const void *value)
Pointer to the value to serialize.
Definition meta.h:336
int(* member)(const struct ecs_serializer_t *ser, const char *member)
Member name.
Definition meta.h:342
const ecs_world_t * world
The world.
Definition meta.h:346
Used with ecs_struct_init().
Definition meta.h:1088
ecs_member_t members[(32)]
Struct members.
Definition meta.h:1090
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1089
Type that contains component information (passed to ctors/dtors/...)
Definition flecs.h:1000
Used with ecs_unit_init().
Definition meta.h:1140
ecs_entity_t base
Base unit, e.g.
Definition meta.h:1151
ecs_entity_t over
Over unit, e.g.
Definition meta.h:1154
const char * symbol
Unit symbol, e.g.
Definition meta.h:1145
ecs_entity_t prefix
Prefix indicating order of magnitude relative to the derived unit.
Definition meta.h:1165
ecs_entity_t quantity
Unit quantity, e.g.
Definition meta.h:1148
ecs_unit_translation_t translation
Translation to apply to derived unit (optional).
Definition meta.h:1157
ecs_entity_t entity
Existing entity to associate with unit (optional).
Definition meta.h:1142
Used with ecs_unit_prefix_init().
Definition meta.h:1181
ecs_entity_t entity
Existing entity to associate with unit prefix (optional).
Definition meta.h:1183
const char * symbol
Unit symbol, e.g.
Definition meta.h:1186
ecs_unit_translation_t translation
Translation to apply to derived unit (optional).
Definition meta.h:1189
Helper type to describe translation between two units.
Definition meta.h:498
int32_t power
Power to apply to factor (e.g.
Definition meta.h:500
int32_t factor
Factor to apply (e.g.
Definition meta.h:499
Utility to hold a value of a dynamic type.
Definition flecs.h:1014
Used with ecs_vector_init().
Definition meta.h:1070
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1071
ecs_entity_t type
Element type.
Definition meta.h:1072