diff --git a/.clang-format b/.clang-format index 1bf3cbf6f..d02bde0c0 100644 --- a/.clang-format +++ b/.clang-format @@ -13,7 +13,7 @@ BreakAfterAttributes: Leave BreakBeforeConceptDeclarations: Always # General rules -InsertBraces: false +InsertBraces: true PointerAlignment: Left ColumnLimit: 120 diff --git a/applications/core_test/src/core_test/source.cpp b/applications/core_test/src/core_test/source.cpp index 9d13e62db..923397800 100644 --- a/applications/core_test/src/core_test/source.cpp +++ b/applications/core_test/src/core_test/source.cpp @@ -1,15 +1,15 @@ #define RYTHE_ENTRY -#include -#include -#include #include #include +#include +#include +#include #include void RYTHE_CCONV reportModules(rythe::core::Program* program) { - rsl::log::debug("Initilizing Core-Application"); - program->addEngineInstance(); + rsl::log::debug("Initilizing Core-Application"); + program->addEngineInstance(); } diff --git a/applications/rsl_test/.rythe_project b/applications/rsl_test/.rythe_project deleted file mode 100644 index 59bf9c459..000000000 --- a/applications/rsl_test/.rythe_project +++ /dev/null @@ -1,7 +0,0 @@ -local project = { - dependencies = { - "rythe/rythe-standard-library:test" - } -} - -return project \ No newline at end of file diff --git a/applications/rsl_test/src/rsl_test/source.cpp b/applications/rsl_test/src/rsl_test/source.cpp deleted file mode 100644 index d2de3dd65..000000000 --- a/applications/rsl_test/src/rsl_test/source.cpp +++ /dev/null @@ -1,281 +0,0 @@ -#define RYTHE_VALIDATE - -#include -#include -#include - -#include - -#include -#include - -static size_t counter; - -static void func() -{ - counter++; -} - -static void func2(unsigned& i) -{ - static unsigned tmp = 0; - static volatile unsigned* ptr = &tmp; - *ptr = i; -} - -struct Object -{ - std::vector ints; - - void memberFunc() - { - for (size_t& i : ints) - { - i++; - counter += i; - } - } - - void constMemberFunc() const - { - - for (size_t i : ints) - { - counter += i; - } - } -}; - -static std::vector createVec(size_t idx) -{ - std::vector vec; - for (size_t i = idx + 20; i > idx; i--) - { - vec.push_back(i); - } - return vec; -} - -void delegate_test(size_t i) -{ - - rsl::delegate del2; - - { - del2 = &func2; - rsl::uint32 t = 0; - del2(t); - } - - rsl::multicast_delegate del; - - { - del = &func; - } - - del(); - - counter = 0; - - { - del = []() - { - counter++; - }; - } - - del(); - - counter = 0; - - { - std::vector ints = createVec(i); - del = [ints]() - { - for (size_t i : ints) - { - i++; - counter += i; - } - }; - } - - del(); - - counter = 0; - - { - Object obj{createVec(i)}; - { - del.assign(obj); - } - - del(); - } - - counter = 0; - - { - const Object obj{createVec(i)}; - { - del.assign(obj); - } - - del(); - } - - counter = 0; - - for (size_t j = 0; j < 10000; j++) - { - del(); - } -} - -void stl_test(size_t i) -{ - - std::function del2; - - { - del2 = &func2; - rsl::uint32 t = 0; - del2(t); - } - - std::function del; - - { - del = &func; - } - - del(); - - counter = 0; - - { - del = []() - { - counter++; - }; - } - - del(); - - counter = 0; - - { - std::vector ints = createVec(i); - del = [ints]() - { - for (size_t i : ints) - { - i++; - counter += i; - } - }; - } - - del(); - - counter = 0; - - { - Object obj{createVec(i)}; - { - auto mf = std::mem_fn(&Object::memberFunc); - del = std::bind(mf, &obj); - } - - del(); - } - - counter = 0; - - { - const Object obj{createVec(i)}; - { - auto mf = std::mem_fn(&Object::constMemberFunc); - del = std::bind(mf, const_cast(&obj)); - } - - del(); - } - - counter = 0; - - for (size_t j = 0; j < 10000; j++) - { - del(); - } -} - -int main() -{ - constexpr size_t ITERATIONS = 10000; - using clock = std::chrono::high_resolution_clock; - { - auto start = clock::now(); - - for (size_t i = 0; i < ITERATIONS; i++) - { - delegate_test(i); - } - - auto elapsed = (clock::now() - start); - std::cout << counter << std::endl; - std::cout << (std::chrono::duration_cast>(elapsed).count() / ITERATIONS) << "\t" << elapsed.count() << std::endl; - counter = 0; - } - - { - auto start = clock::now(); - - for (size_t i = 0; i < ITERATIONS; i++) - { - stl_test(i); - } - - auto elapsed = (clock::now() - start); - std::cout << counter << std::endl; - std::cout << (std::chrono::duration_cast>(elapsed).count() / ITERATIONS) << "\t" << elapsed.count() << std::endl; - counter = 0; - } - - rsl::stopwatch timer; - rsl::timer accurateTimer; - - rsl::time_point startTime = timer.start_point(); - - std::cout << "timer started at: " << startTime.hours() << ':' << startTime.minutes() << ' ' << startTime.seconds() << "s\n"; - - rsl::time_point currentTime = timer.current_point(); - rsl::time_span elapsedTime = currentTime - startTime; - rsl::time_span otherElapsed = timer.elapsed_time(); - rsl::time_span accurateElapsed = accurateTimer.elapsed_time(); - - std::cout << "timer after log: " << currentTime.hours() << ':' << currentTime.minutes() << ' ' << currentTime.seconds() << "s\n"; - - - std::cout << "elapsed time: " << elapsedTime.nanoseconds() << " nanoseconds, other elapsed: " << otherElapsed.nanoseconds() << " nanoseconds, accurate elapsed: " << accurateElapsed.nanoseconds() << " nanoseconds\n"; - - - rsl::buffered_string<16> str = "Hello there!"; - rsl::buffered_string<16> str2 = "This is more than 16 chars!"; - - constexpr auto typeName = rsl::type_name(str); - - std::cout << typeName << '\n'; - - std::cout << '\"' << str << "\"\n\"" << str2 << "\"\n"; - - str.resize(15); - - std::cout << '\"' << str << "\"\n\"" << str2 << "\"\n"; - - str.resize(6); - - std::cout << '\"' << str << "\"\n\"" << str2 << "\"\n"; - - return 0; -} diff --git a/applications/sandbox/src/sandbox/source.cpp b/applications/sandbox/src/sandbox/source.cpp index 9dbeb7825..2e7c5557a 100644 --- a/applications/sandbox/src/sandbox/source.cpp +++ b/applications/sandbox/src/sandbox/source.cpp @@ -8,7 +8,7 @@ #include #include -template +template struct foo { }; @@ -30,7 +30,10 @@ int RYTHE_CCONV reportModules(rythe::core::Program& program) [[maybe_unused]] constexpr auto shrunk = typeName.refit(); constexpr rsl::id_type typeHash = rsl::type_id(); - rsl::log::debug("type info: {} : {}, {}, {}, {}", rsl::string_view(typeName), typeHash, typeName.size(), typeName.capacity(), shrunk.capacity()); + rsl::log::debug( + "type info: {} : {}, {}, {}, {}", rsl::string_view(typeName), typeHash, typeName.size(), typeName.capacity(), + shrunk.capacity() + ); return -1; } diff --git a/build/vs2022/rythe/program.hpp b/build/vs2022/rythe/program.hpp index f2b52d6d3..ef305f171 100644 --- a/build/vs2022/rythe/program.hpp +++ b/build/vs2022/rythe/program.hpp @@ -2,5 +2,4 @@ class Program { - }; diff --git a/libraries/rythe/rythe-standard-library b/libraries/rythe/rythe-standard-library index 3d8fffbc2..2c5978e6c 160000 --- a/libraries/rythe/rythe-standard-library +++ b/libraries/rythe/rythe-standard-library @@ -1 +1 @@ -Subproject commit 3d8fffbc2fc2612fa3f9f3e084b65dd8682e7127 +Subproject commit 2c5978e6ce778b8ad3445991142dc8e046f35f16 diff --git a/modules/rythe/application b/modules/rythe/application index a30a102bd..3f1f2f62f 160000 --- a/modules/rythe/application +++ b/modules/rythe/application @@ -1 +1 @@ -Subproject commit a30a102bdd844f9f2e85c9c832ca806151fb2752 +Subproject commit 3f1f2f62f0781eff8930405118e4c527961311da diff --git a/modules/rythe/audio b/modules/rythe/audio index 538d221d3..33f5fa960 160000 --- a/modules/rythe/audio +++ b/modules/rythe/audio @@ -1 +1 @@ -Subproject commit 538d221d31adeedfb3f48fdfe4bda4c165b43b3a +Subproject commit 33f5fa9603d962b30df993a437375d4eafb1a2ac diff --git a/modules/rythe/core b/modules/rythe/core index efc8c50a8..9d16c2cb5 160000 --- a/modules/rythe/core +++ b/modules/rythe/core @@ -1 +1 @@ -Subproject commit efc8c50a8a33f8e35c7b2189c9273276ab15197a +Subproject commit 9d16c2cb593bb5b56d6baa6574323b947c68599e diff --git a/modules/rythe/graphics b/modules/rythe/graphics index 556c228a6..2a3cfcd6b 160000 --- a/modules/rythe/graphics +++ b/modules/rythe/graphics @@ -1 +1 @@ -Subproject commit 556c228a6463314a64f97526c0bc0b2aa88f9ed9 +Subproject commit 2a3cfcd6b75b67e347bcabb55c9edc45517af2ad diff --git a/modules/rythe/physics b/modules/rythe/physics index 2a7382fc2..579ea6bbc 160000 --- a/modules/rythe/physics +++ b/modules/rythe/physics @@ -1 +1 @@ -Subproject commit 2a7382fc292380b3e87dde2713e42e2a40c971f5 +Subproject commit 579ea6bbceff2cad607e0404c1e498569791719a diff --git a/premake/rythe b/premake/rythe index 837b8a6d9..d280cd418 160000 --- a/premake/rythe +++ b/premake/rythe @@ -1 +1 @@ -Subproject commit 837b8a6d9a5d42712329ba222a3548441672fee3 +Subproject commit d280cd41853493cca23bc28c02cce6998ad5e399 diff --git a/run-clang-format.ps1 b/run-clang-format.ps1 deleted file mode 100644 index 8c0bd0d5f..000000000 --- a/run-clang-format.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -Get-ChildItem -Path . -Directory -Recurse | - foreach { - cd $_.FullName - Write-host "Formatting: $_" - &D:\Perforce\rythe-interactive\Rythe-Engine\tools\clang-format -style=file -i *.cpp - &D:\Perforce\rythe-interactive\Rythe-Engine\tools\clang-format -style=file -i *.hpp - &D:\Perforce\rythe-interactive\Rythe-Engine\tools\clang-format -style=file -i *.inl - } \ No newline at end of file diff --git a/utils/format/.rythe_project b/utils/format/.rythe_project new file mode 100644 index 000000000..48536783d --- /dev/null +++ b/utils/format/.rythe_project @@ -0,0 +1,15 @@ +local project = { + pre_build = {}, + fast_up_to_date_check = false +} + +function project.init(proj, ctx) + proj.pre_build = { + "cd " .. _WORKING_DIR, + "powershell -File ./utils/format/run-clang-format.ps1" + } + + return proj +end + +return project \ No newline at end of file diff --git a/utils/format/run-clang-format.ps1 b/utils/format/run-clang-format.ps1 new file mode 100644 index 000000000..a27efaf8e --- /dev/null +++ b/utils/format/run-clang-format.ps1 @@ -0,0 +1,41 @@ +$WorkspaceRootDir = Join-Path $PSScriptRoot ../.. +$ClangFormatPath = Join-Path $WorkspaceRootDir tools/clang-format + +function FormatDir { + param($DirPath) + + $RelativePath = Get-Item $DirPath | Resolve-Path -Relative + Write-host "Formatting: $RelativePath" + + Set-Location $DirPath + if (Test-Path -Path *.cpp -PathType Leaf) + { + &$ClangFormatPath --style=file -i *.cpp + } + + if (Test-Path -Path *.hpp -PathType Leaf) + { + &$ClangFormatPath --style=file -i *.hpp + } + + if (Test-Path -Path *.inl -PathType Leaf) + { + &$ClangFormatPath --style=file -i *.inl + } + + Set-Location $WorkspaceRootDir +} + +function IterateDir { + param($DirPath) + + Get-ChildItem -Path $DirPath -Directory | + foreach { + if (!($_ -match "^\.|third_party|build|docs|tools|premake|utils|assets")) { + FormatDir($_.FullName) + IterateDir($_.FullName) + } + } +} + +IterateDir($WorkspaceRootDir) \ No newline at end of file diff --git a/utils/refresh/.rythe_project b/utils/refresh/.rythe_project index 0a38928da..fb572c471 100644 --- a/utils/refresh/.rythe_project +++ b/utils/refresh/.rythe_project @@ -8,12 +8,6 @@ function project.init(proj, ctx) "cd " .. _WORKING_DIR, ctx.getCommand() } - - local targetPattern = "build/" .. _ACTION .. "/bin/**/" .. proj.name - for i, dir in ipairs(os.matchdirs(targetPattern)) do - print(dir) - os.rmdir(dir) - end return proj end diff --git a/utils/test utils/main.cpp b/utils/test utils/main.cpp index 3e15d339a..97a9e434a 100644 --- a/utils/test utils/main.cpp +++ b/utils/test utils/main.cpp @@ -1 +1,43 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 #include +#include +#include +#include +#include + +namespace Catch +{ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS + static LeakDetector leakDetector; + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +} // namespace Catch + +// Allow users of amalgamated .cpp file to remove our main and provide their own. +#if !defined(CATCH_AMALGAMATED_CUSTOM_MAIN) + + #if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && \ + !defined(DO_NOT_USE_WMAIN) +// Standard C/C++ Win32 Unicode wmain entry point +extern "C" int __cdecl wmain(int argc, wchar_t* argv[], wchar_t*[]) +{ + #else +// Standard C/C++ main entry point +int main(int argc, char* argv[]) +{ + #endif + + // We want to force the linker not to discard the global variable + // and its constructor, as it (optionally) registers leak detector + (void)&Catch::leakDetector; + + return Catch::Session().run(argc, argv); +} + +#endif // !defined(CATCH_AMALGAMATED_CUSTOM_MAIN