diff options
26 files changed, 47 insertions, 37 deletions
diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx index 95d795ea..15c9b7e5 100644 --- a/Boot/Sources/HEL/AMD64/BootMain.cxx +++ b/Boot/Sources/HEL/AMD64/BootMain.cxx @@ -15,7 +15,7 @@ #include <KernelKit/PE.hxx> #include <KernelKit/PEF.hxx> #include <NewKit/Macros.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #include <BootKit/ProgramLoader.hxx> #include <cstring> diff --git a/Kernel/CFKit/GUIDWizard.hpp b/Kernel/CFKit/GUIDWizard.hpp index 43c0fd89..59e83153 100644 --- a/Kernel/CFKit/GUIDWizard.hpp +++ b/Kernel/CFKit/GUIDWizard.hpp @@ -11,7 +11,7 @@ #include <NewKit/ArrayList.hpp> #include <NewKit/Defines.hpp> #include <NewKit/ErrorOr.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #include <NewKit/Stream.hpp> #include <NewKit/String.hpp> diff --git a/Kernel/CFKit/GUIDWrapper.hpp b/Kernel/CFKit/GUIDWrapper.hpp index c3293365..fe9e373b 100644 --- a/Kernel/CFKit/GUIDWrapper.hpp +++ b/Kernel/CFKit/GUIDWrapper.hpp @@ -7,7 +7,7 @@ #pragma once #include <NewKit/Defines.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #include <NewKit/Stream.hpp> /* GUID for C++ Components */ diff --git a/Kernel/KernelKit/DeviceManager.hpp b/Kernel/KernelKit/DeviceManager.hpp index 125422c8..8261834d 100644 --- a/Kernel/KernelKit/DeviceManager.hpp +++ b/Kernel/KernelKit/DeviceManager.hpp @@ -19,7 +19,7 @@ /* @brief Device abstraction and I/O buffer. */ #include <NewKit/ErrorOr.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> // Last Rev // Wed, Apr 3, 2024 9:09:41 AM diff --git a/Kernel/KernelKit/FileManager.hpp b/Kernel/KernelKit/FileManager.hpp index 1e9fbb75..0d721ec0 100644 --- a/Kernel/KernelKit/FileManager.hpp +++ b/Kernel/KernelKit/FileManager.hpp @@ -26,7 +26,7 @@ #include <KernelKit/DebugOutput.hpp> #include <NewKit/Stream.hpp> #include <NewKit/ErrorOr.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> /// @brief Filesystem manager, abstraction over mounted filesystem. /// Works like the VFS or IFS. diff --git a/Kernel/KernelKit/Framebuffer.hpp b/Kernel/KernelKit/Framebuffer.hpp index 170ab2a4..3d0914ef 100644 --- a/Kernel/KernelKit/Framebuffer.hpp +++ b/Kernel/KernelKit/Framebuffer.hpp @@ -11,7 +11,7 @@ #define __INC_FB_HPP__ #include <NewKit/Defines.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/KernelKit/PCI/Dma.hpp b/Kernel/KernelKit/PCI/Dma.hpp index e5e44c0b..dfac226f 100644 --- a/Kernel/KernelKit/PCI/Dma.hpp +++ b/Kernel/KernelKit/PCI/Dma.hpp @@ -10,7 +10,7 @@ #include <KernelKit/PCI/Device.hpp> #include <NewKit/Array.hpp> #include <NewKit/OwnPtr.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/KernelKit/PCI/IO.hpp b/Kernel/KernelKit/PCI/IO.hpp index 6328921d..90e9244d 100644 --- a/Kernel/KernelKit/PCI/IO.hpp +++ b/Kernel/KernelKit/PCI/IO.hpp @@ -9,7 +9,7 @@ #include <ArchKit/ArchKit.hpp> #include <NewKit/Array.hpp> #include <NewKit/Defines.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/KernelKit/PCI/Iterator.hpp b/Kernel/KernelKit/PCI/Iterator.hpp index 2274df31..0d6d894c 100644 --- a/Kernel/KernelKit/PCI/Iterator.hpp +++ b/Kernel/KernelKit/PCI/Iterator.hpp @@ -5,7 +5,7 @@ #include <KernelKit/PCI/Device.hpp> #include <NewKit/Array.hpp> #include <NewKit/Defines.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #define NEWOS_BUS_COUNT (256) #define NEWOS_DEVICE_COUNT (33) diff --git a/Kernel/KernelKit/ProcessHeap.hxx b/Kernel/KernelKit/ProcessHeap.hxx index d2ec4035..7772398e 100644 --- a/Kernel/KernelKit/ProcessHeap.hxx +++ b/Kernel/KernelKit/ProcessHeap.hxx @@ -10,7 +10,7 @@ #include <NewKit/ArrayList.hpp> #include <NewKit/ErrorOr.hpp> #include <NewKit/PageManager.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #include <NewKit/Pmm.hpp> /// @version 5/11/23 diff --git a/Kernel/KernelKit/ProcessScheduler.hxx b/Kernel/KernelKit/ProcessScheduler.hxx index 3f6e7828..1785e145 100644 --- a/Kernel/KernelKit/ProcessScheduler.hxx +++ b/Kernel/KernelKit/ProcessScheduler.hxx @@ -266,7 +266,7 @@ namespace Kernel SizeT Run() noexcept; public: - STATIC Ref<ProcessScheduler&> The(); + STATIC Ref<ProcessScheduler>& The(); private: ProcessTeam mTeam; diff --git a/Kernel/KernelKit/SMPManager.hpp b/Kernel/KernelKit/SMPManager.hpp index 69c8b54e..cb6b7884 100644 --- a/Kernel/KernelKit/SMPManager.hpp +++ b/Kernel/KernelKit/SMPManager.hpp @@ -9,7 +9,7 @@ #include <ArchKit/ArchKit.hpp> #include <CompilerKit/CompilerKit.hxx> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> // Last Rev // Sat Feb 24 CET 2024 diff --git a/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx b/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx index 6beb12a9..2977ff2e 100644 --- a/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx +++ b/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx @@ -10,7 +10,7 @@ #include <Modules/ACPI/ACPI.hxx> #include <KernelKit/DebugOutput.hpp> #include <NewKit/Defines.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/NetworkKit/IP.hpp b/Kernel/NetworkKit/IP.hpp index 5e29cc1f..80c4ba54 100644 --- a/Kernel/NetworkKit/IP.hpp +++ b/Kernel/NetworkKit/IP.hpp @@ -8,7 +8,7 @@ #include <KernelKit/DebugOutput.hpp> #include <NewKit/Defines.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #include <NewKit/String.hpp> namespace Kernel diff --git a/Kernel/NewKit/ErrorOr.hpp b/Kernel/NewKit/ErrorOr.hpp index a528de57..7e261abf 100644 --- a/Kernel/NewKit/ErrorOr.hpp +++ b/Kernel/NewKit/ErrorOr.hpp @@ -10,7 +10,7 @@ #pragma once #include <NewKit/Defines.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/NewKit/NewKit.hpp b/Kernel/NewKit/NewKit.hpp index 761a0411..144a0ea9 100644 --- a/Kernel/NewKit/NewKit.hpp +++ b/Kernel/NewKit/NewKit.hpp @@ -16,7 +16,7 @@ #include <NewKit/MutableArray.hpp> #include <NewKit/New.hpp> #include <NewKit/OwnPtr.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #include <NewKit/Stream.hpp> #include <KernelKit/ProcessHeap.hxx> #include <NewKit/Utils.hpp> diff --git a/Kernel/NewKit/OwnPtr.hpp b/Kernel/NewKit/OwnPtr.hpp index 7aa2a247..6157a1b6 100644 --- a/Kernel/NewKit/OwnPtr.hpp +++ b/Kernel/NewKit/OwnPtr.hpp @@ -9,7 +9,7 @@ #include <NewKit/Defines.hpp> #include <NewKit/KernelCheck.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/NewKit/PageManager.hpp b/Kernel/NewKit/PageManager.hpp index 89c449f7..57b842ba 100644 --- a/Kernel/NewKit/PageManager.hpp +++ b/Kernel/NewKit/PageManager.hpp @@ -11,7 +11,7 @@ #include <NewKit/Defines.hpp> #include <NewKit/PageAllocator.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #ifndef kBadAddress #define kBadAddress (0) diff --git a/Kernel/NewKit/Pmm.hpp b/Kernel/NewKit/Pmm.hpp index 8c918de4..46db1879 100644 --- a/Kernel/NewKit/Pmm.hpp +++ b/Kernel/NewKit/Pmm.hpp @@ -8,7 +8,7 @@ #pragma once #include <NewKit/PageManager.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/NewKit/Ref.hpp b/Kernel/NewKit/Ref.hxx index 0b0f89cc..69150054 100644 --- a/Kernel/NewKit/Ref.hpp +++ b/Kernel/NewKit/Ref.hxx @@ -18,39 +18,47 @@ namespace Kernel { public: Ref() = default; - ~Ref() = default; + + ~Ref() + { + if (fStrong) + { + fClass = nullptr; + } + } public: Ref(T cls, const bool& strong = false) - : fClass(cls), fStrong(strong) + : fClass(&cls), fStrong(strong) { } Ref& operator=(T ref) { - fClass = ref; + *fClass = ref; return *this; } public: T operator->() const { - return fClass; + return *fClass; } T& Leak() noexcept { - return fClass; + return *fClass; } - T& Fetch() const noexcept + T& TryLeak() const noexcept { - return fClass; + MUST_PASS(*fClass); + return *fClass; } T operator*() { - return fClass; + return *fClass; } bool IsStrong() const @@ -64,8 +72,8 @@ namespace Kernel } private: - T fClass; - bool fStrong{false}; + T* fClass; + Bool fStrong{false}; }; template <typename T> diff --git a/Kernel/NewKit/Stream.hpp b/Kernel/NewKit/Stream.hpp index b615dc77..eefb0a1c 100644 --- a/Kernel/NewKit/Stream.hpp +++ b/Kernel/NewKit/Stream.hpp @@ -8,7 +8,7 @@ #pragma once #include <NewKit/Defines.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/Sources/GUIDWizard.cxx b/Kernel/Sources/GUIDWizard.cxx index be7ad627..71488096 100644 --- a/Kernel/Sources/GUIDWizard.cxx +++ b/Kernel/Sources/GUIDWizard.cxx @@ -10,7 +10,7 @@ ------------------------------------------- */ #include <CFKit/GUIDWizard.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> // begin of ascii 'readable' characters. (A, C, C, 1, 2) #define kAsciiBegin 47 diff --git a/Kernel/Sources/ProcessScheduler.cxx b/Kernel/Sources/ProcessScheduler.cxx index 34bc321d..b3e79c97 100644 --- a/Kernel/Sources/ProcessScheduler.cxx +++ b/Kernel/Sources/ProcessScheduler.cxx @@ -301,12 +301,14 @@ namespace Kernel return mTeam; } + /// @internal + STATIC Ref<ProcessScheduler> cSchedulerRef; + /// @brief Shared instance of the process scheduler. /// @return - Ref<ProcessScheduler&> ProcessScheduler::The() + Ref<ProcessScheduler>& ProcessScheduler::The() { - static ProcessScheduler ref; - return {ref}; + return cSchedulerRef; } /// @brief Gets current running process. diff --git a/Kernel/Sources/Ref.cxx b/Kernel/Sources/Ref.cxx index d9eb039a..b92ceac4 100644 --- a/Kernel/Sources/Ref.cxx +++ b/Kernel/Sources/Ref.cxx @@ -4,4 +4,4 @@ ------------------------------------------- */ -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> diff --git a/Kernel/StorageKit/PRDT.hpp b/Kernel/StorageKit/PRDT.hpp index 62dbfb5a..daf465d4 100644 --- a/Kernel/StorageKit/PRDT.hpp +++ b/Kernel/StorageKit/PRDT.hpp @@ -8,7 +8,7 @@ #include <KernelKit/PCI/Dma.hpp> #include <KernelKit/PCI/Iterator.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #define kPrdtTransferSize (sizeof(Kernel::UShort)) diff --git a/newoskrnl.files b/newoskrnl.files index 762df4f9..d8988b7b 100644 --- a/newoskrnl.files +++ b/newoskrnl.files @@ -236,7 +236,7 @@ Kernel/NewKit/PageAllocator.hpp Kernel/NewKit/PageManager.hpp
Kernel/NewKit/Pair.hpp
Kernel/NewKit/Pmm.hpp
-Kernel/NewKit/Ref.hpp
+Kernel/NewKit/Ref.hxx
Kernel/NewKit/Stream.hpp
Kernel/NewKit/String.hpp
Kernel/NewKit/Utils.hpp
|
