From 4605c0a682eaf8d2ddb78e73d9daad2ce5e700d3 Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Fri, 3 Dec 2021 22:55:37 +0800 Subject: [PATCH] refactor(*): change namespace relationships and fix name errors --- .../Source/Public/Misc/CoreDefines.h | 7 ++- .../Source/Public/Platform/Platform.h | 59 ++++--------------- 2 files changed, 17 insertions(+), 49 deletions(-) diff --git a/Redcraft.Utility/Source/Public/Misc/CoreDefines.h b/Redcraft.Utility/Source/Public/Misc/CoreDefines.h index 06976ea..5bfa19c 100644 --- a/Redcraft.Utility/Source/Public/Misc/CoreDefines.h +++ b/Redcraft.Utility/Source/Public/Misc/CoreDefines.h @@ -33,11 +33,11 @@ // Define the unnamed namespace #define NAMESPACE_UNNAMED_BEGIN namespace { #define NAMESPACE_UNNAMED_END } - -// Create an alias for the namespace - like typedef -#define NAMESPACE_DEFINE(Source, Target) NAMESPACE_BEGIN(Target) NAMESPACE_USING(Source) NAMESPACE_END(Target) +#define NAMESPACE_INLINE_UNNAMED_BEGIN inline namespace { +#define NAMESPACE_INLINE_UNNAMED_END } NAMESPACE_REDCRAFT_BEGIN +NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) enum { INDEX_NONE = -1 }; @@ -46,4 +46,5 @@ enum { UNICODE_BOM = 0xfeff }; enum EForceInit { ForceInit }; NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Platform/Platform.h b/Redcraft.Utility/Source/Public/Platform/Platform.h index 214595f..a21d895 100644 --- a/Redcraft.Utility/Source/Public/Platform/Platform.h +++ b/Redcraft.Utility/Source/Public/Platform/Platform.h @@ -6,6 +6,7 @@ #include NAMESPACE_REDCRAFT_BEGIN +NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) // Build information macro. @@ -66,18 +67,18 @@ NAMESPACE_MODULE_BEGIN(Utility) #if PLATFORM_WINDOWS -# define VARARGS __cdecl -# define CDECL __cdecl -# define NAMESPACE_STDCALL __NAMESPACE_STDcall -# define FORCEINLINE __forceinline -# define FORCENOINLINE __declspec(noinline) +# 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 NAMESPACE_STDCALL +# define STDCALL # define FORCENOINLINE __attribute__((noinline)) # define RESTRICT __restrict @@ -91,59 +92,24 @@ NAMESPACE_MODULE_BEGIN(Utility) # define VARARGS # define CDECL -# define NAMESPACE_STDCALL +# define STDCALL # define FORCEINLINE # define FORCENOINLINE # define RESTRICT __restrict #endif -// Alignment. - -#if PLATFORM_WINDOWS - -# if defined(__clang__) - -# define GCC_PACK(n) __attribute__((packed,aligned(n))) -# define GCC_ALIGN(n) __attribute__((aligned(n))) - -# if defined(_MSC_VER) -# define MS_ALIGN(n) __declspec(align(n)) -# endif - -# else - -# define GCC_PACK(n) -# define GCC_ALIGN(n) -# define MS_ALIGN(n) __declspec(align(n)) - -# endif - -#elif PLATFORM_LINUX - -# define GCC_PACK(n) __attribute__((packed,aligned(n))) -# define GCC_ALIGN(n) __attribute__((aligned(n))) -# define MS_ALIGN(n) - -#else - -# define GCC_PACK(n) -# define GCC_ALIGN(n) -# define MS_ALIGN(n) - -#endif - // DLL export and import definitions. #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 @@ -200,4 +166,5 @@ typedef NAMESPACE_STD::nullptr_t nullptr_t; #define TEXT(x) TEXT_PASTE(x) NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END