From bc933e6dae367c8e7993673dfc8d49990b4dd3bc Mon Sep 17 00:00:00 2001 From: Sander Mertens Date: Tue, 12 Mar 2024 22:54:19 -0700 Subject: [PATCH] Remove COREDOC addon, move logic to meta/doc addons --- .github/workflows/ci.yml | 5 - docs/Quickstart.md | 1 - docs/cfg/Doxyfile | 1 - flecs.c | 645 ++++++++++++++++++--------------- flecs.h | 62 +--- include/flecs.h | 4 +- include/flecs/addons/coredoc.h | 48 --- include/flecs/private/addons.h | 10 - meson.build | 1 + src/addons/coredoc.c | 153 -------- src/addons/doc.c | 102 +++++- src/addons/meta/definitions.c | 230 ++++++++++++ src/addons/meta/meta.c | 132 +------ src/addons/meta/meta.h | 3 + src/addons/monitor.c | 4 +- src/addons/pipeline/pipeline.c | 2 +- src/addons/plecs.c | 2 +- src/addons/rest.c | 2 +- src/addons/system/system.c | 2 +- src/addons/timer.c | 2 +- src/addons/units.c | 2 +- src/world.c | 9 +- 22 files changed, 699 insertions(+), 723 deletions(-) delete mode 100644 include/flecs/addons/coredoc.h delete mode 100644 src/addons/coredoc.c create mode 100644 src/addons/meta/definitions.c diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f889cafeb2..2be5858270 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -384,11 +384,6 @@ jobs: bake rebuild --strict -D FLECS_CUSTOM_BUILD -D FLECS_DOC bake rebuild --strict --cfg release -D FLECS_CUSTOM_BUILD -D FLECS_DOC - - name: FLECS_COREDOC - run: | - bake rebuild --strict -D FLECS_CUSTOM_BUILD -D FLECS_COREDOC - bake rebuild --strict --cfg release -D FLECS_CUSTOM_BUILD -D FLECS_COREDOC - - name: FLECS_LOG run: | bake rebuild --strict -D FLECS_CUSTOM_BUILD -D FLECS_LOG diff --git a/docs/Quickstart.md b/docs/Quickstart.md index 215fe6a0a7..81175056bd 100644 --- a/docs/Quickstart.md +++ b/docs/Quickstart.md @@ -119,7 +119,6 @@ Addon | Description | Define [Expr](/flecs/group__c__addons__expr.html) | String format optimized for ECS data | FLECS_EXPR | [JSON](/flecs/group__c__addons__json.html) | JSON format | FLECS_JSON | [Doc](/flecs/group__c__addons__doc.html) | Add documentation to components, systems & more | FLECS_DOC | -[Coredoc](/flecs/group__c__addons__coredoc.html) | Documentation for builtin components & modules | FLECS_COREDOC | [Http](/flecs/group__c__addons__http.html) | Tiny HTTP server for processing simple requests | FLECS_HTTP | [Rest](/flecs/group__c__addons__rest.html) | REST API for showing entities in the browser | FLECS_REST | [Parser](/flecs/group__c__addons__parser.html) | Create entities & queries from strings | FLECS_PARSER | diff --git a/docs/cfg/Doxyfile b/docs/cfg/Doxyfile index 2f831d25ea..f7c2f8de22 100644 --- a/docs/cfg/Doxyfile +++ b/docs/cfg/Doxyfile @@ -2427,7 +2427,6 @@ INCLUDE_FILE_PATTERNS = # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. PREDEFINED = FLECS_APP \ - FLECS_COREDOC \ FLECS_DOC \ FLECS_EXPR \ FLECS_HTTP \ diff --git a/flecs.c b/flecs.c index db6627e8cd..35539d0efa 100644 --- a/flecs.c +++ b/flecs.c @@ -22528,6 +22528,7 @@ static ecs_entity_t ecs_default_lookup_path[2] = { 0, 0 }; /* Declarations for addons. Located in world.c to avoid issues during linking of * static library */ + #ifdef FLECS_ALERTS ECS_COMPONENT_DECLARE(EcsAlert); ECS_COMPONENT_DECLARE(EcsAlertInstance); @@ -23183,9 +23184,6 @@ static const char *flecs_addons_info[] = { #ifdef FLECS_DOC "FLECS_DOC", #endif -#ifdef FLECS_COREDOC - "FLECS_COREDOC", -#endif #ifdef FLECS_LOG "FLECS_LOG", #endif @@ -23230,6 +23228,8 @@ void flecs_log_build_info(void) { const ecs_build_info_t *bi = ecs_get_build_info(); ecs_assert(bi != NULL, ECS_INTERNAL_ERROR, NULL); + ecs_trace("flecs version %s", bi->version); + ecs_trace("addons included in build:"); ecs_log_push(); @@ -23377,9 +23377,6 @@ ecs_world_t *ecs_init(void) { #ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); #endif -#ifdef FLECS_COREDOC - ECS_IMPORT(world, FlecsCoreDoc); -#endif #ifdef FLECS_SCRIPT ECS_IMPORT(world, FlecsScript); #endif @@ -25525,159 +25522,6 @@ int ecs_app_set_frame_action( #endif -/** - * @file addons/coredoc.c - * @brief Core doc addon. - */ - - -#ifdef FLECS_COREDOC - -#define URL_ROOT "https://www.flecs.dev/flecs/md_docs_2Relationships.html" - -void FlecsCoreDocImport( - ecs_world_t *world) -{ - ECS_MODULE(world, FlecsCoreDoc); - - ECS_IMPORT(world, FlecsMeta); - ECS_IMPORT(world, FlecsDoc); - - ecs_set_name_prefix(world, "Ecs"); - - /* Initialize reflection data for core components */ - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsComponent), - .members = { - {.name = "size", .type = ecs_id(ecs_i32_t)}, - {.name = "alignment", .type = ecs_id(ecs_i32_t)} - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsDocDescription), - .members = { - {.name = "value", .type = ecs_id(ecs_string_t)} - } - }); - - /* Initialize documentation data for core components */ - ecs_doc_set_brief(world, EcsFlecs, "Flecs root module"); - ecs_doc_set_link(world, EcsFlecs, "https://github.com/SanderMertens/flecs"); - ecs_doc_set_brief(world, EcsFlecsCore, "Module with builtin components"); - ecs_doc_set_brief(world, EcsFlecsInternals, "Module with internal entities"); - - ecs_doc_set_brief(world, EcsWorld, "Entity associated with world"); - - ecs_doc_set_brief(world, ecs_id(EcsComponent), "Component that is added to components"); - ecs_doc_set_brief(world, EcsModule, "Tag that is added to modules"); - ecs_doc_set_brief(world, EcsPrefab, "Tag that is added to prefabs"); - ecs_doc_set_brief(world, EcsDisabled, "Tag that is added to disabled entities"); - ecs_doc_set_brief(world, EcsPrivate, "Tag that is added to private components"); - ecs_doc_set_brief(world, EcsFlag, "Internal tag for tracking ids with special id flags"); - ecs_doc_set_brief(world, ecs_id(EcsIterable), "Internal component to make (query) entities iterable"); - ecs_doc_set_brief(world, ecs_id(EcsPoly), "Internal component that stores pointer to poly objects"); - - ecs_doc_set_brief(world, ecs_id(EcsTarget), "Internal component that stores information for flattened trees"); - ecs_doc_set_brief(world, EcsFlatten, "Tag that when added to assembly automatically flattens tree"); - - ecs_doc_set_brief(world, ecs_id(EcsIdentifier), "Component used for entity names"); - ecs_doc_set_brief(world, EcsName, "Tag used with EcsIdentifier to store entity name"); - ecs_doc_set_brief(world, EcsSymbol, "Tag used with EcsIdentifier to store entity symbol"); - ecs_doc_set_brief(world, EcsAlias, "Tag used with EcsIdentifier to store entity alias"); - - ecs_doc_set_brief(world, EcsQuery, "Tag added to query entities"); - ecs_doc_set_brief(world, EcsObserver, "Tag added to observer entities"); - - ecs_doc_set_brief(world, EcsTransitive, "Trait that enables transitive evaluation of relationships"); - ecs_doc_set_brief(world, EcsReflexive, "Trait that enables reflexive evaluation of relationships"); - ecs_doc_set_brief(world, EcsFinal, "Trait that indicates an entity cannot be inherited from"); - ecs_doc_set_brief(world, EcsDontInherit, "Trait that indicates it should not be inherited"); - ecs_doc_set_brief(world, EcsTag, "Trait that ensures a pair cannot contain a value"); - ecs_doc_set_brief(world, EcsAcyclic, "Trait that indicates a relationship is acyclic"); - ecs_doc_set_brief(world, EcsTraversable, "Trait that indicates a relationship is traversable"); - ecs_doc_set_brief(world, EcsExclusive, "Trait that ensures a relationship can only have one target"); - ecs_doc_set_brief(world, EcsSymmetric, "Trait that causes a relationship to be two-way"); - ecs_doc_set_brief(world, EcsWith, "Trait for adding additional components when a component is added"); - ecs_doc_set_brief(world, EcsAlwaysOverride, "Trait that indicates a component should always be overridden"); - ecs_doc_set_brief(world, EcsUnion, "Trait for creating a non-fragmenting relationship"); - ecs_doc_set_brief(world, EcsOneOf, "Trait that enforces target of relationship is a child of "); - ecs_doc_set_brief(world, EcsOnDelete, "Cleanup trait for specifying what happens when component is deleted"); - ecs_doc_set_brief(world, EcsOnDeleteTarget, "Cleanup trait for specifying what happens when pair target is deleted"); - ecs_doc_set_brief(world, EcsRemove, "Cleanup action used with OnDelete/OnDeleteTarget"); - ecs_doc_set_brief(world, EcsDelete, "Cleanup action used with OnDelete/OnDeleteTarget"); - ecs_doc_set_brief(world, EcsPanic, "Cleanup action used with OnDelete/OnDeleteTarget"); - ecs_doc_set_brief(world, EcsDefaultChildComponent, "Sets default component hint for children of entity"); - ecs_doc_set_brief(world, EcsIsA, "Relationship used for expressing inheritance"); - ecs_doc_set_brief(world, EcsChildOf, "Relationship used for expressing hierarchies"); - ecs_doc_set_brief(world, EcsDependsOn, "Relationship used for expressing dependencies"); - ecs_doc_set_brief(world, EcsSlotOf, "Relationship used for expressing prefab slots"); - ecs_doc_set_brief(world, EcsOnAdd, "Event emitted when component is added"); - ecs_doc_set_brief(world, EcsOnRemove, "Event emitted when component is removed"); - ecs_doc_set_brief(world, EcsOnSet, "Event emitted when component is set"); - ecs_doc_set_brief(world, EcsUnSet, "Event emitted when component is unset"); - ecs_doc_set_brief(world, EcsMonitor, "Marker used to create monitor observers"); - ecs_doc_set_brief(world, EcsOnTableFill, "Event emitted when table becomes non-empty"); - ecs_doc_set_brief(world, EcsOnTableEmpty, "Event emitted when table becomes empty"); - ecs_doc_set_brief(world, EcsOnTableCreate, "Event emitted when table is created"); - ecs_doc_set_brief(world, EcsOnTableDelete, "Event emitted when table is deleted"); - - ecs_doc_set_brief(world, EcsThis, "Query marker to express $this variable"); - ecs_doc_set_brief(world, EcsWildcard, "Query marker to express match all wildcard"); - ecs_doc_set_brief(world, EcsAny, "Query marker to express match at least one wildcard"); - - ecs_doc_set_brief(world, EcsPredEq, "Query marker to express == operator"); - ecs_doc_set_brief(world, EcsPredMatch, "Query marker to express ~= operator"); - ecs_doc_set_brief(world, EcsPredLookup, "Query marker to express by-name lookup"); - ecs_doc_set_brief(world, EcsScopeOpen, "Query marker to express scope open"); - ecs_doc_set_brief(world, EcsScopeClose, "Query marker to express scope close"); - ecs_doc_set_brief(world, EcsEmpty, "Tag used to indicate a query has no results"); - - /* Initialize documentation for meta components */ - ecs_entity_t meta = ecs_lookup(world, "flecs.meta"); - ecs_doc_set_brief(world, meta, "Flecs module with reflection components"); - - ecs_doc_set_brief(world, ecs_id(EcsMetaType), "Component added to types"); - ecs_doc_set_brief(world, ecs_id(EcsMetaTypeSerialized), "Component that stores reflection data in an optimized format"); - ecs_doc_set_brief(world, ecs_id(EcsPrimitive), "Component added to primitive types"); - ecs_doc_set_brief(world, ecs_id(EcsEnum), "Component added to enumeration types"); - ecs_doc_set_brief(world, ecs_id(EcsBitmask), "Component added to bitmask types"); - ecs_doc_set_brief(world, ecs_id(EcsMember), "Component added to struct members"); - ecs_doc_set_brief(world, ecs_id(EcsStruct), "Component added to struct types"); - ecs_doc_set_brief(world, ecs_id(EcsArray), "Component added to array types"); - ecs_doc_set_brief(world, ecs_id(EcsVector), "Component added to vector types"); - - ecs_doc_set_brief(world, ecs_id(ecs_bool_t), "bool component"); - ecs_doc_set_brief(world, ecs_id(ecs_char_t), "char component"); - ecs_doc_set_brief(world, ecs_id(ecs_byte_t), "byte component"); - ecs_doc_set_brief(world, ecs_id(ecs_u8_t), "8 bit unsigned int component"); - ecs_doc_set_brief(world, ecs_id(ecs_u16_t), "16 bit unsigned int component"); - ecs_doc_set_brief(world, ecs_id(ecs_u32_t), "32 bit unsigned int component"); - ecs_doc_set_brief(world, ecs_id(ecs_u64_t), "64 bit unsigned int component"); - ecs_doc_set_brief(world, ecs_id(ecs_uptr_t), "word sized unsigned int component"); - ecs_doc_set_brief(world, ecs_id(ecs_i8_t), "8 bit signed int component"); - ecs_doc_set_brief(world, ecs_id(ecs_i16_t), "16 bit signed int component"); - ecs_doc_set_brief(world, ecs_id(ecs_i32_t), "32 bit signed int component"); - ecs_doc_set_brief(world, ecs_id(ecs_i64_t), "64 bit signed int component"); - ecs_doc_set_brief(world, ecs_id(ecs_iptr_t), "word sized signed int component"); - ecs_doc_set_brief(world, ecs_id(ecs_f32_t), "32 bit floating point component"); - ecs_doc_set_brief(world, ecs_id(ecs_f64_t), "64 bit floating point component"); - ecs_doc_set_brief(world, ecs_id(ecs_string_t), "string component"); - ecs_doc_set_brief(world, ecs_id(ecs_entity_t), "entity component"); - - /* Initialize documentation for doc components */ - ecs_entity_t doc = ecs_lookup(world, "flecs.doc"); - ecs_doc_set_brief(world, doc, "Flecs module with documentation components"); - - ecs_doc_set_brief(world, ecs_id(EcsDocDescription), "Component used to add documentation"); - ecs_doc_set_brief(world, EcsDocBrief, "Used as (Description, Brief) to add a brief description"); - ecs_doc_set_brief(world, EcsDocDetail, "Used as (Description, Detail) to add a detailed description"); - ecs_doc_set_brief(world, EcsDocLink, "Used as (Description, Link) to add a link"); -} - -#endif - /** * @file addons/doc.c * @brief Doc addon. @@ -25823,6 +25667,102 @@ const char* ecs_doc_get_color( } } +/* Doc definitions for core components */ +static +void flecs_doc_import_core_definitions( + ecs_world_t *world) +{ + ecs_doc_set_brief(world, EcsFlecs, "Flecs root module"); + ecs_doc_set_link(world, EcsFlecs, "https://github.com/SanderMertens/flecs"); + ecs_doc_set_brief(world, EcsFlecsCore, "Module with builtin components"); + ecs_doc_set_brief(world, EcsFlecsInternals, "Module with internal entities"); + + ecs_doc_set_brief(world, EcsWorld, "Entity associated with world"); + + ecs_doc_set_brief(world, ecs_id(EcsComponent), "Component that is added to components"); + ecs_doc_set_brief(world, EcsModule, "Tag that is added to modules"); + ecs_doc_set_brief(world, EcsPrefab, "Tag that is added to prefabs"); + ecs_doc_set_brief(world, EcsDisabled, "Tag that is added to disabled entities"); + ecs_doc_set_brief(world, EcsPrivate, "Tag that is added to private components"); + ecs_doc_set_brief(world, EcsFlag, "Internal tag for tracking ids with special id flags"); + ecs_doc_set_brief(world, ecs_id(EcsIterable), "Internal component to make (query) entities iterable"); + ecs_doc_set_brief(world, ecs_id(EcsPoly), "Internal component that stores pointer to poly objects"); + + ecs_doc_set_brief(world, ecs_id(EcsTarget), "Internal component that stores information for flattened trees"); + ecs_doc_set_brief(world, EcsFlatten, "Tag that when added to assembly automatically flattens tree"); + + ecs_doc_set_brief(world, ecs_id(EcsIdentifier), "Component used for entity names"); + ecs_doc_set_brief(world, EcsName, "Tag used with EcsIdentifier to store entity name"); + ecs_doc_set_brief(world, EcsSymbol, "Tag used with EcsIdentifier to store entity symbol"); + ecs_doc_set_brief(world, EcsAlias, "Tag used with EcsIdentifier to store entity alias"); + + ecs_doc_set_brief(world, EcsQuery, "Tag added to query entities"); + ecs_doc_set_brief(world, EcsObserver, "Tag added to observer entities"); + + ecs_doc_set_brief(world, EcsTransitive, "Trait that enables transitive evaluation of relationships"); + ecs_doc_set_brief(world, EcsReflexive, "Trait that enables reflexive evaluation of relationships"); + ecs_doc_set_brief(world, EcsFinal, "Trait that indicates an entity cannot be inherited from"); + ecs_doc_set_brief(world, EcsDontInherit, "Trait that indicates it should not be inherited"); + ecs_doc_set_brief(world, EcsTag, "Trait that ensures a pair cannot contain a value"); + ecs_doc_set_brief(world, EcsAcyclic, "Trait that indicates a relationship is acyclic"); + ecs_doc_set_brief(world, EcsTraversable, "Trait that indicates a relationship is traversable"); + ecs_doc_set_brief(world, EcsExclusive, "Trait that ensures a relationship can only have one target"); + ecs_doc_set_brief(world, EcsSymmetric, "Trait that causes a relationship to be two-way"); + ecs_doc_set_brief(world, EcsWith, "Trait for adding additional components when a component is added"); + ecs_doc_set_brief(world, EcsAlwaysOverride, "Trait that indicates a component should always be overridden"); + ecs_doc_set_brief(world, EcsUnion, "Trait for creating a non-fragmenting relationship"); + ecs_doc_set_brief(world, EcsOneOf, "Trait that enforces target of relationship is a child of "); + ecs_doc_set_brief(world, EcsOnDelete, "Cleanup trait for specifying what happens when component is deleted"); + ecs_doc_set_brief(world, EcsOnDeleteTarget, "Cleanup trait for specifying what happens when pair target is deleted"); + ecs_doc_set_brief(world, EcsRemove, "Cleanup action used with OnDelete/OnDeleteTarget"); + ecs_doc_set_brief(world, EcsDelete, "Cleanup action used with OnDelete/OnDeleteTarget"); + ecs_doc_set_brief(world, EcsPanic, "Cleanup action used with OnDelete/OnDeleteTarget"); + ecs_doc_set_brief(world, EcsDefaultChildComponent, "Sets default component hint for children of entity"); + ecs_doc_set_brief(world, EcsIsA, "Relationship used for expressing inheritance"); + ecs_doc_set_brief(world, EcsChildOf, "Relationship used for expressing hierarchies"); + ecs_doc_set_brief(world, EcsDependsOn, "Relationship used for expressing dependencies"); + ecs_doc_set_brief(world, EcsSlotOf, "Relationship used for expressing prefab slots"); + ecs_doc_set_brief(world, EcsOnAdd, "Event emitted when component is added"); + ecs_doc_set_brief(world, EcsOnRemove, "Event emitted when component is removed"); + ecs_doc_set_brief(world, EcsOnSet, "Event emitted when component is set"); + ecs_doc_set_brief(world, EcsUnSet, "Event emitted when component is unset"); + ecs_doc_set_brief(world, EcsMonitor, "Marker used to create monitor observers"); + ecs_doc_set_brief(world, EcsOnTableFill, "Event emitted when table becomes non-empty"); + ecs_doc_set_brief(world, EcsOnTableEmpty, "Event emitted when table becomes empty"); + ecs_doc_set_brief(world, EcsOnTableCreate, "Event emitted when table is created"); + ecs_doc_set_brief(world, EcsOnTableDelete, "Event emitted when table is deleted"); + + ecs_doc_set_brief(world, EcsThis, "Query marker to express $this variable"); + ecs_doc_set_brief(world, EcsWildcard, "Query marker to express match all wildcard"); + ecs_doc_set_brief(world, EcsAny, "Query marker to express match at least one wildcard"); + + ecs_doc_set_brief(world, EcsPredEq, "Query marker to express == operator"); + ecs_doc_set_brief(world, EcsPredMatch, "Query marker to express ~= operator"); + ecs_doc_set_brief(world, EcsPredLookup, "Query marker to express by-name lookup"); + ecs_doc_set_brief(world, EcsScopeOpen, "Query marker to express scope open"); + ecs_doc_set_brief(world, EcsScopeClose, "Query marker to express scope close"); + ecs_doc_set_brief(world, EcsEmpty, "Tag used to indicate a query has no results"); +} + +/* Doc definitions for doc components */ +static +void flecs_doc_import_doc_definitions( + ecs_world_t *world) +{ + ecs_entity_t doc = ecs_lookup(world, "flecs.doc"); + ecs_doc_set_brief(world, doc, "Flecs module with documentation components"); + + ecs_doc_set_brief(world, EcsDocBrief, "Brief description"); + ecs_doc_set_brief(world, EcsDocDetail, "Detailed description"); + ecs_doc_set_brief(world, EcsDocLink, "Link to additional documentation"); + ecs_doc_set_brief(world, EcsDocColor, "Color hint for entity"); + + ecs_doc_set_brief(world, ecs_id(EcsDocDescription), "Component used to add documentation"); + ecs_doc_set_brief(world, EcsDocBrief, "Used as (Description, Brief) to add a brief description"); + ecs_doc_set_brief(world, EcsDocDetail, "Used as (Description, Detail) to add a detailed description"); + ecs_doc_set_brief(world, EcsDocLink, "Used as (Description, Link) to add a link"); +} + void FlecsDocImport( ecs_world_t *world) { @@ -25846,10 +25786,8 @@ void FlecsDocImport( ecs_add_id(world, ecs_id(EcsDocDescription), EcsDontInherit); ecs_add_id(world, ecs_id(EcsDocDescription), EcsPrivate); - ecs_doc_set_brief(world, EcsDocBrief, "Brief description"); - ecs_doc_set_brief(world, EcsDocDetail, "Detailed description"); - ecs_doc_set_brief(world, EcsDocLink, "Link to additional documentation"); - ecs_doc_set_brief(world, EcsDocColor, "Color hint for entity"); + flecs_doc_import_core_definitions(world); + flecs_doc_import_doc_definitions(world); } #endif @@ -31137,7 +31075,7 @@ void FlecsMonitorImport( #ifdef FLECS_UNITS ECS_IMPORT(world, FlecsUnits); #endif -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsMonitor), "Module that automatically monitors statistics for the world & systems"); @@ -31153,7 +31091,7 @@ void FlecsMonitorImport( ECS_COMPONENT_DEFINE(world, EcsWorldSummary); -#if defined(FLECS_META) && defined(FLECS_UNITS) +#if defined(FLECS_META) && defined(FLECS_UNITS) ecs_struct(world, { .entity = ecs_id(EcsWorldSummary), .members = { @@ -34613,7 +34551,7 @@ void FlecsScriptImport( { ECS_MODULE(world, FlecsScript); ECS_IMPORT(world, FlecsMeta); -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsScript), "Module with components for managing Flecs scripts"); @@ -35717,7 +35655,7 @@ void FlecsRestImport( #ifdef FLECS_PLECS ECS_IMPORT(world, FlecsScript); #endif -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsRest), "Module that implements Flecs REST API"); @@ -37479,7 +37417,7 @@ void FlecsTimerImport( { ECS_MODULE(world, FlecsTimer); ECS_IMPORT(world, FlecsPipeline); -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsTimer), "Module that implements system timers (used by .interval)"); @@ -37552,7 +37490,7 @@ void FlecsUnitsImport( { ECS_MODULE(world, FlecsUnits); -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsUnits), "Module with (amongst others) SI units for annotating component members"); @@ -55876,6 +55814,9 @@ bool flecs_unit_validate( ecs_entity_t t, EcsUnit *data); +void flecs_meta_import_definitions( + ecs_world_t *world); + #endif #endif @@ -58393,6 +58334,236 @@ double ecs_meta_ptr_to_float( #endif + +/** + * @file meta/definitions.c + * @brief Reflection definitions for builtin types. + */ + + +#ifdef FLECS_META + +/* Initialize reflection data for core components */ +static +void flecs_meta_import_core_definitions( + ecs_world_t *world) +{ + ecs_struct(world, { + .entity = ecs_id(EcsComponent), + .members = { + { .name = "size", .type = ecs_id(ecs_i32_t) }, + { .name = "alignment", .type = ecs_id(ecs_i32_t) } + } + }); + + ecs_struct(world, { + .entity = ecs_entity(world, { + .name = "flecs.core.build_info_t", + .root_sep = "" + }), + .members = { + { .name = "compiler", .type = ecs_id(ecs_string_t) }, + { .name = "addons", .type = ecs_id(ecs_string_t) }, + { .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) }, + { .name = "version_patch", .type = ecs_id(ecs_i16_t) }, + { .name = "debug", .type = ecs_id(ecs_bool_t) }, + { .name = "sanitize", .type = ecs_id(ecs_bool_t) }, + } + }); +} + +/* Initialize reflection data for doc components */ +static +void flecs_meta_import_doc_definitions( + ecs_world_t *world) +{ + ecs_struct(world, { + .entity = ecs_id(EcsDocDescription), + .members = { + { .name = "value", .type = ecs_id(ecs_string_t) } + } + }); +} + +/* Initialize reflection data for meta components */ +static +void flecs_meta_import_meta_definitions( + ecs_world_t *world) +{ + ecs_entity_t type_kind = ecs_enum_init(world, &(ecs_enum_desc_t){ + .entity = ecs_entity(world, { .name = "TypeKind" }), + .constants = { + { .name = "PrimitiveType" }, + { .name = "BitmaskType" }, + { .name = "EnumType" }, + { .name = "StructType" }, + { .name = "ArrayType" }, + { .name = "VectorType" }, + { .name = "OpaqueType" } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsMetaType), + .members = { + { .name = "kind", .type = type_kind } + } + }); + + ecs_entity_t primitive_kind = ecs_enum_init(world, &(ecs_enum_desc_t){ + .entity = ecs_entity(world, { .name = "PrimitiveKind" }), + .constants = { + { .name = "Bool", 1 }, + { .name = "Char" }, + { .name = "Byte" }, + { .name = "U8" }, + { .name = "U16" }, + { .name = "U32" }, + { .name = "U64 "}, + { .name = "I8" }, + { .name = "I16" }, + { .name = "I32" }, + { .name = "I64" }, + { .name = "F32" }, + { .name = "F64" }, + { .name = "UPtr "}, + { .name = "IPtr" }, + { .name = "String" }, + { .name = "Entity" }, + { .name = "Id" } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsPrimitive), + .members = { + { .name = "kind", .type = primitive_kind } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsMember), + .members = { + { .name = "type", .type = ecs_id(ecs_entity_t) }, + { .name = "count", .type = ecs_id(ecs_i32_t) }, + { .name = "unit", .type = ecs_id(ecs_entity_t) }, + { .name = "offset", .type = ecs_id(ecs_i32_t) } + } + }); + + ecs_entity_t vr = ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_entity(world, { .name = "value_range" }), + .members = { + { .name = "min", .type = ecs_id(ecs_f64_t) }, + { .name = "max", .type = ecs_id(ecs_f64_t) } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsMemberRanges), + .members = { + { .name = "value", .type = vr }, + { .name = "warning", .type = vr }, + { .name = "error", .type = vr } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsArray), + .members = { + { .name = "type", .type = ecs_id(ecs_entity_t) }, + { .name = "count", .type = ecs_id(ecs_i32_t) }, + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsVector), + .members = { + { .name = "type", .type = ecs_id(ecs_entity_t) } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsOpaque), + .members = { + { .name = "as_type", .type = ecs_id(ecs_entity_t) } + } + }); + + ecs_entity_t ut = ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_entity(world, { .name = "unit_translation" }), + .members = { + { .name = "factor", .type = ecs_id(ecs_i32_t) }, + { .name = "power", .type = ecs_id(ecs_i32_t) } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsUnit), + .members = { + { .name = "symbol", .type = ecs_id(ecs_string_t) }, + { .name = "prefix", .type = ecs_id(ecs_entity_t) }, + { .name = "base", .type = ecs_id(ecs_entity_t) }, + { .name = "over", .type = ecs_id(ecs_entity_t) }, + { .name = "translation", .type = ut } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsUnitPrefix), + .members = { + { .name = "symbol", .type = ecs_id(ecs_string_t) }, + { .name = "translation", .type = ut } + } + }); + + /* Meta doc definitions */ +#ifdef FLECS_DOC + ecs_entity_t meta = ecs_lookup(world, "flecs.meta"); + ecs_doc_set_brief(world, meta, "Flecs module with reflection components"); + + ecs_doc_set_brief(world, ecs_id(EcsMetaType), "Component added to types"); + ecs_doc_set_brief(world, ecs_id(EcsMetaTypeSerialized), "Component that stores reflection data in an optimized format"); + ecs_doc_set_brief(world, ecs_id(EcsPrimitive), "Component added to primitive types"); + ecs_doc_set_brief(world, ecs_id(EcsEnum), "Component added to enumeration types"); + ecs_doc_set_brief(world, ecs_id(EcsBitmask), "Component added to bitmask types"); + ecs_doc_set_brief(world, ecs_id(EcsMember), "Component added to struct members"); + ecs_doc_set_brief(world, ecs_id(EcsStruct), "Component added to struct types"); + ecs_doc_set_brief(world, ecs_id(EcsArray), "Component added to array types"); + ecs_doc_set_brief(world, ecs_id(EcsVector), "Component added to vector types"); + + ecs_doc_set_brief(world, ecs_id(ecs_bool_t), "bool component"); + ecs_doc_set_brief(world, ecs_id(ecs_char_t), "char component"); + ecs_doc_set_brief(world, ecs_id(ecs_byte_t), "byte component"); + ecs_doc_set_brief(world, ecs_id(ecs_u8_t), "8 bit unsigned int component"); + ecs_doc_set_brief(world, ecs_id(ecs_u16_t), "16 bit unsigned int component"); + ecs_doc_set_brief(world, ecs_id(ecs_u32_t), "32 bit unsigned int component"); + ecs_doc_set_brief(world, ecs_id(ecs_u64_t), "64 bit unsigned int component"); + ecs_doc_set_brief(world, ecs_id(ecs_uptr_t), "word sized unsigned int component"); + ecs_doc_set_brief(world, ecs_id(ecs_i8_t), "8 bit signed int component"); + ecs_doc_set_brief(world, ecs_id(ecs_i16_t), "16 bit signed int component"); + ecs_doc_set_brief(world, ecs_id(ecs_i32_t), "32 bit signed int component"); + ecs_doc_set_brief(world, ecs_id(ecs_i64_t), "64 bit signed int component"); + ecs_doc_set_brief(world, ecs_id(ecs_iptr_t), "word sized signed int component"); + ecs_doc_set_brief(world, ecs_id(ecs_f32_t), "32 bit floating point component"); + ecs_doc_set_brief(world, ecs_id(ecs_f64_t), "64 bit floating point component"); + ecs_doc_set_brief(world, ecs_id(ecs_string_t), "string component"); + ecs_doc_set_brief(world, ecs_id(ecs_entity_t), "entity component"); +#endif +} + +void flecs_meta_import_definitions( + ecs_world_t *world) +{ + flecs_meta_import_core_definitions(world); + flecs_meta_import_doc_definitions(world); + flecs_meta_import_meta_definitions(world); +} + +#endif + /** * @file meta/meta.c * @brief Meta addon. @@ -59533,6 +59704,9 @@ void FlecsMetaImport( ecs_world_t *world) { ECS_MODULE(world, FlecsMeta); +#ifdef FLECS_DOC + ECS_IMPORT(world, FlecsDoc); +#endif ecs_set_name_prefix(world, "Ecs"); @@ -59752,133 +59926,8 @@ void FlecsMetaImport( ecs_add_id(world, EcsQuantity, EcsExclusive); ecs_add_id(world, EcsQuantity, EcsTag); - /* Initialize reflection data for meta components */ - ecs_entity_t type_kind = ecs_enum_init(world, &(ecs_enum_desc_t){ - .entity = ecs_entity(world, { .name = "TypeKind" }), - .constants = { - { .name = "PrimitiveType" }, - { .name = "BitmaskType" }, - { .name = "EnumType" }, - { .name = "StructType" }, - { .name = "ArrayType" }, - { .name = "VectorType" }, - { .name = "OpaqueType" } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsMetaType), - .members = { - { .name = "kind", .type = type_kind } - } - }); - - ecs_entity_t primitive_kind = ecs_enum_init(world, &(ecs_enum_desc_t){ - .entity = ecs_entity(world, { .name = "PrimitiveKind" }), - .constants = { - { .name = "Bool", 1 }, - { .name = "Char" }, - { .name = "Byte" }, - { .name = "U8" }, - { .name = "U16" }, - { .name = "U32" }, - { .name = "U64 "}, - { .name = "I8" }, - { .name = "I16" }, - { .name = "I32" }, - { .name = "I64" }, - { .name = "F32" }, - { .name = "F64" }, - { .name = "UPtr "}, - { .name = "IPtr" }, - { .name = "String" }, - { .name = "Entity" }, - { .name = "Id" } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsPrimitive), - .members = { - { .name = "kind", .type = primitive_kind } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsMember), - .members = { - { .name = "type", .type = ecs_id(ecs_entity_t) }, - { .name = "count", .type = ecs_id(ecs_i32_t) }, - { .name = "unit", .type = ecs_id(ecs_entity_t) }, - { .name = "offset", .type = ecs_id(ecs_i32_t) } - } - }); - - ecs_entity_t vr = ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_entity(world, { .name = "value_range" }), - .members = { - { .name = "min", .type = ecs_id(ecs_f64_t) }, - { .name = "max", .type = ecs_id(ecs_f64_t) } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsMemberRanges), - .members = { - { .name = "value", .type = vr }, - { .name = "warning", .type = vr }, - { .name = "error", .type = vr } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsArray), - .members = { - { .name = "type", .type = ecs_id(ecs_entity_t) }, - { .name = "count", .type = ecs_id(ecs_i32_t) }, - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsVector), - .members = { - { .name = "type", .type = ecs_id(ecs_entity_t) } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsOpaque), - .members = { - { .name = "as_type", .type = ecs_id(ecs_entity_t) } - } - }); - - ecs_entity_t ut = ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_entity(world, { .name = "unit_translation" }), - .members = { - { .name = "factor", .type = ecs_id(ecs_i32_t) }, - { .name = "power", .type = ecs_id(ecs_i32_t) } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsUnit), - .members = { - { .name = "symbol", .type = ecs_id(ecs_string_t) }, - { .name = "prefix", .type = ecs_id(ecs_entity_t) }, - { .name = "base", .type = ecs_id(ecs_entity_t) }, - { .name = "over", .type = ecs_id(ecs_entity_t) }, - { .name = "translation", .type = ut } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsUnitPrefix), - .members = { - { .name = "symbol", .type = ecs_id(ecs_string_t) }, - { .name = "translation", .type = ut } - } - }); + /* Import reflection definitions for builtin types */ + flecs_meta_import_definitions(world); } #endif @@ -61691,7 +61740,7 @@ void FlecsPipelineImport( { ECS_MODULE(world, FlecsPipeline); ECS_IMPORT(world, FlecsSystem); -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsPipeline), "Module that schedules and runs systems"); @@ -69160,7 +69209,7 @@ void FlecsSystemImport( ecs_world_t *world) { ECS_MODULE(world, FlecsSystem); -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsSystem), "Module that implements Flecs systems"); diff --git a/flecs.h b/flecs.h index 49d792e238..62b10a7f17 100644 --- a/flecs.h +++ b/flecs.h @@ -35,7 +35,8 @@ #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) #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 @@ -191,7 +192,6 @@ #define FLECS_EXPR /**< Parsing strings to/from component values */ #define FLECS_JSON /**< Parsing JSON to/from component values */ #define FLECS_DOC /**< Document entities & components */ -#define FLECS_COREDOC /**< Documentation for core entities & components */ #define FLECS_LOG /**< When enabled ECS provides more detailed logs */ #define FLECS_APP /**< Application addon */ #define FLECS_OS_API_IMPL /**< Default implementation for OS API */ @@ -9617,9 +9617,6 @@ int ecs_value_move_ctor( #ifdef FLECS_NO_DOC #undef FLECS_DOC #endif -#ifdef FLECS_NO_COREDOC -#undef FLECS_COREDOC -#endif #ifdef FLECS_NO_LOG #undef FLECS_LOG #endif @@ -12519,61 +12516,6 @@ void FlecsMonitorImport( #endif -#ifdef FLECS_COREDOC -#ifdef FLECS_NO_COREDOC -#error "FLECS_NO_COREDOC failed: COREDOC is required by other addons" -#endif -/** - * @file addons/coredoc.h - * @brief Core doc module. - * - * The core doc module imports documentation and reflection data for core - * components, tags and systems. - */ - -#ifdef FLECS_COREDOC - -#ifndef FLECS_DOC -#define FLECS_DOC -#endif - -#ifndef FLECS_META -#define FLECS_META -#endif - -#ifndef FLECS_COREDOC_H -#define FLECS_COREDOC_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup c_addons_coredoc Coredoc - * @ingroup c_addons - * Module that adds documentation and reflection to core entities. - * - * @{ - */ - -/* Module import */ - -FLECS_API -void FlecsCoreDocImport( - ecs_world_t *world); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif - -#endif - -#endif - #ifdef FLECS_DOC #ifdef FLECS_NO_DOC #error "FLECS_NO_DOC failed: DOC is required by other addons" diff --git a/include/flecs.h b/include/flecs.h index 8b30ea686e..7b10faa41a 100644 --- a/include/flecs.h +++ b/include/flecs.h @@ -33,7 +33,8 @@ #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) #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 @@ -189,7 +190,6 @@ #define FLECS_EXPR /**< Parsing strings to/from component values */ #define FLECS_JSON /**< Parsing JSON to/from component values */ #define FLECS_DOC /**< Document entities & components */ -#define FLECS_COREDOC /**< Documentation for core entities & components */ #define FLECS_LOG /**< When enabled ECS provides more detailed logs */ #define FLECS_APP /**< Application addon */ #define FLECS_OS_API_IMPL /**< Default implementation for OS API */ diff --git a/include/flecs/addons/coredoc.h b/include/flecs/addons/coredoc.h deleted file mode 100644 index 4130cdace3..0000000000 --- a/include/flecs/addons/coredoc.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file addons/coredoc.h - * @brief Core doc module. - * - * The core doc module imports documentation and reflection data for core - * components, tags and systems. - */ - -#ifdef FLECS_COREDOC - -#ifndef FLECS_DOC -#define FLECS_DOC -#endif - -#ifndef FLECS_META -#define FLECS_META -#endif - -#ifndef FLECS_COREDOC_H -#define FLECS_COREDOC_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup c_addons_coredoc Coredoc - * @ingroup c_addons - * Module that adds documentation and reflection to core entities. - * - * @{ - */ - -/* Module import */ - -FLECS_API -void FlecsCoreDocImport( - ecs_world_t *world); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif - -#endif diff --git a/include/flecs/private/addons.h b/include/flecs/private/addons.h index 83e594c928..7aabc20fab 100644 --- a/include/flecs/private/addons.h +++ b/include/flecs/private/addons.h @@ -60,9 +60,6 @@ #ifdef FLECS_NO_DOC #undef FLECS_DOC #endif -#ifdef FLECS_NO_COREDOC -#undef FLECS_COREDOC -#endif #ifdef FLECS_NO_LOG #undef FLECS_LOG #endif @@ -177,13 +174,6 @@ #include "../addons/monitor.h" #endif -#ifdef FLECS_COREDOC -#ifdef FLECS_NO_COREDOC -#error "FLECS_NO_COREDOC failed: COREDOC is required by other addons" -#endif -#include "../addons/coredoc.h" -#endif - #ifdef FLECS_DOC #ifdef FLECS_NO_DOC #error "FLECS_NO_DOC failed: DOC is required by other addons" diff --git a/meson.build b/meson.build index 50a9548df9..1a406a3670 100644 --- a/meson.build +++ b/meson.build @@ -38,6 +38,7 @@ flecs_src = files( 'src/addons/json/json.c', 'src/addons/log.c', 'src/addons/meta/api.c', + 'src/addons/meta/definitions.c', 'src/addons/meta/meta.c', 'src/addons/meta/serialized.c', 'src/addons/meta/cursor.c', diff --git a/src/addons/coredoc.c b/src/addons/coredoc.c deleted file mode 100644 index 9dd01c4f47..0000000000 --- a/src/addons/coredoc.c +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @file addons/coredoc.c - * @brief Core doc addon. - */ - -#include "../private_api.h" - -#ifdef FLECS_COREDOC - -#define URL_ROOT "https://www.flecs.dev/flecs/md_docs_2Relationships.html" - -void FlecsCoreDocImport( - ecs_world_t *world) -{ - ECS_MODULE(world, FlecsCoreDoc); - - ECS_IMPORT(world, FlecsMeta); - ECS_IMPORT(world, FlecsDoc); - - ecs_set_name_prefix(world, "Ecs"); - - /* Initialize reflection data for core components */ - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsComponent), - .members = { - {.name = "size", .type = ecs_id(ecs_i32_t)}, - {.name = "alignment", .type = ecs_id(ecs_i32_t)} - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsDocDescription), - .members = { - {.name = "value", .type = ecs_id(ecs_string_t)} - } - }); - - /* Initialize documentation data for core components */ - ecs_doc_set_brief(world, EcsFlecs, "Flecs root module"); - ecs_doc_set_link(world, EcsFlecs, "https://github.com/SanderMertens/flecs"); - ecs_doc_set_brief(world, EcsFlecsCore, "Module with builtin components"); - ecs_doc_set_brief(world, EcsFlecsInternals, "Module with internal entities"); - - ecs_doc_set_brief(world, EcsWorld, "Entity associated with world"); - - ecs_doc_set_brief(world, ecs_id(EcsComponent), "Component that is added to components"); - ecs_doc_set_brief(world, EcsModule, "Tag that is added to modules"); - ecs_doc_set_brief(world, EcsPrefab, "Tag that is added to prefabs"); - ecs_doc_set_brief(world, EcsDisabled, "Tag that is added to disabled entities"); - ecs_doc_set_brief(world, EcsPrivate, "Tag that is added to private components"); - ecs_doc_set_brief(world, EcsFlag, "Internal tag for tracking ids with special id flags"); - ecs_doc_set_brief(world, ecs_id(EcsIterable), "Internal component to make (query) entities iterable"); - ecs_doc_set_brief(world, ecs_id(EcsPoly), "Internal component that stores pointer to poly objects"); - - ecs_doc_set_brief(world, ecs_id(EcsTarget), "Internal component that stores information for flattened trees"); - ecs_doc_set_brief(world, EcsFlatten, "Tag that when added to assembly automatically flattens tree"); - - ecs_doc_set_brief(world, ecs_id(EcsIdentifier), "Component used for entity names"); - ecs_doc_set_brief(world, EcsName, "Tag used with EcsIdentifier to store entity name"); - ecs_doc_set_brief(world, EcsSymbol, "Tag used with EcsIdentifier to store entity symbol"); - ecs_doc_set_brief(world, EcsAlias, "Tag used with EcsIdentifier to store entity alias"); - - ecs_doc_set_brief(world, EcsQuery, "Tag added to query entities"); - ecs_doc_set_brief(world, EcsObserver, "Tag added to observer entities"); - - ecs_doc_set_brief(world, EcsTransitive, "Trait that enables transitive evaluation of relationships"); - ecs_doc_set_brief(world, EcsReflexive, "Trait that enables reflexive evaluation of relationships"); - ecs_doc_set_brief(world, EcsFinal, "Trait that indicates an entity cannot be inherited from"); - ecs_doc_set_brief(world, EcsDontInherit, "Trait that indicates it should not be inherited"); - ecs_doc_set_brief(world, EcsTag, "Trait that ensures a pair cannot contain a value"); - ecs_doc_set_brief(world, EcsAcyclic, "Trait that indicates a relationship is acyclic"); - ecs_doc_set_brief(world, EcsTraversable, "Trait that indicates a relationship is traversable"); - ecs_doc_set_brief(world, EcsExclusive, "Trait that ensures a relationship can only have one target"); - ecs_doc_set_brief(world, EcsSymmetric, "Trait that causes a relationship to be two-way"); - ecs_doc_set_brief(world, EcsWith, "Trait for adding additional components when a component is added"); - ecs_doc_set_brief(world, EcsAlwaysOverride, "Trait that indicates a component should always be overridden"); - ecs_doc_set_brief(world, EcsUnion, "Trait for creating a non-fragmenting relationship"); - ecs_doc_set_brief(world, EcsOneOf, "Trait that enforces target of relationship is a child of "); - ecs_doc_set_brief(world, EcsOnDelete, "Cleanup trait for specifying what happens when component is deleted"); - ecs_doc_set_brief(world, EcsOnDeleteTarget, "Cleanup trait for specifying what happens when pair target is deleted"); - ecs_doc_set_brief(world, EcsRemove, "Cleanup action used with OnDelete/OnDeleteTarget"); - ecs_doc_set_brief(world, EcsDelete, "Cleanup action used with OnDelete/OnDeleteTarget"); - ecs_doc_set_brief(world, EcsPanic, "Cleanup action used with OnDelete/OnDeleteTarget"); - ecs_doc_set_brief(world, EcsDefaultChildComponent, "Sets default component hint for children of entity"); - ecs_doc_set_brief(world, EcsIsA, "Relationship used for expressing inheritance"); - ecs_doc_set_brief(world, EcsChildOf, "Relationship used for expressing hierarchies"); - ecs_doc_set_brief(world, EcsDependsOn, "Relationship used for expressing dependencies"); - ecs_doc_set_brief(world, EcsSlotOf, "Relationship used for expressing prefab slots"); - ecs_doc_set_brief(world, EcsOnAdd, "Event emitted when component is added"); - ecs_doc_set_brief(world, EcsOnRemove, "Event emitted when component is removed"); - ecs_doc_set_brief(world, EcsOnSet, "Event emitted when component is set"); - ecs_doc_set_brief(world, EcsUnSet, "Event emitted when component is unset"); - ecs_doc_set_brief(world, EcsMonitor, "Marker used to create monitor observers"); - ecs_doc_set_brief(world, EcsOnTableFill, "Event emitted when table becomes non-empty"); - ecs_doc_set_brief(world, EcsOnTableEmpty, "Event emitted when table becomes empty"); - ecs_doc_set_brief(world, EcsOnTableCreate, "Event emitted when table is created"); - ecs_doc_set_brief(world, EcsOnTableDelete, "Event emitted when table is deleted"); - - ecs_doc_set_brief(world, EcsThis, "Query marker to express $this variable"); - ecs_doc_set_brief(world, EcsWildcard, "Query marker to express match all wildcard"); - ecs_doc_set_brief(world, EcsAny, "Query marker to express match at least one wildcard"); - - ecs_doc_set_brief(world, EcsPredEq, "Query marker to express == operator"); - ecs_doc_set_brief(world, EcsPredMatch, "Query marker to express ~= operator"); - ecs_doc_set_brief(world, EcsPredLookup, "Query marker to express by-name lookup"); - ecs_doc_set_brief(world, EcsScopeOpen, "Query marker to express scope open"); - ecs_doc_set_brief(world, EcsScopeClose, "Query marker to express scope close"); - ecs_doc_set_brief(world, EcsEmpty, "Tag used to indicate a query has no results"); - - /* Initialize documentation for meta components */ - ecs_entity_t meta = ecs_lookup(world, "flecs.meta"); - ecs_doc_set_brief(world, meta, "Flecs module with reflection components"); - - ecs_doc_set_brief(world, ecs_id(EcsMetaType), "Component added to types"); - ecs_doc_set_brief(world, ecs_id(EcsMetaTypeSerialized), "Component that stores reflection data in an optimized format"); - ecs_doc_set_brief(world, ecs_id(EcsPrimitive), "Component added to primitive types"); - ecs_doc_set_brief(world, ecs_id(EcsEnum), "Component added to enumeration types"); - ecs_doc_set_brief(world, ecs_id(EcsBitmask), "Component added to bitmask types"); - ecs_doc_set_brief(world, ecs_id(EcsMember), "Component added to struct members"); - ecs_doc_set_brief(world, ecs_id(EcsStruct), "Component added to struct types"); - ecs_doc_set_brief(world, ecs_id(EcsArray), "Component added to array types"); - ecs_doc_set_brief(world, ecs_id(EcsVector), "Component added to vector types"); - - ecs_doc_set_brief(world, ecs_id(ecs_bool_t), "bool component"); - ecs_doc_set_brief(world, ecs_id(ecs_char_t), "char component"); - ecs_doc_set_brief(world, ecs_id(ecs_byte_t), "byte component"); - ecs_doc_set_brief(world, ecs_id(ecs_u8_t), "8 bit unsigned int component"); - ecs_doc_set_brief(world, ecs_id(ecs_u16_t), "16 bit unsigned int component"); - ecs_doc_set_brief(world, ecs_id(ecs_u32_t), "32 bit unsigned int component"); - ecs_doc_set_brief(world, ecs_id(ecs_u64_t), "64 bit unsigned int component"); - ecs_doc_set_brief(world, ecs_id(ecs_uptr_t), "word sized unsigned int component"); - ecs_doc_set_brief(world, ecs_id(ecs_i8_t), "8 bit signed int component"); - ecs_doc_set_brief(world, ecs_id(ecs_i16_t), "16 bit signed int component"); - ecs_doc_set_brief(world, ecs_id(ecs_i32_t), "32 bit signed int component"); - ecs_doc_set_brief(world, ecs_id(ecs_i64_t), "64 bit signed int component"); - ecs_doc_set_brief(world, ecs_id(ecs_iptr_t), "word sized signed int component"); - ecs_doc_set_brief(world, ecs_id(ecs_f32_t), "32 bit floating point component"); - ecs_doc_set_brief(world, ecs_id(ecs_f64_t), "64 bit floating point component"); - ecs_doc_set_brief(world, ecs_id(ecs_string_t), "string component"); - ecs_doc_set_brief(world, ecs_id(ecs_entity_t), "entity component"); - - /* Initialize documentation for doc components */ - ecs_entity_t doc = ecs_lookup(world, "flecs.doc"); - ecs_doc_set_brief(world, doc, "Flecs module with documentation components"); - - ecs_doc_set_brief(world, ecs_id(EcsDocDescription), "Component used to add documentation"); - ecs_doc_set_brief(world, EcsDocBrief, "Used as (Description, Brief) to add a brief description"); - ecs_doc_set_brief(world, EcsDocDetail, "Used as (Description, Detail) to add a detailed description"); - ecs_doc_set_brief(world, EcsDocLink, "Used as (Description, Link) to add a link"); -} - -#endif diff --git a/src/addons/doc.c b/src/addons/doc.c index 41c22ad554..9ead83f24f 100644 --- a/src/addons/doc.c +++ b/src/addons/doc.c @@ -144,6 +144,102 @@ const char* ecs_doc_get_color( } } +/* Doc definitions for core components */ +static +void flecs_doc_import_core_definitions( + ecs_world_t *world) +{ + ecs_doc_set_brief(world, EcsFlecs, "Flecs root module"); + ecs_doc_set_link(world, EcsFlecs, "https://github.com/SanderMertens/flecs"); + ecs_doc_set_brief(world, EcsFlecsCore, "Module with builtin components"); + ecs_doc_set_brief(world, EcsFlecsInternals, "Module with internal entities"); + + ecs_doc_set_brief(world, EcsWorld, "Entity associated with world"); + + ecs_doc_set_brief(world, ecs_id(EcsComponent), "Component that is added to components"); + ecs_doc_set_brief(world, EcsModule, "Tag that is added to modules"); + ecs_doc_set_brief(world, EcsPrefab, "Tag that is added to prefabs"); + ecs_doc_set_brief(world, EcsDisabled, "Tag that is added to disabled entities"); + ecs_doc_set_brief(world, EcsPrivate, "Tag that is added to private components"); + ecs_doc_set_brief(world, EcsFlag, "Internal tag for tracking ids with special id flags"); + ecs_doc_set_brief(world, ecs_id(EcsIterable), "Internal component to make (query) entities iterable"); + ecs_doc_set_brief(world, ecs_id(EcsPoly), "Internal component that stores pointer to poly objects"); + + ecs_doc_set_brief(world, ecs_id(EcsTarget), "Internal component that stores information for flattened trees"); + ecs_doc_set_brief(world, EcsFlatten, "Tag that when added to assembly automatically flattens tree"); + + ecs_doc_set_brief(world, ecs_id(EcsIdentifier), "Component used for entity names"); + ecs_doc_set_brief(world, EcsName, "Tag used with EcsIdentifier to store entity name"); + ecs_doc_set_brief(world, EcsSymbol, "Tag used with EcsIdentifier to store entity symbol"); + ecs_doc_set_brief(world, EcsAlias, "Tag used with EcsIdentifier to store entity alias"); + + ecs_doc_set_brief(world, EcsQuery, "Tag added to query entities"); + ecs_doc_set_brief(world, EcsObserver, "Tag added to observer entities"); + + ecs_doc_set_brief(world, EcsTransitive, "Trait that enables transitive evaluation of relationships"); + ecs_doc_set_brief(world, EcsReflexive, "Trait that enables reflexive evaluation of relationships"); + ecs_doc_set_brief(world, EcsFinal, "Trait that indicates an entity cannot be inherited from"); + ecs_doc_set_brief(world, EcsDontInherit, "Trait that indicates it should not be inherited"); + ecs_doc_set_brief(world, EcsTag, "Trait that ensures a pair cannot contain a value"); + ecs_doc_set_brief(world, EcsAcyclic, "Trait that indicates a relationship is acyclic"); + ecs_doc_set_brief(world, EcsTraversable, "Trait that indicates a relationship is traversable"); + ecs_doc_set_brief(world, EcsExclusive, "Trait that ensures a relationship can only have one target"); + ecs_doc_set_brief(world, EcsSymmetric, "Trait that causes a relationship to be two-way"); + ecs_doc_set_brief(world, EcsWith, "Trait for adding additional components when a component is added"); + ecs_doc_set_brief(world, EcsAlwaysOverride, "Trait that indicates a component should always be overridden"); + ecs_doc_set_brief(world, EcsUnion, "Trait for creating a non-fragmenting relationship"); + ecs_doc_set_brief(world, EcsOneOf, "Trait that enforces target of relationship is a child of "); + ecs_doc_set_brief(world, EcsOnDelete, "Cleanup trait for specifying what happens when component is deleted"); + ecs_doc_set_brief(world, EcsOnDeleteTarget, "Cleanup trait for specifying what happens when pair target is deleted"); + ecs_doc_set_brief(world, EcsRemove, "Cleanup action used with OnDelete/OnDeleteTarget"); + ecs_doc_set_brief(world, EcsDelete, "Cleanup action used with OnDelete/OnDeleteTarget"); + ecs_doc_set_brief(world, EcsPanic, "Cleanup action used with OnDelete/OnDeleteTarget"); + ecs_doc_set_brief(world, EcsDefaultChildComponent, "Sets default component hint for children of entity"); + ecs_doc_set_brief(world, EcsIsA, "Relationship used for expressing inheritance"); + ecs_doc_set_brief(world, EcsChildOf, "Relationship used for expressing hierarchies"); + ecs_doc_set_brief(world, EcsDependsOn, "Relationship used for expressing dependencies"); + ecs_doc_set_brief(world, EcsSlotOf, "Relationship used for expressing prefab slots"); + ecs_doc_set_brief(world, EcsOnAdd, "Event emitted when component is added"); + ecs_doc_set_brief(world, EcsOnRemove, "Event emitted when component is removed"); + ecs_doc_set_brief(world, EcsOnSet, "Event emitted when component is set"); + ecs_doc_set_brief(world, EcsUnSet, "Event emitted when component is unset"); + ecs_doc_set_brief(world, EcsMonitor, "Marker used to create monitor observers"); + ecs_doc_set_brief(world, EcsOnTableFill, "Event emitted when table becomes non-empty"); + ecs_doc_set_brief(world, EcsOnTableEmpty, "Event emitted when table becomes empty"); + ecs_doc_set_brief(world, EcsOnTableCreate, "Event emitted when table is created"); + ecs_doc_set_brief(world, EcsOnTableDelete, "Event emitted when table is deleted"); + + ecs_doc_set_brief(world, EcsThis, "Query marker to express $this variable"); + ecs_doc_set_brief(world, EcsWildcard, "Query marker to express match all wildcard"); + ecs_doc_set_brief(world, EcsAny, "Query marker to express match at least one wildcard"); + + ecs_doc_set_brief(world, EcsPredEq, "Query marker to express == operator"); + ecs_doc_set_brief(world, EcsPredMatch, "Query marker to express ~= operator"); + ecs_doc_set_brief(world, EcsPredLookup, "Query marker to express by-name lookup"); + ecs_doc_set_brief(world, EcsScopeOpen, "Query marker to express scope open"); + ecs_doc_set_brief(world, EcsScopeClose, "Query marker to express scope close"); + ecs_doc_set_brief(world, EcsEmpty, "Tag used to indicate a query has no results"); +} + +/* Doc definitions for doc components */ +static +void flecs_doc_import_doc_definitions( + ecs_world_t *world) +{ + ecs_entity_t doc = ecs_lookup(world, "flecs.doc"); + ecs_doc_set_brief(world, doc, "Flecs module with documentation components"); + + ecs_doc_set_brief(world, EcsDocBrief, "Brief description"); + ecs_doc_set_brief(world, EcsDocDetail, "Detailed description"); + ecs_doc_set_brief(world, EcsDocLink, "Link to additional documentation"); + ecs_doc_set_brief(world, EcsDocColor, "Color hint for entity"); + + ecs_doc_set_brief(world, ecs_id(EcsDocDescription), "Component used to add documentation"); + ecs_doc_set_brief(world, EcsDocBrief, "Used as (Description, Brief) to add a brief description"); + ecs_doc_set_brief(world, EcsDocDetail, "Used as (Description, Detail) to add a detailed description"); + ecs_doc_set_brief(world, EcsDocLink, "Used as (Description, Link) to add a link"); +} + void FlecsDocImport( ecs_world_t *world) { @@ -167,10 +263,8 @@ void FlecsDocImport( ecs_add_id(world, ecs_id(EcsDocDescription), EcsDontInherit); ecs_add_id(world, ecs_id(EcsDocDescription), EcsPrivate); - ecs_doc_set_brief(world, EcsDocBrief, "Brief description"); - ecs_doc_set_brief(world, EcsDocDetail, "Detailed description"); - ecs_doc_set_brief(world, EcsDocLink, "Link to additional documentation"); - ecs_doc_set_brief(world, EcsDocColor, "Color hint for entity"); + flecs_doc_import_core_definitions(world); + flecs_doc_import_doc_definitions(world); } #endif diff --git a/src/addons/meta/definitions.c b/src/addons/meta/definitions.c new file mode 100644 index 0000000000..0f7cdb7562 --- /dev/null +++ b/src/addons/meta/definitions.c @@ -0,0 +1,230 @@ + +/** + * @file meta/definitions.c + * @brief Reflection definitions for builtin types. + */ + +#include "meta.h" + +#ifdef FLECS_META + +/* Initialize reflection data for core components */ +static +void flecs_meta_import_core_definitions( + ecs_world_t *world) +{ + ecs_struct(world, { + .entity = ecs_id(EcsComponent), + .members = { + { .name = "size", .type = ecs_id(ecs_i32_t) }, + { .name = "alignment", .type = ecs_id(ecs_i32_t) } + } + }); + + ecs_struct(world, { + .entity = ecs_entity(world, { + .name = "flecs.core.build_info_t", + .root_sep = "" + }), + .members = { + { .name = "compiler", .type = ecs_id(ecs_string_t) }, + { .name = "addons", .type = ecs_id(ecs_string_t) }, + { .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) }, + { .name = "version_patch", .type = ecs_id(ecs_i16_t) }, + { .name = "debug", .type = ecs_id(ecs_bool_t) }, + { .name = "sanitize", .type = ecs_id(ecs_bool_t) }, + } + }); +} + +/* Initialize reflection data for doc components */ +static +void flecs_meta_import_doc_definitions( + ecs_world_t *world) +{ + ecs_struct(world, { + .entity = ecs_id(EcsDocDescription), + .members = { + { .name = "value", .type = ecs_id(ecs_string_t) } + } + }); +} + +/* Initialize reflection data for meta components */ +static +void flecs_meta_import_meta_definitions( + ecs_world_t *world) +{ + ecs_entity_t type_kind = ecs_enum_init(world, &(ecs_enum_desc_t){ + .entity = ecs_entity(world, { .name = "TypeKind" }), + .constants = { + { .name = "PrimitiveType" }, + { .name = "BitmaskType" }, + { .name = "EnumType" }, + { .name = "StructType" }, + { .name = "ArrayType" }, + { .name = "VectorType" }, + { .name = "OpaqueType" } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsMetaType), + .members = { + { .name = "kind", .type = type_kind } + } + }); + + ecs_entity_t primitive_kind = ecs_enum_init(world, &(ecs_enum_desc_t){ + .entity = ecs_entity(world, { .name = "PrimitiveKind" }), + .constants = { + { .name = "Bool", 1 }, + { .name = "Char" }, + { .name = "Byte" }, + { .name = "U8" }, + { .name = "U16" }, + { .name = "U32" }, + { .name = "U64 "}, + { .name = "I8" }, + { .name = "I16" }, + { .name = "I32" }, + { .name = "I64" }, + { .name = "F32" }, + { .name = "F64" }, + { .name = "UPtr "}, + { .name = "IPtr" }, + { .name = "String" }, + { .name = "Entity" }, + { .name = "Id" } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsPrimitive), + .members = { + { .name = "kind", .type = primitive_kind } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsMember), + .members = { + { .name = "type", .type = ecs_id(ecs_entity_t) }, + { .name = "count", .type = ecs_id(ecs_i32_t) }, + { .name = "unit", .type = ecs_id(ecs_entity_t) }, + { .name = "offset", .type = ecs_id(ecs_i32_t) } + } + }); + + ecs_entity_t vr = ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_entity(world, { .name = "value_range" }), + .members = { + { .name = "min", .type = ecs_id(ecs_f64_t) }, + { .name = "max", .type = ecs_id(ecs_f64_t) } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsMemberRanges), + .members = { + { .name = "value", .type = vr }, + { .name = "warning", .type = vr }, + { .name = "error", .type = vr } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsArray), + .members = { + { .name = "type", .type = ecs_id(ecs_entity_t) }, + { .name = "count", .type = ecs_id(ecs_i32_t) }, + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsVector), + .members = { + { .name = "type", .type = ecs_id(ecs_entity_t) } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsOpaque), + .members = { + { .name = "as_type", .type = ecs_id(ecs_entity_t) } + } + }); + + ecs_entity_t ut = ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_entity(world, { .name = "unit_translation" }), + .members = { + { .name = "factor", .type = ecs_id(ecs_i32_t) }, + { .name = "power", .type = ecs_id(ecs_i32_t) } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsUnit), + .members = { + { .name = "symbol", .type = ecs_id(ecs_string_t) }, + { .name = "prefix", .type = ecs_id(ecs_entity_t) }, + { .name = "base", .type = ecs_id(ecs_entity_t) }, + { .name = "over", .type = ecs_id(ecs_entity_t) }, + { .name = "translation", .type = ut } + } + }); + + ecs_struct_init(world, &(ecs_struct_desc_t){ + .entity = ecs_id(EcsUnitPrefix), + .members = { + { .name = "symbol", .type = ecs_id(ecs_string_t) }, + { .name = "translation", .type = ut } + } + }); + + /* Meta doc definitions */ +#ifdef FLECS_DOC + ecs_entity_t meta = ecs_lookup(world, "flecs.meta"); + ecs_doc_set_brief(world, meta, "Flecs module with reflection components"); + + ecs_doc_set_brief(world, ecs_id(EcsMetaType), "Component added to types"); + ecs_doc_set_brief(world, ecs_id(EcsMetaTypeSerialized), "Component that stores reflection data in an optimized format"); + ecs_doc_set_brief(world, ecs_id(EcsPrimitive), "Component added to primitive types"); + ecs_doc_set_brief(world, ecs_id(EcsEnum), "Component added to enumeration types"); + ecs_doc_set_brief(world, ecs_id(EcsBitmask), "Component added to bitmask types"); + ecs_doc_set_brief(world, ecs_id(EcsMember), "Component added to struct members"); + ecs_doc_set_brief(world, ecs_id(EcsStruct), "Component added to struct types"); + ecs_doc_set_brief(world, ecs_id(EcsArray), "Component added to array types"); + ecs_doc_set_brief(world, ecs_id(EcsVector), "Component added to vector types"); + + ecs_doc_set_brief(world, ecs_id(ecs_bool_t), "bool component"); + ecs_doc_set_brief(world, ecs_id(ecs_char_t), "char component"); + ecs_doc_set_brief(world, ecs_id(ecs_byte_t), "byte component"); + ecs_doc_set_brief(world, ecs_id(ecs_u8_t), "8 bit unsigned int component"); + ecs_doc_set_brief(world, ecs_id(ecs_u16_t), "16 bit unsigned int component"); + ecs_doc_set_brief(world, ecs_id(ecs_u32_t), "32 bit unsigned int component"); + ecs_doc_set_brief(world, ecs_id(ecs_u64_t), "64 bit unsigned int component"); + ecs_doc_set_brief(world, ecs_id(ecs_uptr_t), "word sized unsigned int component"); + ecs_doc_set_brief(world, ecs_id(ecs_i8_t), "8 bit signed int component"); + ecs_doc_set_brief(world, ecs_id(ecs_i16_t), "16 bit signed int component"); + ecs_doc_set_brief(world, ecs_id(ecs_i32_t), "32 bit signed int component"); + ecs_doc_set_brief(world, ecs_id(ecs_i64_t), "64 bit signed int component"); + ecs_doc_set_brief(world, ecs_id(ecs_iptr_t), "word sized signed int component"); + ecs_doc_set_brief(world, ecs_id(ecs_f32_t), "32 bit floating point component"); + ecs_doc_set_brief(world, ecs_id(ecs_f64_t), "64 bit floating point component"); + ecs_doc_set_brief(world, ecs_id(ecs_string_t), "string component"); + ecs_doc_set_brief(world, ecs_id(ecs_entity_t), "entity component"); +#endif +} + +void flecs_meta_import_definitions( + ecs_world_t *world) +{ + flecs_meta_import_core_definitions(world); + flecs_meta_import_doc_definitions(world); + flecs_meta_import_meta_definitions(world); +} + +#endif diff --git a/src/addons/meta/meta.c b/src/addons/meta/meta.c index 50d568ebe3..f5738be2d8 100644 --- a/src/addons/meta/meta.c +++ b/src/addons/meta/meta.c @@ -1139,6 +1139,9 @@ void FlecsMetaImport( ecs_world_t *world) { ECS_MODULE(world, FlecsMeta); +#ifdef FLECS_DOC + ECS_IMPORT(world, FlecsDoc); +#endif ecs_set_name_prefix(world, "Ecs"); @@ -1358,133 +1361,8 @@ void FlecsMetaImport( ecs_add_id(world, EcsQuantity, EcsExclusive); ecs_add_id(world, EcsQuantity, EcsTag); - /* Initialize reflection data for meta components */ - ecs_entity_t type_kind = ecs_enum_init(world, &(ecs_enum_desc_t){ - .entity = ecs_entity(world, { .name = "TypeKind" }), - .constants = { - { .name = "PrimitiveType" }, - { .name = "BitmaskType" }, - { .name = "EnumType" }, - { .name = "StructType" }, - { .name = "ArrayType" }, - { .name = "VectorType" }, - { .name = "OpaqueType" } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsMetaType), - .members = { - { .name = "kind", .type = type_kind } - } - }); - - ecs_entity_t primitive_kind = ecs_enum_init(world, &(ecs_enum_desc_t){ - .entity = ecs_entity(world, { .name = "PrimitiveKind" }), - .constants = { - { .name = "Bool", 1 }, - { .name = "Char" }, - { .name = "Byte" }, - { .name = "U8" }, - { .name = "U16" }, - { .name = "U32" }, - { .name = "U64 "}, - { .name = "I8" }, - { .name = "I16" }, - { .name = "I32" }, - { .name = "I64" }, - { .name = "F32" }, - { .name = "F64" }, - { .name = "UPtr "}, - { .name = "IPtr" }, - { .name = "String" }, - { .name = "Entity" }, - { .name = "Id" } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsPrimitive), - .members = { - { .name = "kind", .type = primitive_kind } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsMember), - .members = { - { .name = "type", .type = ecs_id(ecs_entity_t) }, - { .name = "count", .type = ecs_id(ecs_i32_t) }, - { .name = "unit", .type = ecs_id(ecs_entity_t) }, - { .name = "offset", .type = ecs_id(ecs_i32_t) } - } - }); - - ecs_entity_t vr = ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_entity(world, { .name = "value_range" }), - .members = { - { .name = "min", .type = ecs_id(ecs_f64_t) }, - { .name = "max", .type = ecs_id(ecs_f64_t) } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsMemberRanges), - .members = { - { .name = "value", .type = vr }, - { .name = "warning", .type = vr }, - { .name = "error", .type = vr } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsArray), - .members = { - { .name = "type", .type = ecs_id(ecs_entity_t) }, - { .name = "count", .type = ecs_id(ecs_i32_t) }, - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsVector), - .members = { - { .name = "type", .type = ecs_id(ecs_entity_t) } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsOpaque), - .members = { - { .name = "as_type", .type = ecs_id(ecs_entity_t) } - } - }); - - ecs_entity_t ut = ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_entity(world, { .name = "unit_translation" }), - .members = { - { .name = "factor", .type = ecs_id(ecs_i32_t) }, - { .name = "power", .type = ecs_id(ecs_i32_t) } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsUnit), - .members = { - { .name = "symbol", .type = ecs_id(ecs_string_t) }, - { .name = "prefix", .type = ecs_id(ecs_entity_t) }, - { .name = "base", .type = ecs_id(ecs_entity_t) }, - { .name = "over", .type = ecs_id(ecs_entity_t) }, - { .name = "translation", .type = ut } - } - }); - - ecs_struct_init(world, &(ecs_struct_desc_t){ - .entity = ecs_id(EcsUnitPrefix), - .members = { - { .name = "symbol", .type = ecs_id(ecs_string_t) }, - { .name = "translation", .type = ut } - } - }); + /* Import reflection definitions for builtin types */ + flecs_meta_import_definitions(world); } #endif diff --git a/src/addons/meta/meta.h b/src/addons/meta/meta.h index 9e06c8df35..d3972175f3 100644 --- a/src/addons/meta/meta.h +++ b/src/addons/meta/meta.h @@ -24,6 +24,9 @@ bool flecs_unit_validate( ecs_entity_t t, EcsUnit *data); +void flecs_meta_import_definitions( + ecs_world_t *world); + #endif #endif diff --git a/src/addons/monitor.c b/src/addons/monitor.c index c740fbd59b..003c372cfb 100644 --- a/src/addons/monitor.c +++ b/src/addons/monitor.c @@ -322,7 +322,7 @@ void FlecsMonitorImport( #ifdef FLECS_UNITS ECS_IMPORT(world, FlecsUnits); #endif -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsMonitor), "Module that automatically monitors statistics for the world & systems"); @@ -338,7 +338,7 @@ void FlecsMonitorImport( ECS_COMPONENT_DEFINE(world, EcsWorldSummary); -#if defined(FLECS_META) && defined(FLECS_UNITS) +#if defined(FLECS_META) && defined(FLECS_UNITS) ecs_struct(world, { .entity = ecs_id(EcsWorldSummary), .members = { diff --git a/src/addons/pipeline/pipeline.c b/src/addons/pipeline/pipeline.c index 65161ba322..6faa48d24d 100644 --- a/src/addons/pipeline/pipeline.c +++ b/src/addons/pipeline/pipeline.c @@ -877,7 +877,7 @@ void FlecsPipelineImport( { ECS_MODULE(world, FlecsPipeline); ECS_IMPORT(world, FlecsSystem); -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsPipeline), "Module that schedules and runs systems"); diff --git a/src/addons/plecs.c b/src/addons/plecs.c index ce457c8077..900e9b6c20 100644 --- a/src/addons/plecs.c +++ b/src/addons/plecs.c @@ -2235,7 +2235,7 @@ void FlecsScriptImport( { ECS_MODULE(world, FlecsScript); ECS_IMPORT(world, FlecsMeta); -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsScript), "Module with components for managing Flecs scripts"); diff --git a/src/addons/rest.c b/src/addons/rest.c index 54b893efac..6f12693a13 100644 --- a/src/addons/rest.c +++ b/src/addons/rest.c @@ -1069,7 +1069,7 @@ void FlecsRestImport( #ifdef FLECS_PLECS ECS_IMPORT(world, FlecsScript); #endif -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsRest), "Module that implements Flecs REST API"); diff --git a/src/addons/system/system.c b/src/addons/system/system.c index 1affb6e25e..d75b1c1abd 100644 --- a/src/addons/system/system.c +++ b/src/addons/system/system.c @@ -377,7 +377,7 @@ void FlecsSystemImport( ecs_world_t *world) { ECS_MODULE(world, FlecsSystem); -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsSystem), "Module that implements Flecs systems"); diff --git a/src/addons/timer.c b/src/addons/timer.c index 3345ed23c2..36601773dd 100644 --- a/src/addons/timer.c +++ b/src/addons/timer.c @@ -289,7 +289,7 @@ void FlecsTimerImport( { ECS_MODULE(world, FlecsTimer); ECS_IMPORT(world, FlecsPipeline); -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsTimer), "Module that implements system timers (used by .interval)"); diff --git a/src/addons/units.c b/src/addons/units.c index e6d1ce7343..36a8205898 100644 --- a/src/addons/units.c +++ b/src/addons/units.c @@ -12,7 +12,7 @@ void FlecsUnitsImport( { ECS_MODULE(world, FlecsUnits); -#ifdef FLECS_COREDOC +#ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); ecs_doc_set_brief(world, ecs_id(FlecsUnits), "Module with (amongst others) SI units for annotating component members"); diff --git a/src/world.c b/src/world.c index 3ff6ed25c9..68126cfb6d 100644 --- a/src/world.c +++ b/src/world.c @@ -167,6 +167,7 @@ static ecs_entity_t ecs_default_lookup_path[2] = { 0, 0 }; /* Declarations for addons. Located in world.c to avoid issues during linking of * static library */ + #ifdef FLECS_ALERTS ECS_COMPONENT_DECLARE(EcsAlert); ECS_COMPONENT_DECLARE(EcsAlertInstance); @@ -822,9 +823,6 @@ static const char *flecs_addons_info[] = { #ifdef FLECS_DOC "FLECS_DOC", #endif -#ifdef FLECS_COREDOC - "FLECS_COREDOC", -#endif #ifdef FLECS_LOG "FLECS_LOG", #endif @@ -869,6 +867,8 @@ void flecs_log_build_info(void) { const ecs_build_info_t *bi = ecs_get_build_info(); ecs_assert(bi != NULL, ECS_INTERNAL_ERROR, NULL); + ecs_trace("flecs version %s", bi->version); + ecs_trace("addons included in build:"); ecs_log_push(); @@ -1016,9 +1016,6 @@ ecs_world_t *ecs_init(void) { #ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); #endif -#ifdef FLECS_COREDOC - ECS_IMPORT(world, FlecsCoreDoc); -#endif #ifdef FLECS_SCRIPT ECS_IMPORT(world, FlecsScript); #endif