[*] Exterminate more std:: references

This commit is contained in:
Reece Wilson 2022-01-19 17:08:13 +00:00
parent 7316aa0f8f
commit 7759d38ed0
69 changed files with 476 additions and 305 deletions

View File

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

View File

@ -32,28 +32,28 @@ namespace Aurora::Async
}
template<typename Out_t = AVoid, typename ... Args, typename Callable_t>
FJob<std::tuple<Args...>, Out_t> JobFromTupleConsumer(/*AuConsumer<Args..., const Result_t &> */ Callable_t &&onSuccess)
FJob<AuTuple<Args...>, Out_t> JobFromTupleConsumer(/*AuConsumer<Args..., const Result_t &> */ Callable_t &&onSuccess)
{
FJob<std::tuple<Args...>, Out_t> ret;
static_assert(std::is_same_v<std::tuple<Args...>, std::tuple<AuUInt64, AuUInt64>>);
ret.onSuccess = [=](const std::tuple<Args...> &in, const Out_t &a)
FJob<AuTuple<Args...>, Out_t> ret;
static_assert(AuIsSame_v<AuTuple<Args...>, AuTuple<AuUInt64, AuUInt64>>);
ret.onSuccess = [=](const AuTuple<Args...> &in, const Out_t &a)
{
std::apply(onSuccess, std::tuple_cat(in, std::make_tuple<const Out_t &>(a)));
std::apply(onSuccess, std::tuple_cat(in, AuMakeTuple<const Out_t &>(a)));
};
return ret;
}
template<typename Out_t = AVoid, typename ... Args, typename Callable_t, typename FailureCallable_t>
FJob<std::tuple<Args...>, Out_t> JobFromTupleConsumerEx(/*AuConsumer<Args..., const Result_t &> */ Callable_t &&onSuccess, FailureCallable_t &&onFailure)
FJob<AuTuple<Args...>, Out_t> JobFromTupleConsumerEx(/*AuConsumer<Args..., const Result_t &> */ Callable_t &&onSuccess, FailureCallable_t &&onFailure)
{
FJob<std::tuple<Args...>, Out_t> ret;
static_assert(std::is_same_v<std::tuple<Args...>, std::tuple<AuUInt64, AuUInt64>>);
ret.onSuccess = [=](const std::tuple<Args...> &in, const Out_t &a)
FJob<AuTuple<Args...>, Out_t> ret;
static_assert(AuIsSame_v<AuTuple<Args...>, AuTuple<AuUInt64, AuUInt64>>);
ret.onSuccess = [=](const AuTuple<Args...> &in, const Out_t &a)
{
std::apply(onSuccess, std::tuple_cat(in, std::make_tuple<const Out_t &>(a)));
std::apply(onSuccess, std::tuple_cat(in, AuMakeTuple<const Out_t &>(a)));
};
ret.onFailure = [=](const std::tuple<Args...> &in)
ret.onFailure = [=](const AuTuple<Args...> &in)
{
std::apply(onFailure, in);
};
@ -112,10 +112,10 @@ namespace Aurora::Async
}
template<typename ReturnValue_t = void, typename Arg0_t, typename ... Args>
static inline FJob<std::tuple<Arg0_t, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer<const Arg0_t &, const ReturnValue_t &> &onSuccess)
static inline FJob<AuTuple<Arg0_t, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer<const Arg0_t &, const ReturnValue_t &> &onSuccess)
{
FJob<std::tuple<Arg0_t, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const std::tuple<Arg0_t, Args...> &in, const ReturnValue_t &out)
FJob<AuTuple<Arg0_t, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const AuTuple<Arg0_t, Args...> &in, const ReturnValue_t &out)
{
onSuccess(std::get<0>(in), out);
};
@ -123,15 +123,15 @@ namespace Aurora::Async
}
template<typename ReturnValue_t = void, typename Arg0_t, typename ... Args>
static inline FJob<std::tuple<Arg0_t, Args...>, ReturnValue_t> JobFromTupleClazzEx(const AuConsumer<const Arg0_t &, const ReturnValue_t &> &onSuccess, const AuConsumer<const Arg0_t &> &onFailure)
static inline FJob<AuTuple<Arg0_t, Args...>, ReturnValue_t> JobFromTupleClazzEx(const AuConsumer<const Arg0_t &, const ReturnValue_t &> &onSuccess, const AuConsumer<const Arg0_t &> &onFailure)
{
FJob<std::tuple<Arg0_t, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const std::tuple<Arg0_t, Args...> &in, const ReturnValue_t &out)
FJob<AuTuple<Arg0_t, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const AuTuple<Arg0_t, Args...> &in, const ReturnValue_t &out)
{
onSuccess(std::get<0>(in), out);
};
ret.onFailure = [=](const std::tuple<Arg0_t, Args...> &in)
ret.onFailure = [=](const AuTuple<Arg0_t, Args...> &in)
{
onFailure(std::get<0>(in));
};
@ -140,10 +140,10 @@ namespace Aurora::Async
#if 0
template<typename ReturnValue_t = void, typename Clazz_t, typename ... Args>
static inline FJob<std::tuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer<const ReturnValue_t &> &onSuccess)
static inline FJob<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer<const ReturnValue_t &> &onSuccess)
{
FJob<std::tuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const std::tuple<AuSPtr<Clazz_t>, Args...> &in, const ReturnValue_t &out)
FJob<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const AuTuple<AuSPtr<Clazz_t>, Args...> &in, const ReturnValue_t &out)
{
onSuccess(out);
};
@ -151,22 +151,22 @@ namespace Aurora::Async
}
template<typename ReturnValue_t = void, typename Clazz_t, typename ... Args>
static inline FJob<std::tuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer<Args..., const ReturnValue_t &> &onSuccess)
static inline FJob<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer<Args..., const ReturnValue_t &> &onSuccess)
{
FJob<std::tuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const std::tuple<AuSPtr<Clazz_t>, Args...> &in, const ReturnValue_t &out)
FJob<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const AuTuple<AuSPtr<Clazz_t>, Args...> &in, const ReturnValue_t &out)
{
std::apply(onSuccess, std::tuple_cat(AuTuplePopFront(in), std::make_tuple<const ReturnValue_t &>(out)));
std::apply(onSuccess, std::tuple_cat(AuTuplePopFront(in), AuMakeTuple<const ReturnValue_t &>(out)));
};
return ret;
}
#endif
template<typename ReturnValue_t = void, typename ... Args>
static inline FJob<std::tuple<Args...>, ReturnValue_t> JobFromTupleResultConsumer(const AuConsumer<const ReturnValue_t &> &onSuccess)
static inline FJob<AuTuple<Args...>, ReturnValue_t> JobFromTupleResultConsumer(const AuConsumer<const ReturnValue_t &> &onSuccess)
{
FJob<std::tuple<Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const std::tuple<Args...> &in, const ReturnValue_t &out)
FJob<AuTuple<Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const AuTuple<Args...> &in, const ReturnValue_t &out)
{
onSuccess(out);
};
@ -174,12 +174,12 @@ namespace Aurora::Async
}
template<typename ReturnValue_t = void, typename ... Args>
static inline FJob<std::tuple<Args...>, ReturnValue_t> JobFromTuple(const AuConsumer<Args..., const ReturnValue_t &> &onSuccess)
static inline FJob<AuTuple<Args...>, ReturnValue_t> JobFromTuple(const AuConsumer<Args..., const ReturnValue_t &> &onSuccess)
{
FJob<std::tuple<Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const std::tuple<Args...> &in, const ReturnValue_t &out)
FJob<AuTuple<Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const AuTuple<Args...> &in, const ReturnValue_t &out)
{
std::apply(onSuccess, std::tuple_cat(in, std::make_tuple<const ReturnValue_t &>(out)));
std::apply(onSuccess, std::tuple_cat(in, AuMakeTuple<const ReturnValue_t &>(out)));
};
return ret;
}

View File

@ -15,7 +15,7 @@ namespace Aurora::Async
FTask<Info_t, Out_t> ret;
ret.onFrame = [callable = func](const Info_t &in) -> Out_t
{
if constexpr (std::is_same_v<Out_t, AVoid>)
if constexpr (AuIsSame_v<Out_t, AVoid>)
{
callable(in);
return {};
@ -29,11 +29,11 @@ namespace Aurora::Async
}
template<typename Out_t = AVoid, typename ... Args, typename Functor>
FTask<std::tuple<Args...>, Out_t> TaskFromTupleCallable(Functor &&func)
FTask<AuTuple<Args...>, Out_t> TaskFromTupleCallable(Functor &&func)
{
FTask<std::tuple<Args...>, Out_t> ret;
static_assert(std::is_same_v<std::tuple<Args...>, std::tuple<AuUInt64, AuUInt64>>);
ret.onFrame = [callable = func](const std::tuple<Args...> &in) -> Out_t
FTask<AuTuple<Args...>, Out_t> ret;
static_assert(AuIsSame_v<AuTuple<Args...>, AuTuple<AuUInt64, AuUInt64>>);
ret.onFrame = [callable = func](const AuTuple<Args...> &in) -> Out_t
{
return std::apply(callable, in);
};
@ -41,12 +41,12 @@ namespace Aurora::Async
}
template<typename Out_t = AVoid, typename Owner_t, typename ... Args>
FTask<std::tuple<Args...>, Out_t> TaskFromTupleCallableWithOwnerArg(AuFunction<Out_t(Args...)> &&func, const Owner_t &ownerToPin)
FTask<AuTuple<Args...>, Out_t> TaskFromTupleCallableWithOwnerArg(AuFunction<Out_t(Args...)> &&func, const Owner_t &ownerToPin)
{
FTask<std::tuple<Owner_t, Args...>, Out_t> ret;
ret.onFrame = [callable = func](const std::tuple<Args...> &in) -> Out_t
FTask<AuTuple<Owner_t, Args...>, Out_t> ret;
ret.onFrame = [callable = func](const AuTuple<Args...> &in) -> Out_t
{
return std::apply(callable, std::tuple_cat(std::make_tuple<Owner_t>(ownerToPin), in));
return std::apply(callable, AuTuple_cat(AuMakeTuple<Owner_t>(ownerToPin), in));
};
return ret;
}

View File

@ -12,43 +12,43 @@ namespace Aurora::Async
/// --- THREAD POOL --
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a = const Job_t &, class b = Task_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v<WorkerPId_tt, WorkerPId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a = const Job_t &, class b = Task_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerPId_tt, WorkerPId_t>)>
static AuSPtr<IWorkItem> NewWork(const WorkerPId_tt &worker, a task, b job, bool enableWait = false)
{
return worker.pool->NewWorkItem(worker, AuMakeShared<WorkPairImpl<Info_t, Result_t, Task_t>>(task, job), enableWait);
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a = const Job_t &, class b = Task_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v<WorkerPId_tt, WorkerPId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a = const Job_t &, class b = Task_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerPId_tt, WorkerPId_t>)>
static AuSPtr<IWorkItem> DispatchWork(const WorkerPId_tt &worker, a task, b job, bool enableWait = false)
{
return NewWork<Info_t, Result_t, Task_t, Job_t>(worker, task, job, enableWait)->Dispatch();
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a, class b = Job_t, class c, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v<WorkerPId_tt, WorkerPId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a, class b = Job_t, class c, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerPId_tt, WorkerPId_t>)>
static AuSPtr<IWorkItem> NewWork(const WorkerPId_tt &worker, a task, b job, c info, bool enableWait = false)
{
return worker.pool->NewWorkItem(worker, AuMakeShared<WorkPairImpl<Info_t, Result_t, Task_t>>(task, job, info), enableWait);
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a, class b = Job_t, class c, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v<WorkerPId_tt, WorkerPId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a, class b = Job_t, class c, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerPId_tt, WorkerPId_t>)>
static AuSPtr<IWorkItem> DispatchWork(const WorkerPId_tt &worker, a task, b job, c info, bool enableWait = false)
{
return NewWork<Info_t, Result_t, Task_t, Job_t>(worker, task, job, info, enableWait)->Dispatch();
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, 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<WorkerPId_tt, WorkerPId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerPId_tt, WorkerPId_t>)>
AuSPtr<IWorkItem> DispatchFunctional(const WorkerPId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false)
{
return NewWork<Info_t, Result_t, Task_t, Job_t>(worker, TaskFromConsumerRefT<Info_t, Result_t>(task), job, inputParameters, enableWait);
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, 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<WorkerPId_tt, WorkerPId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerPId_tt, WorkerPId_t>)>
AuSPtr<IWorkItem> DispatchFunctor(const WorkerPId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false)
{
return NewWork<Info_t, Result_t, Task_t, Job_t>(worker, TaskFromConsumerRefT<Info_t, Result_t>(task), job, inputParameters, enableWait);
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, 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<WorkerPId_tt, WorkerPId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerPId_tt, WorkerPId_t>)>
AuSPtr<IWorkItem> DispatchVoid(const WorkerPId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false)
{
return NewWork<Info_t, Result_t, Task_t, Job_t>(worker, TaskFromVoidVoid<Info_t, Result_t>(task), job, inputParameters, enableWait);
@ -57,43 +57,43 @@ namespace Aurora::Async
/// --- ASYNC APP --
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v<WorkerId_tt, WorkerId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerId_tt, WorkerId_t>)>
static AuSPtr<IWorkItem> NewWork(const WorkerId_tt &worker, a task, b job, bool enableWait = false)
{
return NewWorkItem(worker, AuMakeShared<WorkPairImpl<Info_t, Result_t, Task_t>>(task, job), enableWait);
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v<WorkerId_tt, WorkerId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerId_tt, WorkerId_t>)>
static AuSPtr<IWorkItem> DispatchWork(const WorkerId_tt &worker, a task, b job, bool enableWait = false)
{
return NewWork<Info_t, Result_t, Task_t, Job_t>(worker, task, job, enableWait)->Dispatch();
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a, class b = Job_t, class c, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v<WorkerId_tt, WorkerId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a, class b = Job_t, class c, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerId_tt, WorkerId_t>)>
static AuSPtr<IWorkItem> NewWork(const WorkerId_tt &worker, a task, b job, c info, bool enableWait = false)
{
return NewWorkItem(worker, AuMakeShared<WorkPairImpl<Info_t, Result_t, Task_t>>(task, job, info), enableWait);
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a, class b = Job_t, class c, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v<WorkerId_tt, WorkerId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a, class b = Job_t, class c, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerId_tt, WorkerId_t>)>
static AuSPtr<IWorkItem> DispatchWork(const WorkerId_tt &worker, a task, b job, c info, bool enableWait = false)
{
return NewWork<Info_t, Result_t, Task_t, Job_t>(worker, task, job, info, enableWait)->Dispatch();
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, 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<WorkerId_tt, WorkerId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerId_tt, WorkerId_t>)>
AuSPtr<IWorkItem> DispatchFunctional(const WorkerId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false)
{
return NewWork<Info_t, Result_t, Task_t, Job_t>(worker, TaskFromConsumerRefT<Info_t, Result_t>(task), job, inputParameters, enableWait);
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, 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<WorkerId_tt, WorkerId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerId_tt, WorkerId_t>)>
AuSPtr<IWorkItem> DispatchFunctor(const WorkerId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false)
{
return NewWork<Info_t, Result_t, Task_t, Job_t>(worker, TaskFromConsumerRefT<Info_t, Result_t>(task), job, inputParameters, enableWait);
}
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, 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<WorkerId_tt, WorkerId_t>)>
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<WorkerId_tt, WorkerId_t>)>
AuSPtr<IWorkItem> DispatchVoid(const WorkerId_t &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false)
{
return NewWork<Info_t, Result_t, Task_t, Job_t>(worker, TaskFromVoidVoid<Info_t, Result_t>(task), job, inputParameters, enableWait);
@ -105,7 +105,7 @@ namespace Aurora::Async
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),
Async::JobFromTupleClazz<ReturnValue_t, AuSPtr<Clazz_t>, Args...>(job),
std::make_tuple<AuSPtr<Clazz_t>, Args...>(AU_FWD(owner), std::forward<Args>(in)...),
AuMakeTuple<AuSPtr<Clazz_t>, Args...>(AU_FWD(owner), std::forward<Args>(in)...),
false);
}
@ -115,7 +115,7 @@ namespace Aurora::Async
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),
Async::JobFromTupleClazzEx<ReturnValue_t, AuSPtr<Clazz_t>, Args...>(success, failure),
std::make_tuple<AuSPtr<Clazz_t>, Args...>(AU_FWD(owner), std::forward<Args>(in)...),
AuMakeTuple<AuSPtr<Clazz_t>, Args...>(AU_FWD(owner), std::forward<Args>(in)...),
false);
}
}

View File

@ -80,8 +80,8 @@ namespace Aurora::Async
private:
static constexpr bool IsCallbackPtr = std::is_pointer_v<Job_t> || AuIsBaseOfTemplate<AURORA_RUNTIME_AU_SHARED_PTR, Job_t>::value || AuIsBaseOfTemplate<AURORA_RUNTIME_AU_UNIQUE_PTR, Job_t>::value;
static constexpr bool IsTaskPtr = std::is_pointer_v<Task_t> || AuIsBaseOfTemplate<AURORA_RUNTIME_AU_SHARED_PTR, Task_t>::value || AuIsBaseOfTemplate<AURORA_RUNTIME_AU_UNIQUE_PTR, Task_t>::value;
static constexpr bool IsCallbackPtr = AuIsPointer_v<Job_t> || AuIsBaseOfTemplate<AURORA_RUNTIME_AU_SHARED_PTR, Job_t>::value || AuIsBaseOfTemplate<AURORA_RUNTIME_AU_UNIQUE_PTR, Job_t>::value;
static constexpr bool IsTaskPtr = AuIsPointer_v<Task_t> || AuIsBaseOfTemplate<AURORA_RUNTIME_AU_SHARED_PTR, Task_t>::value || AuIsBaseOfTemplate<AURORA_RUNTIME_AU_UNIQUE_PTR, Task_t>::value;
//WorkerId_t caller;
WorkerPId_t caller_;

View File

@ -17,13 +17,13 @@ namespace Aurora::Compression
AuUInt32 threads;
/// consume from stream callback
std::function<AuUInt(void *, AuUInt)> inPipe;
AuFunction<AuUInt(void *, AuUInt)> inPipe;
/// write to stream callback
std::function<void(const void *, AuUInt)> writePipe;
AuFunction<void(const void *, AuUInt)> writePipe;
/// preemption and reporting
std::function<bool(AuUInt, AuUInt)> reportProgress;
AuFunction<bool(AuUInt, AuUInt)> reportProgress;
};
AUKN_SYM bool Decompress(const CompressionPipe &stream, const DecompressInfo &meta);

View File

@ -9,52 +9,52 @@
namespace Aurora::Hashing
{
AUKN_SYM void MD5(const void *buffer, AuMach length, std::array<AuUInt8, 16> &md5);
static void MD5(const AuList<AuUInt8> &bytebuffer, std::array<AuUInt8, 16> &md5)
AUKN_SYM void MD5(const void *buffer, AuMach length, AuArray<AuUInt8, 16> &md5);
static void MD5(const AuList<AuUInt8> &bytebuffer, AuArray<AuUInt8, 16> &md5)
{
return MD5(bytebuffer.data(), bytebuffer.size(), md5);
}
static void MD5(const AuString &bytebuffer, std::array<AuUInt8, 16> &md5)
static void MD5(const AuString &bytebuffer, AuArray<AuUInt8, 16> &md5)
{
return MD5(bytebuffer.data(), bytebuffer.size(), md5);
}
AUKN_SYM void SHA1(const void *buffer, AuMach length, std::array<AuUInt8, 20> &sha1);
static void SHA1(const AuList<AuUInt8> &bytebuffer, std::array<AuUInt8, 20> &sha1)
AUKN_SYM void SHA1(const void *buffer, AuMach length, AuArray<AuUInt8, 20> &sha1);
static void SHA1(const AuList<AuUInt8> &bytebuffer, AuArray<AuUInt8, 20> &sha1)
{
return SHA1(bytebuffer.data(), bytebuffer.size(), sha1);
}
static void SHA1(const AuString &bytebuffer, std::array<AuUInt8, 20> &sha1)
static void SHA1(const AuString &bytebuffer, AuArray<AuUInt8, 20> &sha1)
{
return SHA1(bytebuffer.data(), bytebuffer.size(), sha1);
}
AUKN_SYM void Tiger(const void *buffer, AuMach length, std::array<AuUInt8, 24> &tiger);
static void Tiger(const AuList<AuUInt8> &bytebuffer, std::array<AuUInt8, 24> &tiger)
AUKN_SYM void Tiger(const void *buffer, AuMach length, AuArray<AuUInt8, 24> &tiger);
static void Tiger(const AuList<AuUInt8> &bytebuffer, AuArray<AuUInt8, 24> &tiger)
{
return Tiger(bytebuffer.data(), bytebuffer.size(), tiger);
}
static void Tiger(const AuString &bytebuffer, std::array<AuUInt8, 24> &tiger)
static void Tiger(const AuString &bytebuffer, AuArray<AuUInt8, 24> &tiger)
{
return Tiger(bytebuffer.data(), bytebuffer.size(), tiger);
}
AUKN_SYM void SHA2(const void *buffer, AuMach length, std::array<AuUInt8, 32> &sha2);
static void SHA2(const AuList<AuUInt8> &bytebuffer, std::array<AuUInt8, 32> &sha2)
AUKN_SYM void SHA2(const void *buffer, AuMach length, AuArray<AuUInt8, 32> &sha2);
static void SHA2(const AuList<AuUInt8> &bytebuffer, AuArray<AuUInt8, 32> &sha2)
{
return SHA2(bytebuffer.data(), bytebuffer.size(), sha2);
}
static void SHA2(const AuString &bytebuffer, std::array<AuUInt8, 32> &sha2)
static void SHA2(const AuString &bytebuffer, AuArray<AuUInt8, 32> &sha2)
{
return SHA2(bytebuffer.data(), bytebuffer.size(), sha2);
}
AUKN_SYM void SHA2_64(const void *buffer, AuMach length, std::array<AuUInt8, 64> &sha2);
static void SHA2_64(const AuList<AuUInt8> &bytebuffer, std::array<AuUInt8, 64> &sha2)
AUKN_SYM void SHA2_64(const void *buffer, AuMach length, AuArray<AuUInt8, 64> &sha2);
static void SHA2_64(const AuList<AuUInt8> &bytebuffer, AuArray<AuUInt8, 64> &sha2)
{
return SHA2_64(bytebuffer.data(), bytebuffer.size(), sha2);
}
static void SHA2_64(const AuString &bytebuffer, std::array<AuUInt8, 64> &sha2)
static void SHA2_64(const AuString &bytebuffer, AuArray<AuUInt8, 64> &sha2)
{
return SHA2_64(bytebuffer.data(), bytebuffer.size(), sha2);
}

View File

@ -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;
}

View File

@ -25,11 +25,11 @@ namespace Aurora::IO::Buffered
virtual EStreamError Read(const Memory::MemoryViewStreamWrite &paramters) 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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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<AuUInt8 *>(out) + linearOverhead, base, toWriteReadable);
AuMemcpy(reinterpret_cast<AuUInt8 *>(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)

View File

@ -12,7 +12,7 @@ namespace Aurora::Memory
template<typename T>
bool ByteBuffer::Read(T &out)
{
if constexpr (std::is_class_v<T>)
if constexpr (AuIsClass_v<T>)
{
if constexpr (AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, std::remove_reference_t<T>>::value)
{
@ -32,7 +32,7 @@ namespace Aurora::Memory
return !this->flagReadError;
}
else if constexpr (std::is_same_v<std::remove_reference_t<T>, AuString>)
else if constexpr (AuIsSame_v<std::remove_reference_t<T>, AuString>)
{
out.resize(Read<AuUInt32>());
Read(out.data(), out.size());
@ -60,7 +60,7 @@ namespace Aurora::Memory
template<typename T>
bool ByteBuffer::Write(const T &in)
{
if constexpr (std::is_class_v<T>)
if constexpr (AuIsClass_v<T>)
{
if constexpr (AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, std::remove_reference_t<T>>::value)
{
@ -74,7 +74,7 @@ namespace Aurora::Memory
return !this->flagWriteError;
}
else if constexpr (std::is_same_v<std::remove_reference_t<T>, AuString>)
else if constexpr (AuIsSame_v<std::remove_reference_t<T>, AuString>)
{
Write<AuUInt32>(AuUInt32(in.size()));
Write(in.data(), in.size());

View File

@ -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;

View File

@ -106,7 +106,7 @@ namespace Aurora::Memory
return std::shared_ptr<T>(in,
[heapHandle, in, this](T *delt)
{
if constexpr (std::is_class_v<T>)
if constexpr (AuIsClass_v<T>)
{
delt->~T();
}

View File

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

View File

@ -15,7 +15,7 @@ namespace Aurora::Memory
using Void_t = std::conditional_t<Readonly_b, const void *, void *>;
template<typename T, int Z>
using StdArray_t = std::conditional_t<Readonly_b, const std::array<T, Z>, std::array<T, Z>>;
using StdArray_t = std::conditional_t<Readonly_b, const AuArray<T, Z>, AuArray<T, Z>>;
/*
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<T, Void_t>)
if constexpr (AuIsSame_v<T, Void_t>)
{
this->length = reinterpret_cast<const AuUInt8 *>(end) - reinterpret_cast<const AuUInt8 *>(start);
}

View File

@ -9,7 +9,7 @@
namespace Aurora::Parse
{
static AuString SplitNewlines(const AuString &in, std::function<void(const AuString &)> lineCallback, bool returnRemaining)
static AuString SplitNewlines(const AuString &in, AuFunction<void(const AuString &)> lineCallback, bool returnRemaining)
{
AuMach index = 0, startIdx = 0;
@ -42,7 +42,7 @@ namespace Aurora::Parse
}
}
static void SplitNewlines(const AuString &in, std::function<void(const AuString &)> lineCallback)
static void SplitNewlines(const AuString &in, AuFunction<void(const AuString &)> 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));

View File

@ -112,7 +112,7 @@ namespace Aurora::Parse
ParsedObject result;
};
using ConsumeStream_cb = std::function<bool(AuUInt8 &)>;
using ConsumeStream_cb = AuFunction<bool(AuUInt8 &)>;
static ConsumeStream_cb StringToConsumable(const AuString &str, AuMach &index)
{

View File

@ -19,7 +19,7 @@ namespace Aurora::Threading
LockGuard(T &lock)
{
if constexpr (std::is_pointer_v<T>)
if constexpr (AuIsPointer_v<T>)
{
annoying_ = lock;
}
@ -40,7 +40,7 @@ namespace Aurora::Threading
LockGuard(T &&lock)
{
if constexpr (std::is_pointer_v<T>)
if constexpr (AuIsPointer_v<T>)
{
annoying_ = lock;
}
@ -72,7 +72,7 @@ namespace Aurora::Threading
}
private:
std::conditional_t<std::is_pointer_v<T>, T, T*> annoying_;
std::conditional_t<AuIsPointer_v<T>, T, T*> annoying_;
};
#define AU_LOCK_GUARD(variable) Aurora::Threading::LockGuard<decltype(variable)> AU_CONCAT(__stack_lock, __COUNTER__) (variable);

View File

@ -20,7 +20,7 @@ namespace Aurora::Threading
TryLockGuard(T &lock)
{
if constexpr (std::is_pointer_v<T>)
if constexpr (AuIsPointer_v<T>)
{
annoying_ = lock;
}
@ -41,7 +41,7 @@ namespace Aurora::Threading
TryLockGuard(T &&lock)
{
if constexpr (std::is_pointer_v<T>)
if constexpr (AuIsPointer_v<T>)
{
annoying_ = lock;
}
@ -82,7 +82,7 @@ namespace Aurora::Threading
return bLockSuccessful;
}
private:
std::conditional_t<std::is_pointer_v<T>, T, T*> annoying_;
std::conditional_t<AuIsPointer_v<T>, T, T*> annoying_;
};

View File

@ -67,7 +67,7 @@ namespace Aurora::Threading::Threads
sizeof(T),
[](void *buffer) -> void
{
if constexpr (std::is_class_v<T>)
if constexpr (AuIsClass_v<T>)
{
new (buffer) T();
}
@ -78,7 +78,7 @@ namespace Aurora::Threading::Threads
},
[](void *buffer) -> void
{
if constexpr (std::is_class_v<T>)
if constexpr (AuIsClass_v<T>)
{
reinterpret_cast<T *>(buffer)->~T();
}

View File

@ -17,7 +17,7 @@ namespace Aurora::Threading::Threads
class TLSView
{
public:
using TlsCb = std::function<void(void *)>;
using TlsCb = AuFunction<void(void *)>;
virtual void Remove(AuUInt64 key) = 0;
virtual void *GetTLS(AuUInt64 key, AuMach length, bool noAutoCreate = false) = 0;

View File

@ -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));
}

View File

@ -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); // ?
}
}
}

View File

@ -22,6 +22,68 @@
#endif
#endif
template<bool v>
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<false>;
using AuTrueType = AuBoolType<true>;
template<class T, class U>
struct AuIsSame : AuFalseType
{};
template<class T>
struct AuIsSame<T, T> : AuTrueType
{};
template< class T, class U >
inline constexpr bool AuIsSame_v = AuIsSame<T, U>::value;
namespace _audetail {
template <class T>
AuBoolType<!std::is_union<T>::value> test(int T:: *);
template <class>
AuFalseType test(...);
}
template<class T>
struct AuIsClass : decltype(_audetail::test<T>(nullptr))
{};
template<class T>
inline constexpr bool AuIsClass_v = AuIsClass<T>::value;
template <class>
inline constexpr bool AuIsPointer_v = false;
template <class _Ty>
inline constexpr bool AuIsPointer_v<_Ty *> = true;
template <class _Ty>
inline constexpr bool AuIsPointer_v<_Ty *const> = true;
template <class _Ty>
inline constexpr bool AuIsPointer_v<_Ty *volatile> = true;
template <class _Ty>
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<typename T>
using AuList = typename std::conditional<std::is_class<T>::value, AURORA_RUNTIME_AU_LIST<T>, AURORA_RUNTIME_AU_LIST<T, Aurora::Memory::SpeedyArrayAllocator<T>>>::type;
using AuList = typename std::conditional<AuIsClass_v<T>, AURORA_RUNTIME_AU_LIST<T>, AURORA_RUNTIME_AU_LIST<T, Aurora::Memory::SpeedyArrayAllocator<T>>>::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<T, Deleter_t>;
template<typename A_t, typename B_t>
using AuPair = AURORA_RUNTIME_AU_PAIR<A_t, B_t>;
#if !defined(AURORA_RUNTIME_AU_TUPLE)
#define AURORA_RUNTIME_AU_TUPLE std::tuple
#endif
template<class... Types>
using AuTuple = AURORA_RUNTIME_AU_TUPLE<Types...>;
#if defined(AURORA_COMPILER_MSVC)
using AuAtomicInt = long;
#else

View File

@ -34,12 +34,101 @@ static auline auto AuMakePair(Args&&... args)
return AURORA_RUNTIME_MAKE_PAIR(std::forward<Args>(args)...);
}
#if !defined(AURORA_RUNTIME_MAKE_TUPLE)
#define AURORA_RUNTIME_MAKE_TUPLE std::make_tuple
#endif
template<typename... Args>
static auline auto AuMakeTuple(Args&&... args)
{
return AURORA_RUNTIME_MAKE_TUPLE(std::forward<Args>(args)...);
}
#if !defined(AURORA_RUNTIME_TO_STRING)
#define AURORA_RUNTIME_TO_STRING std::to_string
#endif
template<class T>
AuString AuToString(const T &obj)
{
return AURORA_RUNTIME_TO_STRING(obj);
}
#if !defined(AURORA_RUNTIME_EXCHANGE)
#define AURORA_RUNTIME_EXCHANGE std::exchange
#endif
template<class T, class U = T>
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<typename Map, class Key>
static auline bool AuTryFindGeneric(Map &map, const Key &key)
{
if (map.find(key) != map.end())
{
return true;
}
else
{
return false;
}
}
template<typename Map, class Key>
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<T, Aurora::Memory::ByteBuffer>)
if constexpr (AuIsSame_v<T, Aurora::Memory::ByteBuffer>)
{
return list.Resize(length);
}
@ -491,7 +593,7 @@ static auline bool AuTryDownsize(T &list, AuUInt length)
{
try
{
if constexpr (std::is_same_v<T, Aurora::Memory::ByteBuffer>)
if constexpr (AuIsSame_v<T, Aurora::Memory::ByteBuffer>)
{
return list.Resize(length);
}
@ -649,31 +751,31 @@ static auline T AuReadGenericLE(const void *ptr, int offset)
return *reinterpret_cast<const T *>(reinterpret_cast<const AuUInt8 *>(ptr) + offset);
#else
T temp;
std::memcpy(&temp, reinterpret_cast<const AuUInt8 *>(ptr) + offset, sizeof(temp));
AuMemcpy(&temp, reinterpret_cast<const AuUInt8 *>(ptr) + offset, sizeof(temp));
#if !defined(AU_CPU_ENDIAN_LITTLE)
#if defined(AURORA_COMPILER_MSVC)
if constexpr (std::is_same_v<T, AuUInt32> || std::is_same_v<T, AuInt32>)
if constexpr (AuIsSame_v<T, AuUInt32> || AuIsSame_v<T, AuInt32>)
{
temp = _byteswap_ulong(temp);
}
else if constexpr (std::is_same_v<T, AuUInt64> || std::is_same_v<T, AuInt64>)
else if constexpr (AuIsSame_v<T, AuUInt64> || AuIsSame_v<T, AuInt64>)
{
temp = _byteswap_uint64(temp);
}
else if constexpr (std::is_same_v<T, AuUInt16> || std::is_same_v<T, AuInt16>)
else if constexpr (AuIsSame_v<T, AuUInt16> || AuIsSame_v<T, AuInt16>)
{
temp = _byteswap_ushort(temp);
}
#else
if constexpr (std::is_same_v<T, AuUInt32> || std::is_same_v<T, AuInt32>)
if constexpr (AuIsSame_v<T, AuUInt32> || AuIsSame_v<T, AuInt32>)
{
temp = __builtin_bswap32(temp);
}
else if constexpr (std::is_same_v<T, AuUInt64> || std::is_same_v<T, AuInt64>)
else if constexpr (AuIsSame_v<T, AuUInt64> || AuIsSame_v<T, AuInt64>)
{
temp = __builtin_bswap64(temp);
}
else if constexpr (std::is_same_v<T, AuUInt16> || std::is_same_v<T, AuInt16>)
else if constexpr (AuIsSame_v<T, AuUInt16> || AuIsSame_v<T, AuInt16>)
{
temp = (temp << 8) | ((temp >> 8) & 0xFF);
}
@ -690,31 +792,31 @@ static auline T AuReadGenericBE(const void *ptr, int offset)
return *reinterpret_cast<const T *>(reinterpret_cast<const AuUInt8 *>(ptr) + offset);
#else
T temp;
std::memcpy(&temp, reinterpret_cast<const AuUInt8 *>(ptr) + offset, sizeof(temp));
AuMemcpy(&temp, reinterpret_cast<const AuUInt8 *>(ptr) + offset, sizeof(temp));
#if defined(AU_CPU_ENDIAN_LITTLE)
#if defined(AURORA_COMPILER_MSVC)
if constexpr (std::is_same_v<T, AuUInt32> || std::is_same_v<T, AuInt32>)
if constexpr (AuIsSame_v<T, AuUInt32> || AuIsSame_v<T, AuInt32>)
{
temp = _byteswap_ulong(temp);
}
else if constexpr (std::is_same_v<T, AuUInt64> || std::is_same_v<T, AuInt64>)
else if constexpr (AuIsSame_v<T, AuUInt64> || AuIsSame_v<T, AuInt64>)
{
temp = _byteswap_uint64(temp);
}
else if constexpr (std::is_same_v<T, AuUInt16> || std::is_same_v<T, AuInt16>)
else if constexpr (AuIsSame_v<T, AuUInt16> || AuIsSame_v<T, AuInt16>)
{
temp = _byteswap_ushort(temp);
}
#else
if constexpr (std::is_same_v<T, AuUInt32> || std::is_same_v<T, AuInt32>)
if constexpr (AuIsSame_v<T, AuUInt32> || AuIsSame_v<T, AuInt32>)
{
temp = __builtin_bswap32(temp);
}
else if constexpr (std::is_same_v<T, AuUInt64> || std::is_same_v<T, AuInt64>)
else if constexpr (AuIsSame_v<T, AuUInt64> || AuIsSame_v<T, AuInt64>)
{
temp = __builtin_bswap64(temp);
}
else if constexpr (std::is_same_v<T, AuUInt16> || std::is_same_v<T, AuInt16>)
else if constexpr (AuIsSame_v<T, AuUInt16> || AuIsSame_v<T, AuInt16>)
{
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<T, AuUInt32> || std::is_same_v<T, AuInt32>)
if constexpr (AuIsSame_v<T, AuUInt32> || AuIsSame_v<T, AuInt32>)
{
temp = _byteswap_ulong(temp);
}
else if constexpr (std::is_same_v<T, AuUInt64> || std::is_same_v<T, AuInt64>)
else if constexpr (AuIsSame_v<T, AuUInt64> || AuIsSame_v<T, AuInt64>)
{
temp = _byteswap_uint64(temp);
}
else if constexpr (std::is_same_v<T, AuUInt16> || std::is_same_v<T, AuInt16>)
else if constexpr (AuIsSame_v<T, AuUInt16> || AuIsSame_v<T, AuInt16>)
{
temp = _byteswap_ushort(temp);
}
#else
if constexpr (std::is_same_v<T, AuUInt32> || std::is_same_v<T, AuInt32>)
if constexpr (AuIsSame_v<T, AuUInt32> || AuIsSame_v<T, AuInt32>)
{
temp = __builtin_bswap32(temp);
}
else if constexpr (std::is_same_v<T, AuUInt64> || std::is_same_v<T, AuInt64>)
else if constexpr (AuIsSame_v<T, AuUInt64> || AuIsSame_v<T, AuInt64>)
{
temp = __builtin_bswap64(temp);
}
else if constexpr (std::is_same_v<T, AuUInt16> || std::is_same_v<T, AuInt16>)
else if constexpr (AuIsSame_v<T, AuUInt16> || AuIsSame_v<T, AuInt16>)
{
temp = (temp << 8) | ((temp >> 8) & 0xFF);
}
#endif
#endif
std::memcpy(reinterpret_cast<AuUInt8 *>(ptr) + offset, &temp, sizeof(temp));
AuMemcpy(reinterpret_cast<AuUInt8 *>(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<T, AuUInt32> || std::is_same_v<T, AuInt32>)
if constexpr (AuIsSame_v<T, AuUInt32> || AuIsSame_v<T, AuInt32>)
{
temp = _byteswap_ulong(temp);
}
else if constexpr (std::is_same_v<T, AuUInt64> || std::is_same_v<T, AuInt64>)
else if constexpr (AuIsSame_v<T, AuUInt64> || AuIsSame_v<T, AuInt64>)
{
temp = _byteswap_uint64(temp);
}
else if constexpr (std::is_same_v<T, AuUInt16> || std::is_same_v<T, AuInt16>)
else if constexpr (AuIsSame_v<T, AuUInt16> || AuIsSame_v<T, AuInt16>)
{
temp = _byteswap_ushort(temp);
}
#else
if constexpr (std::is_same_v<T, AuUInt32> || std::is_same_v<T, AuInt32>)
if constexpr (AuIsSame_v<T, AuUInt32> || AuIsSame_v<T, AuInt32>)
{
temp = __builtin_bswap32(temp);
}
else if constexpr (std::is_same_v<T, AuUInt64> || std::is_same_v<T, AuInt64>)
else if constexpr (AuIsSame_v<T, AuUInt64> || AuIsSame_v<T, AuInt64>)
{
temp = __builtin_bswap64(temp);
}
else if constexpr (std::is_same_v<T, AuUInt16> || std::is_same_v<T, AuInt16>)
else if constexpr (AuIsSame_v<T, AuUInt16> || AuIsSame_v<T, AuInt16>)
{
temp = (temp << 8) | ((temp >> 8) & 0xFF);
}
#endif
#endif
std::memcpy(reinterpret_cast<AuUInt8 *>(ptr) + offset, &temp, sizeof(temp));
AuMemcpy(reinterpret_cast<AuUInt8 *>(ptr) + offset, &temp, sizeof(temp));
#endif
}

View File

@ -22,20 +22,20 @@ namespace Aurora::Async
{
public:
std::function<void()> callback;
std::function<void()> fail;
AuFunction<void()> callback;
AuFunction<void()> fail;
AuThreadPrimitives::SpinLock lock;
AsyncFuncRunnable(std::function<void()> &&callback) : callback(std::move(callback))
AsyncFuncRunnable(AuFunction<void()> &&callback) : callback(std::move(callback))
{}
AsyncFuncRunnable(std::function<void()> &&callback, std::function<void()> &&fail) : callback(std::move(callback)), fail(std::move(fail))
AsyncFuncRunnable(AuFunction<void()> &&callback, AuFunction<void()> &&fail) : callback(std::move(callback)), fail(std::move(fail))
{}
AsyncFuncRunnable(const std::function<void()> &callback) : callback(callback)
AsyncFuncRunnable(const AuFunction<void()> &callback) : callback(callback)
{}
AsyncFuncRunnable(const std::function<void()> &callback, const std::function<void()> &fail) : callback(callback), fail(fail)
AsyncFuncRunnable(const AuFunction<void()> &callback, const AuFunction<void()> &fail) : callback(callback), fail(fail)
{}
void RunAsync() override

View File

@ -96,7 +96,7 @@ namespace Aurora::Async
{
try
{
if (!std::exchange(gLockedPump, true))
if (!AuExchange(gLockedPump, true))
{
NewWorkItem(AuWorkerId_t{0, 0}, AuMakeShared<BasicWorkStdFunc>(PumpSysThread))->Dispatch();
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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)

View File

@ -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);

View File

@ -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();

View File

@ -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) ||

View File

@ -10,7 +10,7 @@
namespace Aurora::Console
{
static std::array<std::string, static_cast<size_t>(EAnsiColor::eCount)> kAnsiCheats
static AuArray<std::string, static_cast<size_t>(EAnsiColor::eCount)> kAnsiCheats
{
"\033[0;31m",
"\033[1;31m",

View File

@ -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;

View File

@ -53,7 +53,7 @@ public:
private:
DECLARE_EVENT_TABLE()
std::optional<wxColor> _color;
AuOptional<wxColor> _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<const wxColour, static_cast<size_t>(Aurora::Console::EAnsiColor::eCount)> ColorMap
static AuArray<const wxColour, static_cast<size_t>(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<bool, static_cast<size_t>(Aurora::Console::EAnsiColor::eCount)> HahaBald
static AuArray<bool, static_cast<size_t>(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<Console::ConsoleMessage> lines;
{
AU_LOCK_GUARD(gMutex);
lines = std::exchange(gPendingLines, {});
lines = AuExchange(gPendingLines, {});
}
for (const auto& line : lines)

View File

@ -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)

View File

@ -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);

View File

@ -126,7 +126,7 @@ namespace Aurora::Crypto::ECC
return true;
}
std::optional<IECCPrivate *> GenerateNewGenericECC(EECCCurve curve)
AuOptional<IECCPrivate *> GenerateNewGenericECC(EECCCurve curve)
{
ecc_key key = {};
const int prng_idx = register_prng(&sprng_desc);

View File

@ -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<unsigned long>(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<IECCPrivate *> GenerateNewGenericECC(EECCCurve curve);
AuOptional<IECCPrivate *> GenerateNewGenericECC(EECCCurve curve);
}

View File

@ -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<void(mbedtls_x509_buf &ex, unsigned char **, unsigned char *)> cb);
static int x509_get_crt_ext(mbedtls_x509_crt *crt, const char *oid, int oidLength, AuFunction<void(mbedtls_x509_buf &ex, unsigned char **, unsigned char *)> cb);
static int x509_get_ca_id(mbedtls_x509_crt *crt, AuList<AuUInt8> &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<void(mbedtls_x509_crt &crt)> cb)
static bool ParseCert(const Certificate &der, AuFunction<void(mbedtls_x509_crt &crt)> cb)
{
bool ret = false;
mbedtls_x509_crt crt {};

View File

@ -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

View File

@ -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();
}

View File

@ -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<CPUIdContext> data;
std::vector<CPUIdContext> extdata;
AuList<CPUIdContext> data;
AuList<CPUIdContext> extdata;
auto cpuInfo = cpuid(0);
auto nIds = cpuInfo.eax;

View File

@ -11,7 +11,7 @@
namespace Aurora::Hashing
{
AUKN_SYM void MD5(const void *buffer, AuMach length, std::array<AuUInt8, 16> &md5)
AUKN_SYM void MD5(const void *buffer, AuMach length, AuArray<AuUInt8, 16> &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<AuUInt8, 20> &sha1)
AUKN_SYM void SHA1(const void *buffer, AuMach length, AuArray<AuUInt8, 20> &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<AuUInt8, 24> &tiger)
AUKN_SYM void Tiger(const void *buffer, AuMach length, AuArray<AuUInt8, 24> &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<AuUInt8, 32> &sha2)
AUKN_SYM void SHA2(const void *buffer, AuMach length, AuArray<AuUInt8, 32> &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<AuUInt8, 64> &sha2)
AUKN_SYM void SHA2_64(const void *buffer, AuMach length, AuArray<AuUInt8, 64> &sha2)
{
hash_state md;
sha512_init(&md);

View File

@ -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<unsigned char *>(buffer_));
}
return buffer_;
case EHashType::eSHA1:
length = 20;
if (!std::exchange(finished_, true))
if (!AuExchange(finished_, true))
{
sha1_done(&state_, reinterpret_cast<unsigned char *>(buffer_));
}
return buffer_;
case EHashType::eSHA2_32:
length = 32;
if (!std::exchange(finished_, true))
if (!AuExchange(finished_, true))
{
sha256_done(&state_, reinterpret_cast<unsigned char *>(buffer_));
}
return buffer_;
case EHashType::eSHA2_64:
length = 64;
if (!std::exchange(finished_, true))
if (!AuExchange(finished_, true))
{
sha512_done(&state_, reinterpret_cast<unsigned char *>(buffer_));
}
return buffer_;
case EHashType::eTiger:
length = 24;
if (!std::exchange(finished_, true))
if (!AuExchange(finished_, true))
{
tiger_done(&state_, reinterpret_cast<unsigned char *>(buffer_));
}

View File

@ -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_)
{

View File

@ -70,7 +70,7 @@ namespace Aurora::IO::FS
{
DWORD written;
int blockSize = std::min(static_cast<AuUInt64>(kFileCopyBlock), static_cast<AuUInt64>(length));
int blockSize = AuMin(static_cast<AuUInt64>(kFileCopyBlock), static_cast<AuUInt64>(length));
if (!::WriteFile(fileHandle, &reinterpret_cast<const char *>(data)[offset], blockSize, &written, NULL))
{
@ -129,7 +129,7 @@ namespace Aurora::IO::FS
{
DWORD read;
int blockSize = std::min(static_cast<AuUInt64>(kFileCopyBlock), static_cast<AuUInt64>(length.QuadPart));
int blockSize = AuMin(static_cast<AuUInt64>(kFileCopyBlock), static_cast<AuUInt64>(length.QuadPart));
if (!::ReadFile(fileHandle, &buffer[offset], blockSize, &read, NULL))
{

View File

@ -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<char *>(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<const char *>(parameters.ptr) + offset, blockSize, &written, NULL))
{

View File

@ -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;

View File

@ -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

View File

@ -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<AuUInt8> 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<AuUInt8> rw(reinterpret_cast<const AuUInt8 *>(binary), reinterpret_cast<const AuUInt8 *>(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<AuUInt8> rw(reinterpret_cast<const AuUInt8 *>(binary), reinterpret_cast<const AuUInt8 *>(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;

View File

@ -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};
}

View File

@ -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)
{

View File

@ -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<AuString, AuString> &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);
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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<size_t Z>
static std::function<bool(AuUInt8)> ContainedHerein(const AuUInt8(&arry)[Z])
static AuFunction<bool(AuUInt8)> ContainedHerein(const AuUInt8(&arry)[Z])
{
return [=](AuUInt8 c) -> bool
{
@ -67,7 +67,7 @@ namespace Aurora::Parse
template<size_t Z>
static std::function<bool(AuUInt8)> IsTerminating(ParseState &state, const AuUInt8(&arry)[Z])
static AuFunction<bool(AuUInt8)> 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<AuUInt>(*itr) - static_cast<AuUInt>('0');
if constexpr (std::is_same<T, AuUInt>::value)
if constexpr (AuIsSame_v<T, AuUInt>)
{
if (old > res)
{
@ -269,7 +269,7 @@ namespace Aurora::Parse
return false;
}
}
else if constexpr (std::is_same<T, AuSInt>::value)
else if constexpr (AuIsSame_v<T, AuSInt>)
{
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;

View File

@ -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())
{

View File

@ -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);

View File

@ -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();

View File

@ -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;
}

View File

@ -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<void()> task)
bool OSThread::ExecuteNewOSContext(AuFunction<void()> 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<void()> callback)
void OSThread::ExecuteInDeadThread(AuFunction<void()> 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_);
}

View File

@ -32,7 +32,7 @@ namespace Aurora::Threading::Threads
AuSPtr<TLSView> GetTlsView() override;
void ExecuteInDeadThread(std::function<void()> callback) override;
void ExecuteInDeadThread(AuFunction<void()> callback) override;
AuSPtr<IWaitable> AsWaitable() override;
void AddLastHopeTlsHook(const AuSPtr<Threading::Threads::IThreadFeature> &feature) override;
@ -46,7 +46,7 @@ namespace Aurora::Threading::Threads
protected:
bool Exit(bool willReturnToOS);
bool ExecuteNewOSContext(std::function<void()> task);
bool ExecuteNewOSContext(AuFunction<void()> task);
void UpdatePrio(EThreadPrio prio);
void UpdateAffinity(AuUInt32 mask);
void UpdateName();
@ -79,7 +79,7 @@ namespace Aurora::Threading::Threads
AuList<AuSPtr<IThreadFeature>> threadFeatures_;
std::function<void()> task_;
AuFunction<void()> task_;
#if defined(AURORA_IS_MODERNNT_DERIVED)
HANDLE handle_ = INVALID_HANDLE_VALUE;

View File

@ -22,7 +22,7 @@ namespace Aurora::Threading::Threads
void ConsiderRehash();
Primitives::SpinLock lock_;
AuHashMap<AuUInt64, std::pair<void*, TlsCb>> tls_;
AuHashMap<AuUInt64, AuPair<void*, TlsCb>> tls_;
AuUInt64 fence_ = 0;
};
}

View File

@ -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