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
55#ifdef FLECS_META
56
65#include <stddef.h>
66
67#ifndef FLECS_MODULE
68#define FLECS_MODULE
69#endif
70
71#ifndef FLECS_META_H
72#define FLECS_META_H
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
78#define ECS_MEMBER_DESC_CACHE_SIZE (32)
79
87typedef bool ecs_bool_t;
88typedef char ecs_char_t;
89typedef unsigned char ecs_byte_t;
90typedef uint8_t ecs_u8_t;
91typedef uint16_t ecs_u16_t;
92typedef uint32_t ecs_u32_t;
93typedef uint64_t ecs_u64_t;
94typedef uintptr_t ecs_uptr_t;
95typedef int8_t ecs_i8_t;
96typedef int16_t ecs_i16_t;
97typedef int32_t ecs_i32_t;
98typedef int64_t ecs_i64_t;
99typedef intptr_t ecs_iptr_t;
100typedef float ecs_f32_t;
101typedef double ecs_f64_t;
102typedef char* ecs_string_t;
103
104/* Meta module component ids */
105FLECS_API extern const ecs_entity_t ecs_id(EcsMetaType);
106FLECS_API extern const ecs_entity_t ecs_id(EcsMetaTypeSerialized);
107FLECS_API extern const ecs_entity_t ecs_id(EcsPrimitive);
108FLECS_API extern const ecs_entity_t ecs_id(EcsEnum);
109FLECS_API extern const ecs_entity_t ecs_id(EcsBitmask);
110FLECS_API extern const ecs_entity_t ecs_id(EcsMember);
111FLECS_API extern const ecs_entity_t ecs_id(EcsStruct);
112FLECS_API extern const ecs_entity_t ecs_id(EcsArray);
113FLECS_API extern const ecs_entity_t ecs_id(EcsVector);
114FLECS_API extern const ecs_entity_t ecs_id(EcsOpaque);
115FLECS_API extern const ecs_entity_t ecs_id(EcsUnit);
116FLECS_API extern const ecs_entity_t ecs_id(EcsUnitPrefix);
117FLECS_API extern const ecs_entity_t EcsConstant;
118FLECS_API extern const ecs_entity_t EcsQuantity;
119
120/* Primitive type component ids */
121FLECS_API extern const ecs_entity_t ecs_id(ecs_bool_t);
122FLECS_API extern const ecs_entity_t ecs_id(ecs_char_t);
123FLECS_API extern const ecs_entity_t ecs_id(ecs_byte_t);
124FLECS_API extern const ecs_entity_t ecs_id(ecs_u8_t);
125FLECS_API extern const ecs_entity_t ecs_id(ecs_u16_t);
126FLECS_API extern const ecs_entity_t ecs_id(ecs_u32_t);
127FLECS_API extern const ecs_entity_t ecs_id(ecs_u64_t);
128FLECS_API extern const ecs_entity_t ecs_id(ecs_uptr_t);
129FLECS_API extern const ecs_entity_t ecs_id(ecs_i8_t);
130FLECS_API extern const ecs_entity_t ecs_id(ecs_i16_t);
131FLECS_API extern const ecs_entity_t ecs_id(ecs_i32_t);
132FLECS_API extern const ecs_entity_t ecs_id(ecs_i64_t);
133FLECS_API extern const ecs_entity_t ecs_id(ecs_iptr_t);
134FLECS_API extern const ecs_entity_t ecs_id(ecs_f32_t);
135FLECS_API extern const ecs_entity_t ecs_id(ecs_f64_t);
136FLECS_API extern const ecs_entity_t ecs_id(ecs_string_t);
137FLECS_API extern const ecs_entity_t ecs_id(ecs_entity_t);
138
140typedef enum ecs_type_kind_t {
141 EcsPrimitiveType,
142 EcsBitmaskType,
143 EcsEnumType,
144 EcsStructType,
145 EcsArrayType,
146 EcsVectorType,
147 EcsOpaqueType,
148 EcsTypeKindLast = EcsOpaqueType
150
152typedef struct EcsMetaType {
153 ecs_type_kind_t kind;
154 bool existing;
155 bool partial;
156 ecs_size_t size;
157 ecs_size_t alignment;
159
160typedef enum ecs_primitive_kind_t {
161 EcsBool = 1,
162 EcsChar,
163 EcsByte,
164 EcsU8,
165 EcsU16,
166 EcsU32,
167 EcsU64,
168 EcsI8,
169 EcsI16,
170 EcsI32,
171 EcsI64,
172 EcsF32,
173 EcsF64,
174 EcsUPtr,
175 EcsIPtr,
176 EcsString,
177 EcsEntity,
178 EcsPrimitiveKindLast = EcsEntity
179} ecs_primitive_kind_t;
180
181typedef struct EcsPrimitive {
182 ecs_primitive_kind_t kind;
184
185typedef struct EcsMember {
186 ecs_entity_t type;
187 int32_t count;
188 ecs_entity_t unit;
189 int32_t offset;
190} EcsMember;
191
193typedef struct ecs_member_t {
195 const char *name;
196 ecs_entity_t type;
197
199 int32_t count;
200 int32_t offset;
201
205
207 ecs_size_t size;
208 ecs_entity_t member;
210
211typedef struct EcsStruct {
213 ecs_vec_t members; /* vector<ecs_member_t> */
214} EcsStruct;
215
216typedef struct ecs_enum_constant_t {
218 const char *name;
219
221 int32_t value;
222
226
227typedef struct EcsEnum {
229 ecs_map_t constants; /* map<i32_t, ecs_enum_constant_t> */
230} EcsEnum;
231
234 const char *name;
235
237 ecs_flags32_t value;
238
242
243typedef struct EcsBitmask {
244 /* Populated from child entities with Constant component */
245 ecs_map_t constants; /* map<u32_t, ecs_bitmask_constant_t> */
246} EcsBitmask;
247
248typedef struct EcsArray {
249 ecs_entity_t type;
250 int32_t count;
251} EcsArray;
252
253typedef struct EcsVector {
254 ecs_entity_t type;
255} EcsVector;
256
257
258/* Opaque type support */
259
260#if !defined(__cplusplus) || !defined(FLECS_CPP)
261
263typedef struct ecs_serializer_t {
264 /* Serialize value */
265 int (*value)(
266 const struct ecs_serializer_t *ser,
267 ecs_entity_t type,
268 const void *value);
270 /* Serialize member */
271 int (*member)(
272 const struct ecs_serializer_t *ser,
273 const char *member);
275 const ecs_world_t *world;
276 void *ctx;
278
279#elif defined(__cplusplus)
280
281} /* extern "C" { */
282
284typedef struct ecs_serializer_t {
285 /* Serialize value */
286 int (*value_)(
287 const struct ecs_serializer_t *ser,
288 ecs_entity_t type,
289 const void *value);
290
291 /* Serialize member */
292 int (*member_)(
293 const struct ecs_serializer_t *ser,
294 const char *name);
295
296 /* Serialize value */
297 int value(ecs_entity_t type, const void *value) const;
298
299 /* Serialize value */
300 template <typename T>
301 int value(const T& value) const;
302
303 /* Serialize member */
304 int member(const char *name) const;
305
306 const ecs_world_t *world;
307 void *ctx;
309
310extern "C" {
311#endif
312
314typedef int (*ecs_meta_serialize_t)(
315 const ecs_serializer_t *ser,
316 const void *src);
318typedef struct EcsOpaque {
322 /* Deserializer interface
323 * Only override the callbacks that are valid for the opaque type. If a
324 * deserializer attempts to assign a value type that is not supported by the
325 * interface, a conversion error is thrown.
326 */
327
329 void (*assign_bool)(
330 void *dst,
331 bool value);
332
334 void (*assign_char)(
335 void *dst,
336 char value);
337
339 void (*assign_int)(
340 void *dst,
341 int64_t value);
342
344 void (*assign_uint)(
345 void *dst,
346 uint64_t value);
347
350 void *dst,
351 double value);
352
355 void *dst,
356 const char *value);
357
360 void *dst,
361 ecs_world_t *world,
362 ecs_entity_t entity);
363
365 void (*assign_null)(
366 void *dst);
367
369 void (*clear)(
370 void *dst);
371
373 void* (*ensure_element)(
374 void *dst,
375 size_t elem);
376
378 void* (*ensure_member)(
379 void *dst,
380 const char *member);
381
383 size_t (*count)(
384 const void *dst);
385
387 void (*resize)(
388 void *dst,
389 size_t count);
390} EcsOpaque;
391
392
393/* Units */
394
395/* Helper type to describe translation between two units. Note that this
396 * is not intended as a generic approach to unit conversions (e.g. from celsius
397 * to fahrenheit) but to translate between units that derive from the same base
398 * (e.g. meters to kilometers).
399 *
400 * Note that power is applied to the factor. When describing a translation of
401 * 1000, either use {factor = 1000, power = 1} or {factor = 1, power = 3}. */
403 int32_t factor;
404 int32_t power;
406
407typedef struct EcsUnit {
408 char *symbol;
413} EcsUnit;
414
415typedef struct EcsUnitPrefix {
416 char *symbol;
419
420
421/* Serializer utilities */
422
424 EcsOpArray,
425 EcsOpVector,
426 EcsOpOpaque,
427 EcsOpPush,
428 EcsOpPop,
429
432 EcsOpEnum,
433 EcsOpBitmask,
434
437 EcsOpBool,
438 EcsOpChar,
439 EcsOpByte,
440 EcsOpU8,
441 EcsOpU16,
442 EcsOpU32,
443 EcsOpU64,
444 EcsOpI8,
445 EcsOpI16,
446 EcsOpI32,
447 EcsOpI64,
448 EcsOpF32,
449 EcsOpF64,
450 EcsOpUPtr,
451 EcsOpIPtr,
452 EcsOpString,
453 EcsOpEntity,
454 EcsMetaTypeOpKindLast = EcsOpEntity
456
457typedef struct ecs_meta_type_op_t {
459 ecs_size_t offset;
460 int32_t count;
461 const char *name;
462 int32_t op_count;
463 ecs_size_t size;
464 ecs_entity_t type;
465 ecs_entity_t unit;
466 ecs_hashmap_t *members;
468
469typedef struct EcsMetaTypeSerialized {
470 ecs_vec_t ops;
472
473
474/* Deserializer utilities */
475
476#define ECS_META_MAX_SCOPE_DEPTH (32) /* >32 levels of nesting is not sane */
477
478typedef struct ecs_meta_scope_t {
481 int32_t op_count;
482 int32_t op_cur;
483 int32_t elem_cur;
484 int32_t prev_depth;
485 void *ptr;
489 ecs_vec_t *vector;
490 ecs_hashmap_t *members;
495
497typedef struct ecs_meta_cursor_t {
498 const ecs_world_t *world;
499 ecs_meta_scope_t scope[ECS_META_MAX_SCOPE_DEPTH];
500 int32_t depth;
501 bool valid;
504 /* Custom entity lookup action for overriding default ecs_lookup_fullpath */
505 ecs_entity_t (*lookup_action)(const ecs_world_t*, const char*, void*);
506 void *lookup_ctx;
508
509FLECS_API
510ecs_meta_cursor_t ecs_meta_cursor(
511 const ecs_world_t *world,
512 ecs_entity_t type,
513 void *ptr);
514
516FLECS_API
518 ecs_meta_cursor_t *cursor);
519
521FLECS_API
523 ecs_meta_cursor_t *cursor);
524
526FLECS_API
528 ecs_meta_cursor_t *cursor,
529 int32_t elem);
530
532FLECS_API
534 ecs_meta_cursor_t *cursor,
535 const char *name);
536
538FLECS_API
540 ecs_meta_cursor_t *cursor,
541 const char *name);
542
544FLECS_API
546 ecs_meta_cursor_t *cursor);
547
549FLECS_API
551 ecs_meta_cursor_t *cursor);
552
554FLECS_API
556 const ecs_meta_cursor_t *cursor);
557
559FLECS_API
561 const ecs_meta_cursor_t *cursor);
562
564FLECS_API
566 const ecs_meta_cursor_t *cursor);
567
569FLECS_API
571 const ecs_meta_cursor_t *cursor);
572
573/* The set functions assign the field with the specified value. If the value
574 * does not have the same type as the field, it will be cased to the field type.
575 * If no valid conversion is available, the operation will fail. */
576
578FLECS_API
580 ecs_meta_cursor_t *cursor,
581 bool value);
582
584FLECS_API
586 ecs_meta_cursor_t *cursor,
587 char value);
588
590FLECS_API
592 ecs_meta_cursor_t *cursor,
593 int64_t value);
594
596FLECS_API
598 ecs_meta_cursor_t *cursor,
599 uint64_t value);
600
602FLECS_API
604 ecs_meta_cursor_t *cursor,
605 double value);
606
608FLECS_API
610 ecs_meta_cursor_t *cursor,
611 const char *value);
612
614FLECS_API
616 ecs_meta_cursor_t *cursor,
617 const char *value);
618
620FLECS_API
622 ecs_meta_cursor_t *cursor,
623 ecs_entity_t value);
624
626FLECS_API
628 ecs_meta_cursor_t *cursor);
629
631FLECS_API
633 ecs_meta_cursor_t *cursor,
634 const ecs_value_t *value);
635
636/* Functions for getting members. */
637
639FLECS_API
641 const ecs_meta_cursor_t *cursor);
642
644FLECS_API
646 const ecs_meta_cursor_t *cursor);
647
649FLECS_API
651 const ecs_meta_cursor_t *cursor);
652
654FLECS_API
656 const ecs_meta_cursor_t *cursor);
657
659FLECS_API
661 const ecs_meta_cursor_t *cursor);
662
667FLECS_API
669 const ecs_meta_cursor_t *cursor);
670
673FLECS_API
675 const ecs_meta_cursor_t *cursor);
676
678FLECS_API
680 ecs_primitive_kind_t type_kind,
681 const void *ptr);
682
683/* API functions for creating meta types */
684
686typedef struct ecs_primitive_desc_t {
688 ecs_primitive_kind_t kind;
690
692FLECS_API
694 ecs_world_t *world,
695 const ecs_primitive_desc_t *desc);
696
698typedef struct ecs_enum_desc_t {
700 ecs_enum_constant_t constants[ECS_MEMBER_DESC_CACHE_SIZE];
702
704FLECS_API
706 ecs_world_t *world,
707 const ecs_enum_desc_t *desc);
708
709
711typedef struct ecs_bitmask_desc_t {
713 ecs_bitmask_constant_t constants[ECS_MEMBER_DESC_CACHE_SIZE];
715
717FLECS_API
719 ecs_world_t *world,
720 const ecs_bitmask_desc_t *desc);
721
722
724typedef struct ecs_array_desc_t {
726 ecs_entity_t type;
727 int32_t count;
729
731FLECS_API
733 ecs_world_t *world,
734 const ecs_array_desc_t *desc);
735
736
738typedef struct ecs_vector_desc_t {
740 ecs_entity_t type;
742
744FLECS_API
746 ecs_world_t *world,
747 const ecs_vector_desc_t *desc);
748
749
751typedef struct ecs_struct_desc_t {
753 ecs_member_t members[ECS_MEMBER_DESC_CACHE_SIZE];
755
757FLECS_API
759 ecs_world_t *world,
760 const ecs_struct_desc_t *desc);
761
763typedef struct ecs_opaque_desc_t {
764 ecs_entity_t entity;
765 EcsOpaque type;
767
786FLECS_API
788 ecs_world_t *world,
789 const ecs_opaque_desc_t *desc);
790
792typedef struct ecs_unit_desc_t {
795
797 const char *symbol;
798
801
804
807
810
819
821FLECS_API
823 ecs_world_t *world,
824 const ecs_unit_desc_t *desc);
825
830
832 const char *symbol;
833
837
839FLECS_API
841 ecs_world_t *world,
842 const ecs_unit_prefix_desc_t *desc);
843
845FLECS_API
847 ecs_world_t *world,
848 const ecs_entity_desc_t *desc);
849
850/* Convenience macros */
851
852#define ecs_primitive(world, ...)\
853 ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ )
854
855#define ecs_enum(world, ...)\
856 ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ )
857
858#define ecs_bitmask(world, ...)\
859 ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ )
860
861#define ecs_array(world, ...)\
862 ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ )
863
864#define ecs_vector(world, ...)\
865 ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ )
866
867#define ecs_opaque(world, ...)\
868 ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ )
869
870#define ecs_struct(world, ...)\
871 ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ )
872
873#define ecs_unit(world, ...)\
874 ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ )
875
876#define ecs_unit_prefix(world, ...)\
877 ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ )
878
879#define ecs_quantity(world, ...)\
880 ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ )
881
882/* Module import */
883FLECS_API
884void FlecsMetaImport(
885 ecs_world_t *world);
886
887#ifdef __cplusplus
888}
889#endif
890
891#endif
892
895#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.
FLECS_API bool ecs_meta_get_bool(const ecs_meta_cursor_t *cursor)
Get field value as boolean.
bool ecs_bool_t
Primitive type definitions.
Definition: meta.h:87
FLECS_API ecs_entity_t ecs_bitmask_init(ecs_world_t *world, const ecs_bitmask_desc_t *desc)
Create a new bitmask type.
FLECS_API double ecs_meta_ptr_to_float(ecs_primitive_kind_t type_kind, const void *ptr)
Convert pointer of primitive kind to float.
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.
FLECS_API int ecs_meta_dotmember(ecs_meta_cursor_t *cursor, const char *name)
Move cursor to member, supports dot-separated nested members.
FLECS_API ecs_entity_t ecs_meta_get_entity(const ecs_meta_cursor_t *cursor)
Get field value as entity.
FLECS_API bool ecs_meta_is_collection(const ecs_meta_cursor_t *cursor)
Is the current scope a collection?
FLECS_API ecs_entity_t ecs_quantity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Create a new quantity.
FLECS_API ecs_entity_t ecs_meta_get_unit(const ecs_meta_cursor_t *cursor)
Get unit of current element.
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.
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:423
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.
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.
ecs_type_kind_t
Type kinds supported by reflection type system.
Definition: meta.h:140
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:314
FLECS_API int ecs_meta_set_string(ecs_meta_cursor_t *cursor, const char *value)
Set field with string value.
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.
FLECS_API void * ecs_meta_get_ptr(ecs_meta_cursor_t *cursor)
Get pointer to current field.
FLECS_API int ecs_meta_set_value(ecs_meta_cursor_t *cursor, const ecs_value_t *value)
Set field with dynamic value.
FLECS_API int ecs_meta_set_null(ecs_meta_cursor_t *cursor)
Set field with null value.
FLECS_API ecs_entity_t ecs_array_init(ecs_world_t *world, const ecs_array_desc_t *desc)
Create a new array type.
FLECS_API int ecs_meta_set_entity(ecs_meta_cursor_t *cursor, ecs_entity_t value)
Set field with entity value.
FLECS_API 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:435
@ EcsOpScope
Marks last constant that can open/close a scope.
Definition: meta.h:430
ecs_id_t ecs_entity_t
An entity identifier.
Definition: flecs.h:277
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition: flecs.h:286
Definition: meta.h:248
Component information.
Definition: flecs.h:1086
Definition: meta.h:227
ecs_map_t constants
Populated from child entities with Constant component.
Definition: meta.h:229
ecs_vec_t ops
vector<ecs_meta_type_op_t>
Definition: meta.h:470
Component that is automatically added to every type with the right kind.
Definition: meta.h:152
ecs_size_t alignment
Computed alignment.
Definition: meta.h:157
bool partial
Is the reflection data a partial type description.
Definition: meta.h:155
ecs_size_t size
Computed size.
Definition: meta.h:156
bool existing
Did the type exist or is it populated from reflection.
Definition: meta.h:154
size_t(* count)(const void *dst)
Return number of elements.
Definition: meta.h:383
void(* assign_null)(void *dst)
Assign null value.
Definition: meta.h:365
void(* clear)(void *dst)
Clear collection elements.
Definition: meta.h:369
void(* assign_uint)(void *dst, uint64_t value)
Assign unsigned int value.
Definition: meta.h:344
ecs_meta_serialize_t serialize
Serialize action.
Definition: meta.h:320
void(* assign_char)(void *dst, char value)
Assign char value.
Definition: meta.h:334
ecs_entity_t as_type
Type that describes the serialized output.
Definition: meta.h:319
void(* assign_bool)(void *dst, bool value)
Assign bool value.
Definition: meta.h:329
void(* assign_string)(void *dst, const char *value)
Assign string value.
Definition: meta.h:354
void(* resize)(void *dst, size_t count)
Resize to number of elements.
Definition: meta.h:387
void(* assign_int)(void *dst, int64_t value)
Assign int value.
Definition: meta.h:339
void(* assign_float)(void *dst, double value)
Assign float value.
Definition: meta.h:349
void(* assign_entity)(void *dst, ecs_world_t *world, ecs_entity_t entity)
Assign entity value.
Definition: meta.h:359
ecs_vec_t members
Populated from child entities with Member component.
Definition: meta.h:213
ecs_unit_translation_t translation
Translation of prefix.
Definition: meta.h:417
char * symbol
Symbol of prefix (e.g.
Definition: meta.h:416
Definition: meta.h:407
ecs_unit_translation_t translation
Translation for derived unit.
Definition: meta.h:412
ecs_entity_t prefix
Order of magnitude prefix relative to derived.
Definition: meta.h:409
ecs_entity_t base
Base unit (e.g.
Definition: meta.h:410
ecs_entity_t over
Over unit (e.g.
Definition: meta.h:411
Used with ecs_array_init.
Definition: meta.h:724
ecs_entity_t entity
Existing entity to use for type (optional)
Definition: meta.h:725
ecs_entity_t constant
Should not be set by ecs_bitmask_desc_t.
Definition: meta.h:240
ecs_flags32_t value
May be set when used with ecs_bitmask_desc_t.
Definition: meta.h:237
const char * name
Must be set when used with ecs_bitmask_desc_t.
Definition: meta.h:234
Used with ecs_bitmask_init.
Definition: meta.h:711
ecs_entity_t entity
Existing entity to use for type (optional)
Definition: meta.h:712
Used with ecs_entity_init.
Definition: flecs.h:755
ecs_entity_t constant
Should not be set by ecs_enum_desc_t.
Definition: meta.h:224
int32_t value
May be set when used with ecs_enum_desc_t.
Definition: meta.h:221
const char * name
Must be set when used with ecs_enum_desc_t.
Definition: meta.h:218
Used with ecs_enum_init.
Definition: meta.h:698
ecs_entity_t entity
Existing entity to use for type (optional)
Definition: meta.h:699
Element type of members vector in EcsStruct.
Definition: meta.h:193
const char * name
Must be set when used with ecs_struct_desc_t.
Definition: meta.h:195
ecs_size_t size
Should not be set by ecs_struct_desc_t.
Definition: meta.h:207
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:204
int32_t count
May be set when used with ecs_struct_desc_t.
Definition: meta.h:199
Type that enables iterating/populating a value using reflection data.
Definition: meta.h:497
bool is_primitive_scope
If in root scope, this allows for a push for primitive types.
Definition: meta.h:502
const EcsOpaque * opaque
Opaque type interface.
Definition: meta.h:488
int32_t prev_depth
Depth to restore, in case dotmember was used.
Definition: meta.h:484
const EcsComponent * comp
Pointer to component, in case size/alignment is needed.
Definition: meta.h:487
void * ptr
Pointer to the value being iterated.
Definition: meta.h:485
bool is_empty_scope
Was scope populated (for collections)
Definition: meta.h:493
ecs_vec_t * vector
Current vector, in case a vector is iterated.
Definition: meta.h:489
int32_t elem_cur
Current element (for collections)
Definition: meta.h:483
int32_t op_cur
Current operation.
Definition: meta.h:482
bool is_inline_array
Is the scope iterating an inline array?
Definition: meta.h:492
ecs_hashmap_t * members
string -> member index
Definition: meta.h:490
ecs_meta_type_op_t * ops
The type operations (see ecs_meta_type_op_t)
Definition: meta.h:480
int32_t op_count
Number of operations in ops array to process.
Definition: meta.h:481
ecs_entity_t type
The type being iterated.
Definition: meta.h:479
bool is_collection
Is the scope iterating elements?
Definition: meta.h:491
ecs_size_t size
Size of type of operation.
Definition: meta.h:463
ecs_size_t offset
Offset of current field.
Definition: meta.h:459
const char * name
Name of value (only used for struct members)
Definition: meta.h:461
ecs_hashmap_t * members
string -> member index (structs only)
Definition: meta.h:466
int32_t op_count
Number of operations until next field or end.
Definition: meta.h:462
Used with ecs_opaque_init.
Definition: meta.h:763
Used with ecs_primitive_init.
Definition: meta.h:686
ecs_entity_t entity
Existing entity to use for type (optional)
Definition: meta.h:687
Serializer interface.
Definition: meta.h:263
int(* value)(const struct ecs_serializer_t *ser, ecs_entity_t type, const void *value)
Pointer to the value to serialize.
Definition: meta.h:265
int(* member)(const struct ecs_serializer_t *ser, const char *member)
Member name.
Definition: meta.h:271
Used with ecs_struct_init.
Definition: meta.h:751
ecs_entity_t entity
Existing entity to use for type (optional)
Definition: meta.h:752
Used with ecs_unit_init.
Definition: meta.h:792
ecs_entity_t base
Base unit, e.g.
Definition: meta.h:803
ecs_entity_t over
Over unit, e.g.
Definition: meta.h:806
const char * symbol
Unit symbol, e.g.
Definition: meta.h:797
ecs_entity_t prefix
Prefix indicating order of magnitude relative to the derived unit.
Definition: meta.h:817
ecs_entity_t quantity
Unit quantity, e.g.
Definition: meta.h:800
ecs_unit_translation_t translation
Translation to apply to derived unit (optional)
Definition: meta.h:809
ecs_entity_t entity
Existing entity to associate with unit (optional)
Definition: meta.h:794
Used with ecs_unit_prefix_init.
Definition: meta.h:827
ecs_entity_t entity
Existing entity to associate with unit prefix (optional)
Definition: meta.h:829
const char * symbol
Unit symbol, e.g.
Definition: meta.h:832
ecs_unit_translation_t translation
Translation to apply to derived unit (optional)
Definition: meta.h:835
int32_t power
Power to apply to factor (e.g.
Definition: meta.h:404
int32_t factor
Factor to apply (e.g.
Definition: meta.h:403
Used with ecs_vector_init.
Definition: meta.h:738
ecs_entity_t entity
Existing entity to use for type (optional)
Definition: meta.h:739