From 6b9bddeeaf85e8f0c6521903ba59d8af4e532702 Mon Sep 17 00:00:00 2001 From: Reece Date: Wed, 19 Jan 2022 18:18:13 +0000 Subject: [PATCH] nuke more of the stl --- Include/Aurora/Async/Async.hpp | 4 +- Include/Aurora/Async/WorkPairImpl.hpp | 10 ++-- Include/Aurora/Memory/Heap.hpp | 4 +- Include/Aurora/Memory/MemoryView.hpp | 7 +-- Include/Aurora/Parse/Parser.hpp | 2 +- Include/Aurora/Telemetry/BlackBox.hpp | 5 +- Include/Aurora/Threading/LockGuard.hpp | 2 +- Include/Aurora/Threading/LockGuardTry.hpp | 2 +- .../Threading/Threads/IAuroraThread.hpp | 2 +- Include/AuroraTypedefs.hpp | 58 +++++++++++++++++++ Source/Async/AsyncRunnable.hpp | 4 +- Source/Async/Schedular.cpp | 2 +- Source/Console/Commands/Commands.cpp | 2 +- 13 files changed, 81 insertions(+), 23 deletions(-) diff --git a/Include/Aurora/Async/Async.hpp b/Include/Aurora/Async/Async.hpp index 22208098..a593836c 100644 --- a/Include/Aurora/Async/Async.hpp +++ b/Include/Aurora/Async/Async.hpp @@ -44,10 +44,10 @@ namespace Aurora::Async AuFunction callback; AuFunction shutdown; // error - BasicWorkStdFunc(AuFunction &&callback, AuFunction &&shutdown) : callback(std::move(callback)), shutdown(std::move(shutdown)) + BasicWorkStdFunc(AuFunction &&callback, AuFunction &&shutdown) : callback(AuMove(callback)), shutdown(AuMove(shutdown)) {} - BasicWorkStdFunc(AuFunction &&callback) : callback(std::move(callback)) + BasicWorkStdFunc(AuFunction &&callback) : callback(AuMove(callback)) {} BasicWorkStdFunc(const AuFunction &callback) : callback(callback) diff --git a/Include/Aurora/Async/WorkPairImpl.hpp b/Include/Aurora/Async/WorkPairImpl.hpp index db2bc884..9800f3dc 100644 --- a/Include/Aurora/Async/WorkPairImpl.hpp +++ b/Include/Aurora/Async/WorkPairImpl.hpp @@ -34,10 +34,10 @@ namespace Aurora::Async WorkPairImpl() : caller_(Async::GetCurrentWorkerPId()) {} - WorkPairImpl(Task_t &&task) : task(std::move(task)), caller_(Async::GetCurrentWorkerPId()) + WorkPairImpl(Task_t &&task) : task(AuMove(task)), caller_(Async::GetCurrentWorkerPId()) {} - WorkPairImpl(Task_t &&task, Job_t &&callback) : task(std::move(task)), callback(std::move(callback)), caller_(Async::GetCurrentWorkerPId()) + WorkPairImpl(Task_t &&task, Job_t &&callback) : task(AuMove(task)), callback(AuMove(callback)), caller_(Async::GetCurrentWorkerPId()) {} WorkPairImpl(const Task_t &task) : task(task), caller_(Async::GetCurrentWorkerPId()) @@ -49,13 +49,13 @@ namespace Aurora::Async WorkPairImpl(const Task_t &task, const Job_t &callback, const Info_t &info) : task(task), callback(callback), input(info), caller_(Async::GetCurrentWorkerPId()) {} - WorkPairImpl(Task_t &&task, const Job_t &callback, const Info_t &info) : task(std::move(task)), callback(callback), input(info), caller_(Async::GetCurrentWorkerPId()) + WorkPairImpl(Task_t &&task, const Job_t &callback, const Info_t &info) : task(AuMove(task)), callback(callback), input(info), caller_(Async::GetCurrentWorkerPId()) {} - WorkPairImpl(Task_t &&task, Job_t &&callback, const Info_t &info) : task(std::move(task)), callback(std::move(callback)), input(info), caller_(Async::GetCurrentWorkerPId()) + WorkPairImpl(Task_t &&task, Job_t &&callback, const Info_t &info) : task(AuMove(task)), callback(AuMove(callback)), input(info), caller_(Async::GetCurrentWorkerPId()) {} - WorkPairImpl(Task_t &&task, Job_t &&callback, Info_t &&info) : task(std::move(task)), callback(std::move(callback)), input(std::move(info)), caller_(Async::GetCurrentWorkerPId()) + WorkPairImpl(Task_t &&task, Job_t &&callback, Info_t &&info) : task(AuMove(task)), callback(AuMove(callback)), input(AuMove(info)), caller_(Async::GetCurrentWorkerPId()) {} WorkPairImpl(const Task_t &task, const Job_t &callback, Info_t &&info) : task(task), callback(callback), input(info), caller_(Async::GetCurrentWorkerPId()) diff --git a/Include/Aurora/Memory/Heap.hpp b/Include/Aurora/Memory/Heap.hpp index d0ddd85e..ff7d71ae 100644 --- a/Include/Aurora/Memory/Heap.hpp +++ b/Include/Aurora/Memory/Heap.hpp @@ -103,7 +103,7 @@ namespace Aurora::Memory { if (in == nullptr) return {}; auto heapHandle = pinThis ? GetSelfReference() : AuSPtr {}; - return std::shared_ptr(in, + return AuSPtr(in, [heapHandle, in, this](T *delt) { if constexpr (AuIsClass_v) @@ -119,7 +119,7 @@ namespace Aurora::Memory { auto handle = pinHeap ? heap : AuSPtr {}; auto ptr = heap.get(); // so long as in is a valid pointer within the heap, this is fine - return std::shared_ptr(in, + return AuSPtr(in, [handle, ptr](T *delt) { ptr->Free(delt); diff --git a/Include/Aurora/Memory/MemoryView.hpp b/Include/Aurora/Memory/MemoryView.hpp index 5b934dda..e4464bff 100644 --- a/Include/Aurora/Memory/MemoryView.hpp +++ b/Include/Aurora/Memory/MemoryView.hpp @@ -12,10 +12,10 @@ namespace Aurora::Memory template struct MemoryView { - using Void_t = std::conditional_t; + using Void_t = AuConditional_t; template - using StdArray_t = std::conditional_t, AuArray>; + using StdArray_t = AuConditional_t, AuArray>; /* YadaYada(MemoryView(tempstring/array/etc)) should be legal, right? @@ -119,7 +119,6 @@ namespace Aurora::Memory template struct MemoryViewStream : MemoryView { - // template::value>::type* = nullptr> template::value)> constexpr MemoryViewStream(T &list, AuUInt &length) : MemoryView(list), outVariable(length) { @@ -143,7 +142,7 @@ namespace Aurora::Memory outVariable = 0; } - template::value>::type* = nullptr> + template::value>::type* = nullptr> constexpr MemoryViewStream(T &list) : MemoryView(list), outVariable(unused) { outVariable = 0; diff --git a/Include/Aurora/Parse/Parser.hpp b/Include/Aurora/Parse/Parser.hpp index a9c805b9..9cadced0 100644 --- a/Include/Aurora/Parse/Parser.hpp +++ b/Include/Aurora/Parse/Parser.hpp @@ -135,7 +135,7 @@ namespace Aurora::Parse ParseState(ConsumeStream_cb &str) : stringstream(str) {} - ParseState(ConsumeStream_cb &&str) : stringstream(std::move(str)) + ParseState(ConsumeStream_cb &&str) : stringstream(AuMove(str)) {} ConsumeStream_cb stringstream; diff --git a/Include/Aurora/Telemetry/BlackBox.hpp b/Include/Aurora/Telemetry/BlackBox.hpp index 319c7276..c6b7dfba 100644 --- a/Include/Aurora/Telemetry/BlackBox.hpp +++ b/Include/Aurora/Telemetry/BlackBox.hpp @@ -158,8 +158,9 @@ namespace Aurora::Telemetry NewBlackboxEntryUpdateMap map; }; - using StreamWriter = std::function; - using StreamReader = std::function; + // TODO: port to lui + using StreamWriter = AuFunction; + using StreamReader = AuFunction; AUKN_SYM AuList ReadBlackboxStream(const StreamReader &reader); AUKN_SYM void WriteBlackboxStream(const AuList &, StreamWriter writer); diff --git a/Include/Aurora/Threading/LockGuard.hpp b/Include/Aurora/Threading/LockGuard.hpp index c9acb135..387d2368 100644 --- a/Include/Aurora/Threading/LockGuard.hpp +++ b/Include/Aurora/Threading/LockGuard.hpp @@ -13,7 +13,7 @@ namespace Aurora::Threading class LockGuard { private: - using Internal_t = std::remove_pointer_t; + using Internal_t = AuRemovePointer_t; public: diff --git a/Include/Aurora/Threading/LockGuardTry.hpp b/Include/Aurora/Threading/LockGuardTry.hpp index 10612faf..b915ed85 100644 --- a/Include/Aurora/Threading/LockGuardTry.hpp +++ b/Include/Aurora/Threading/LockGuardTry.hpp @@ -13,7 +13,7 @@ namespace Aurora::Threading class TryLockGuard { private: - using Internal_t = std::remove_pointer_t; + using Internal_t = AuRemovePointer_t; bool bLockSuccessful; public: diff --git a/Include/Aurora/Threading/Threads/IAuroraThread.hpp b/Include/Aurora/Threading/Threads/IAuroraThread.hpp index 9df583a1..7f80237c 100644 --- a/Include/Aurora/Threading/Threads/IAuroraThread.hpp +++ b/Include/Aurora/Threading/Threads/IAuroraThread.hpp @@ -69,6 +69,6 @@ namespace Aurora::Threading::Threads // UPDATE: DONE virtual void Detach() = 0; - virtual void ExecuteInDeadThread(std::function callback) = 0; + virtual void ExecuteInDeadThread(AuFunction callback) = 0; }; } \ No newline at end of file diff --git a/Include/AuroraTypedefs.hpp b/Include/AuroraTypedefs.hpp index 765703a5..13acd8ec 100644 --- a/Include/AuroraTypedefs.hpp +++ b/Include/AuroraTypedefs.hpp @@ -131,6 +131,64 @@ using AuIsVoid = AuIsSame; template inline constexpr bool AuIsVoid_v = AuIsVoid::value; +template +struct AuRemoveReference +{ + using type = T; +}; + +template +struct AuRemoveReference +{ + using type = T; +}; + +template +struct AuRemoveReference +{ + using type = T; +}; + +template +using AuRemoveReference_t = typename AuRemoveReference::type; + +template +constexpr AuRemoveReference_t &&AuMove(T &&arg) noexcept +{ + return static_cast &&>(arg); +} + + +template +struct AuEnableIf +{ +}; + +template +struct AuEnableIf +{ + using type = T; +}; + +template +using AuEnableIf_t = typename AuEnableIf::type; + + +template +struct AuConditional +{ + using type = T; +}; + +template +struct AuConditional +{ + using type = T2; +}; + +template +using AuConditional_t = typename AuConditional::type; + #if !defined(AURORA_RUNTIME_AU_LIST) #define AURORA_RUNTIME_AU_LIST std::vector diff --git a/Source/Async/AsyncRunnable.hpp b/Source/Async/AsyncRunnable.hpp index 4c9590a0..75598d28 100644 --- a/Source/Async/AsyncRunnable.hpp +++ b/Source/Async/AsyncRunnable.hpp @@ -26,10 +26,10 @@ namespace Aurora::Async AuFunction fail; AuThreadPrimitives::SpinLock lock; - AsyncFuncRunnable(AuFunction &&callback) : callback(std::move(callback)) + AsyncFuncRunnable(AuFunction &&callback) : callback(AuMove(callback)) {} - AsyncFuncRunnable(AuFunction &&callback, AuFunction &&fail) : callback(std::move(callback)), fail(std::move(fail)) + AsyncFuncRunnable(AuFunction &&callback, AuFunction &&fail) : callback(AuMove(callback)), fail(AuMove(fail)) {} AsyncFuncRunnable(const AuFunction &callback) : callback(callback) diff --git a/Source/Async/Schedular.cpp b/Source/Async/Schedular.cpp index 2dfbb45a..43270766 100644 --- a/Source/Async/Schedular.cpp +++ b/Source/Async/Schedular.cpp @@ -35,7 +35,7 @@ namespace Aurora::Async { if (itr->ns <= time) { - if (!AuTryInsert(pending, std::move(*itr))) + if (!AuTryInsert(pending, AuMove(*itr))) { break; } diff --git a/Source/Console/Commands/Commands.cpp b/Source/Console/Commands/Commands.cpp index d0f40132..8f0e0437 100644 --- a/Source/Console/Commands/Commands.cpp +++ b/Source/Console/Commands/Commands.cpp @@ -27,7 +27,7 @@ namespace Aurora::Console::Commands AuSPtr callback; Command(AuString tag, Parse::ParseObject commandStructure, const AuSPtr &callback) : tag(tag), commandStructure(commandStructure), callback(callback) {} - Command(AuString tag, Parse::ParseObject commandStructure, AuSPtr &&callback) : tag(tag), commandStructure(commandStructure), callback(std::move(callback)) {} + Command(AuString tag, Parse::ParseObject commandStructure, AuSPtr &&callback) : tag(tag), commandStructure(commandStructure), callback(AuMove(callback)) {} }; struct CommandDispatch