diff --git a/flecs.c b/flecs.c index 35539d0efa..253bc13313 100644 --- a/flecs.c +++ b/flecs.c @@ -30812,6 +30812,8 @@ void UpdateWorldSummary(ecs_iter_t *it) { summary[i].merge_time_total = (double)info->merge_time_total; summary[i].frame_count ++; + + summary[i].build_info = *ecs_get_build_info(); } } @@ -31092,6 +31094,7 @@ void FlecsMonitorImport( ECS_COMPONENT_DEFINE(world, EcsWorldSummary); #if defined(FLECS_META) && defined(FLECS_UNITS) + ecs_entity_t build_info = ecs_lookup(world, "flecs.core.build_info_t"); ecs_struct(world, { .entity = ecs_id(EcsWorldSummary), .members = { @@ -31102,7 +31105,8 @@ void FlecsMonitorImport( { .name = "frame_time_last", .type = ecs_id(ecs_f64_t), .unit = EcsSeconds }, { .name = "system_time_last", .type = ecs_id(ecs_f64_t), .unit = EcsSeconds }, { .name = "merge_time_last", .type = ecs_id(ecs_f64_t), .unit = EcsSeconds }, - { .name = "frame_count", .type = ecs_id(ecs_u64_t) } + { .name = "frame_count", .type = ecs_id(ecs_u64_t) }, + { .name = "build_info", .type = build_info } } }); #endif @@ -58343,6 +58347,28 @@ double ecs_meta_ptr_to_float( #ifdef FLECS_META +/* Opaque type serializatior addon vector */ +static +int flecs_addon_vec_serialize(const ecs_serializer_t *ser, const void *ptr) { + char ***data = ECS_CONST_CAST(char***, ptr); + char **addons = data[0]; + do { + ser->value(ser, ecs_id(ecs_string_t), addons); + } while((++ addons)[0]); + return 0; +} + +static +size_t flecs_addon_vec_count(const void *ptr) { + int32_t count = 0; + char ***data = ECS_CONST_CAST(char***, ptr); + char **addons = data[0]; + do { + ++ count; + } while(addons[count]); + return flecs_ito(size_t, count); +} + /* Initialize reflection data for core components */ static void flecs_meta_import_core_definitions( @@ -58356,6 +58382,26 @@ void flecs_meta_import_core_definitions( } }); + ecs_entity_t string_vec = ecs_vector(world, { + .entity = ecs_entity(world, { .name = "flecs.core.string_vec_t "}), + .type = ecs_id(ecs_string_t) + }); + + ecs_entity_t addon_vec = ecs_opaque(world, { + .entity = ecs_component(world, { + .type = { + .name = "flecs.core.addon_vec_t", + .size = ECS_SIZEOF(char**), + .alignment = ECS_ALIGNOF(char**) + } + }), + .type = { + .as_type = string_vec, + .serialize = flecs_addon_vec_serialize, + .count = flecs_addon_vec_count, + } + }); + ecs_struct(world, { .entity = ecs_entity(world, { .name = "flecs.core.build_info_t", @@ -58363,7 +58409,7 @@ void flecs_meta_import_core_definitions( }), .members = { { .name = "compiler", .type = ecs_id(ecs_string_t) }, - { .name = "addons", .type = ecs_id(ecs_string_t) }, + { .name = "addons", .type = addon_vec }, { .name = "version", .type = ecs_id(ecs_string_t) }, { .name = "version_major", .type = ecs_id(ecs_i16_t) }, { .name = "version_minor", .type = ecs_id(ecs_i16_t) }, @@ -58379,12 +58425,15 @@ static void flecs_meta_import_doc_definitions( ecs_world_t *world) { + (void)world; +#ifdef FLECS_DOC ecs_struct(world, { .entity = ecs_id(EcsDocDescription), .members = { { .name = "value", .type = ecs_id(ecs_string_t) } } }); +#endif } /* Initialize reflection data for meta components */ diff --git a/flecs.h b/flecs.h index 62b10a7f17..05a80f40f5 100644 --- a/flecs.h +++ b/flecs.h @@ -35,9 +35,9 @@ #define FLECS_VERSION_MAJOR 3 #define FLECS_VERSION_MINOR 2 #define FLECS_VERSION_PATCH 12 -#define FLECS_VERSION__(major, minor, patch) #major "." #minor "." #patch -#define FLECS_VERSION_(major, minor, patch) FLECS_VERSION__(major, minor, patch) -#define FLECS_VERSION FLECS_VERSION_(FLECS_VERSION_MAJOR, FLECS_VERSION_MINOR, FLECS_VERSION_PATCH) +#define FLECS___VERSION(major, minor, patch) #major "." #minor "." #patch +#define FLECS__VERSION(major, minor, patch) FLECS___VERSION(major, minor, patch) +#define FLECS_VERSION FLECS__VERSION(FLECS_VERSION_MAJOR, FLECS_VERSION_MINOR, FLECS_VERSION_PATCH) /** @def FLECS_CONFIG_HEADER * Allows for including a user-customizable header that specifies compile-time @@ -12497,6 +12497,9 @@ typedef struct { /* Frame count */ int64_t frame_count; /**< Number of frames processed */ + + /* Build info */ + ecs_build_info_t build_info; /**< Build info */ } EcsWorldSummary; /* Module import */ diff --git a/include/flecs.h b/include/flecs.h index 7b10faa41a..3035453a45 100644 --- a/include/flecs.h +++ b/include/flecs.h @@ -33,9 +33,9 @@ #define FLECS_VERSION_MAJOR 3 #define FLECS_VERSION_MINOR 2 #define FLECS_VERSION_PATCH 12 -#define FLECS_VERSION__(major, minor, patch) #major "." #minor "." #patch -#define FLECS_VERSION_(major, minor, patch) FLECS_VERSION__(major, minor, patch) -#define FLECS_VERSION FLECS_VERSION_(FLECS_VERSION_MAJOR, FLECS_VERSION_MINOR, FLECS_VERSION_PATCH) +#define FLECS___VERSION(major, minor, patch) #major "." #minor "." #patch +#define FLECS__VERSION(major, minor, patch) FLECS___VERSION(major, minor, patch) +#define FLECS_VERSION FLECS__VERSION(FLECS_VERSION_MAJOR, FLECS_VERSION_MINOR, FLECS_VERSION_PATCH) /** @def FLECS_CONFIG_HEADER * Allows for including a user-customizable header that specifies compile-time diff --git a/include/flecs/addons/monitor.h b/include/flecs/addons/monitor.h index 247c6dc6df..473d083d20 100644 --- a/include/flecs/addons/monitor.h +++ b/include/flecs/addons/monitor.h @@ -73,6 +73,9 @@ typedef struct { /* Frame count */ int64_t frame_count; /**< Number of frames processed */ + + /* Build info */ + ecs_build_info_t build_info; /**< Build info */ } EcsWorldSummary; /* Module import */ diff --git a/meson.build b/meson.build index 1a406a3670..c57bc27f71 100644 --- a/meson.build +++ b/meson.build @@ -20,7 +20,6 @@ endif flecs_src = files( 'src/addons/alerts.c', - 'src/addons/coredoc.c', 'src/addons/doc.c', 'src/addons/expr/deserialize.c', 'src/addons/expr/serialize.c', diff --git a/src/addons/meta/definitions.c b/src/addons/meta/definitions.c index 0f7cdb7562..34c6abfaa1 100644 --- a/src/addons/meta/definitions.c +++ b/src/addons/meta/definitions.c @@ -8,6 +8,28 @@ #ifdef FLECS_META +/* Opaque type serializatior addon vector */ +static +int flecs_addon_vec_serialize(const ecs_serializer_t *ser, const void *ptr) { + char ***data = ECS_CONST_CAST(char***, ptr); + char **addons = data[0]; + do { + ser->value(ser, ecs_id(ecs_string_t), addons); + } while((++ addons)[0]); + return 0; +} + +static +size_t flecs_addon_vec_count(const void *ptr) { + int32_t count = 0; + char ***data = ECS_CONST_CAST(char***, ptr); + char **addons = data[0]; + do { + ++ count; + } while(addons[count]); + return flecs_ito(size_t, count); +} + /* Initialize reflection data for core components */ static void flecs_meta_import_core_definitions( @@ -21,6 +43,26 @@ void flecs_meta_import_core_definitions( } }); + ecs_entity_t string_vec = ecs_vector(world, { + .entity = ecs_entity(world, { .name = "flecs.core.string_vec_t "}), + .type = ecs_id(ecs_string_t) + }); + + ecs_entity_t addon_vec = ecs_opaque(world, { + .entity = ecs_component(world, { + .type = { + .name = "flecs.core.addon_vec_t", + .size = ECS_SIZEOF(char**), + .alignment = ECS_ALIGNOF(char**) + } + }), + .type = { + .as_type = string_vec, + .serialize = flecs_addon_vec_serialize, + .count = flecs_addon_vec_count, + } + }); + ecs_struct(world, { .entity = ecs_entity(world, { .name = "flecs.core.build_info_t", @@ -28,7 +70,7 @@ void flecs_meta_import_core_definitions( }), .members = { { .name = "compiler", .type = ecs_id(ecs_string_t) }, - { .name = "addons", .type = ecs_id(ecs_string_t) }, + { .name = "addons", .type = addon_vec }, { .name = "version", .type = ecs_id(ecs_string_t) }, { .name = "version_major", .type = ecs_id(ecs_i16_t) }, { .name = "version_minor", .type = ecs_id(ecs_i16_t) }, @@ -44,12 +86,15 @@ static void flecs_meta_import_doc_definitions( ecs_world_t *world) { + (void)world; +#ifdef FLECS_DOC ecs_struct(world, { .entity = ecs_id(EcsDocDescription), .members = { { .name = "value", .type = ecs_id(ecs_string_t) } } }); +#endif } /* Initialize reflection data for meta components */ diff --git a/src/addons/monitor.c b/src/addons/monitor.c index 003c372cfb..e1a150bd46 100644 --- a/src/addons/monitor.c +++ b/src/addons/monitor.c @@ -59,6 +59,8 @@ void UpdateWorldSummary(ecs_iter_t *it) { summary[i].merge_time_total = (double)info->merge_time_total; summary[i].frame_count ++; + + summary[i].build_info = *ecs_get_build_info(); } } @@ -339,6 +341,7 @@ void FlecsMonitorImport( ECS_COMPONENT_DEFINE(world, EcsWorldSummary); #if defined(FLECS_META) && defined(FLECS_UNITS) + ecs_entity_t build_info = ecs_lookup(world, "flecs.core.build_info_t"); ecs_struct(world, { .entity = ecs_id(EcsWorldSummary), .members = { @@ -349,7 +352,8 @@ void FlecsMonitorImport( { .name = "frame_time_last", .type = ecs_id(ecs_f64_t), .unit = EcsSeconds }, { .name = "system_time_last", .type = ecs_id(ecs_f64_t), .unit = EcsSeconds }, { .name = "merge_time_last", .type = ecs_id(ecs_f64_t), .unit = EcsSeconds }, - { .name = "frame_count", .type = ecs_id(ecs_u64_t) } + { .name = "frame_count", .type = ecs_id(ecs_u64_t) }, + { .name = "build_info", .type = build_info } } }); #endif diff --git a/test/meta/src/SerializeEntityToJson.c b/test/meta/src/SerializeEntityToJson.c index ae45476d07..c940859679 100644 --- a/test/meta/src/SerializeEntityToJson.c +++ b/test/meta/src/SerializeEntityToJson.c @@ -1104,13 +1104,13 @@ void SerializeEntityToJson_serialize_w_2_alerts(void) { "\"path\":\"e1\", " "\"ids\":[[\"Position\"]], " "\"alerts\":[{" - "\"alert\":\"position_without_velocity.e1_alert_1\", " - "\"message\":\"e1 has Position but not Velocity\", " - "\"severity\":\"Error\"" - "}, {" "\"alert\":\"position_without_mass.e1_alert_2\", " "\"message\":\"e1 has Position but not Mass\", " "\"severity\":\"Error\"" + "}, {" + "\"alert\":\"position_without_velocity.e1_alert_1\", " + "\"message\":\"e1 has Position but not Velocity\", " + "\"severity\":\"Error\"" "}]" "}"); ecs_os_free(json);