Skip to content

Commit

Permalink
adding WindowInstance and MacOSInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
Kbz-8 committed Feb 4, 2024
1 parent 63009a2 commit ad06f63
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 43 deletions.
3 changes: 2 additions & 1 deletion Akel/Runtime/Includes/Core/CompilationProfile.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is a part of Akel
// Authors : @kbz_8
// Created : 31/01/2024
// Updated : 02/02/2024
// Updated : 04/02/2024

#ifndef __AK_CORE_COMPILATION_PROFILE__
#define __AK_CORE_COMPILATION_PROFILE__
Expand Down Expand Up @@ -38,6 +38,7 @@
#define AK_PLAT_WINDOWS
#elif defined(__linux__)
#define AK_PLAT_LINUX
#define AK_PLAT_UNIX
#elif defined(__APPLE__) && defined(__MACH__)
#define AK_PLAT_MACOS
#elif defined(unix) || defined(__unix__) || defined(__unix)
Expand Down
29 changes: 16 additions & 13 deletions Akel/Runtime/Includes/Core/Logs.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is a part of Akel
// Authors : @kbz_8
// Created : 31/01/2024
// Updated : 02/02/2024
// Updated : 04/02/2024

#ifndef __AK_CORE_LOGS__
#define __AK_CORE_LOGS__
Expand All @@ -12,19 +12,19 @@
namespace Ak
{
template<typename... Args>
void Debug(std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args);
void Debug(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args);

template<typename... Args>
void Error(std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args);
void Error(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args);

template<typename... Args>
void Warning(std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args);
void Warning(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args);

template<typename... Args>
void Message(std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args);
void Message(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args);

template<typename... Args>
void FatalError(std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args);
void FatalError(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args);

class AK_CORE_API Logs
{
Expand All @@ -39,10 +39,10 @@ namespace Ak

#if defined(AK_CORE_DEBUG) || defined(AK_FORCE_ENABLE_ASSERTS)
template<typename... Args>
void Assert(bool cond, std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args);
void Assert(bool cond, unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args);
#else
template<typename... Args>
void Assert(bool cond, std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args) {}
void Assert(bool cond, unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args) {}
#endif
}

Expand All @@ -51,19 +51,22 @@ namespace Ak
namespace Ak
{
#undef Debug
#define Debug(msg, ...) Debug(msg, __LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)
#define Debug(...) Debug(__LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)

#undef Message
#define Message(msg, ...) Message(msg, __LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)
#define Message(...) Message(__LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)

#undef Warning
#define Warning(msg, ...) Warning(msg, __LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)
#define Warning(...) Warning(__LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)

#undef Error
#define Error(msg, ...) Error(msg, __LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)
#define Error(...) Error(__LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)

#undef FatalError
#define FatalError(msg, ...) FatalError(msg, __LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)
#define FatalError(...) FatalError(__LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)

#undef Assert
#define Assert(cond, ...) Assert(cond, __LINE__ - 1, __FILE__, AK_FUNC_SIG, __VA_ARGS__)
}

#endif
14 changes: 7 additions & 7 deletions Akel/Runtime/Includes/Core/Logs.inl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// This file is a part of Akel
// Authors : @kbz_8
// Created : 01/02/2024
// Updated : 02/02/2024
// Updated : 04/02/2024

#include <Core/Format.h>

namespace Ak
{
template<typename... Args>
void Debug(std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args)
void Debug(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
{
using namespace std::literals;
try
Expand All @@ -24,7 +24,7 @@ namespace Ak
}

template<typename... Args>
void Error(std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args)
void Error(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
{
using namespace std::literals;
try
Expand All @@ -40,7 +40,7 @@ namespace Ak
}

template<typename... Args>
void Warning(std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args)
void Warning(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
{
using namespace std::literals;
try
Expand All @@ -56,7 +56,7 @@ namespace Ak
}

template<typename... Args>
void Message(std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args)
void Message(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
{
using namespace std::literals;
try
Expand All @@ -72,7 +72,7 @@ namespace Ak
}

template<typename... Args>
void FatalError(std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args)
void FatalError(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
{
using namespace std::literals;
try
Expand All @@ -89,7 +89,7 @@ namespace Ak

#if defined(AK_CORE_DEBUG) || defined(AK_FORCE_ENABLE_ASSERTS)
template<typename... Args>
void Assert(bool cond, std::string message, unsigned int line, std::string_view file, std::string_view function, const Args&... args)
void Assert(bool cond, unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
{
using namespace std::literals;
if(cond)
Expand Down
5 changes: 4 additions & 1 deletion Akel/Runtime/Includes/Core/OS/OSInstance.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// This file is a part of Akel
// Authors : @kbz_8
// Created : 02/02/2024
// Updated : 03/02/2024
// Updated : 04/02/2024

#ifndef __AK_CORE_OS_INSTANCE__
#define __AK_CORE_OS_INSTANCE__

#include <Core/PreCompiled.h>
#include <Maths/Vec4.h>

namespace Ak
{
Expand All @@ -21,6 +22,8 @@ namespace Ak
virtual bool OpenURL([[maybe_unused]] const std::string& url) { return false; }
virtual void Delay(std::uint32_t us) {}

virtual bool SetTitleBarColor([[maybe_unused]] Vec4f color, [[maybe_unused]] bool dark = true) {}

virtual OSInstance& Get() = 0;

protected:
Expand Down
3 changes: 2 additions & 1 deletion Akel/Runtime/Includes/Core/PreCompiled.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is a part of Akel
// Authors : @kbz_8
// Created : 31/01/2024
// Updated : 03/02/2024
// Updated : 04/02/2024

#ifndef __AK_CORE_PRE_COMPILED_HEADER__
#define __AK_CORE_PRE_COMPILED_HEADER__
Expand All @@ -22,6 +22,7 @@
#include <type_traits>
#include <sstream>
#include <vector>
#include <cstring>

#if !__has_include(<filesystem>)
#if !__has_include(<experimental/filesystem>)
Expand Down
21 changes: 20 additions & 1 deletion Akel/Runtime/Includes/Drivers/MacOS/MacOSInstance.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
// This file is a part of Akel
// Authors : @kbz_8
// Created : 03/02/2024
// Updated : 03/02/2024
// Updated : 04/02/2024

#ifndef __AK_DRIVERS_MACOS_INSTANCE__
#define __AK_DRIVERS_MACOS_INSTANCE__

#include <Drivers/MacOS/PreCompiled.h>
#include <Core/OS/OSInstance.h>

namespace Ak
{
class AK_MACOS_API MacOSInstance final : public OSInstance
{
public:
void Init() override;
void Shutdown() override;

std::filesystem::path GetExecutablePath() override;
std::filesystem::path GetCurrentWorkingDirectoryPath() override;
bool OpenURL([[maybe_unused]] const std::string& url) override;
void Delay(std::uint32_t us) override;

bool SetTitleBarColor(Vec4f color, bool dark = true) override;

OSInstance& Get() override;

private:
MacOSInstance() = default;
~MacOSInstance() override = default;
};
}

#endif
6 changes: 4 additions & 2 deletions Akel/Runtime/Includes/Drivers/Unix/PreCompiled.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// This file is a part of Akel
// Authors : @kbz_8
// Created : 02/02/2024
// Updated : 03/02/2024
// Updated : 04/02/2024

#ifndef __AK_DRIVERS_UNIX_PRE_COMPILED_HEADER__
#define __AK_DRIVERS_UNIX_PRE_COMPILED_HEADER__

#include <Core/CompilationProfile.h>
#include <Drivers/Unix/Unix.h>
#include <ctime>
#include <unistd.h>
#ifdef AK_PLAT_UNIX
#include <unistd.h>
#endif

#endif
5 changes: 4 additions & 1 deletion Akel/Runtime/Includes/Drivers/Windows/PreCompiled.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is a part of Akel
// Authors : @kbz_8
// Created : 02/02/2024
// Updated : 03/02/2024
// Updated : 04/02/2024

#ifndef __AK_DRIVERS_WINDOWS_PRE_COMPILED_HEADER__
#define __AK_DRIVERS_WINDOWS_PRE_COMPILED_HEADER__
Expand All @@ -14,6 +14,9 @@
#define NOMINMAX // For windows.h
#endif
#include <windows.h>
#include <shellapi.h>
#include <dwmapi.h>
#include <winuser.h>
#endif

#endif
21 changes: 20 additions & 1 deletion Akel/Runtime/Includes/Drivers/Windows/WindowsInstance.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
// This file is a part of Akel
// Authors : @kbz_8
// Created : 03/02/2024
// Updated : 03/02/2024
// Updated : 04/02/2024

#ifndef __AK_DRIVERS_WINDOWS_INSTANCE__
#define __AK_DRIVERS_WINDOWS_INSTANCE__

#include <Drivers/Windows/PreCompiled.h>
#include <Core/OS/OSInstance.h>

namespace Ak
{
class AK_WINDOWS_API WindowsInstance final : public OSInstance
{
public:
void Init() override;
void Shutdown() override;

std::filesystem::path GetExecutablePath() override;
std::filesystem::path GetCurrentWorkingDirectoryPath() override;
bool OpenURL(const std::string& url) override;
void Delay(std::uint32_t us) override;

bool SetTitleBarColor(Vec4f color, bool dark = true) override;

OSInstance& Get() override;

private:
WindowsInstance() = default;
~WindowsInstance() = default;
};
}

#endif
6 changes: 3 additions & 3 deletions Akel/Runtime/Includes/Maths/Vec4.inl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is a part of Akel
// Authors : @kbz_8
// Created : 23/06/2021
// Updated : 02/02/2024
// Updated : 04/02/2024

#include <Core/Logs.h>

Expand Down Expand Up @@ -123,14 +123,14 @@ namespace Ak
template<typename T>
constexpr T& Vec4<T>::operator[](std::size_t i)
{
Ak::Assert(i < 4, "index out of range");
Assert(i < 4, "index out of range");
return *(&x + i);
}

template<typename T>
constexpr const T& Vec4<T>::operator[](std::size_t i) const
{
Ak::Assert(i < 4, "index out of range");
Assert(i < 4, "index out of range");
return *(&x + i);
}

Expand Down
11 changes: 0 additions & 11 deletions Akel/Runtime/Sources/Drivers/MacOS/MacOSInstance.cpp

This file was deleted.

Loading

0 comments on commit ad06f63

Please sign in to comment.