From bb89dd6509b109df76fbf42d3507e5513ca9168f Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Fri, 8 Apr 2022 17:29:05 +0800 Subject: [PATCH] refactor(miscellaneous): renamed builtin type, add fixed-width character type --- .../Source/Public/Memory/Alignment.h | 8 +-- .../Public/Miscellaneous/CoreMiscDefines.h | 2 +- .../Source/Public/Miscellaneous/Platform.h | 65 ++++++++++--------- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/Redcraft.Utility/Source/Public/Memory/Alignment.h b/Redcraft.Utility/Source/Public/Memory/Alignment.h index 58ae027..d7b4a9b 100644 --- a/Redcraft.Utility/Source/Public/Memory/Alignment.h +++ b/Redcraft.Utility/Source/Public/Memory/Alignment.h @@ -14,7 +14,7 @@ FORCEINLINE constexpr T Align(T InValue, size_t Alignment) { static_assert(TIsIntegral::Value || TIsPointer::Value, "Align expects an integer or pointer type"); - return (T)(((uintptr_t)(InValue) + static_cast(Alignment) - 1) & ~(static_cast(Alignment) - 1)); + return (T)(((uintptr)(InValue) + static_cast(Alignment) - 1) & ~(static_cast(Alignment) - 1)); } template @@ -22,7 +22,7 @@ FORCEINLINE constexpr T AlignDown(T InValue, size_t Alignment) { static_assert(TIsIntegral::Value || TIsPointer::Value, "AlignDown expects an integer or pointer type"); - return (T)((uintptr_t)(InValue) & ~(static_cast(Alignment) - 1)); + return (T)((uintptr)(InValue) & ~(static_cast(Alignment) - 1)); } template @@ -30,7 +30,7 @@ FORCEINLINE constexpr T AlignArbitrary(T InValue, size_t Alignment) { static_assert(TIsIntegral::Value || TIsPointer::Value, "AlignArbitrary expects an integer or pointer type"); - return (T)((((uintptr_t)(InValue) + static_cast(Alignment) - 1) / static_cast(Alignment)) * static_cast(Alignment)); + return (T)((((uintptr)(InValue) + static_cast(Alignment) - 1) / static_cast(Alignment)) * static_cast(Alignment)); } template @@ -38,7 +38,7 @@ FORCEINLINE constexpr bool IsAligned(T InValue, size_t Alignment) { static_assert(TIsIntegral::Value || TIsPointer::Value, "IsAligned expects an integer or pointer type"); - return !((uintptr_t)(InValue) & (static_cast(Alignment) - 1)); + return !((uintptr)(InValue) & (static_cast(Alignment) - 1)); } NAMESPACE_END(Memory) diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/CoreMiscDefines.h b/Redcraft.Utility/Source/Public/Miscellaneous/CoreMiscDefines.h index 154e7d2..4ee256a 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/CoreMiscDefines.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/CoreMiscDefines.h @@ -17,7 +17,7 @@ NAMESPACE_MODULE_BEGIN(Utility) #define NO_UNIQUE_ADDRESS [[no_unique_address]] constexpr size_t INDEX_NONE = -1; -constexpr WIDECHAR UNICODE_BOM = 0xfeff; +constexpr charw UNICODE_BOM = 0xfeff; struct FForceInit { explicit FForceInit() = default; }; struct FNoInit { explicit FNoInit() = default; }; diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h b/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h index 0d9dc3b..04f50ec 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h @@ -68,25 +68,25 @@ NAMESPACE_MODULE_BEGIN(Utility) #if PLATFORM_WINDOWS -# define VARARGS __cdecl -# define CDECL __cdecl -# define STDCALL __stdcall -# define FORCEINLINE __forceinline -# define FORCENOINLINE __declspec(noinline) -# define RESTRICT __restrict +# define VARARGS __cdecl +# define CDECL __cdecl +# define STDCALL __stdcall +# define FORCEINLINE __forceinline +# define FORCENOINLINE __declspec(noinline) +# define RESTRICT __restrict #elif PLATFORM_LINUX # define VARARGS # define CDECL # define STDCALL -# define FORCENOINLINE __attribute__((noinline)) -# define RESTRICT __restrict +# define FORCENOINLINE __attribute__((noinline)) +# define RESTRICT __restrict # if BUILD_DEBUG -# define FORCEINLINE inline +# define FORCEINLINE inline # else -# define FORCEINLINE inline __attribute__ ((always_inline)) +# define FORCEINLINE inline __attribute__ ((always_inline)) # endif #else @@ -96,7 +96,7 @@ NAMESPACE_MODULE_BEGIN(Utility) # define STDCALL # define FORCEINLINE # define FORCENOINLINE -# define RESTRICT __restrict +# define RESTRICT __restrict #endif @@ -104,13 +104,13 @@ NAMESPACE_MODULE_BEGIN(Utility) #if PLATFORM_WINDOWS -# define DLLEXPORT __declspec(dllexport) -# define DLLIMPORT __declspec(dllimport) +# define DLLEXPORT __declspec(dllexport) +# define DLLIMPORT __declspec(dllimport) #elif PLATFORM_LINUX -# define DLLEXPORT __attribute__((visibility("default"))) -# define DLLIMPORT __attribute__((visibility("default"))) +# define DLLEXPORT __attribute__((visibility("default"))) +# define DLLIMPORT __attribute__((visibility("default"))) #else @@ -121,31 +121,34 @@ NAMESPACE_MODULE_BEGIN(Utility) // Unsigned base types. -typedef NAMESPACE_STD::uint8_t uint8; -typedef NAMESPACE_STD::uint16_t uint16; -typedef NAMESPACE_STD::uint32_t uint32; -typedef NAMESPACE_STD::uint64_t uint64; +typedef NAMESPACE_STD::uint8_t uint8; +typedef NAMESPACE_STD::uint16_t uint16; +typedef NAMESPACE_STD::uint32_t uint32; +typedef NAMESPACE_STD::uint64_t uint64; // Signed base types. -typedef NAMESPACE_STD::int8_t int8; -typedef NAMESPACE_STD::int16_t int16; -typedef NAMESPACE_STD::int32_t int32; -typedef NAMESPACE_STD::int64_t int64; +typedef NAMESPACE_STD::int8_t int8; +typedef NAMESPACE_STD::int16_t int16; +typedef NAMESPACE_STD::int32_t int32; +typedef NAMESPACE_STD::int64_t int64; // Character types. -typedef char ANSICHAR; -typedef wchar_t WIDECHAR; -typedef WIDECHAR TCHAR; +typedef char chara; +typedef wchar_t charw; +typedef charw chart; +typedef char8_t char8; +typedef char16_t char16; +typedef char32_t char32; // Pointer types. -typedef NAMESPACE_STD::uintptr_t uintptr_t; -typedef NAMESPACE_STD::intptr_t intptr_t; -typedef NAMESPACE_STD::ptrdiff_t ptrdiff_t; -typedef NAMESPACE_STD::size_t size_t; -typedef intptr_t ssize_t; +typedef NAMESPACE_STD::uintptr_t uintptr; +typedef NAMESPACE_STD::intptr_t intptr; +typedef NAMESPACE_STD::ptrdiff_t ptrdiff; +typedef NAMESPACE_STD::size_t size_t; +typedef intptr_t ssize_t; // Null types.