From 7e1bf30131146ac22e08568657b0be0669f343de Mon Sep 17 00:00:00 2001 From: Reece Date: Fri, 1 Apr 2022 05:03:03 +0100 Subject: [PATCH] [-] auROXTL -> Moved to https://gitea.reece.sx/AuroraSupport/auROXTL --- Aurora.json | 4 +- Include/auROXTL.hpp | 32 - Include/auROXTL/AU_MACROS.hpp | 190 ------ Include/auROXTL/AU_Z.hpp | 73 --- Include/auROXTL/Objects/ClassHelpers.hpp | 131 ---- Include/auROXTL/Objects/ModuleApi.hpp | 8 - Include/auROXTL/Objects/Objects.hpp | 11 - .../STLShims/ExtendStlLikeSharedPtr.hpp | 401 ------------ Include/auROXTL/auArray.hpp | 15 - Include/auROXTL/auAtomic.hpp | 312 ---------- Include/auROXTL/auBST.hpp | 17 - Include/auROXTL/auBitsUtils.hpp | 222 ------- Include/auROXTL/auCastUtils.hpp | 136 ---- Include/auROXTL/auContainerUtils.hpp | 589 ------------------ Include/auROXTL/auCopyMoveUtils.hpp | 58 -- Include/auROXTL/auEndianness.hpp | 94 --- Include/auROXTL/auFNV1Utils.hpp | 86 --- Include/auROXTL/auFunctional.hpp | 29 - Include/auROXTL/auHashMap.hpp | 17 - Include/auROXTL/auHashUtils.hpp | 143 ----- Include/auROXTL/auIntegerSequence.hpp | 35 -- Include/auROXTL/auList.hpp | 31 - Include/auROXTL/auListUtils.hpp | 22 - Include/auROXTL/auMagicUtils.hpp | 66 -- Include/auROXTL/auMemoryModel.hpp | 221 ------- Include/auROXTL/auMemoryUtils.hpp | 47 -- Include/auROXTL/auNumberUtils.hpp | 38 -- Include/auROXTL/auNumericLimits.hpp | 131 ---- Include/auROXTL/auOptional.hpp | 15 - Include/auROXTL/auOptionalEx.hpp | 91 --- Include/auROXTL/auPosixUtils.hpp | 9 - Include/auROXTL/auResult.hpp | 67 -- Include/auROXTL/auString.hpp | 28 - Include/auROXTL/auStringUtils.hpp | 123 ---- Include/auROXTL/auSwapExchangeUtils.hpp | 24 - Include/auROXTL/auTemplateMeta.hpp | 341 ---------- Include/auROXTL/auTemplateMetaIsFunction.hpp | 172 ----- Include/auROXTL/auTransform.hpp | 8 - Include/auROXTL/auTryConstruct.hpp | 37 -- Include/auROXTL/auTryConstructUtils.hpp | 94 --- Include/auROXTL/auTuple.hpp | 25 - Include/auROXTL/auTupleUtils.hpp | 180 ------ Include/auROXTL/auTypeUtils.hpp | 386 ------------ Include/auROXTL/auTypes.hpp | 30 - Include/auROXTL/auUTF8StringView.hpp | 7 - Include/auROXTL/auUnitUtils.hpp | 112 ---- Include/auROXTL/auVector.hpp | 50 -- Include/auROXTL/auWin32Utils.hpp | 26 - Include/auROXTLTypes.hpp | 63 -- Include/auROXTLUtils.hpp | 77 --- 50 files changed, 2 insertions(+), 5122 deletions(-) delete mode 100644 Include/auROXTL.hpp delete mode 100644 Include/auROXTL/AU_MACROS.hpp delete mode 100644 Include/auROXTL/AU_Z.hpp delete mode 100644 Include/auROXTL/Objects/ClassHelpers.hpp delete mode 100644 Include/auROXTL/Objects/ModuleApi.hpp delete mode 100644 Include/auROXTL/Objects/Objects.hpp delete mode 100644 Include/auROXTL/STLShims/ExtendStlLikeSharedPtr.hpp delete mode 100644 Include/auROXTL/auArray.hpp delete mode 100644 Include/auROXTL/auAtomic.hpp delete mode 100644 Include/auROXTL/auBST.hpp delete mode 100644 Include/auROXTL/auBitsUtils.hpp delete mode 100644 Include/auROXTL/auCastUtils.hpp delete mode 100644 Include/auROXTL/auContainerUtils.hpp delete mode 100644 Include/auROXTL/auCopyMoveUtils.hpp delete mode 100644 Include/auROXTL/auEndianness.hpp delete mode 100644 Include/auROXTL/auFNV1Utils.hpp delete mode 100644 Include/auROXTL/auFunctional.hpp delete mode 100644 Include/auROXTL/auHashMap.hpp delete mode 100644 Include/auROXTL/auHashUtils.hpp delete mode 100644 Include/auROXTL/auIntegerSequence.hpp delete mode 100644 Include/auROXTL/auList.hpp delete mode 100644 Include/auROXTL/auListUtils.hpp delete mode 100644 Include/auROXTL/auMagicUtils.hpp delete mode 100644 Include/auROXTL/auMemoryModel.hpp delete mode 100644 Include/auROXTL/auMemoryUtils.hpp delete mode 100644 Include/auROXTL/auNumberUtils.hpp delete mode 100644 Include/auROXTL/auNumericLimits.hpp delete mode 100644 Include/auROXTL/auOptional.hpp delete mode 100644 Include/auROXTL/auOptionalEx.hpp delete mode 100644 Include/auROXTL/auPosixUtils.hpp delete mode 100644 Include/auROXTL/auResult.hpp delete mode 100644 Include/auROXTL/auString.hpp delete mode 100644 Include/auROXTL/auStringUtils.hpp delete mode 100644 Include/auROXTL/auSwapExchangeUtils.hpp delete mode 100644 Include/auROXTL/auTemplateMeta.hpp delete mode 100644 Include/auROXTL/auTemplateMetaIsFunction.hpp delete mode 100644 Include/auROXTL/auTransform.hpp delete mode 100644 Include/auROXTL/auTryConstruct.hpp delete mode 100644 Include/auROXTL/auTryConstructUtils.hpp delete mode 100644 Include/auROXTL/auTuple.hpp delete mode 100644 Include/auROXTL/auTupleUtils.hpp delete mode 100644 Include/auROXTL/auTypeUtils.hpp delete mode 100644 Include/auROXTL/auTypes.hpp delete mode 100644 Include/auROXTL/auUTF8StringView.hpp delete mode 100644 Include/auROXTL/auUnitUtils.hpp delete mode 100644 Include/auROXTL/auVector.hpp delete mode 100644 Include/auROXTL/auWin32Utils.hpp delete mode 100644 Include/auROXTLTypes.hpp delete mode 100644 Include/auROXTLUtils.hpp diff --git a/Aurora.json b/Aurora.json index ac097d6a..155d66da 100644 --- a/Aurora.json +++ b/Aurora.json @@ -7,8 +7,8 @@ "staticImpDefines": "AURORA_ENGINE_KERNEL_STATIC", "defines": [], "soft-depends": ["wxwidgets", "glm", "bzip2", "lz4"], - "depends": ["AuroraInterfaces", "AuroraEnum", "mimalloc", "uuid", "fmt", "json", "ltc", "o1heap", "zstd", "zlib", "mbedtls"], - "include-depends": ["fmt", "uuid", "AuroraInterfaces", "AuroraEnum"], + "depends": ["auROXTL", "AuroraInterfaces", "AuroraEnum", "mimalloc", "uuid", "fmt", "json", "ltc", "o1heap", "zstd", "zlib", "mbedtls"], + "include-depends": ["fmt", "uuid", "AuroraInterfaces", "AuroraEnum", "auROXTL"], "features": ["guess-platform-code"], "linkSources": "Source/Alloc.cpp", "actions": [ diff --git a/Include/auROXTL.hpp b/Include/auROXTL.hpp deleted file mode 100644 index c0a6e28d..00000000 --- a/Include/auROXTL.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auROXTL.hpp - Date: 2022-2-2 - Author: Reece -***/ -#pragma once - -#include -#include - -#if defined(_AUHAS_AURORAENUM) - #include - #include - #include -#endif - -#if defined(_AUHAS_FMT) - #include -#endif - -#include "auROXTL/AU_Z.hpp" -#include "auROXTL/AU_MACROS.hpp" -#include "auROXTLTypes.hpp" - -#if defined(_AUHAS_AURORAENUM) - #define _ALLOW_AURORA_ENUM_AUENVHPP - #include -#endif - -#include "auROXTLUtils.hpp" \ No newline at end of file diff --git a/Include/auROXTL/AU_MACROS.hpp b/Include/auROXTL/AU_MACROS.hpp deleted file mode 100644 index 9abae7ad..00000000 --- a/Include/auROXTL/AU_MACROS.hpp +++ /dev/null @@ -1,190 +0,0 @@ -/*** - Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: AuroraMacros.hpp - File: AU_MACROS.hpp - Date: 2021-6-10 - Author: Reece -***/ -#pragma once - -#define AU_COPY(type) type(const type&) = default; type &operator=(const type &) = default; -#define AU_MOVE(type) type(type&&) = default; type &operator=(type &&) = default; -#define AU_COPY_MOVE(type) AU_COPY(type) AU_MOVE(type) - -#define AU_NO_COPY(type) type(const type&) = delete; -#define AU_NO_MOVE(type) type(type&&) = delete; -#define AU_NO_COPY_NO_MOVE(type) AU_NO_COPY(type) AU_NO_MOVE(type) - -#if !defined(AU_SHARED_FROM_THIS) - #define AU_SHARED_FROM_THIS (AuStaticPointerCast>(this->SharedFromThis())) -#endif - -#if !defined(AU_WEAK_FROM_THIS) - #define AU_WEAK_FROM_THIS (AuWPtr>(AuStaticPointerCast>(this->SharedFromThis()))) -#endif - -#define AU_BRACKET_SCOPE(...) __VA_ARGS__ - -#if !defined(AU_TEMPLATE_ENABLE_WHEN) - #define AU_TEMPLATE_ENABLE_WHEN(...) typename AuEnableIf<__VA_ARGS__>::type* = nullptr -#endif - -#define AU_WHAT(n) n - -/// @hideinitializer -#define _AU_STRINGIFY(in) #in -#define AU_STRINGIFY(in) _AU_STRINGIFY(in) - -/// @hideinitializer -#define _AU_CONCAT(a, b) a ## b -#define AU_CONCAT(a, b) _AU_CONCAT(a, b) - -/// @hideinitializer -#define _AUKCON_STRINGIFY_X(in) AU_STRINGIFY(in) - -#if !defined(AU_SHARED_API_EX) - #define AU_SHARED_API_EX(vis, name, type, ...) \ - \ - vis type *name ## New(__VA_ARGS__); \ - vis void name ## Release(type *); \ - static inline void name ## Destroy(type *val) \ - { \ - name ## Release(val); \ - } \ - \ - struct CppDeleter ## name \ - { \ - void operator()(type *t) \ - { \ - name ## Release(t); \ - } \ - }; \ - \ - using name ## Unique_t = AURORA_RUNTIME_AU_UNIQUE_PTR; \ - template \ - name ## Unique_t name ## Unique(T... args) \ - { \ - return name ## Unique_t(name ## New(args...)); \ - } \ - \ - using name ## Shared_t = AuSPtr; \ - template \ - name ## Shared_t name ## Shared(T... args) \ - { \ - return name ## Shared_t(name ## New(args...), name ## Release); \ - } -#endif - -#if !defined(AU_SHARED_API) - #define AU_SHARED_API(name, type, ...) AU_SHARED_API_EX(, name, type, #__VA_ARGS__) -#endif - -#if !defined(AU_NOINLINE) - #if defined(AURORA_COMPILER_MSVC) - #define AU_NOINLINE __declspec(noinline) - #else - #define AU_NOINLINE __attribute__((noinline)) - #endif -#endif - -#if !defined(AU_INLINE) - #if defined(AURORA_COMPILER_MSVC) - #define AU_INLINE __forceinline - #else - #define AU_INLINE __attribute__((always_inline)) - #endif -#endif - -#if !defined(AU_NORETURN) - #if defined(AURORA_COMPILER_MSVC) - #define AU_NORETURN __declspec(noreturn) - #elif (defined(AURORA_COMPILER_CLANG) || defined(AURORA_COMPILER_GCC)) - #define AU_NORETURN __attribute__((noreturn)) - #elif defined(AU_LANG_CPP) - #define AU_NORETURN [[noreturn]] - #else - #define AU_NORETURN - #endif -#endif - -#if !defined(AU_ALLOC) - #if defined(AURORA_PLATFORM_WIN32) - #define AU_ALLOC __declspec(allocator) - #elif defined(AURORA_COMPILER_CLANG) - #define AU_ALLOC __declspec(allocator) - #elif defined(AURORA_COMPILER_GCC) - #define AU_ALLOC __attribute__((malloc)) - #else - #define AU_ALLOC - #endif -#endif - -#if !defined(NO__NEW) - #if !defined(_new) - #define _new new (std::nothrow) - #endif -#endif - -#if !defined(NO__INLINE) - #if !defined(auline) - #define auline AU_INLINE - #endif -#endif - -#if !defined(AU_FWD) - #define AU_FWD(var) AuForward(var) -#endif - -#if !defined(AU_THROW_STRING) - #define AU_THROW_STRING(var) throw AuString(var) -#endif - -#define AU_ITERATE_ARRAY(index, arry) AuUInt index = 0; index < AuArraySize(arry); index++ -#define AU_ITERATE_N(index, n) AuUInt index = 0; index < n; index++ -#define AU_ITERATE_N_TO_X(index, n, x) AuUInt index = n; index < x; index++ -#define AU_ITERATE_BACKWARDS(index, lastIdx) AuUInt index = lastIdx; index <= 0; index-- - -#define AU_ITR_ARRAY AU_ITERATE_ARRAY -#define AU_ITR_N AU_ITERATE_N -#define AU_ITR_N_TO_X AU_ITERATE_N_TO_X -#define AU_ITR_BACKWARDS AU_ITERATE_BACKWARDS - -#define AU_STRIP_BRACKETS_IMPL(...) __VA_ARGS__ - -#if !defined(AU_STRIP_BRACKETS) - #define AU_STRIP_BRACKETS(X) AU_WHAT(AU_STRIP_BRACKETS_IMPL X) -#endif - -#if !defined(AU_STRIP) - #define AU_STRIP AU_STRIP_BRACKETS -#endif - -#if !defined(AU_EMIT_FIRST) - #define AU_EMIT_FIRST(a, b)a -#endif - -#if !defined(AU_EMIT_SECOND) - #define AU_EMIT_SECOND(a, b)b -#endif - -#if !defined(AU_EMIT_BOTH) - #define AU_EMIT_BOTH(a, b)a, a -#endif - -#if !defined(AuBindThis) - #define AuBindThis(method, ...) std::bind(method, this, ## __VA_ARGS__) -#endif - -#if !defined(AuSharedFromThis) - #define AuSharedFromThis() AU_SHARED_FROM_THIS -#endif - -#if !defined(AuWeakFromThis) - #define AuWeakFromThis() AU_SHARED_FROM_THIS -#endif - -#define AU_EMIT_FIRST_COMMA_FIRST(n)n -#define AU_EMIT_FIRST_COMMA_OTHERS(n),n - -#include "Objects/Objects.hpp" \ No newline at end of file diff --git a/Include/auROXTL/AU_Z.hpp b/Include/auROXTL/AU_Z.hpp deleted file mode 100644 index 470423cc..00000000 --- a/Include/auROXTL/AU_Z.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: AU_Z.hpp - Date: 2022-3-26 - Author: Reece -***/ -#pragma once - -//////////////////////////////////////////////////////////////////////////////////////////////// -// Exception model -//////////////////////////////////////////////////////////////////////////////////////////////// - -#if !defined(AUROXTL_NO_TRY) - #define AUROXTL_COMMODITY_TRY try - #define AUROXTL_COMMODITY_CATCH catch (...) -#else - #define AUROXTL_COMMODITY_TRY - #define AUROXTL_COMMODITY_CATCH while (0) -#endif - -//////////////////////////////////////////////////////////////////////////////////////////////// -// Stinky container config (leave it alone) -//////////////////////////////////////////////////////////////////////////////////////////////// - - -#if (!defined(AURORA_ENGINE_KERNEL) && \ - !defined(_AUHAS_AURORARUNTIME)) - - // If we're in our ecosystem, assume global allocator override in all modules - // std::allocator __will__ be Aurora::memory backed no matter what - // - // Externally, however, the ABI of the type matters. - // > We want the differing ABI for std - // > We want customers' STLs' containers' move/copy semantics to apply - // > ...w/o copying between container types - // - // Therefore, `#if !defined(aurora) - // #define USE_STL //(for source compatibility) - // #endif ` - #define AURORA_ROXTL_ALLOCATORS_USE_STD -#endif - -#if defined(AURORA_ROXTL_ALLOCATORS_USE_STD) - - // Crossing API boundaries will resort in an alloc + copy - // Don't enable unless you're in the ecosystem - // Default behaviour (omitted): use the exact std::string type - #define AURORA_ROXTL_CONTAINERS_USE_PURE -#endif - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// Memory, AuSPtr, and Friends -//////////////////////////////////////////////////////////////////////////////////////////////// - -#if defined(AURORA_ROXTL_NULL_POINTER_CHECKS_DISABLED) - #define _AURORA_NULLEXPT_ENABLE_UB -#endif - -#if defined(AURORA_ROXTL_NULL_POINTER_CHECKS_USE_COMPARE_OVER_INDIRECT_JMP) - #define _AURORA_NULLEXPT_BRANCH -#endif - -#if defined(AURORA_ROXTL_NULL_POINTER_COMPARE_MODE_AGGRESSIVE) - #define _AURORA_NULLEXPT_BRANCH_BUG_CHECK -#endif - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////////////////////// - -//#define _AURORA_NULLEXPT_USE_TRY_EMPLACE_AFTER_FIND \ No newline at end of file diff --git a/Include/auROXTL/Objects/ClassHelpers.hpp b/Include/auROXTL/Objects/ClassHelpers.hpp deleted file mode 100644 index 22e1ba1d..00000000 --- a/Include/auROXTL/Objects/ClassHelpers.hpp +++ /dev/null @@ -1,131 +0,0 @@ -/*** - Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: Objects.hpp - File: AuroraMacros.hpp - File: AU_MACROS.hpp - Date: 2021-6-10 - Author: Reece -***/ -#pragma once - -/* - AU_DEFINE_FOR_VA(Object, - (AU_DEFINE_CTOR_VA, // initializer-list-like ctor (extending a struct or adding a ctor will break initializer lists) - AU_DEFINE_THIS_MOVE_CTOR_VA, // add move `Object(Object &&)` - AU_DEFINE_EQUALS_VA, // add equals operator - AU_DEFINE_MOVE_VA, // add move assignment operator - AU_DEFINE_COPY_VA), // add copy assignment operator - (id, task)); -*/ - -/// @hideinitializer -#define AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(variable) AuRemoveConst_t> - -/// @hideinitializer -#define AU_EMIT_CTOR_CPY(pair) const AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(pair) &pair - -/// @hideinitializer -#define AU_EMIT_CTOR_CPY_SECOND(pair) ,AU_EMIT_CTOR_CPY(pair) - -/// @hideinitializer -#define AU_EMIT_CTOR_MOV(pair) AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(pair) &&pair - -/// @hideinitializer -#define AU_EMIT_CTOR_MOV_SECOND(pair) ,AU_EMIT_CTOR_MOV(pair) - -/// @hideinitializer -#define AU_EMIT_CTOR_ASSIGN(pair) pair(pair) - -/// @hideinitializer -#define AU_EMIT_CTOR_ASSIGN_SECOND(pair) ,AU_EMIT_CTOR_ASSIGN(pair) - -/// @hideinitializer -#define AU_EMIT_CTOR_ASSIGN2(pair) pair(cpy.pair) - -/// @hideinitializer -#define AU_EMIT_CTOR_ASSIGN2_SECOND(pair) ,AU_EMIT_CTOR_ASSIGN2(pair) - -/// @hideinitializer -#define AU_EMIT_CTOR_MOVE_ASSIGN2(pair) pair(AuMove(cpy.pair)) - -/// @hideinitializer -#define AU_EMIT_CTOR_MOVE_ASSIGN2_SECOND(pair) ,AU_EMIT_CTOR_MOVE_ASSIGN2(pair) - -/// @hideinitializer -#define AU_DEFINE_CTOR_VA_(thisType, args) AU_DEFINE_CTOR_CPY_VA(thisType, args) AU_DEFINE_CTOR_MOV_VA(thisType, args) - -/// @deprecated -#define AU_DEFINE_CTOR_ONE(thisType, pairTypeName) AU_DEFINE_CTOR_VA_(thisType, (AU_EMIT_SECOND pairTypeName)) - -/// @hideinitializer -#define AU_DEFINE_EQUALS_VA_A(name) this->name == ref.name - -/// @hideinitializer -#define AU_DEFINE_EQUALS_VA_B(name) && AU_DEFINE_EQUALS_VA_A(name) - -/// @hideinitializer -#define AU_DEFINE_EQUALS_HASHCODE_A(name) AuHashCode(this->name) - -/// @hideinitializer -#define AU_DEFINE_EQUALS_HASHCODE_B(name) ^ AU_DEFINE_EQUALS_HASHCODE_A(name) - -/// @hideinitializer -#define AU_DEFINE_MOVE_VA_A(name) this->name = AuMove(ref.name); - -/// @hideinitializer -#define AU_DEFINE_MOVE_VA_B(name) AU_DEFINE_MOVE_VA_A(name) - -/// @hideinitializer -#define AU_DEFINE_COPY_VA_A(name) this->name = ref.name; - -/// @hideinitializer -#define AU_DEFINE_COPY_VA_B(name) AU_DEFINE_COPY_VA_A(name) - -/// @hideinitializer -#define AU_DEFINE_CTOR_CPY_VA(thisType, args) \ -inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_CPY, AU_EMIT_CTOR_CPY_SECOND, AU_STRIP_BRACKETS(args))) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN, AU_EMIT_CTOR_ASSIGN_SECOND, AU_STRIP_BRACKETS(args)) \ -{} - -/// @hideinitializer -#define AU_DEFINE_CTOR_MOV_VA(thisType, args) \ -inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOV, AU_EMIT_CTOR_MOV_SECOND, AU_STRIP_BRACKETS(args))) noexcept : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN, AU_EMIT_CTOR_ASSIGN_SECOND, AU_STRIP_BRACKETS(args)) \ -{} - -/// @hideinitializer -#define AU_DEFINE_THIS_COPY_CTOR_VA(thisType, args) \ -inline thisType(const thisType &cpy) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN2, AU_EMIT_CTOR_ASSIGN2_SECOND, AU_STRIP_BRACKETS(args)) \ -{} - -/// @hideinitializer -#define AU_DEFINE_THIS_MOVE_CTOR_VA(thisType, args) \ -inline thisType(thisType &&cpy) noexcept : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOVE_ASSIGN2, AU_EMIT_CTOR_MOVE_ASSIGN2_SECOND, AU_STRIP_BRACKETS(args)) \ -{} - -/// @hideinitializer -#define AU_DEFINE_FOR_VA_(pair, func) func(AU_EMIT_SECOND pair, AU_STRIP_BRACKETS(AU_EMIT_FIRST pair)) - - - - - -/// -#define AU_DEFINE_HASHCODE_VA(thisType, args) AuUInt HashCode() const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_HASHCODE_A, AU_DEFINE_EQUALS_HASHCODE_B, AU_STRIP_BRACKETS(args)) ; } - -/// -#define AU_DEFINE_CTOR_VA(thisType, args) AU_DEFINE_CTOR_CPY_VA(thisType, args) AU_DEFINE_CTOR_MOV_VA(thisType, args) - -/// -#define AU_DEFINE_EQUALS_VA(thisType, args) bool operator==(const thisType & ref) const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_VA_A, AU_DEFINE_EQUALS_VA_B, AU_STRIP_BRACKETS(args)) ; } - -/// -#define AU_DEFINE_MOVE_VA(thisType, args) thisType& operator=( thisType && ref) noexcept { AU_FOR_EACH_FIRST(AU_DEFINE_MOVE_VA_A, AU_DEFINE_MOVE_VA_B, AU_STRIP_BRACKETS(args)) return *this; } - -/// -#define AU_DEFINE_COPY_VA(thisType, args) thisType& operator=(const thisType & ref) { AU_FOR_EACH_FIRST(AU_DEFINE_COPY_VA_A, AU_DEFINE_COPY_VA_B, AU_STRIP_BRACKETS(args)) return *this; } - - - - -// -#define AU_DEFINE_FOR_VA(type, arry, members) AU_FOR_EACH_THAT(AU_DEFINE_FOR_VA_, ((members), type), AU_STRIP_BRACKETS(arry)) \ No newline at end of file diff --git a/Include/auROXTL/Objects/ModuleApi.hpp b/Include/auROXTL/Objects/ModuleApi.hpp deleted file mode 100644 index 218e923e..00000000 --- a/Include/auROXTL/Objects/ModuleApi.hpp +++ /dev/null @@ -1,8 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: ModuleApi.hpp - Date: 2022-3-31 - Author: Reece -***/ -#pragma once \ No newline at end of file diff --git a/Include/auROXTL/Objects/Objects.hpp b/Include/auROXTL/Objects/Objects.hpp deleted file mode 100644 index 7040c2fa..00000000 --- a/Include/auROXTL/Objects/Objects.hpp +++ /dev/null @@ -1,11 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: Objects.hpp - Date: 2022-3-31 - Author: Reece -***/ -#pragma once - -#include "ClassHelpers.hpp" -#include "ModuleApi.hpp" \ No newline at end of file diff --git a/Include/auROXTL/STLShims/ExtendStlLikeSharedPtr.hpp b/Include/auROXTL/STLShims/ExtendStlLikeSharedPtr.hpp deleted file mode 100644 index ee88687b..00000000 --- a/Include/auROXTL/STLShims/ExtendStlLikeSharedPtr.hpp +++ /dev/null @@ -1,401 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: ExtendStlLikeSharedPtr.hpp - Date: 2022-1-25 - Author: Reece -***/ -#pragma once - -//#include -#include - -namespace Aurora::Memory -{ - inline void ThrowNullException(); - - namespace _detail - { - struct IPtrGet - { - virtual void *Get() = 0; - }; - - struct IPtrNoOpGet : IPtrGet - { - inline virtual void *Get() override - { - ThrowNullException(); - return {}; - } - }; - - inline IPtrNoOpGet gNoop; - } - - template - struct ExSharedPtr : Base_t - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) && !defined(_AURORA_NULLEXPT_BRANCH) - , private _detail::IPtrGet - #endif - { - using element_type = typename Base_t::element_type; - using weak_type = typename Base_t::weak_type; - using base_type = Base_t; - using Base_t::Base_t; - - ExSharedPtr() : Base_t() - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - ExSharedPtr(Base_t &&in) : Base_t(in) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - ExSharedPtr(ExSharedPtr &&in) : Base_t(in) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - ExSharedPtr(const ExSharedPtr &in) : Base_t(in) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - template - ExSharedPtr(const ExSharedPtr &in) : Base_t(in.BasePointerType(), static_cast(in.get())) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - template - ExSharedPtr(ExSharedPtr &&in) : Base_t(in.BasePointerType(), static_cast(in.get())) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - template - ExSharedPtr(ExSharedPtr &&in, element_type *ptr) : Base_t(AuMove(in.BasePointerType()), ptr) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - ExSharedPtr(Base_t &&in, element_type *ptr) : Base_t(in, ptr) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - template - ExSharedPtr(const ExSharedPtr &in, element_type *ptr) : Base_t(in.BasePointerType(), ptr) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - ExSharedPtr(const Base_t &in, element_type *ptr) : Base_t(in, ptr) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - ExSharedPtr(const Base_t &in) : Base_t(in) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - template - ExSharedPtr(Y *in, Deleter_t del, Alloc_t alloc) : Base_t(in, del, alloc) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - template - ExSharedPtr(Y *in, Deleter_t del) : Base_t(in, del) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - template < class Y, class Deleter > - ExSharedPtr(AURORA_RUNTIME_AU_UNIQUE_PTR &&r) : Base_t(r) - { - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - - template - void swap(ExSharedPtr &in) - { - Base_t::swap(in.BasePointerType()); - - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - void swap(Base_t &r) - { - Base_t::swap(r); - - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - } - - void reset() - { - Base_t::reset(); - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - #if !defined(_AURORA_NULLEXPT_BRANCH) - ptr = &_detail::gNoop; - #endif - #endif - } - - operator const Base_t &() const noexcept - { - return *this; - } - - // required for move casts - operator Base_t &() noexcept - { - return *this; - } - - const Base_t &BasePointerType() const noexcept - { - return *this; - } - - Base_t &BasePointerType() noexcept - { - return *this; - } - - operator bool() const noexcept - { - return Base_t::operator bool(); - } - - ExSharedPtr &operator =(const Base_t &in) noexcept - { - Base_t::operator=(in); - - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - return *this; - } - - template - ExSharedPtr &operator =(ExSharedPtr &&in) noexcept - { - Base_t::operator=(AuMove(in.BasePointerType())); - - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - return *this; - } - - ExSharedPtr &operator =(Base_t &&in) noexcept - { - Base_t::operator=(in); - - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - return *this; - } - - ExSharedPtr &operator =(const ExSharedPtr &in) noexcept - { - Base_t::operator=(in); - - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - return *this; - } - - template - ExSharedPtr &operator =(const ExSharedPtr &in) noexcept - { - Base_t::operator=(in.BasePointerType()); - - #if !defined(_AURORA_NULLEXPT_ENABLE_UB) - _cache(); - #endif - return *this; - } - - template - TType2_t &operator*() const - { - return *operator->(); - } - - template - TType2_t *operator->() const - { - #if defined(_AURORA_NULLEXPT_ENABLE_UB) - return Base_t::operator->(); - #elif !defined(_AURORA_NULLEXPT_BRANCH) - return reinterpret_cast(ptr->Get()); - #else - throwif(); - return Base_t::operator->(); - #endif - } - - template - TType2_t &operator*() - { - return *operator->(); - } - - template - TType2_t *operator->() - { - #if defined(_AURORA_NULLEXPT_ENABLE_UB) - return Base_t::operator->(); - #elif !defined(_AURORA_NULLEXPT_BRANCH) - return reinterpret_cast(ptr->Get()); - #else - throwif(); - return Base_t::operator->(); - #endif - } - - element_type *get() const - { - return Base_t::get(); - } - - #define ADD_OPERATOR(op) \ - template \ - bool operator op(const T &rhs) noexcept \ - { \ - return static_cast(*this) op(rhs); \ - } \ - \ - template < class T > \ - bool operator op(std::nullptr_t rhs) noexcept \ - { \ - return static_cast(*this) op(rhs); \ - } - - - ADD_OPERATOR(==) - ADD_OPERATOR(!=) - #if defined(AU_LANG_CPP_20) - template < class T > - std::strong_ordering operator<=>(const T &rhs) noexcept - { - return Base_t::operator<=>(rhs); - } - #else - ADD_OPERATOR(>) - ADD_OPERATOR(<) - ADD_OPERATOR(<=) - ADD_OPERATOR(=>) - #endif - - private: - - #if defined(_AURORA_NULLEXPT_ENABLE_UB) - void _cache() - {} - #elif !defined(_AURORA_NULLEXPT_BRANCH) - _detail::IPtrGet * ptr; - - inline virtual void *Get() override - { - return Base_t::operator->(); - } - - auline void _cache() - { - if (Base_t::operator bool()) - { - ptr = this; - } - else - { - - ptr = &_detail::gNoop; - } - } - #else - bool cached {}; - auline void throwif() const - { - if (!cached) [[unlikely]] - { - #if defined(_AURORA_NULLEXPT_BRANCH_BUG_CHECK) - if (!Base_t::operator bool()) [[likely]] - #endif - { - AU_THROW_STRING("ExSharedPointer Null Access Violation"); - } - } - } - - auline void throwif() - { - if (!cached) [[unlikely]] - { - #if defined(_AURORA_NULLEXPT_BRANCH_BUG_CHECK) - cached = Base_t::operator bool(); - if (!cached) [[likely]] - #endif - { - AU_THROW_STRING("ExSharedPointer Null Access Violation"); - } - } - } - - auline void _cache() - { - cached = Base_t::operator bool(); - } - #endif - }; - - template - struct ExSharedFromThis : Base_t - { - ExSharedPtr> SharedFromThis() - { - return Base_t::shared_from_this(); - } - }; -} \ No newline at end of file diff --git a/Include/auROXTL/auArray.hpp b/Include/auROXTL/auArray.hpp deleted file mode 100644 index 6eaf4c27..00000000 --- a/Include/auROXTL/auArray.hpp +++ /dev/null @@ -1,15 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auArray.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -#if !defined(AURORA_RUNTIME_AU_ARRAY) - #define AURORA_RUNTIME_AU_ARRAY std::array -#endif - -template -using AuArray = AURORA_RUNTIME_AU_ARRAY; \ No newline at end of file diff --git a/Include/auROXTL/auAtomic.hpp b/Include/auROXTL/auAtomic.hpp deleted file mode 100644 index 3d5b8ad9..00000000 --- a/Include/auROXTL/auAtomic.hpp +++ /dev/null @@ -1,312 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auAtomic.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -template -struct AuAtomicUtils -{ - /** - * @brief Generic bitwise (1 << offset) - * @return original value - * @warning T is bound by platform and compiler constraints - */ - static T Set(T *in, AuUInt8 offset); - - /** - * @brief Adds addend to in - * @return updated value - * @warning T is bound by platform and compiler constraints - */ - static T Add(T *in, T addend); - - /** - * @brief Subtracts the minuend from in - * @return updated value - * @warning T is bound by platform and compiler constraints - */ - static T Sub(T *in, T minuend); - - /** - * @brief Generic compare exchange - * @param replace replacement value for in if in matches compare - * @param compare required reference value - * @return original value - * @warning T is bound by platform and compiler constraints - */ - static T CompareExchange(T *in, T replace, T compare); - - /** - * @brief { return *in & (1 << offset); in |= (1 << offset) } - * @param in - * @param offset Bit index - * @return *in & (1 << offset) - * @warning T is bound by platform and compiler constraints - */ - static bool TestAndSet(T *in, const AuUInt8 offset); -}; - -#if defined(AURORA_COMPILER_MSVC) - -template <> -inline auline AuUInt64 AuAtomicUtils::CompareExchange(AuUInt64 *in, AuUInt64 replace, AuUInt64 compare) -{ - return static_cast(_InterlockedCompareExchange64(reinterpret_cast(in), static_cast(replace), static_cast(compare))); -} - -template <> -inline auline AuUInt32 AuAtomicUtils::CompareExchange(AuUInt32 *in, AuUInt32 replace, AuUInt32 compare) -{ - return static_cast(_InterlockedCompareExchange(reinterpret_cast(in), static_cast(replace), static_cast(compare))); -} - -template <> -inline auline AuUInt16 AuAtomicUtils::CompareExchange(AuUInt16 *in, AuUInt16 replace, AuUInt16 compare) -{ - return static_cast(_InterlockedCompareExchange16(reinterpret_cast(in), static_cast(replace), static_cast(compare))); -} - -template <> -inline auline AuInt64 AuAtomicUtils::CompareExchange(AuInt64 *in, AuInt64 replace, AuInt64 compare) -{ - return _InterlockedCompareExchange64(reinterpret_cast(in), static_cast(replace), static_cast(compare)); -} - -template <> -inline auline AuInt32 AuAtomicUtils::CompareExchange(AuInt32 *in, AuInt32 replace, AuInt32 compare) -{ - return _InterlockedCompareExchange(reinterpret_cast(in), static_cast(replace), static_cast(compare)); -} - -template <> -inline auline AuInt16 AuAtomicUtils::CompareExchange(AuInt16 *in, AuInt16 replace, AuInt16 compare) -{ - return _InterlockedCompareExchange16(reinterpret_cast(in), static_cast(replace), static_cast(compare)); -} - -#if !defined(AURORA_IS_32BIT) -template <> -inline auline AuUInt64 AuAtomicUtils::Add(AuUInt64 *in, AuUInt64 addend) -{ - return static_cast(_InterlockedExchangeAdd64(reinterpret_cast(in), static_cast(addend)) + static_cast(addend)); -} -#endif - -template <> -inline auline AuUInt32 AuAtomicUtils::Add(AuUInt32 *in, AuUInt32 addend) -{ - return static_cast(_InterlockedExchangeAdd(reinterpret_cast(in), static_cast(addend)) + static_cast(addend)); -} - -#if !defined(AURORA_IS_32BIT) -template <> -inline auline AuInt64 AuAtomicUtils::Add(AuInt64 *in, AuInt64 addend) -{ - return _InterlockedExchangeAdd64(reinterpret_cast(in), static_cast(addend)) + static_cast(addend); -} -#endif - -template <> -inline auline AuInt32 AuAtomicUtils::Add(AuInt32 *in, AuInt32 addend) -{ - return _InterlockedExchangeAdd(reinterpret_cast(in), static_cast(addend)) + static_cast(addend); -} - -// TODO: -#if 0 -template <> -inline auline AuUInt16 AuAtomicUtils::Add(AuUInt16 *in, AuUInt16 addend) -{ - return {}; -} -#endif - - -template <> -inline auline AuUInt64 AuAtomicUtils::Sub(AuUInt64 *in, AuUInt64 minuend) -{ - return Add(in, AuUInt64(0) - minuend); -} - -template <> -inline auline AuUInt32 AuAtomicUtils::Sub(AuUInt32 *in, AuUInt32 minuend) -{ - return Add(in, AuUInt32(0) - minuend); -} - -// TODO: -#if 0 -template <> -inline auline AuUInt16 AuAtomicUtils::Sub(AuUInt16 *in, AuUInt16 minuend) -{ - return {}; -} - -#endif - -#if !defined(AURORA_IS_32BIT) -template <> -inline auline AuUInt64 AuAtomicUtils::Set(AuUInt64 *in, AuUInt8 offset) -{ - return _InterlockedOr64(reinterpret_cast(in), AuUInt64(1) << offset); -} -#endif - -template <> -inline auline AuUInt32 AuAtomicUtils::Set(AuUInt32 *in, AuUInt8 offset) -{ - return _InterlockedOr(reinterpret_cast(in), 1 << offset); -} - -template <> -inline auline AuUInt16 AuAtomicUtils::Set(AuUInt16 *in, AuUInt8 offset) -{ - return _InterlockedOr16(reinterpret_cast(in), 1 << offset); -} - -#if !defined(AURORA_IS_32BIT) -template <> -inline auline AuInt64 AuAtomicUtils::Set(AuInt64 *in, AuUInt8 offset) -{ - return _InterlockedOr64(reinterpret_cast(in), AuUInt64(1) << offset); -} -#endif - -template <> -inline auline AuInt32 AuAtomicUtils::Set(AuInt32 *in, AuUInt8 offset) -{ - return _InterlockedOr(reinterpret_cast(in), 1 << offset); -} - -template <> -inline auline long AuAtomicUtils::Set(long *in, AuUInt8 offset) -{ - return _InterlockedOr(reinterpret_cast(in), 1 << offset); -} - -template <> -inline auline unsigned long AuAtomicUtils::Set(unsigned long *in, AuUInt8 offset) -{ - return _InterlockedOr(reinterpret_cast(in), 1 << offset); -} - -template <> -inline auline AuInt16 AuAtomicUtils::Set(AuInt16 *in, AuUInt8 offset) -{ - return _InterlockedOr16(reinterpret_cast(in), 1 << offset); -} - -#elif defined(AURORA_COMPILER_CLANG) || defined(AURORA_COMPILER_GCC) - -template -inline auline T AuAtomicUtils::CompareExchange(T *in, T replace, T compare) -{ - return __sync_val_compare_and_swap(in, compare, replace); -} - -template -inline auline T AuAtomicUtils::Add(T *in, T addend) -{ - return __sync_add_and_fetch(in, addend); -} - -template -inline auline T AuAtomicUtils::Sub(T *in, T minuend) -{ - return __sync_sub_and_fetch(in, minuend); -} - -template -inline auline T AuAtomicUtils::Set(T *in, AuUInt8 offset) -{ - return __sync_fetch_and_or(in, T(1) << offset); -} - -#endif - -template -inline auline bool AuAtomicUtils::TestAndSet(T *in, const AuUInt8 offset) -{ - return AuAtomicUtils::Set(in, offset) & (1 << offset); -} - -#if defined(AURORA_COMPILER_MSVC) && (defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86)) - -template <> -inline auline bool AuAtomicUtils::TestAndSet(unsigned long *in, const AuUInt8 offset) -{ - return _interlockedbittestandset(reinterpret_cast(in), offset); -} - -template <> -inline auline bool AuAtomicUtils::TestAndSet(long *in, const AuUInt8 offset) -{ - return _interlockedbittestandset(reinterpret_cast(in), offset); -} - -template <> -inline auline bool AuAtomicUtils::TestAndSet(AuUInt32 *in, const AuUInt8 offset) -{ - return _interlockedbittestandset(reinterpret_cast(in), offset); -} - -template <> -inline auline bool AuAtomicUtils::TestAndSet(AuInt32 *in, const AuUInt8 offset) -{ - return _interlockedbittestandset(reinterpret_cast(in), offset); -} - -#if !defined(AURORA_IS_32BIT) -template <> -inline auline bool AuAtomicUtils::TestAndSet(AuUInt64 *in, const AuUInt8 offset) -{ - return _interlockedbittestandset64(reinterpret_cast(in), offset); -} - -template <> -inline auline bool AuAtomicUtils::TestAndSet(AuInt64 *in, const AuUInt8 offset) -{ - return _interlockedbittestandset64(reinterpret_cast(in), offset); -} -#endif - -#endif - -template -auline -T AuAtomicSet(T *in, AuUInt8 offset) -{ - return AuAtomicUtils::Set(in, offset); -} - -template -auline -T AuAtomicAdd(T *in, T addend) -{ - return AuAtomicUtils::Add(in, addend); -} - -template -auline -T AuAtomicSub(T *in, T minuend) -{ - return AuAtomicUtils::Sub(in, minuend); -} - -template -auline -T AuAtomicCompareExchange(T *in, T replace, T compare) -{ - return AuAtomicUtils::CompareExchange(in, replace, compare); -} - -template -auline -bool AuAtomicTestAndSet(T *in, AuUInt8 offset) -{ - return AuAtomicUtils::TestAndSet(in, offset); -} \ No newline at end of file diff --git a/Include/auROXTL/auBST.hpp b/Include/auROXTL/auBST.hpp deleted file mode 100644 index ead7f6a3..00000000 --- a/Include/auROXTL/auBST.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auBST.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -#if !defined(AURORA_RUNTIME_AU_BST) - #define AURORA_RUNTIME_AU_BST std::map -#endif - -#include "auHashUtils.hpp" - -template > -using AuBST = AURORA_RUNTIME_AU_BST; \ No newline at end of file diff --git a/Include/auROXTL/auBitsUtils.hpp b/Include/auROXTL/auBitsUtils.hpp deleted file mode 100644 index 8addbb35..00000000 --- a/Include/auROXTL/auBitsUtils.hpp +++ /dev/null @@ -1,222 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auBitsUtils.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -template -static auline bool AuTestBit(T value, AuUInt8 idx) -{ - return value & (T(1) << T(idx)); -} - -template -static auline void AuSetBit(T &value, AuUInt8 idx) -{ - value |= T(1) << T(idx); -} - -template -static auline void AuClearBit(T &value, AuUInt8 idx) -{ - value &= ~(T(1) << T(idx)); -} - -template -static auline bool AuBitScanForward(AuUInt8 &index, T value) -{ - unsigned long ret; - bool success; - - success = false; - index = 0; - -#if defined(AURORA_COMPILER_MSVC) - if constexpr (sizeof(T) == sizeof(AuUInt64)) - #if defined(AURORA_IS_32BIT) - if (!_BitScanForward(&ret, static_cast(value & 0xffffffff))) - { - if (!_BitScanForward(&ret, static_cast((value >> 32) & 0xffffffff))) - { - return false; - } - ret += 32; - } - #else - success = _BitScanForward64(&ret, static_cast(value)); - #endif - else success = _BitScanForward(&ret, static_cast(value)); -#elif defined(AURORA_COMPILER_GCC) || defined(AURORA_COMPILER_CLANG) - if (value == 0) - { - return false; - } - - if constexpr (sizeof(T) == sizeof(AuUInt64)) - { - #if defined(AURORA_IS_32BIT) - auto lower = static_cast(value & 0xffffffff)); - if (lower == 0) - { - ret = __builtin_ctzl(static_cast((value >> 32) & 0xffffffff)); - ret += 32; - } - else - { - ret = __builtin_ctzl(static_cast(lower)); - } - #else - ret = __builtin_ctzll(static_cast(value)); - #endif - } - else if constexpr (sizeof(T) == sizeof(unsigned long)) - { - ret = __builtin_ctzl(static_cast(value)); - } - else if constexpr (sizeof(T) == sizeof(unsigned int)) - { - ret = __builtin_ctz(static_cast(value)); - } - - success = true; -#endif - index = ret; - return success; -} - -template -struct AuHalfWord -{ - using ReturnType_t = AuConditional_t, AuUInt32, AuConditional_t, AuUInt32, AuConditional_t, AuUInt8, AuFalseType>>>; - - static ReturnType_t ToLower(T in) - { - if constexpr (AuIsSame_v) - { - return in & AuUInt64(0xFFFFFFFF); - } - else if constexpr (AuIsSame_v) - { - return in & 0xFFFF; - } - else if constexpr (AuIsSame_v) - { - return in & 0xFF; - } - else - { - return {}; - } - } - - static ReturnType_t ToHigher(T in) - { - if constexpr (AuIsSame_v) - { - return (in >> AuUInt64(32)) & AuUInt64(0xFFFFFFFF); - } - else if constexpr (AuIsSame_v) - { - return (in >> 16) & 0xFFFF; - } - else if constexpr (AuIsSame_v) - { - return (in >> 8) & 0xFF; - } - else - { - return {}; - } - } -}; - -template -static auto AuBitsToLower(T in) -{ - return AuHalfWord::ToLower(in); -} - -template -static auto AuBitsToHigher(T in) -{ - return AuHalfWord::ToHigher(in); -} - -template -static AuUInt8 AuPopCnt(T in) -{ -#if defined(AURORA_COMPILER_MSVC) - #if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86) - #if defined(AURORA_ARCH_X64) - if constexpr (sizeof(T) == sizeof(AuUInt64)) - { - return _mm_popcnt_u64(static_cast(in)); - } - else - #endif - if constexpr (sizeof(T) == sizeof(unsigned int)) - { - return __popcnt(static_cast(in)); - } - else if constexpr (sizeof(T) <= sizeof(AuUInt16)) - { - return __popcnt16(static_cast(in)); - } - #endif -#else - if constexpr (sizeof(T) == sizeof(unsigned long long)) - { - return __builtin_popcountll(static_cast(in)); - } - else if constexpr (sizeof(T) == sizeof(unsigned long)) - { - return __builtin_popcountl(static_cast(in)); - } - else if constexpr (sizeof(T) == sizeof(unsigned int)) - { - return __builtin_popcount(static_cast(in)); - } -#endif - -#if defined(AU_CPU_ENDIAN_LITTLE) - if constexpr (sizeof(T) == sizeof(AuUInt64)) - { - const AuUInt64 m1 = 0x5555555555555555ll; - const AuUInt64 m2 = 0x3333333333333333ll; - const AuUInt64 m4 = 0x0F0F0F0F0F0F0F0Fll; - const AuUInt64 h01 = 0x0101010101010101ll; - - in -= (in >> 1) & m1; - in = (in & m2) + ((in >> 2) & m2); - in = (in + (in >> 4)) & m4; - - return (in * h01) >> 56; - } - else if constexpr (sizeof(T) == sizeof(AuUInt32)) - { - const AuUInt32 m1 = 0x55555555l; - const AuUInt32 m2 = 0x33333333l; - const AuUInt32 m4 = 0x0F0F0F0Fl; - const AuUInt32 h01 = 0x01010101l; - - in -= (in >> 1) & m1; - in = (in & m2) + ((in >> 2) & m2); - in = (in + (in >> 4)) & m4; - - return (in * h01) >> 24; - } -#endif - - if constexpr ((sizeof(T) == sizeof(AuUInt16)) || - (sizeof(T) == sizeof(AuUInt8))) - { - return AuPopCnt(AuUInt32(in)); - } - - return {}; -} - -// TODO: AuBitScanReverse \ No newline at end of file diff --git a/Include/auROXTL/auCastUtils.hpp b/Include/auROXTL/auCastUtils.hpp deleted file mode 100644 index 099e407b..00000000 --- a/Include/auROXTL/auCastUtils.hpp +++ /dev/null @@ -1,136 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auCastUtils.hpp - Date: 2022-2-10 - Author: Reece -***/ -#pragma once - -template -static constexpr AuSPtr AuStaticCast(const AuSPtr &other) -{ - return AuSPtr(other, static_cast(other.get())); -} - -template -static constexpr AuSPtr AuStaticCast(AuSPtr &&other) -{ - return AuSPtr(AuMove(other), static_cast(other.get())); -} - -template -static constexpr AuConditional_t, T, T *> AuStaticCast(Z *other) -{ - return static_cast, T, T *>>(other); -} - -template )> -static constexpr AuConditional_t, T, T &> AuStaticCast(Z &other) -{ - return static_cast, T, T &>>(AuForward(other)); -} - -template )> -static constexpr AuConditional_t, T, T &&> AuStaticCast(Z &&other) -{ - return static_cast, T, T &&>>(AuMove(other)); -} - -template && !AuIsPointer_v)> -static constexpr T AuStaticCast(Z other) -{ - return static_cast(other); -} - -template -static constexpr AuConditional_t, T, T *> AuConstCast(Z *other) -{ - return const_cast, T, T *>>(other); -} - -template )> -static constexpr AuConditional_t, T, T &> AuConstCast(Z &other) -{ - return const_cast, T, T &>>(AuForward(other)); -} - -template )> -static constexpr AuConditional_t, T, T &&> AuConstCast(Z &&other) -{ - return const_cast, T, T &&>>(AuMove(other)); -} - -template -static constexpr AuSPtr AuConstCast(const AuSPtr &other) -{ - return AuSPtr(other, const_cast(other.get())); -} - -template -static constexpr AuSPtr AuConstCast(AuSPtr &&other) -{ - return AuSPtr(AuMove(other), const_cast(other.get())); -} - -template -static constexpr AuConditional_t && !AuIsPointer_v && AuIsPointer_v, T *, T> AuReinterpretCast(Z other) -{ - return reinterpret_cast && !AuIsPointer_v &&AuIsPointer_v, T *, T>>(other); -} - -template -static constexpr AuSPtr AuReinterpretCast(const AuSPtr &other) -{ - return AuSPtr(other, reinterpret_cast(other.get())); -} - -template -static constexpr AuSPtr AuReinterpretCast(AuSPtr &&other) -{ - return AuSPtr(AuMove(other), reinterpret_cast(other.get())); -} - -template -static T *AuDynamicCast(Z *other) -{ - return dynamic_cast(other); -} - -template -static AuSPtr AuDynamicCast(const AuSPtr &other) -{ - return AuSPtr(other, dynamic_cast(other.get())); -} - -template -static AuSPtr AuDynamicCast(AuSPtr &&other) -{ - return AuSPtr(AuMove(other), dynamic_cast(other.get())); -} - -template -static AuOptional> AuOptionalSharedDynamicCast(AuOptional> &in) -{ - if (!in.has_value()) return {}; - return AuDynamicCast(in.value()); -} - -template -static AuOptional> AuOptionalSharedStaticCast(AuOptional> &in) -{ - if (!in.has_value()) return {}; - return AuStaticPointerCast(in.value()); -} - -template -static AuSPtr AuStaticPointerCast(const AuSPtr &other) noexcept -{ - return AuSPtr(other, static_cast::element_type *>(other.get())); -} - -template -static AuSPtr AuStaticPointerCast(AuSPtr &&other) noexcept -{ - return AuSPtr(AuMove(other), static_cast::element_type *>(other.get())); -} \ No newline at end of file diff --git a/Include/auROXTL/auContainerUtils.hpp b/Include/auROXTL/auContainerUtils.hpp deleted file mode 100644 index 864565be..00000000 --- a/Include/auROXTL/auContainerUtils.hpp +++ /dev/null @@ -1,589 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auContainerUtils.hpp - Date: 2022-2-1 - File: AuroraUtils.hpp - File: auROXTLUtils.hpp - Date: 2021-6-9 - Author: Reece -***/ -#pragma once - -#include - -namespace __audetail -{ - template - struct AuHascapacity - { - template static constexpr AuTrueType Test(decltype(&C::capacity)); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); - }; - - template - constexpr inline bool AuHascapacity_v = AuHascapacity::type::value; - - template - struct AuHasreserve - { - template static constexpr AuTrueType Test(decltype(&C::reserve)); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); - }; - - template - constexpr inline bool AuHasreserve_v = AuHasreserve::type::value; - - template - constexpr inline bool AuIsPreallocatable_v = AuHascapacity_v && AuHasreserve_v; - - template - struct AuHastry_emplace - { - template static constexpr AuTrueType Test(decltype(&C::try_emplace)); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); - }; - - template - constexpr inline bool AuHastry_emplace_v = false;// ::type::value; - - template - struct AuHasemplace - { - template static constexpr AuTrueType Test(decltype(&C::emplace)); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); - }; - - template - constexpr inline bool AuHasemplace_v = true;//AuHasemplace::type::value; - - template - struct AuHasfind - { - template static constexpr AuTrueType Test(decltype(static_cast(&C::find))); - template static constexpr AuTrueType Test(decltype(static_cast(&C::find))); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); - }; - - template - constexpr inline bool AuHasfind_v = AuHasfind::type::value; - - template - struct AuHasend - { - template static constexpr AuTrueType Test(decltype(static_cast(&C::end))); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); - }; - - template - constexpr inline bool AuHasend_v = AuHasend::type::value; -} - -template -inline bool _AuRemoveIfBase(T &in, const AuPredicate &> &predicate); - -template -inline bool AuRemoveAllIf(T &in, const AuPredicate &> &predicate) -{ - return _AuRemoveIfBase(in, predicate); -} - -template -inline bool AuRemoveIf(T &in, const AuPredicate &> &predicate) -{ - return _AuRemoveIfBase(in, predicate); -} - -template -inline void AuRemove(T &in, const Z &type) -{ - auto itr = in.find(type); - if (itr == in.end()) - { - return; - } - in.erase(itr); -} - -template -inline void AuRemoveRange(T &in, AuUInt index, AuUInt length) -{ - if (index + length > in.size()) - { - return; - } - - auto begin = in.begin(); - auto end = begin; - - std::advance(begin, index); - std::advance(end, index + length); - - while (begin != end) - { - in.erase(begin++); - } -} - -template -inline bool AuTryRemoveRange(T &in, AuUInt index, AuUInt length) -{ - AUROXTL_COMMODITY_TRY - { - if (index + length > in.size()) - { - return false; - } - - auto begin = in.begin(); - auto end = begin; - - std::advance(begin, index); - std::advance(end, index + length); - - while (begin != end) - { - in.erase(begin++); - } - } - AUROXTL_COMMODITY_CATCH - { - return false; - } - - return true; -} - -template && !AuIsPointer_v)> -inline bool AuTryFind(Map &map, const Key &key, Value *&ptr) -{ - auto itr = map.find(key); - if (itr != map.end()) - { - ptr = &itr->second; - return true; - } - else - { - ptr = nullptr; - return false; - } -} - -template -inline bool AuTryFind(Map *map, const Key &key, Value *&ptr) -{ - return AuTryFind(*map, key, ptr); -} - -template -inline auto AuTryFindByTupleN(List &list, const Key &key) -{ - for (auto itr = list.begin(); itr != list.end(); ) - { - if (AuGet(*itr) == key) - { - return itr; - } - else - { - itr++; - } - } - return list.end(); -} - -template && !AuIsPointer_v)> -inline bool AuExists(const Range &a, const Key &key) -{ - return std::find(a.begin(), a.end(), key) != a.end(); -} - -template && !AuIsPointer_v)> -inline bool AuExists(const Map &map, const Key &key) -{ - auto itr = map.find(key); - if (itr != map.end()) - { - return true; - } - else - { - return false; - } -} - -template -inline bool AuExists(const Map *map, const Key &key) -{ - return AuExists(*map, key); -} - -template -inline bool AuTryClear(Container &container) -{ - container.clear(); - return true; -} - -template && !AuIsPointer_v)> -inline bool AuTryRemove(Range &list, const Key &key) -{ - auto itr = std::find(list.begin(), list.end(), key); - if (itr != list.end()) - { - list.erase(itr); - return true; - } - else - { - return false; - } -} - -template && !AuIsPointer_v)> -inline bool AuTryRemove(Map &map, const Key &key) -{ - auto itr = map.find(key); - if (itr != map.end()) - { - map.erase(itr); - return true; - } - else - { - return false; - } -} - -template -inline bool AuTryRemove(Map *map, const Key &key) -{ - return AuTryRemove(*map, key); -} - -template -inline bool AuTryRemoveByTupleN(List &list, const Key &key) -{ - for (auto itr = list.begin(); itr != list.end(); ) - { - if (AuGet(*itr) == key) - { - itr = list.erase(itr); - return true; - } - else - { - itr++; - } - } - - return false; -} - -template -inline bool AuTryInsert(Container &container, Key_t &&key, Type_t &&value, bool overwriteMode = true) -{ - AUROXTL_COMMODITY_TRY - { - auto itr = container.find(key); - if (itr == container.end()) - { - #if defined(_AURORA_NULLEXPT_USE_TRY_EMPLACE_AFTER_FIND) - if constexpr (__audetail::AuHastry_emplace_v) - { - auto [iterator, success] = container.try_emplace(AuMove(key), AuMove(value)); - return success; - } - else - #endif - if constexpr (__audetail::AuHasemplace_v) - { - container.emplace(AuMove(key), AuMove(value)); - return true; - } - else - { - container.insert(AuMakePair(AuMove(key), AuMove(value))); - } - } - else - { - if (!overwriteMode) - { - return false; - } - itr->second = AuMove(value); - } - return true; - } - AUROXTL_COMMODITY_CATCH - { - return false; - } -} - -template -inline bool AuTryInsert(Container &container, const Key_t &key, Type_t &&value, bool overwriteMode = true) -{ - AUROXTL_COMMODITY_TRY - { - auto itr = container.find(key); - if (itr == container.end()) - { - #if defined(_AURORA_NULLEXPT_USE_TRY_EMPLACE_AFTER_FIND) - if constexpr (__audetail::AuHastry_emplace_v) - { - auto [iterator, success] = container.try_emplace(key, AuMove(value)); - return success; - } - else - #endif - if constexpr (__audetail::AuHasemplace_v) - { - container.emplace(key, AuMove(value)); - return true; - } - else - { - container.insert(AuMakePair(key, AuMove(value))); - } - } - else - { - if (!overwriteMode) - { - return false; - } - itr->second = AuMove(value); - } - return true; - } - AUROXTL_COMMODITY_CATCH - { - return false; - } -} - -template -inline bool AuContainerExpandOne(Container &container) -{ - auto required = container.size() + 1; - if (container.capacity() >= required) - { - return true; - } - - container.reserve(required); - return container.capacity() >= required; -} - -template -inline bool AuContainerExpandOne(Container *container) -{ - return AuContainerExpandOne(*container); -} - -template && !AuIsPointer_v)> -inline bool AuTryInsert(Container &container, const Value &value) -{ - AUROXTL_COMMODITY_TRY - { - if constexpr (__audetail::AuIsPreallocatable_v>) - { - if (!AuContainerExpandOne(container)) - { - return false; - } - } - - container.insert(AuReference(value)); - - return true; - } - AUROXTL_COMMODITY_CATCH - { - return false; - } -} - -template && !AuIsPointer_v)> -inline bool AuTryInsert(Container &container, Value &&value) -{ - AUROXTL_COMMODITY_TRY - { - if constexpr (__audetail::AuIsPreallocatable_v>) - { - if (!AuContainerExpandOne(container)) - { - return false; - } - } - - container.insert(AuMove(value)); - - return true; - } - AUROXTL_COMMODITY_CATCH - { - return false; - } -} - -template && !AuIsPointer_v)> -inline bool AuTryInsert(Container &container, Value &&value) -{ - AUROXTL_COMMODITY_TRY - { - if constexpr (__audetail::AuIsPreallocatable_v>) - { - if (!AuContainerExpandOne(container)) - { - return false; - } - } - - container.insert(container.end(), AuMove(value)); - - return true; - } - AUROXTL_COMMODITY_CATCH - { - return false; - } -} - -template && !AuIsPointer_v)> -inline bool AuTryInsert(Container &container, const Value &value) -{ - AUROXTL_COMMODITY_TRY - { - if constexpr (__audetail::AuIsPreallocatable_v>) - { - if (!AuContainerExpandOne(container)) - { - return false; - } - } - - container.insert(container.end(), value); - - return true; - } - AUROXTL_COMMODITY_CATCH - { - return false; - } -} - -template -inline bool AuTryInsert(Map *map, Key &&key, Value &&value, bool overwriteMode = true) -{ - return AuTryInsert(*map, AuMove(key), AuMove(value), overwriteMode); -} - -template -inline bool AuTryInsert(Map *map, const Key &key, Value &&value, bool overwriteMode = true) -{ - return AuTryInsert(*map, AuReference(key), AuMove(value), overwriteMode); -} - -template -inline bool AuTryInsert(Map *map, Value &&value) -{ - return AuTryInsert(*map, AuMove(value)); -} - -template -inline bool AuTryInsert(Map *map, const Value &value) -{ - return AuTryInsert(*map, value); -} - -namespace Aurora::Memory -{ - struct ByteBuffer; -} - -template -inline bool AuTryResize(T &list, AuUInt length) -{ - AUROXTL_COMMODITY_TRY - { - if constexpr (AuIsSame_v) - { - return list.Resize(length); - } - else - { - list.resize(length); - return true; - } - } - AUROXTL_COMMODITY_CATCH - { - return false; - } -} - -template -inline bool AuTryDownsize(T &list, AuUInt length) -{ - AUROXTL_COMMODITY_TRY - { - if constexpr (AuIsSame_v) - { - if (!list.Resize(length)) - { - return false; - } - - list.GC(); - return true; - } - else - { - list.resize(length); - list.shrink_to_fit(); - return true; - } - } - AUROXTL_COMMODITY_CATCH - { - return false; - } -} - -template -inline bool _AuRemoveIfBase(T &in, const AuPredicate &> &predicate) -{ - bool retOne {}; - - for (auto itr = in.begin(); itr != in.end(); ) - { - if (predicate(*itr)) - { - itr = in.erase(itr); - if constexpr (!all) - { - return true; - } - - retOne = true; - } - else - { - itr++; - } - } - - // optimization hint - if constexpr (all) return retOne; - return {}; -} \ No newline at end of file diff --git a/Include/auROXTL/auCopyMoveUtils.hpp b/Include/auROXTL/auCopyMoveUtils.hpp deleted file mode 100644 index 01f4b2c1..00000000 --- a/Include/auROXTL/auCopyMoveUtils.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auCopyMoveUtils.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -/** - * @brief Upcasts R-Value upcastable @param arg. - * For an L-Value equivalent hint, use AuReference - * @tparam T - * @param arg - * @return -*/ -template -auline constexpr AuRemoveReference_t &&AuMove(T &&arg) noexcept -{ - return static_cast &&>(arg); -} - -/** - * @brief Upcasts L-Value upcastable @param arg. - * For an R-Value equivalent hint, use AuMove - * @tparam T An expression to implicitly upcast to an L-value - * @param arg - * @return -*/ -template -auline constexpr T &AuReference(T &arg) noexcept -{ - return static_cast(arg); -} - -/** - * @brief Preserves R or L value without reducing; implicit AuMove or AuReference - * @tparam T An expression to implicitly upcast to an R-value - * @param arg - * @return -*/ -template -auline constexpr T &&AuForward(AuRemoveReference_t &arg) noexcept -{ - return static_cast(arg); -} - -/** - * @brief Preserves R or L value without reducing; implicit AuMove or AuReference - * @tparam T - * @param arg - * @return -*/ -template -auline constexpr T &&AuForward(AuRemoveReference_t &&arg) noexcept -{ - return static_cast(arg); -} \ No newline at end of file diff --git a/Include/auROXTL/auEndianness.hpp b/Include/auROXTL/auEndianness.hpp deleted file mode 100644 index 0c4e5c7e..00000000 --- a/Include/auROXTL/auEndianness.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auEndianness.hpp - Date: 2022-2-6 - Author: Reece -***/ -#pragma once - -template -struct AuEndianUtils -{ - static T Swap(T in); -}; - -template -inline T AuEndianUtils::Swap(T in) -{ - if constexpr (sizeof(T) == 8) - return (T(in) & 0xFF) << T(56) | - (T(in >> T(8)) & T(0xFF)) << T(48) | - (T(in >> T(16)) & T(0xFF)) << T(40) | - (T(in >> T(24)) & T(0xFF)) << T(32) | - (T(in >> T(32)) & T(0xFF)) << T(24) | - (T(in >> T(40)) & T(0xFF)) << T(16) | - (T(in >> T(48)) & T(0xFF)) << T(8) | - (T(in >> T(56)) & T(0xFF)); - - if constexpr (sizeof(T) == 4) - return T(in & 0xFF) << 24 | - (T(in >> 8) & 0xFF) << 16 | - (T(in >> 16) & 0xFF) << 8 | - (T(in >> 24) & 0xFF); - - if constexpr (sizeof(T) == 2) - return (in & 0xFF) << 8 | - ((in >> 8) & 0xFF); - - return in; -} - -#if defined(AURORA_COMPILER_MSVC) - -template <> -inline AuUInt64 AuEndianUtils::Swap(AuUInt64 in) -{ - return _byteswap_uint64(in); -} - -template <> -inline AuUInt32 AuEndianUtils::Swap(AuUInt32 in) -{ - return _byteswap_ulong(in); -} - -template <> -inline unsigned long AuEndianUtils::Swap(unsigned long in) -{ - return _byteswap_ulong(in); -} - -template <> -inline AuUInt16 AuEndianUtils::Swap(AuUInt16 in) -{ - return _byteswap_ushort(in); -} - -#elif defined(AURORA_COMPILER_CLANG) - -template <> -inline AuUInt64 AuEndianUtils::Swap(AuUInt64 in) -{ - return __builtin_bswap64(in); -} - -template <> -inline AuUInt32 AuEndianUtils::Swap(AuUInt32 in) -{ - return __builtin_bswap32(in); -} - -template <> -inline AuUInt16 AuEndianUtils::Swap(AuUInt16 in) -{ - return __builtin_bswap16(in); -} - -#endif - -template -inline auline Type_t AuFlipEndian(Type_t in) -{ - return AuEndianUtils::Swap(in); -} \ No newline at end of file diff --git a/Include/auROXTL/auFNV1Utils.hpp b/Include/auROXTL/auFNV1Utils.hpp deleted file mode 100644 index 474d9a84..00000000 --- a/Include/auROXTL/auFNV1Utils.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auFNV1Utils.hpp - Date: 2022-3-23 - File: fnv1.hpp - Date: 2021-6-10 - Author: Reece -***/ -#pragma once - -#include "auTypeUtils.hpp" - -// Note: we're too early for AuroraEnv.hpp w/ AuroraEnums -#if defined(AURORA_IS_32BIT) - #define _AU_FNV1_32 1 -#else - #define _AU_FNV1_32 0 -#endif - -constexpr AuUInt64 kFnv1MagicVal64 = 0xcbf29ce484222325; -constexpr AuUInt64 kFnv1MagicPrime64 = 0x100000001b3; -constexpr AuUInt32 kFnv1MagicVal32 = 0x811c9dc5; -constexpr AuUInt32 kFnv1MagicPrime32 = 0x01000193; - -constexpr auto kFnv1MagicValPlatform = _AU_FNV1_32 ? kFnv1MagicVal32 : kFnv1MagicVal64; -constexpr auto kFnv1MagicPrimePlatform = _AU_FNV1_32 ? kFnv1MagicPrime32 : kFnv1MagicPrime64; - -inline constexpr AuUInt64 AuFnv1a64(const char *const str, const AuUInt64 value = kFnv1MagicVal64) noexcept -{ - return (str[0] == '\0') ? value : AuFnv1a64(&str[1], (value ^ AuUInt64(str[0])) * kFnv1MagicPrime64); -} - -inline constexpr AuUInt32 AuFnv1aTrunc(const char *const str) noexcept -{ - return static_cast(AuFnv1a64(str)); -} - -inline constexpr AuUInt32 AuFnv1a32(const char *const str, const AuUInt32 value = kFnv1MagicVal32) noexcept -{ - return (str[0] == '\0') ? value : AuFnv1a32(&str[1], (value ^ AuUInt32(str[0])) * kFnv1MagicPrime32); -} - -inline constexpr AuUInt AuFnv1aType(const char *type, AuUInt size, AuUInt index, const AuUInt value) noexcept -{ - return (index == size) ? value : AuFnv1aType(type + 1, size, index + 1, (value ^ AuUInt(*type) * kFnv1MagicPrimePlatform)); -} - -template -inline constexpr AuUInt AuFnv1aType(const T &type, const AuUInt value = kFnv1MagicValPlatform) noexcept -{ - return AuFnv1aType(((const char *)&type) + 1, sizeof(T), 1, (value ^ AuUInt(*(const char *)&type) * kFnv1MagicPrimePlatform)); -} - -inline constexpr auto AuFnv1a(const char *const str) noexcept -{ - return _AU_FNV1_32 ? AuFnv1a32(str) : AuFnv1a64(str); -} - -inline AuUInt32 AuFnv1a32Runtime(const void *base, AuUInt length) noexcept -{ - AuUInt32 result {kFnv1MagicVal32}; - - AuUInt i {}; - for (; i < length; i++) - { - result ^= AuUInt(AuReadU8(base, i)) * kFnv1MagicPrime32; - } - - return result; -} - -inline AuUInt64 AuFnv1a64Runtime(const void *base, AuUInt length) noexcept -{ - AuUInt64 result {kFnv1MagicVal64}; - - AuUInt i {}; - for (; i < length; i++) - { - result ^= AuUInt64(AuReadU8(base, i)) * kFnv1MagicPrime64; - } - - return result; -} - -#undef _AU_FNV1_32 \ No newline at end of file diff --git a/Include/auROXTL/auFunctional.hpp b/Include/auROXTL/auFunctional.hpp deleted file mode 100644 index 8a06d444..00000000 --- a/Include/auROXTL/auFunctional.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auFunctional.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -#if !defined(AURORA_RUNTIME_AU_FUNC) - #define AURORA_RUNTIME_AU_FUNC std::function -#endif - -template -using AuFunction = AURORA_RUNTIME_AU_FUNC; - -template -using AuPredicate = AuFunction; - -using AuVoidFunc = AuFunction; - -template -using AuConsumer = AuFunction; - -template -using AuSupplier = AuFunction; - -template -using AuSupplierConsumer = AuFunction; \ No newline at end of file diff --git a/Include/auROXTL/auHashMap.hpp b/Include/auROXTL/auHashMap.hpp deleted file mode 100644 index b1946790..00000000 --- a/Include/auROXTL/auHashMap.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auHashMap.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -#if !defined(AURORA_RUNTIME_AU_HASH_MAP) - #define AURORA_RUNTIME_AU_HASH_MAP std::unordered_map -#endif - -#include "auHashUtils.hpp" - -template , class Equal_t = AuHash::equal> -using AuHashMap = AURORA_RUNTIME_AU_HASH_MAP; \ No newline at end of file diff --git a/Include/auROXTL/auHashUtils.hpp b/Include/auROXTL/auHashUtils.hpp deleted file mode 100644 index 8fda96f0..00000000 --- a/Include/auROXTL/auHashUtils.hpp +++ /dev/null @@ -1,143 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auHashUtils.hpp - Date: 2022-3-23 - Author: Reece -***/ -#pragma once - -#include "auFNV1Utils.hpp" - -#define _AU_HASH_UTILS_HAS_STD - -template -struct AuHasHashCode -{ - template static constexpr AuTrueType Test(decltype(&C::HashCode)); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); -}; - -template -constexpr inline bool AuHasHashCode_v = AuHasHashCode::type::value; - -namespace AuHash -{ - template - struct hash - { - #if defined(_AU_HASH_UTILS_HAS_STD) - AuConditional_t, AuUInt8, std::hash> trashHasher; - #endif - - AuUInt operator()(const Key &ref) const - { - if constexpr (AuHasHashCode_v) - { - return ref.HashCode(); - } - #if defined(_AU_HASH_UTILS_HAS_STD) - else - { - return trashHasher(ref); - } - #endif - } - }; - -#define _HASH_F_CPP(type) \ - template <> \ - struct hash \ - { \ - constexpr AuUInt operator ()(const type b) const \ - { \ - return AuFnv1aType(b); \ - } \ - }; - - _HASH_F_CPP(bool); - _HASH_F_CPP(char); - _HASH_F_CPP(signed char); - _HASH_F_CPP(unsigned char); - _HASH_F_CPP(char8_t); - _HASH_F_CPP(char16_t); - _HASH_F_CPP(char32_t); - _HASH_F_CPP(wchar_t); - _HASH_F_CPP(short); - _HASH_F_CPP(unsigned short); - _HASH_F_CPP(int); - _HASH_F_CPP(unsigned int); - _HASH_F_CPP(long); - _HASH_F_CPP(long long); - _HASH_F_CPP(unsigned long); - _HASH_F_CPP(unsigned long long); - _HASH_F_CPP(float); - _HASH_F_CPP(double); - _HASH_F_CPP(long double); - _HASH_F_CPP(std::nullptr_t); - -#undef _HASH_F_CPP - - template struct hash - { - AuUInt operator ()(T *ptr) const - { - #if defined(AURORA_IS_32BIT) - return AuFnv1a32Runtime(&ptr, sizeof(T *)); - #else - return AuFnv1a64Runtime(&ptr, sizeof(T *)); - #endif - } - }; - - template - struct less - { - constexpr bool operator()(const T &lhs, const T &rhs) const - { - if constexpr (AuHasHashCode_v) - { - return lhs.HashCode() < rhs.HashCode(); - } - else - { - return lhs < rhs; - } - } - }; - - template - struct equal - { - constexpr bool operator()(const T &lhs, const T &rhs) const - { - return lhs == rhs; - } - }; -} - -template )> -inline AuUInt AuHashCode(const T &ref) -{ - return ref.HashCode(); -} - -template )> -inline AuUInt AuHashCode(const T &ref) -{ - return AuHash::hash()(ref); -} - -template -struct AuEnableHashCodeOnData -{ - AuUInt HashCode() const - { - #if defined(AURORA_IS_32BIT) - return AuFnv1a32Runtime(AuStaticCast>(this), sizeof(T)); - #else - return AuFnv1a64Runtime(AuStaticCast>(this), sizeof(T)); - #endif - } -}; \ No newline at end of file diff --git a/Include/auROXTL/auIntegerSequence.hpp b/Include/auROXTL/auIntegerSequence.hpp deleted file mode 100644 index 9ec5f93e..00000000 --- a/Include/auROXTL/auIntegerSequence.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auIntegerSequence.hpp - Date: 2022-3-25 - Author: Reece -***/ -#pragma once - -template -struct AuIntegerSequence -{ - using value_type = T; - - inline constexpr AuUInt size() - { - return sizeof...(Args); - } -}; - -template -#if defined(AURORA_COMPILER_GCC) - using AuMakeIntegerSequence = std::make_integer_sequence; -#else - using AuMakeIntegerSequence = __make_integer_seq; -#endif - -template -using AuMakeIndexSequence = AuMakeIntegerSequence; - -template -using AuIndexSequence = AuIntegerSequence; - -template -using AuIndexSequenceFor = AuMakeIndexSequence; \ No newline at end of file diff --git a/Include/auROXTL/auList.hpp b/Include/auROXTL/auList.hpp deleted file mode 100644 index af6395d0..00000000 --- a/Include/auROXTL/auList.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auList.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -#if !defined(AURORA_RUNTIME_AU_LIST) - #define AURORA_RUNTIME_AU_LIST std::vector -#endif - -#include "auMemoryModel.hpp" - -#if defined(AURORA_ROXTL_CONTAINERS_USE_PURE) - - template - using AuList = AURORA_RUNTIME_AU_LIST; - -#else - - template - using AuList = AURORA_RUNTIME_AU_LIST, - Aurora::Memory::ClassArrayAllocator, - Aurora::Memory::PrimitiveArrayAllocator - > - >; - -#endif \ No newline at end of file diff --git a/Include/auROXTL/auListUtils.hpp b/Include/auROXTL/auListUtils.hpp deleted file mode 100644 index 713b2617..00000000 --- a/Include/auROXTL/auListUtils.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auListUtils.hpp - Date: 2022-3-27 - Author: Reece -***/ -#pragma once - -template -constexpr bool AuListFromArgs(T &list, Args && ... args) -{ - constexpr auto end = sizeof...(Args); - if (!AuTryResize(list, end)) - { - return false; - } - - AuUInt i = 0; - (..., (list[i++] = AuMove(args))); - return true; -} diff --git a/Include/auROXTL/auMagicUtils.hpp b/Include/auROXTL/auMagicUtils.hpp deleted file mode 100644 index 7c2f211b..00000000 --- a/Include/auROXTL/auMagicUtils.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auMagicUtils.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -/** - * @brief - * @param buffer - * @return A non-determinstic/platform specific magic number that once written with respect to endianness emits the tag -*/ -static constexpr auline AuUInt32 AuConvertMagicTag32(const char buffer[4]) -{ - AuUInt32 magic {}; - if (Aurora::Build::kCurrentEndian == Aurora::Build::ECPUEndian::eCPULittle) - { - magic |= AuUInt32(buffer[0]); - magic |= AuUInt32(buffer[1]) << 8; - magic |= AuUInt32(buffer[2]) << 16; - magic |= AuUInt32(buffer[3]) << 24; - } - else - { - magic |= AuUInt32(buffer[4]); - magic |= AuUInt32(buffer[2]) << 8; - magic |= AuUInt32(buffer[1]) << 16; - magic |= AuUInt32(buffer[0]) << 24; - } - return magic; -} - -/** - * @brief - * @param buffer - * @return A non-determinstic/platform specific magic number that once written with respect to endianness emits the tag -*/ -static constexpr auline AuUInt64 AuConvertMagicTag64(const char buffer[8]) -{ - AuUInt64 magic {}; - if (Aurora::Build::kCurrentEndian == Aurora::Build::ECPUEndian::eCPULittle) - { - magic |= AuUInt64(buffer[0]); - magic |= AuUInt64(buffer[1]) << 8; - magic |= AuUInt64(buffer[2]) << 16; - magic |= AuUInt64(buffer[3]) << 24; - magic |= AuUInt64(buffer[4]) << 32; - magic |= AuUInt64(buffer[5]) << 40; - magic |= AuUInt64(buffer[6]) << 48; - magic |= AuUInt64(buffer[7]) << 56; - } - else - { - magic |= AuUInt64(buffer[7]); - magic |= AuUInt64(buffer[6]) << 8; - magic |= AuUInt64(buffer[5]) << 16; - magic |= AuUInt64(buffer[4]) << 24; - magic |= AuUInt64(buffer[3]) << 32; - magic |= AuUInt64(buffer[2]) << 40; - magic |= AuUInt64(buffer[1]) << 48; - magic |= AuUInt64(buffer[0]) << 56; - } - return magic; -} \ No newline at end of file diff --git a/Include/auROXTL/auMemoryModel.hpp b/Include/auROXTL/auMemoryModel.hpp deleted file mode 100644 index 14110a91..00000000 --- a/Include/auROXTL/auMemoryModel.hpp +++ /dev/null @@ -1,221 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auMemoryModel.hpp - Date: 2022-2-1 - File: AuroraUtils.hpp - File: auROXTLUtils.hpp - Date: 2021-6-9 - Author: Reece -***/ -#pragma once - -#include "auTypes.hpp" - -#if !defined(AURORA_RUNTIME_AU_SHARED_PTR) - #define AURORA_RUNTIME_AU_SHARED_PTR std::shared_ptr -#endif - -#if !defined(AURORA_RUNTIME_AU_WEAK_PTR) - #define AURORA_RUNTIME_AU_WEAK_PTR std::weak_ptr -#endif - -template -using AuWPtr = AURORA_RUNTIME_AU_WEAK_PTR; - -#if !defined(AURORA_RUNTIME_AU_UNIQUE_PTR) - #define AURORA_RUNTIME_AU_UNIQUE_PTR std::unique_ptr -#endif - -#if !defined(AURORA_RUNTIME_AU_DEFAULT_DELETER) - #define AURORA_RUNTIME_AU_DEFAULT_DELETER std::default_delete -#endif - -template -using AuDefaultDeleter = AURORA_RUNTIME_AU_DEFAULT_DELETER; - -#include "STLShims/ExtendStlLikeSharedPtr.hpp" - -template -using AuSPtr = typename Aurora::Memory::ExSharedPtr>; - -template -using AuUPtr = AURORA_RUNTIME_AU_UNIQUE_PTR; - -#if !defined(AU_AuEnableSharedFromThis) -#define AU_AuEnableSharedFromThis - -template -struct AuEnableSharedFromThis : Aurora::Memory::ExSharedFromThis> -{}; - -#endif - -#if !defined(AURORA_RUNTIME_MAKE_SHARED) - #define AURORA_RUNTIME_MAKE_SHARED std::make_shared -#endif - -template -static auline AuSPtr AuMakeShared(Args&&... args) -{ - try - { - return AURORA_RUNTIME_MAKE_SHARED(AuForward(args)...); - } - catch (...) - { - return {}; - } -} - -namespace __audetail -{ - struct Dummy - { - char a; - }; - - inline AuSPtr GetDummyDeleter() - { - static AuSPtr d; - if (!d) - { - #if defined(AURORA_COMPILER_MSVC) - return d; - #endif - d = AuMakeShared(); - } - return d; - } -} - -template -static auline AuSPtr AuMakeSharedArray(AuUInt count) -{ - try - { - #if defined(AU_LANG_CPP_20) && 0 - return AURORA_RUNTIME_AU_SHARED_PTR(count); - #else - return AURORA_RUNTIME_AU_SHARED_PTR(new T[count], AuDefaultDeleter()); - #endif - } - catch (...) - { - return {}; - } -} - -template -static AuSPtr AuUnsafeRaiiToShared(T *in) -{ - return AuSPtr(__audetail::GetDummyDeleter(), in); -} - -template -static AuSPtr AuUnsafeRaiiToShared(const AuUPtr &in) -{ - return AuUnsafeRaiiToShared(in.get()); -} - -template -static constexpr int AuArraySize(const T(&array)[Z]) -{ - return Z; -} - -#if defined(DEBUG) || defined(STAGING) - -template -static auline void AU_NORETURN SysPanic(T... args); - -template -static void auline AuSafeDelete(T *in) -{ - static_assert(AuIsBaseOf_v>, "Couldn't not safe delete from type T because it is not derived from Z"); - - if (in == nullptr) - { - Z re; - SysPanic("Tried to free: 0x{:x}, type \"{}\" / \"{}\"", AuUInt(in), typeid(in).name(), typeid(re).name()); - } - - delete static_cast(in); -} - -#else - -template -static void auline AuSafeDelete(T *in) -{ - static_assert(AuIsBaseOf_v>, "Couldn't not safe delete from type T because it is not derived from Z"); - delete static_cast(in); -} - -#endif - -namespace Aurora::Memory -{ -#if defined(AURORA_ROXTL_ALLOCATORS_USE_STD) - - template - using PrimitiveArrayAllocator = std::allocator; - - template - using ClassArrayAllocator = std::allocator; - - template - using StringAllocator = std::allocator; - -#else - - static void *__FAlloc(Types::size_t length, Types::size_t align); - static void __Free(void *buffer); - - template - struct BaseAuroraRuntimeAllocator - { - typedef T value_type; - - AU_COPY_MOVE(BaseAuroraRuntimeAllocator) - - constexpr BaseAuroraRuntimeAllocator() - {} - - template constexpr BaseAuroraRuntimeAllocator(const BaseAuroraRuntimeAllocator &) noexcept - { - } - - inline [[nodiscard]] constexpr T* allocate(Types::size_t n) - { - if (auto p = (__FAlloc(n * sizeof(T), alignof(T)))) - { - return AuReinterpretCast(p); - } - - throw std::bad_alloc(); - } - - inline constexpr void deallocate(T *p, std::size_t n) noexcept - { - __Free(p); - } - - inline bool operator==(const BaseAuroraRuntimeAllocator &op) - { - return true; - } - }; - - - template - using PrimitiveArrayAllocator = BaseAuroraRuntimeAllocator; - - template - using ClassArrayAllocator = BaseAuroraRuntimeAllocator; - - template - using StringAllocator = BaseAuroraRuntimeAllocator; - -#endif -} \ No newline at end of file diff --git a/Include/auROXTL/auMemoryUtils.hpp b/Include/auROXTL/auMemoryUtils.hpp deleted file mode 100644 index fe65e381..00000000 --- a/Include/auROXTL/auMemoryUtils.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auMemoryUtils.hpp - Date: 2022-2-1 - File: AuroraUtils.hpp - File: auROXTLUtils.hpp - Date: 2021-6-9 - Author: Reece -***/ -#pragma once - -#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); -} \ No newline at end of file diff --git a/Include/auROXTL/auNumberUtils.hpp b/Include/auROXTL/auNumberUtils.hpp deleted file mode 100644 index d1a735b3..00000000 --- a/Include/auROXTL/auNumberUtils.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auNumberUtils.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -template -constexpr const T &AuMin(const T &a, const T &b) -{ - return a < b ? a : b; -} - -template -constexpr const T &AuMax(const T &a, const T &b) -{ - return a < b ? b : a; -} - -template -constexpr const T AuConstPow(const T base, const AuUInt8 exponent) -{ - return exponent ? base * AuConstPow(base, exponent - 1) : 1; -} - -template -constexpr const T AuPageRoundUp(const T value, const T pageSize) -{ - return (value + (pageSize - 1)) & ~(pageSize - 1); -} - -template -constexpr const T AuPageRound(const T value, const T pageSize) -{ - return value & ~(pageSize - 1); -} \ No newline at end of file diff --git a/Include/auROXTL/auNumericLimits.hpp b/Include/auROXTL/auNumericLimits.hpp deleted file mode 100644 index 7813e8c1..00000000 --- a/Include/auROXTL/auNumericLimits.hpp +++ /dev/null @@ -1,131 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auNumericLimits.hpp - Date: 2022-2-19 - Author: Reece -***/ -#pragma once - -template -struct _AuNonStdLimits -{ - using Type = T; - - static const bool is_signed = IsSigned; - static const bool is_integer = IsInteger; - - static constexpr Type min() - { - return Min; - } - - static constexpr Type max() - { - return Max; - } - - static constexpr Type epsilon() - { - return Epsilon; - } -}; - - -template -struct AuNumericLimits; - -#define _AU_LIMITS_ADD(bits) \ - \ -template <> \ -struct AuNumericLimits : _AuNonStdLimits(AuInt ## bits(-1)), 1, false, true> \ -{ \ - \ -}; \ - \ -template <> \ -struct AuNumericLimits : _AuNonStdLimits(2, bits - 1) - 1)) - 1, AuInt ## bits(AuConstPow(2, bits - 1) - 1), 1, true, true> \ -{ \ - \ -}; - -_AU_LIMITS_ADD(8) -_AU_LIMITS_ADD(16) -_AU_LIMITS_ADD(32) -_AU_LIMITS_ADD(64) - -#undef _AU_LIMITS_ADD - -#if defined(AURORA_COMPILER_MSVC) - -template <> -struct AuNumericLimits : AuNumericLimits -{}; - -template <> -struct AuNumericLimits : AuNumericLimits -{}; - -#endif - -// TODO: clang x86 and x64 will need different hacks for [unsigned] long long - -template <> -struct AuNumericLimits : _AuNonStdLimits -{}; - -template <> -struct AuNumericLimits : AuNumericLimits -{}; - -template <> -struct AuNumericLimits : AuNumericLimits -{}; - -template -struct _AuNonStdLimitsFP -{ - using Type = T; - - static const bool is_signed = true; - static const bool is_integer = false; -}; - -template <> -struct AuNumericLimits : _AuNonStdLimitsFP -{ - static double max() - { - return 340282346638528859811704183484516925440.0000000000000000; - } - - static double min() - { - return -340282346638528859811704183484516925440.0000000000000000; - } - - static constexpr double epsilon() - { - return 0.000000000000000111; - } - -}; - -template <> -struct AuNumericLimits : _AuNonStdLimitsFP -{ - static double max() - { - return 1.7976931348623157e+308; - } - - static double min() - { - return -2.2250738585072014e-308; - } - - static constexpr double epsilon() - { - return 0.000000000000000111; - } -}; \ No newline at end of file diff --git a/Include/auROXTL/auOptional.hpp b/Include/auROXTL/auOptional.hpp deleted file mode 100644 index 21933a3b..00000000 --- a/Include/auROXTL/auOptional.hpp +++ /dev/null @@ -1,15 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auOptional.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -#if !defined(AURORA_RUNTIME_AU_OPTIONAL) - #define AURORA_RUNTIME_AU_OPTIONAL std::optional -#endif - -template -using AuOptional = AURORA_RUNTIME_AU_OPTIONAL; \ No newline at end of file diff --git a/Include/auROXTL/auOptionalEx.hpp b/Include/auROXTL/auOptionalEx.hpp deleted file mode 100644 index 1c9bd143..00000000 --- a/Include/auROXTL/auOptionalEx.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auOptionalEx.hpp - Date: 2022-3-23 - Author: Reece -***/ -#pragma once - -#include "auCopyMoveUtils.hpp" -#include "auHashUtils.hpp" - -template -struct AuOptionalEx -{ - bool hasValue; - T type; - - AuOptionalEx() : hasValue({}) - {} - - AuOptionalEx(T &value) : type(value), hasValue(true) - {} - - AuOptionalEx(T &&value) : type(value), hasValue(true) - {} - - T &Value() - { - return type; - } - - const T &Value() const - { - return type; - } - - template - constexpr T ValueOr(U &&defaultValue) const & - { - return bool(*this) ? value() : static_cast(AuForward(defaultValue)); - - } - template - constexpr T ValueOr(U &&defaultValue) && - { - return bool(*this) ? AuMove(value()) : static_cast(AuForward(defaultValue)); - } - - bool HasValue() const - { - return this->hasValue; - } - - operator bool() const - { - return this->hasValue; - } - - T &value() - { - return this->type; - } - - const T &value() const - { - return this->type; - } - - bool has_value() const - { - return this->hasValue; - } - - AuUInt HashCode() const - { - return AuHashCode(type); - } - - void Reset() - { - this->type = {}; - this->hasValue = {}; - } - - void Swap(AuOptionalEx &&ex) - { - AuSwap(this->type, ex.type); - AuSwap(this->hasValue, ex.hasValue); - } -}; \ No newline at end of file diff --git a/Include/auROXTL/auPosixUtils.hpp b/Include/auROXTL/auPosixUtils.hpp deleted file mode 100644 index f06cfa79..00000000 --- a/Include/auROXTL/auPosixUtils.hpp +++ /dev/null @@ -1,9 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auPosixUtils.hpp - Date: 2022-2-6 - Author: Reece -***/ -#pragma once - diff --git a/Include/auROXTL/auResult.hpp b/Include/auROXTL/auResult.hpp deleted file mode 100644 index bb8f993f..00000000 --- a/Include/auROXTL/auResult.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auResult.hpp - Date: 2022-3-23 - Author: Reece -***/ -#pragma once - -#include "auCopyMoveUtils.hpp" -#include "auHashUtils.hpp" - -template -struct AuResult -{ - bool success; - T type; - - AuResult() : success() - {} - - AuResult(bool success) : success(success) - {} - - AuResult(T &&value) : type(value), success(true) - {} - - // I could be pulling this out of my ass, but i'd assume with callee provided stack space being provided through arg0 in most abis, - // and with the callers binary originating from a file in which contains the T declaration, i'd assume it would be faster to chuck - // the return value in the callers' stack **and** access it by reference in the callee, rather than assigning a value using move - // constructors/assignment operators whenever the data is available. - // Feels like a landmine of accidental allocates: - // ...what is the default constructor doing in the caller? (hopefully nothing) - // ...does the object even support move semantics? (would AuResult(AuMove(t)) result in a copy no matter what?) - // - // generally recommend ::GetResult() - - T &GetResult() - { - return type; - } - - constexpr const T *operator->() const - { - return &type; - } - - constexpr T *operator->() - { - return &type; - } - - const T &GetResult() const - { - return type; - } - - void Complete() - { - this->success = true; - } - - operator bool() const - { - return this->success; - } -}; \ No newline at end of file diff --git a/Include/auROXTL/auString.hpp b/Include/auROXTL/auString.hpp deleted file mode 100644 index b2de5e24..00000000 --- a/Include/auROXTL/auString.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auString.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -//#include "tinyutf8.h" -//#define AU_STRING_IS_TINYUTF_EXPERIMENT - -#if defined(AURORA_ROXTL_CONTAINERS_USE_PURE) - using AuString = std::string; -#elif defined(AURORA_ROXTL_STRING_USE_STR_ALLOCATOR) - template , Aurora::Memory::StringAllocator>> - struct _AuStdExString : Base_t - { - using Base_t::Base_t; - - _AuStdExString(const std::string &str) : Base_t(str.begin(), str.end()) - {} - }; - - using AuString = _AuStdExString<>; -#else - using AuString = std::string; -#endif \ No newline at end of file diff --git a/Include/auROXTL/auStringUtils.hpp b/Include/auROXTL/auStringUtils.hpp deleted file mode 100644 index e75291a3..00000000 --- a/Include/auROXTL/auStringUtils.hpp +++ /dev/null @@ -1,123 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auStringUtils.hpp - Date: 2022-2-1 - File: AuroraUtils.hpp - File: auROXTLUtils.hpp - Date: 2021-6-9 - Author: Reece -***/ -#pragma once - -static auline bool AuStringContains(const AuString &value, const AuString &subpattern) -{ - return value.find(subpattern) != AuString::npos; -} - -static auline bool AuEndsWith(AuString const &value, AuString const &ending) -{ - if (ending.size() > value.size()) return false; - return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); -} - -static auline bool AuStartsWith(AuString const &value, AuString const &starting) -{ -#if defined(AU_STRING_IS_TINYUTF_EXPERIMENT) - return value.starts_with(starting); -#else - return value.rfind(starting, 0) == 0; -#endif -} - -#if defined(AU_STRING_IS_TINYUTF_EXPERIMENT) - -static AuString AuStringTransform(const AuString &in, const AuSupplierConsumer &out) -{ - AuString cpy = in; - for (int i = 0; i < cpy.length(); i++) - { - cpy[i] = out(cpy[i]); - } - return cpy; -} - -static auline AuString AuToUpper(const AuString &in) -{ - return AuStringTransform(in, std::toupper); -} - - -static auline AuString AuToLower(const AuString &in) -{ - return AuStringTransform(in, std::toupper); -} - -#else - -template -static auline AuString AuToStringASCIIOp(T op, const AuString &in) -{ - AuString ret; - ret.resize(in.size()); - std::transform(in.begin(), in.end(), ret.begin(), [=](const char &c) - { - return op(c); - }); - return ret; -} - -static auline AuString AuToLower(const AuString &in) -{ - return AuToStringASCIIOp(std::tolower, in); -} - -static auline AuString AuToUpper(const AuString &in) -{ - return AuToStringASCIIOp(std::toupper, in); -} -#endif - -static auline AuString AuReplaceAll(AuString &str, const AuString &from, const AuString &to) -{ - size_t start_pos = 0; - while ((start_pos = str.find(from, start_pos)) != std::string::npos) - { - str.replace(start_pos, from.length(), to); - start_pos += to.length(); // Handles case where 'to' is a substring of 'from' - } - return str; // :( -} - -// i told myself not to copy this, required a split function twice, now here we are :D -static auline AuList AuSplitString(const AuString &str, const AuString &delim, bool ignoreEmpty = true) -{ - AuList tokens; - AuUInt prev = 0, pos = 0; - do - { - pos = str.find(delim, prev); - if (pos == AuString::npos) pos = str.length(); - auto token = str.substr(prev, pos - prev); - if ((!token.empty()) && ignoreEmpty) tokens.push_back(token); - prev = pos + delim.length(); - } - while (pos < str.length() && prev < str.length()); - return tokens; -} - -#if !defined(AURORA_RUNTIME_TO_STRING) - #define AURORA_RUNTIME_TO_STRING std::to_string -#endif - -template -static auline AuString AuToString(const T &obj) -{ -#if defined(_AUHAS_FMT) - // locale independent and better optimized! - return fmt::format("{}", obj); -#else - // TODO: to_chars (locale independent) - return AURORA_RUNTIME_TO_STRING(obj); -#endif -} \ No newline at end of file diff --git a/Include/auROXTL/auSwapExchangeUtils.hpp b/Include/auROXTL/auSwapExchangeUtils.hpp deleted file mode 100644 index 810486c3..00000000 --- a/Include/auROXTL/auSwapExchangeUtils.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - File: auSwapExchangeUtils.hpp - Date: 2022-3-27 - Author: Reece -***/ -#pragma once - -template -inline T AuExchange(T &obj, U &&newValue) -{ - T oldValue = AuMove(obj); - obj = AuForward(newValue); - return oldValue; -} - -#if !defined(AURORA_RUNTIME_SWAP) - #define AURORA_RUNTIME_SWAP std::swap -#endif -template -inline void AuSwap(T &a, T &b) -{ - AURORA_RUNTIME_SWAP(a, b); -} \ No newline at end of file diff --git a/Include/auROXTL/auTemplateMeta.hpp b/Include/auROXTL/auTemplateMeta.hpp deleted file mode 100644 index 07a74fb2..00000000 --- a/Include/auROXTL/auTemplateMeta.hpp +++ /dev/null @@ -1,341 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: auTemplateMeta.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -template -struct AuBoolType -{ - static constexpr bool value = v; - using value_type = bool; - using type = AuBoolType; - - constexpr operator value_type() const noexcept - { - return value; - } - - constexpr value_type operator()() const noexcept - { - return value; - } -}; - -using AuFalseType = AuBoolType; -using AuTrueType = AuBoolType; - -#include "auTemplateMetaIsFunction.hpp" - -template -using AuToValueType_t = typename T::value_type; - -template -using AuToElementType_t = typename T::element_type; - -template -using AuToIterator_t = typename T::iterator; - -template -struct AuIsSame : AuFalseType -{}; - -template -struct AuIsSame : AuTrueType -{}; - -template -inline constexpr bool AuIsSame_v = AuIsSame::value; - -namespace _audetail -{ - template - AuBoolType IsClass(int T:: *); - - template - AuFalseType IsClass(...); - - template - AuTrueType TestIsPtrConvertible(const volatile B *); - template - AuFalseType TestIsPtrConvertible(const volatile void *); - - template - auto TestIsBaseOf(...)->AuTrueType; - - template - auto TestIsBaseOf(int) -> decltype(TestIsPtrConvertible(static_cast(nullptr))); -} - -template -struct AuIsClass : decltype(_audetail::IsClass(nullptr)) -{}; - -template -inline constexpr bool AuIsClass_v = AuIsClass::value; - -template -struct AuIsBaseOf : - AuBoolType< - AuIsClass_v && - AuIsClass_v && - decltype(_audetail::TestIsBaseOf(0))::value - > -{}; - -template -inline constexpr bool AuIsBaseOf_v = AuIsBaseOf::value; - -template -inline constexpr bool AuIsPointer_v = false; - -template -inline constexpr bool AuIsPointer_v = true; - -template -inline constexpr bool AuIsPointer_v = true; - -template -inline constexpr bool AuIsPointer_v = true; - -template -inline constexpr bool AuIsPointer_v = true; - -template -inline constexpr bool AuIsReference_v = false; - -template -inline constexpr bool AuIsReference_v = true; - -template -inline constexpr bool AuIsReference_v = true; - -template -inline constexpr bool AuIsLValueReference_v = false; - -template -inline constexpr bool AuIsLValueReference_v = true; - -template -inline constexpr bool AuIsRValueReference_v = false; - -template -inline constexpr bool AuIsRValueReference_v = true; - -template -struct AuRemovePointer -{ - typedef T type; -}; - -template -struct AuRemovePointer -{ - typedef T type; -}; - -template -struct AuRemovePointer -{ - typedef T type; -}; - -template -struct AuRemovePointer -{ - typedef T type; -}; - -template -struct AuRemovePointer -{ - typedef T type; -}; - -template -using AuRemovePointer_t = typename AuRemovePointer::type; - -template -using AuIsVoid = AuIsSame; - -template -inline constexpr bool AuIsVoid_v = AuIsVoid::value; - -template -struct AuRemoveReference -{ - using type = T; -}; - -template -struct AuRemoveReference -{ - using type = T; -}; - -template -struct AuRemoveReference -{ - using type = T; -}; - -template -using AuRemoveReference_t = typename AuRemoveReference::type; - -template -struct AuRemoveConst -{ - typedef T type; -}; - -template -struct AuRemoveConst -{ - typedef T type; -}; - -template -using AuRemoveConst_t = typename AuRemoveConst::type; - -template -struct AuEnableIf -{}; - -template -struct AuEnableIf -{ - using type = T; -}; - -template -struct AuAddPointer -{ - using type = AuRemoveReference_t *; -}; - -template -using AuAddPointer_t = typename AuAddPointer::type; - -template -struct AuAddLReference -{ - using type = AuRemoveReference_t &; -}; - -template -using AuAddLReference_t = typename AuAddLReference::type; - -template -struct AuAddRReference -{ - using type = AuRemoveReference_t &&; -}; - -template -using AuAddRReference_t = typename AuAddRReference::type; - -template -AuAddRReference_t AuDeclVal(); - -template -struct AuAddConst -{ - using type = const T; -}; - -template -using AuAddConst_t = typename AuAddConst::type; - -template -using AuAddRemoveCV_t = AuRemoveConst_t>; - -template -struct AuRemoveExtent -{ - using type = T; -}; - -template -struct AuRemoveExtent -{ - using type = T; -}; - -template -struct AuRemoveExtent -{ - using type = T; -}; - -template -using AuRemoveExtent_t = typename AuRemoveExtent::type; - -template -constexpr inline bool AuIsArray_v = false; - -template -inline constexpr bool AuIsArray_v = true; - -template -inline constexpr bool AuIsArray_v = true; - -template -using AuEnableIf_t = typename AuEnableIf::type; - -template -struct AuIsConstructible -{ - template static constexpr AuTrueType Test(decltype(T(AuDeclVal()...))); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); -}; - -template -using AuIsConstructible_t = typename AuIsConstructible::type; - -template -inline constexpr bool AuIsConstructible_v = AuIsConstructible_t::value; - -template -struct AuConditional -{ - using type = T; -}; - -template -struct AuConditional -{ - using type = T2; -}; - -template -using AuConditional_t = typename AuConditional::type; - -template -using AuDecay_t = AuConditional_t< - AuIsArray_v, - AuAddPointer_t>, - AuConditional_t< - AuIsFunction_v, - AuAddPointer_t, - AuAddRemoveCV_t - > ->; - -template