Flecs v3.2
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
80#define ECS_MEMBER_DESC_CACHE_SIZE (32)
81
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;
111
112/* Meta module component ids */
113FLECS_API extern const ecs_entity_t ecs_id(EcsMetaType);
114FLECS_API extern const ecs_entity_t ecs_id(EcsMetaTypeSerialized);
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 EcsConstant;
127FLECS_API extern const ecs_entity_t EcsQuantity;
128
129/* Primitive type component ids */
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);
148
150typedef enum ecs_type_kind_t {
151 EcsPrimitiveType,
152 EcsBitmaskType,
153 EcsEnumType,
154 EcsStructType,
155 EcsArrayType,
156 EcsVectorType,
157 EcsOpaqueType,
158 EcsTypeKindLast = EcsOpaqueType
160
162typedef struct EcsMetaType {
163 ecs_type_kind_t kind;
164 bool existing;
165 bool partial;
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
197typedef struct EcsMember {
198 ecs_entity_t type;
199 int32_t count;
200 ecs_entity_t unit;
201 int32_t offset;
203
206 double min;
207 double max;
209
216
248
250typedef struct EcsStruct {
252 ecs_vec_t members; /* vector<ecs_member_t> */
254
255typedef struct ecs_enum_constant_t {
257 const char *name;
258
260 int32_t value;
261
265
267typedef struct EcsEnum {
269 ecs_map_t constants; /* map<i32_t, ecs_enum_constant_t> */
271
274 const char *name;
275
277 ecs_flags32_t value;
278
282
284typedef struct EcsBitmask {
285 /* Populated from child entities with Constant component */
286 ecs_map_t constants; /* map<u32_t, ecs_bitmask_constant_t> */
288
294
299
300
301/* Opaque type support */
302
303#if !defined(__cplusplus) || !defined(FLECS_CPP)
304
306typedef struct ecs_serializer_t {
307 /* Serialize value */
308 int (*value)(
309 const struct ecs_serializer_t *ser,
310 ecs_entity_t type,
311 const void *value);
313 /* Serialize member */
314 int (*member)(
315 const struct ecs_serializer_t *ser,
316 const char *member);
318 const ecs_world_t *world;
319 void *ctx;
321
322#elif defined(__cplusplus)
323
324} /* extern "C" { */
325
327typedef struct ecs_serializer_t {
328 /* Serialize value */
329 int (*value_)(
330 const struct ecs_serializer_t *ser,
331 ecs_entity_t type,
332 const void *value);
333
334 /* Serialize member */
335 int (*member_)(
336 const struct ecs_serializer_t *ser,
337 const char *name);
338
339 /* Serialize value */
340 int value(ecs_entity_t type, const void *value) const;
341
342 /* Serialize value */
343 template <typename T>
344 int value(const T& value) const;
345
346 /* Serialize member */
347 int member(const char *name) const;
348
349 const ecs_world_t *world;
350 void *ctx;
352
353extern "C" {
354#endif
355
357typedef int (*ecs_meta_serialize_t)(
358 const ecs_serializer_t *ser,
359 const void *src);
361typedef struct EcsOpaque {
365 /* Deserializer interface
366 * Only override the callbacks that are valid for the opaque type. If a
367 * deserializer attempts to assign a value type that is not supported by the
368 * interface, a conversion error is thrown.
369 */
370
372 void (*assign_bool)(
373 void *dst,
374 bool value);
375
377 void (*assign_char)(
378 void *dst,
379 char value);
380
382 void (*assign_int)(
383 void *dst,
384 int64_t value);
385
387 void (*assign_uint)(
388 void *dst,
389 uint64_t value);
390
393 void *dst,
394 double value);
395
398 void *dst,
399 const char *value);
400
403 void *dst,
404 ecs_world_t *world,
405 ecs_entity_t entity);
406
408 void (*assign_id)(
409 void *dst,
410 ecs_world_t *world,
411 ecs_id_t id);
412
414 void (*assign_null)(
415 void *dst);
416
418 void (*clear)(
419 void *dst);
420
422 void* (*ensure_element)(
423 void *dst,
424 size_t elem);
425
427 void* (*ensure_member)(
428 void *dst,
429 const char *member);
430
432 size_t (*count)(
433 const void *dst);
434
436 void (*resize)(
437 void *dst,
438 size_t count);
439} EcsOpaque;
440
441
442/* Units */
443
444/* Helper type to describe translation between two units. Note that this
445 * is not intended as a generic approach to unit conversions (e.g. from celsius
446 * to fahrenheit) but to translate between units that derive from the same base
447 * (e.g. meters to kilometers).
448 *
449 * Note that power is applied to the factor. When describing a translation of
450 * 1000, either use {factor = 1000, power = 1} or {factor = 1, power = 3}. */
452 int32_t factor;
453 int32_t power;
455
463
468
469
470/* Serializer utilities */
471
473 EcsOpArray,
474 EcsOpVector,
475 EcsOpOpaque,
476 EcsOpPush,
477 EcsOpPop,
478
481 EcsOpEnum,
482 EcsOpBitmask,
483
486 EcsOpBool,
487 EcsOpChar,
488 EcsOpByte,
489 EcsOpU8,
490 EcsOpU16,
491 EcsOpU32,
492 EcsOpU64,
493 EcsOpI8,
494 EcsOpI16,
495 EcsOpI32,
496 EcsOpI64,
497 EcsOpF32,
498 EcsOpF64,
499 EcsOpUPtr,
500 EcsOpIPtr,
501 EcsOpString,
502 EcsOpEntity,
503 EcsOpId,
504 EcsMetaTypeOpKindLast = EcsOpId
506
507typedef struct ecs_meta_type_op_t {
509 ecs_size_t offset;
510 int32_t count;
511 const char *name;
512 int32_t op_count;
513 ecs_size_t size;
515 int32_t member_index;
516 ecs_hashmap_t *members;
518
519typedef struct EcsMetaTypeSerialized {
520 ecs_vec_t ops;
522
523
524/* Deserializer utilities */
525
526#define ECS_META_MAX_SCOPE_DEPTH (32) /* >32 levels of nesting is not sane */
527
545
547typedef struct ecs_meta_cursor_t {
548 const ecs_world_t *world;
549 ecs_meta_scope_t scope[ECS_META_MAX_SCOPE_DEPTH];
550 int32_t depth;
551 bool valid;
554 /* Custom entity lookup action for overriding default ecs_lookup */
555 ecs_entity_t (*lookup_action)(const ecs_world_t*, const char*, void*);
556 void *lookup_ctx;
558
559FLECS_API
560ecs_meta_cursor_t ecs_meta_cursor(
561 const ecs_world_t *world,
562 ecs_entity_t type,
563 void *ptr);
564
566FLECS_API
568 ecs_meta_cursor_t *cursor);
569
571FLECS_API
573 ecs_meta_cursor_t *cursor);
574
576FLECS_API
578 ecs_meta_cursor_t *cursor,
579 int32_t elem);
580
582FLECS_API
584 ecs_meta_cursor_t *cursor,
585 const char *name);
586
588FLECS_API
590 ecs_meta_cursor_t *cursor,
591 const char *name);
592
594FLECS_API
596 ecs_meta_cursor_t *cursor);
597
599FLECS_API
601 ecs_meta_cursor_t *cursor);
602
604FLECS_API
606 const ecs_meta_cursor_t *cursor);
607
609FLECS_API
611 const ecs_meta_cursor_t *cursor);
612
614FLECS_API
616 const ecs_meta_cursor_t *cursor);
617
619FLECS_API
621 const ecs_meta_cursor_t *cursor);
622
624FLECS_API
626 const ecs_meta_cursor_t *cursor);
627
628/* The set functions assign the field with the specified value. If the value
629 * does not have the same type as the field, it will be cased to the field type.
630 * If no valid conversion is available, the operation will fail. */
631
633FLECS_API
635 ecs_meta_cursor_t *cursor,
636 bool value);
637
639FLECS_API
641 ecs_meta_cursor_t *cursor,
642 char value);
643
645FLECS_API
647 ecs_meta_cursor_t *cursor,
648 int64_t value);
649
651FLECS_API
653 ecs_meta_cursor_t *cursor,
654 uint64_t value);
655
657FLECS_API
659 ecs_meta_cursor_t *cursor,
660 double value);
661
663FLECS_API
665 ecs_meta_cursor_t *cursor,
666 const char *value);
667
669FLECS_API
671 ecs_meta_cursor_t *cursor,
672 const char *value);
673
675FLECS_API
677 ecs_meta_cursor_t *cursor,
678 ecs_entity_t value);
679
681FLECS_API
683 ecs_meta_cursor_t *cursor,
684 ecs_id_t value);
685
687FLECS_API
689 ecs_meta_cursor_t *cursor,
690 ecs_id_t value);
691
693FLECS_API
695 ecs_meta_cursor_t *cursor);
696
698FLECS_API
700 ecs_meta_cursor_t *cursor,
701 const ecs_value_t *value);
702
703/* Functions for getting members. */
704
706FLECS_API
708 const ecs_meta_cursor_t *cursor);
709
711FLECS_API
713 const ecs_meta_cursor_t *cursor);
714
716FLECS_API
718 const ecs_meta_cursor_t *cursor);
719
721FLECS_API
723 const ecs_meta_cursor_t *cursor);
724
726FLECS_API
728 const ecs_meta_cursor_t *cursor);
729
734FLECS_API
736 const ecs_meta_cursor_t *cursor);
737
740FLECS_API
742 const ecs_meta_cursor_t *cursor);
743
747 const ecs_meta_cursor_t *cursor);
748
750FLECS_API
752 ecs_primitive_kind_t type_kind,
753 const void *ptr);
754
755/* API functions for creating meta types */
756
762
764FLECS_API
766 ecs_world_t *world,
767 const ecs_primitive_desc_t *desc);
768
770typedef struct ecs_enum_desc_t {
772 ecs_enum_constant_t constants[ECS_MEMBER_DESC_CACHE_SIZE];
774
776FLECS_API
778 ecs_world_t *world,
779 const ecs_enum_desc_t *desc);
780
781
783typedef struct ecs_bitmask_desc_t {
785 ecs_bitmask_constant_t constants[ECS_MEMBER_DESC_CACHE_SIZE];
787
789FLECS_API
791 ecs_world_t *world,
792 const ecs_bitmask_desc_t *desc);
793
794
796typedef struct ecs_array_desc_t {
798 ecs_entity_t type;
799 int32_t count;
801
803FLECS_API
805 ecs_world_t *world,
806 const ecs_array_desc_t *desc);
807
808
814
816FLECS_API
818 ecs_world_t *world,
819 const ecs_vector_desc_t *desc);
820
821
823typedef struct ecs_struct_desc_t {
825 ecs_member_t members[ECS_MEMBER_DESC_CACHE_SIZE];
827
829FLECS_API
831 ecs_world_t *world,
832 const ecs_struct_desc_t *desc);
833
835typedef struct ecs_opaque_desc_t {
836 ecs_entity_t entity;
837 EcsOpaque type;
839
858FLECS_API
860 ecs_world_t *world,
861 const ecs_opaque_desc_t *desc);
862
891
893FLECS_API
895 ecs_world_t *world,
896 const ecs_unit_desc_t *desc);
897
909
911FLECS_API
913 ecs_world_t *world,
914 const ecs_unit_prefix_desc_t *desc);
915
917FLECS_API
919 ecs_world_t *world,
920 const ecs_entity_desc_t *desc);
921
922/* Convenience macros */
923
924#define ecs_primitive(world, ...)\
925 ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ )
926
927#define ecs_enum(world, ...)\
928 ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ )
929
930#define ecs_bitmask(world, ...)\
931 ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ )
932
933#define ecs_array(world, ...)\
934 ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ )
935
936#define ecs_vector(world, ...)\
937 ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ )
938
939#define ecs_opaque(world, ...)\
940 ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ )
941
942#define ecs_struct(world, ...)\
943 ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ )
944
945#define ecs_unit(world, ...)\
946 ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ )
947
948#define ecs_unit_prefix(world, ...)\
949 ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ )
950
951#define ecs_quantity(world, ...)\
952 ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ )
953
954/* Module import */
955FLECS_API
956void FlecsMetaImport(
957 ecs_world_t *world);
958
959#ifdef __cplusplus
960}
961#endif
962
963#endif
964
967#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:95
struct ecs_vector_desc_t ecs_vector_desc_t
Used with ecs_vector_init().
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.
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_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, supports dot-separated nested members.
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.
struct ecs_member_t ecs_member_t
Element type of members vector in EcsStruct.
struct EcsVector EcsVector
Component added to vector type entities.
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.
struct EcsBitmask EcsBitmask
Component added to bitmask type entities.
struct ecs_member_value_range_t ecs_member_value_range_t
Type expressing a range for a member value.
FLECS_API 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.
FLECS_API int ecs_meta_set_component(ecs_meta_cursor_t *cursor, ecs_id_t value)
Set field with (component) id value.
FLECS_API ecs_entity_t ecs_meta_get_unit(const ecs_meta_cursor_t *cursor)
Get unit of current element.
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 member.
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 member.
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 element.
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
Definition meta.h:472
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 EcsMetaType EcsMetaType
Component that is automatically added to every type with the right kind.
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 element.
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
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.
int(* ecs_meta_serialize_t)(const ecs_serializer_t *ser, const void *src)
Callback invoked serializing an opaque type.
Definition meta.h:357
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().
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.
FLECS_API int ecs_meta_set_bool(ecs_meta_cursor_t *cursor, bool value)
Set field with boolean value.
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().
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.
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:484
@ EcsOpScope
Marks last constant that can open/close a scope.
Definition meta.h:479
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:318
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:362
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:311
Component added to array type entities.
Definition meta.h:290
int32_t count
Number of elements.
Definition meta.h:292
ecs_entity_t type
Element type.
Definition meta.h:291
Component added to bitmask type entities.
Definition meta.h:284
Component information.
Definition flecs.h:1316
Component added to enum type entities.
Definition meta.h:267
ecs_map_t constants
Populated from child entities with Constant component.
Definition meta.h:269
Component added to member entities to express valid value ranges.
Definition meta.h:211
Component added to member entities.
Definition meta.h:197
ecs_vec_t ops
vector<ecs_meta_type_op_t>
Definition meta.h:520
Component that is automatically added to every type with the right kind.
Definition meta.h:162
bool partial
Is the reflection data a partial type description.
Definition meta.h:165
bool existing
Did the type exist or is it populated from reflection.
Definition meta.h:164
size_t(* count)(const void *dst)
Return number of elements.
Definition meta.h:432
void(* assign_null)(void *dst)
Assign null value.
Definition meta.h:414
void(* clear)(void *dst)
Clear collection elements.
Definition meta.h:418
void(* assign_uint)(void *dst, uint64_t value)
Assign unsigned int value.
Definition meta.h:387
ecs_meta_serialize_t serialize
Serialize action.
Definition meta.h:363
void(* assign_char)(void *dst, char value)
Assign char value.
Definition meta.h:377
ecs_entity_t as_type
Type that describes the serialized output.
Definition meta.h:362
void(* assign_bool)(void *dst, bool value)
Assign bool value.
Definition meta.h:372
void(* assign_string)(void *dst, const char *value)
Assign string value.
Definition meta.h:397
void(* resize)(void *dst, size_t count)
Resize to number of elements.
Definition meta.h:436
void(* assign_int)(void *dst, int64_t value)
Assign int value.
Definition meta.h:382
void(* assign_float)(void *dst, double value)
Assign float value.
Definition meta.h:392
void(* assign_entity)(void *dst, ecs_world_t *world, ecs_entity_t entity)
Assign entity value.
Definition meta.h:402
void(* assign_id)(void *dst, ecs_world_t *world, ecs_id_t id)
Assign (component) id value.
Definition meta.h:408
Component added to primitive types.
Definition meta.h:192
Component added to struct type entities.
Definition meta.h:250
ecs_vec_t members
Populated from child entities with Member component.
Definition meta.h:252
ecs_unit_translation_t translation
Translation of prefix.
Definition meta.h:466
char * symbol
Symbol of prefix (e.g.
Definition meta.h:465
ecs_unit_translation_t translation
Translation for derived unit.
Definition meta.h:461
ecs_entity_t prefix
Order of magnitude prefix relative to derived.
Definition meta.h:458
ecs_entity_t base
Base unit (e.g.
Definition meta.h:459
ecs_entity_t over
Over unit (e.g.
Definition meta.h:460
Component added to vector type entities.
Definition meta.h:296
ecs_entity_t type
Element type.
Definition meta.h:297
Used with ecs_array_init().
Definition meta.h:796
ecs_entity_t entity
Existing entity to use for type (optional)
Definition meta.h:797
ecs_entity_t constant
Should not be set by ecs_bitmask_desc_t.
Definition meta.h:280
ecs_flags32_t value
May be set when used with ecs_bitmask_desc_t.
Definition meta.h:277
const char * name
Must be set when used with ecs_bitmask_desc_t.
Definition meta.h:274
Used with ecs_bitmask_init().
Definition meta.h:783
ecs_entity_t entity
Existing entity to use for type (optional)
Definition meta.h:784
Used with ecs_entity_init().
Definition flecs.h:913
ecs_entity_t constant
Should not be set by ecs_enum_desc_t.
Definition meta.h:263
int32_t value
May be set when used with ecs_enum_desc_t.
Definition meta.h:260
const char * name
Must be set when used with ecs_enum_desc_t.
Definition meta.h:257
Used with ecs_enum_init().
Definition meta.h:770
ecs_entity_t entity
Existing entity to use for type (optional)
Definition meta.h:771
Element type of members vector in EcsStruct.
Definition meta.h:218
ecs_member_value_range_t warning_range
Numerical range outside of which the value represents an warning.
Definition meta.h:242
const char * name
Must be set when used with ecs_struct_desc_t.
Definition meta.h:220
ecs_size_t size
Should not be set by ecs_struct_desc_t.
Definition meta.h:245
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:229
ecs_member_value_range_t range
Numerical range that specifies which values member can assume.
Definition meta.h:234
int32_t count
May be set when used with ecs_struct_desc_t.
Definition meta.h:224
ecs_member_value_range_t error_range
Numerical range outside of which the value represents an error.
Definition meta.h:238
Type expressing a range for a member value.
Definition meta.h:205
Type that enables iterating/populating a value using reflection data.
Definition meta.h:547
bool is_primitive_scope
If in root scope, this allows for a push for primitive types.
Definition meta.h:552
const EcsOpaque * opaque
Opaque type interface.
Definition meta.h:538
int32_t prev_depth
Depth to restore, in case dotmember was used.
Definition meta.h:534
const EcsComponent * comp
Pointer to component, in case size/alignment is needed.
Definition meta.h:537
void * ptr
Pointer to the value being iterated.
Definition meta.h:535
bool is_empty_scope
Was scope populated (for collections)
Definition meta.h:543
ecs_vec_t * vector
Current vector, in case a vector is iterated.
Definition meta.h:539
int32_t elem_cur
Current element (for collections)
Definition meta.h:533
int32_t op_cur
Current operation.
Definition meta.h:532
bool is_inline_array
Is the scope iterating an inline array?
Definition meta.h:542
ecs_hashmap_t * members
string -> member index
Definition meta.h:540
ecs_meta_type_op_t * ops
The type operations (see ecs_meta_type_op_t)
Definition meta.h:530
int32_t op_count
Number of operations in ops array to process.
Definition meta.h:531
ecs_entity_t type
The type being iterated.
Definition meta.h:529
bool is_collection
Is the scope iterating elements?
Definition meta.h:541
ecs_entity_t type
Type entity.
Definition meta.h:514
ecs_size_t size
Size of type of operation.
Definition meta.h:513
ecs_size_t offset
Offset of current field.
Definition meta.h:509
const char * name
Name of value (only used for struct members)
Definition meta.h:511
int32_t member_index
Index of member in struct.
Definition meta.h:515
ecs_hashmap_t * members
string -> member index (structs only)
Definition meta.h:516
int32_t op_count
Number of operations until next field or end.
Definition meta.h:512
Used with ecs_opaque_init().
Definition meta.h:835
Used with ecs_primitive_init().
Definition meta.h:758
ecs_entity_t entity
Existing entity to use for type (optional)
Definition meta.h:759
Serializer interface.
Definition meta.h:306
int(* value)(const struct ecs_serializer_t *ser, ecs_entity_t type, const void *value)
Pointer to the value to serialize.
Definition meta.h:308
int(* member)(const struct ecs_serializer_t *ser, const char *member)
Member name.
Definition meta.h:314
Used with ecs_struct_init().
Definition meta.h:823
ecs_entity_t entity
Existing entity to use for type (optional)
Definition meta.h:824
Used with ecs_unit_init().
Definition meta.h:864
ecs_entity_t base
Base unit, e.g.
Definition meta.h:875
ecs_entity_t over
Over unit, e.g.
Definition meta.h:878
const char * symbol
Unit symbol, e.g.
Definition meta.h:869
ecs_entity_t prefix
Prefix indicating order of magnitude relative to the derived unit.
Definition meta.h:889
ecs_entity_t quantity
Unit quantity, e.g.
Definition meta.h:872
ecs_unit_translation_t translation
Translation to apply to derived unit (optional)
Definition meta.h:881
ecs_entity_t entity
Existing entity to associate with unit (optional)
Definition meta.h:866
Used with ecs_unit_prefix_init().
Definition meta.h:899
ecs_entity_t entity
Existing entity to associate with unit prefix (optional)
Definition meta.h:901
const char * symbol
Unit symbol, e.g.
Definition meta.h:904
ecs_unit_translation_t translation
Translation to apply to derived unit (optional)
Definition meta.h:907
int32_t power
Power to apply to factor (e.g.
Definition meta.h:453
int32_t factor
Factor to apply (e.g.
Definition meta.h:452
Used with ecs_vector_init().
Definition meta.h:810
ecs_entity_t entity
Existing entity to use for type (optional)
Definition meta.h:811