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 EcsQuantity;
130/* Primitive type component ids */
131
132FLECS_API extern const ecs_entity_t ecs_id(ecs_bool_t);
133FLECS_API extern const ecs_entity_t ecs_id(ecs_char_t);
134FLECS_API extern const ecs_entity_t ecs_id(ecs_byte_t);
135FLECS_API extern const ecs_entity_t ecs_id(ecs_u8_t);
136FLECS_API extern const ecs_entity_t ecs_id(ecs_u16_t);
137FLECS_API extern const ecs_entity_t ecs_id(ecs_u32_t);
138FLECS_API extern const ecs_entity_t ecs_id(ecs_u64_t);
139FLECS_API extern const ecs_entity_t ecs_id(ecs_uptr_t);
140FLECS_API extern const ecs_entity_t ecs_id(ecs_i8_t);
141FLECS_API extern const ecs_entity_t ecs_id(ecs_i16_t);
142FLECS_API extern const ecs_entity_t ecs_id(ecs_i32_t);
143FLECS_API extern const ecs_entity_t ecs_id(ecs_i64_t);
144FLECS_API extern const ecs_entity_t ecs_id(ecs_iptr_t);
145FLECS_API extern const ecs_entity_t ecs_id(ecs_f32_t);
146FLECS_API extern const ecs_entity_t ecs_id(ecs_f64_t);
147FLECS_API extern const ecs_entity_t ecs_id(ecs_string_t);
148FLECS_API extern const ecs_entity_t ecs_id(ecs_entity_t);
149FLECS_API extern const ecs_entity_t ecs_id(ecs_id_t);
152typedef enum ecs_type_kind_t {
153 EcsPrimitiveType,
154 EcsBitmaskType,
155 EcsEnumType,
156 EcsStructType,
157 EcsArrayType,
158 EcsVectorType,
159 EcsOpaqueType,
160 EcsTypeKindLast = EcsOpaqueType
162
169
172 EcsBool = 1,
173 EcsChar,
174 EcsByte,
175 EcsU8,
176 EcsU16,
177 EcsU32,
178 EcsU64,
179 EcsI8,
180 EcsI16,
181 EcsI32,
182 EcsI64,
183 EcsF32,
184 EcsF64,
185 EcsUPtr,
186 EcsIPtr,
187 EcsString,
188 EcsEntity,
189 EcsId,
190 EcsPrimitiveKindLast = EcsId
192
197
206
212
219
262
264typedef struct EcsStruct {
266 ecs_vec_t members; /* vector<ecs_member_t> */
268
270typedef struct ecs_enum_constant_t {
272 const char *name;
273
275 int64_t value;
276
279
283
285typedef struct EcsEnum {
286 ecs_entity_t underlying_type;
287
289 ecs_map_t constants;
291
295 const char *name;
296
298 ecs_flags64_t value;
299
301 int64_t _unused;
302
306
308typedef struct EcsBitmask {
309 /* Populated from child entities with Constant component */
310 ecs_map_t constants;
312
318
323
324
325/* Opaque type support */
326
327#if !defined(__cplusplus) || !defined(FLECS_CPP)
328
330typedef struct ecs_serializer_t {
331 /* Serialize value */
332 int (*value)(
333 const struct ecs_serializer_t *ser,
334 ecs_entity_t type,
335 const void *value);
337 /* Serialize member */
338 int (*member)(
339 const struct ecs_serializer_t *ser,
340 const char *member);
343 void *ctx;
345
346#elif defined(__cplusplus)
347
348} /* extern "C" { */
349
351typedef struct ecs_serializer_t {
352 /* Serialize value */
353 int (*value_)(
354 const struct ecs_serializer_t *ser,
355 ecs_entity_t type,
356 const void *value);
357
358 /* Serialize member */
359 int (*member_)(
360 const struct ecs_serializer_t *ser,
361 const char *name);
362
363 /* Serialize value */
364 int value(ecs_entity_t type, const void *value) const;
365
366 /* Serialize value */
367 template <typename T>
368 int value(const T& value) const;
369
370 /* Serialize member */
371 int member(const char *name) const;
372
373 const ecs_world_t *world;
374 void *ctx;
376
377extern "C" {
378#endif
379
381typedef int (*ecs_meta_serialize_t)(
382 const ecs_serializer_t *ser,
383 const void *src);
388 const ecs_serializer_t *ser,
389 const void *src,
390 const char* name);
394 const ecs_serializer_t *ser,
395 const void *src,
396 size_t elem);
402typedef struct EcsOpaque {
408 /* Deserializer interface
409 * Only override the callbacks that are valid for the opaque type. If a
410 * deserializer attempts to assign a value type that is not supported by the
411 * interface, a conversion error is thrown.
412 */
413
415 void (*assign_bool)(
416 void *dst,
417 bool value);
418
420 void (*assign_char)(
421 void *dst,
422 char value);
423
425 void (*assign_int)(
426 void *dst,
427 int64_t value);
428
430 void (*assign_uint)(
431 void *dst,
432 uint64_t value);
433
436 void *dst,
437 double value);
438
441 void *dst,
442 const char *value);
443
446 void *dst,
447 ecs_world_t *world,
448 ecs_entity_t entity);
449
451 void (*assign_id)(
452 void *dst,
453 ecs_world_t *world,
454 ecs_id_t id);
455
457 void (*assign_null)(
458 void *dst);
459
461 void (*clear)(
462 void *dst);
463
465 void* (*ensure_element)(
466 void *dst,
467 size_t elem);
468
470 void* (*ensure_member)(
471 void *dst,
472 const char *member);
473
475 size_t (*count)(
476 const void *dst);
477
479 void (*resize)(
480 void *dst,
481 size_t count);
483
484
485/* Units */
486
498
507
513
514
515/* Serializer utilities */
516
523 EcsOpArray,
524 EcsOpVector,
525 EcsOpOpaque,
526 EcsOpPush,
527 EcsOpPop,
528
531 EcsOpEnum,
532 EcsOpBitmask,
533
536 EcsOpBool,
537 EcsOpChar,
538 EcsOpByte,
539 EcsOpU8,
540 EcsOpU16,
541 EcsOpU32,
542 EcsOpU64,
543 EcsOpI8,
544 EcsOpI16,
545 EcsOpI32,
546 EcsOpI64,
547 EcsOpF32,
548 EcsOpF64,
549 EcsOpUPtr,
550 EcsOpIPtr,
551 EcsOpString,
552 EcsOpEntity,
553 EcsOpId,
554 EcsMetaTypeOpKindLast = EcsOpId
556
558typedef struct ecs_meta_type_op_t {
560 ecs_size_t offset;
561 int32_t count;
562 const char *name;
563 int32_t op_count;
564 ecs_size_t size;
566 int32_t member_index;
567 ecs_hashmap_t *members;
569
573typedef struct EcsTypeSerializer {
574 ecs_vec_t ops;
576
577
578/* Deserializer utilities */
579
583#define ECS_META_MAX_SCOPE_DEPTH (32)
584
602
615
630FLECS_API
632 const ecs_world_t *world,
633 ecs_entity_t type,
634 void *ptr);
635
641FLECS_API
643 ecs_meta_cursor_t *cursor);
644
650FLECS_API
652 ecs_meta_cursor_t *cursor);
653
659FLECS_API
661 ecs_meta_cursor_t *cursor,
662 int32_t elem);
663
670FLECS_API
672 ecs_meta_cursor_t *cursor,
673 const char *name);
674
682FLECS_API
684 ecs_meta_cursor_t *cursor,
685 const char *name);
686
692FLECS_API
694 ecs_meta_cursor_t *cursor);
695
701FLECS_API
703 ecs_meta_cursor_t *cursor);
704
710FLECS_API
712 const ecs_meta_cursor_t *cursor);
713
719FLECS_API
721 const 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
750/* The set functions assign the field with the specified value. If the value
751 * does not have the same type as the field, it will be cased to the field type.
752 * If no valid conversion is available, the operation will fail. */
753
760FLECS_API
762 ecs_meta_cursor_t *cursor,
763 bool value);
764
771FLECS_API
773 ecs_meta_cursor_t *cursor,
774 char value);
775
782FLECS_API
784 ecs_meta_cursor_t *cursor,
785 int64_t value);
786
793FLECS_API
795 ecs_meta_cursor_t *cursor,
796 uint64_t value);
797
804FLECS_API
806 ecs_meta_cursor_t *cursor,
807 double value);
808
815FLECS_API
817 ecs_meta_cursor_t *cursor,
818 const char *value);
819
826FLECS_API
828 ecs_meta_cursor_t *cursor,
829 const char *value);
830
837FLECS_API
839 ecs_meta_cursor_t *cursor,
840 ecs_entity_t value);
841
848FLECS_API
850 ecs_meta_cursor_t *cursor,
851 ecs_id_t value);
852
858FLECS_API
860 ecs_meta_cursor_t *cursor);
861
868FLECS_API
870 ecs_meta_cursor_t *cursor,
871 const ecs_value_t *value);
872
873/* Functions for getting members. */
874
880FLECS_API
882 const ecs_meta_cursor_t *cursor);
883
889FLECS_API
891 const ecs_meta_cursor_t *cursor);
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
927FLECS_API
929 const ecs_meta_cursor_t *cursor);
930
937FLECS_API
939 const ecs_meta_cursor_t *cursor);
940
948 const ecs_meta_cursor_t *cursor);
949
956FLECS_API
958 ecs_primitive_kind_t type_kind,
959 const void *ptr);
960
961/* API functions for creating meta types */
962
968
975FLECS_API
977 ecs_world_t *world,
978 const ecs_primitive_desc_t *desc);
979
980
987
994FLECS_API
996 ecs_world_t *world,
997 const ecs_enum_desc_t *desc);
998
999
1005
1012FLECS_API
1014 ecs_world_t *world,
1015 const ecs_bitmask_desc_t *desc);
1016
1017
1024
1031FLECS_API
1033 ecs_world_t *world,
1034 const ecs_array_desc_t *desc);
1035
1036
1042
1049FLECS_API
1051 ecs_world_t *world,
1052 const ecs_vector_desc_t *desc);
1053
1054
1060
1067FLECS_API
1069 ecs_world_t *world,
1070 const ecs_struct_desc_t *desc);
1071
1072
1078
1101FLECS_API
1103 ecs_world_t *world,
1104 const ecs_opaque_desc_t *desc);
1105
1106
1135
1142FLECS_API
1144 ecs_world_t *world,
1145 const ecs_unit_desc_t *desc);
1146
1147
1159
1166FLECS_API
1168 ecs_world_t *world,
1169 const ecs_unit_prefix_desc_t *desc);
1170
1171
1178FLECS_API
1180 ecs_world_t *world,
1181 const ecs_entity_desc_t *desc);
1182
1183/* Convenience macros */
1184
1186#define ecs_primitive(world, ...)\
1187 ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ )
1188
1190#define ecs_enum(world, ...)\
1191 ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ )
1192
1194#define ecs_bitmask(world, ...)\
1195 ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ )
1196
1198#define ecs_array(world, ...)\
1199 ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ )
1200
1202#define ecs_vector(world, ...)\
1203 ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ )
1204
1206#define ecs_opaque(world, ...)\
1207 ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ )
1208
1210#define ecs_struct(world, ...)\
1211 ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ )
1212
1214#define ecs_unit(world, ...)\
1215 ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ )
1216
1218#define ecs_unit_prefix(world, ...)\
1219 ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ )
1220
1222#define ecs_quantity(world, ...)\
1223 ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ )
1224
1225
1234FLECS_API
1236 ecs_world_t *world);
1237
1238#ifdef __cplusplus
1239}
1240#endif
1241
1242#include "meta_c.h"
1243
1244#endif
1245
1248#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.
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:387
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.
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:393
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.
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:171
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:522
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:152
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:381
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:583
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:534
@ EcsOpScope
Marks last constant that can open/close a scope.
Definition meta.h:529
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:381
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:425
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:374
Utility macros for populating reflection data in C.
Component added to array type entities.
Definition meta.h:314
int32_t count
Number of elements.
Definition meta.h:316
ecs_entity_t type
Element type.
Definition meta.h:315
Component added to bitmask type entities.
Definition meta.h:308
ecs_map_t constants
map<u32_t, ecs_bitmask_constant_t>
Definition meta.h:310
Component information.
Definition flecs.h:1522
Component added to enum type entities.
Definition meta.h:285
ecs_map_t constants
Populated from child entities with Constant component.
Definition meta.h:289
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:199
ecs_entity_t unit
Member unit.
Definition meta.h:202
bool use_offset
If offset should be explicitly used.
Definition meta.h:204
ecs_entity_t type
Member type.
Definition meta.h:200
int32_t offset
Member offset.
Definition meta.h:203
int32_t count
Number of elements (for inline arrays).
Definition meta.h:201
Opaque type reflection data.
Definition meta.h:402
size_t(* count)(const void *dst)
Return number of elements.
Definition meta.h:475
void(* assign_null)(void *dst)
Assign null value.
Definition meta.h:457
ecs_meta_serialize_member_t serialize_member
Serialize member action.
Definition meta.h:405
void(* clear)(void *dst)
Clear collection elements.
Definition meta.h:461
void(* assign_uint)(void *dst, uint64_t value)
Assign unsigned int value.
Definition meta.h:430
ecs_meta_serialize_t serialize
Serialize action.
Definition meta.h:404
void(* assign_char)(void *dst, char value)
Assign char value.
Definition meta.h:420
ecs_entity_t as_type
Type that describes the serialized output.
Definition meta.h:403
void(* assign_bool)(void *dst, bool value)
Assign bool value.
Definition meta.h:415
void(* assign_string)(void *dst, const char *value)
Assign string value.
Definition meta.h:440
void(* resize)(void *dst, size_t count)
Resize to number of elements.
Definition meta.h:479
void(* assign_int)(void *dst, int64_t value)
Assign int value.
Definition meta.h:425
void(* assign_float)(void *dst, double value)
Assign float value.
Definition meta.h:435
void(* assign_entity)(void *dst, ecs_world_t *world, ecs_entity_t entity)
Assign entity value.
Definition meta.h:445
void(* assign_id)(void *dst, ecs_world_t *world, ecs_id_t id)
Assign (component) id value.
Definition meta.h:451
ecs_meta_serialize_element_t serialize_element
Serialize element action.
Definition meta.h:406
Component added to primitive types.
Definition meta.h:194
ecs_primitive_kind_t kind
Primitive type kind.
Definition meta.h:195
Component added to struct type entities.
Definition meta.h:264
ecs_vec_t members
Populated from child entities with Member component.
Definition meta.h:266
Component that stores the type serializer.
Definition meta.h:573
ecs_vec_t ops
vector<ecs_meta_type_op_t>
Definition meta.h:574
Component that is automatically added to every type with the right kind.
Definition meta.h:164
bool existing
Did the type exist or is it populated from reflection.
Definition meta.h:166
bool partial
Is the reflection data a partial type description.
Definition meta.h:167
ecs_type_kind_t kind
Type kind.
Definition meta.h:165
Component that stores unit prefix data.
Definition meta.h:509
ecs_unit_translation_t translation
Translation of prefix.
Definition meta.h:511
char * symbol
Symbol of prefix (e.g.
Definition meta.h:510
Component that stores unit data.
Definition meta.h:500
ecs_unit_translation_t translation
Translation for derived unit.
Definition meta.h:505
ecs_entity_t prefix
Order of magnitude prefix relative to derived.
Definition meta.h:502
char * symbol
Unit symbol.
Definition meta.h:501
ecs_entity_t base
Base unit (e.g.
Definition meta.h:503
ecs_entity_t over
Over unit (e.g.
Definition meta.h:504
Component added to vector type entities.
Definition meta.h:320
ecs_entity_t type
Element type.
Definition meta.h:321
Used with ecs_array_init().
Definition meta.h:1019
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1020
ecs_entity_t type
Element type.
Definition meta.h:1021
int32_t count
Number of elements.
Definition meta.h:1022
Type that describes an bitmask constant.
Definition meta.h:293
ecs_flags64_t value
May be set when used with ecs_bitmask_desc_t.
Definition meta.h:298
int64_t _unused
Keep layout the same with ecs_enum_constant_t.
Definition meta.h:301
ecs_entity_t constant
Should not be set by ecs_bitmask_desc_t.
Definition meta.h:304
const char * name
Must be set when used with ecs_bitmask_desc_t.
Definition meta.h:295
Used with ecs_bitmask_init().
Definition meta.h:1001
ecs_bitmask_constant_t constants[(32)]
Bitmask constants.
Definition meta.h:1003
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1002
Used with ecs_entity_init().
Definition flecs.h:1011
Type that describes an enum constant.
Definition meta.h:270
ecs_entity_t constant
Should not be set by ecs_enum_desc_t.
Definition meta.h:281
uint64_t value_unsigned
For when the underlying type is unsigned.
Definition meta.h:278
int64_t value
May be set when used with ecs_enum_desc_t.
Definition meta.h:275
const char * name
Must be set when used with ecs_enum_desc_t.
Definition meta.h:272
Used with ecs_enum_init().
Definition meta.h:982
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:983
ecs_enum_constant_t constants[(32)]
Enum constants.
Definition meta.h:984
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:254
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:257
bool use_offset
Set to true to prevent automatic offset computation.
Definition meta.h:241
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:260
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:246
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:250
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:604
ecs_meta_scope_t scope[(32)]
Cursor scope stack.
Definition meta.h:606
bool valid
Does the cursor point to a valid field.
Definition meta.h:608
const ecs_world_t * world
The world.
Definition meta.h:605
void * lookup_ctx
Context for lookup_action.
Definition meta.h:613
int32_t depth
Current scope depth.
Definition meta.h:607
bool is_primitive_scope
If in root scope, this allows for a push for primitive types.
Definition meta.h:609
ecs_entity_t(* lookup_action)(const ecs_world_t *, const char *, void *)
Custom entity lookup action for overriding default ecs_lookup.
Definition meta.h:612
Type with information about currently serialized scope.
Definition meta.h:586
const EcsOpaque * opaque
Opaque type interface.
Definition meta.h:595
int32_t prev_depth
Depth to restore, in case dotmember was used.
Definition meta.h:592
const EcsComponent * comp
Pointer to component, in case size/alignment is needed.
Definition meta.h:594
void * ptr
Pointer to the value being iterated.
Definition meta.h:593
bool is_empty_scope
Was scope populated (for collections)
Definition meta.h:600
ecs_vec_t * vector
Current vector, in case a vector is iterated.
Definition meta.h:596
int32_t elem_cur
Current element (for collections)
Definition meta.h:591
int32_t op_cur
Current operation.
Definition meta.h:590
bool is_inline_array
Is the scope iterating an inline array?
Definition meta.h:599
ecs_hashmap_t * members
string -> member index
Definition meta.h:597
ecs_meta_type_op_t * ops
The type operations (see ecs_meta_type_op_t)
Definition meta.h:588
int32_t op_count
Number of operations in ops array to process.
Definition meta.h:589
ecs_entity_t type
The type being iterated.
Definition meta.h:587
bool is_collection
Is the scope iterating elements?
Definition meta.h:598
Meta type serializer instruction data.
Definition meta.h:558
ecs_meta_type_op_kind_t kind
Instruction opcode.
Definition meta.h:559
ecs_entity_t type
Type entity.
Definition meta.h:565
int32_t count
Number of elements (for inline arrays).
Definition meta.h:561
ecs_size_t size
Size of type of operation.
Definition meta.h:564
ecs_size_t offset
Offset of current field.
Definition meta.h:560
const char * name
Name of value (only used for struct members)
Definition meta.h:562
int32_t member_index
Index of member in struct.
Definition meta.h:566
ecs_hashmap_t * members
string -> member index (structs only)
Definition meta.h:567
int32_t op_count
Number of operations until next field or end.
Definition meta.h:563
Used with ecs_opaque_init().
Definition meta.h:1074
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1075
EcsOpaque type
Type that the opaque type maps to.
Definition meta.h:1076
Used with ecs_primitive_init().
Definition meta.h:964
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:965
ecs_primitive_kind_t kind
Primitive type kind.
Definition meta.h:966
Serializer interface.
Definition meta.h:330
void * ctx
Serializer context.
Definition meta.h:343
int(* value)(const struct ecs_serializer_t *ser, ecs_entity_t type, const void *value)
Pointer to the value to serialize.
Definition meta.h:332
int(* member)(const struct ecs_serializer_t *ser, const char *member)
Member name.
Definition meta.h:338
const ecs_world_t * world
The world.
Definition meta.h:342
Used with ecs_struct_init().
Definition meta.h:1056
ecs_member_t members[(32)]
Struct members.
Definition meta.h:1058
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1057
Used with ecs_unit_init().
Definition meta.h:1108
ecs_entity_t base
Base unit, e.g.
Definition meta.h:1119
ecs_entity_t over
Over unit, e.g.
Definition meta.h:1122
const char * symbol
Unit symbol, e.g.
Definition meta.h:1113
ecs_entity_t prefix
Prefix indicating order of magnitude relative to the derived unit.
Definition meta.h:1133
ecs_entity_t quantity
Unit quantity, e.g.
Definition meta.h:1116
ecs_unit_translation_t translation
Translation to apply to derived unit (optional).
Definition meta.h:1125
ecs_entity_t entity
Existing entity to associate with unit (optional).
Definition meta.h:1110
Used with ecs_unit_prefix_init().
Definition meta.h:1149
ecs_entity_t entity
Existing entity to associate with unit prefix (optional).
Definition meta.h:1151
const char * symbol
Unit symbol, e.g.
Definition meta.h:1154
ecs_unit_translation_t translation
Translation to apply to derived unit (optional).
Definition meta.h:1157
Helper type to describe translation between two units.
Definition meta.h:494
int32_t power
Power to apply to factor (e.g.
Definition meta.h:496
int32_t factor
Factor to apply (e.g.
Definition meta.h:495
Utility to hold a value of a dynamic type.
Definition flecs.h:1002
Used with ecs_vector_init().
Definition meta.h:1038
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1039
ecs_entity_t type
Element type.
Definition meta.h:1040