diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-11 13:25:12 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-11 13:25:12 +0100 |
| commit | 37b8e34dc54f572fbfbd135742fa11c21c5e67c1 (patch) | |
| tree | 94a017be79eb83306ecc6c7ca2455a7e3e242b56 | |
| parent | 30a7184205b0cbf2dfc49ed3a52543219008dc32 (diff) | |
chore! breaking changes in NeCTI API.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | include/CompilerKit/CodeGenerator.h | 8 | ||||
| -rw-r--r-- | include/CompilerKit/ErrorOr.h | 2 | ||||
| -rw-r--r-- | include/CompilerKit/Ref.h | 27 | ||||
| -rw-r--r-- | src/CompilerKit/src/CodeGenerator+AssemblyFactory.cc | 9 | ||||
| -rw-r--r-- | src/CompilerKit/src/Compilers/CCompiler+64x0.cc | 4 | ||||
| -rw-r--r-- | src/CompilerKit/src/Compilers/CCompiler+ARM64.cc | 4 | ||||
| -rw-r--r-- | src/CompilerKit/src/Compilers/CCompiler+Power64.cc | 4 | ||||
| -rw-r--r-- | src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc | 4 | ||||
| -rw-r--r-- | src/CompilerKit/src/DynamicLinkers/DynamicLinker64+PEF.cc | 4 |
9 files changed, 38 insertions, 28 deletions
diff --git a/include/CompilerKit/CodeGenerator.h b/include/CompilerKit/CodeGenerator.h index 8119c58..721743d 100644 --- a/include/CompilerKit/CodeGenerator.h +++ b/include/CompilerKit/CodeGenerator.h @@ -8,6 +8,10 @@ #include <CompilerKit/Detail/Config.h> #include <CompilerKit/Macros.h> + +#include <CompilerKit/ErrorOr.h> +#include <CompilerKit/Ref.h> + #include <cstring> #define CK_ASSEMBLY_INTERFACE : public ::CompilerKit::IAssembly @@ -42,8 +46,8 @@ class AssemblyFactory final { Int32 Compile(STLString sourceFile, const Int32& arch) noexcept; - void Mount(IAssembly* mountPtr) noexcept; - IAssembly* Unmount() noexcept; + void Mount(WeakRef<IAssembly> mountPtr) noexcept; + WeakRef<IAssembly> Unmount() noexcept; private: IAssembly* fMounted{nullptr}; diff --git a/include/CompilerKit/ErrorOr.h b/include/CompilerKit/ErrorOr.h index 7cc418a..1d5c2ac 100644 --- a/include/CompilerKit/ErrorOr.h +++ b/include/CompilerKit/ErrorOr.h @@ -17,7 +17,7 @@ #include <CompilerKit/Detail/Config.h> #include <CompilerKit/ErrorID.h> -#include <CompilerKit/StrongRef.h> +#include <CompilerKit/Ref.h> namespace CompilerKit { using ErrorT = Int32; diff --git a/include/CompilerKit/Ref.h b/include/CompilerKit/Ref.h index d9b0593..c104a81 100644 --- a/include/CompilerKit/Ref.h +++ b/include/CompilerKit/Ref.h @@ -28,28 +28,27 @@ class StrongRef { } } - NECTI_COPY_DELETE(StrongRef) - NECTI_MOVE_DEFAULT(StrongRef) + NECTI_COPY_DEFAULT(StrongRef) using Type = T; protected: - explicit StrongRef(Type* cls, const bool strong) : m_Class(cls), m_Strong(strong) {} + StrongRef(Type* cls, const bool strong) : m_Class(cls), m_Strong(strong) {} public: - explicit StrongRef(Type* cls) : m_Class(cls), m_Strong(true) {} + StrongRef(Type* cls) : m_Class(cls), m_Strong(true) {} - StrongRef& operator=(Type ref) { - *m_Class = ref; + StrongRef& operator=(Type *ref) { + m_Class = ref; return *this; } public: Type* operator->() const { return m_Class; } - Type& Leak() { return *m_Class; } + Type* Leak() { return m_Class; } - Type operator*() { return *m_Class; } + Type* operator*() { return m_Class; } bool IsStrong() const { return m_Strong; } @@ -61,19 +60,17 @@ class StrongRef { }; template <typename T> -class WeakRef final : StrongRef<T> { +class WeakRef final : public StrongRef<T> { public: - WeakRef() = default; - + WeakRef() = delete; ~WeakRef() = default; - NECTI_COPY_DELETE(WeakRef) - NECTI_MOVE_DEFAULT(WeakRef) + NECTI_COPY_DEFAULT(WeakRef) public: using Type = T; - explicit WeakRef(Type* cls) : StrongRef<Type>(cls, false) {} + WeakRef(Type* cls) : StrongRef<Type>(cls, false) {} }; /// @author Amlal El Mahrouss @@ -82,7 +79,7 @@ template <typename Type> class NonNullRef final { public: explicit NonNullRef() = delete; - explicit NonNullRef(Type* ref) : m_Ref(ref, true) {} + NonNullRef(Type* ref) : m_Ref(ref, true) {} StrongRef<Type>& operator->() { MUST_PASS(m_Ref); diff --git a/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cc b/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cc index 44e2484..b5da2a8 100644 --- a/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cc +++ b/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cc @@ -5,7 +5,6 @@ ======================================== */ #include <CompilerKit/CodeGenerator.h> -#include <CompilerKit/ErrorID.h> /** * @file AssemblyFactory.cc @@ -32,20 +31,20 @@ Int32 AssemblyFactory::Compile(STLString sourceFile, const Int32& arch) noexcept } ///! @brief mount assembly backend. -void AssemblyFactory::Mount(IAssembly* mountPtr) noexcept { +void AssemblyFactory::Mount(WeakRef<IAssembly> mountPtr) noexcept { if (mountPtr) { - fMounted = mountPtr; + fMounted = mountPtr.Leak(); } } ///! @brief Unmount assembler. -IAssembly* AssemblyFactory::Unmount() noexcept { +WeakRef<IAssembly> AssemblyFactory::Unmount() noexcept { auto mount_prev = fMounted; if (fMounted) { fMounted = nullptr; } - return mount_prev; + return WeakRef<IAssembly>{mount_prev}; } } // namespace CompilerKit diff --git a/src/CompilerKit/src/Compilers/CCompiler+64x0.cc b/src/CompilerKit/src/Compilers/CCompiler+64x0.cc index 394f933..f18b22b 100644 --- a/src/CompilerKit/src/Compilers/CCompiler+64x0.cc +++ b/src/CompilerKit/src/Compilers/CCompiler+64x0.cc @@ -1191,7 +1191,9 @@ NECTI_MODULE(CompilerCLang64x0) { bool skip = false; - kFactory.Mount(new AssemblyCCInterface()); + CompilerKit::StrongRef<AssemblyCCInterface> mntPnt{new AssemblyCCInterface()}; + + kFactory.Mount({mntPnt.Leak()}); kMachine = CompilerKit::AssemblyFactory::kArch64x0; kCompilerFrontend = new CompilerFrontend64x0(); diff --git a/src/CompilerKit/src/Compilers/CCompiler+ARM64.cc b/src/CompilerKit/src/Compilers/CCompiler+ARM64.cc index 7b99b70..e0f08e2 100644 --- a/src/CompilerKit/src/Compilers/CCompiler+ARM64.cc +++ b/src/CompilerKit/src/Compilers/CCompiler+ARM64.cc @@ -1190,7 +1190,9 @@ NECTI_MODULE(CompilerCLangARM64) { bool skip = false; - kFactory.Mount(new AssemblyCCInterface()); + CompilerKit::StrongRef<AssemblyCCInterface> mntPnt{new AssemblyCCInterface()}; + + kFactory.Mount({mntPnt.Leak()}); kMachine = CompilerKit::AssemblyFactory::kArchAARCH64; kCompilerFrontend = new CompilerFrontendARM64(); diff --git a/src/CompilerKit/src/Compilers/CCompiler+Power64.cc b/src/CompilerKit/src/Compilers/CCompiler+Power64.cc index 993ee7c..724e7cc 100644 --- a/src/CompilerKit/src/Compilers/CCompiler+Power64.cc +++ b/src/CompilerKit/src/Compilers/CCompiler+Power64.cc @@ -1202,7 +1202,9 @@ NECTI_MODULE(CompilerCLangPowerPC) { bool skip = false; - kFactory.Mount(new AssemblyMountpointCLang()); + CompilerKit::StrongRef<AssemblyMountpointCLang> mntPnt{new AssemblyMountpointCLang()}; + + kFactory.Mount({mntPnt.Leak()}); kMachine = CompilerKit::AssemblyFactory::kArchPowerPC; kCompilerFrontend = new CompilerFrontendPower64(); diff --git a/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc b/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc index 4f85f05..70de909 100644 --- a/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc +++ b/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc @@ -819,7 +819,9 @@ NECTI_MODULE(CompilerCPlusPlusAMD64) { kErrorLimit = 0; kFrontend = new CompilerFrontendCPlusPlusAMD64(); - kAssembler.Mount(new AssemblyCPlusPlusInterfaceAMD64()); + + CompilerKit::StrongRef<AssemblyCPlusPlusInterfaceAMD64> mntPnt{new AssemblyCPlusPlusInterfaceAMD64()}; + kAssembler.Mount({mntPnt.Leak()}); CompilerKit::install_signal(SIGSEGV, CompilerKit::Detail::drvi_crash_handler); diff --git a/src/CompilerKit/src/DynamicLinkers/DynamicLinker64+PEF.cc b/src/CompilerKit/src/DynamicLinkers/DynamicLinker64+PEF.cc index 0fffa84..0361873 100644 --- a/src/CompilerKit/src/DynamicLinkers/DynamicLinker64+PEF.cc +++ b/src/CompilerKit/src/DynamicLinkers/DynamicLinker64+PEF.cc @@ -27,6 +27,8 @@ #define kPefNoCpu (0U) #define kPefNoSubCpu (0U) +#define kPefDefaultOutput {"a" kPefExt} + #define kLinkerDefaultOrigin kPefBaseOrigin #define kLinkerId (0x5046FF) #define kLinkerAbiContainer "__PEFContainer:ABI:" @@ -48,7 +50,7 @@ enum { kABITypeInvalid = 0xFFFF, }; -static CompilerKit::STLString kOutput = "a" kPefExt; +static CompilerKit::STLString kOutput = kPefDefaultOutput; static Int32 kAbi = kABITypeNE; static Int32 kSubArch = kPefNoSubCpu; static Int32 kArch = CompilerKit::kPefArchInvalid; |
