diff --git a/flecs.c b/flecs.c index 7de9975506..a979e25199 100644 --- a/flecs.c +++ b/flecs.c @@ -30510,6 +30510,12 @@ ECS_DECLARE(EcsAngle); ECS_DECLARE(EcsBel); ECS_DECLARE(EcsDeciBel); +ECS_DECLARE(EcsFrequency); + ECS_DECLARE(EcsHerz); + ECS_DECLARE(EcsKiloHerz); + ECS_DECLARE(EcsMegaHerz); + ECS_DECLARE(EcsGigaHerz); + void FlecsUnitsImport( ecs_world_t *world) { @@ -31321,6 +31327,47 @@ void FlecsUnitsImport( .kind = EcsF32 }); + EcsFrequency = ecs_quantity_init(world, &(ecs_entity_desc_t){ + .name = "Frequency" }); + prev_scope = ecs_set_scope(world, EcsFrequency); + + EcsHerz = ecs_unit_init(world, &(ecs_unit_desc_t){ + .entity = ecs_entity(world, { .name = "Herz" }), + .quantity = EcsFrequency, + .symbol = "Hz" }); + ecs_primitive_init(world, &(ecs_primitive_desc_t){ + .entity = EcsHerz, + .kind = EcsF32 + }); + + EcsKiloHerz = ecs_unit_init(world, &(ecs_unit_desc_t){ + .entity = ecs_entity(world, { .name = "KiloHerz" }), + .prefix = EcsKilo, + .base = EcsHerz }); + ecs_primitive_init(world, &(ecs_primitive_desc_t){ + .entity = EcsKiloHerz, + .kind = EcsF32 + }); + + EcsMegaHerz = ecs_unit_init(world, &(ecs_unit_desc_t){ + .entity = ecs_entity(world, { .name = "MegaHerz" }), + .prefix = EcsMega, + .base = EcsHerz }); + ecs_primitive_init(world, &(ecs_primitive_desc_t){ + .entity = EcsMegaHerz, + .kind = EcsF32 + }); + + EcsGigaHerz = ecs_unit_init(world, &(ecs_unit_desc_t){ + .entity = ecs_entity(world, { .name = "GigaHerz" }), + .prefix = EcsGiga, + .base = EcsHerz }); + ecs_primitive_init(world, &(ecs_primitive_desc_t){ + .entity = EcsGigaHerz, + .kind = EcsF32 + }); + ecs_set_scope(world, prev_scope); + /* Documentation */ #ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc); diff --git a/flecs.h b/flecs.h index 6edfa96924..791cdf249c 100644 --- a/flecs.h +++ b/flecs.h @@ -11783,6 +11783,12 @@ FLECS_API extern ECS_DECLARE(EcsDegrees); FLECS_API extern ECS_DECLARE(EcsBel); FLECS_API extern ECS_DECLARE(EcsDeciBel); +FLECS_API extern ECS_DECLARE(EcsFrequency); +FLECS_API extern ECS_DECLARE(EcsHerz); +FLECS_API extern ECS_DECLARE(EcsKiloHerz); +FLECS_API extern ECS_DECLARE(EcsMegaHerz); +FLECS_API extern ECS_DECLARE(EcsGigaHerz); + //////////////////////////////////////////////////////////////////////////////// //// Module //////////////////////////////////////////////////////////////////////////////// diff --git a/include/flecs/addons/cpp/mixins/units/decl.hpp b/include/flecs/addons/cpp/mixins/units/decl.hpp index d1c4de1114..eb768370e8 100644 --- a/include/flecs/addons/cpp/mixins/units/decl.hpp +++ b/include/flecs/addons/cpp/mixins/units/decl.hpp @@ -57,6 +57,7 @@ struct Temperature { }; struct Data { }; struct DataRate { }; struct Angle { }; +struct Frequency { }; //////////////////////////////////////////////////////////////////////////////// @@ -158,6 +159,13 @@ struct MegaBytesPerSecond { }; struct GigaBytesPerSecond { }; }; +struct frequency { +struct Herz { }; +struct KiloHerz { }; +struct MegaHerz { }; +struct GigaHerz { }; +}; + struct Percentage { }; struct Bel { }; struct DeciBel { }; diff --git a/include/flecs/addons/cpp/mixins/units/impl.hpp b/include/flecs/addons/cpp/mixins/units/impl.hpp index 2c3593aaf1..e05b2380a2 100644 --- a/include/flecs/addons/cpp/mixins/units/impl.hpp +++ b/include/flecs/addons/cpp/mixins/units/impl.hpp @@ -171,6 +171,16 @@ inline units::units(flecs::world& world) { world.entity( "::flecs::units::DataRate::GigaBytesPerSecond"); + // Initialize datarate units + world.entity( + "::flecs::units::Frequency::Herz"); + world.entity( + "::flecs::units::Frequency::KiloHerz"); + world.entity( + "::flecs::units::Frequency::MegaHerz"); + world.entity( + "::flecs::units::Frequency::GigaHerz"); + // Initialize angles world.entity( "::flecs::units::Angle::Radians"); diff --git a/include/flecs/addons/units.h b/include/flecs/addons/units.h index 369b7e07c0..7db28a23a4 100644 --- a/include/flecs/addons/units.h +++ b/include/flecs/addons/units.h @@ -162,6 +162,12 @@ FLECS_API extern ECS_DECLARE(EcsDegrees); FLECS_API extern ECS_DECLARE(EcsBel); FLECS_API extern ECS_DECLARE(EcsDeciBel); +FLECS_API extern ECS_DECLARE(EcsFrequency); +FLECS_API extern ECS_DECLARE(EcsHerz); +FLECS_API extern ECS_DECLARE(EcsKiloHerz); +FLECS_API extern ECS_DECLARE(EcsMegaHerz); +FLECS_API extern ECS_DECLARE(EcsGigaHerz); + //////////////////////////////////////////////////////////////////////////////// //// Module //////////////////////////////////////////////////////////////////////////////// diff --git a/src/addons/units.c b/src/addons/units.c index 1c286bbead..0f11f5e443 100644 --- a/src/addons/units.c +++ b/src/addons/units.c @@ -123,6 +123,12 @@ ECS_DECLARE(EcsAngle); ECS_DECLARE(EcsBel); ECS_DECLARE(EcsDeciBel); +ECS_DECLARE(EcsFrequency); + ECS_DECLARE(EcsHerz); + ECS_DECLARE(EcsKiloHerz); + ECS_DECLARE(EcsMegaHerz); + ECS_DECLARE(EcsGigaHerz); + void FlecsUnitsImport( ecs_world_t *world) { @@ -934,6 +940,47 @@ void FlecsUnitsImport( .kind = EcsF32 }); + EcsFrequency = ecs_quantity_init(world, &(ecs_entity_desc_t){ + .name = "Frequency" }); + prev_scope = ecs_set_scope(world, EcsFrequency); + + EcsHerz = ecs_unit_init(world, &(ecs_unit_desc_t){ + .entity = ecs_entity(world, { .name = "Herz" }), + .quantity = EcsFrequency, + .symbol = "Hz" }); + ecs_primitive_init(world, &(ecs_primitive_desc_t){ + .entity = EcsHerz, + .kind = EcsF32 + }); + + EcsKiloHerz = ecs_unit_init(world, &(ecs_unit_desc_t){ + .entity = ecs_entity(world, { .name = "KiloHerz" }), + .prefix = EcsKilo, + .base = EcsHerz }); + ecs_primitive_init(world, &(ecs_primitive_desc_t){ + .entity = EcsKiloHerz, + .kind = EcsF32 + }); + + EcsMegaHerz = ecs_unit_init(world, &(ecs_unit_desc_t){ + .entity = ecs_entity(world, { .name = "MegaHerz" }), + .prefix = EcsMega, + .base = EcsHerz }); + ecs_primitive_init(world, &(ecs_primitive_desc_t){ + .entity = EcsMegaHerz, + .kind = EcsF32 + }); + + EcsGigaHerz = ecs_unit_init(world, &(ecs_unit_desc_t){ + .entity = ecs_entity(world, { .name = "GigaHerz" }), + .prefix = EcsGiga, + .base = EcsHerz }); + ecs_primitive_init(world, &(ecs_primitive_desc_t){ + .entity = EcsGigaHerz, + .kind = EcsF32 + }); + ecs_set_scope(world, prev_scope); + /* Documentation */ #ifdef FLECS_DOC ECS_IMPORT(world, FlecsDoc);