mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-11-03 15:26:12 -08:00 
			
		
		
		
	Introduced the general context struct for gencpp
This commit is contained in:
		@@ -6,53 +6,6 @@
 | 
			
		||||
 | 
			
		||||
#pragma region Constants
 | 
			
		||||
 | 
			
		||||
#ifndef GEN_GLOBAL_BUCKET_SIZE
 | 
			
		||||
#	define GEN_GLOBAL_BUCKET_SIZE megabytes(8)
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GEN_CODEPOOL_NUM_BLOCKS
 | 
			
		||||
#	define GEN_CODEPOOL_NUM_BLOCKS kilobytes(16)
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GEN_SIZE_PER_STRING_ARENA
 | 
			
		||||
#	define GEN_SIZE_PER_STRING_ARENA megabytes(1)
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GEN_MAX_COMMENT_LINE_LENGTH
 | 
			
		||||
#	define GEN_MAX_COMMENT_LINE_LENGTH 1024
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GEN_MAX_NAME_LENGTH
 | 
			
		||||
#	define GEN_MAX_NAME_LENGTH 128
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GEN_MAX_UNTYPED_STR_LENGTH
 | 
			
		||||
#	define GEN_MAX_UNTYPED_STR_LENGTH megabytes(1)
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef TokenMap_FixedArena
 | 
			
		||||
#	define TokenMap_FixedArena FixedArena_8KB
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GEN_LEX_ALLOCATOR_SIZE
 | 
			
		||||
#	define GEN_LEX_ALLOCATOR_SIZE megabytes(4)
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GEN_BUILDER_STR_BUFFER_RESERVE
 | 
			
		||||
#	define GEN_BUILDER_STR_BUFFER_RESERVE megabytes(2)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// These constexprs are used for allocation behavior of data structures
 | 
			
		||||
// or string handling while constructing or serializing.
 | 
			
		||||
// Change them to suit your needs.
 | 
			
		||||
 | 
			
		||||
constexpr s32 InitSize_DataArrays = 16;
 | 
			
		||||
 | 
			
		||||
// NOTE: This limits the maximum size of an allocation
 | 
			
		||||
// If you are generating a string larger than this, increase the size of the bucket here.
 | 
			
		||||
constexpr usize  Global_BucketSize      = GEN_GLOBAL_BUCKET_SIZE;
 | 
			
		||||
constexpr s32 CodePool_NumBlocks        = GEN_CODEPOOL_NUM_BLOCKS;
 | 
			
		||||
constexpr s32 SizePer_StringArena       = GEN_SIZE_PER_STRING_ARENA;
 | 
			
		||||
 | 
			
		||||
constexpr s32 MaxCommentLineLength      = GEN_MAX_COMMENT_LINE_LENGTH;
 | 
			
		||||
constexpr s32 MaxNameLength             = GEN_MAX_NAME_LENGTH;
 | 
			
		||||
constexpr s32 MaxUntypedStrLength       = GEN_MAX_UNTYPED_STR_LENGTH;
 | 
			
		||||
// constexpr s32 TokenFmt_TokenMap_MemSize	= GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE;
 | 
			
		||||
constexpr s32 LexAllocator_Size         = GEN_LEX_ALLOCATOR_SIZE;
 | 
			
		||||
constexpr s32 Builder_StrBufferReserve  = GEN_BUILDER_STR_BUFFER_RESERVE;
 | 
			
		||||
 | 
			
		||||
extern Str enum_underlying_sig;
 | 
			
		||||
 | 
			
		||||
extern Code access_public;
 | 
			
		||||
@@ -111,6 +64,7 @@ extern CodeTypename t_typename;
 | 
			
		||||
 | 
			
		||||
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
 | 
			
		||||
	// Predefined typename codes. Are set to readonly and are setup during gen::init()
 | 
			
		||||
	extern Context* _ctx;
 | 
			
		||||
 | 
			
		||||
	extern CodeTypename t_b32;
 | 
			
		||||
 | 
			
		||||
@@ -132,28 +86,3 @@ extern CodeTypename t_typename;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#pragma endregion Constants
 | 
			
		||||
 | 
			
		||||
// Used by the lexer to persistently treat all these identifiers as preprocessor defines.
 | 
			
		||||
// Populate with strings via gen::get_cached_string.
 | 
			
		||||
// Functional defines must have format: id( ;at minimum to indicate that the define is only valid with arguments.
 | 
			
		||||
extern Array(StringCached) PreprocessorDefines;
 | 
			
		||||
 | 
			
		||||
#ifdef GEN_EXPOSE_BACKEND
 | 
			
		||||
	// Global allocator used for data with process lifetime.
 | 
			
		||||
	extern AllocatorInfo  GlobalAllocator;
 | 
			
		||||
	extern Array(Arena) Global_AllocatorBuckets;
 | 
			
		||||
 | 
			
		||||
	extern Array(Pool)  CodePools;
 | 
			
		||||
	extern Array(Arena) StringArenas;
 | 
			
		||||
 | 
			
		||||
	extern StringTable StringCache;
 | 
			
		||||
 | 
			
		||||
	extern Arena LexArena;
 | 
			
		||||
 | 
			
		||||
	extern AllocatorInfo Allocator_DataArrays;
 | 
			
		||||
	extern AllocatorInfo Allocator_CodePool;
 | 
			
		||||
	extern AllocatorInfo Allocator_Lexer;
 | 
			
		||||
	extern AllocatorInfo Allocator_StringArena;
 | 
			
		||||
	extern AllocatorInfo Allocator_StringTable;
 | 
			
		||||
	extern AllocatorInfo Allocator_TypeTable;
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user