[*] House cleaning, refactoring, clean up

This commit is contained in:
Reece Wilson 2021-10-23 20:21:16 +01:00
parent 1c9fd1a59d
commit 39834cef6a
9 changed files with 46 additions and 37 deletions

View File

@ -17,11 +17,11 @@ namespace Aurora::Async
namespace Aurora::Console::Commands
{
AUKN_INTERFACE(ICommandSubscriber,
AUI_METHOD(void, onCommand, (const Parse::ParsedObject &, parseList))
AUI_METHOD(void, OnCommand, (const Parse::ParsedObject &, parseList))
);
AUKN_INTERFACE(ITextLineSubscriber,
AUI_METHOD(void, onProcessedLineUTF8, (const AuString &, line))
AUI_METHOD(void, OnProcessedLineUTF8, (const AuString &, line))
);
AUKN_SYM void AddCommand(const AuString &tag, const Parse::ParseObject &commandStructure, const AuSPtr<ICommandSubscriber> &subscriber);

View File

@ -7,8 +7,6 @@
***/
#pragma once
//#include <Aurora/Time/Time.hpp>
namespace Aurora::Threading::Threads
{
AUKN_SYM AuThreadId_t GetThreadId();
@ -21,7 +19,7 @@ namespace Aurora::Time
namespace Aurora::Console
{
class ConsoleMessage
class ConsoleMessage
{
public:
EAnsiColor color;
@ -33,6 +31,8 @@ namespace Aurora::Console
inline ConsoleMessage()
{
color = EAnsiColor::eReset;
tid = 0;
time = 0;
}
inline ConsoleMessage(const AuString &prefix, const AuString &line) : prefix(prefix), line(line), color(EAnsiColor::eReset)

View File

@ -11,61 +11,61 @@ namespace Aurora::Console::Logging
{
#if defined(_AUHAS_FMT)
template<typename ... T>
static inline void WriteLinef(const AuString &tag, const AuString &msg, T... args)
static inline void WriteLinef(const AuString &tag, const AuString &msg, T&& ... args)
{
Aurora::Console::WriteLine(ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, args...)));
WriteLine(ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, std::forward<T>(args)...)));
}
template<typename ... T>
static inline void WriteLinef(EAnsiColor color, const AuString &tag, const AuString &msg, T... args)
static inline void WriteLinef(EAnsiColor color, const AuString &tag, const AuString &msg, T&& ... args)
{
Aurora::Console::WriteLine(ConsoleMessage(color, tag, fmt::format(msg, args...)));
WriteLine(ConsoleMessage(color, tag, fmt::format(msg, std::forward<T>(args)...)));
}
template<typename ... T>
static inline void LogVerbose(const AuString &line, T... args)
static inline void LogVerbose(const AuString &line, T&& ... args)
{
Aurora::Console::Logging::WriteLinef(EAnsiColor::eYellow, "Verbose", line, args...);
WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
}
#if defined(STAGING) || defined(DEBUG)
template<typename ... T>
static inline void LogVerboseNoShip(const AuString &line, T... args)
static inline void LogVerboseNoShip(const AuString &line, T&& ... args)
{
Aurora::Console::Logging::WriteLinef(EAnsiColor::eYellow, "Verbose", line, args...);
WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
}
#else
#define LogVerboseNoShip(...)
#endif
template<typename ... T>
static inline void LogInfo(const AuString &line, T... args)
static inline void LogInfo(const AuString &line, T&& ... args)
{
Aurora::Console::Logging::WriteLinef(EAnsiColor::eGreen, "Info", line, args...);
WriteLinef(EAnsiColor::eGreen, "Info", line, std::forward<T>(args)...);
}
template<typename ... T>
static inline void LogDbg(const AuString &line, T... args)
static inline void LogDbg(const AuString &line, T&& ... args)
{
Aurora::Console::Logging::WriteLinef(EAnsiColor::eYellow, "Debug", line, args...);
WriteLinef(EAnsiColor::eYellow, "Debug", line, std::forward<T>(args)...);
}
template<typename ... T>
static inline void LogWarn(const AuString &line, T... args)
static inline void LogWarn(const AuString &line, T&& ... args)
{
Aurora::Console::Logging::WriteLinef(EAnsiColor::eRed, "Warn", line, args...);
WriteLinef(EAnsiColor::eRed, "Warn", line, std::forward<T>(args)...);
}
template<typename ... T>
static inline void LogError(const AuString &line, T... args)
static inline void LogError(const AuString &line, T&& ... args)
{
Aurora::Console::Logging::WriteLinef(EAnsiColor::eBoldRed, "Error", line, args...);
WriteLinef(EAnsiColor::eBoldRed, "Error", line, std::forward<T>(args)...);
}
template<typename ... T>
static inline void LogGame(const AuString &line, T... args)
static inline void LogGame(const AuString &line, T&& ... args)
{
Aurora::Console::Logging::WriteLinef(EAnsiColor::eBlue, "Game", line, args...);
WriteLinef(EAnsiColor::eBlue, "Game", line, std::forward<T>(args)...);
}
#endif
}

View File

@ -23,7 +23,7 @@ namespace Aurora::Debug
#pragma optimize("", off)
#define _FREECOMPILER_OPTIMIZE_OFF
#elif defined(AURORA_COMPILER_CLANG)
#define _FREECOMPILER_OPTIMIZE_OFF __attribute__((optnone))
#define _FREECOMPILER_OPTIMIZE_OFF __attribute__((optnone))
#else
#define _FREECOMPILER_OPTIMIZE_OFF __attribute__((optimize("0")))
#endif
@ -34,13 +34,17 @@ namespace Aurora::Debug
}
template<typename ... T>
static AU_NOINLINE void ErrorMakeNested(const AuString &msg, T... args) _FREECOMPILER_OPTIMIZE_OFF
static AU_NOINLINE void ErrorMakeNested(const AuString &msg, T&& ... args) _FREECOMPILER_OPTIMIZE_OFF
{
_PushError(_DBG_RET_ADDR, FailureCategory::kFailureNested, fmt::format(msg, args...).c_str());
#if defined(_AUHAS_FMT)
_PushError(_DBG_RET_ADDR, FailureCategory::kFailureNested, fmt::format(msg, std::forward<T>(args)...).c_str());
#else
_PushError(_DBG_RET_ADDR, FailureCategory::kFailureNested, nullptr);
#endif
}
template<typename ... T>
static AU_NOINLINE void SysPushError(FailureCategory category, const AuString &msg, T... args) _FREECOMPILER_OPTIMIZE_OFF
static AU_NOINLINE void SysPushError(FailureCategory category, const AuString &msg, T&& ... args) _FREECOMPILER_OPTIMIZE_OFF
{
if constexpr (sizeof...(T) == 0)
{
@ -49,7 +53,7 @@ namespace Aurora::Debug
else
{
#if defined(_AUHAS_FMT)
_PushError(_DBG_RET_ADDR, category, fmt::format(msg, args...).c_str());
_PushError(_DBG_RET_ADDR, category, fmt::format(msg, std::forward<T>(args)...).c_str());
#else
_PushError(_DBG_RET_ADDR, category, "Missing dependency");
#endif
@ -64,6 +68,7 @@ namespace Aurora::Debug
#if defined(AURORA_COMPILER_MSVC)
#pragma optimize("", on)
#endif
#undef _FREECOMPILER_OPTIMIZE_OFF
}
#define SysCheckReturn(x, ...) if (!(static_cast<bool>(x))) { Aurora::Debug::ErrorMakeNested(); return __VA_ARGS__; }

View File

@ -26,7 +26,7 @@ namespace Aurora::IO::FS
class IAsyncTransaction
{
public:
// Do not switch to Aurora::Memory::MemoryView, you must use a raw pointer to the parent RAII object that effectively owns the IAsyncTransaction
// Do not switch to Aurora::Memory::MemoryView, you must use a raw pointer to the parent object that effectively owns the IAsyncTransaction
virtual bool StartRead(AuUInt64 offset, void *, AuUInt32 length) = 0;
virtual bool StartWrite(AuUInt64 offset, const void *, AuUInt32 length) = 0;

View File

@ -19,10 +19,13 @@ namespace Aurora::IO
EStreamError ReadAll(AuList<AuUInt8> &buffer)
{
static const int kBufferSize = 2048;
AuUInt len;
EStreamError ret;
AuUInt8 temp[kBufferSize];
AuUInt len = kBufferSize;
EStreamError ret = EStreamError::eErrorEndOfStream;
len = kBufferSize;
ret = EStreamError::eErrorEndOfStream;
while ((ret = Read(Memory::MemoryViewStreamWrite(temp, len))) == EStreamError::eErrorNone)
{

View File

@ -13,7 +13,7 @@ namespace Aurora::IO
{
public:
virtual EStreamError Open() = 0;
virtual EStreamError Write(const Memory::MemoryViewStreamRead & parameters) = 0;
virtual EStreamError Write(const Memory::MemoryViewStreamRead &parameters) = 0;
virtual void Flush() = 0;
virtual void Close() = 0;
};

View File

@ -19,6 +19,7 @@
#include "../AuroraMacros.hpp"
#include <utilitY>
#include <memory>
#include <optional>
#include <functional>

View File

@ -101,14 +101,14 @@ namespace Aurora::Console::Commands
if (type == EDispatchType::eNow)
{
callback->onCommand(res.result);
callback->OnCommand(res.result);
}
else
{
Async::DispatchBasicWorkCallback<CommandDispatch>(workerId,
Async::TaskFromConsumerRefT<CommandDispatch>([](const CommandDispatch &dispatch) -> void
{
dispatch.callback->onCommand(dispatch.arguments);
dispatch.callback->OnCommand(dispatch.arguments);
}),
{},
CommandDispatch(res.result, callback),
@ -146,7 +146,7 @@ namespace Aurora::Console::Commands
{
if (gExternalLineProcessor)
{
gExternalLineProcessor->onProcessedLineUTF8(string);
gExternalLineProcessor->OnProcessedLineUTF8(string);
return true;
}
@ -169,7 +169,7 @@ namespace Aurora::Console::Commands
auto commands = std::exchange(gPendingCommands, {});
for (const auto &command : commands)
{
command.callback->onCommand(command.arguments);
command.callback->OnCommand(command.arguments);
}
}
@ -180,7 +180,7 @@ namespace Aurora::Console::Commands
{
for (const auto &command : commands)
{
command.callback->onCommand(command.arguments);
command.callback->OnCommand(command.arguments);
}
}