From d26471b1733170339cf46143016f6d9af50ef44c Mon Sep 17 00:00:00 2001 From: Reece Date: Wed, 19 Jan 2022 17:53:33 +0000 Subject: [PATCH] so long gay bowser --- Include/Aurora/Async/Async.hpp | 6 +-- Include/Aurora/Async/WorkBasic.hpp | 4 +- Include/Aurora/Async/WorkPairImpl.hpp | 6 +-- Include/Aurora/Console/Hooks/Hooks.hpp | 2 +- .../Memory/ByteBuffer_TypedReadWrite.inl | 8 ++-- Include/Aurora/Memory/Memory.hpp | 10 ++-- Include/AuroraTypedefs.hpp | 48 +++++++++++++++++++ .../ConsoleWxWidgets/ConsoleWxWidgets.cpp | 2 +- 8 files changed, 67 insertions(+), 19 deletions(-) diff --git a/Include/Aurora/Async/Async.hpp b/Include/Aurora/Async/Async.hpp index 14393398..22208098 100644 --- a/Include/Aurora/Async/Async.hpp +++ b/Include/Aurora/Async/Async.hpp @@ -129,7 +129,7 @@ namespace Aurora::Async #define ASYNC_ERROR(exp) { if constexpr (AuIsSame_v) { SysPushErrorGen(exp); return {}; } else { throw std::string(exp); } } #define ASYNC_FINISH { if constexpr (AuIsSame_v) { return true; } } - template || std::is_void::value)> + template || AuIsVoid_v)> static AuFunction TranslateAsyncFunctionToDispatcherWithThread(WorkerId_t id, AuFunction func) { if (!func) return {}; @@ -147,14 +147,14 @@ namespace Aurora::Async } /// Async app only - template || std::is_void::value)> + template || AuIsVoid_v)> static AuFunction TranslateAsyncFunctionToDispatcher(AuFunction func) { return TranslateAsyncFunctionToDispatcherWithThread(GetAsyncApp()->GetCurrentThread(), func); } /// Async app only - template || std::is_void::value)> + template || AuIsVoid_v)> static AuFunction, Args...)> TranslateAsyncReturnableFunctionToDispatcherWithThread(WorkerId_t id, AuFunction func) { return [=](AuFunction callback, Args... in) -> T diff --git a/Include/Aurora/Async/WorkBasic.hpp b/Include/Aurora/Async/WorkBasic.hpp index c221f00e..ee738336 100644 --- a/Include/Aurora/Async/WorkBasic.hpp +++ b/Include/Aurora/Async/WorkBasic.hpp @@ -103,7 +103,7 @@ namespace Aurora::Async static AuSPtr DispathSmartWork(const WorkerId_t &worker, AuSPtr owner, FunctorTask_t task, FuckYou_t job, Args ... in) { return DispatchWork, Args...>, ReturnValue_t>(worker, - TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), + TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), Async::JobFromTupleClazz, Args...>(job), AuMakeTuple, Args...>(AU_FWD(owner), std::forward(in)...), false); @@ -113,7 +113,7 @@ namespace Aurora::Async static AuSPtr DispathSmartWorkEx(const WorkerId_t &worker, AuSPtr owner, FunctorTask_t task, FuckYou_t success, FuckYou2_t failure, Args ... in) { return DispatchWork, Args...>, ReturnValue_t>(worker, - TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), + TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), Async::JobFromTupleClazzEx, Args...>(success, failure), AuMakeTuple, Args...>(AU_FWD(owner), std::forward(in)...), false); diff --git a/Include/Aurora/Async/WorkPairImpl.hpp b/Include/Aurora/Async/WorkPairImpl.hpp index 2f330c57..db2bc884 100644 --- a/Include/Aurora/Async/WorkPairImpl.hpp +++ b/Include/Aurora/Async/WorkPairImpl.hpp @@ -121,7 +121,7 @@ namespace Aurora::Async auto pin = AuSharedFromThis(); - std::function func = [pin]() + AuFunction func = [pin]() { try { @@ -201,7 +201,7 @@ namespace Aurora::Async { if constexpr (IsCallbackPtr) { - if constexpr (AuIsBaseOfTemplateonFailure)>::value) + if constexpr (AuIsBaseOfTemplateonFailure)>::value) { if (!callback->onFailure) { @@ -213,7 +213,7 @@ namespace Aurora::Async } else { - if constexpr (AuIsBaseOfTemplate::value) + if constexpr (AuIsBaseOfTemplate::value) { if (!callback.onFailure) { diff --git a/Include/Aurora/Console/Hooks/Hooks.hpp b/Include/Aurora/Console/Hooks/Hooks.hpp index 7e01df84..b1f22ac2 100644 --- a/Include/Aurora/Console/Hooks/Hooks.hpp +++ b/Include/Aurora/Console/Hooks/Hooks.hpp @@ -15,7 +15,7 @@ namespace Aurora::Console::Hooks AUKN_SYM void AddSubscription(const AuSPtr &subscriber); AUKN_SYM void RemoveSubscription(const AuSPtr &subscriber); - using LineHook_cb = std::function; + using LineHook_cb = AuFunction; /// @deprecated wont ever remove /// Most c++ styleguides would have you chuck an IConsoleSubscriber in your app somewhere diff --git a/Include/Aurora/Memory/ByteBuffer_TypedReadWrite.inl b/Include/Aurora/Memory/ByteBuffer_TypedReadWrite.inl index 9e6d6bfb..75bf4a94 100644 --- a/Include/Aurora/Memory/ByteBuffer_TypedReadWrite.inl +++ b/Include/Aurora/Memory/ByteBuffer_TypedReadWrite.inl @@ -14,7 +14,7 @@ namespace Aurora::Memory { if constexpr (AuIsClass_v) { - if constexpr (AuIsBaseOfTemplate>::value) + if constexpr (AuIsBaseOfTemplate>::value) { if (Read() != sizeof(typename T::value_type)) { @@ -32,7 +32,7 @@ namespace Aurora::Memory return !this->flagReadError; } - else if constexpr (AuIsSame_v, AuString>) + else if constexpr (AuIsSame_v, AuString>) { out.resize(Read()); Read(out.data(), out.size()); @@ -62,7 +62,7 @@ namespace Aurora::Memory { if constexpr (AuIsClass_v) { - if constexpr (AuIsBaseOfTemplate>::value) + if constexpr (AuIsBaseOfTemplate>::value) { Write(sizeof(typename T::value_type)); Write(AuUInt32(in.size())); @@ -74,7 +74,7 @@ namespace Aurora::Memory return !this->flagWriteError; } - else if constexpr (AuIsSame_v, AuString>) + else if constexpr (AuIsSame_v, AuString>) { Write(AuUInt32(in.size())); Write(in.data(), in.size()); diff --git a/Include/Aurora/Memory/Memory.hpp b/Include/Aurora/Memory/Memory.hpp index f741c0ca..9b09eb14 100644 --- a/Include/Aurora/Memory/Memory.hpp +++ b/Include/Aurora/Memory/Memory.hpp @@ -38,14 +38,14 @@ namespace Aurora::Memory template T ZAlloc(Types::size_t length) { - static_assert(!AuIsClass_v::type>, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v>, "Do not use heap/kmem apis with classes"); return reinterpret_cast(_ZAlloc(length)); } template T ZAlloc(Types::size_t length, Types::size_t align) { - static_assert(!AuIsClass_v::type>, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v>, "Do not use heap/kmem apis with classes"); return reinterpret_cast(_ZAlloc(length, align)); } @@ -66,7 +66,7 @@ namespace Aurora::Memory template AuSPtr AllocateFastArray(Types::size_t length, Types::size_t align = sizeof(T)) { - static_assert(!AuIsClass_v::type>, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v>, "Do not use heap/kmem apis with classes"); return AuSPtr(reinterpret_cast(_FAlloc(length)), [](T *ptr) { _Free(ptr); @@ -102,14 +102,14 @@ namespace Aurora::Memory template T FAlloc(Types::size_t length) { - static_assert(!AuIsClass_v::type>, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v>, "Do not use heap/kmem apis with classes"); return reinterpret_cast(_FAlloc(length)); } template T FAlloc(Types::size_t length, Types::size_t align) { - static_assert(!AuIsClass_v::type>, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v>, "Do not use heap/kmem apis with classes"); return reinterpret_cast(_FAlloc(length, align)); } diff --git a/Include/AuroraTypedefs.hpp b/Include/AuroraTypedefs.hpp index f3e4a9b6..765703a5 100644 --- a/Include/AuroraTypedefs.hpp +++ b/Include/AuroraTypedefs.hpp @@ -60,6 +60,17 @@ namespace _audetail { template AuFalseType test(...); + + template + std::true_type test_pre_ptr_convertible(const volatile B *); + template + std::false_type test_pre_ptr_convertible(const volatile void *); + + template + auto test_pre_is_base_of(...)->std::true_type; + template + auto test_pre_is_base_of(int) -> + decltype(test_pre_ptr_convertible(static_cast(nullptr))); } template @@ -69,6 +80,18 @@ struct AuIsClass : decltype(_audetail::test(nullptr)) template inline constexpr bool AuIsClass_v = AuIsClass::value; +template +struct AuIsBaseOf : + AuBoolType< + AuIsClass_v && + AuIsClass_v && + decltype(_audetail::test_pre_is_base_of(0))::value + > +{}; + +template +inline constexpr bool AuIsBaseOf_v = AuIsBaseOf::value; + template inline constexpr bool AuIsPointer_v = false; @@ -84,6 +107,31 @@ inline constexpr bool AuIsPointer_v<_Ty *volatile> = true; template inline constexpr bool AuIsPointer_v<_Ty *const volatile> = true; +template +struct AuRemovePointer {typedef T type;}; + +template +struct AuRemovePointer {typedef T type;}; + +template +struct AuRemovePointer {typedef T type;}; + +template +struct AuRemovePointer {typedef T type;}; + +template +struct AuRemovePointer {typedef T type;}; + +template +using AuRemovePointer_t = typename AuRemovePointer::type; + +template +using AuIsVoid = AuIsSame; + +template +inline constexpr bool AuIsVoid_v = AuIsVoid::value; + + #if !defined(AURORA_RUNTIME_AU_LIST) #define AURORA_RUNTIME_AU_LIST std::vector #endif diff --git a/Source/Console/ConsoleWxWidgets/ConsoleWxWidgets.cpp b/Source/Console/ConsoleWxWidgets/ConsoleWxWidgets.cpp index 06392428..01af61e0 100644 --- a/Source/Console/ConsoleWxWidgets/ConsoleWxWidgets.cpp +++ b/Source/Console/ConsoleWxWidgets/ConsoleWxWidgets.cpp @@ -36,7 +36,7 @@ class WxSplitterLine : public wxWindow { public: WxSplitterLine() {} - WxSplitterLine(wxSize splitter, std::optional color, wxWindow *parent, wxWindowID winid) : wxWindow(parent, winid), _color(color) + WxSplitterLine(wxSize splitter, AuOptional color, wxWindow *parent, wxWindowID winid) : wxWindow(parent, winid), _color(color) { SetMinSize(splitter); }