From 654c31b94d547e8d83be378eb5d5ab16a820dcdd Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 4 Dec 2025 16:22:22 +0100 Subject: chore:: breaking structural changes of CompilerKit. The Kit has been redesigned to be expandable to new language frontends. Signed-off-by: Amlal El Mahrouss --- src/CompilerKit/Utilities/Assembler.h | 8 ++++---- src/CompilerKit/Utilities/Compiler.h | 14 +++++++++----- src/CompilerKit/Utilities/DLL.h | 4 ++++ 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src/CompilerKit/Utilities') diff --git a/src/CompilerKit/Utilities/Assembler.h b/src/CompilerKit/Utilities/Assembler.h index 3da48cc..fc965f0 100644 --- a/src/CompilerKit/Utilities/Assembler.h +++ b/src/CompilerKit/Utilities/Assembler.h @@ -27,7 +27,7 @@ static NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) { case 'x': { if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 16); !res) { if (errno != 0) { - Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit"); + CompilerKit::Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit"); throw std::runtime_error("invalid_hex"); } } @@ -43,7 +43,7 @@ static NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) { case 'b': { if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 2); !res) { if (errno != 0) { - Detail::print_error("invalid binary number:" + lineBuffer, "CompilerKit"); + CompilerKit::Detail::print_error("invalid binary number:" + lineBuffer, "CompilerKit"); throw std::runtime_error("invalid_bin"); } } @@ -59,7 +59,7 @@ static NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) { case 'o': { if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 7); !res) { if (errno != 0) { - Detail::print_error("invalid octal number: " + lineBuffer, "CompilerKit"); + CompilerKit::Detail::print_error("invalid octal number: " + lineBuffer, "CompilerKit"); throw std::runtime_error("invalid_octal"); } } @@ -75,7 +75,7 @@ static NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) { default: { if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 10); !res) { if (errno != 0) { - Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit"); + CompilerKit::Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit"); throw std::runtime_error("invalid_hex"); } } diff --git a/src/CompilerKit/Utilities/Compiler.h b/src/CompilerKit/Utilities/Compiler.h index 165ab53..bbca020 100644 --- a/src/CompilerKit/Utilities/Compiler.h +++ b/src/CompilerKit/Utilities/Compiler.h @@ -37,14 +37,18 @@ inline static UInt32 kAcceptableErrors = 0; inline static bool kVerbose = false; inline static bool kOutputAsBinary = false; -namespace Detail { -/// @brief Linker specific blob metadata structure -struct DynamicLinkerBlob final { +namespace CompilerKit::Detail { +/// @brief Blob structure +struct Blob final { std::vector mBlob{}; // PEF code/bss/data blob. UIntPtr mOffset{0UL}; // the offset of the PEF container header... + + explicit operator bool() { + return mBlob.empty() && mOffset > 0UL; + } }; -inline void print_error(std::string reason, std::string file) noexcept { +inline void print_error(STLString reason, STLString file) noexcept { if (reason[0] == '\n') reason.erase(0, 1); kStdErr << reason << kBlank << std::endl; @@ -54,7 +58,7 @@ inline void print_error(std::string reason, std::string file) noexcept { ++kAcceptableErrors; } -inline void print_warning(std::string reason, std::string file) noexcept { +inline void print_warning(STLString reason, STLString file) noexcept { if (reason[0] == '\n') reason.erase(0, 1); kStdOut << kYellow << reason << kBlank << std::endl; diff --git a/src/CompilerKit/Utilities/DLL.h b/src/CompilerKit/Utilities/DLL.h index 58e0cc7..5bfe032 100644 --- a/src/CompilerKit/Utilities/DLL.h +++ b/src/CompilerKit/Utilities/DLL.h @@ -20,6 +20,10 @@ struct CompilerKitDylibTraits final { CompilerKitEntrypoint fEntrypoint{nullptr}; std::mutex fMutex; + explicit operator bool() { + return fDylib && fEntrypoint; + } + CompilerKitDylibTraits& operator()(const Char* path, const Char* fEntrypoint) { std::lock_guard lock(this->fMutex); -- cgit v1.2.3