diff --git a/Include/Aurora/Async/Async.hpp b/Include/Aurora/Async/Async.hpp index e2c2e09a..14393398 100644 --- a/Include/Aurora/Async/Async.hpp +++ b/Include/Aurora/Async/Async.hpp @@ -126,10 +126,10 @@ namespace Aurora::Async }; - #define ASYNC_ERROR(exp) { if constexpr (std::is_same_v) { SysPushErrorGen(exp); return {}; } else { throw std::string(exp); } } - #define ASYNC_FINISH { if constexpr (std::is_same_v) { return true; } } + #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 || std::is_void::value)> 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 || std::is_void::value)> static AuFunction TranslateAsyncFunctionToDispatcher(AuFunction func) { return TranslateAsyncFunctionToDispatcherWithThread(GetAsyncApp()->GetCurrentThread(), func); } /// Async app only - template || std::is_void::value)> + template || std::is_void::value)> static AuFunction, Args...)> TranslateAsyncReturnableFunctionToDispatcherWithThread(WorkerId_t id, AuFunction func) { return [=](AuFunction callback, Args... in) -> T diff --git a/Include/Aurora/Async/JobFrom.hpp b/Include/Aurora/Async/JobFrom.hpp index 4a4f9682..f0f5093c 100644 --- a/Include/Aurora/Async/JobFrom.hpp +++ b/Include/Aurora/Async/JobFrom.hpp @@ -32,28 +32,28 @@ namespace Aurora::Async } template - FJob, Out_t> JobFromTupleConsumer(/*AuConsumer */ Callable_t &&onSuccess) + FJob, Out_t> JobFromTupleConsumer(/*AuConsumer */ Callable_t &&onSuccess) { - FJob, Out_t> ret; - static_assert(std::is_same_v, std::tuple>); - ret.onSuccess = [=](const std::tuple &in, const Out_t &a) + FJob, Out_t> ret; + static_assert(AuIsSame_v, AuTuple>); + ret.onSuccess = [=](const AuTuple &in, const Out_t &a) { - std::apply(onSuccess, std::tuple_cat(in, std::make_tuple(a))); + std::apply(onSuccess, std::tuple_cat(in, AuMakeTuple(a))); }; return ret; } template - FJob, Out_t> JobFromTupleConsumerEx(/*AuConsumer */ Callable_t &&onSuccess, FailureCallable_t &&onFailure) + FJob, Out_t> JobFromTupleConsumerEx(/*AuConsumer */ Callable_t &&onSuccess, FailureCallable_t &&onFailure) { - FJob, Out_t> ret; - static_assert(std::is_same_v, std::tuple>); - ret.onSuccess = [=](const std::tuple &in, const Out_t &a) + FJob, Out_t> ret; + static_assert(AuIsSame_v, AuTuple>); + ret.onSuccess = [=](const AuTuple &in, const Out_t &a) { - std::apply(onSuccess, std::tuple_cat(in, std::make_tuple(a))); + std::apply(onSuccess, std::tuple_cat(in, AuMakeTuple(a))); }; - ret.onFailure = [=](const std::tuple &in) + ret.onFailure = [=](const AuTuple &in) { std::apply(onFailure, in); }; @@ -112,10 +112,10 @@ namespace Aurora::Async } template - static inline FJob, ReturnValue_t> JobFromTupleClazz(const AuConsumer &onSuccess) + static inline FJob, ReturnValue_t> JobFromTupleClazz(const AuConsumer &onSuccess) { - FJob, ReturnValue_t> ret; - ret.onSuccess = [=](const std::tuple &in, const ReturnValue_t &out) + FJob, ReturnValue_t> ret; + ret.onSuccess = [=](const AuTuple &in, const ReturnValue_t &out) { onSuccess(std::get<0>(in), out); }; @@ -123,15 +123,15 @@ namespace Aurora::Async } template - static inline FJob, ReturnValue_t> JobFromTupleClazzEx(const AuConsumer &onSuccess, const AuConsumer &onFailure) + static inline FJob, ReturnValue_t> JobFromTupleClazzEx(const AuConsumer &onSuccess, const AuConsumer &onFailure) { - FJob, ReturnValue_t> ret; - ret.onSuccess = [=](const std::tuple &in, const ReturnValue_t &out) + FJob, ReturnValue_t> ret; + ret.onSuccess = [=](const AuTuple &in, const ReturnValue_t &out) { onSuccess(std::get<0>(in), out); }; - ret.onFailure = [=](const std::tuple &in) + ret.onFailure = [=](const AuTuple &in) { onFailure(std::get<0>(in)); }; @@ -140,10 +140,10 @@ namespace Aurora::Async #if 0 template - static inline FJob, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer &onSuccess) + static inline FJob, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer &onSuccess) { - FJob, Args...>, ReturnValue_t> ret; - ret.onSuccess = [=](const std::tuple, Args...> &in, const ReturnValue_t &out) + FJob, Args...>, ReturnValue_t> ret; + ret.onSuccess = [=](const AuTuple, Args...> &in, const ReturnValue_t &out) { onSuccess(out); }; @@ -151,22 +151,22 @@ namespace Aurora::Async } template - static inline FJob, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer &onSuccess) + static inline FJob, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer &onSuccess) { - FJob, Args...>, ReturnValue_t> ret; - ret.onSuccess = [=](const std::tuple, Args...> &in, const ReturnValue_t &out) + FJob, Args...>, ReturnValue_t> ret; + ret.onSuccess = [=](const AuTuple, Args...> &in, const ReturnValue_t &out) { - std::apply(onSuccess, std::tuple_cat(AuTuplePopFront(in), std::make_tuple(out))); + std::apply(onSuccess, std::tuple_cat(AuTuplePopFront(in), AuMakeTuple(out))); }; return ret; } #endif template - static inline FJob, ReturnValue_t> JobFromTupleResultConsumer(const AuConsumer &onSuccess) + static inline FJob, ReturnValue_t> JobFromTupleResultConsumer(const AuConsumer &onSuccess) { - FJob, ReturnValue_t> ret; - ret.onSuccess = [=](const std::tuple &in, const ReturnValue_t &out) + FJob, ReturnValue_t> ret; + ret.onSuccess = [=](const AuTuple &in, const ReturnValue_t &out) { onSuccess(out); }; @@ -174,12 +174,12 @@ namespace Aurora::Async } template - static inline FJob, ReturnValue_t> JobFromTuple(const AuConsumer &onSuccess) + static inline FJob, ReturnValue_t> JobFromTuple(const AuConsumer &onSuccess) { - FJob, ReturnValue_t> ret; - ret.onSuccess = [=](const std::tuple &in, const ReturnValue_t &out) + FJob, ReturnValue_t> ret; + ret.onSuccess = [=](const AuTuple &in, const ReturnValue_t &out) { - std::apply(onSuccess, std::tuple_cat(in, std::make_tuple(out))); + std::apply(onSuccess, std::tuple_cat(in, AuMakeTuple(out))); }; return ret; } diff --git a/Include/Aurora/Async/TaskFrom.hpp b/Include/Aurora/Async/TaskFrom.hpp index a05a311f..ac58644a 100644 --- a/Include/Aurora/Async/TaskFrom.hpp +++ b/Include/Aurora/Async/TaskFrom.hpp @@ -15,7 +15,7 @@ namespace Aurora::Async FTask ret; ret.onFrame = [callable = func](const Info_t &in) -> Out_t { - if constexpr (std::is_same_v) + if constexpr (AuIsSame_v) { callable(in); return {}; @@ -29,11 +29,11 @@ namespace Aurora::Async } template - FTask, Out_t> TaskFromTupleCallable(Functor &&func) + FTask, Out_t> TaskFromTupleCallable(Functor &&func) { - FTask, Out_t> ret; - static_assert(std::is_same_v, std::tuple>); - ret.onFrame = [callable = func](const std::tuple &in) -> Out_t + FTask, Out_t> ret; + static_assert(AuIsSame_v, AuTuple>); + ret.onFrame = [callable = func](const AuTuple &in) -> Out_t { return std::apply(callable, in); }; @@ -41,12 +41,12 @@ namespace Aurora::Async } template - FTask, Out_t> TaskFromTupleCallableWithOwnerArg(AuFunction &&func, const Owner_t &ownerToPin) + FTask, Out_t> TaskFromTupleCallableWithOwnerArg(AuFunction &&func, const Owner_t &ownerToPin) { - FTask, Out_t> ret; - ret.onFrame = [callable = func](const std::tuple &in) -> Out_t + FTask, Out_t> ret; + ret.onFrame = [callable = func](const AuTuple &in) -> Out_t { - return std::apply(callable, std::tuple_cat(std::make_tuple(ownerToPin), in)); + return std::apply(callable, AuTuple_cat(AuMakeTuple(ownerToPin), in)); }; return ret; } diff --git a/Include/Aurora/Async/WorkBasic.hpp b/Include/Aurora/Async/WorkBasic.hpp index 462b76d8..c221f00e 100644 --- a/Include/Aurora/Async/WorkBasic.hpp +++ b/Include/Aurora/Async/WorkBasic.hpp @@ -12,43 +12,43 @@ namespace Aurora::Async /// --- THREAD POOL -- - template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> static AuSPtr NewWork(const WorkerPId_tt &worker, a task, b job, bool enableWait = false) { return worker.pool->NewWorkItem(worker, AuMakeShared>(task, job), enableWait); } - template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> static AuSPtr DispatchWork(const WorkerPId_tt &worker, a task, b job, bool enableWait = false) { return NewWork(worker, task, job, enableWait)->Dispatch(); } - template, typename Job_t = FJob, class a, class b = Job_t, class c, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, class a, class b = Job_t, class c, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> static AuSPtr NewWork(const WorkerPId_tt &worker, a task, b job, c info, bool enableWait = false) { return worker.pool->NewWorkItem(worker, AuMakeShared>(task, job, info), enableWait); } - template, typename Job_t = FJob, class a, class b = Job_t, class c, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, class a, class b = Job_t, class c, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> static AuSPtr DispatchWork(const WorkerPId_tt &worker, a task, b job, c info, bool enableWait = false) { return NewWork(worker, task, job, info, enableWait)->Dispatch(); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> AuSPtr DispatchFunctional(const WorkerPId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromConsumerRefT(task), job, inputParameters, enableWait); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> AuSPtr DispatchFunctor(const WorkerPId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromConsumerRefT(task), job, inputParameters, enableWait); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> AuSPtr DispatchVoid(const WorkerPId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromVoidVoid(task), job, inputParameters, enableWait); @@ -57,43 +57,43 @@ namespace Aurora::Async /// --- ASYNC APP -- - template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> static AuSPtr NewWork(const WorkerId_tt &worker, a task, b job, bool enableWait = false) { return NewWorkItem(worker, AuMakeShared>(task, job), enableWait); } - template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> static AuSPtr DispatchWork(const WorkerId_tt &worker, a task, b job, bool enableWait = false) { return NewWork(worker, task, job, enableWait)->Dispatch(); } - template, typename Job_t = FJob, class a, class b = Job_t, class c, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, class a, class b = Job_t, class c, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> static AuSPtr NewWork(const WorkerId_tt &worker, a task, b job, c info, bool enableWait = false) { return NewWorkItem(worker, AuMakeShared>(task, job, info), enableWait); } - template, typename Job_t = FJob, class a, class b = Job_t, class c, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, class a, class b = Job_t, class c, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> static AuSPtr DispatchWork(const WorkerId_tt &worker, a task, b job, c info, bool enableWait = false) { return NewWork(worker, task, job, info, enableWait)->Dispatch(); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> AuSPtr DispatchFunctional(const WorkerId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromConsumerRefT(task), job, inputParameters, enableWait); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> AuSPtr DispatchFunctor(const WorkerId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromConsumerRefT(task), job, inputParameters, enableWait); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v)> AuSPtr DispatchVoid(const WorkerId_t &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromVoidVoid(task), job, inputParameters, enableWait); @@ -105,7 +105,7 @@ namespace Aurora::Async return DispatchWork, Args...>, ReturnValue_t>(worker, TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), Async::JobFromTupleClazz, Args...>(job), - std::make_tuple, Args...>(AU_FWD(owner), std::forward(in)...), + AuMakeTuple, Args...>(AU_FWD(owner), std::forward(in)...), false); } @@ -115,7 +115,7 @@ namespace Aurora::Async return DispatchWork, Args...>, ReturnValue_t>(worker, TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), Async::JobFromTupleClazzEx, Args...>(success, failure), - std::make_tuple, Args...>(AU_FWD(owner), std::forward(in)...), + AuMakeTuple, Args...>(AU_FWD(owner), std::forward(in)...), false); } } \ No newline at end of file diff --git a/Include/Aurora/Async/WorkPairImpl.hpp b/Include/Aurora/Async/WorkPairImpl.hpp index d44aeb96..2f330c57 100644 --- a/Include/Aurora/Async/WorkPairImpl.hpp +++ b/Include/Aurora/Async/WorkPairImpl.hpp @@ -80,8 +80,8 @@ namespace Aurora::Async private: - static constexpr bool IsCallbackPtr = std::is_pointer_v || AuIsBaseOfTemplate::value || AuIsBaseOfTemplate::value; - static constexpr bool IsTaskPtr = std::is_pointer_v || AuIsBaseOfTemplate::value || AuIsBaseOfTemplate::value; + static constexpr bool IsCallbackPtr = AuIsPointer_v || AuIsBaseOfTemplate::value || AuIsBaseOfTemplate::value; + static constexpr bool IsTaskPtr = AuIsPointer_v || AuIsBaseOfTemplate::value || AuIsBaseOfTemplate::value; //WorkerId_t caller; WorkerPId_t caller_; diff --git a/Include/Aurora/Compression/StreamPipeProcessor.hpp b/Include/Aurora/Compression/StreamPipeProcessor.hpp index d78d3e1e..af0f25c0 100644 --- a/Include/Aurora/Compression/StreamPipeProcessor.hpp +++ b/Include/Aurora/Compression/StreamPipeProcessor.hpp @@ -17,13 +17,13 @@ namespace Aurora::Compression AuUInt32 threads; /// consume from stream callback - std::function inPipe; + AuFunction inPipe; /// write to stream callback - std::function writePipe; + AuFunction writePipe; /// preemption and reporting - std::function reportProgress; + AuFunction reportProgress; }; AUKN_SYM bool Decompress(const CompressionPipe &stream, const DecompressInfo &meta); diff --git a/Include/Aurora/Hashing/Digests.hpp b/Include/Aurora/Hashing/Digests.hpp index 5b0463bf..6bf71854 100644 --- a/Include/Aurora/Hashing/Digests.hpp +++ b/Include/Aurora/Hashing/Digests.hpp @@ -9,52 +9,52 @@ namespace Aurora::Hashing { - AUKN_SYM void MD5(const void *buffer, AuMach length, std::array &md5); - static void MD5(const AuList &bytebuffer, std::array &md5) + AUKN_SYM void MD5(const void *buffer, AuMach length, AuArray &md5); + static void MD5(const AuList &bytebuffer, AuArray &md5) { return MD5(bytebuffer.data(), bytebuffer.size(), md5); } - static void MD5(const AuString &bytebuffer, std::array &md5) + static void MD5(const AuString &bytebuffer, AuArray &md5) { return MD5(bytebuffer.data(), bytebuffer.size(), md5); } - AUKN_SYM void SHA1(const void *buffer, AuMach length, std::array &sha1); - static void SHA1(const AuList &bytebuffer, std::array &sha1) + AUKN_SYM void SHA1(const void *buffer, AuMach length, AuArray &sha1); + static void SHA1(const AuList &bytebuffer, AuArray &sha1) { return SHA1(bytebuffer.data(), bytebuffer.size(), sha1); } - static void SHA1(const AuString &bytebuffer, std::array &sha1) + static void SHA1(const AuString &bytebuffer, AuArray &sha1) { return SHA1(bytebuffer.data(), bytebuffer.size(), sha1); } - AUKN_SYM void Tiger(const void *buffer, AuMach length, std::array &tiger); - static void Tiger(const AuList &bytebuffer, std::array &tiger) + AUKN_SYM void Tiger(const void *buffer, AuMach length, AuArray &tiger); + static void Tiger(const AuList &bytebuffer, AuArray &tiger) { return Tiger(bytebuffer.data(), bytebuffer.size(), tiger); } - static void Tiger(const AuString &bytebuffer, std::array &tiger) + static void Tiger(const AuString &bytebuffer, AuArray &tiger) { return Tiger(bytebuffer.data(), bytebuffer.size(), tiger); } - AUKN_SYM void SHA2(const void *buffer, AuMach length, std::array &sha2); - static void SHA2(const AuList &bytebuffer, std::array &sha2) + AUKN_SYM void SHA2(const void *buffer, AuMach length, AuArray &sha2); + static void SHA2(const AuList &bytebuffer, AuArray &sha2) { return SHA2(bytebuffer.data(), bytebuffer.size(), sha2); } - static void SHA2(const AuString &bytebuffer, std::array &sha2) + static void SHA2(const AuString &bytebuffer, AuArray &sha2) { return SHA2(bytebuffer.data(), bytebuffer.size(), sha2); } - AUKN_SYM void SHA2_64(const void *buffer, AuMach length, std::array &sha2); - static void SHA2_64(const AuList &bytebuffer, std::array &sha2) + AUKN_SYM void SHA2_64(const void *buffer, AuMach length, AuArray &sha2); + static void SHA2_64(const AuList &bytebuffer, AuArray &sha2) { return SHA2_64(bytebuffer.data(), bytebuffer.size(), sha2); } - static void SHA2_64(const AuString &bytebuffer, std::array &sha2) + static void SHA2_64(const AuString &bytebuffer, AuArray &sha2) { return SHA2_64(bytebuffer.data(), bytebuffer.size(), sha2); } diff --git a/Include/Aurora/IO/Buffered/BlobArbitraryReader.hpp b/Include/Aurora/IO/Buffered/BlobArbitraryReader.hpp index dffa9c6a..d17cbbeb 100644 --- a/Include/Aurora/IO/Buffered/BlobArbitraryReader.hpp +++ b/Include/Aurora/IO/Buffered/BlobArbitraryReader.hpp @@ -28,13 +28,13 @@ namespace Aurora::IO::Buffered if (buffer_.empty()) return EStreamError::eErrorEndOfStream; auto endOffset = offset + paramters.length; - auto realEndOffset = std::min(buffer_.size(), endOffset); + auto realEndOffset = AuMin(buffer_.size(), endOffset); auto actualLength = realEndOffset - offset; if (actualLength < 0) return EStreamError::eErrorEndOfStream; paramters.outVariable = actualLength; - std::memcpy(paramters.ptr, buffer_.data() + offset, paramters.outVariable); + AuMemcpy(paramters.ptr, buffer_.data() + offset, paramters.outVariable); return EStreamError::eErrorNone; } diff --git a/Include/Aurora/IO/Buffered/BlobReader.hpp b/Include/Aurora/IO/Buffered/BlobReader.hpp index 3285d105..515db93d 100644 --- a/Include/Aurora/IO/Buffered/BlobReader.hpp +++ b/Include/Aurora/IO/Buffered/BlobReader.hpp @@ -25,11 +25,11 @@ namespace Aurora::IO::Buffered virtual EStreamError Read(const Memory::MemoryViewStreamWrite ¶mters) override { - auto realEndOffset = std::min(buffer_.size() - offset_, paramters.length); + auto realEndOffset = AuMin(buffer_.size() - offset_, paramters.length); if (realEndOffset == 0) return EStreamError::eErrorEndOfStream; paramters.outVariable = realEndOffset; - std::memcpy(paramters.ptr, buffer_.data() + offset_, realEndOffset); + AuMemcpy(paramters.ptr, buffer_.data() + offset_, realEndOffset); offset_ += realEndOffset; return EStreamError::eErrorNone; diff --git a/Include/Aurora/IO/Buffered/BlobWriter.hpp b/Include/Aurora/IO/Buffered/BlobWriter.hpp index 03ba6c2c..28a994cc 100644 --- a/Include/Aurora/IO/Buffered/BlobWriter.hpp +++ b/Include/Aurora/IO/Buffered/BlobWriter.hpp @@ -26,7 +26,7 @@ namespace Aurora::IO::Buffered { auto idx = buffer_.size(); buffer_.resize(idx + parameters.length); - std::memcpy(buffer_.data() + idx, parameters.ptr, buffer_.size() - idx); + AuMemcpy(buffer_.data() + idx, parameters.ptr, buffer_.size() - idx); return EStreamError::eErrorNone; } diff --git a/Include/Aurora/Memory/ByteBuffer.hpp b/Include/Aurora/Memory/ByteBuffer.hpp index ab55f4e4..aeaf9ec2 100644 --- a/Include/Aurora/Memory/ByteBuffer.hpp +++ b/Include/Aurora/Memory/ByteBuffer.hpp @@ -108,7 +108,7 @@ namespace Aurora::Memory this->writePtr = this->base; this->readPtr = this->base; } - std::memcpy(this->base, buffer.base, this->length); + AuMemcpy(this->base, buffer.base, this->length); this->flagCircular = buffer.flagCircular; this->flagExpandable = buffer.flagExpandable; this->scaleSize = buffer.scaleSize; @@ -122,7 +122,7 @@ namespace Aurora::Memory this->allocSize = length; this->readPtr = this->base; this->writePtr = this->readPtr + this->length; - std::memcpy(this->base, in, this->length); + AuMemcpy(this->base, in, this->length); this->scaleSize = kBufferInitialPower; } @@ -134,7 +134,7 @@ namespace Aurora::Memory this->allocSize = vector.size(); this->readPtr = this->base; this->writePtr = this->readPtr + this->length; - std::memcpy(this->base, vector.data(), this->length); + AuMemcpy(this->base, vector.data(), this->length); this->scaleSize = kBufferInitialPower; } diff --git a/Include/Aurora/Memory/ByteBuffer_Memory.inl b/Include/Aurora/Memory/ByteBuffer_Memory.inl index 464377ad..737262c4 100644 --- a/Include/Aurora/Memory/ByteBuffer_Memory.inl +++ b/Include/Aurora/Memory/ByteBuffer_Memory.inl @@ -35,7 +35,7 @@ namespace Aurora::Memory return false; } - std::memcpy(this->base, in, this->length); + AuMemcpy(this->base, in, this->length); return true; } @@ -75,7 +75,7 @@ namespace Aurora::Memory { auto scale = GetAllocationPower(); oldLength = this->length; - newLength = std::max(AuUInt(length), AuUInt(((this->allocSize / scale) + 1) * scale)); + newLength = AuMax(AuUInt(length), AuUInt(((this->allocSize / scale) + 1) * scale)); nextPtr = ZRealloc(this->base, newLength); if (!nextPtr) @@ -109,9 +109,9 @@ namespace Aurora::Memory else { auto expansion = newLength - oldLength; - auto movableTail = std::min(oldWriteIdx, expansion); + auto movableTail = AuMin(oldWriteIdx, expansion); - std::memcpy(nextPtr + oldLength, nextPtr, movableTail); + AuMemcpy(nextPtr + oldLength, nextPtr, movableTail); this->readPtr = nextRead; this->writePtr = nextPtr + oldLength + movableTail; diff --git a/Include/Aurora/Memory/ByteBuffer_ReadWrite.inl b/Include/Aurora/Memory/ByteBuffer_ReadWrite.inl index d70b42f4..5a822b76 100644 --- a/Include/Aurora/Memory/ByteBuffer_ReadWrite.inl +++ b/Include/Aurora/Memory/ByteBuffer_ReadWrite.inl @@ -33,14 +33,14 @@ namespace Aurora::Memory toReadOverhead = readPtr - base; } - writable = std::min(linearOverhead + toReadOverhead, requestLength); + writable = AuMin(linearOverhead + toReadOverhead, requestLength); - linearWritable = std::min(linearOverhead, requestLength); + linearWritable = AuMin(linearOverhead, requestLength); toReadWritable = writable - linearWritable; if (cptr) { - std::memcpy(writePtr, cptr, linearWritable); + AuMemcpy(writePtr, cptr, linearWritable); } writePtr += linearWritable; @@ -49,7 +49,7 @@ namespace Aurora::Memory writePtr = base; if (cptr) { - std::memcpy(writePtr, cptr + linearOverhead, toReadWritable); + AuMemcpy(writePtr, cptr + linearOverhead, toReadWritable); } writePtr += toReadWritable; } @@ -68,7 +68,7 @@ namespace Aurora::Memory auto offset = writePtr - base; auto overhead = length - offset; - AuUInt len = std::min(overhead, requestLength); + AuUInt len = AuMin(overhead, requestLength); if ((len != requestLength) && (flagExpandable)) { @@ -78,12 +78,12 @@ namespace Aurora::Memory } overhead = length - offset; - len = std::min(overhead, requestLength); + len = AuMin(overhead, requestLength); } if (buffer) { - std::memcpy(writePtr, buffer, len); + AuMemcpy(writePtr, buffer, len); } writePtr += len; @@ -108,14 +108,14 @@ namespace Aurora::Memory toWriteOverhead = writePtr - base; } - auto readable = std::min(linearOverhead + toWriteOverhead, requestedLength); + auto readable = AuMin(linearOverhead + toWriteOverhead, requestedLength); - linearReadable = std::min(linearOverhead, requestedLength); + linearReadable = AuMin(linearOverhead, requestedLength); toWriteReadable = readable - linearReadable; if (out) { - std::memcpy(out, readPtr, linearOverhead); + AuMemcpy(out, readPtr, linearOverhead); } if (!peek) @@ -125,7 +125,7 @@ namespace Aurora::Memory if (toWriteOverhead) { - std::memcpy(reinterpret_cast(out) + linearOverhead, base, toWriteReadable); + AuMemcpy(reinterpret_cast(out) + linearOverhead, base, toWriteReadable); if (!peek) { @@ -144,11 +144,11 @@ namespace Aurora::Memory } else { - AuUInt len = std::min(AuUInt(writePtr - readPtr), requestedLength); + AuUInt len = AuMin(AuUInt(writePtr - readPtr), requestedLength); if (out) { - std::memcpy(out, readPtr, len); + AuMemcpy(out, readPtr, len); } if (!peek) diff --git a/Include/Aurora/Memory/ByteBuffer_TypedReadWrite.inl b/Include/Aurora/Memory/ByteBuffer_TypedReadWrite.inl index ae77d1f5..9e6d6bfb 100644 --- a/Include/Aurora/Memory/ByteBuffer_TypedReadWrite.inl +++ b/Include/Aurora/Memory/ByteBuffer_TypedReadWrite.inl @@ -12,7 +12,7 @@ namespace Aurora::Memory template bool ByteBuffer::Read(T &out) { - if constexpr (std::is_class_v) + if constexpr (AuIsClass_v) { if constexpr (AuIsBaseOfTemplate>::value) { @@ -32,7 +32,7 @@ namespace Aurora::Memory return !this->flagReadError; } - else if constexpr (std::is_same_v, AuString>) + else if constexpr (AuIsSame_v, AuString>) { out.resize(Read()); Read(out.data(), out.size()); @@ -60,7 +60,7 @@ namespace Aurora::Memory template bool ByteBuffer::Write(const T &in) { - if constexpr (std::is_class_v) + if constexpr (AuIsClass_v) { if constexpr (AuIsBaseOfTemplate>::value) { @@ -74,7 +74,7 @@ namespace Aurora::Memory return !this->flagWriteError; } - else if constexpr (std::is_same_v, AuString>) + else if constexpr (AuIsSame_v, AuString>) { Write(AuUInt32(in.size())); Write(in.data(), in.size()); diff --git a/Include/Aurora/Memory/ByteBuffer_Utils.inl b/Include/Aurora/Memory/ByteBuffer_Utils.inl index 2ffc4c02..e51cab96 100644 --- a/Include/Aurora/Memory/ByteBuffer_Utils.inl +++ b/Include/Aurora/Memory/ByteBuffer_Utils.inl @@ -19,7 +19,7 @@ namespace Aurora::Memory } else { - std::memcpy(vec.data(), base, length); + AuMemcpy(vec.data(), base, length); } return vec; } @@ -62,7 +62,7 @@ namespace Aurora::Memory auto len = length - (writePtr - readPtr); vec.resize(len); - std::memcpy(vec.data(), readPtr, len); + AuMemcpy(vec.data(), readPtr, len); } else { @@ -70,8 +70,8 @@ namespace Aurora::Memory auto toWriteOverhead = endAtWrite ? (writePtr - base) : (readPtr - base); vec.resize(linearOverhead + toWriteOverhead); - std::memcpy(vec.data(), readPtr, linearOverhead); - std::memcpy(vec.data() + linearOverhead, base, linearOverhead); + AuMemcpy(vec.data(), readPtr, linearOverhead); + AuMemcpy(vec.data() + linearOverhead, base, linearOverhead); } } else @@ -87,7 +87,7 @@ namespace Aurora::Memory } vec.resize(len); - std::memcpy(vec.data(), readPtr, len); + AuMemcpy(vec.data(), readPtr, len); } return vec; diff --git a/Include/Aurora/Memory/Heap.hpp b/Include/Aurora/Memory/Heap.hpp index 51fa4de7..d0ddd85e 100644 --- a/Include/Aurora/Memory/Heap.hpp +++ b/Include/Aurora/Memory/Heap.hpp @@ -106,7 +106,7 @@ namespace Aurora::Memory return std::shared_ptr(in, [heapHandle, in, this](T *delt) { - if constexpr (std::is_class_v) + if constexpr (AuIsClass_v) { delt->~T(); } diff --git a/Include/Aurora/Memory/Memory.hpp b/Include/Aurora/Memory/Memory.hpp index bab46325..f741c0ca 100644 --- a/Include/Aurora/Memory/Memory.hpp +++ b/Include/Aurora/Memory/Memory.hpp @@ -38,35 +38,35 @@ namespace Aurora::Memory template T ZAlloc(Types::size_t length) { - static_assert(!std::is_class::type>::value, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v::type>, "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(!std::is_class::type>::value, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v::type>, "Do not use heap/kmem apis with classes"); return reinterpret_cast(_ZAlloc(length, align)); } template T *NewArray(Types::size_t count) { - static_assert(!std::is_class::value, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v, "Do not use heap/kmem apis with classes"); return reinterpret_cast(_FAlloc(count * sizeof(T))); } template T *NewArray(Types::size_t count, Types::size_t align) { - static_assert(!std::is_class::value, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v, "Do not use heap/kmem apis with classes"); return reinterpret_cast(_FAlloc(count * sizeof(T)), align); } template AuSPtr AllocateFastArray(Types::size_t length, Types::size_t align = sizeof(T)) { - static_assert(!std::is_class::type>::value, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v::type>, "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(!std::is_class::type>::value, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v::type>, "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(!std::is_class::type>::value, "Do not use heap/kmem apis with classes"); + static_assert(!AuIsClass_v::type>, "Do not use heap/kmem apis with classes"); return reinterpret_cast(_FAlloc(length, align)); } diff --git a/Include/Aurora/Memory/MemoryView.hpp b/Include/Aurora/Memory/MemoryView.hpp index 49048c07..5b934dda 100644 --- a/Include/Aurora/Memory/MemoryView.hpp +++ b/Include/Aurora/Memory/MemoryView.hpp @@ -15,7 +15,7 @@ namespace Aurora::Memory using Void_t = std::conditional_t; template - using StdArray_t = std::conditional_t, std::array>; + using StdArray_t = std::conditional_t, AuArray>; /* YadaYada(MemoryView(tempstring/array/etc)) should be legal, right? @@ -59,7 +59,7 @@ namespace Aurora::Memory constexpr MemoryView(T *start, T *end) { this->ptr = start; - if constexpr (std::is_same_v) + if constexpr (AuIsSame_v) { this->length = reinterpret_cast(end) - reinterpret_cast(start); } diff --git a/Include/Aurora/Parse/LineParser.hpp b/Include/Aurora/Parse/LineParser.hpp index cd14de48..258cb53e 100644 --- a/Include/Aurora/Parse/LineParser.hpp +++ b/Include/Aurora/Parse/LineParser.hpp @@ -9,7 +9,7 @@ namespace Aurora::Parse { - static AuString SplitNewlines(const AuString &in, std::function lineCallback, bool returnRemaining) + static AuString SplitNewlines(const AuString &in, AuFunction lineCallback, bool returnRemaining) { AuMach index = 0, startIdx = 0; @@ -42,7 +42,7 @@ namespace Aurora::Parse } } - static void SplitNewlines(const AuString &in, std::function lineCallback) + static void SplitNewlines(const AuString &in, AuFunction lineCallback) { SplitNewlines(in, lineCallback, false); } @@ -53,7 +53,7 @@ namespace Aurora::Parse for (auto i = 0u; i < in.size(); i += characters) { auto start = i; - auto end = std::min(AuUInt32(in.size()), AuUInt32(i + characters)); + auto end = AuMin(AuUInt32(in.size()), AuUInt32(i + characters)); auto len = end - start; ret.push_back(in.substr(start, len)); } @@ -74,7 +74,7 @@ namespace Aurora::Parse } start = i; - end = std::min(AuUInt32(in.size()), AuUInt32(i + characters)); + end = AuMin(AuUInt32(in.size()), AuUInt32(i + characters)); len = end - start; ret.insert(ret.size(), in.substr(start, len)); diff --git a/Include/Aurora/Parse/Parser.hpp b/Include/Aurora/Parse/Parser.hpp index 12cc671a..a9c805b9 100644 --- a/Include/Aurora/Parse/Parser.hpp +++ b/Include/Aurora/Parse/Parser.hpp @@ -112,7 +112,7 @@ namespace Aurora::Parse ParsedObject result; }; - using ConsumeStream_cb = std::function; + using ConsumeStream_cb = AuFunction; static ConsumeStream_cb StringToConsumable(const AuString &str, AuMach &index) { diff --git a/Include/Aurora/Threading/LockGuard.hpp b/Include/Aurora/Threading/LockGuard.hpp index b6249e63..c9acb135 100644 --- a/Include/Aurora/Threading/LockGuard.hpp +++ b/Include/Aurora/Threading/LockGuard.hpp @@ -19,7 +19,7 @@ namespace Aurora::Threading LockGuard(T &lock) { - if constexpr (std::is_pointer_v) + if constexpr (AuIsPointer_v) { annoying_ = lock; } @@ -40,7 +40,7 @@ namespace Aurora::Threading LockGuard(T &&lock) { - if constexpr (std::is_pointer_v) + if constexpr (AuIsPointer_v) { annoying_ = lock; } @@ -72,7 +72,7 @@ namespace Aurora::Threading } private: - std::conditional_t, T, T*> annoying_; + std::conditional_t, T, T*> annoying_; }; #define AU_LOCK_GUARD(variable) Aurora::Threading::LockGuard AU_CONCAT(__stack_lock, __COUNTER__) (variable); diff --git a/Include/Aurora/Threading/LockGuardTry.hpp b/Include/Aurora/Threading/LockGuardTry.hpp index 01046fea..10612faf 100644 --- a/Include/Aurora/Threading/LockGuardTry.hpp +++ b/Include/Aurora/Threading/LockGuardTry.hpp @@ -20,7 +20,7 @@ namespace Aurora::Threading TryLockGuard(T &lock) { - if constexpr (std::is_pointer_v) + if constexpr (AuIsPointer_v) { annoying_ = lock; } @@ -41,7 +41,7 @@ namespace Aurora::Threading TryLockGuard(T &&lock) { - if constexpr (std::is_pointer_v) + if constexpr (AuIsPointer_v) { annoying_ = lock; } @@ -82,7 +82,7 @@ namespace Aurora::Threading return bLockSuccessful; } private: - std::conditional_t, T, T*> annoying_; + std::conditional_t, T, T*> annoying_; }; diff --git a/Include/Aurora/Threading/Threads/TLSVariable.hpp b/Include/Aurora/Threading/Threads/TLSVariable.hpp index df2e792b..60a4c2b1 100644 --- a/Include/Aurora/Threading/Threads/TLSVariable.hpp +++ b/Include/Aurora/Threading/Threads/TLSVariable.hpp @@ -67,7 +67,7 @@ namespace Aurora::Threading::Threads sizeof(T), [](void *buffer) -> void { - if constexpr (std::is_class_v) + if constexpr (AuIsClass_v) { new (buffer) T(); } @@ -78,7 +78,7 @@ namespace Aurora::Threading::Threads }, [](void *buffer) -> void { - if constexpr (std::is_class_v) + if constexpr (AuIsClass_v) { reinterpret_cast(buffer)->~T(); } diff --git a/Include/Aurora/Threading/Threads/TLSView.hpp b/Include/Aurora/Threading/Threads/TLSView.hpp index 26dd05b7..99b79a35 100644 --- a/Include/Aurora/Threading/Threads/TLSView.hpp +++ b/Include/Aurora/Threading/Threads/TLSView.hpp @@ -17,7 +17,7 @@ namespace Aurora::Threading::Threads class TLSView { public: - using TlsCb = std::function; + using TlsCb = AuFunction; virtual void Remove(AuUInt64 key) = 0; virtual void *GetTLS(AuUInt64 key, AuMach length, bool noAutoCreate = false) = 0; diff --git a/Include/Aurora/Time/DebugBenchmark.hpp b/Include/Aurora/Time/DebugBenchmark.hpp index 3b19e0d8..cd99ea65 100644 --- a/Include/Aurora/Time/DebugBenchmark.hpp +++ b/Include/Aurora/Time/DebugBenchmark.hpp @@ -25,7 +25,7 @@ namespace Aurora::Time void Finish() { - if (std::exchange(finished_, true)) return; + if (AuExchange(finished_, true)) return; auto time = timer_.End(); Aurora::Console::Logging::LogDbg("[Benchmark] {} took {}", message_, ConvertMSToTimescaleEN(time)); } diff --git a/Include/Aurora/Time/Time.hpp b/Include/Aurora/Time/Time.hpp index 82385224..20ebba2e 100644 --- a/Include/Aurora/Time/Time.hpp +++ b/Include/Aurora/Time/Time.hpp @@ -17,30 +17,30 @@ namespace Aurora::Time if (ms < 1000) { - return std::to_string(ms) + "ms"; + return AuToString(ms) + "ms"; } else if (ms >= 1000) { auto s = msDiv1000; auto remMs = ms % 1000; - return std::to_string(s) + "." + std::to_string(remMs) + "s"; + return AuToString(s) + "." + AuToString(remMs) + "s"; } else if (ms > (1000 * 60)) { auto m = msDiv1000Div60; auto remS = msDiv1000Mod60; - return std::to_string(m) + "m " + std::to_string(remS) + "s"; + return AuToString(m) + "m " + AuToString(remS) + "s"; } else if (ms > (1000 * 60 * 60)) { auto h = msDiv1000Div60 / 60; auto remM = msDiv1000Div60 % 60; auto remS = msDiv1000Mod60; - return std::to_string(h) + "h " + std::to_string(remM) + "m" + std::to_string(remS) + "s"; + return AuToString(h) + "h " + AuToString(remM) + "m" + AuToString(remS) + "s"; } else { - return std::to_string(ms); // ? + return AuToString(ms); // ? } } } diff --git a/Include/AuroraTypedefs.hpp b/Include/AuroraTypedefs.hpp index 78968f8c..f3e4a9b6 100644 --- a/Include/AuroraTypedefs.hpp +++ b/Include/AuroraTypedefs.hpp @@ -22,6 +22,68 @@ #endif #endif +template +struct AuBoolType +{ + static constexpr bool value = v; + using value_type = bool; + using type = AuBoolType; + + constexpr operator value_type() const noexcept + { + return value; +} + + constexpr value_type operator()() const noexcept + { + return value; + } +}; + +using AuFalseType = AuBoolType; +using AuTrueType = AuBoolType; + +template +struct AuIsSame : AuFalseType +{}; + +template +struct AuIsSame : AuTrueType +{}; + +template< class T, class U > +inline constexpr bool AuIsSame_v = AuIsSame::value; + +namespace _audetail { + template + AuBoolType::value> test(int T:: *); + + template + AuFalseType test(...); +} + +template +struct AuIsClass : decltype(_audetail::test(nullptr)) +{}; + +template +inline constexpr bool AuIsClass_v = AuIsClass::value; + +template +inline constexpr bool AuIsPointer_v = false; + +template +inline constexpr bool AuIsPointer_v<_Ty *> = true; + +template +inline constexpr bool AuIsPointer_v<_Ty *const> = true; + +template +inline constexpr bool AuIsPointer_v<_Ty *volatile> = true; + +template +inline constexpr bool AuIsPointer_v<_Ty *const volatile> = true; + #if !defined(AURORA_RUNTIME_AU_LIST) #define AURORA_RUNTIME_AU_LIST std::vector #endif @@ -40,11 +102,10 @@ namespace Aurora::Memory } template -using AuList = typename std::conditional::value, AURORA_RUNTIME_AU_LIST, AURORA_RUNTIME_AU_LIST>>::type; +using AuList = typename std::conditional, AURORA_RUNTIME_AU_LIST, AURORA_RUNTIME_AU_LIST>>::type; #endif - #if !defined(AURORA_RUNTIME_AU_ARRAY) #define AURORA_RUNTIME_AU_ARRAY std::array #endif @@ -113,6 +174,14 @@ using AuUPtr = AURORA_RUNTIME_AU_UNIQUE_PTR; template using AuPair = AURORA_RUNTIME_AU_PAIR; + +#if !defined(AURORA_RUNTIME_AU_TUPLE) +#define AURORA_RUNTIME_AU_TUPLE std::tuple +#endif + +template +using AuTuple = AURORA_RUNTIME_AU_TUPLE; + #if defined(AURORA_COMPILER_MSVC) using AuAtomicInt = long; #else diff --git a/Include/AuroraUtils.hpp b/Include/AuroraUtils.hpp index 376cb4bc..f2f0b59d 100644 --- a/Include/AuroraUtils.hpp +++ b/Include/AuroraUtils.hpp @@ -34,12 +34,101 @@ static auline auto AuMakePair(Args&&... args) return AURORA_RUNTIME_MAKE_PAIR(std::forward(args)...); } + +#if !defined(AURORA_RUNTIME_MAKE_TUPLE) +#define AURORA_RUNTIME_MAKE_TUPLE std::make_tuple +#endif + +template +static auline auto AuMakeTuple(Args&&... args) +{ + return AURORA_RUNTIME_MAKE_TUPLE(std::forward(args)...); +} + + +#if !defined(AURORA_RUNTIME_TO_STRING) +#define AURORA_RUNTIME_TO_STRING std::to_string +#endif + +template +AuString AuToString(const T &obj) +{ + return AURORA_RUNTIME_TO_STRING(obj); +} + + +#if !defined(AURORA_RUNTIME_EXCHANGE) +#define AURORA_RUNTIME_EXCHANGE std::exchange +#endif + +template +T AuExchange(T &obj, U &&new_value) +{ + return AURORA_RUNTIME_EXCHANGE(obj, new_value); +} + +#if !defined(AURORA_RUNTIME_MIN) +#define AURORA_RUNTIME_MIN std::min +#endif + +template< class T > +constexpr const T &AuMin(const T &a, const T &b) +{ + return AURORA_RUNTIME_MIN(a, b); +} + +#if !defined(AURORA_RUNTIME_MAX) +#define AURORA_RUNTIME_MAX std::max +#endif + +template< class T > +constexpr const T &AuMax(const T &a, const T &b) +{ + return AURORA_RUNTIME_MAX(a, b); +} + +#if !defined(AURORA_RUNTIME_MEMCMP) +#define AURORA_RUNTIME_MEMCMP std::memcmp +#endif + +static auline int AuMemcmp(const void *dest, const void *src, size_t n) +{ + return AURORA_RUNTIME_MEMCMP(dest, src, n); +} + +#if !defined(AURORA_RUNTIME_MEMSET) +#define AURORA_RUNTIME_MEMSET std::memset +#endif + +static auline void *AuMemset(void *dest, AuUInt8 c, size_t n) +{ + return AURORA_RUNTIME_MEMSET(dest, c, n); +} + +#if !defined(AURORA_RUNTIME_MEMCPY) +#define AURORA_RUNTIME_MEMCPY std::memcpy +#endif + +static auline void *AuMemcpy(void *dest, const void *src, size_t n) +{ + return AURORA_RUNTIME_MEMCPY(dest, src, n); +} + +#if !defined(AURORA_RUNTIME_MEMMOVE) +#define AURORA_RUNTIME_MEMMOVE std::memmove +#endif + +static auline void *AuMemmove(void *dest, const void *src, size_t n) +{ + return AURORA_RUNTIME_MEMMOVE(dest, src, n); +} + #if defined(AURORA_IS_MODERNNT_DERIVED) && (defined(_WINDOWS_) || defined(_OTHER_MS_MAIN_HEADER_GUARDS_HERE)) static auline void AuWin32CloseHandle(HANDLE &handle) { HANDLE local; - if ((local = std::exchange(handle, INVALID_HANDLE_VALUE)) != INVALID_HANDLE_VALUE) + if ((local = AuExchange(handle, INVALID_HANDLE_VALUE)) != INVALID_HANDLE_VALUE) { CloseHandle(local); } @@ -311,6 +400,19 @@ static auline bool AuTryFindGeneric(Map &map, const Key &key, Value *&ptr) } } +template +static auline bool AuTryFindGeneric(Map &map, const Key &key) +{ + if (map.find(key) != map.end()) + { + return true; + } + else + { + return false; + } +} + template static auline bool AuTryDelete(Map &map, const Key &key) { @@ -470,7 +572,7 @@ static auline bool AuTryResize(T &list, AuUInt length) { try { - if constexpr (std::is_same_v) + if constexpr (AuIsSame_v) { return list.Resize(length); } @@ -491,7 +593,7 @@ static auline bool AuTryDownsize(T &list, AuUInt length) { try { - if constexpr (std::is_same_v) + if constexpr (AuIsSame_v) { return list.Resize(length); } @@ -649,31 +751,31 @@ static auline T AuReadGenericLE(const void *ptr, int offset) return *reinterpret_cast(reinterpret_cast(ptr) + offset); #else T temp; - std::memcpy(&temp, reinterpret_cast(ptr) + offset, sizeof(temp)); + AuMemcpy(&temp, reinterpret_cast(ptr) + offset, sizeof(temp)); #if !defined(AU_CPU_ENDIAN_LITTLE) #if defined(AURORA_COMPILER_MSVC) - if constexpr (std::is_same_v || std::is_same_v) + if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_ulong(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_uint64(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_ushort(temp); } #else - if constexpr (std::is_same_v || std::is_same_v) + if constexpr (AuIsSame_v || AuIsSame_v) { temp = __builtin_bswap32(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = __builtin_bswap64(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = (temp << 8) | ((temp >> 8) & 0xFF); } @@ -690,31 +792,31 @@ static auline T AuReadGenericBE(const void *ptr, int offset) return *reinterpret_cast(reinterpret_cast(ptr) + offset); #else T temp; - std::memcpy(&temp, reinterpret_cast(ptr) + offset, sizeof(temp)); + AuMemcpy(&temp, reinterpret_cast(ptr) + offset, sizeof(temp)); #if defined(AU_CPU_ENDIAN_LITTLE) #if defined(AURORA_COMPILER_MSVC) - if constexpr (std::is_same_v || std::is_same_v) + if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_ulong(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_uint64(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_ushort(temp); } #else - if constexpr (std::is_same_v || std::is_same_v) + if constexpr (AuIsSame_v || AuIsSame_v) { temp = __builtin_bswap32(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = __builtin_bswap64(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = (temp << 8) | ((temp >> 8) & 0xFF); } @@ -885,34 +987,34 @@ static auline void AuWriteGenericLE(void *ptr, int offset, T value) T temp = value; #if !defined(AU_CPU_ENDIAN_LITTLE) #if defined(AURORA_COMPILER_MSVC) - if constexpr (std::is_same_v || std::is_same_v) + if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_ulong(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_uint64(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_ushort(temp); } #else - if constexpr (std::is_same_v || std::is_same_v) + if constexpr (AuIsSame_v || AuIsSame_v) { temp = __builtin_bswap32(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = __builtin_bswap64(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = (temp << 8) | ((temp >> 8) & 0xFF); } #endif #endif - std::memcpy(reinterpret_cast(ptr) + offset, &temp, sizeof(temp)); + AuMemcpy(reinterpret_cast(ptr) + offset, &temp, sizeof(temp)); #endif } @@ -925,34 +1027,34 @@ static auline void AuWriteGenericBE(void *ptr, T value, int offset) T temp = value; #if defined(AU_CPU_ENDIAN_LITTLE) #if defined(AURORA_COMPILER_MSVC) - if constexpr (std::is_same_v || std::is_same_v) + if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_ulong(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_uint64(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = _byteswap_ushort(temp); } #else - if constexpr (std::is_same_v || std::is_same_v) + if constexpr (AuIsSame_v || AuIsSame_v) { temp = __builtin_bswap32(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = __builtin_bswap64(temp); } - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (AuIsSame_v || AuIsSame_v) { temp = (temp << 8) | ((temp >> 8) & 0xFF); } #endif #endif - std::memcpy(reinterpret_cast(ptr) + offset, &temp, sizeof(temp)); + AuMemcpy(reinterpret_cast(ptr) + offset, &temp, sizeof(temp)); #endif } diff --git a/Source/Async/AsyncRunnable.hpp b/Source/Async/AsyncRunnable.hpp index 8125899b..4c9590a0 100644 --- a/Source/Async/AsyncRunnable.hpp +++ b/Source/Async/AsyncRunnable.hpp @@ -22,20 +22,20 @@ namespace Aurora::Async { public: - std::function callback; - std::function fail; + AuFunction callback; + AuFunction fail; AuThreadPrimitives::SpinLock lock; - AsyncFuncRunnable(std::function &&callback) : callback(std::move(callback)) + AsyncFuncRunnable(AuFunction &&callback) : callback(std::move(callback)) {} - AsyncFuncRunnable(std::function &&callback, std::function &&fail) : callback(std::move(callback)), fail(std::move(fail)) + AsyncFuncRunnable(AuFunction &&callback, AuFunction &&fail) : callback(std::move(callback)), fail(std::move(fail)) {} - AsyncFuncRunnable(const std::function &callback) : callback(callback) + AsyncFuncRunnable(const AuFunction &callback) : callback(callback) {} - AsyncFuncRunnable(const std::function &callback, const std::function &fail) : callback(callback), fail(fail) + AsyncFuncRunnable(const AuFunction &callback, const AuFunction &fail) : callback(callback), fail(fail) {} void RunAsync() override diff --git a/Source/Async/Schedular.cpp b/Source/Async/Schedular.cpp index 581a24b1..2dfbb45a 100644 --- a/Source/Async/Schedular.cpp +++ b/Source/Async/Schedular.cpp @@ -96,7 +96,7 @@ namespace Aurora::Async { try { - if (!std::exchange(gLockedPump, true)) + if (!AuExchange(gLockedPump, true)) { NewWorkItem(AuWorkerId_t{0, 0}, AuMakeShared(PumpSysThread))->Dispatch(); } diff --git a/Source/Async/ThreadPool.cpp b/Source/Async/ThreadPool.cpp index 2f1f2685..b0d6bc2e 100644 --- a/Source/Async/ThreadPool.cpp +++ b/Source/Async/ThreadPool.cpp @@ -357,7 +357,7 @@ namespace Aurora::Async int runningTasks {}; - auto oldTlsHandle = std::exchange(gCurrentPool, AuSharedFromThis()); + auto oldTlsHandle = AuExchange(gCurrentPool, AuSharedFromThis()); bool lowPrioCont {}; bool lowPrioContCached {}; @@ -540,7 +540,7 @@ namespace Aurora::Async // Set shutdown flag { AU_LOCK_GUARD(this->rwlock_->AsWritable()); - if (std::exchange(this->shuttingdown_, true)) + if (AuExchange(this->shuttingdown_, true)) { return; } diff --git a/Source/Async/WorkItem.cpp b/Source/Async/WorkItem.cpp index 9081f4b1..fa94dcd7 100644 --- a/Source/Async/WorkItem.cpp +++ b/Source/Async/WorkItem.cpp @@ -171,7 +171,7 @@ namespace Aurora::Async return; } - if (auto delay = std::exchange(delayTimeNs_, {})) + if (auto delay = AuExchange(delayTimeNs_, {})) { this->dispatchTimeNs_ = delay + Time::CurrentClockNS(); Schedule(); @@ -271,7 +271,7 @@ namespace Aurora::Async { failed = true; - if (auto task_ = std::exchange(this->task_, {})) + if (auto task_ = AuExchange(this->task_, {})) { task_->Shutdown(); } diff --git a/Source/Compression/BlockCompressor.cpp b/Source/Compression/BlockCompressor.cpp index 70de3e34..5aab843d 100644 --- a/Source/Compression/BlockCompressor.cpp +++ b/Source/Compression/BlockCompressor.cpp @@ -36,7 +36,7 @@ namespace Aurora::Compression { while (this->_outbuffer.RemainingBytes() < minimumDeflated) { - auto toRead = minimumDeflated ? std::min(AuUInt32(4096), AuUInt32(minimumDeflated - this->_outbuffer.RemainingBytes())) : 4096; + auto toRead = minimumDeflated ? AuMin(AuUInt32(4096), AuUInt32(minimumDeflated - this->_outbuffer.RemainingBytes())) : 4096; if (Ingest(toRead).second == 0) { if (!this->_outbuffer.RemainingBytes()) @@ -86,7 +86,7 @@ namespace Aurora::Compression if (written != length) { - auto increase = std::max(0, (int)length - (int)this->_outbuffer.RemainingWrite()); + auto increase = AuMax(0, (int)length - (int)this->_outbuffer.RemainingWrite()); increase += this->_outbuffer.length; if (increase > 64 * 1024 * 1024) diff --git a/Source/Compression/BlockDecompressor.cpp b/Source/Compression/BlockDecompressor.cpp index f5aaff23..f5a97058 100644 --- a/Source/Compression/BlockDecompressor.cpp +++ b/Source/Compression/BlockDecompressor.cpp @@ -25,7 +25,7 @@ namespace Aurora::Compression { while (this->_outbuffer.RemainingBytes() < minimumInflated) { - auto toRead = minimumInflated ? std::min(AuUInt32(4096), AuUInt32(minimumInflated - this->_outbuffer.RemainingBytes())) : 4096; + auto toRead = minimumInflated ? AuMin(AuUInt32(4096), AuUInt32(minimumInflated - this->_outbuffer.RemainingBytes())) : 4096; if (Ingest(toRead).second == 0) { if (!this->_outbuffer.RemainingBytes()) @@ -69,7 +69,7 @@ namespace Aurora::Compression if (written != length) { - auto increase = std::max(0, (int)length - (int)this->_outbuffer.RemainingWrite()); + auto increase = AuMax(0, (int)length - (int)this->_outbuffer.RemainingWrite()); increase += this->_outbuffer.length; if (increase > 64 * 1024 * 1024) @@ -109,7 +109,7 @@ namespace Aurora::Compression ~ZSTDInflate() { - if (auto dctx = std::exchange(dctx_, {})) + if (auto dctx = AuExchange(dctx_, {})) { ZSTD_freeDCtx(dctx); } @@ -137,7 +137,7 @@ namespace Aurora::Compression while (read != input) { - AuUInt request = std::min(input, length); + AuUInt request = AuMin(input, length); if (this->reader_->Read(Memory::MemoryViewStreamWrite(din_, request)) != IO::EStreamError::eErrorNone) { return AuMakePair(read, done); @@ -218,7 +218,7 @@ namespace Aurora::Compression while (read < input) { - AuUInt request = std::min(input, AuUInt32(AuArraySize(din_))); + AuUInt request = AuMin(input, AuUInt32(AuArraySize(din_))); if (this->reader_->Read(Memory::MemoryViewStreamWrite(din_, request)) != IO::EStreamError::eErrorNone) { return AuMakePair(read, done); @@ -231,7 +231,7 @@ namespace Aurora::Compression do { - this->ctx_.avail_out = AuArraySize(dout_); // std::min(AuUInt32(AuArraySize(dout_)), AuUInt32(this->_outbuffer.RemainingWrite())); + this->ctx_.avail_out = AuArraySize(dout_); // AuMin(AuUInt32(AuArraySize(dout_)), AuUInt32(this->_outbuffer.RemainingWrite())); this->ctx_.next_out = dout_; if (!this->ctx_.avail_out) @@ -308,7 +308,7 @@ namespace Aurora::Compression AuUInt32 done{}, read{}; while (read < input) { - AuUInt request = std::min(input, AuUInt32(AuArraySize(din_))); + AuUInt request = AuMin(input, AuUInt32(AuArraySize(din_))); if (this->reader_->Read(Memory::MemoryViewStreamWrite(din_, request)) != IO::EStreamError::eErrorNone) { return AuMakePair(read, done); diff --git a/Source/Compression/StreamCompression.cpp b/Source/Compression/StreamCompression.cpp index 5df0012a..6003441a 100644 --- a/Source/Compression/StreamCompression.cpp +++ b/Source/Compression/StreamCompression.cpp @@ -143,7 +143,7 @@ namespace Aurora::Compression return false; } - ret = ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, std::max(stream.threads, 1u)); + ret = ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, AuMax(stream.threads, 1u)); if (ZSTD_isError(ret)) { SysPushErrorGen(); diff --git a/Source/Console/Commands/Commands.cpp b/Source/Console/Commands/Commands.cpp index 5c8dbb8d..d0f40132 100644 --- a/Source/Console/Commands/Commands.cpp +++ b/Source/Console/Commands/Commands.cpp @@ -153,7 +153,7 @@ namespace Aurora::Console::Commands // process commands before async app termination if ((!target.has_value())) { - auto commands = std::exchange(gPendingCommands, {}); + auto commands = AuExchange(gPendingCommands, {}); for (const auto &command : commands) { command.callback->OnCommand(command.arguments); @@ -176,7 +176,7 @@ namespace Aurora::Console::Commands gMutex->Lock(); gPendingCommandsMutex->Lock(); - auto commands = std::exchange(gPendingCommands, {}); + auto commands = AuExchange(gPendingCommands, {}); gPendingCommandsMutex->Unlock(); if ((gCommandDispatcher.pool == nullptr) || diff --git a/Source/Console/ConsoleMessage.cpp b/Source/Console/ConsoleMessage.cpp index c3b85a60..f9a70f1c 100644 --- a/Source/Console/ConsoleMessage.cpp +++ b/Source/Console/ConsoleMessage.cpp @@ -10,7 +10,7 @@ namespace Aurora::Console { - static std::array(EAnsiColor::eCount)> kAnsiCheats + static AuArray(EAnsiColor::eCount)> kAnsiCheats { "\033[0;31m", "\033[1;31m", diff --git a/Source/Console/ConsoleStd/ConsoleStd.cpp b/Source/Console/ConsoleStd/ConsoleStd.cpp index f1b74549..e669f001 100644 --- a/Source/Console/ConsoleStd/ConsoleStd.cpp +++ b/Source/Console/ConsoleStd/ConsoleStd.cpp @@ -134,7 +134,7 @@ namespace Aurora::Console::ConsoleStd void Start() { static bool gConsoleStarted = false; - if (std::exchange(gConsoleStarted, true)) return; + if (AuExchange(gConsoleStarted, true)) return; #if defined(AURORA_IS_MODERNNT_DERIVED) @@ -311,14 +311,14 @@ namespace Aurora::Console::ConsoleStd Pump(); gRingLock.Lock(); - auto readable = std::min(AuUInt32(length), AuUInt32(gEncodedIndex)); + auto readable = AuMin(AuUInt32(length), AuUInt32(gEncodedIndex)); - std::memcpy(data, gLineEncodedBuffer, readable); + AuMemcpy(data, gLineEncodedBuffer, readable); const auto remainingBytes = gEncodedIndex - readable; if (remainingBytes) { - std::memmove(gLineEncodedBuffer, &gLineEncodedBuffer[readable], remainingBytes); + AuMemmove(gLineEncodedBuffer, &gLineEncodedBuffer[readable], remainingBytes); } gEncodedIndex = remainingBytes; @@ -362,7 +362,7 @@ namespace Aurora::Console::ConsoleStd const auto remainingBytes = gLineIndex - startIdx; if (remainingBytes) { - std::memmove(gLineBuffer.data(), &gLineBuffer.data()[startIdx], remainingBytes); + AuMemmove(gLineBuffer.data(), &gLineBuffer.data()[startIdx], remainingBytes); gLineIndex -= startIdx; } } @@ -385,7 +385,7 @@ namespace Aurora::Console::ConsoleStd const auto remainingBytes = gEncodedIndex - ret.first; if (remainingBytes) { - std::memmove(gLineEncodedBuffer, &gLineEncodedBuffer[ret.first], remainingBytes); + AuMemmove(gLineEncodedBuffer, &gLineEncodedBuffer[ret.first], remainingBytes); } gEncodedIndex = remainingBytes; diff --git a/Source/Console/ConsoleWxWidgets/ConsoleWxWidgets.cpp b/Source/Console/ConsoleWxWidgets/ConsoleWxWidgets.cpp index 81ffcab4..06392428 100644 --- a/Source/Console/ConsoleWxWidgets/ConsoleWxWidgets.cpp +++ b/Source/Console/ConsoleWxWidgets/ConsoleWxWidgets.cpp @@ -53,7 +53,7 @@ public: private: DECLARE_EVENT_TABLE() - std::optional _color; + AuOptional _color; }; wxBEGIN_EVENT_TABLE(WxSplitterLine, wxPanel) EVT_PAINT(WxSplitterLine::OnPaint) @@ -164,7 +164,7 @@ WxSplitterLine *ConsoleFrame::NewSplitter(wxSize splitter) void ConsoleFrame::WriteLine(const Aurora::Console::ConsoleMessage &string) { - static std::array(Aurora::Console::EAnsiColor::eCount)> ColorMap + static AuArray(Aurora::Console::EAnsiColor::eCount)> ColorMap { *wxRED, // kRed, *wxRED, // kBoldRed, @@ -181,7 +181,7 @@ void ConsoleFrame::WriteLine(const Aurora::Console::ConsoleMessage &string) *wxWHITE, // kReset }; - static std::array(Aurora::Console::EAnsiColor::eCount)> HahaBald + static AuArray(Aurora::Console::EAnsiColor::eCount)> HahaBald { false, // kRed, true, // kBoldRed, @@ -769,7 +769,7 @@ namespace Aurora::Console::ConsoleWxWidgets void Start() { - if (std::exchange(gConsoleStarted, true)) return; + if (AuExchange(gConsoleStarted, true)) return; gMutex = AuThreadPrimitives::MutexUnique(); if (!gMutex) return; @@ -797,7 +797,7 @@ namespace Aurora::Console::ConsoleWxWidgets AuList lines; { AU_LOCK_GUARD(gMutex); - lines = std::exchange(gPendingLines, {}); + lines = AuExchange(gPendingLines, {}); } for (const auto& line : lines) diff --git a/Source/Console/Hooks/Hooks.cpp b/Source/Console/Hooks/Hooks.cpp index fc014d53..ad5e41f4 100644 --- a/Source/Console/Hooks/Hooks.cpp +++ b/Source/Console/Hooks/Hooks.cpp @@ -39,7 +39,7 @@ namespace Aurora::Console::Hooks static void WriteLoggerFailedWarning() { - static std::string kLoggerError = "Something went from while dispatching a log line\n"; + static AuString kLoggerError = "Something went from while dispatching a log line\n"; Console::WriteStdOut(kLoggerError.data(), kLoggerError.size()); #if defined(AURORA_IS_MODERNNT_DERIVED) diff --git a/Source/Crypto/AES/Aes.cpp b/Source/Crypto/AES/Aes.cpp index 241c04f0..99a45222 100644 --- a/Source/Crypto/AES/Aes.cpp +++ b/Source/Crypto/AES/Aes.cpp @@ -125,7 +125,7 @@ namespace Aurora::Crypto::AES return false; } - std::memcpy(pad, tptr + primaryLength, overhang); + AuMemcpy(pad, tptr + primaryLength, overhang); pad[127] = padding; ret = cbc_encrypt(pad, out.data() + primaryLength, 128, &cbc); diff --git a/Source/Crypto/ECC/ECCGeneric.cpp b/Source/Crypto/ECC/ECCGeneric.cpp index e2a9eca4..74ca9e31 100644 --- a/Source/Crypto/ECC/ECCGeneric.cpp +++ b/Source/Crypto/ECC/ECCGeneric.cpp @@ -126,7 +126,7 @@ namespace Aurora::Crypto::ECC return true; } - std::optional GenerateNewGenericECC(EECCCurve curve) + AuOptional GenerateNewGenericECC(EECCCurve curve) { ecc_key key = {}; const int prng_idx = register_prng(&sprng_desc); diff --git a/Source/Crypto/ECC/ECCGeneric.hpp b/Source/Crypto/ECC/ECCGeneric.hpp index 5a6daf47..57838906 100644 --- a/Source/Crypto/ECC/ECCGeneric.hpp +++ b/Source/Crypto/ECC/ECCGeneric.hpp @@ -63,7 +63,7 @@ namespace Aurora::Crypto::ECC pk_oid_str_to_num(ref.value()->OID, oid, &oidLength); if (oidLength != in.dp.oidlen || - std::memcmp(in.dp.oid, oid, in.dp.oidlen * sizeof(unsigned long))) + AuMemcmp(in.dp.oid, oid, in.dp.oidlen * sizeof(unsigned long))) { SysPushErrorParam("Improper curve type, expected {}, got {}, for ECCCurveType: {}", ref.value()->OID, AuList(in.dp.oid, in.dp.oid + in.dp.oidlen), curve.value()); ecc_free(&in); @@ -90,5 +90,5 @@ namespace Aurora::Crypto::ECC return out; } - std::optional GenerateNewGenericECC(EECCCurve curve); + AuOptional GenerateNewGenericECC(EECCCurve curve); } \ No newline at end of file diff --git a/Source/Crypto/X509/x509.cpp b/Source/Crypto/X509/x509.cpp index ba3c7bf9..68328b63 100644 --- a/Source/Crypto/X509/x509.cpp +++ b/Source/Crypto/X509/x509.cpp @@ -27,7 +27,7 @@ namespace Aurora::Crypto::X509 { #pragma region functions copied from mbedtls, modified to do extract the asn fields we care about - static int x509_get_crt_ext(mbedtls_x509_crt *crt, const char *oid, int oidLength, std::function cb); + static int x509_get_crt_ext(mbedtls_x509_crt *crt, const char *oid, int oidLength, AuFunction cb); static int x509_get_ca_id(mbedtls_x509_crt *crt, AuList &key) { @@ -318,7 +318,7 @@ namespace Aurora::Crypto::X509 find_oid_value_in_name(&name, MBEDTLS_OID_AT_GIVEN_NAME, out.name); } - static bool ParseCert(const Certificate &der, std::function cb) + static bool ParseCert(const Certificate &der, AuFunction cb) { bool ret = false; mbedtls_x509_crt crt {}; diff --git a/Source/Debug/ExceptionWatcher.Win32.cpp b/Source/Debug/ExceptionWatcher.Win32.cpp index 8f6579ca..58b10ef8 100644 --- a/Source/Debug/ExceptionWatcher.Win32.cpp +++ b/Source/Debug/ExceptionWatcher.Win32.cpp @@ -110,7 +110,7 @@ namespace Aurora::Debug if (SymGetLineFromAddr64(process, stack.AddrPC.Offset, &disp, &line)) { - frameCurrent.file = std::make_tuple(line.FileName, line.LineNumber, 0); + frameCurrent.file = AuMakeTuple(line.FileName, line.LineNumber, 0); } #endif @@ -304,7 +304,7 @@ namespace Aurora::Debug } else { - entry.wincxx.str = std::to_string(ExceptionInfo->ExceptionRecord->ExceptionCode); + entry.wincxx.str = AuToString(ExceptionInfo->ExceptionRecord->ExceptionCode); } } else diff --git a/Source/Debug/Panic.cpp b/Source/Debug/Panic.cpp index 707fa4c2..0507e5b3 100644 --- a/Source/Debug/Panic.cpp +++ b/Source/Debug/Panic.cpp @@ -59,7 +59,7 @@ namespace Aurora::Debug } static bool panicSingleshot = false; - if (std::exchange(panicSingleshot, true)) + if (AuExchange(panicSingleshot, true)) { try { @@ -73,7 +73,7 @@ namespace Aurora::Debug // static bool handlingFatal = false; - if (std::exchange(handlingFatal, true)) + if (AuExchange(handlingFatal, true)) { std::terminate(); } diff --git a/Source/HWInfo/CpuInfo.cpp b/Source/HWInfo/CpuInfo.cpp index 9d96bf89..526c0b4a 100644 --- a/Source/HWInfo/CpuInfo.cpp +++ b/Source/HWInfo/CpuInfo.cpp @@ -336,8 +336,8 @@ namespace Aurora::HWInfo { // Credit: https://docs.microsoft.com/en-us/cpp/intrinsics/cpuid-cpuidex?view=msvc-160 #if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86) - std::vector data; - std::vector extdata; + AuList data; + AuList extdata; auto cpuInfo = cpuid(0); auto nIds = cpuInfo.eax; diff --git a/Source/Hashing/Digests.cpp b/Source/Hashing/Digests.cpp index 9ae4558c..813a6b1f 100644 --- a/Source/Hashing/Digests.cpp +++ b/Source/Hashing/Digests.cpp @@ -11,7 +11,7 @@ namespace Aurora::Hashing { - AUKN_SYM void MD5(const void *buffer, AuMach length, std::array &md5) + AUKN_SYM void MD5(const void *buffer, AuMach length, AuArray &md5) { hash_state md; md5_init(&md); @@ -19,7 +19,7 @@ namespace Aurora::Hashing md5_done(&md, md5.data()); } - AUKN_SYM void SHA1(const void *buffer, AuMach length, std::array &sha1) + AUKN_SYM void SHA1(const void *buffer, AuMach length, AuArray &sha1) { hash_state md; sha1_init(&md); @@ -27,7 +27,7 @@ namespace Aurora::Hashing sha1_done(&md, sha1.data()); } - AUKN_SYM void Tiger(const void *buffer, AuMach length, std::array &tiger) + AUKN_SYM void Tiger(const void *buffer, AuMach length, AuArray &tiger) { hash_state md; tiger_init(&md); @@ -35,7 +35,7 @@ namespace Aurora::Hashing tiger_done(&md, tiger.data()); } - AUKN_SYM void SHA2(const void *buffer, AuMach length, std::array &sha2) + AUKN_SYM void SHA2(const void *buffer, AuMach length, AuArray &sha2) { hash_state md; sha256_init(&md); @@ -43,7 +43,7 @@ namespace Aurora::Hashing sha256_done(&md, sha2.data()); } - AUKN_SYM void SHA2_64(const void *buffer, AuMach length, std::array &sha2) + AUKN_SYM void SHA2_64(const void *buffer, AuMach length, AuArray &sha2) { hash_state md; sha512_init(&md); diff --git a/Source/Hashing/HashStream.cpp b/Source/Hashing/HashStream.cpp index 51e08c1b..a40c4647 100644 --- a/Source/Hashing/HashStream.cpp +++ b/Source/Hashing/HashStream.cpp @@ -81,35 +81,35 @@ namespace Aurora::Hashing { case EHashType::eMD5: length = 16; - if (!std::exchange(finished_, true)) + if (!AuExchange(finished_, true)) { md5_done(&state_, reinterpret_cast(buffer_)); } return buffer_; case EHashType::eSHA1: length = 20; - if (!std::exchange(finished_, true)) + if (!AuExchange(finished_, true)) { sha1_done(&state_, reinterpret_cast(buffer_)); } return buffer_; case EHashType::eSHA2_32: length = 32; - if (!std::exchange(finished_, true)) + if (!AuExchange(finished_, true)) { sha256_done(&state_, reinterpret_cast(buffer_)); } return buffer_; case EHashType::eSHA2_64: length = 64; - if (!std::exchange(finished_, true)) + if (!AuExchange(finished_, true)) { sha512_done(&state_, reinterpret_cast(buffer_)); } return buffer_; case EHashType::eTiger: length = 24; - if (!std::exchange(finished_, true)) + if (!AuExchange(finished_, true)) { tiger_done(&state_, reinterpret_cast(buffer_)); } diff --git a/Source/IO/FS/Async.NT.cpp b/Source/IO/FS/Async.NT.cpp index cf12306a..8690e9f5 100644 --- a/Source/IO/FS/Async.NT.cpp +++ b/Source/IO/FS/Async.NT.cpp @@ -183,7 +183,7 @@ namespace Aurora::IO::FS bool NtAsyncFileTransaction::StartRead(AuUInt64 offset, void *buffer, AuUInt32 length) { - if (std::exchange(this->pin_, AuSharedFromThis())) + if (AuExchange(this->pin_, AuSharedFromThis())) { return {}; } @@ -197,7 +197,7 @@ namespace Aurora::IO::FS bool NtAsyncFileTransaction::StartWrite(AuUInt64 offset, const void *buffer, AuUInt32 length) { - if (std::exchange(this->pin_, AuSharedFromThis())) + if (AuExchange(this->pin_, AuSharedFromThis())) { return {}; } @@ -211,12 +211,12 @@ namespace Aurora::IO::FS void NtAsyncFileTransaction::DispatchCb() { - if (std::exchange(this->latch_, true)) + if (AuExchange(this->latch_, true)) { return; } - auto hold = std::exchange(this->pin_, {}); + auto hold = AuExchange(this->pin_, {}); if (hold->sub_) { diff --git a/Source/IO/FS/FS.NT.cpp b/Source/IO/FS/FS.NT.cpp index 04e39c9e..aa3fe181 100644 --- a/Source/IO/FS/FS.NT.cpp +++ b/Source/IO/FS/FS.NT.cpp @@ -70,7 +70,7 @@ namespace Aurora::IO::FS { DWORD written; - int blockSize = std::min(static_cast(kFileCopyBlock), static_cast(length)); + int blockSize = AuMin(static_cast(kFileCopyBlock), static_cast(length)); if (!::WriteFile(fileHandle, &reinterpret_cast(data)[offset], blockSize, &written, NULL)) { @@ -129,7 +129,7 @@ namespace Aurora::IO::FS { DWORD read; - int blockSize = std::min(static_cast(kFileCopyBlock), static_cast(length.QuadPart)); + int blockSize = AuMin(static_cast(kFileCopyBlock), static_cast(length.QuadPart)); if (!::ReadFile(fileHandle, &buffer[offset], blockSize, &read, NULL)) { diff --git a/Source/IO/FS/FileStream.NT.cpp b/Source/IO/FS/FileStream.NT.cpp index 26868d35..c17d8975 100644 --- a/Source/IO/FS/FileStream.NT.cpp +++ b/Source/IO/FS/FileStream.NT.cpp @@ -103,7 +103,7 @@ namespace Aurora::IO::FS { DWORD read; - int blockSize = std::min(kFileCopyBlock, length); + int blockSize = AuMin(kFileCopyBlock, length); if (!::ReadFile(handle_, reinterpret_cast(parameters.ptr) + offset, blockSize, &read, NULL)) { @@ -144,7 +144,7 @@ namespace Aurora::IO::FS { DWORD written; - int blockSize = std::min(kFileCopyBlock, length); + int blockSize = AuMin(kFileCopyBlock, length); if (!::WriteFile(handle_, reinterpret_cast(parameters.ptr) + offset, blockSize, &written, NULL)) { diff --git a/Source/IO/FS/Resources.cpp b/Source/IO/FS/Resources.cpp index 7a7e0b1d..5cab7009 100644 --- a/Source/IO/FS/Resources.cpp +++ b/Source/IO/FS/Resources.cpp @@ -22,7 +22,7 @@ namespace Aurora::IO::FS { #if defined(AURORA_PLATFORM_WIN32) - static void Win32FixGlobalAppDataAcl(const std::string &path); + static void Win32FixGlobalAppDataAcl(const AuString &path); #endif static AuString gHomeDirectory; @@ -337,7 +337,7 @@ namespace Aurora::IO::FS } #if defined(AURORA_PLATFORM_WIN32) - static void Win32FixGlobalAppDataAcl(const std::string &path) + static void Win32FixGlobalAppDataAcl(const AuString &path) { BOOL bRetval = FALSE; diff --git a/Source/IO/Net/SocketStatAverageBps.hpp b/Source/IO/Net/SocketStatAverageBps.hpp index 556a4f49..f1a8861f 100644 --- a/Source/IO/Net/SocketStatAverageBps.hpp +++ b/Source/IO/Net/SocketStatAverageBps.hpp @@ -62,8 +62,8 @@ namespace Aurora::IO::Net if (nextTick < timeNow) { frameLastEnd = timeNow; - frameLastStart = std::exchange(frameStart, timeNow); - lastBytesTransferred = std::exchange(bytesTransferred, bytes); + frameLastStart = AuExchange(frameStart, timeNow); + lastBytesTransferred = AuExchange(bytesTransferred, bytes); frameZero = true; } else diff --git a/Source/Locale/Encoding/ConvertInternal.cpp b/Source/Locale/Encoding/ConvertInternal.cpp index 24d5a7b7..49a9635e 100644 --- a/Source/Locale/Encoding/ConvertInternal.cpp +++ b/Source/Locale/Encoding/ConvertInternal.cpp @@ -142,7 +142,7 @@ namespace Aurora::Locale::Encoding AuStreamReadWrittenPair_t EncodeUTF8Internal(const void *utf8, AuUInt32 utf8Length, void *binary, AuUInt32 binaryLength, ECodePage page) { AuStreamReadWrittenPair_t ret {}; - auto readable = std::min(AuUInt(utf8Length), AuUInt(binaryLength)); + auto readable = AuMin(AuUInt(utf8Length), AuUInt(binaryLength)); AuList temp; if (!binary) @@ -168,7 +168,7 @@ namespace Aurora::Locale::Encoding case ECodePage::eUTF8: if (utf8 && binary) { - std::memcpy(binary, utf8, readable); + AuMemcpy(binary, utf8, readable); } ret = AuMakePair(utf8Length, binary ? binaryLength : utf8Length); break; @@ -190,7 +190,7 @@ namespace Aurora::Locale::Encoding } AuList rw(reinterpret_cast(binary), reinterpret_cast(binary) + binaryLength); - auto readable = std::min(AuUInt(binaryLength), AuUInt(utf8Max)); + auto readable = AuMin(AuUInt(binaryLength), AuUInt(utf8Max)); switch (page) { @@ -208,7 +208,7 @@ namespace Aurora::Locale::Encoding case ECodePage::eUTF8: if (utf8 && binary) { - std::memcpy(utf8, binary, readable); + AuMemcpy(utf8, binary, readable); } ret = AuMakePair(binaryLength, utf8 ? utf8Max : binaryLength); break; @@ -229,7 +229,7 @@ namespace Aurora::Locale::Encoding } AuList rw(reinterpret_cast(binary), reinterpret_cast(binary) + binaryLength); - auto readable = std::min(AuUInt(binaryLength), AuUInt(utf8Max)); + auto readable = AuMin(AuUInt(binaryLength), AuUInt(utf8Max)); switch (page) { @@ -247,7 +247,7 @@ namespace Aurora::Locale::Encoding case ECodePage::eUTF8: if (utf8 && binary) { - std::memcpy(utf8, binary, readable); + AuMemcpy(utf8, binary, readable); } ret = AuMakePair(binaryLength, utf8 ? utf8Max : binaryLength); break; diff --git a/Source/Locale/Encoding/EncoderAdapter.cpp b/Source/Locale/Encoding/EncoderAdapter.cpp index d51f0e1c..ff00b6d5 100644 --- a/Source/Locale/Encoding/EncoderAdapter.cpp +++ b/Source/Locale/Encoding/EncoderAdapter.cpp @@ -57,10 +57,10 @@ namespace Aurora::Locale::Encoding { length = CountUTF8Length({in, length}, true); - auto readable = std::min(length, utf8Max); + auto readable = AuMin(length, utf8Max); if (utf8 && in) { - std::memcpy(utf8, in, readable); + AuMemcpy(utf8, in, readable); } return {readable, readable}; @@ -110,10 +110,10 @@ namespace Aurora::Locale::Encoding if (TestPage(ECodePage::eUTF8)) { - auto readable = std::min(utf8Length, cpLen); + auto readable = AuMin(utf8Length, cpLen); if (utf8 && cp) { - std::memcpy(cp, utf8, readable); + AuMemcpy(cp, utf8, readable); } return {utf8Length, utf8 ? cpLen : utf8Length}; } diff --git a/Source/Locale/Encoding/Encoding.hpp b/Source/Locale/Encoding/Encoding.hpp index bfa8f226..3f4e5cdc 100644 --- a/Source/Locale/Encoding/Encoding.hpp +++ b/Source/Locale/Encoding/Encoding.hpp @@ -36,7 +36,7 @@ namespace Aurora::Locale::Encoding if (!binary) return {}; if (!binaryLength) return {}; - if (!std::exchange(readHeader, true)) + if (!AuExchange(readHeader, true)) { if (page == ECodePage::eUnsupported) { diff --git a/Source/Locale/Locale.cpp b/Source/Locale/Locale.cpp index 137dcec1..1fd576d8 100644 --- a/Source/Locale/Locale.cpp +++ b/Source/Locale/Locale.cpp @@ -135,7 +135,7 @@ namespace Aurora::Locale } else { - gCodeset = "MS-" + std::to_string(acp); + gCodeset = "MS-" + AuToString(acp); gInternalCodePage = ECodePage::eSysUnk; } } @@ -206,7 +206,7 @@ namespace Aurora::Locale { #if 0 // this doesn't seem to work with libc++ lol? - auto locale = std::locale("").name(); + auto locale = -std::--locale("").name(); #else setlocale(LC_ALL, ""); AuString locale = setlocale(LC_ALL, NULL); @@ -352,7 +352,7 @@ namespace Aurora::Locale AUKN_SYM void RuntimeOverloadLocality(const AuPair &locality) { - SysAssert(!std::exchange(gLockLocale, true), "Locality has been locked"); + SysAssert(!AuExchange(gLockLocale, true), "Locality has been locked"); gLanguageCode = AuToLower(locality.first); gCountryCode = AuToUpper(locality.second); } diff --git a/Source/Memory/Heap.cpp b/Source/Memory/Heap.cpp index a9896ecb..82b5466d 100644 --- a/Source/Memory/Heap.cpp +++ b/Source/Memory/Heap.cpp @@ -182,7 +182,7 @@ namespace Aurora::Memory auto prevLength = GetHeapSize(buffer); auto alloc = _ZAlloc(length); if (!alloc) return nullptr; - std::memcpy(alloc, buffer, std::min(prevLength, length)); + AuMemcpy(alloc, buffer, AuMin(prevLength, length)); _Free(buffer); return alloc; } @@ -198,7 +198,7 @@ namespace Aurora::Memory auto prevLength = GetHeapSize(buffer); auto alloc = _FAlloc(length); if (!alloc) return nullptr; - std::memcpy(alloc, buffer, std::min(prevLength, length)); + AuMemcpy(alloc, buffer, AuMin(prevLength, length)); _Free(buffer); return alloc; } diff --git a/Source/Parse/Hex.cpp b/Source/Parse/Hex.cpp index 835676a9..70bd25a9 100644 --- a/Source/Parse/Hex.cpp +++ b/Source/Parse/Hex.cpp @@ -44,7 +44,7 @@ namespace Aurora::Parse AUKN_SYM bool HexToInt(const char *hex, AuUInt32 length, AuUInt64 &val) { val = 0; - length = std::min(AuUInt32(sizeof(AuUInt64) * 2), length); + length = AuMin(AuUInt32(sizeof(AuUInt64) * 2), length); for (auto i = 0u; i < length; i++) { @@ -247,7 +247,7 @@ namespace Aurora::Parse in.insert(in.size(), " "); } - rowMax = std::min(AuUInt32(i + 16), AuUInt32(length)); + rowMax = AuMin(AuUInt32(i + 16), AuUInt32(length)); for (x = i; x < rowMax; diff --git a/Source/Parse/Parser.cpp b/Source/Parse/Parser.cpp index 68aa8c0f..1fe01853 100644 --- a/Source/Parse/Parser.cpp +++ b/Source/Parse/Parser.cpp @@ -26,7 +26,7 @@ namespace Aurora::Parse bool Next(AuUInt8 &c) { - if (std::exchange(_hasNext, false)) + if (AuExchange(_hasNext, false)) { c = _next; return true; @@ -50,7 +50,7 @@ namespace Aurora::Parse }; template - static std::function ContainedHerein(const AuUInt8(&arry)[Z]) + static AuFunction ContainedHerein(const AuUInt8(&arry)[Z]) { return [=](AuUInt8 c) -> bool { @@ -67,7 +67,7 @@ namespace Aurora::Parse template - static std::function IsTerminating(ParseState &state, const AuUInt8(&arry)[Z]) + static AuFunction IsTerminating(ParseState &state, const AuUInt8(&arry)[Z]) { return [&](AuUInt8 c) -> bool { @@ -131,7 +131,7 @@ namespace Aurora::Parse if (isTerminating(next)) { // Make sure we aren't encapsulated by quotation marks - if ((!stringLevel) && (!std::exchange(escapedNewLine, false))) + if ((!stringLevel) && (!AuExchange(escapedNewLine, false))) { state.hasLastToken = true; state.lastTokenCharacter = next; @@ -172,7 +172,7 @@ namespace Aurora::Parse } // see above - if ((next == '"') && (isString) && (std::exchange(escapedQuote, false))) + if ((next == '"') && (isString) && (AuExchange(escapedQuote, false))) { out += "\""; continue; @@ -261,7 +261,7 @@ namespace Aurora::Parse res *= 10; res += static_cast(*itr) - static_cast('0'); - if constexpr (std::is_same::value) + if constexpr (AuIsSame_v) { if (old > res) { @@ -269,7 +269,7 @@ namespace Aurora::Parse return false; } } - else if constexpr (std::is_same::value) + else if constexpr (AuIsSame_v) { if (SignBit(old) != SignBit(res)) { @@ -548,32 +548,32 @@ namespace Aurora::Parse { case ParsableTag::kParseUInt: { - str += std::to_string(value.primitive.uint); + str += AuToString(value.primitive.uint); break; } case ParsableTag::kParseSInt: { - str += std::to_string(value.primitive.sint); + str += AuToString(value.primitive.sint); break; } case ParsableTag::kParseNumber: { - str += std::to_string(value.primitive.number); + str += AuToString(value.primitive.number); break; } case ParsableTag::kParseVec3: { - str += std::to_string(value.primitive.vec3[0]) + " "; - str += std::to_string(value.primitive.vec3[1]) + " "; - str += std::to_string(value.primitive.vec3[2]); + str += AuToString(value.primitive.vec3[0]) + " "; + str += AuToString(value.primitive.vec3[1]) + " "; + str += AuToString(value.primitive.vec3[2]); break; } case ParsableTag::kParseVec4: { - str += std::to_string(value.primitive.vec4[0]) + " "; - str += std::to_string(value.primitive.vec4[1]) + " "; - str += std::to_string(value.primitive.vec4[2]) + " "; - str += std::to_string(value.primitive.vec4[3]); + str += AuToString(value.primitive.vec4[0]) + " "; + str += AuToString(value.primitive.vec4[1]) + " "; + str += AuToString(value.primitive.vec4[2]) + " "; + str += AuToString(value.primitive.vec4[3]); break; } case ParsableTag::kParseString: @@ -617,7 +617,7 @@ namespace Aurora::Parse if (parsed.isArray) { ret += " "; - ret += std::to_string(parsed.count); + ret += AuToString(parsed.count); } bool isArray = parsed.count > 1 || parsed.isArray; diff --git a/Source/Process/Paths.cpp b/Source/Process/Paths.cpp index 40154654..872794f5 100644 --- a/Source/Process/Paths.cpp +++ b/Source/Process/Paths.cpp @@ -140,7 +140,7 @@ namespace Aurora::Process static bool init = false; char spitter; - if (std::exchange(init, true)) + if (AuExchange(init, true)) { if (!cachedModule.size()) { diff --git a/Source/Processes/Process.Win32.cpp b/Source/Processes/Process.Win32.cpp index 07b14154..d3b4b84f 100644 --- a/Source/Processes/Process.Win32.cpp +++ b/Source/Processes/Process.Win32.cpp @@ -219,7 +219,7 @@ namespace Aurora::Processes bool ProcessImpl::Read(void *buffer, AuUInt32 &len, bool errorStream, bool nonblock) { - DWORD size = std::exchange(len, 0); + DWORD size = AuExchange(len, 0); auto handle = errorStream ? pipeStdErrRead_ : pipeStdOutRead_; if (handle == INVALID_HANDLE_VALUE) @@ -240,7 +240,7 @@ namespace Aurora::Processes return true; } - size = std::min(size, avail); + size = AuMin(size, avail); } auto ret = ReadFile(handle, buffer, size, &size, NULL); diff --git a/Source/RNG/WELL.cpp b/Source/RNG/WELL.cpp index 5e238f06..58d226e7 100644 --- a/Source/RNG/WELL.cpp +++ b/Source/RNG/WELL.cpp @@ -101,14 +101,14 @@ void WELL_NextBytes(WELLRand *rand, void *in, AuUInt32 length) for (; i < length; i += 4) { AuUInt32 rng = WELL_NextLong_Unlocked(rand); - std::memcpy(base + i, &rng, 4); + AuMemcpy(base + i, &rng, 4); } if (i > length) { i -= 4; AuUInt32 padRng = WELL_NextLong_Unlocked(rand); - std::memcpy(base + i, &padRng, length - i); + AuMemcpy(base + i, &padRng, length - i); } rand->lock.Unlock(); diff --git a/Source/Registry/Registry.cpp b/Source/Registry/Registry.cpp index 68efb69b..93655b59 100644 --- a/Source/Registry/Registry.cpp +++ b/Source/Registry/Registry.cpp @@ -227,12 +227,12 @@ namespace Aurora::Registry json object {}; AuString stringified; - if (std::find(restrictedKeys_.begin(), restrictedKeys_.end(), key) != restrictedKeys_.end()) + if (writeMode_ == EWriteMode::eWriteModeLocked) { return false; } - if (writeMode_ == EWriteMode::eWriteModeLocked) + if (AuExists(restrictedKeys_, key)) { return false; } diff --git a/Source/Threading/Threads/OSThread.cpp b/Source/Threading/Threads/OSThread.cpp index 7d6613cc..3fdb1543 100644 --- a/Source/Threading/Threads/OSThread.cpp +++ b/Source/Threading/Threads/OSThread.cpp @@ -85,8 +85,8 @@ namespace Aurora::Threading::Threads AU_LOCK_GUARD(this->tlsLock_); AU_LOCK_GUARD(this->tlsReferenceThread_->tlsLock_); - std::exchange(this->tlsReferenceThread_->tls_, this->tls_); - std::exchange(this->tlsReferenceThread_->threadFeatures_, this->threadFeatures_); + AuExchange(this->tlsReferenceThread_->tls_, this->tls_); + AuExchange(this->tlsReferenceThread_->threadFeatures_, this->threadFeatures_); bDetachedSuccess = true; } @@ -160,7 +160,7 @@ namespace Aurora::Threading::Threads SysPanic("::Run called on system thread"); } - if (std::exchange(contextUsed_, true)) + if (AuExchange(contextUsed_, true)) { return false; } @@ -299,7 +299,7 @@ namespace Aurora::Threading::Threads return tls_; } - bool OSThread::ExecuteNewOSContext(std::function task) + bool OSThread::ExecuteNewOSContext(AuFunction task) { task_ = task; @@ -377,7 +377,7 @@ namespace Aurora::Threading::Threads if (info_.stackSize) { - ret = pthread_attr_setstacksize(&tattr, std::min(AuUInt32(PTHREAD_STACK_MIN), info_.stackSize)); + ret = pthread_attr_setstacksize(&tattr, AuMin(AuUInt32(PTHREAD_STACK_MIN), info_.stackSize)); if (ret != 0) { SysPushErrorGen("Couldn't create thread: {}", GetName()); @@ -413,7 +413,7 @@ namespace Aurora::Threading::Threads Exit(true); } - void OSThread::ExecuteInDeadThread(std::function callback) + void OSThread::ExecuteInDeadThread(AuFunction callback) { auto old = HandleCurrent(); @@ -718,7 +718,7 @@ namespace Aurora::Threading::Threads void OSThread::FreeOSContext() { #if defined(AURORA_IS_MODERNNT_DERIVED) - if (auto handle = std::exchange(handle_, {})) + if (auto handle = AuExchange(handle_, {})) { CloseHandle(handle_); } diff --git a/Source/Threading/Threads/OSThread.hpp b/Source/Threading/Threads/OSThread.hpp index 43021bdb..6bb5afd5 100644 --- a/Source/Threading/Threads/OSThread.hpp +++ b/Source/Threading/Threads/OSThread.hpp @@ -32,7 +32,7 @@ namespace Aurora::Threading::Threads AuSPtr GetTlsView() override; - void ExecuteInDeadThread(std::function callback) override; + void ExecuteInDeadThread(AuFunction callback) override; AuSPtr AsWaitable() override; void AddLastHopeTlsHook(const AuSPtr &feature) override; @@ -46,7 +46,7 @@ namespace Aurora::Threading::Threads protected: bool Exit(bool willReturnToOS); - bool ExecuteNewOSContext(std::function task); + bool ExecuteNewOSContext(AuFunction task); void UpdatePrio(EThreadPrio prio); void UpdateAffinity(AuUInt32 mask); void UpdateName(); @@ -79,7 +79,7 @@ namespace Aurora::Threading::Threads AuList> threadFeatures_; - std::function task_; + AuFunction task_; #if defined(AURORA_IS_MODERNNT_DERIVED) HANDLE handle_ = INVALID_HANDLE_VALUE; diff --git a/Source/Threading/Threads/TLSView.hpp b/Source/Threading/Threads/TLSView.hpp index efe28326..731a629a 100644 --- a/Source/Threading/Threads/TLSView.hpp +++ b/Source/Threading/Threads/TLSView.hpp @@ -22,7 +22,7 @@ namespace Aurora::Threading::Threads void ConsiderRehash(); Primitives::SpinLock lock_; - AuHashMap> tls_; + AuHashMap> tls_; AuUInt64 fence_ = 0; }; } \ No newline at end of file diff --git a/Source/Threading/WaitFor.cpp b/Source/Threading/WaitFor.cpp index 73bb0461..785f85d4 100644 --- a/Source/Threading/WaitFor.cpp +++ b/Source/Threading/WaitFor.cpp @@ -113,7 +113,7 @@ namespace Aurora::Threading { #if defined(AURORA_IS_LINUX_DERIVED) int alpha = getpriority(PRIO_PROCESS, 0); - int bravo = std::min(15, std::max(19, alpha + 5)); + int bravo = AuMin(15, AuMax(19, alpha + 5)); #else int alpha, bravo = 0; #endif @@ -133,7 +133,7 @@ namespace Aurora::Threading { #if defined(AURORA_IS_LINUX_DERIVED) int alpha = getpriority(PRIO_PROCESS, 0); - int bravo = std::min(15, std::max(19, alpha + 5)); + int bravo = AuMin(15, AuMax(19, alpha + 5)); #else int alpha, bravo = 0; #endif