so long gay bowser

This commit is contained in:
Reece Wilson 2022-01-19 17:53:33 +00:00
parent bafe2893b8
commit d26471b173
8 changed files with 67 additions and 19 deletions

View File

@ -129,7 +129,7 @@ namespace Aurora::Async
#define ASYNC_ERROR(exp) { if constexpr (AuIsSame_v<T, bool>) { SysPushErrorGen(exp); return {}; } else { throw std::string(exp); } } #define ASYNC_ERROR(exp) { if constexpr (AuIsSame_v<T, bool>) { SysPushErrorGen(exp); return {}; } else { throw std::string(exp); } }
#define ASYNC_FINISH { if constexpr (AuIsSame_v<T, bool>) { return true; } } #define ASYNC_FINISH { if constexpr (AuIsSame_v<T, bool>) { return true; } }
template<typename T = void, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || std::is_void<T>::value)> template<typename T = void, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || AuIsVoid_v<T>)>
static AuFunction<T(Args&&...)> TranslateAsyncFunctionToDispatcherWithThread(WorkerId_t id, AuFunction<void(Args...)> func) static AuFunction<T(Args&&...)> TranslateAsyncFunctionToDispatcherWithThread(WorkerId_t id, AuFunction<void(Args...)> func)
{ {
if (!func) return {}; if (!func) return {};
@ -147,14 +147,14 @@ namespace Aurora::Async
} }
/// Async app only /// Async app only
template<typename T = void, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || std::is_void<T>::value)> template<typename T = void, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || AuIsVoid_v<T>)>
static AuFunction<T(Args&&...)> TranslateAsyncFunctionToDispatcher(AuFunction<void(Args...)> func) static AuFunction<T(Args&&...)> TranslateAsyncFunctionToDispatcher(AuFunction<void(Args...)> func)
{ {
return TranslateAsyncFunctionToDispatcherWithThread(GetAsyncApp()->GetCurrentThread(), func); return TranslateAsyncFunctionToDispatcherWithThread(GetAsyncApp()->GetCurrentThread(), func);
} }
/// Async app only /// Async app only
template<typename B = void, typename T, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || std::is_void<T>::value)> template<typename B = void, typename T, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || AuIsVoid_v<T>)>
static AuFunction<T(AuFunction<void(const B&)>, Args...)> TranslateAsyncReturnableFunctionToDispatcherWithThread(WorkerId_t id, AuFunction<B(Args...)> func) static AuFunction<T(AuFunction<void(const B&)>, Args...)> TranslateAsyncReturnableFunctionToDispatcherWithThread(WorkerId_t id, AuFunction<B(Args...)> func)
{ {
return [=](AuFunction<T(const B&)> callback, Args... in) -> T return [=](AuFunction<T(const B&)> callback, Args... in) -> T

View File

@ -103,7 +103,7 @@ namespace Aurora::Async
static AuSPtr<IWorkItem> DispathSmartWork(const WorkerId_t &worker, AuSPtr<Clazz_t> owner, FunctorTask_t task, FuckYou_t job, Args ... in) static AuSPtr<IWorkItem> DispathSmartWork(const WorkerId_t &worker, AuSPtr<Clazz_t> owner, FunctorTask_t task, FuckYou_t job, Args ... in)
{ {
return DispatchWork<std::tuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t>(worker, return DispatchWork<std::tuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t>(worker,
TaskFromTupleCallableWithBindOwner2<FTask<std::tuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), TaskFromTupleCallableWithBindOwner2<FTask<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task),
Async::JobFromTupleClazz<ReturnValue_t, AuSPtr<Clazz_t>, Args...>(job), Async::JobFromTupleClazz<ReturnValue_t, AuSPtr<Clazz_t>, Args...>(job),
AuMakeTuple<AuSPtr<Clazz_t>, Args...>(AU_FWD(owner), std::forward<Args>(in)...), AuMakeTuple<AuSPtr<Clazz_t>, Args...>(AU_FWD(owner), std::forward<Args>(in)...),
false); false);
@ -113,7 +113,7 @@ namespace Aurora::Async
static AuSPtr<IWorkItem> DispathSmartWorkEx(const WorkerId_t &worker, AuSPtr<Clazz_t> owner, FunctorTask_t task, FuckYou_t success, FuckYou2_t failure, Args ... in) static AuSPtr<IWorkItem> DispathSmartWorkEx(const WorkerId_t &worker, AuSPtr<Clazz_t> owner, FunctorTask_t task, FuckYou_t success, FuckYou2_t failure, Args ... in)
{ {
return DispatchWork<std::tuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t>(worker, return DispatchWork<std::tuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t>(worker,
TaskFromTupleCallableWithBindOwner2<FTask<std::tuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), TaskFromTupleCallableWithBindOwner2<FTask<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task),
Async::JobFromTupleClazzEx<ReturnValue_t, AuSPtr<Clazz_t>, Args...>(success, failure), Async::JobFromTupleClazzEx<ReturnValue_t, AuSPtr<Clazz_t>, Args...>(success, failure),
AuMakeTuple<AuSPtr<Clazz_t>, Args...>(AU_FWD(owner), std::forward<Args>(in)...), AuMakeTuple<AuSPtr<Clazz_t>, Args...>(AU_FWD(owner), std::forward<Args>(in)...),
false); false);

View File

@ -121,7 +121,7 @@ namespace Aurora::Async
auto pin = AuSharedFromThis(); auto pin = AuSharedFromThis();
std::function<void()> func = [pin]() AuFunction<void()> func = [pin]()
{ {
try try
{ {
@ -201,7 +201,7 @@ namespace Aurora::Async
{ {
if constexpr (IsCallbackPtr) if constexpr (IsCallbackPtr)
{ {
if constexpr (AuIsBaseOfTemplate<std::function, decltype(callback->onFailure)>::value) if constexpr (AuIsBaseOfTemplate<AURORA_RUNTIME_AU_FUNC, decltype(callback->onFailure)>::value)
{ {
if (!callback->onFailure) if (!callback->onFailure)
{ {
@ -213,7 +213,7 @@ namespace Aurora::Async
} }
else else
{ {
if constexpr (AuIsBaseOfTemplate<std::function, decltype(callback.onFailure)>::value) if constexpr (AuIsBaseOfTemplate<AURORA_RUNTIME_AU_FUNC, decltype(callback.onFailure)>::value)
{ {
if (!callback.onFailure) if (!callback.onFailure)
{ {

View File

@ -15,7 +15,7 @@ namespace Aurora::Console::Hooks
AUKN_SYM void AddSubscription(const AuSPtr<IConsoleSubscriber> &subscriber); AUKN_SYM void AddSubscription(const AuSPtr<IConsoleSubscriber> &subscriber);
AUKN_SYM void RemoveSubscription(const AuSPtr<IConsoleSubscriber> &subscriber); AUKN_SYM void RemoveSubscription(const AuSPtr<IConsoleSubscriber> &subscriber);
using LineHook_cb = std::function<void(const ConsoleMessage &string)>; using LineHook_cb = AuFunction<void(const ConsoleMessage &string)>;
/// @deprecated wont ever remove /// @deprecated wont ever remove
/// Most c++ styleguides would have you chuck an IConsoleSubscriber in your app somewhere /// Most c++ styleguides would have you chuck an IConsoleSubscriber in your app somewhere

View File

@ -14,7 +14,7 @@ namespace Aurora::Memory
{ {
if constexpr (AuIsClass_v<T>) if constexpr (AuIsClass_v<T>)
{ {
if constexpr (AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, std::remove_reference_t<T>>::value) if constexpr (AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, AuRemovePointer_t<T>>::value)
{ {
if (Read<AuUInt32>() != sizeof(typename T::value_type)) if (Read<AuUInt32>() != sizeof(typename T::value_type))
{ {
@ -32,7 +32,7 @@ namespace Aurora::Memory
return !this->flagReadError; return !this->flagReadError;
} }
else if constexpr (AuIsSame_v<std::remove_reference_t<T>, AuString>) else if constexpr (AuIsSame_v<AuRemovePointer_t<T>, AuString>)
{ {
out.resize(Read<AuUInt32>()); out.resize(Read<AuUInt32>());
Read(out.data(), out.size()); Read(out.data(), out.size());
@ -62,7 +62,7 @@ namespace Aurora::Memory
{ {
if constexpr (AuIsClass_v<T>) if constexpr (AuIsClass_v<T>)
{ {
if constexpr (AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, std::remove_reference_t<T>>::value) if constexpr (AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, AuRemovePointer_t<T>>::value)
{ {
Write<AuUInt32>(sizeof(typename T::value_type)); Write<AuUInt32>(sizeof(typename T::value_type));
Write<AuUInt32>(AuUInt32(in.size())); Write<AuUInt32>(AuUInt32(in.size()));
@ -74,7 +74,7 @@ namespace Aurora::Memory
return !this->flagWriteError; return !this->flagWriteError;
} }
else if constexpr (AuIsSame_v<std::remove_reference_t<T>, AuString>) else if constexpr (AuIsSame_v<AuRemovePointer_t<T>, AuString>)
{ {
Write<AuUInt32>(AuUInt32(in.size())); Write<AuUInt32>(AuUInt32(in.size()));
Write(in.data(), in.size()); Write(in.data(), in.size());

View File

@ -38,14 +38,14 @@ namespace Aurora::Memory
template<typename T> template<typename T>
T ZAlloc(Types::size_t length) T ZAlloc(Types::size_t length)
{ {
static_assert(!AuIsClass_v<typename std::remove_pointer<T>::type>, "Do not use heap/kmem apis with classes"); static_assert(!AuIsClass_v<AuRemovePointer_t<T>>, "Do not use heap/kmem apis with classes");
return reinterpret_cast<T>(_ZAlloc(length)); return reinterpret_cast<T>(_ZAlloc(length));
} }
template<typename T> template<typename T>
T ZAlloc(Types::size_t length, Types::size_t align) T ZAlloc(Types::size_t length, Types::size_t align)
{ {
static_assert(!AuIsClass_v<typename std::remove_pointer<T>::type>, "Do not use heap/kmem apis with classes"); static_assert(!AuIsClass_v<AuRemovePointer_t<T>>, "Do not use heap/kmem apis with classes");
return reinterpret_cast<T>(_ZAlloc(length, align)); return reinterpret_cast<T>(_ZAlloc(length, align));
} }
@ -66,7 +66,7 @@ namespace Aurora::Memory
template<typename T> template<typename T>
AuSPtr<T> AllocateFastArray(Types::size_t length, Types::size_t align = sizeof(T)) AuSPtr<T> AllocateFastArray(Types::size_t length, Types::size_t align = sizeof(T))
{ {
static_assert(!AuIsClass_v<typename std::remove_pointer<T>::type>, "Do not use heap/kmem apis with classes"); static_assert(!AuIsClass_v<AuRemovePointer_t<T>>, "Do not use heap/kmem apis with classes");
return AuSPtr<T>(reinterpret_cast<T *>(_FAlloc(length)), [](T *ptr) return AuSPtr<T>(reinterpret_cast<T *>(_FAlloc(length)), [](T *ptr)
{ {
_Free(ptr); _Free(ptr);
@ -102,14 +102,14 @@ namespace Aurora::Memory
template<typename T> template<typename T>
T FAlloc(Types::size_t length) T FAlloc(Types::size_t length)
{ {
static_assert(!AuIsClass_v<typename std::remove_pointer<T>::type>, "Do not use heap/kmem apis with classes"); static_assert(!AuIsClass_v<AuRemovePointer_t<T>>, "Do not use heap/kmem apis with classes");
return reinterpret_cast<T>(_FAlloc(length)); return reinterpret_cast<T>(_FAlloc(length));
} }
template<typename T> template<typename T>
T FAlloc(Types::size_t length, Types::size_t align) T FAlloc(Types::size_t length, Types::size_t align)
{ {
static_assert(!AuIsClass_v<typename std::remove_pointer<T>::type>, "Do not use heap/kmem apis with classes"); static_assert(!AuIsClass_v<AuRemovePointer_t<T>>, "Do not use heap/kmem apis with classes");
return reinterpret_cast<T>(_FAlloc(length, align)); return reinterpret_cast<T>(_FAlloc(length, align));
} }

View File

@ -60,6 +60,17 @@ namespace _audetail {
template <class> template <class>
AuFalseType test(...); AuFalseType test(...);
template <typename B>
std::true_type test_pre_ptr_convertible(const volatile B *);
template <typename>
std::false_type test_pre_ptr_convertible(const volatile void *);
template <typename, typename>
auto test_pre_is_base_of(...)->std::true_type;
template <typename B, typename D>
auto test_pre_is_base_of(int) ->
decltype(test_pre_ptr_convertible<B>(static_cast<D *>(nullptr)));
} }
template<class T> template<class T>
@ -69,6 +80,18 @@ struct AuIsClass : decltype(_audetail::test<T>(nullptr))
template<class T> template<class T>
inline constexpr bool AuIsClass_v = AuIsClass<T>::value; inline constexpr bool AuIsClass_v = AuIsClass<T>::value;
template <typename Base, typename Derived>
struct AuIsBaseOf :
AuBoolType<
AuIsClass_v<Base> &&
AuIsClass_v<Derived> &&
decltype(_audetail::test_pre_is_base_of<Base, Derived>(0))::value
>
{};
template <typename Base, typename Derived>
inline constexpr bool AuIsBaseOf_v = AuIsBaseOf<Base, Derived>::value;
template <class> template <class>
inline constexpr bool AuIsPointer_v = false; inline constexpr bool AuIsPointer_v = false;
@ -84,6 +107,31 @@ inline constexpr bool AuIsPointer_v<_Ty *volatile> = true;
template <class _Ty> template <class _Ty>
inline constexpr bool AuIsPointer_v<_Ty *const volatile> = true; inline constexpr bool AuIsPointer_v<_Ty *const volatile> = true;
template<class T>
struct AuRemovePointer {typedef T type;};
template<class T>
struct AuRemovePointer<T*> {typedef T type;};
template<class T>
struct AuRemovePointer<T* const> {typedef T type;};
template<class T>
struct AuRemovePointer<T* volatile> {typedef T type;};
template<class T>
struct AuRemovePointer<T* const volatile> {typedef T type;};
template<class T>
using AuRemovePointer_t = typename AuRemovePointer<T>::type;
template<class T>
using AuIsVoid = AuIsSame<void, T>;
template <class T>
inline constexpr bool AuIsVoid_v = AuIsVoid<T>::value;
#if !defined(AURORA_RUNTIME_AU_LIST) #if !defined(AURORA_RUNTIME_AU_LIST)
#define AURORA_RUNTIME_AU_LIST std::vector #define AURORA_RUNTIME_AU_LIST std::vector
#endif #endif

View File

@ -36,7 +36,7 @@ class WxSplitterLine : public wxWindow
{ {
public: public:
WxSplitterLine() {} WxSplitterLine() {}
WxSplitterLine(wxSize splitter, std::optional<wxColor> color, wxWindow *parent, wxWindowID winid) : wxWindow(parent, winid), _color(color) WxSplitterLine(wxSize splitter, AuOptional<wxColor> color, wxWindow *parent, wxWindowID winid) : wxWindow(parent, winid), _color(color)
{ {
SetMinSize(splitter); SetMinSize(splitter);
} }