From 5ce8bfa259c6fb9356d3cc7e5e47b1e79bc0b4e0 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 23 Jul 2023 22:25:19 -0400 Subject: [PATCH] Added macros to make the gen namespace optional. --- project/gen.cpp | 5 ++--- project/gen.dep.hpp | 14 ++++++++++---- project/gen.hpp | 24 +++++++++++------------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/project/gen.cpp b/project/gen.cpp index f1d4318..ccd0190 100644 --- a/project/gen.cpp +++ b/project/gen.cpp @@ -14,7 +14,7 @@ #include "gen.hpp" -namespace gen { +GEN_NS_BEGIN #pragma region StaticData // TODO : Convert global allocation strategy to use a slab allocation strategy. @@ -6606,7 +6606,6 @@ void Builder::write() } #pragma endregion Builder -// namespace gen -} +GEN_NS_END #include "gen.pop_ignores.inline.hpp" diff --git a/project/gen.dep.hpp b/project/gen.dep.hpp index 56826bd..cd5e6b3 100644 --- a/project/gen.dep.hpp +++ b/project/gen.dep.hpp @@ -133,7 +133,15 @@ # endif #pragma endregion Mandatory Includes -namespace gen { +#ifdef GEN_DONT_USE_NAMESPACE +# define GEN_NS_BEGIN +# define GEN_NS_END +#else +# define GEN_NS_BEGIN namespace gen { +# define GEN_NS_END } +#endif + +GEN_NS_BEGIN #pragma region Macros #define zpl_cast( Type ) ( Type ) @@ -2918,6 +2926,4 @@ f64 time_rel( void ); u64 time_rel_ms( void ); #endif -// gen namespace -} - +GEN_NS_END diff --git a/project/gen.hpp b/project/gen.hpp index 2a32513..ecac2b3 100644 --- a/project/gen.hpp +++ b/project/gen.hpp @@ -20,7 +20,15 @@ # include "gen.dep.hpp" #endif -namespace gen { +#if defined(GEN_DONT_USE_NAMESPACE) && ! defined(GEN_NS_BEGIN) +# define GEN_NS_BEGIN +# define GEN_NS_END +#elif ! defined(GEN_NS_BEGIN) +# define GEN_NS_BEGIN namespace gen { +# define GEN_NS_END } +#endif + +GEN_NS_BEGIN #pragma region Types using LogFailType = sw(*)(char const*, ...); @@ -1857,13 +1865,8 @@ StrC token_fmt_impl( sw num, ... ) } #pragma endregion Inlines -// namespace gen -} - #pragma region Constants #ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS -namespace gen -{ // Predefined typename codes. Are set to readonly and are setup during gen::init() extern CodeType t_b32; @@ -1883,11 +1886,8 @@ namespace gen extern CodeType t_f32; extern CodeType t_f64; -} #endif -namespace gen -{ // These constexprs are used for allocation behavior of data structures // or string handling while constructing or serializing. // Change them to suit your needs. @@ -1947,7 +1947,6 @@ namespace gen extern CodeSpecifier spec_static_member; extern CodeSpecifier spec_thread_local; extern CodeSpecifier spec_volatile; -} #pragma endregion Constants #pragma region Macros @@ -1972,8 +1971,6 @@ namespace gen #pragma endregion Macros #ifdef GEN_EXPOSE_BACKEND -namespace gen -{ // Global allocator used for data with process lifetime. extern AllocatorInfo GlobalAllocator; extern Array< Arena > Global_AllocatorBuckets; @@ -1990,7 +1987,8 @@ namespace gen extern AllocatorInfo Allocator_StringArena; extern AllocatorInfo Allocator_StringTable; extern AllocatorInfo Allocator_TypeTable; -} #endif +GEN_NS_END + #include "gen.pop_ignores.inline.hpp"