mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-11-03 15:26:12 -08:00 
			
		
		
		
	interface.untyped.cpp impl compiles in gnerated c library
This commit is contained in:
		@@ -24,8 +24,8 @@
 | 
			
		||||
#ifndef GEN_MAX_UNTYPED_STR_LENGTH
 | 
			
		||||
#	define GEN_MAX_UNTYPED_STR_LENGTH megabytes(1)
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE
 | 
			
		||||
#	define GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE kilobytes(8)
 | 
			
		||||
#ifndef TokenMap_FixedArena
 | 
			
		||||
#	define TokenMap_FixedArena FixedArena_8KB
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GEN_LEX_ALLOCATOR_SIZE
 | 
			
		||||
#	define GEN_LEX_ALLOCATOR_SIZE megabytes(4)
 | 
			
		||||
@@ -49,7 +49,7 @@ 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 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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -272,7 +272,7 @@ StrC token_fmt_impl( ssize, ... );
 | 
			
		||||
 | 
			
		||||
Code untyped_str      ( StrC content);
 | 
			
		||||
Code untyped_fmt      ( char const* fmt, ... );
 | 
			
		||||
Code untyped_token_fmt( char const* fmt, s32 num_tokens, ... );
 | 
			
		||||
Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... );
 | 
			
		||||
 | 
			
		||||
#pragma endregion Untyped text
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -35,8 +35,8 @@ CodeConstructor parse_constructor( StrC def )
 | 
			
		||||
 | 
			
		||||
	// TODO(Ed): Constructors can have prefix attributes
 | 
			
		||||
 | 
			
		||||
	CodeSpecifiers specifiers;
 | 
			
		||||
	Specifier      specs_found[ 16 ] { Spec_NumSpecifiers };
 | 
			
		||||
	CodeSpecifiers specifiers = NullCode;
 | 
			
		||||
	Specifier      specs_found[ 16 ] = { Spec_NumSpecifiers };
 | 
			
		||||
	s32            NumSpecifiers = 0;
 | 
			
		||||
 | 
			
		||||
	while ( left && tok_is_specifier(currtok) )
 | 
			
		||||
 
 | 
			
		||||
@@ -9,11 +9,11 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
 | 
			
		||||
	ssize       remaining = buf_size;
 | 
			
		||||
 | 
			
		||||
	local_persist
 | 
			
		||||
	FixedArena<TokenFmt_TokenMap_MemSize> tok_map_arena;
 | 
			
		||||
	TokenMap_FixedArena tok_map_arena;
 | 
			
		||||
	fixed_arena_init( & tok_map_arena);
 | 
			
		||||
 | 
			
		||||
	local_persist
 | 
			
		||||
	HashTable(StrC) tok_map;
 | 
			
		||||
	StringTable tok_map;
 | 
			
		||||
	{
 | 
			
		||||
		tok_map = hashtable_init(StrC, fixed_arena_allocator_info(& tok_map_arena) );
 | 
			
		||||
 | 
			
		||||
@@ -113,7 +113,7 @@ Code untyped_str( StrC content )
 | 
			
		||||
	result->Type    = CT_Untyped;
 | 
			
		||||
	result->Content = result->Name;
 | 
			
		||||
 | 
			
		||||
	if ( result->Name == nullptr )
 | 
			
		||||
	if ( result->Name.Len == 0 )
 | 
			
		||||
	{
 | 
			
		||||
		log_failure( "untyped_str: could not cache string" );
 | 
			
		||||
		return InvalidCode;
 | 
			
		||||
@@ -138,13 +138,16 @@ Code untyped_fmt( char const* fmt, ...)
 | 
			
		||||
	ssize length = str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va);
 | 
			
		||||
	va_end(va);
 | 
			
		||||
 | 
			
		||||
	StrC buf_str      = { str_len_capped(fmt, MaxNameLength), fmt };
 | 
			
		||||
    StrC uncapped_str = { length, buf };
 | 
			
		||||
 | 
			
		||||
	Code
 | 
			
		||||
	result          = make_code();
 | 
			
		||||
	result->Name    = get_cached_string( { str_len_capped(fmt, MaxNameLength), fmt } );
 | 
			
		||||
	result->Name    = get_cached_string( buf_str );
 | 
			
		||||
	result->Type    = CT_Untyped;
 | 
			
		||||
	result->Content = get_cached_string( { length, buf } );
 | 
			
		||||
	result->Content = get_cached_string( uncapped_str );
 | 
			
		||||
 | 
			
		||||
	if ( result->Name == nullptr )
 | 
			
		||||
	if ( result->Name.Len == 0 )
 | 
			
		||||
	{
 | 
			
		||||
		log_failure( "untyped_fmt: could not cache string" );
 | 
			
		||||
		return InvalidCode;
 | 
			
		||||
@@ -153,7 +156,7 @@ Code untyped_fmt( char const* fmt, ...)
 | 
			
		||||
	return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Code untyped_token_fmt( s32 num_tokens, ... )
 | 
			
		||||
Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... )
 | 
			
		||||
{
 | 
			
		||||
	if ( num_tokens == 0 )
 | 
			
		||||
	{
 | 
			
		||||
@@ -165,17 +168,19 @@ Code untyped_token_fmt( s32 num_tokens, ... )
 | 
			
		||||
	char buf[GEN_PRINTF_MAXLEN] = { 0 };
 | 
			
		||||
 | 
			
		||||
	va_list va;
 | 
			
		||||
	va_start(va, num_tokens);
 | 
			
		||||
	va_start(va, fmt);
 | 
			
		||||
	ssize length = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num_tokens, va);
 | 
			
		||||
	va_end(va);
 | 
			
		||||
 | 
			
		||||
	StrC buf_str = { length, buf };
 | 
			
		||||
 | 
			
		||||
	Code
 | 
			
		||||
	result          = make_code();
 | 
			
		||||
	result->Name    = get_cached_string( { length, buf } );
 | 
			
		||||
	result->Name    = get_cached_string( buf_str );
 | 
			
		||||
	result->Type    = CT_Untyped;
 | 
			
		||||
	result->Content = result->Name;
 | 
			
		||||
 | 
			
		||||
	if ( result->Name == nullptr )
 | 
			
		||||
	if ( result->Name.Len == 0 )
 | 
			
		||||
	{
 | 
			
		||||
		log_failure( "untyped_fmt: could not cache string" );
 | 
			
		||||
		return InvalidCode;
 | 
			
		||||
 
 | 
			
		||||
@@ -150,7 +150,7 @@ void parser_init()
 | 
			
		||||
internal
 | 
			
		||||
void parser_deinit()
 | 
			
		||||
{
 | 
			
		||||
	Array(Token) null_array = {};
 | 
			
		||||
	Array(Token) null_array = { nullptr };
 | 
			
		||||
	Lexer_Tokens = null_array;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user