@@ -19098,9 +19098,11 @@ void ecs_cpp_enum_init(
1909819098{
1909919099 ecs_suspend_readonly_state_t readonly_state;
1910019100 world = flecs_suspend_readonly(world, &readonly_state);
19101- ecs_add_id(world, id, EcsExclusive);
19102- ecs_add_id(world, id, EcsOneOf);
19103- ecs_add_id(world, id, EcsTag);
19101+
19102+ #ifdef FLECS_META
19103+ ecs_set(world, id, EcsEnum, {0});
19104+ #endif
19105+
1910419106 flecs_resume_readonly(world, &readonly_state);
1910519107}
1910619108
@@ -19138,7 +19140,10 @@ ecs_entity_t ecs_cpp_enum_constant_register(
1913819140 "enum component must have 32bit size");
1913919141 #endif
1914019142
19141- ecs_set_id(world, id, parent, sizeof(int), &value);
19143+ #ifdef FLECS_META
19144+ ecs_set_id(world, id, ecs_pair(EcsConstant, ecs_id(ecs_i32_t)),
19145+ sizeof(ecs_i32_t), &value);
19146+ #endif
1914219147
1914319148 flecs_resume_readonly(world, &readonly_state);
1914419149
@@ -23894,9 +23899,24 @@ static ECS_MOVE(EcsUnitPrefix, dst, src, {
2389423899
2389523900static ECS_DTOR(EcsUnitPrefix, ptr, { dtor_unit_prefix(ptr); })
2389623901
23897-
2389823902/* Type initialization */
2389923903
23904+ static
23905+ const char* flecs_type_kind_str(
23906+ ecs_type_kind_t kind)
23907+ {
23908+ switch(kind) {
23909+ case EcsPrimitiveType: return "Primitive";
23910+ case EcsBitmaskType: return "Bitmask";
23911+ case EcsEnumType: return "Enum";
23912+ case EcsStructType: return "Struct";
23913+ case EcsArrayType: return "Array";
23914+ case EcsVectorType: return "Vector";
23915+ case EcsOpaqueType: return "Opaque";
23916+ default: return "unknown";
23917+ }
23918+ }
23919+
2390023920static
2390123921int flecs_init_type(
2390223922 ecs_world_t *world,
@@ -23920,8 +23940,10 @@ int flecs_init_type(
2392023940 }
2392123941 } else {
2392223942 if (meta_type->kind != kind) {
23923- ecs_err("type '%s' reregistered with different kind",
23924- ecs_get_name(world, type));
23943+ ecs_err("type '%s' reregistered as '%s' (was '%s')",
23944+ ecs_get_name(world, type),
23945+ flecs_type_kind_str(kind),
23946+ flecs_type_kind_str(meta_type->kind));
2392523947 return -1;
2392623948 }
2392723949 }
@@ -24239,6 +24261,9 @@ int flecs_add_constant_to_enum(
2423924261 ecs_assert(cptr != NULL, ECS_INTERNAL_ERROR, NULL);
2424024262 cptr[0] = value;
2424124263
24264+ cptr = ecs_get_mut_id(world, e, type);
24265+ cptr[0] = value;
24266+
2424224267 return 0;
2424324268}
2424424269
@@ -24305,6 +24330,9 @@ int flecs_add_constant_to_bitmask(
2430524330 ecs_assert(cptr != NULL, ECS_INTERNAL_ERROR, NULL);
2430624331 cptr[0] = value;
2430724332
24333+ cptr = ecs_get_mut_id(world, e, type);
24334+ cptr[0] = value;
24335+
2430824336 return 0;
2430924337}
2431024338
@@ -24687,10 +24715,14 @@ void ecs_meta_type_init_default_ctor(ecs_iter_t *it) {
2468724715 * contain uninitialized memory, which could cause serializers to crash
2468824716 * when for example inspecting string fields. */
2468924717 if (!type->existing) {
24690- ecs_set_hooks_id(world, it->entities[i],
24691- &(ecs_type_hooks_t){
24692- .ctor = ecs_default_ctor
24693- });
24718+ ecs_entity_t e = it->entities[i];
24719+ const ecs_type_info_t *ti = ecs_get_type_info(world, e);
24720+ if (!ti || !ti->hooks.ctor) {
24721+ ecs_set_hooks_id(world, e,
24722+ &(ecs_type_hooks_t){
24723+ .ctor = ecs_default_ctor
24724+ });
24725+ }
2469424726 }
2469524727 }
2469624728}
0 commit comments