From eda801d3c7b412aeadf01ff6890eff203e3a85a1 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Tue, 7 Oct 2025 18:03:40 +0800 Subject: [PATCH] refactor: move env outside from rust namespace --- src/CMakeLists.txt | 4 ++-- src/yycc/carton/clap/manual.cpp | 4 ++-- src/yycc/{rust => }/env.cpp | 16 ++++++++-------- src/yycc/{rust => }/env.hpp | 4 ++-- test/CMakeLists.txt | 2 +- test/yycc/{rust => }/env.cpp | 12 ++++++------ 6 files changed, 21 insertions(+), 21 deletions(-) rename src/yycc/{rust => }/env.cpp (96%) rename src/yycc/{rust => }/env.hpp (98%) rename test/yycc/{rust => }/env.cpp (88%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f18a32f..a4c0e59 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,7 @@ PRIVATE yycc/patch/fopen.cpp yycc/patch/stream.cpp yycc/rust/panic.cpp - yycc/rust/env.cpp + yycc/env.cpp yycc/windows/com.cpp yycc/windows/dialog.cpp yycc/windows/winfct.cpp @@ -69,7 +69,7 @@ FILES yycc/rust/panic.hpp yycc/rust/option.hpp yycc/rust/result.hpp - yycc/rust/env.hpp + yycc/env.hpp yycc/windows/import_guard_head.hpp yycc/windows/import_guard_tail.hpp yycc/windows/com.hpp diff --git a/src/yycc/carton/clap/manual.cpp b/src/yycc/carton/clap/manual.cpp index 8e7eff2..3f244c1 100644 --- a/src/yycc/carton/clap/manual.cpp +++ b/src/yycc/carton/clap/manual.cpp @@ -3,7 +3,7 @@ #include "../../patch/stream.hpp" #include "../../patch/format.hpp" #include "../../string/op.hpp" -#include "../../rust/env.hpp" +#include "../../env.hpp" #include #define CLAP ::yycc::carton::clap @@ -11,7 +11,7 @@ #define TERMCOLOR ::yycc::carton::termcolor #define OP ::yycc::string::op #define FORMAT ::yycc::patch::format -#define ENV ::yycc::rust::env +#define ENV ::yycc::env using namespace ::yycc::patch::stream; diff --git a/src/yycc/rust/env.cpp b/src/yycc/env.cpp similarity index 96% rename from src/yycc/rust/env.cpp rename to src/yycc/env.cpp index 5a80b84..7c3af81 100644 --- a/src/yycc/rust/env.cpp +++ b/src/yycc/env.cpp @@ -1,15 +1,15 @@ #include "env.hpp" -#include "../macro/os_detector.hpp" +#include "macro/os_detector.hpp" // Environment variable required #if defined(YYCC_OS_WINDOWS) -#include "../encoding/windows.hpp" -#include "../num/safe_op.hpp" -#include "../num/safe_cast.hpp" +#include "encoding/windows.hpp" +#include "num/safe_op.hpp" +#include "num/safe_cast.hpp" #include #include #else -#include "../string/reinterpret.hpp" +#include "string/reinterpret.hpp" #include #include #include @@ -17,7 +17,7 @@ // Path related functions required #if defined(YYCC_OS_WINDOWS) -#include "../windows/winfct.hpp" +#include "windows/winfct.hpp" #else #include #include @@ -29,7 +29,7 @@ #define REINTERPRET ::yycc::string::reinterpret #define WINFCT ::yycc::windows::winfct -namespace yycc::rust::env { +namespace yycc::env { #pragma region Environment Variable @@ -207,4 +207,4 @@ namespace yycc::rust::env { #pragma endregion -} // namespace yycc::rust::env +} // namespace yycc::env diff --git a/src/yycc/rust/env.hpp b/src/yycc/env.hpp similarity index 98% rename from src/yycc/rust/env.hpp rename to src/yycc/env.hpp index ed79b50..f9bbdcc 100644 --- a/src/yycc/rust/env.hpp +++ b/src/yycc/env.hpp @@ -14,7 +14,7 @@ * I create this namespace inspired from Rust standard library * to glue all these things up and make a uniform interface. */ -namespace yycc::rust::env { +namespace yycc::env { #pragma region Environment Variable @@ -86,4 +86,4 @@ namespace yycc::rust::env { #pragma endregion -} // namespace yycc::rust::env +} // namespace yycc::env diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f0e848c..c94d50b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -20,7 +20,7 @@ PRIVATE yycc/patch/fopen.cpp yycc/patch/stream.cpp yycc/patch/format.cpp - yycc/rust/env.cpp + yycc/env.cpp yycc/string/reinterpret.cpp yycc/string/op.cpp yycc/num/parse.cpp diff --git a/test/yycc/rust/env.cpp b/test/yycc/env.cpp similarity index 88% rename from test/yycc/rust/env.cpp rename to test/yycc/env.cpp index 428397f..53e6b2a 100644 --- a/test/yycc/rust/env.cpp +++ b/test/yycc/env.cpp @@ -1,17 +1,17 @@ #include #include -#include +#include #include #include -#define ENV ::yycc::rust::env +#define ENV ::yycc::env -namespace yycctest::rust::env { +namespace yycctest::env { constexpr char8_t VAR_NAME[] = u8"HOMER"; constexpr char8_t VAR_VALUE[] = u8"doh"; - TEST(RustEnv, EnvVar) { + TEST(Env, EnvVar) { // Write a new variable should okey { auto rv = ENV::set_var(VAR_NAME, VAR_VALUE); @@ -44,7 +44,7 @@ namespace yycctest::rust::env { } } - TEST(RustEnv, CurrentExe) { + TEST(Env, CurrentExe) { auto rv = ENV::current_exe(); ASSERT_TRUE(rv.has_value()); @@ -59,4 +59,4 @@ namespace yycctest::rust::env { #endif } -} // namespace yycctest::rust::env +} // namespace yycctest::env