Added macros to make the gen namespace optional.

This commit is contained in:
Edward R. Gonzalez 2023-07-23 22:25:19 -04:00
parent e7374ec328
commit 5ce8bfa259
3 changed files with 23 additions and 20 deletions

View File

@ -14,7 +14,7 @@
#include "gen.hpp" #include "gen.hpp"
namespace gen { GEN_NS_BEGIN
#pragma region StaticData #pragma region StaticData
// TODO : Convert global allocation strategy to use a slab allocation strategy. // TODO : Convert global allocation strategy to use a slab allocation strategy.
@ -6606,7 +6606,6 @@ void Builder::write()
} }
#pragma endregion Builder #pragma endregion Builder
// namespace gen GEN_NS_END
}
#include "gen.pop_ignores.inline.hpp" #include "gen.pop_ignores.inline.hpp"

View File

@ -133,7 +133,15 @@
# endif # endif
#pragma endregion Mandatory Includes #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 #pragma region Macros
#define zpl_cast( Type ) ( Type ) #define zpl_cast( Type ) ( Type )
@ -2918,6 +2926,4 @@ f64 time_rel( void );
u64 time_rel_ms( void ); u64 time_rel_ms( void );
#endif #endif
// gen namespace GEN_NS_END
}

View File

@ -20,7 +20,15 @@
# include "gen.dep.hpp" # include "gen.dep.hpp"
#endif #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 #pragma region Types
using LogFailType = sw(*)(char const*, ...); using LogFailType = sw(*)(char const*, ...);
@ -1857,13 +1865,8 @@ StrC token_fmt_impl( sw num, ... )
} }
#pragma endregion Inlines #pragma endregion Inlines
// namespace gen
}
#pragma region Constants #pragma region Constants
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS #ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
namespace gen
{
// Predefined typename codes. Are set to readonly and are setup during gen::init() // Predefined typename codes. Are set to readonly and are setup during gen::init()
extern CodeType t_b32; extern CodeType t_b32;
@ -1883,11 +1886,8 @@ namespace gen
extern CodeType t_f32; extern CodeType t_f32;
extern CodeType t_f64; extern CodeType t_f64;
}
#endif #endif
namespace gen
{
// These constexprs are used for allocation behavior of data structures // These constexprs are used for allocation behavior of data structures
// or string handling while constructing or serializing. // or string handling while constructing or serializing.
// Change them to suit your needs. // Change them to suit your needs.
@ -1947,7 +1947,6 @@ namespace gen
extern CodeSpecifier spec_static_member; extern CodeSpecifier spec_static_member;
extern CodeSpecifier spec_thread_local; extern CodeSpecifier spec_thread_local;
extern CodeSpecifier spec_volatile; extern CodeSpecifier spec_volatile;
}
#pragma endregion Constants #pragma endregion Constants
#pragma region Macros #pragma region Macros
@ -1972,8 +1971,6 @@ namespace gen
#pragma endregion Macros #pragma endregion Macros
#ifdef GEN_EXPOSE_BACKEND #ifdef GEN_EXPOSE_BACKEND
namespace gen
{
// Global allocator used for data with process lifetime. // Global allocator used for data with process lifetime.
extern AllocatorInfo GlobalAllocator; extern AllocatorInfo GlobalAllocator;
extern Array< Arena > Global_AllocatorBuckets; extern Array< Arena > Global_AllocatorBuckets;
@ -1990,7 +1987,8 @@ namespace gen
extern AllocatorInfo Allocator_StringArena; extern AllocatorInfo Allocator_StringArena;
extern AllocatorInfo Allocator_StringTable; extern AllocatorInfo Allocator_StringTable;
extern AllocatorInfo Allocator_TypeTable; extern AllocatorInfo Allocator_TypeTable;
}
#endif #endif
GEN_NS_END
#include "gen.pop_ignores.inline.hpp" #include "gen.pop_ignores.inline.hpp"