From cdc44137e8fe70209f3b2fa048586d36d1e703b7 Mon Sep 17 00:00:00 2001 From: Isuru Samarathunga Date: Mon, 3 Nov 2025 01:46:13 +0530 Subject: [PATCH] Fixes --- Src/IACore/inc/hpp/IACore/Definitions.hpp | 117 ++++++++++++---------- 1 file changed, 65 insertions(+), 52 deletions(-) diff --git a/Src/IACore/inc/hpp/IACore/Definitions.hpp b/Src/IACore/inc/hpp/IACore/Definitions.hpp index 14fb48b..fe8fab5 100644 --- a/Src/IACore/inc/hpp/IACore/Definitions.hpp +++ b/Src/IACore/inc/hpp/IACore/Definitions.hpp @@ -1,16 +1,16 @@ -// IACore-OSS; The Core Library for All IA Open Source Projects +// IACore-OSS; The Core Library for All IA Open Source Projects // Copyright (C) 2024 IAS (ias@iasoft.dev) -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -19,13 +19,14 @@ #include #include -#include -#include -#include -#include #include -#include +#include +#include +#include #include +#include +#include +#include #define IAC_SEC_LEVEL(v) (IACORE_SECURITY_LEVEL >= v) @@ -47,15 +48,15 @@ #define DEBUG_ONLY(f) #endif -#define AUTO auto -#define CONST const -#define STATIC static -#define EXTERN extern -#define VIRTUAL virtual -#define OVERRIDE override +#define AUTO auto +#define CONST const +#define STATIC static +#define EXTERN extern +#define VIRTUAL virtual +#define OVERRIDE override #define CONSTEXPR constexpr -#define NOEXCEPT noexcept -#define NORETURN [[noreturn]] +#define NOEXCEPT noexcept +#define NORETURN [[noreturn]] #define IA_MOVE(...) std::move(__VA_ARGS__) @@ -66,16 +67,16 @@ #define INLINE inline #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #define ALWAYS_INLINE __attribute__((always_inline)) inline +#define ALWAYS_INLINE __attribute__((always_inline)) inline #elif defined(_MSC_VER) - #define ALWAYS_INLINE __forceinline +#define ALWAYS_INLINE __forceinline #endif -#define UNUSED(v) ((void)v); +#define UNUSED(v) ((void) v); #define NO_DISCARD(s) [[nodiscard(s)]] -#define B_LIKELY(cond) (cond) [[likely]] +#define B_LIKELY(cond) (cond) [[likely]] #define B_UNLIKELY(cond) (cond) [[unlikely]] #define __INTERNAL_IA_STRINGIFY(value) #value @@ -99,7 +100,7 @@ #undef TRUE #undef FALSE #define FALSE false -#define TRUE true +#define TRUE true #define IN #define OUT @@ -110,22 +111,23 @@ #define C_DECL(f) EXTERN "C" f -#define CAST(v, t) ((t)v) +#define CAST(v, t) ((t) v) -#define ALIAS_FUNCTION(alias, function) template \ - auto alias(Args&&... args) -> decltype(f(std::forward(args)...)) \ - { \ - return function(std::forward(args)...); \ - } +#define ALIAS_FUNCTION(alias, function) \ + template auto alias(Args &&...args) -> decltype(f(std::forward(args)...)) \ + { \ + return function(std::forward(args)...); \ + } -#define ALIAS_TEMPLATE_FUNCTION(t, alias, function) template \ - auto alias(Args&&... args) -> decltype(function(std::forward(args)...)) \ - { \ - return function(std::forward(args)...); \ - } +#define ALIAS_TEMPLATE_FUNCTION(t, alias, function) \ + template \ + auto alias(Args &&...args) -> decltype(function(std::forward(args)...)) \ + { \ + return function(std::forward(args)...); \ + } -#define IA_RELEASE_ASSERT(v) assert((v)) -#define IA_RELEASE_ASSERT_MSG(v, m) assert((v) && m) +#define IA_RELEASE_ASSERT(v) assert((v)) +#define IA_RELEASE_ASSERT_MSG(v, m) assert((v) && m) #if defined(__DEBUG_MODE__) #define IA_ASSERT(v) IA_RELEASE_ASSERT(v) @@ -138,8 +140,8 @@ #define IA_ASSERT_EQ(a, b) IA_ASSERT((a) == (b)) #define IA_ASSERT_GE(a, b) IA_ASSERT((a) >= (b)) #define IA_ASSERT_LE(a, b) IA_ASSERT(a <= b) -#define IA_ASSERT_LT(a, b) IA_ASSERT(a < b) -#define IA_ASSERT_GT(a, b) IA_ASSERT(a > b) +#define IA_ASSERT_LT(a, b) IA_ASSERT(a < b) +#define IA_ASSERT_GT(a, b) IA_ASSERT(a > b) #define IA_ASSERT_IMPLIES(a, b) IA_ASSERT(!(a) || (b)) #define IA_ASSERT_NOT_NULL(v) IA_ASSERT(((v) != nullptr)) @@ -150,26 +152,37 @@ #define IA_MAX_STRING_LENGTH (IA_MAX_POSSIBLE_SIZE >> 8) #define IA_VERSION_TYPE UINT64 -#define IA_MAKE_VERSION(major, minor, patch) ((static_cast(major) & 0xFFFFFF) << 40) | ((static_cast(minor) & 0xFFFFFF) << 16) | (static_cast(patch) & 0xFFFF) -#define IA_STRINGIFY_VERSION(version) BuildString("v", (version >> 40) & 0xFFFFFF, ".", (version >> 16) & 0xFFFFFF, ".", version & 0xFFFF) +#define IA_MAKE_VERSION(major, minor, patch) \ + ((static_cast(major) & 0xFFFFFF) << 40) | ((static_cast(minor) & 0xFFFFFF) << 16) | \ + (static_cast(patch) & 0xFFFF) +#define IA_STRINGIFY_VERSION(version) \ + BuildString("v", (version >> 40) & 0xFFFFFF, ".", (version >> 16) & 0xFFFFFF, ".", version & 0xFFFF) +#define IA_PARSE_VERSION_STRING(versionString) \ + [](IN std::string str) { \ + INT32 minor, major, patch; \ + char dot; \ + std::stringstream ss(str); \ + ss >> major >> dot >> minor >> dot >> patch; \ + return IA_MAKE_VERSION(major, minor, patch); \ + }(versionString) #if defined(_MSC_VER) - #define IA_DLL_EXPORT __declspec(dllexport) - #define IA_DLL_IMPORT __declspec(dllimport) +#define IA_DLL_EXPORT __declspec(dllexport) +#define IA_DLL_IMPORT __declspec(dllimport) #elif defined(__GNUC__) - #define IA_DLL_EXPORT __attribute__((visibility("default"))) - #define IA_DLL_IMPORT +#define IA_DLL_EXPORT __attribute__((visibility("default"))) +#define IA_DLL_IMPORT #else - #define IA_DLL_EXPORT - #define IA_DLL_IMPORT +#define IA_DLL_EXPORT +#define IA_DLL_IMPORT #endif -#define __CC_BLACK "\033[30m" -#define __CC_RED "\033[31m" -#define __CC_GREEN "\033[32m" -#define __CC_YELLOW "\033[33m" -#define __CC_BLUE "\033[34m" +#define __CC_BLACK "\033[30m" +#define __CC_RED "\033[31m" +#define __CC_GREEN "\033[32m" +#define __CC_YELLOW "\033[33m" +#define __CC_BLUE "\033[34m" #define __CC_MAGENTA "\033[35m" -#define __CC_CYAN "\033[36m" -#define __CC_WHITE "\033[37m" +#define __CC_CYAN "\033[36m" +#define __CC_WHITE "\033[37m" #define __CC_DEFAULT "\033[39m"