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);
389typedef struct EcsOpaque {
393 /* Deserializer interface
394 * Only override the callbacks that are valid for the opaque type. If a
395 * deserializer attempts to assign a value type that is not supported by the
396 * interface, a conversion error is thrown.
397 */
398
400 void (*assign_bool)(
401 void *dst,
402 bool value);
403
405 void (*assign_char)(
406 void *dst,
407 char value);
408
410 void (*assign_int)(
411 void *dst,
412 int64_t value);
413
415 void (*assign_uint)(
416 void *dst,
417 uint64_t value);
418
421 void *dst,
422 double value);
423
426 void *dst,
427 const char *value);
428
431 void *dst,
432 ecs_world_t *world,
433 ecs_entity_t entity);
434
436 void (*assign_id)(
437 void *dst,
438 ecs_world_t *world,
439 ecs_id_t id);
440
442 void (*assign_null)(
443 void *dst);
444
446 void (*clear)(
447 void *dst);
448
450 void* (*ensure_element)(
451 void *dst,
452 size_t elem);
453
455 void* (*ensure_member)(
456 void *dst,
457 const char *member);
458
460 size_t (*count)(
461 const void *dst);
462
464 void (*resize)(
465 void *dst,
466 size_t count);
468
469
470/* Units */
471
483
492
498
499
500/* Serializer utilities */
501
508 EcsOpArray,
509 EcsOpVector,
510 EcsOpOpaque,
511 EcsOpPush,
512 EcsOpPop,
513
516 EcsOpEnum,
517 EcsOpBitmask,
518
521 EcsOpBool,
522 EcsOpChar,
523 EcsOpByte,
524 EcsOpU8,
525 EcsOpU16,
526 EcsOpU32,
527 EcsOpU64,
528 EcsOpI8,
529 EcsOpI16,
530 EcsOpI32,
531 EcsOpI64,
532 EcsOpF32,
533 EcsOpF64,
534 EcsOpUPtr,
535 EcsOpIPtr,
536 EcsOpString,
537 EcsOpEntity,
538 EcsOpId,
539 EcsMetaTypeOpKindLast = EcsOpId
541
543typedef struct ecs_meta_type_op_t {
545 ecs_size_t offset;
546 int32_t count;
547 const char *name;
548 int32_t op_count;
549 ecs_size_t size;
551 int32_t member_index;
552 ecs_hashmap_t *members;
554
558typedef struct EcsTypeSerializer {
559 ecs_vec_t ops;
561
562
563/* Deserializer utilities */
564
568#define ECS_META_MAX_SCOPE_DEPTH (32)
569
587
600
615FLECS_API
617 const ecs_world_t *world,
618 ecs_entity_t type,
619 void *ptr);
620
626FLECS_API
628 ecs_meta_cursor_t *cursor);
629
635FLECS_API
637 ecs_meta_cursor_t *cursor);
638
644FLECS_API
646 ecs_meta_cursor_t *cursor,
647 int32_t elem);
648
655FLECS_API
657 ecs_meta_cursor_t *cursor,
658 const char *name);
659
667FLECS_API
669 ecs_meta_cursor_t *cursor,
670 const char *name);
671
677FLECS_API
679 ecs_meta_cursor_t *cursor);
680
686FLECS_API
688 ecs_meta_cursor_t *cursor);
689
695FLECS_API
697 const ecs_meta_cursor_t *cursor);
698
704FLECS_API
706 const ecs_meta_cursor_t *cursor);
707
713FLECS_API
715 const ecs_meta_cursor_t *cursor);
716
722FLECS_API
724 const ecs_meta_cursor_t *cursor);
725
731FLECS_API
733 const ecs_meta_cursor_t *cursor);
734
735/* The set functions assign the field with the specified value. If the value
736 * does not have the same type as the field, it will be cased to the field type.
737 * If no valid conversion is available, the operation will fail. */
738
745FLECS_API
747 ecs_meta_cursor_t *cursor,
748 bool value);
749
756FLECS_API
758 ecs_meta_cursor_t *cursor,
759 char value);
760
767FLECS_API
769 ecs_meta_cursor_t *cursor,
770 int64_t value);
771
778FLECS_API
780 ecs_meta_cursor_t *cursor,
781 uint64_t value);
782
789FLECS_API
791 ecs_meta_cursor_t *cursor,
792 double value);
793
800FLECS_API
802 ecs_meta_cursor_t *cursor,
803 const char *value);
804
811FLECS_API
813 ecs_meta_cursor_t *cursor,
814 const char *value);
815
822FLECS_API
824 ecs_meta_cursor_t *cursor,
825 ecs_entity_t value);
826
833FLECS_API
835 ecs_meta_cursor_t *cursor,
836 ecs_id_t value);
837
843FLECS_API
845 ecs_meta_cursor_t *cursor);
846
853FLECS_API
855 ecs_meta_cursor_t *cursor,
856 const ecs_value_t *value);
857
858/* Functions for getting members. */
859
865FLECS_API
867 const ecs_meta_cursor_t *cursor);
868
874FLECS_API
876 const ecs_meta_cursor_t *cursor);
877
883FLECS_API
885 const ecs_meta_cursor_t *cursor);
886
892FLECS_API
894 const ecs_meta_cursor_t *cursor);
895
901FLECS_API
903 const ecs_meta_cursor_t *cursor);
904
912FLECS_API
914 const ecs_meta_cursor_t *cursor);
915
922FLECS_API
924 const ecs_meta_cursor_t *cursor);
925
933 const ecs_meta_cursor_t *cursor);
934
941FLECS_API
943 ecs_primitive_kind_t type_kind,
944 const void *ptr);
945
946/* API functions for creating meta types */
947
953
960FLECS_API
962 ecs_world_t *world,
963 const ecs_primitive_desc_t *desc);
964
965
972
979FLECS_API
981 ecs_world_t *world,
982 const ecs_enum_desc_t *desc);
983
984
990
997FLECS_API
999 ecs_world_t *world,
1000 const ecs_bitmask_desc_t *desc);
1001
1002
1009
1016FLECS_API
1018 ecs_world_t *world,
1019 const ecs_array_desc_t *desc);
1020
1021
1027
1034FLECS_API
1036 ecs_world_t *world,
1037 const ecs_vector_desc_t *desc);
1038
1039
1045
1052FLECS_API
1054 ecs_world_t *world,
1055 const ecs_struct_desc_t *desc);
1056
1057
1063
1086FLECS_API
1088 ecs_world_t *world,
1089 const ecs_opaque_desc_t *desc);
1090
1091
1120
1127FLECS_API
1129 ecs_world_t *world,
1130 const ecs_unit_desc_t *desc);
1131
1132
1144
1151FLECS_API
1153 ecs_world_t *world,
1154 const ecs_unit_prefix_desc_t *desc);
1155
1156
1163FLECS_API
1165 ecs_world_t *world,
1166 const ecs_entity_desc_t *desc);
1167
1168/* Convenience macros */
1169
1171#define ecs_primitive(world, ...)\
1172 ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ )
1173
1175#define ecs_enum(world, ...)\
1176 ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ )
1177
1179#define ecs_bitmask(world, ...)\
1180 ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ )
1181
1183#define ecs_array(world, ...)\
1184 ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ )
1185
1187#define ecs_vector(world, ...)\
1188 ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ )
1189
1191#define ecs_opaque(world, ...)\
1192 ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ )
1193
1195#define ecs_struct(world, ...)\
1196 ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ )
1197
1199#define ecs_unit(world, ...)\
1200 ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ )
1201
1203#define ecs_unit_prefix(world, ...)\
1204 ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ )
1205
1207#define ecs_quantity(world, ...)\
1208 ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ )
1209
1210
1219FLECS_API
1221 ecs_world_t *world);
1222
1223#ifdef __cplusplus
1224}
1225#endif
1226
1227#include "meta_c.h"
1228
1229#endif
1230
1233#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.
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:507
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:568
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:519
@ EcsOpScope
Marks last constant that can open/close a scope.
Definition meta.h:514
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:375
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:419
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:368
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:1515
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:389
size_t(* count)(const void *dst)
Return number of elements.
Definition meta.h:460
void(* assign_null)(void *dst)
Assign null value.
Definition meta.h:442
void(* clear)(void *dst)
Clear collection elements.
Definition meta.h:446
void(* assign_uint)(void *dst, uint64_t value)
Assign unsigned int value.
Definition meta.h:415
ecs_meta_serialize_t serialize
Serialize action.
Definition meta.h:391
void(* assign_char)(void *dst, char value)
Assign char value.
Definition meta.h:405
ecs_entity_t as_type
Type that describes the serialized output.
Definition meta.h:390
void(* assign_bool)(void *dst, bool value)
Assign bool value.
Definition meta.h:400
void(* assign_string)(void *dst, const char *value)
Assign string value.
Definition meta.h:425
void(* resize)(void *dst, size_t count)
Resize to number of elements.
Definition meta.h:464
void(* assign_int)(void *dst, int64_t value)
Assign int value.
Definition meta.h:410
void(* assign_float)(void *dst, double value)
Assign float value.
Definition meta.h:420
void(* assign_entity)(void *dst, ecs_world_t *world, ecs_entity_t entity)
Assign entity value.
Definition meta.h:430
void(* assign_id)(void *dst, ecs_world_t *world, ecs_id_t id)
Assign (component) id value.
Definition meta.h:436
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:558
ecs_vec_t ops
vector<ecs_meta_type_op_t>
Definition meta.h:559
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:494
ecs_unit_translation_t translation
Translation of prefix.
Definition meta.h:496
char * symbol
Symbol of prefix (e.g.
Definition meta.h:495
Component that stores unit data.
Definition meta.h:485
ecs_unit_translation_t translation
Translation for derived unit.
Definition meta.h:490
ecs_entity_t prefix
Order of magnitude prefix relative to derived.
Definition meta.h:487
char * symbol
Unit symbol.
Definition meta.h:486
ecs_entity_t base
Base unit (e.g.
Definition meta.h:488
ecs_entity_t over
Over unit (e.g.
Definition meta.h:489
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:1004
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1005
ecs_entity_t type
Element type.
Definition meta.h:1006
int32_t count
Number of elements.
Definition meta.h:1007
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:986
ecs_bitmask_constant_t constants[(32)]
Bitmask constants.
Definition meta.h:988
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:987
Used with ecs_entity_init().
Definition flecs.h:1004
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:967
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:968
ecs_enum_constant_t constants[(32)]
Enum constants.
Definition meta.h:969
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:589
ecs_meta_scope_t scope[(32)]
Cursor scope stack.
Definition meta.h:591
bool valid
Does the cursor point to a valid field.
Definition meta.h:593
const ecs_world_t * world
The world.
Definition meta.h:590
void * lookup_ctx
Context for lookup_action.
Definition meta.h:598
int32_t depth
Current scope depth.
Definition meta.h:592
bool is_primitive_scope
If in root scope, this allows for a push for primitive types.
Definition meta.h:594
ecs_entity_t(* lookup_action)(const ecs_world_t *, const char *, void *)
Custom entity lookup action for overriding default ecs_lookup.
Definition meta.h:597
Type with information about currently serialized scope.
Definition meta.h:571
const EcsOpaque * opaque
Opaque type interface.
Definition meta.h:580
int32_t prev_depth
Depth to restore, in case dotmember was used.
Definition meta.h:577
const EcsComponent * comp
Pointer to component, in case size/alignment is needed.
Definition meta.h:579
void * ptr
Pointer to the value being iterated.
Definition meta.h:578
bool is_empty_scope
Was scope populated (for collections)
Definition meta.h:585
ecs_vec_t * vector
Current vector, in case a vector is iterated.
Definition meta.h:581
int32_t elem_cur
Current element (for collections)
Definition meta.h:576
int32_t op_cur
Current operation.
Definition meta.h:575
bool is_inline_array
Is the scope iterating an inline array?
Definition meta.h:584
ecs_hashmap_t * members
string -> member index
Definition meta.h:582
ecs_meta_type_op_t * ops
The type operations (see ecs_meta_type_op_t)
Definition meta.h:573
int32_t op_count
Number of operations in ops array to process.
Definition meta.h:574
ecs_entity_t type
The type being iterated.
Definition meta.h:572
bool is_collection
Is the scope iterating elements?
Definition meta.h:583
Meta type serializer instruction data.
Definition meta.h:543
ecs_meta_type_op_kind_t kind
Instruction opcode.
Definition meta.h:544
ecs_entity_t type
Type entity.
Definition meta.h:550
int32_t count
Number of elements (for inline arrays).
Definition meta.h:546
ecs_size_t size
Size of type of operation.
Definition meta.h:549
ecs_size_t offset
Offset of current field.
Definition meta.h:545
const char * name
Name of value (only used for struct members)
Definition meta.h:547
int32_t member_index
Index of member in struct.
Definition meta.h:551
ecs_hashmap_t * members
string -> member index (structs only)
Definition meta.h:552
int32_t op_count
Number of operations until next field or end.
Definition meta.h:548
Used with ecs_opaque_init().
Definition meta.h:1059
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1060
EcsOpaque type
Type that the opaque type maps to.
Definition meta.h:1061
Used with ecs_primitive_init().
Definition meta.h:949
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:950
ecs_primitive_kind_t kind
Primitive type kind.
Definition meta.h:951
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:1041
ecs_member_t members[(32)]
Struct members.
Definition meta.h:1043
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1042
Used with ecs_unit_init().
Definition meta.h:1093
ecs_entity_t base
Base unit, e.g.
Definition meta.h:1104
ecs_entity_t over
Over unit, e.g.
Definition meta.h:1107
const char * symbol
Unit symbol, e.g.
Definition meta.h:1098
ecs_entity_t prefix
Prefix indicating order of magnitude relative to the derived unit.
Definition meta.h:1118
ecs_entity_t quantity
Unit quantity, e.g.
Definition meta.h:1101
ecs_unit_translation_t translation
Translation to apply to derived unit (optional).
Definition meta.h:1110
ecs_entity_t entity
Existing entity to associate with unit (optional).
Definition meta.h:1095
Used with ecs_unit_prefix_init().
Definition meta.h:1134
ecs_entity_t entity
Existing entity to associate with unit prefix (optional).
Definition meta.h:1136
const char * symbol
Unit symbol, e.g.
Definition meta.h:1139
ecs_unit_translation_t translation
Translation to apply to derived unit (optional).
Definition meta.h:1142
Helper type to describe translation between two units.
Definition meta.h:479
int32_t power
Power to apply to factor (e.g.
Definition meta.h:481
int32_t factor
Factor to apply (e.g.
Definition meta.h:480
Utility to hold a value of a dynamic type.
Definition flecs.h:995
Used with ecs_vector_init().
Definition meta.h:1023
ecs_entity_t entity
Existing entity to use for type (optional).
Definition meta.h:1024
ecs_entity_t type
Element type.
Definition meta.h:1025