diff --git a/modules/stormkit/Core/Containers/RingBuffer.mpp b/include/stormkit/private/Core/Containers/RingBuffer.inc similarity index 94% rename from modules/stormkit/Core/Containers/RingBuffer.mpp rename to include/stormkit/private/Core/Containers/RingBuffer.inc index 19fbb650..fa70f0ab 100644 --- a/modules/stormkit/Core/Containers/RingBuffer.mpp +++ b/include/stormkit/private/Core/Containers/RingBuffer.inc @@ -1,19 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -export module stormkit.Core:Containers.RingBuffer; - -import std; - -import :Utils.Assert; -import :Utils.Numerics; -import :Utils.Byte; - export namespace stormkit::core { template class RingBuffer { @@ -266,4 +253,4 @@ namespace stormkit::core { return std::launder(std::bit_cast(addr)); } -} // namespace stormkit::core \ No newline at end of file +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Containers/Tree.mpp b/include/stormkit/private/Core/Containers/Tree.inc similarity index 96% rename from modules/stormkit/Core/Containers/Tree.mpp rename to include/stormkit/private/Core/Containers/Tree.inc index 37a00f98..da12966b 100644 --- a/modules/stormkit/Core/Containers/Tree.mpp +++ b/include/stormkit/private/Core/Containers/Tree.inc @@ -1,20 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -#include - -export module stormkit.Core:Containers.Tree; - -import std; - -import :Utils.Numerics; -import :Utils.Handle; - export namespace stormkit::core { class STORMKIT_API TreeNode { public: @@ -507,4 +493,4 @@ namespace stormkit::core { stream.close(); } -} // namespace stormkit::core \ No newline at end of file +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Containers/Utils.mpp b/include/stormkit/private/Core/Containers/Utils.inc similarity index 98% rename from modules/stormkit/Core/Containers/Utils.mpp rename to include/stormkit/private/Core/Containers/Utils.inc index fa878a24..3d666c2b 100644 --- a/modules/stormkit/Core/Containers/Utils.mpp +++ b/include/stormkit/private/Core/Containers/Utils.inc @@ -1,16 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Containers.Utils; - -import std; - -import :Meta.Traits; -import :Meta.Concepts; - -import :Utils.Byte; - export namespace stormkit::core { template constexpr auto merge(T& output, const U&... ranges) noexcept -> void; diff --git a/modules/stormkit/Core/Hash/Base.mpp b/include/stormkit/private/Core/Hash/Base.inc similarity index 96% rename from modules/stormkit/Core/Hash/Base.mpp rename to include/stormkit/private/Core/Hash/Base.inc index 35a89f24..3b598fca 100644 --- a/modules/stormkit/Core/Hash/Base.mpp +++ b/include/stormkit/private/Core/Hash/Base.inc @@ -1,13 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Hash.Base; - -import std; - -import :Meta.Concepts; - export namespace stormkit::core { using Hash32 = std::uint32_t; using Hash64 = std::uint64_t; diff --git a/modules/stormkit/Core/Hash/HashMap.mpp b/include/stormkit/private/Core/Hash/HashMap.inc similarity index 89% rename from modules/stormkit/Core/Hash/HashMap.mpp rename to include/stormkit/private/Core/Hash/HashMap.inc index c0277493..1c7c83c1 100644 --- a/modules/stormkit/Core/Hash/HashMap.mpp +++ b/include/stormkit/private/Core/Hash/HashMap.inc @@ -1,13 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Hash.HashMap; - -import std; - -import ankerl.unordered_dense; - export namespace stormkit::core { template // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Hash.StringHash; - -import std; - export namespace stormkit::core { struct StringHash { using is_transparent = void; @@ -81,4 +76,4 @@ namespace stormkit::core { -> bool { return a.compare(b) == 0; } -} // namespace stormkit::core \ No newline at end of file +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Meta/Concepts.mpp b/include/stormkit/private/Core/Meta/Concepts.inc similarity index 96% rename from modules/stormkit/Core/Meta/Concepts.mpp rename to include/stormkit/private/Core/Meta/Concepts.inc index 8405d3f9..f0b8772b 100644 --- a/modules/stormkit/Core/Meta/Concepts.mpp +++ b/include/stormkit/private/Core/Meta/Concepts.inc @@ -1,11 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Meta.Concepts; - -import std; - namespace stormkit::core { namespace details { template diff --git a/modules/stormkit/Core/Meta/Traits.mpp b/include/stormkit/private/Core/Meta/Traits.inc similarity index 94% rename from modules/stormkit/Core/Meta/Traits.mpp rename to include/stormkit/private/Core/Meta/Traits.inc index 64219020..560e6370 100644 --- a/modules/stormkit/Core/Meta/Traits.mpp +++ b/include/stormkit/private/Core/Meta/Traits.inc @@ -1,13 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Meta.Traits; - -import std; - -import :Meta.Concepts; - export namespace stormkit::core { template struct PureTypeTrait { diff --git a/modules/stormkit/Core/Parallelism/ThreadPool.mpp b/include/stormkit/private/Core/Parallelism/ThreadPool.inc similarity index 95% rename from modules/stormkit/Core/Parallelism/ThreadPool.mpp rename to include/stormkit/private/Core/Parallelism/ThreadPool.inc index b0bdda88..b7bbf62d 100644 --- a/modules/stormkit/Core/Parallelism/ThreadPool.mpp +++ b/include/stormkit/private/Core/Parallelism/ThreadPool.inc @@ -1,19 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -export module stormkit.Core:Parallelism.ThreadPool; - -import std; - -import :Utils.Algorithms; -import :Utils.Numerics; -import :Parallelism.ThreadUtils; - export namespace stormkit::core { class STORMKIT_API ThreadPool { public: diff --git a/modules/stormkit/Core/Parallelism/ThreadUtils.mpp b/include/stormkit/private/Core/Parallelism/ThreadUtils.inc similarity index 78% rename from modules/stormkit/Core/Parallelism/ThreadUtils.mpp rename to include/stormkit/private/Core/Parallelism/ThreadUtils.inc index 2e16fb0f..9be6dd2b 100644 --- a/modules/stormkit/Core/Parallelism/ThreadUtils.mpp +++ b/include/stormkit/private/Core/Parallelism/ThreadUtils.inc @@ -1,15 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -export module stormkit.Core:Parallelism.ThreadUtils; - -import std; - export namespace stormkit::core { STORMKIT_API auto setCurrentThreadName(std::string_view name) -> void; STORMKIT_API auto setThreadName(std::thread& thread, std::string_view name) -> void; diff --git a/modules/stormkit/Core/String/Encodings.mpp b/include/stormkit/private/Core/String/Encodings.inc similarity index 97% rename from modules/stormkit/Core/String/Encodings.mpp rename to include/stormkit/private/Core/String/Encodings.inc index 2d55da3b..36d9a0e5 100644 --- a/modules/stormkit/Core/String/Encodings.mpp +++ b/include/stormkit/private/Core/String/Encodings.inc @@ -1,21 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include -#include - -#include - -export module stormkit.Core:String.Encodings; - -import std; - -import :Utils.AsCast; -import :Utils.Numerics; - export namespace stormkit::core { auto asciiToUtf16(std::string_view) -> std::u16string; auto utf16ToAscii(std::u16string_view) -> std::string; diff --git a/modules/stormkit/Core/String/Format.mpp b/include/stormkit/private/Core/String/Format.inc similarity index 93% rename from modules/stormkit/Core/String/Format.mpp rename to include/stormkit/private/Core/String/Format.inc index 52471c5f..96eda02b 100644 --- a/modules/stormkit/Core/String/Format.mpp +++ b/include/stormkit/private/Core/String/Format.inc @@ -1,19 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include "magic_enum.hpp" - -export module stormkit.Core:String.Format; - -import std; - -import :Meta; -import :Utils.Numerics; -import :Utils.Math; - export namespace std { template struct formatter: formatter { diff --git a/modules/stormkit/Core/String/Operations.mpp b/include/stormkit/private/Core/String/Operations.inc similarity index 97% rename from modules/stormkit/Core/String/Operations.mpp rename to include/stormkit/private/Core/String/Operations.inc index 9c57d48c..da9f6016 100644 --- a/modules/stormkit/Core/String/Operations.mpp +++ b/include/stormkit/private/Core/String/Operations.inc @@ -1,13 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:String.Operations; - -import std; - -import :Utils.Numerics; - export namespace stormkit::core { [[nodiscard]] auto split(std::string_view string, char delim) noexcept -> std::vector; diff --git a/modules/stormkit/Core/Utils/Algorithms.mpp b/include/stormkit/private/Core/Utils/Algorithms.inc similarity index 95% rename from modules/stormkit/Core/Utils/Algorithms.mpp rename to include/stormkit/private/Core/Utils/Algorithms.inc index d4dcb735..cc74e856 100644 --- a/modules/stormkit/Core/Utils/Algorithms.mpp +++ b/include/stormkit/private/Core/Utils/Algorithms.inc @@ -1,13 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Utils.Algorithms; - -import std; - -import :Meta; - export namespace stormkit::core { template::value_type> Predicate> @@ -105,4 +98,4 @@ namespace stormkit::core { if (predicate(elem)) *it++ = lambda(elem); }); } -} // namespace stormkit::core \ No newline at end of file +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/App.mpp b/include/stormkit/private/Core/Utils/App.inc similarity index 77% rename from modules/stormkit/Core/Utils/App.mpp rename to include/stormkit/private/Core/Utils/App.inc index b9970490..0ef34ea3 100644 --- a/modules/stormkit/Core/Utils/App.mpp +++ b/include/stormkit/private/Core/Utils/App.inc @@ -1,19 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -#include - -export module stormkit.Core:Utils.App; - -import std; - -import :Utils.Numerics; - export namespace stormkit::core { class STORMKIT_API App { public: diff --git a/modules/stormkit/Core/Utils/AsCast.mpp b/include/stormkit/private/Core/Utils/AsCast.inc similarity index 96% rename from modules/stormkit/Core/Utils/AsCast.mpp rename to include/stormkit/private/Core/Utils/AsCast.inc index 794a1665..0edaefc1 100644 --- a/modules/stormkit/Core/Utils/AsCast.mpp +++ b/include/stormkit/private/Core/Utils/AsCast.inc @@ -1,19 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -export module stormkit.Core:Utils.AsCast; - -import std; - -import :Utils.Assert; -import :Meta.Concepts; -import :Meta.Traits; - export namespace stormkit::core { template [[nodiscard]] constexpr auto is(const std::variant& variant) noexcept -> bool; diff --git a/modules/stormkit/Core/Utils/Assert.mpp b/include/stormkit/private/Core/Utils/Assert.inc similarity index 94% rename from modules/stormkit/Core/Utils/Assert.mpp rename to include/stormkit/private/Core/Utils/Assert.inc index 3f3c01b5..3301f4d5 100644 --- a/modules/stormkit/Core/Utils/Assert.mpp +++ b/include/stormkit/private/Core/Utils/Assert.inc @@ -1,22 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -#ifndef STORMKIT_ASSERT -#define STORMKIT_ASSERT 1 -#endif - -export module stormkit.Core:Utils.Assert; - -import std; - -import :Utils.Descriptors; -import :Utils.Stacktrace; - export namespace stormkit::core { enum class AssertType { Assert, @@ -99,7 +83,6 @@ namespace stormkit::core { const std::source_location& location) noexcept { if constexpr (STORMKIT_ASSERT == 1) { if (not cond) [[unlikely]] { - auto stderr = getSTDErr(); std::println(stderr, "[{}] failed in \n" " > file: {}\n" diff --git a/modules/stormkit/Core/Utils/Byte.mpp b/include/stormkit/private/Core/Utils/Byte.inc similarity index 95% rename from modules/stormkit/Core/Utils/Byte.mpp rename to include/stormkit/private/Core/Utils/Byte.inc index 1cda4d22..2c8ca1e6 100644 --- a/modules/stormkit/Core/Utils/Byte.mpp +++ b/include/stormkit/private/Core/Utils/Byte.inc @@ -1,14 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Utils.Byte; - -import std; - -import :Meta; -import :Utils.Numerics; - export namespace stormkit::core { using Byte = std::byte; diff --git a/modules/stormkit/Core/Utils/DeferInit.mpp b/include/stormkit/private/Core/Utils/DeferInit.inc similarity index 97% rename from modules/stormkit/Core/Utils/DeferInit.mpp rename to include/stormkit/private/Core/Utils/DeferInit.inc index 27ecb7b2..bcfb739b 100644 --- a/modules/stormkit/Core/Utils/DeferInit.mpp +++ b/include/stormkit/private/Core/Utils/DeferInit.inc @@ -1,18 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -export module stormkit.Core:Utils.DeferInit; - -import std; - -import :Meta.Traits; -import :Utils.Assert; - export namespace stormkit::core { template class DeferInit { diff --git a/modules/stormkit/Core/Utils/DynamicLoader.mpp b/include/stormkit/private/Core/Utils/DynamicLoader.inc similarity index 92% rename from modules/stormkit/Core/Utils/DynamicLoader.mpp rename to include/stormkit/private/Core/Utils/DynamicLoader.inc index 717a7f37..e91288c3 100644 --- a/modules/stormkit/Core/Utils/DynamicLoader.mpp +++ b/include/stormkit/private/Core/Utils/DynamicLoader.inc @@ -1,20 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -#include - -export module stormkit.Core:Utils.DynamicLoader; - -import std; - -import :Utils.Assert; -import :Utils.Pimpl; - export namespace stormkit::core { class DynamicLoader; diff --git a/modules/stormkit/Core/Utils/ErrorHandling.mpp b/include/stormkit/private/Core/Utils/ErrorHandling.inc similarity index 94% rename from modules/stormkit/Core/Utils/ErrorHandling.mpp rename to include/stormkit/private/Core/Utils/ErrorHandling.inc index d9aa2c86..a3966196 100644 --- a/modules/stormkit/Core/Utils/ErrorHandling.mpp +++ b/include/stormkit/private/Core/Utils/ErrorHandling.inc @@ -1,21 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -export module stormkit.Core:Utils.ErrorHandling; - -import std; - -import :Meta.Concepts; -import :Meta.Traits; - -import :Utils.Descriptors; -import :Utils.Stacktrace; - export namespace stormkit::core { template [[nodiscard]] constexpr auto @@ -59,8 +44,6 @@ namespace stormkit::core { std::source_location location) noexcept -> decltype(auto) { return [message = std::move(message), location = std::move(location)] NORETURN_LAMBDA() -> std::optional { - auto stderr = getSTDErr(); - std::println(stderr, "[Expects] failed in \n" " > file: {}\n" @@ -83,8 +66,6 @@ namespace stormkit::core { template constexpr auto expects(std::source_location location) noexcept -> decltype(auto) { return [location = std::move(location)] NORETURN_LAMBDA(auto&& error) -> std::optional { - auto stderr = getSTDErr(); - std::println(stderr, "[Expects] failed in\n" " > file: {}\n" @@ -108,8 +89,6 @@ namespace stormkit::core { std::source_location location) noexcept -> decltype(auto) { return [message = std::move(message), location = std::move(location)] NORETURN_LAMBDA( auto&& error) -> std::expected> { - auto stderr = getSTDErr(); - std::println(stderr, "[Expects] failed in \n" " > file: {}\n" @@ -134,8 +113,6 @@ namespace stormkit::core { constexpr auto expects(std::source_location location) noexcept -> decltype(auto) { return [location = std::move(location)] NORETURN_LAMBDA( auto&& error) -> std::expected> { - auto stderr = getSTDErr(); - std::println(stderr, "[Expects] failed in\n" " > file: {}\n" diff --git a/modules/stormkit/Core/Utils/Filesystem.mpp b/include/stormkit/private/Core/Utils/Filesystem.inc similarity index 82% rename from modules/stormkit/Core/Utils/Filesystem.mpp rename to include/stormkit/private/Core/Utils/Filesystem.inc index fb651115..681c1c45 100644 --- a/modules/stormkit/Core/Utils/Filesystem.mpp +++ b/include/stormkit/private/Core/Utils/Filesystem.inc @@ -1,14 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Utils.Filesystem; - -import std; - -import :Utils.Byte; -import :Utils.Numerics; - export namespace stormkit::core { [[nodiscard]] auto read(std::istream& stream, RangeExtent size) noexcept -> std::vector; @@ -55,13 +47,14 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - inline auto read(std::istream& stream, std::span output) noexcept -> void { + STORMKIT_FORCE_INLINE auto read(std::istream& stream, std::span output) noexcept -> void { stream.read(std::bit_cast(std::data(output)), std::size(output)); } //////////////////////////////////////// //////////////////////////////////////// - inline auto write(std::ostream& stream, std::span data) noexcept -> void { + STORMKIT_FORCE_INLINE auto write(std::ostream& stream, + std::span data) noexcept -> void { stream.write(std::bit_cast(std::data(data)), std::size(data)); } @@ -78,13 +71,15 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - inline auto readText(std::istream& stream, std::span output) noexcept -> void { + STORMKIT_FORCE_INLINE auto readText(std::istream& stream, + std::span output) noexcept -> void { stream.read(std::data(output), std::size(output)); } //////////////////////////////////////// //////////////////////////////////////// - inline auto writeText(std::ostream& stream, std::string_view data) noexcept -> void { + STORMKIT_FORCE_INLINE auto writeText(std::ostream& stream, + std::string_view data) noexcept -> void { stream.write(std::data(data), std::size(data)); } -} // namespace stormkit::core \ No newline at end of file +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/Flags.mpp b/include/stormkit/private/Core/Utils/Flags.inc similarity index 94% rename from modules/stormkit/Core/Utils/Flags.mpp rename to include/stormkit/private/Core/Utils/Flags.inc index 9b161817..40d3ed9a 100644 --- a/modules/stormkit/Core/Utils/Flags.mpp +++ b/include/stormkit/private/Core/Utils/Flags.inc @@ -1,18 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -export module stormkit.Core:Utils.Flags; - -import std; - -import :Utils.AsCast; -import :Meta; - export { namespace stormkit::core { namespace details { diff --git a/modules/stormkit/Core/Utils/FunctionRef.mpp b/include/stormkit/private/Core/Utils/FunctionRef.inc similarity index 51% rename from modules/stormkit/Core/Utils/FunctionRef.mpp rename to include/stormkit/private/Core/Utils/FunctionRef.inc index 5328daa1..30b44028 100644 --- a/modules/stormkit/Core/Utils/FunctionRef.mpp +++ b/include/stormkit/private/Core/Utils/FunctionRef.inc @@ -1,9 +1,6 @@ -module; - -#include - -export module stormkit.Core:Utils.FunctionRef; - +// Copyright (C) 2023 Arthur LAURENT +// This file is subject to the license terms in the LICENSE file +// found in the top-level of this distribution export namespace stormkit::core { using tl::swap; diff --git a/modules/stormkit/Core/Utils/Functional.mpp b/include/stormkit/private/Core/Utils/Functional.inc similarity index 88% rename from modules/stormkit/Core/Utils/Functional.mpp rename to include/stormkit/private/Core/Utils/Functional.inc index 09f6574c..f8f00208 100644 --- a/modules/stormkit/Core/Utils/Functional.mpp +++ b/include/stormkit/private/Core/Utils/Functional.inc @@ -1,17 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -export module stormkit.Core:Utils.Functional; - -import std; - -import :Meta; - export namespace stormkit::core { [[nodiscard]] constexpr auto either(bool condition, std::invocable auto&& true_, @@ -25,7 +14,7 @@ export namespace stormkit::core { template requires(not IsArithmetic and not IsArithmetic) - [[nodiscard]] constexpr auto isEqual(const T& a, const U& b) noexcept -> bool; + [[nodiscard]] constexpr auto equal(const T& a, const U& b) noexcept -> bool; template // requires(std::invocable) @@ -62,7 +51,7 @@ namespace stormkit::core { ///////////////////////////////////// template requires(not IsArithmetic and not IsArithmetic) - STORMKIT_FORCE_INLINE constexpr auto isEqual(const T& a, const U& b) noexcept -> bool { + STORMKIT_FORCE_INLINE constexpr auto equal(const T& a, const U& b) noexcept -> bool { return a == b; } diff --git a/modules/stormkit/Core/Utils/Handle.mpp b/include/stormkit/private/Core/Utils/Handle.inc similarity index 91% rename from modules/stormkit/Core/Utils/Handle.mpp rename to include/stormkit/private/Core/Utils/Handle.inc index f881dabc..881ca0e9 100644 --- a/modules/stormkit/Core/Utils/Handle.mpp +++ b/include/stormkit/private/Core/Utils/Handle.inc @@ -1,22 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -#include - -export module stormkit.Core:Utils.Handle; - -import std; - -import :Hash; -import :Utils.AsCast; -import :Utils.Numerics; -import :Meta; - export { namespace stormkit::core { template @@ -129,4 +113,4 @@ template constexpr stormkit::core::Hash64 std::hash>::operator()( stormkit::core::Handle handle) const noexcept { return stormkit::core::as(handle.id); -} \ No newline at end of file +} diff --git a/modules/stormkit/Core/Utils/Monadic.mpp b/include/stormkit/private/Core/Utils/Monadic.inc similarity index 76% rename from modules/stormkit/Core/Utils/Monadic.mpp rename to include/stormkit/private/Core/Utils/Monadic.inc index fff20192..7dd00fd2 100644 --- a/modules/stormkit/Core/Utils/Monadic.mpp +++ b/include/stormkit/private/Core/Utils/Monadic.inc @@ -1,20 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -export module stormkit.Core:Utils.Monadic; - -import std; - -import :Meta; - -import :Utils.AsCast; -import :Utils.Functional; - export namespace stormkit::core::monadic { struct Anything { template @@ -47,7 +33,7 @@ export namespace stormkit::core::monadic { std::invocable auto&& true_, std::invocable auto&& false_) noexcept -> decltype(auto); - [[nodiscard]] constexpr auto isEqual() noexcept -> decltype(auto); + [[nodiscard]] constexpr auto equal() noexcept -> decltype(auto); [[nodiscard]] constexpr auto clone() noexcept -> decltype(auto); @@ -56,6 +42,14 @@ export namespace stormkit::core::monadic { template [[nodiscard]] constexpr auto init(Args&&... args) noexcept -> decltype(auto); + + [[nodiscard]] constexpr auto equal(auto&& value) noexcept; + + [[nodiscard]] constexpr auto appendTo(std::ranges::range auto& range) noexcept; + + [[nodiscard]] constexpr auto wrap(std::invocable auto&& func) noexcept; + + [[nodiscard]] constexpr auto asByte() noexcept; } // namespace stormkit::core::monadic //////////////////////////////////////////////////////////////////// @@ -110,8 +104,8 @@ namespace stormkit::core::monadic { template First, std::invocable&&> Second> - STORMKIT_FORCE_INLINE constexpr auto map(First&& first, Second&& second) noexcept - -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto map(First&& first, + Second&& second) noexcept -> decltype(auto) { return [first = std::forward(first), second = std::forward(second)](T&& args) noexcept -> decltype(auto) { @@ -121,8 +115,8 @@ namespace stormkit::core::monadic { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto map(auto&& first, auto&& second) noexcept - -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto map(auto&& first, + auto&& second) noexcept -> decltype(auto) { return [first = std::forward(first), second = std::forward(second)]( auto&&... args) noexcept -> decltype(auto) { @@ -133,10 +127,10 @@ namespace stormkit::core::monadic { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE constexpr auto either(IsUnaryPredicate auto&& predicate, - std::invocable auto&& true_, - std::invocable auto&& false_) noexcept - -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto + either(IsUnaryPredicate auto&& predicate, + std::invocable auto&& true_, + std::invocable auto&& false_) noexcept -> decltype(auto) { [predicate = std::move(predicate), true_ = std::move(true_), false_ = std::move(false_)]( auto&& elem) noexcept -> decltype(auto) { if (predicate(elem)) return first(std::forward(elem)); @@ -146,9 +140,9 @@ namespace stormkit::core::monadic { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto isEqual() noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto equal() noexcept -> decltype(auto) { return [](const auto& first, const auto& second) noexcept { - return core::isEqual(first, second); + return core::equal(first, second); }; } @@ -191,4 +185,34 @@ namespace stormkit::core::monadic { return T { std::forward(args)... }; }; } + + //////////////////////////////////////// + //////////////////////////////////////// + STORMKIT_FORCE_INLINE constexpr auto equal(auto&& value) noexcept { + return [value = std::forward(value)](auto&& other) { + return core::equal(value, other); + }; + } + + //////////////////////////////////////// + //////////////////////////////////////// + STORMKIT_FORCE_INLINE constexpr auto appendTo(std::ranges::range auto& range) noexcept { + return [&range](auto&& val) { + range.emplace(std::ranges::cend(range), std::forward(val)); + }; + } + + //////////////////////////////////////// + //////////////////////////////////////// + STORMKIT_FORCE_INLINE constexpr auto wrap(std::invocable auto&& func) noexcept { + return [func = std::forward(func)](auto&&... args) { + return func(std::forward(args)...); + }; + } + + //////////////////////////////////////// + //////////////////////////////////////// + STORMKIT_FORCE_INLINE constexpr auto asByte() noexcept { + return [](auto&& val) { return static_cast(val); }; + } } // namespace stormkit::core::monadic diff --git a/modules/stormkit/Core/Utils/NakedRef.mpp b/include/stormkit/private/Core/Utils/NakedRef.inc similarity index 97% rename from modules/stormkit/Core/Utils/NakedRef.mpp rename to include/stormkit/private/Core/Utils/NakedRef.inc index 565b4dbf..04ac360b 100644 --- a/modules/stormkit/Core/Utils/NakedRef.mpp +++ b/include/stormkit/private/Core/Utils/NakedRef.inc @@ -1,15 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Utils.NakedRef; - -import std; - -import :Meta.Concepts; -import :Meta.Traits; -import :Utils.Assert; - export namespace stormkit::core { template class NakedRef { diff --git a/modules/stormkit/Core/Meta/NamedType.mpp b/include/stormkit/private/Core/Utils/NamedType.inc similarity index 88% rename from modules/stormkit/Core/Meta/NamedType.mpp rename to include/stormkit/private/Core/Utils/NamedType.inc index e287ba98..0b7e98f7 100644 --- a/modules/stormkit/Core/Meta/NamedType.mpp +++ b/include/stormkit/private/Core/Utils/NamedType.inc @@ -1,20 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -module; - -#include - -#include - -export module stormkit.Core:Meta.NamedType; - -import std; - -// import :Hash; -import :Utils.Numerics; - export { namespace stormkit::core { class NamedTypeBase {}; @@ -45,9 +31,8 @@ export { constexpr NamedType(NamedType&&) noexcept( std::is_nothrow_move_constructible_v); - constexpr auto - operator=(NamedType&&) noexcept(std::is_nothrow_move_assignable_v) - -> NamedType&; + constexpr auto operator=(NamedType&&) noexcept( + std::is_nothrow_move_assignable_v) -> NamedType&; [[nodiscard]] constexpr auto get(this auto&& self) noexcept -> decltype(auto); @@ -80,8 +65,8 @@ export { }; struct BinaryAddable { - [[nodiscard]] constexpr auto operator+(this auto&& self, auto&& other) - -> decltype(auto); + [[nodiscard]] constexpr auto operator+(this auto&& self, + auto&& other) -> decltype(auto); constexpr auto operator+=(this auto&& self, auto&& other) -> decltype(auto); }; @@ -92,8 +77,8 @@ export { struct Addable: BinaryAddable, UnaryAddable {}; struct BinarySubtractable { - [[nodiscard]] constexpr auto operator-(this auto&& self, auto&& other) - -> decltype(auto); + [[nodiscard]] constexpr auto operator-(this auto&& self, + auto&& other) -> decltype(auto); constexpr auto operator-=(this auto&& self, auto&& other) -> decltype(auto); }; @@ -104,20 +89,20 @@ export { struct Subtractable: BinarySubtractable, UnarySubtractable {}; struct Multiplicable { - [[nodiscard]] constexpr auto operator*(this auto&& self, auto&& other) - -> decltype(auto); + [[nodiscard]] constexpr auto operator*(this auto&& self, + auto&& other) -> decltype(auto); constexpr auto operator*=(this auto&& self, auto&& other) -> decltype(auto); }; struct Divisible { - [[nodiscard]] constexpr auto operator/(this auto&& self, auto&& other) - -> decltype(auto); + [[nodiscard]] constexpr auto operator/(this auto&& self, + auto&& other) -> decltype(auto); constexpr auto operator/=(this auto&& self, auto&& other) -> decltype(auto); }; struct Modulable { - [[nodiscard]] constexpr auto operator%(this auto&& self, auto&& other) - -> decltype(auto); + [[nodiscard]] constexpr auto operator%(this auto&& self, + auto&& other) -> decltype(auto); constexpr auto operator%=(this auto&& self, auto&& other) -> decltype(auto); }; @@ -126,38 +111,38 @@ export { }; struct BitWiseAndable { - [[nodiscard]] constexpr auto operator&(this auto&& self, auto&& other) - -> decltype(auto); + [[nodiscard]] constexpr auto operator&(this auto&& self, + auto&& other) -> decltype(auto); constexpr auto operator&=(this auto&& self, auto&& other) -> decltype(auto); }; struct BitWiseOrable { - [[nodiscard]] constexpr auto operator|(this auto&& self, auto&& other) - -> decltype(auto); + [[nodiscard]] constexpr auto operator|(this auto&& self, + auto&& other) -> decltype(auto); constexpr auto operator|=(this auto&& self, auto&& other) -> decltype(auto); }; struct BitWiseXorable { - [[nodiscard]] constexpr auto operator^(this auto&& self, auto&& other) - -> decltype(auto); + [[nodiscard]] constexpr auto operator^(this auto&& self, + auto&& other) -> decltype(auto); constexpr auto operator^=(this auto&& self, auto&& other) -> decltype(auto); }; struct BitWiseLeftShiftable { - [[nodiscard]] constexpr auto operator<<(this auto&& self, auto&& other) - -> decltype(auto); + [[nodiscard]] constexpr auto operator<<(this auto&& self, + auto&& other) -> decltype(auto); constexpr auto operator<<=(this auto&& self, auto&& other) -> decltype(auto); }; struct BitWiseRightShiftable { - [[nodiscard]] constexpr auto operator>>(this auto&& self, auto&& other) - -> decltype(auto); + [[nodiscard]] constexpr auto operator>>(this auto&& self, + auto&& other) -> decltype(auto); constexpr auto operator>>=(this auto&& self, auto&& other) -> decltype(auto); }; struct Comparable { - [[nodiscard]] constexpr auto operator<=>(this auto&& self, auto&& other) noexcept - -> std::strong_ordering; + [[nodiscard]] constexpr auto operator<=>(this auto&& self, + auto&& other) noexcept -> std::strong_ordering; }; struct Dereferencable { @@ -319,8 +304,8 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - constexpr auto BinarySubtractable::operator-=(this auto&& self, auto&& other) - -> decltype(auto) { + constexpr auto BinarySubtractable::operator-=(this auto&& self, + auto&& other) -> decltype(auto) { auto&& val = std::forward(self).get(); val -= std::forward(other).get(); return val; @@ -430,16 +415,16 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - constexpr auto BitWiseLeftShiftable::operator<<(this auto&& self, auto&& other) - -> decltype(auto) { + constexpr auto BitWiseLeftShiftable::operator<<(this auto&& self, + auto&& other) -> decltype(auto) { return std::forward(self).get() << std::forward(other).get(); } //////////////////////////////////////// //////////////////////////////////////// - constexpr auto BitWiseLeftShiftable::operator<<=(this auto&& self, auto&& other) - -> decltype(auto) { + constexpr auto BitWiseLeftShiftable::operator<<=(this auto&& self, + auto&& other) -> decltype(auto) { auto&& val = std::forward(self).get(); val <<= std::forward(other).get(); return val; @@ -447,16 +432,16 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - constexpr auto BitWiseRightShiftable::operator>>(this auto&& self, auto&& other) - -> decltype(auto) { + constexpr auto BitWiseRightShiftable::operator>>(this auto&& self, + auto&& other) -> decltype(auto) { return std::forward(self).get() >> std::forward(other).get(); } //////////////////////////////////////// //////////////////////////////////////// - constexpr auto BitWiseRightShiftable::operator>>=(this auto&& self, auto&& other) - -> decltype(auto) { + constexpr auto BitWiseRightShiftable::operator>>=(this auto&& self, + auto&& other) -> decltype(auto) { auto&& val = std::forward(self).get(); val >>= std::forward(other).get(); return val; @@ -464,8 +449,8 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - constexpr auto Comparable::operator<=>(this auto&& self, auto&& other) noexcept - -> std::strong_ordering { + constexpr auto Comparable::operator<=>(this auto&& self, + auto&& other) noexcept -> std::strong_ordering { return std::forward(self).get() <=> std::forward(other).get(); } @@ -488,4 +473,4 @@ namespace stormkit::core { constexpr auto MethodCallable::operator->(this auto&& self) -> decltype(auto) { return std::addressof(std::forward(self).get()); } -} // namespace stormkit::core \ No newline at end of file +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/Pimpl.mpp b/include/stormkit/private/Core/Utils/Pimpl.inc similarity index 93% rename from modules/stormkit/Core/Utils/Pimpl.mpp rename to include/stormkit/private/Core/Utils/Pimpl.inc index 8e72cc4c..e64a4dea 100644 --- a/modules/stormkit/Core/Utils/Pimpl.mpp +++ b/include/stormkit/private/Core/Utils/Pimpl.inc @@ -1,15 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Utils.Pimpl; - -import std; - -import :Meta; -import :Utils.Assert; -import :Utils.Expected; - export namespace stormkit::core { template class Pimpl { @@ -135,4 +126,4 @@ namespace stormkit::core { Pimpl::operator bool() const noexcept { return m_data != nullptr; } -} // namespace stormkit::core \ No newline at end of file +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/Random.mpp b/include/stormkit/private/Core/Utils/Random.inc similarity index 78% rename from modules/stormkit/Core/Utils/Random.mpp rename to include/stormkit/private/Core/Utils/Random.inc index 9636a849..99414e3a 100644 --- a/modules/stormkit/Core/Utils/Random.mpp +++ b/include/stormkit/private/Core/Utils/Random.inc @@ -1,14 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Utils.Random; - -import std; - -import :Utils.Numerics; -import :Meta.Concepts; - export namespace stormkit::core { auto seed(Int seed) noexcept -> void; @@ -30,20 +22,20 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - inline auto randomGenerator() noexcept -> std::default_random_engine& { + STORMKIT_FORCE_INLINE auto randomGenerator() noexcept -> std::default_random_engine& { return generator; } ///////////////////////////////////// ///////////////////////////////////// - inline auto seed(Int seed) noexcept -> void { + STORMKIT_FORCE_INLINE auto seed(Int seed) noexcept -> void { randomGenerator().seed(seed); } ///////////////////////////////////// ///////////////////////////////////// template - auto rand(T min, T max) noexcept -> T { + STORMKIT_FORCE_INLINE auto rand(T min, T max) noexcept -> T { std::uniform_real_distribution dis(min, max); return dis(randomGenerator()); } @@ -51,8 +43,8 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - auto rand(T min, T max) noexcept -> T { + STORMKIT_FORCE_INLINE auto rand(T min, T max) noexcept -> T { std::uniform_int_distribution dis(min, max); return dis(randomGenerator()); } -} // namespace stormkit::core \ No newline at end of file +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/Singleton.mpp b/include/stormkit/private/Core/Utils/Singleton.inc similarity index 92% rename from modules/stormkit/Core/Utils/Singleton.mpp rename to include/stormkit/private/Core/Utils/Singleton.inc index 883d9e78..548c02b8 100644 --- a/modules/stormkit/Core/Utils/Singleton.mpp +++ b/include/stormkit/private/Core/Utils/Singleton.inc @@ -1,11 +1,6 @@ // Copyright (C) 2023 Arthur LAURENT // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - -export module stormkit.Core:Utils.Singleton; - -import std; - export namespace stormkit::core { template class Singleton { @@ -56,4 +51,4 @@ namespace stormkit::core { static auto once_flag = std::once_flag {}; return once_flag; } -} // namespace stormkit::core \ No newline at end of file +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/Stacktrace.mpp b/include/stormkit/private/Core/Utils/Stacktrace.inc similarity index 88% rename from modules/stormkit/Core/Utils/Stacktrace.mpp rename to include/stormkit/private/Core/Utils/Stacktrace.inc index 32282dfe..744de477 100644 --- a/modules/stormkit/Core/Utils/Stacktrace.mpp +++ b/include/stormkit/private/Core/Utils/Stacktrace.inc @@ -1,23 +1,6 @@ -module; - -#include - -#include -#include - -#if defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L - #define STD_STACKTRACE_SUPPORTED -#elif defined(STORMKIT_OS_LINUX) - #define BACKTRACE_SUPPORTED - #include - #include - #include -#endif - -export module stormkit.Core:Utils.Stacktrace; - -import std; - +// Copyright (C) 2023 Arthur LAURENT +// This file is subject to the license terms in the LICENSE file +// found in the top-level of this distribution export namespace stormkit::core { auto printStacktrace(); #if defined(BACKTRACE_SUPPORTED) diff --git a/modules/stormkit/Core.mpp b/modules/stormkit/Core.mpp index 19c02d6c..2cf6910d 100644 --- a/modules/stormkit/Core.mpp +++ b/modules/stormkit/Core.mpp @@ -4,15 +4,14 @@ export module stormkit.Core; -// clang-format off - -// clang-format on - +export import :Color; export import :Configuration; export import :Containers; export import :Coroutines; export import :Hash; export import :Meta; +export import :Math; +export import :Numerics; export import :Parallelism; export import :String; export import :Utils; diff --git a/modules/stormkit/Core/Utils/Color.mpp b/modules/stormkit/Core/Color.mpp similarity index 97% rename from modules/stormkit/Core/Utils/Color.mpp rename to modules/stormkit/Core/Color.mpp index 8faac09f..b5c3a4f8 100644 --- a/modules/stormkit/Core/Utils/Color.mpp +++ b/modules/stormkit/Core/Color.mpp @@ -1,333 +1,332 @@ -// Copyright (C) 2023 Arthur LAURENT -// This file is subject to the license terms in the LICENSE file -// found in the top-level of this distribution - -module; - -#include - -#include - -export module stormkit.Core:Utils.Color; - -import std; - -import :Hash; -import :Utils.Numerics; -import :Utils.Math; -import :Meta; - -export { - namespace stormkit::core { - constexpr auto colorComponentAs(UInt8 component) noexcept -> float; - - constexpr auto colorComponentAs(float component) noexcept -> UInt8; - - template - constexpr auto maxColorComponentValue() noexcept -> T; - - template - struct RGBColor { - using UnderlyingType = T; - - constexpr RGBColor( - UnderlyingType red, - UnderlyingType green, - UnderlyingType blue, - UnderlyingType alpha = maxColorComponentValue()) noexcept; - - constexpr explicit RGBColor(const math::Vector3& vector) noexcept; - - constexpr explicit RGBColor(const math::Vector4& vector) noexcept; - - constexpr RGBColor(const RGBColor& other) noexcept; - constexpr auto operator=(const RGBColor& other) noexcept -> RGBColor&; - - constexpr RGBColor(RGBColor&& other) noexcept; - constexpr auto operator=(RGBColor&& other) noexcept -> RGBColor&; - - template - constexpr RGBColor(const RGBColor& other) noexcept; - - template - constexpr auto operator=(const RGBColor& other) noexcept -> RGBColor&; - - constexpr auto toVector3() const noexcept -> math::Vector3; - constexpr auto toVector4() const noexcept -> math::Vector4; - - constexpr operator math::Vector3() const noexcept; - constexpr operator math::Vector4() const noexcept; - constexpr operator std::array() const noexcept; - - UnderlyingType red; - UnderlyingType green; - UnderlyingType blue; - UnderlyingType alpha; - }; - - using RGBColorU = RGBColor; - using RGBColorF = RGBColor; - - /// This namespace contain preset colors, these colors are defined from [HTML 4.01 - /// colors](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names). - ///``` - /// | name | red |green|blue |alpha| - /// |-------------|-----|-----|-----|-----| - /// | Black | 0 | 0 | 0 | 255 | - /// | Gray | 127 | 127 | 127 | 255 | - /// | Silver | 190 | 190 | 190 | 255 | - /// | White | 255 | 255 | 255 | 255 | - /// | Maroon | 127 | 0 | 0 | 255 | - /// | Red | 255 | 0 | 0 | 255 | - /// | Olive | 127 | 127 | 0 | 255 | - /// | Yellow | 255 | 255 | 0 | 255 | - /// | Green | 0 | 127 | 0 | 255 | - /// | Lime | 0 | 255 | 0 | 255 | - /// | Teal | 0 | 127 | 127 | 255 | - /// | Aqua | 0 | 255 | 255 | 255 | - /// | Navy | 0 | 0 | 127 | 255 | - /// | Blue | 0 | 0 | 255 | 255 | - /// | Purple | 127 | 0 | 127 | 255 | - /// | Fuschia | 255 | 0 | 255 | 255 | - /// | Transparent | 0 | 0 | 0 | 0 | - ///``` - namespace RGBColorDef { - template - inline constexpr auto Black = - RGBColor { T { 0 }, T { 0 }, T { 0 }, maxColorComponentValue() }; - - template - inline constexpr auto Gray = RGBColor { maxColorComponentValue() / T { 2 }, - maxColorComponentValue() / T { 2 }, - maxColorComponentValue() / T { 2 }, - maxColorComponentValue() }; - - template - inline constexpr auto Silver = RGBColor { - (maxColorComponentValue() / T { 2 }) + (maxColorComponentValue() / T { 4 }), - (maxColorComponentValue() / T { 2 }) + (maxColorComponentValue() / T { 4 }), - (maxColorComponentValue() / T { 2 }) + (maxColorComponentValue() / T { 4 }), - maxColorComponentValue() - }; - - template - inline constexpr auto White = RGBColor { maxColorComponentValue(), - maxColorComponentValue(), - maxColorComponentValue(), - maxColorComponentValue() }; - - template - inline constexpr auto Maroon = RGBColor { maxColorComponentValue() / T { 2 }, - T { 0 }, - T { 0 }, - maxColorComponentValue() }; - - template - inline constexpr auto Red = RGBColor { maxColorComponentValue(), - T { 0 }, - T { 0 }, - maxColorComponentValue() }; - - template - inline constexpr auto Olive = RGBColor { maxColorComponentValue() / T { 2 }, - maxColorComponentValue() / T { 2 }, - T { 0 }, - maxColorComponentValue() }; - - template - inline constexpr auto Yellow = RGBColor { maxColorComponentValue(), - maxColorComponentValue(), - T { 0 }, - maxColorComponentValue() }; - template - inline constexpr auto Green = RGBColor { T { 0 }, - maxColorComponentValue() / T { 2 }, - T { 0 }, - maxColorComponentValue() }; - - template - inline constexpr auto Lime = RGBColor { T { 0 }, - maxColorComponentValue(), - T { 0 }, - maxColorComponentValue() }; - - template - inline constexpr auto Teal = RGBColor { T { 0 }, - maxColorComponentValue() / T { 2 }, - maxColorComponentValue() / T { 2 }, - maxColorComponentValue() }; - - template - inline constexpr auto Aqua = RGBColor { T { 0 }, - maxColorComponentValue(), - maxColorComponentValue(), - maxColorComponentValue() }; - - template - inline constexpr auto Navy = RGBColor { T { 0 }, - T { 0 }, - maxColorComponentValue() / T { 2 }, - maxColorComponentValue() }; - - template - inline constexpr auto Blue = RGBColor { T { 0 }, - T { 0 }, - maxColorComponentValue(), - maxColorComponentValue() }; - - template - inline constexpr auto Purple = RGBColor { maxColorComponentValue() / T { 2 }, - T { 0 }, - maxColorComponentValue() / T { 2 }, - maxColorComponentValue() }; - - template - inline constexpr auto Fuchsia = RGBColor { maxColorComponentValue(), - T { 0 }, - maxColorComponentValue(), - maxColorComponentValue() }; - - template - inline constexpr auto Transparent = RGBColor { T { 0 }, T { 0 }, T { 0 }, T { 0 } }; - } // namespace RGBColorDef - - } // namespace stormkit::core - - TEMPLATED_HASH_EQUAL_FUNC(stormkit::core::RGBColor, - stormkit::core::IsColorComponent, - T, - value.r, - value.g, - value.b, - value.a) -} - -//////////////////////////////////////////////////////////////////// -/// IMPLEMENTATION /// -//////////////////////////////////////////////////////////////////// - -namespace stormkit::core { - ///////////////////////////////////// - ///////////////////////////////////// - constexpr auto colorComponentAs(UInt8 component) noexcept -> float { - return narrow(component) / 255.f; - } - - ///////////////////////////////////// - ///////////////////////////////////// - constexpr auto colorComponentAs(float component) noexcept -> UInt8 { - expects(component <= 1.f); - return narrow(component * 255u); - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto maxColorComponentValue() noexcept -> T { - if constexpr (std::is_same_v) return 1.f; - - return 255u; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr RGBColor::RGBColor(UnderlyingType _red, - UnderlyingType _green, - UnderlyingType _blue, - UnderlyingType _alpha) noexcept - : red { _red }, green { _green }, blue { _blue }, alpha { _alpha } { - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr RGBColor::RGBColor(const math::Vector3& vector) noexcept - : red { vector.r }, green { vector.g }, blue { vector.b }, - alpha(maxColorComponentValue()) { - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr RGBColor::RGBColor(const math::Vector4& vector) noexcept - : red { vector.r }, green { vector.g }, blue { vector.b }, alpha { vector.a } { - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr RGBColor::RGBColor(const RGBColor& other) noexcept = default; - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto RGBColor::operator=(const RGBColor& other) noexcept - -> RGBColor& = default; - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr RGBColor::RGBColor(RGBColor&& other) noexcept = default; - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto RGBColor::operator=(RGBColor&& other) noexcept - -> RGBColor& = default; - - ///////////////////////////////////// - ///////////////////////////////////// - template - template - constexpr RGBColor::RGBColor(const RGBColor& other) noexcept - : red { colorComponentAs(other.red) }, green { colorComponentAs(other.green) }, - blue { colorComponentAs(other.blue) }, alpha { colorComponentAs(other.alpha) } { - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - template - constexpr auto RGBColor::operator=(const RGBColor& other) noexcept -> RGBColor& { - red = colorComponentAs(other.red); - green = colorComponentAs(other.green); - blue = colorComponentAs(other.blue); - alpha = colorComponentAs(other.alpha); - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto RGBColor::toVector3() const noexcept -> math::Vector3 { - return { red, green, blue }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto RGBColor::toVector4() const noexcept -> math::Vector4 { - return { red, green, blue, alpha }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr RGBColor::operator math::Vector3() const noexcept { - return toVector3(); - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr RGBColor::operator math::Vector4() const noexcept { - return toVector4(); - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr RGBColor::operator std::array() const noexcept { - return { red, green, blue, alpha }; - } -} // namespace stormkit::core +// Copyright (C) 2023 Arthur LAURENT +// This file is subject to the license terms in the LICENSE file +// found in the top-level of this distribution +module; + +#include +#include + +export module stormkit.Core:Color; + +import std; + +import :Utils; +import :Math; +import :Numerics; +import :Meta; +import :Hash; + +export { + namespace stormkit::core { + constexpr auto colorComponentAs(UInt8 component) noexcept -> float; + + constexpr auto colorComponentAs(float component) noexcept -> UInt8; + + template + constexpr auto maxColorComponentValue() noexcept -> T; + + template + struct RGBColor { + using UnderlyingType = T; + + constexpr RGBColor( + UnderlyingType red, + UnderlyingType green, + UnderlyingType blue, + UnderlyingType alpha = maxColorComponentValue()) noexcept; + + constexpr explicit RGBColor(const math::Vector3& vector) noexcept; + + constexpr explicit RGBColor(const math::Vector4& vector) noexcept; + + constexpr RGBColor(const RGBColor& other) noexcept; + constexpr auto operator=(const RGBColor& other) noexcept -> RGBColor&; + + constexpr RGBColor(RGBColor&& other) noexcept; + constexpr auto operator=(RGBColor&& other) noexcept -> RGBColor&; + + template + constexpr RGBColor(const RGBColor& other) noexcept; + + template + constexpr auto operator=(const RGBColor& other) noexcept -> RGBColor&; + + constexpr auto toVector3() const noexcept -> math::Vector3; + constexpr auto toVector4() const noexcept -> math::Vector4; + + constexpr operator math::Vector3() const noexcept; + constexpr operator math::Vector4() const noexcept; + constexpr operator std::array() const noexcept; + + UnderlyingType red; + UnderlyingType green; + UnderlyingType blue; + UnderlyingType alpha; + }; + + using RGBColorU = RGBColor; + using RGBColorF = RGBColor; + + /// This namespace contain preset colors, these colors are defined from [HTML 4.01 + /// colors](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names). + ///``` + /// | name | red |green|blue |alpha| + /// |-------------|-----|-----|-----|-----| + /// | Black | 0 | 0 | 0 | 255 | + /// | Gray | 127 | 127 | 127 | 255 | + /// | Silver | 190 | 190 | 190 | 255 | + /// | White | 255 | 255 | 255 | 255 | + /// | Maroon | 127 | 0 | 0 | 255 | + /// | Red | 255 | 0 | 0 | 255 | + /// | Olive | 127 | 127 | 0 | 255 | + /// | Yellow | 255 | 255 | 0 | 255 | + /// | Green | 0 | 127 | 0 | 255 | + /// | Lime | 0 | 255 | 0 | 255 | + /// | Teal | 0 | 127 | 127 | 255 | + /// | Aqua | 0 | 255 | 255 | 255 | + /// | Navy | 0 | 0 | 127 | 255 | + /// | Blue | 0 | 0 | 255 | 255 | + /// | Purple | 127 | 0 | 127 | 255 | + /// | Fuschia | 255 | 0 | 255 | 255 | + /// | Transparent | 0 | 0 | 0 | 0 | + ///``` + namespace RGBColorDef { + template + inline constexpr auto Black = + RGBColor { T { 0 }, T { 0 }, T { 0 }, maxColorComponentValue() }; + + template + inline constexpr auto Gray = RGBColor { maxColorComponentValue() / T { 2 }, + maxColorComponentValue() / T { 2 }, + maxColorComponentValue() / T { 2 }, + maxColorComponentValue() }; + + template + inline constexpr auto Silver = RGBColor { + (maxColorComponentValue() / T { 2 }) + (maxColorComponentValue() / T { 4 }), + (maxColorComponentValue() / T { 2 }) + (maxColorComponentValue() / T { 4 }), + (maxColorComponentValue() / T { 2 }) + (maxColorComponentValue() / T { 4 }), + maxColorComponentValue() + }; + + template + inline constexpr auto White = RGBColor { maxColorComponentValue(), + maxColorComponentValue(), + maxColorComponentValue(), + maxColorComponentValue() }; + + template + inline constexpr auto Maroon = RGBColor { maxColorComponentValue() / T { 2 }, + T { 0 }, + T { 0 }, + maxColorComponentValue() }; + + template + inline constexpr auto Red = RGBColor { maxColorComponentValue(), + T { 0 }, + T { 0 }, + maxColorComponentValue() }; + + template + inline constexpr auto Olive = RGBColor { maxColorComponentValue() / T { 2 }, + maxColorComponentValue() / T { 2 }, + T { 0 }, + maxColorComponentValue() }; + + template + inline constexpr auto Yellow = RGBColor { maxColorComponentValue(), + maxColorComponentValue(), + T { 0 }, + maxColorComponentValue() }; + template + inline constexpr auto Green = RGBColor { T { 0 }, + maxColorComponentValue() / T { 2 }, + T { 0 }, + maxColorComponentValue() }; + + template + inline constexpr auto Lime = RGBColor { T { 0 }, + maxColorComponentValue(), + T { 0 }, + maxColorComponentValue() }; + + template + inline constexpr auto Teal = RGBColor { T { 0 }, + maxColorComponentValue() / T { 2 }, + maxColorComponentValue() / T { 2 }, + maxColorComponentValue() }; + + template + inline constexpr auto Aqua = RGBColor { T { 0 }, + maxColorComponentValue(), + maxColorComponentValue(), + maxColorComponentValue() }; + + template + inline constexpr auto Navy = RGBColor { T { 0 }, + T { 0 }, + maxColorComponentValue() / T { 2 }, + maxColorComponentValue() }; + + template + inline constexpr auto Blue = RGBColor { T { 0 }, + T { 0 }, + maxColorComponentValue(), + maxColorComponentValue() }; + + template + inline constexpr auto Purple = RGBColor { maxColorComponentValue() / T { 2 }, + T { 0 }, + maxColorComponentValue() / T { 2 }, + maxColorComponentValue() }; + + template + inline constexpr auto Fuchsia = RGBColor { maxColorComponentValue(), + T { 0 }, + maxColorComponentValue(), + maxColorComponentValue() }; + + template + inline constexpr auto Transparent = RGBColor { T { 0 }, T { 0 }, T { 0 }, T { 0 } }; + } // namespace RGBColorDef + + } // namespace stormkit::core + + TEMPLATED_HASH_EQUAL_FUNC(stormkit::core::RGBColor, + stormkit::core::IsColorComponent, + T, + value.r, + value.g, + value.b, + value.a) +} + +//////////////////////////////////////////////////////////////////// +/// IMPLEMENTATION /// +//////////////////////////////////////////////////////////////////// + +namespace stormkit::core { + ///////////////////////////////////// + ///////////////////////////////////// + constexpr auto colorComponentAs(UInt8 component) noexcept -> float { + return narrow(component) / 255.f; + } + + ///////////////////////////////////// + ///////////////////////////////////// + constexpr auto colorComponentAs(float component) noexcept -> UInt8 { + expects(component <= 1.f); + return narrow(component * 255u); + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto maxColorComponentValue() noexcept -> T { + if constexpr (std::is_same_v) return 1.f; + + return 255u; + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr RGBColor::RGBColor(UnderlyingType _red, + UnderlyingType _green, + UnderlyingType _blue, + UnderlyingType _alpha) noexcept + : red { _red }, green { _green }, blue { _blue }, alpha { _alpha } { + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr RGBColor::RGBColor(const math::Vector3& vector) noexcept + : red { vector.r }, green { vector.g }, blue { vector.b }, + alpha(maxColorComponentValue()) { + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr RGBColor::RGBColor(const math::Vector4& vector) noexcept + : red { vector.r }, green { vector.g }, blue { vector.b }, alpha { vector.a } { + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr RGBColor::RGBColor(const RGBColor& other) noexcept = default; + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto RGBColor::operator=(const RGBColor& other) noexcept + -> RGBColor& = default; + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr RGBColor::RGBColor(RGBColor&& other) noexcept = default; + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto RGBColor::operator=(RGBColor&& other) noexcept + -> RGBColor& = default; + + ///////////////////////////////////// + ///////////////////////////////////// + template + template + constexpr RGBColor::RGBColor(const RGBColor& other) noexcept + : red { colorComponentAs(other.red) }, green { colorComponentAs(other.green) }, + blue { colorComponentAs(other.blue) }, alpha { colorComponentAs(other.alpha) } { + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + template + constexpr auto RGBColor::operator=(const RGBColor& other) noexcept -> RGBColor& { + red = colorComponentAs(other.red); + green = colorComponentAs(other.green); + blue = colorComponentAs(other.blue); + alpha = colorComponentAs(other.alpha); + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto RGBColor::toVector3() const noexcept -> math::Vector3 { + return { red, green, blue }; + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto RGBColor::toVector4() const noexcept -> math::Vector4 { + return { red, green, blue, alpha }; + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr RGBColor::operator math::Vector3() const noexcept { + return toVector3(); + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr RGBColor::operator math::Vector4() const noexcept { + return toVector4(); + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr RGBColor::operator std::array() const noexcept { + return { red, green, blue, alpha }; + } +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Containers.mpp b/modules/stormkit/Core/Containers.mpp index 022ddcf6..69e57884 100644 --- a/modules/stormkit/Core/Containers.mpp +++ b/modules/stormkit/Core/Containers.mpp @@ -2,8 +2,19 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution +module; + +#include +#include + export module stormkit.Core:Containers; -export import :Containers.RingBuffer; -export import :Containers.Tree; -export import :Containers.Utils; +import std; + +import :Utils; +import :Numerics; +import :Meta; + +#include +#include +#include diff --git a/modules/stormkit/Core/Hash.mpp b/modules/stormkit/Core/Hash.mpp index 171125d1..e830c5c8 100644 --- a/modules/stormkit/Core/Hash.mpp +++ b/modules/stormkit/Core/Hash.mpp @@ -4,6 +4,11 @@ export module stormkit.Core:Hash; -export import :Hash.Base; -export import :Hash.HashMap; -export import :Hash.StringHash; +import std; +import ankerl.unordered_dense; + +import :Meta; + +#include +#include +#include diff --git a/modules/stormkit/Core/Utils/Math.mpp b/modules/stormkit/Core/Math.mpp similarity index 92% rename from modules/stormkit/Core/Utils/Math.mpp rename to modules/stormkit/Core/Math.mpp index 2ba6ed38..63c6ad2e 100644 --- a/modules/stormkit/Core/Utils/Math.mpp +++ b/modules/stormkit/Core/Math.mpp @@ -1,534 +1,532 @@ -// Copyright (C) 2023 Arthur LAURENT -// This file is subject to the license terms in the LICENSE file -// found in the top-level of this distribution - -module; - -#include - -#include -#include - -#include - -export module stormkit.Core:Utils.Math; - -import std; - -import :Meta; -import :Hash; -import :Utils.Numerics; - -// import :Utils.Details.GLM; - -export { - namespace stormkit::core { - namespace math { - using glm::abs; - using glm::ceil; - using glm::clamp; - using glm::floatBitsToInt; - using glm::floatBitsToUint; - using glm::floor; - using glm::fma; - using glm::fract; - using glm::frexp; - using glm::intBitsToFloat; - using glm::isinf; - using glm::isnan; - using glm::ldexp; - using glm::max; - using glm::min; - using glm::mix; - using glm::mod; - using glm::modf; - using glm::round; - using glm::roundEven; - using glm::sign; - using glm::smoothstep; - using glm::step; - using glm::trunc; - using glm::uintBitsToFloat; - - using glm::exp; - using glm::exp2; - using glm::inversesqrt; - using glm::log; - using glm::log2; - using glm::pow; - using glm::sqrt; - - using glm::cross; - using glm::distance; - using glm::dot; - using glm::faceforward; - using glm::length; - using glm::normalize; - using glm::reflect; - using glm::refract; - - using glm::packDouble2x32; - using glm::packHalf2x16; - using glm::packSnorm4x8; - using glm::packUnorm2x16; - using glm::packUnorm4x8; - using glm::unpackDouble2x32; - using glm::unpackHalf2x16; - using glm::unpackSnorm2x16; - using glm::unpackSnorm4x8; - using glm::unpackUnorm2x16; - using glm::unpackUnorm4x8; - - using glm::acos; - using glm::acosh; - using glm::asin; - using glm::asinh; - using glm::atan; - using glm::atanh; - using glm::cos; - using glm::cosh; - using glm::degrees; - using glm::radians; - using glm::sin; - using glm::sinh; - using glm::tan; - using glm::tanh; - - using glm::all; - using glm::any; - using glm::equal; - using glm::greaterThan; - using glm::greaterThanEqual; - using glm::lessThan; - using glm::lessThanEqual; - using glm::not_; - using glm::notEqual; - - using glm::angleAxis; - using glm::axis; - using glm::conjugate; - using glm::inverse; - using glm::isinf; - using glm::isnan; - using glm::lerp; - using glm::mix; - using glm::rotate; - using glm::slerp; - using glm::translate; - - using glm::bitCount; - using glm::bitfieldExtract; - using glm::bitfieldInsert; - using glm::bitfieldReverse; - using glm::findLSB; - using glm::findMSB; - using glm::imulExtended; - using glm::uaddCarry; - using glm::umulExtended; - using glm::usubBorrow; - - using glm::eulerAngles; - using glm::mat3_cast; - using glm::mat4_cast; - using glm::pitch; - using glm::quat_cast; - using glm::quatLookAt; - using glm::quatLookAtLH; - using glm::quatLookAtRH; - using glm::roll; - using glm::yaw; - - template - using Vector = glm::vec; - - /// \group vector-types Math vector types. - /// - /// Aliases to `glm::vec*` types. - /// - /// \unique_name Vector2 - template - using Vector2 = Vector<2, T>; - - /// \group vector-types - /// \unique_name Vector3 - template - using Vector3 = Vector<3, T>; - - /// \group vector-types - /// \unique_name Vector4 - template - using Vector4 = Vector<4, T>; - - /// \group vector-types - /// \unique_name Vector2F - using Vector2F = Vector2; - - /// \group vector-types - /// \unique_name Vector3F - using Vector3F = Vector3; - - /// \group vector-types - /// \unique_name Vector4F - using Vector4F = Vector4; - - /// \group vector-types - /// \unique_name Vector2U - using Vector2U = Vector2; - - /// \group vector-types - /// \unique_name Vector3U - using Vector3U = Vector3; - - /// \group vector-types - /// \unique_name Vector4U - using Vector4U = Vector4; - - /// \group vector-types - /// \unique_name Vector2I - using Vector2I = Vector2; - - /// \group vector-types - /// \unique_name Vector3I - using Vector3I = Vector3; - - /// \group vector-types - /// \unique_name Vector4I - using Vector4I = Vector4; - - template - concept IsVectorType = IsOneOf; - - /// \group matrices-types Math matrices types. - /// - /// Aliases to `glm::mat*`. - /// - /// \unique_name Matrix - template - using Matrix = glm::mat<4, 4, T, glm::defaultp>; - - /// \group matrices-types - /// \unique_name Matrixu - using Matrixu = Matrix; - - /// \group matrices-types - /// \unique_name Matrixi - using Matrixi = Matrix; - - /// \group matrices-types - /// \unique_name MatrixF - using MatrixF = Matrix; - - /// \brief Quaternion. - /// - /// Alias to `glm::quat`. - /// - /// \unique_name Quaternion - using QuaternionF = glm::quat; - - /// \brief Representation of an extent. - /// \requires `T` need to be an arithmetic type (satisfy std::floating_point or - /// std::integral). - /// \unique_name ExtentBase - template - struct Extent { - using UnderlyingType = T; - - using OrderingType = std:: - conditional_t, std::weak_ordering, std::strong_ordering>; - - /// \output_section Public Special Member Functions - /// \brief Default construct an extent. - /// - /// `width` `height` and `depth` are default constructed to 1. - constexpr Extent() noexcept; - - /// \brief Construct an extent from width, height and optionnaly depth - /// \param red The amound of width. - /// \param green The amound of height. - constexpr Extent(UnderlyingType width, - UnderlyingType height, - UnderlyingType depth = UnderlyingType { 1 }) noexcept; - - /// \brief Copy constructor. - /// - /// Construct a copy of other. - /// - /// \param other UnderlyingType copied extent. - constexpr Extent(const Extent& other) noexcept = default; - - /// \brief Move constructor. - /// - /// Move-constructs a `Extent` instance, making it point at the same object that - /// other was pointing to. - /// - /// \param other UnderlyingType moved extent. - constexpr Extent(Extent&& other) noexcept = default; - - /// \brief Assigns other to this extent and returns a reference to this extent. - /// \param other UnderlyingType extent copied. - /// \returns UnderlyingType reference of the copied extent. - constexpr auto operator=(const Extent& other) noexcept - -> Extent& = default; - - /// \brief Move assign other to this Extent instance. - /// \param other UnderlyingType extent moved. - /// \returns UnderlyingType reference of the moved extent. - constexpr auto operator=(Extent&& other) noexcept - -> Extent& = default; - - /// \brief Construct a extent from the convertion of an other extent. - /// - /// Values are converted with static_cast. - /// - /// \param other UnderlyingType extent converted. - /// \requires `U` need to be an arithmetic type (satisfy std::is_floating_point or - /// std::is_integral). - template - constexpr Extent(const Extent& other) noexcept; - - /// \output_section Publics operators members - /// \brief UnderlyingType the equality with an other extent. - /// \param other UnderlyingType extent to test - /// \returns true if this extent is equal to `other`, otherwise returns false. - [[nodiscard]] constexpr auto - operator<=>(const Extent& other) const noexcept -> OrderingType; - - /// \brief UnderlyingType the equality with an other extent. - /// \param other UnderlyingType extent to test - /// \returns true if this extent is equal to `other`, otherwise returns false. - [[nodiscard]] constexpr auto - operator==(const Extent& other) const noexcept -> bool; - - /// \brief Multiply an extent with a factor. - /// \param factor UnderlyingType factor to multiply - /// \returns A newly constructed extent equal to this extent multiplied with - /// `factor` - [[nodiscard]] constexpr auto operator*(UnderlyingType factor) const noexcept - -> Extent; - - /// \brief Divide an extent with a factor. - /// \param factor UnderlyingType factor to divide - /// \returns A newly constructed extent equal to this extent Divided with `factor` - [[nodiscard]] constexpr auto operator/(UnderlyingType factor) const noexcept - -> Extent; - - /// \brief Multiply this extent with a factor. - /// \param factor UnderlyingType factor to multiply - /// \returns A reference to this after the multiplication with `factor` - [[nodiscard]] constexpr auto operator*=(UnderlyingType factor) noexcept - -> Extent&; - - /// \brief Divide this extent with a factor. - /// \param factor UnderlyingType factor to divide - /// \returns A reference to this after the division with `factor` - [[nodiscard]] constexpr auto operator/=(UnderlyingType factor) noexcept - -> Extent&; - - /// \output_section Publics member - /// \brief Width attribute. - UnderlyingType width = 0; - - /// \brief Height attribute. - UnderlyingType height = 0; - - /// \brief Depth attribute. - UnderlyingType depth = 1; - }; - - /// \brief Alias of `Extent`. - /// \unique_name ExtentI - using ExtentI = Extent; - - /// \brief Alias of `Extent`. - /// \unique_name ExtentU - using ExtentU = Extent; - - /// \brief Alias of `Extent`. - /// \unique_name ExtentI - using ExtentI16 = Extent; - - /// \brief Alias of `Extent`. - /// \unique_name ExtentU - using ExtentU16 = Extent; - - /// \brief Alias of `Extent`. - /// \unique_name ExtentF - using ExtentF = Extent; - - template - concept IsExtentType = requires(T&& value) { - value.width; - value.height; - value.depth; - }; - } // namespace math - - template - auto toString(const math::Vector2& data) noexcept; - - template - auto toString(const math::Vector3& data) noexcept; - - template - auto toString(const math::Vector4& data) noexcept; - - template - auto toString(const T& data) noexcept; - } // namespace stormkit::core - - TEMPLATED_HASH_FUNC(stormkit::core::math::Vector2, - stormkit::core::IsArithmetic, - T, - value.x, - value.y) - TEMPLATED_HASH_FUNC(stormkit::core::math::Vector3, - stormkit::core::IsArithmetic, - T, - value.x, - value.y, - value.z) - TEMPLATED_HASH_FUNC(stormkit::core::math::Vector4, - stormkit::core::IsArithmetic, - T, - value.x, - value.y, - value.z, - value.w) - TEMPLATED_HASH_FUNC(stormkit::core::math::Extent, - stormkit::core::IsArithmetic, - T, - value.width, - value.height, - value.depth) -} - -//////////////////////////////////////////////////////////////////// -/// IMPLEMENTATION /// -//////////////////////////////////////////////////////////////////// - -namespace stormkit::core { - namespace math { - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr Extent::Extent() noexcept : Extent { 0, 0 } { - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr Extent::Extent(UnderlyingType _width, - UnderlyingType _height, - UnderlyingType _depth) noexcept - : width { _width }, height { _height }, depth { _depth } { - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - template - constexpr Extent::Extent(const Extent& other) noexcept - : width { narrow(other.width) }, - height { narrow(other.height) }, - depth { narrow(other.depth) } { - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto Extent::operator<=>(const Extent& other) const noexcept - -> OrderingType { - if (auto ret = width <=> other.width; ret != 0) return ret; - if (auto ret = height <=> other.height; ret != 0) return ret; - if (auto ret = depth <=> other.depth; ret != 0) return ret; - - return OrderingType::equivalent; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto Extent::operator==(const Extent& other) const noexcept -> bool { - return isEqual(width, other.width) and isEqual(height, other.height) and - isEqual(depth, other.depth); - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto Extent::operator*(UnderlyingType factor) const noexcept -> Extent { - return Extent { width, height, depth } *= factor; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto Extent::operator/(UnderlyingType factor) const noexcept -> Extent { - return Extent { width, height, depth } /= factor; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto Extent::operator*=(UnderlyingType factor) noexcept -> Extent& { - width *= factor; - height *= factor; - depth *= factor; - return *this; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - constexpr auto Extent::operator/=(UnderlyingType factor) noexcept -> Extent& { - width /= factor; - height /= factor; - depth /= factor; - return *this; - } - } // namespace math - - ///////////////////////////////////// - ///////////////////////////////////// - template - auto toString(const math::Vector2& data) noexcept { - return std::format("[Vector2: .x = {}, .y = {}]", data.x, data.y); - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - auto toString(const math::Vector3& data) noexcept { - return std::format("[Vector3: .x = {}, .y = {}, .z = {}]", data.x, data.y, data.z); - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - auto toString(const math::Vector4& data) noexcept { - return std::format("[Vector4: .x = {}, .y = {}, .z = {}, .w = {}]", - data.x, - data.y, - data.z, - data.w); - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - auto toString(const T& data) noexcept { - return std::format("[Extent: .width = {}, .height = {}, .depth = {}]", - data.width, - data.height, - data.depth); - } -} // namespace stormkit::core +// Copyright (C) 2023 Arthur LAURENT +// This file is subject to the license terms in the LICENSE file +// found in the top-level of this distribution + +module; + +#include + +#include +#include + +#include + +export module stormkit.Core:Math; + +import std; + +import :Numerics; +import :Hash; +import :Meta; + +export { + namespace stormkit::core { + namespace math { + using glm::abs; + using glm::ceil; + using glm::clamp; + using glm::floatBitsToInt; + using glm::floatBitsToUint; + using glm::floor; + using glm::fma; + using glm::fract; + using glm::frexp; + using glm::intBitsToFloat; + using glm::isinf; + using glm::isnan; + using glm::ldexp; + using glm::max; + using glm::min; + using glm::mix; + using glm::mod; + using glm::modf; + using glm::round; + using glm::roundEven; + using glm::sign; + using glm::smoothstep; + using glm::step; + using glm::trunc; + using glm::uintBitsToFloat; + + using glm::exp; + using glm::exp2; + using glm::inversesqrt; + using glm::log; + using glm::log2; + using glm::pow; + using glm::sqrt; + + using glm::cross; + using glm::distance; + using glm::dot; + using glm::faceforward; + using glm::length; + using glm::normalize; + using glm::reflect; + using glm::refract; + + using glm::packDouble2x32; + using glm::packHalf2x16; + using glm::packSnorm4x8; + using glm::packUnorm2x16; + using glm::packUnorm4x8; + using glm::unpackDouble2x32; + using glm::unpackHalf2x16; + using glm::unpackSnorm2x16; + using glm::unpackSnorm4x8; + using glm::unpackUnorm2x16; + using glm::unpackUnorm4x8; + + using glm::acos; + using glm::acosh; + using glm::asin; + using glm::asinh; + using glm::atan; + using glm::atanh; + using glm::cos; + using glm::cosh; + using glm::degrees; + using glm::radians; + using glm::sin; + using glm::sinh; + using glm::tan; + using glm::tanh; + + using glm::all; + using glm::any; + using glm::equal; + using glm::greaterThan; + using glm::greaterThanEqual; + using glm::lessThan; + using glm::lessThanEqual; + using glm::not_; + using glm::notEqual; + + using glm::angleAxis; + using glm::axis; + using glm::conjugate; + using glm::inverse; + using glm::isinf; + using glm::isnan; + using glm::lerp; + using glm::mix; + using glm::rotate; + using glm::slerp; + using glm::translate; + + using glm::bitCount; + using glm::bitfieldExtract; + using glm::bitfieldInsert; + using glm::bitfieldReverse; + using glm::findLSB; + using glm::findMSB; + using glm::imulExtended; + using glm::uaddCarry; + using glm::umulExtended; + using glm::usubBorrow; + + using glm::eulerAngles; + using glm::mat3_cast; + using glm::mat4_cast; + using glm::pitch; + using glm::quat_cast; + using glm::quatLookAt; + using glm::quatLookAtLH; + using glm::quatLookAtRH; + using glm::roll; + using glm::yaw; + + template + using Vector = glm::vec; + + /// \group vector-types Math vector types. + /// + /// Aliases to `glm::vec*` types. + /// + /// \unique_name Vector2 + template + using Vector2 = Vector<2, T>; + + /// \group vector-types + /// \unique_name Vector3 + template + using Vector3 = Vector<3, T>; + + /// \group vector-types + /// \unique_name Vector4 + template + using Vector4 = Vector<4, T>; + + /// \group vector-types + /// \unique_name Vector2F + using Vector2F = Vector2; + + /// \group vector-types + /// \unique_name Vector3F + using Vector3F = Vector3; + + /// \group vector-types + /// \unique_name Vector4F + using Vector4F = Vector4; + + /// \group vector-types + /// \unique_name Vector2U + using Vector2U = Vector2; + + /// \group vector-types + /// \unique_name Vector3U + using Vector3U = Vector3; + + /// \group vector-types + /// \unique_name Vector4U + using Vector4U = Vector4; + + /// \group vector-types + /// \unique_name Vector2I + using Vector2I = Vector2; + + /// \group vector-types + /// \unique_name Vector3I + using Vector3I = Vector3; + + /// \group vector-types + /// \unique_name Vector4I + using Vector4I = Vector4; + + template + concept IsVectorType = IsOneOf; + + /// \group matrices-types Math matrices types. + /// + /// Aliases to `glm::mat*`. + /// + /// \unique_name Matrix + template + using Matrix = glm::mat<4, 4, T, glm::defaultp>; + + /// \group matrices-types + /// \unique_name Matrixu + using Matrixu = Matrix; + + /// \group matrices-types + /// \unique_name Matrixi + using Matrixi = Matrix; + + /// \group matrices-types + /// \unique_name MatrixF + using MatrixF = Matrix; + + /// \brief Quaternion. + /// + /// Alias to `glm::quat`. + /// + /// \unique_name Quaternion + using QuaternionF = glm::quat; + + /// \brief Representation of an extent. + /// \requires `T` need to be an arithmetic type (satisfy std::floating_point or + /// std::integral). + /// \unique_name ExtentBase + template + struct Extent { + using UnderlyingType = T; + + using OrderingType = std:: + conditional_t, std::weak_ordering, std::strong_ordering>; + + /// \output_section Public Special Member Functions + /// \brief Default construct an extent. + /// + /// `width` `height` and `depth` are default constructed to 1. + constexpr Extent() noexcept; + + /// \brief Construct an extent from width, height and optionnaly depth + /// \param red The amound of width. + /// \param green The amound of height. + constexpr Extent(UnderlyingType width, + UnderlyingType height, + UnderlyingType depth = UnderlyingType { 1 }) noexcept; + + /// \brief Copy constructor. + /// + /// Construct a copy of other. + /// + /// \param other UnderlyingType copied extent. + constexpr Extent(const Extent& other) noexcept = default; + + /// \brief Move constructor. + /// + /// Move-constructs a `Extent` instance, making it point at the same object that + /// other was pointing to. + /// + /// \param other UnderlyingType moved extent. + constexpr Extent(Extent&& other) noexcept = default; + + /// \brief Assigns other to this extent and returns a reference to this extent. + /// \param other UnderlyingType extent copied. + /// \returns UnderlyingType reference of the copied extent. + constexpr auto operator=(const Extent& other) noexcept + -> Extent& = default; + + /// \brief Move assign other to this Extent instance. + /// \param other UnderlyingType extent moved. + /// \returns UnderlyingType reference of the moved extent. + constexpr auto operator=(Extent&& other) noexcept + -> Extent& = default; + + /// \brief Construct a extent from the convertion of an other extent. + /// + /// Values are converted with static_cast. + /// + /// \param other UnderlyingType extent converted. + /// \requires `U` need to be an arithmetic type (satisfy std::is_floating_point or + /// std::is_integral). + template + constexpr Extent(const Extent& other) noexcept; + + /// \output_section Publics operators members + /// \brief UnderlyingType the equality with an other extent. + /// \param other UnderlyingType extent to test + /// \returns true if this extent is equal to `other`, otherwise returns false. + [[nodiscard]] constexpr auto + operator<=>(const Extent& other) const noexcept -> OrderingType; + + /// \brief UnderlyingType the equality with an other extent. + /// \param other UnderlyingType extent to test + /// \returns true if this extent is equal to `other`, otherwise returns false. + [[nodiscard]] constexpr auto + operator==(const Extent& other) const noexcept -> bool; + + /// \brief Multiply an extent with a factor. + /// \param factor UnderlyingType factor to multiply + /// \returns A newly constructed extent equal to this extent multiplied with + /// `factor` + [[nodiscard]] constexpr auto + operator*(UnderlyingType factor) const noexcept -> Extent; + + /// \brief Divide an extent with a factor. + /// \param factor UnderlyingType factor to divide + /// \returns A newly constructed extent equal to this extent Divided with `factor` + [[nodiscard]] constexpr auto + operator/(UnderlyingType factor) const noexcept -> Extent; + + /// \brief Multiply this extent with a factor. + /// \param factor UnderlyingType factor to multiply + /// \returns A reference to this after the multiplication with `factor` + [[nodiscard]] constexpr auto + operator*=(UnderlyingType factor) noexcept -> Extent&; + + /// \brief Divide this extent with a factor. + /// \param factor UnderlyingType factor to divide + /// \returns A reference to this after the division with `factor` + [[nodiscard]] constexpr auto + operator/=(UnderlyingType factor) noexcept -> Extent&; + + /// \output_section Publics member + /// \brief Width attribute. + UnderlyingType width = 0; + + /// \brief Height attribute. + UnderlyingType height = 0; + + /// \brief Depth attribute. + UnderlyingType depth = 1; + }; + + /// \brief Alias of `Extent`. + /// \unique_name ExtentI + using ExtentI = Extent; + + /// \brief Alias of `Extent`. + /// \unique_name ExtentU + using ExtentU = Extent; + + /// \brief Alias of `Extent`. + /// \unique_name ExtentI + using ExtentI16 = Extent; + + /// \brief Alias of `Extent`. + /// \unique_name ExtentU + using ExtentU16 = Extent; + + /// \brief Alias of `Extent`. + /// \unique_name ExtentF + using ExtentF = Extent; + + template + concept IsExtentType = requires(T&& value) { + value.width; + value.height; + value.depth; + }; + } // namespace math + + template + auto toString(const math::Vector2& data) noexcept; + + template + auto toString(const math::Vector3& data) noexcept; + + template + auto toString(const math::Vector4& data) noexcept; + + template + auto toString(const T& data) noexcept; + } // namespace stormkit::core + + TEMPLATED_HASH_FUNC(stormkit::core::math::Vector2, + stormkit::core::IsArithmetic, + T, + value.x, + value.y) + TEMPLATED_HASH_FUNC(stormkit::core::math::Vector3, + stormkit::core::IsArithmetic, + T, + value.x, + value.y, + value.z) + TEMPLATED_HASH_FUNC(stormkit::core::math::Vector4, + stormkit::core::IsArithmetic, + T, + value.x, + value.y, + value.z, + value.w) + TEMPLATED_HASH_FUNC(stormkit::core::math::Extent, + stormkit::core::IsArithmetic, + T, + value.width, + value.height, + value.depth) +} + +//////////////////////////////////////////////////////////////////// +/// IMPLEMENTATION /// +//////////////////////////////////////////////////////////////////// + +namespace stormkit::core { + namespace math { + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr Extent::Extent() noexcept : Extent { 0, 0 } { + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr Extent::Extent(UnderlyingType _width, + UnderlyingType _height, + UnderlyingType _depth) noexcept + : width { _width }, height { _height }, depth { _depth } { + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + template + constexpr Extent::Extent(const Extent& other) noexcept + : width { static_cast(other.width) }, + height { static_cast(other.height) }, + depth { static_cast(other.depth) } { + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto + Extent::operator<=>(const Extent& other) const noexcept -> OrderingType { + if (auto ret = width <=> other.width; ret != 0) return ret; + if (auto ret = height <=> other.height; ret != 0) return ret; + if (auto ret = depth <=> other.depth; ret != 0) return ret; + + return OrderingType::equivalent; + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto Extent::operator==(const Extent& other) const noexcept -> bool { + return isEqual(width, other.width) and isEqual(height, other.height) and + isEqual(depth, other.depth); + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto Extent::operator*(UnderlyingType factor) const noexcept -> Extent { + return Extent { width, height, depth } *= factor; + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto Extent::operator/(UnderlyingType factor) const noexcept -> Extent { + return Extent { width, height, depth } /= factor; + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto Extent::operator*=(UnderlyingType factor) noexcept -> Extent& { + width *= factor; + height *= factor; + depth *= factor; + return *this; + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + constexpr auto Extent::operator/=(UnderlyingType factor) noexcept -> Extent& { + width /= factor; + height /= factor; + depth /= factor; + return *this; + } + } // namespace math + + ///////////////////////////////////// + ///////////////////////////////////// + template + auto toString(const math::Vector2& data) noexcept { + return std::format("[Vector2: .x = {}, .y = {}]", data.x, data.y); + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + auto toString(const math::Vector3& data) noexcept { + return std::format("[Vector3: .x = {}, .y = {}, .z = {}]", data.x, data.y, data.z); + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + auto toString(const math::Vector4& data) noexcept { + return std::format("[Vector4: .x = {}, .y = {}, .z = {}, .w = {}]", + data.x, + data.y, + data.z, + data.w); + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + auto toString(const T& data) noexcept { + return std::format("[Extent: .width = {}, .height = {}, .depth = {}]", + data.width, + data.height, + data.depth); + } +} // namespace stormkit::core diff --git a/modules/stormkit/Core/Meta.mpp b/modules/stormkit/Core/Meta.mpp index 6071faa4..4b49135b 100644 --- a/modules/stormkit/Core/Meta.mpp +++ b/modules/stormkit/Core/Meta.mpp @@ -2,11 +2,18 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution +module; + +#include + +#include + export module stormkit.Core:Meta; -export import :Meta.Concepts; -export import :Meta.Traits; -export import :Meta.NamedType; +import std; + +#include +#include export namespace stormkit::core { template diff --git a/modules/stormkit/Core/Utils/Numerics.mpp b/modules/stormkit/Core/Numerics.mpp similarity index 83% rename from modules/stormkit/Core/Utils/Numerics.mpp rename to modules/stormkit/Core/Numerics.mpp index af55818a..0b4b8c4d 100644 --- a/modules/stormkit/Core/Utils/Numerics.mpp +++ b/modules/stormkit/Core/Numerics.mpp @@ -6,14 +6,11 @@ module; #include -export module stormkit.Core:Utils.Numerics; +export module stormkit.Core:Numerics; import std; -import :Meta.Traits; -import :Meta.Concepts; -import :Utils.AsCast; - +import :Meta; import :Coroutines; export namespace stormkit::core { @@ -39,21 +36,21 @@ export namespace stormkit::core { template [[nodiscard]] constexpr auto - isEqual(const T& a, const T& b, const T& epsilon = Epsilon) noexcept -> bool; + equal(const T& a, const T& b, const T& epsilon = Epsilon) noexcept -> bool; template> [[nodiscard]] constexpr auto - isEqual(const T& a, const U& b, const V& epsilon = Epsilon) noexcept -> bool; + equal(const T& a, const U& b, const V& epsilon = Epsilon) noexcept -> bool; template requires Is - [[nodiscard]] constexpr auto isEqual(const T& a, const U& b) noexcept -> bool; + [[nodiscard]] constexpr auto equal(const T& a, const U& b) noexcept -> bool; template requires IsNot - [[nodiscard]] constexpr auto isEqual(const T& a, const U& b) noexcept -> bool; + [[nodiscard]] constexpr auto equal(const T& a, const U& b) noexcept -> bool; template [[nodiscard]] constexpr auto map(const T& x, @@ -127,8 +124,10 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - auto rangeImplementation(T a, U b, V c, W d) noexcept -> std::generator< - std::tuple> { + auto rangeImplementation(T a, U b, V c, W d) noexcept + -> std::generator< + std:: + tuple> { FOR(i, a) FOR(j, b) FOR(k, c) @@ -214,7 +213,7 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - constexpr auto isEqual(const T& a, const T& b, const T& epsilon) noexcept -> bool { + constexpr auto equal(const T& a, const T& b, const T& epsilon) noexcept -> bool { const auto diff = std::abs(a - b); const auto max_ab = std::max(std::abs(a), std::abs(b)); @@ -230,18 +229,18 @@ namespace stormkit::core { template> - STORMKIT_FORCE_INLINE constexpr auto isEqual(const T& a, const U& b, const V& epsilon) noexcept - -> bool { + STORMKIT_FORCE_INLINE constexpr auto + equal(const T& a, const U& b, const V& epsilon) noexcept -> bool { using Type = SafeNarrowHelperType; - return isEqual(narrow(a), narrow(b), narrow(epsilon)); + return equal(static_cast(a), static_cast(b), static_cast(epsilon)); } ///////////////////////////////////// ///////////////////////////////////// template requires Is - STORMKIT_FORCE_INLINE constexpr auto isEqual(const T& a, const U& b) noexcept -> bool { + STORMKIT_FORCE_INLINE constexpr auto equal(const T& a, const U& b) noexcept -> bool { return a == b; } @@ -249,10 +248,10 @@ namespace stormkit::core { ///////////////////////////////////// template requires IsNot - STORMKIT_FORCE_INLINE constexpr auto isEqual(const T& a, const U& b) noexcept -> bool { + STORMKIT_FORCE_INLINE constexpr auto equal(const T& a, const U& b) noexcept -> bool { using Type = SafeNarrowHelperType; - return isEqual(narrow(a), narrow(b)); + return equal(static_cast(a), static_cast(b)); } ///////////////////////////////////// @@ -263,7 +262,7 @@ namespace stormkit::core { const T& in_max, const U& out_min, const U& out_max) noexcept -> U { - return narrow((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min); + return static_cast((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min); } ///////////////////////////////////// @@ -278,9 +277,9 @@ namespace stormkit::core { STORMKIT_FORCE_INLINE constexpr auto range(const T& begin, const U& end, const V& step) noexcept { using Type = SafeNarrowHelperType, V>; - return range(NumericsRange { .begin = narrow(begin), - .end = narrow(end), - .step = narrow(step) }); + return range(NumericsRange { .begin = static_cast(begin), + .end = static_cast(end), + .step = static_cast(step) }); } ///////////////////////////////////// diff --git a/modules/stormkit/Core/Parallelism.mpp b/modules/stormkit/Core/Parallelism.mpp index fb36a16b..bf5a6d0c 100644 --- a/modules/stormkit/Core/Parallelism.mpp +++ b/modules/stormkit/Core/Parallelism.mpp @@ -2,7 +2,16 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution +module; + +#include + export module stormkit.Core:Parallelism; -export import :Parallelism.ThreadPool; -export import :Parallelism.ThreadUtils; \ No newline at end of file +import std; + +import :Utils; +import :Numerics; + +#include +#include diff --git a/modules/stormkit/Core/String.mpp b/modules/stormkit/Core/String.mpp index 5ca33a1c..d7ed44b3 100644 --- a/modules/stormkit/Core/String.mpp +++ b/modules/stormkit/Core/String.mpp @@ -2,9 +2,31 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution +module; + +#include +#include + +#include + +#include + export module stormkit.Core:String; -export import :String.CString; -export import :String.Encodings; -export import :String.Format; -export import :String.Operations; \ No newline at end of file +import std; + +import :Meta; +import :Numerics; +import :Math; +import :Utils; + +export namespace stormkit::core { + using CZString = const char*; + using ZString = char*; + using CWZString = const wchar_t*; + using WZString = wchar_t*; +} // namespace stormkit::core + +#include +#include +#include diff --git a/modules/stormkit/Core/String/CStrings.mpp b/modules/stormkit/Core/String/CStrings.mpp deleted file mode 100644 index 1863bcd1..00000000 --- a/modules/stormkit/Core/String/CStrings.mpp +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2023 Arthur LAURENT -// This file is subject to the license terms in the LICENSE file -// found in the top-level of this distribution - -export module stormkit.Core:String.CString; - -export namespace stormkit::core { - using CZString = const char*; - using ZString = char*; - using CWZString = const wchar_t*; - using WZString = wchar_t*; -} // namespace stormkit::core \ No newline at end of file diff --git a/modules/stormkit/Core/Utils.mpp b/modules/stormkit/Core/Utils.mpp index dd9c43b1..9ef431d7 100644 --- a/modules/stormkit/Core/Utils.mpp +++ b/modules/stormkit/Core/Utils.mpp @@ -2,30 +2,61 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution +module; + +#include +#include + +#include + +#include +#include +#include + +#if defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L + #define STD_STACKTRACE_SUPPORTED +#elif defined(STORMKIT_OS_LINUX) + #define BACKTRACE_SUPPORTED + #include + #include + #include +#endif + +#ifndef STORMKIT_ASSERT + #define STORMKIT_ASSERT 1 +#endif + +#undef assert + export module stormkit.Core:Utils; -export import :Utils.Algorithms; -export import :Utils.App; -export import :Utils.AsCast; -export import :Utils.Assert; -export import :Utils.Byte; -export import :Utils.Color; -export import :Utils.Descriptors; -export import :Utils.DeferInit; -export import :Utils.DynamicLoader; -export import :Utils.Expected; -export import :Utils.ErrorHandling; -export import :Utils.Filesystem; -export import :Utils.Functional; -export import :Utils.FunctionRef; -export import :Utils.Flags; -export import :Utils.Handle; -export import :Utils.Math; -export import :Utils.Monadic; -export import :Utils.NakedRef; -export import :Utils.Numerics; -export import :Utils.Pimpl; -export import :Utils.Predicates; -export import :Utils.Random; -export import :Utils.Singleton; -export import :Utils.Stacktrace; +import std; + +import :Meta; +import :Coroutines; +import :Hash; +import :Numerics; +import :Math; + +// clang-format off +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// clang-format on diff --git a/modules/stormkit/Core/Utils/Descriptors.mpp b/modules/stormkit/Core/Utils/Descriptors.mpp deleted file mode 100644 index fc6bd7c5..00000000 --- a/modules/stormkit/Core/Utils/Descriptors.mpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2023 Arthur LAURENT -// This file is subject to the license terms in the LICENSE file -// found in the top-level of this distribution - -module; - -#include - -#include - -export module stormkit.Core:Utils.Descriptors; - -import std; - -export namespace stormkit::core { - [[nodiscard]] auto getSTDErr() noexcept -> std::FILE*; - [[nodiscard]] auto getSTDOut() noexcept -> std::FILE*; -} // namespace stormkit::core - -namespace stormkit::core { - ///////////////////////////////////// - ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto getSTDErr() noexcept -> std::FILE* { - return std::bit_cast(stderr); - } - - ///////////////////////////////////// - ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto getSTDOut() noexcept -> std::FILE* { - return std::bit_cast(stdout); - } -} // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/Expected.mpp b/modules/stormkit/Core/Utils/Expected.mpp deleted file mode 100644 index 4f812f2a..00000000 --- a/modules/stormkit/Core/Utils/Expected.mpp +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright (C) 2023 Arthur LAURENT -// This file is subject to the license terms in the LICENSE file -// found in the top-level of this distribution - -module; - -#include - -export module stormkit.Core:Utils.Expected; - -import std; - -import :Meta; - -import :Utils.AsCast; - -export namespace stormkit::core { - [[nodiscard]] constexpr auto either(bool condition, - std::invocable auto&& true_, - std::invocable auto&& false_) noexcept -> decltype(auto); - - template - [[nodiscard]] constexpr auto - either(T&& optional, - std::invocable::value_type> auto&& true_, - std::invocable auto&& false_) noexcept -> decltype(auto); - -} // namespace stormkit::core - -export namespace stormkit::core::monadic { - struct Anything { - template - operator T&(this auto& self) noexcept; - - template - operator T&&(this auto&& self) noexcept; - }; - - template - [[nodiscard]] constexpr auto as() noexcept -> decltype(auto); - template - [[nodiscard]] constexpr auto narrow() noexcept -> decltype(auto); - [[nodiscard]] constexpr auto discard() noexcept -> decltype(auto); - [[nodiscard]] constexpr auto set(auto& output) noexcept -> decltype(auto); - [[nodiscard]] constexpr auto emplaceTo(auto& container) noexcept -> decltype(auto); - - template First, - std::invocable&&> Second> - [[nodiscard]] constexpr auto map(First&& first, Second&& second) noexcept -> decltype(auto); - - [[nodiscard]] constexpr auto map(auto&& first, auto&& second) noexcept -> decltype(auto); - - [[nodiscard]] constexpr auto - either(std::regular_invocable auto&&... visitors) noexcept -> decltype(auto); - - template - [[nodiscard]] constexpr auto either(IsUnaryPredicate auto&& predicate, - std::invocable auto&& true_, - std::invocable auto&& false_) noexcept -> decltype(auto); - - [[nodiscard]] constexpr auto clone() noexcept -> decltype(auto); - - template - [[nodiscard]] constexpr auto init() noexcept -> decltype(auto); - - template - [[nodiscard]] constexpr auto init(Args&&... args) noexcept -> decltype(auto); -} // namespace stormkit::core::monadic - -//////////////////////////////////////////////////////////////////// -/// IMPLEMENTATION /// -//////////////////////////////////////////////////////////////////// - -namespace stormkit::core { - ///////////////////////////////////// - ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto - either(bool condition, std::invocable auto&& true_, std::invocable auto&& false_) noexcept - -> decltype(auto) { - if (condition) return true_(); - return false_(); - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - STORMKIT_FORCE_INLINE constexpr auto - either(T&& optional, - std::invocable::value_type> auto&& true_, - std::invocable auto&& false_) noexcept -> decltype(auto) { - if (optional != std::nullopt) return true_(*std::forward(optional)); - return false_(); - } - -} // namespace stormkit::core - -namespace stormkit::core::monadic { - ///////////////////////////////////// - ///////////////////////////////////// - template - STORMKIT_FORCE_INLINE constexpr auto as() noexcept -> decltype(auto) { - return [](auto&& value) noexcept -> decltype(auto) { - using core::as; - return as(std::forward(value)); - }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - STORMKIT_FORCE_INLINE constexpr auto narrow() noexcept -> decltype(auto) { - return [](auto&& value) noexcept -> decltype(auto) { - using core::narrow; - return narrow(std::forward(value)); - }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto discard() noexcept -> decltype(auto) { - return []([[maybe_unused]] auto&& value) noexcept -> void {}; - } - - ///////////////////////////////////// - ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto set(auto& output) noexcept -> decltype(auto) { - return [&output](auto&& value) noexcept -> void { - output = std::forward(value); - }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto emplaceTo(auto& container) noexcept -> decltype(auto) { - return [&container](auto&& value) noexcept -> void { - container.emplace_back(std::forward(value)); - }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template First, - std::invocable&&> Second> - STORMKIT_FORCE_INLINE constexpr auto map(First&& first, Second&& second) noexcept - -> decltype(auto) { - return - [first = std::forward(first), - second = std::forward(second)](T&& args) noexcept -> decltype(auto) { - return second(first(std::forward(args))); - }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto map(auto&& first, auto&& second) noexcept - -> decltype(auto) { - return [first = std::forward(first), - second = std::forward(second)]( - auto&&... args) noexcept -> decltype(auto) { - return second(first(std::forward(args)...)); - }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - STORMKIT_FORCE_INLINE constexpr auto either(IsUnaryPredicate auto&& predicate, - std::invocable auto&& true_, - std::invocable auto&& false_) noexcept - -> decltype(auto) { - [predicate = std::move(predicate), true_ = std::move(true_), false_ = std::move(false_)]( - auto&& elem) noexcept -> decltype(auto) { - if (predicate(elem)) return first(std::forward(elem)); - return second(elem); - }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto - either(std::regular_invocable auto&&... visitors) noexcept -> decltype(auto) { - return [... visitors = - std::forward(visitors)](auto&& variant) mutable noexcept { - return std::visit(core::Overloaded { std::forward(visitors)... }, - std::forward(variant)); - }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto clone() noexcept -> decltype(auto) { - return [](auto&& value) noexcept( - noexcept(std::is_nothrow_copy_constructible_v>)) { - return auto(std::forward(value)); - }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - STORMKIT_FORCE_INLINE constexpr auto init() noexcept -> decltype(auto) { - return [](Args&&... args) noexcept( - noexcept(std::is_nothrow_constructible_v)) -> decltype(auto) { - return T { std::forward(args)... }; - }; - } - - ///////////////////////////////////// - ///////////////////////////////////// - template - STORMKIT_FORCE_INLINE constexpr auto init(Args&&... args) noexcept -> decltype(auto) { - return [... args = std::forward(args)]() mutable noexcept( - noexcept(std::is_nothrow_constructible_v)) -> decltype(auto) { - return T { std::forward(args)... }; - }; - } -} // namespace stormkit::core::monadic diff --git a/modules/stormkit/Core/Utils/Predicates.mpp b/modules/stormkit/Core/Utils/Predicates.mpp deleted file mode 100644 index 43ac8ca2..00000000 --- a/modules/stormkit/Core/Utils/Predicates.mpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2023 Arthur LAURENT -// This file is subject to the license terms in the LICENSE file -// found in the top-level of this distribution - -export module stormkit.Core:Utils.Predicates; - -import std; - -export namespace stormkit::core::predicates { - constexpr auto equal(auto&& value) noexcept; - constexpr auto appendTo(std::ranges::range auto& range) noexcept; - constexpr auto wrap(std::invocable auto&& func) noexcept; - constexpr auto asByte() noexcept; -} // namespace stormkit::core::predicates - -//////////////////////////////////////////////////////////////////// -/// IMPLEMENTATION /// -//////////////////////////////////////////////////////////////////// - -namespace stormkit::core::predicates { - //////////////////////////////////////// - //////////////////////////////////////// - constexpr auto equal(auto&& value) noexcept { - return - [value = std::forward(value)](auto&& other) { return value == other; }; - } - - //////////////////////////////////////// - //////////////////////////////////////// - constexpr auto appendTo(std::ranges::range auto& range) noexcept { - return [&range](auto&& val) { - range.emplace(std::ranges::cend(range), std::forward(val)); - }; - } - - //////////////////////////////////////// - //////////////////////////////////////// - constexpr auto wrap(std::invocable auto&& func) noexcept { - return [func = std::forward(func)](auto&&... args) { - return func(std::forward(args)...); - }; - } - - //////////////////////////////////////// - //////////////////////////////////////// - constexpr auto asByte() noexcept { - return [](auto&& val) { return static_cast(val); }; - } -} // namespace stormkit::core::predicates \ No newline at end of file diff --git a/modules/stormkit/Gpu/Vulkan/Utils.mpp b/modules/stormkit/Gpu/Vulkan/Utils.mpp index 5cf8eeba..5e4491bc 100644 --- a/modules/stormkit/Gpu/Vulkan/Utils.mpp +++ b/modules/stormkit/Gpu/Vulkan/Utils.mpp @@ -126,7 +126,7 @@ namespace stormkit::gpu { auto func = std::mem_fn(std::forward(func_ref)); const auto result = func(value, std::forward(args)...); - if (std::ranges::any_of(possible_results, core::toUnary(core::monadic::isEqual(), result))) + if (std::ranges::any_of(possible_results, core::toUnary(core::monadic::equal(), result))) return result; return std::unexpected { result }; diff --git a/modules/stormkit/Wsi.mpp b/modules/stormkit/Wsi.mpp index 994da3a1..799cf939 100644 --- a/modules/stormkit/Wsi.mpp +++ b/modules/stormkit/Wsi.mpp @@ -139,7 +139,7 @@ export { KeyCount, Unknow = std::numeric_limits::max(), }; - STORMKIT_FORCE_INLINE constexpr auto KEY_COUNT = core::as(Key::KeyCount); + inline constexpr auto KEY_COUNT = core::as(Key::KeyCount); enum class MouseButton : core::UInt8 { Left, @@ -150,7 +150,7 @@ export { ButtonCount, Unknow = std::numeric_limits::max(), }; - STORMKIT_FORCE_INLINE constexpr auto MOUSE_BUTTON_COUNT = + inline constexpr auto MOUSE_BUTTON_COUNT = core::as(MouseButton::ButtonCount); struct Monitor { diff --git a/src/Core/ThreadPool.cpp b/src/Core/ThreadPool.cpp index 3d5f50ec..04b70004 100644 --- a/src/Core/ThreadPool.cpp +++ b/src/Core/ThreadPool.cpp @@ -6,6 +6,8 @@ module stormkit.Core; import std; +import :Parallelism; + namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// diff --git a/src/Core/darwin/ThreadUtils.cpp b/src/Core/darwin/ThreadUtils.cpp index f8007e6d..49e6004c 100644 --- a/src/Core/darwin/ThreadUtils.cpp +++ b/src/Core/darwin/ThreadUtils.cpp @@ -6,7 +6,7 @@ module stormkit.Core; import std; -import :Parallelism.ThreadUtils; +import :Parallelism; namespace stormkit::core { //////////////////////////////////////// diff --git a/src/Core/linux/ThreadUtils.cpp b/src/Core/linux/ThreadUtils.cpp index 80a0904c..9f6ba984 100644 --- a/src/Core/linux/ThreadUtils.cpp +++ b/src/Core/linux/ThreadUtils.cpp @@ -6,6 +6,8 @@ module stormkit.Core; import std; +import :Parallelism; + namespace stormkit::core { namespace details { //////////////////////////////////////// diff --git a/src/Core/posix/DynamicLoader.mpp b/src/Core/posix/DynamicLoader.mpp index 62598f28..274693fd 100644 --- a/src/Core/posix/DynamicLoader.mpp +++ b/src/Core/posix/DynamicLoader.mpp @@ -13,10 +13,8 @@ export module stormkit.Core:Utils.DynamicLoaderImpl; import std; -import :Utils.Expected; -import :Utils.Numerics; -import :Utils.AsCast; -import :Utils.DynamicLoader; +import :Utils; +import :Numerics; export namespace stormkit::core { class DynamicLoader::DynamicLoaderImpl { diff --git a/src/Core/win32/DynamicLoader.mpp b/src/Core/win32/DynamicLoader.mpp index edb748a6..67ff8da3 100644 --- a/src/Core/win32/DynamicLoader.mpp +++ b/src/Core/win32/DynamicLoader.mpp @@ -12,10 +12,8 @@ export module stormkit.Core:Utils.DynamicLoaderImpl; import std; -import :Utils.Expected; -import :Utils.Numerics; -import :Utils.AsCast; -import :Utils.DynamicLoader; +import :Utils; +import :Numerics; export namespace stormkit::core { class DynamicLoader::DynamicLoaderImpl { diff --git a/src/Core/win32/ThreadUtils.cpp b/src/Core/win32/ThreadUtils.cpp index 822ad023..4e4e7aaa 100644 --- a/src/Core/win32/ThreadUtils.cpp +++ b/src/Core/win32/ThreadUtils.cpp @@ -7,7 +7,9 @@ module stormkit.Core; import std; -inline constexpr auto MS_VC_EXCEPTION = DWORD { 0x406D1388 }; +import :Parallelism; + +static constexpr auto MS_VC_EXCEPTION = DWORD { 0x406D1388 }; #pragma pack(push, 8) diff --git a/src/Engine/Renderer/FrameGraphBuilder.cpp b/src/Engine/Renderer/FrameGraphBuilder.cpp index e64e33b5..90615423 100644 --- a/src/Engine/Renderer/FrameGraphBuilder.cpp +++ b/src/Engine/Renderer/FrameGraphBuilder.cpp @@ -275,45 +275,44 @@ namespace stormkit::engine { }) | std::ranges::to(); - const auto reads = - task.reads() | std::views::filter([this](const auto id) noexcept { - const auto& resource = getResource(id); - return core::is(resource); - }) | - std::views::transform([&, this](const auto id) { - const auto& resource = getResource(id); - const auto& description = resource.description(); - - auto attachment_description = gpu::AttachmentDescription { - .format = description.format, - .load_op = gpu::AttachmentLoadOperation::Load, - .store_op = gpu::AttachmentStoreOperation::Dont_Care, - .stencil_load_op = gpu::AttachmentLoadOperation::Dont_Care, - .stencil_store_op = gpu::AttachmentStoreOperation::Dont_Care, - .source_layout = layouts.at(id), - .destination_layout = layouts.at(id) - }; - - if (std::ranges::any_of(task.writes(), - core::toUnary(core::monadic::isEqual(), id))) { - to_remove.emplace_back(id); - attachment_description.store_op = gpu::AttachmentStoreOperation::Store; - } - - if (isDepthStencilFormat(description.format)) [[unlikely]] { - std::swap(attachment_description.load_op, - attachment_description.stencil_load_op); - std::swap(attachment_description.store_op, - attachment_description.stencil_store_op); - attachment_description.destination_layout = - gpu::ImageLayout::Depth_Stencil_Attachment_Optimal; - } - - layouts[id] = attachment_description.destination_layout; - - return attachment_description; - }) | - std::ranges::to(); + const auto reads = task.reads() | std::views::filter([this](const auto id) noexcept { + const auto& resource = getResource(id); + return core::is(resource); + }) | + std::views::transform([&, this](const auto id) { + const auto& resource = getResource(id); + const auto& description = resource.description(); + + auto attachment_description = gpu::AttachmentDescription { + .format = description.format, + .load_op = gpu::AttachmentLoadOperation::Load, + .store_op = gpu::AttachmentStoreOperation::Dont_Care, + .stencil_load_op = gpu::AttachmentLoadOperation::Dont_Care, + .stencil_store_op = gpu::AttachmentStoreOperation::Dont_Care, + .source_layout = layouts.at(id), + .destination_layout = layouts.at(id) + }; + + if (std::ranges::any_of(task.writes(), core::monadic::equal(id))) { + to_remove.emplace_back(id); + attachment_description.store_op = + gpu::AttachmentStoreOperation::Store; + } + + if (isDepthStencilFormat(description.format)) [[unlikely]] { + std::swap(attachment_description.load_op, + attachment_description.stencil_load_op); + std::swap(attachment_description.store_op, + attachment_description.stencil_store_op); + attachment_description.destination_layout = + gpu::ImageLayout::Depth_Stencil_Attachment_Optimal; + } + + layouts[id] = attachment_description.destination_layout; + + return attachment_description; + }) | + std::ranges::to(); auto output = RenderPassData {}; output.description.attachments = diff --git a/src/Entities/EntityManager.cpp b/src/Entities/EntityManager.cpp index efa0f9ae..60085b6b 100644 --- a/src/Entities/EntityManager.cpp +++ b/src/Entities/EntityManager.cpp @@ -69,8 +69,8 @@ namespace stormkit::entities { auto EntityManager::hasEntity(Entity entity) const -> bool { core::expects(entity != INVALID_ENTITY); - return std::ranges::any_of(entities(), core::predicates::equal(entity)) or - std::ranges::any_of(m_added_entities, core::predicates::equal(entity)); + return std::ranges::any_of(entities(), core::monadic::equal(entity)) or + std::ranges::any_of(m_added_entities, core::monadic::equal(entity)); } ///////////////////////////////////// @@ -79,7 +79,7 @@ namespace stormkit::entities { core::expects(entity != INVALID_ENTITY and type != Component::INVALID_TYPE); return std::ranges::any_of(m_registered_components_for_entities.at(entity), - core::predicates::equal(type)); + core::monadic::equal(type)); } ///////////////////////////////////// @@ -101,7 +101,7 @@ namespace stormkit::entities { removeFromSystems(entity); - if (not std::ranges::any_of(m_added_entities, core::predicates::equal(entity))) + if (not std::ranges::any_of(m_added_entities, core::monadic::equal(entity))) m_free_entities.push(entity); } m_removed_entities.clear(); diff --git a/src/Log/ConsoleLogger.cpp b/src/Log/ConsoleLogger.cpp index 0a139666..ee8e5dcb 100644 --- a/src/Log/ConsoleLogger.cpp +++ b/src/Log/ConsoleLogger.cpp @@ -46,7 +46,7 @@ namespace stormkit::log { }(); const auto to_stderr = severity == Severity::Error or severity == Severity::Fatal; - auto output = (to_stderr) ? core::getSTDErr() : core::getSTDOut(); + auto output = (to_stderr) ? stderr : stdout; // not yet /* diff --git a/src/Log/posix/LogColorizer.cpp b/src/Log/posix/LogColorizer.cpp index e3d5cc5f..d0b4e7d7 100644 --- a/src/Log/posix/LogColorizer.cpp +++ b/src/Log/posix/LogColorizer.cpp @@ -2,6 +2,10 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution +module; + +#include + module stormkit.Log; import std; @@ -28,7 +32,7 @@ namespace stormkit::log::details { ///////////////////////////////////// ///////////////////////////////////// auto colorifyBegin(Severity severity, bool to_stderr) noexcept -> void { - auto output = (to_stderr) ? core::getSTDErr() : core::getSTDOut(); + auto output = (to_stderr) ? stderr : stdout; switch (severity) { case Severity::Info: std::print(output, "{}{}{}", KBLCK, KINV, KGRN); break; case Severity::Warning: std::print(output, "{}{}{}", KBLCK, KINV, KMAG); break; @@ -42,7 +46,7 @@ namespace stormkit::log::details { ///////////////////////////////////// ///////////////////////////////////// auto colorifyEnd(bool to_stderr) noexcept -> void { - auto output = (to_stderr) ? core::getSTDErr() : core::getSTDOut(); + auto output = (to_stderr) ? stderr : stdout; std::print(output, KNRM); } } // namespace stormkit::log::details diff --git a/xmake/rules/wayland-protocols.lua b/xmake/rules/wayland-protocols.lua index 4e9c0737..440cc561 100644 --- a/xmake/rules/wayland-protocols.lua +++ b/xmake/rules/wayland-protocols.lua @@ -44,9 +44,9 @@ do local privatefile = path.join(outputdir, path.basename(protocol) .. ".c") -- for c++ module dependency discovery - -- if not os.exists(clientfile) then - -- os.touch(clientfile) - -- end + if not os.exists(clientfile) then + os.touch(clientfile) + end target:add("files", privatefile, { always_added = true }) end