mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-11-03 23:36:12 -08:00 
			
		
		
		
	Introduced the general context struct for gencpp
This commit is contained in:
		@@ -30,16 +30,16 @@ R"(#define HashTable(_type) struct _type
 | 
			
		||||
CodeBody gen_hashtable( Str type, Str hashtable_name )
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	StrBuilder tbl_type = {(char*) hashtable_name.duplicate(GlobalAllocator).Ptr};
 | 
			
		||||
	StrBuilder fn       = tbl_type.duplicate(GlobalAllocator);
 | 
			
		||||
	StrBuilder tbl_type = {(char*) hashtable_name.duplicate(FallbackAllocator).Ptr};
 | 
			
		||||
	StrBuilder fn       = tbl_type.duplicate(FallbackAllocator);
 | 
			
		||||
	// c_str_to_lower(fn.Data);
 | 
			
		||||
 | 
			
		||||
	StrBuilder name_lower = StrBuilder::make( GlobalAllocator, hashtable_name );
 | 
			
		||||
	StrBuilder name_lower = StrBuilder::make( FallbackAllocator, hashtable_name );
 | 
			
		||||
	// c_str_to_lower( name_lower.Data );
 | 
			
		||||
 | 
			
		||||
	StrBuilder hashtable_entry   = StrBuilder::fmt_buf( GlobalAllocator, "HTE_%.*s",     hashtable_name.Len, hashtable_name.Ptr );
 | 
			
		||||
	StrBuilder entry_array_name  = StrBuilder::fmt_buf( GlobalAllocator, "Arr_HTE_%.*s", hashtable_name.Len, hashtable_name.Ptr );
 | 
			
		||||
	StrBuilder entry_array_fn_ns = StrBuilder::fmt_buf( GlobalAllocator, "arr_hte_%.*s", name_lower.length(), name_lower.Data );
 | 
			
		||||
	StrBuilder hashtable_entry   = StrBuilder::fmt_buf( FallbackAllocator, "HTE_%.*s",     hashtable_name.Len, hashtable_name.Ptr );
 | 
			
		||||
	StrBuilder entry_array_name  = StrBuilder::fmt_buf( FallbackAllocator, "Arr_HTE_%.*s", hashtable_name.Len, hashtable_name.Ptr );
 | 
			
		||||
	StrBuilder entry_array_fn_ns = StrBuilder::fmt_buf( FallbackAllocator, "arr_hte_%.*s", name_lower.length(), name_lower.Data );
 | 
			
		||||
 | 
			
		||||
	CodeBody hashtable_types = parse_global_body( token_fmt(
 | 
			
		||||
		"type",        (Str) type,
 | 
			
		||||
@@ -372,7 +372,7 @@ CodeBody gen_hashtable( Str type, Str hashtable_name )
 | 
			
		||||
#pragma pop_macro( "forceinline" )
 | 
			
		||||
 | 
			
		||||
	++ HashTable_DefinitionCounter;
 | 
			
		||||
	Str slot_str = StrBuilder::fmt_buf(GlobalAllocator, "%d", HashTable_DefinitionCounter).to_str();
 | 
			
		||||
	Str slot_str = StrBuilder::fmt_buf(FallbackAllocator, "%d", HashTable_DefinitionCounter).to_str();
 | 
			
		||||
 | 
			
		||||
	Code generic_interface_slot = untyped_str(token_fmt( "type", type, "tbl_type", (Str)tbl_type, "slot", (Str)slot_str,
 | 
			
		||||
R"(#define GENERIC_SLOT_<slot>__hashtable_init          <type>,      <tbl_type>_init
 | 
			
		||||
@@ -400,7 +400,7 @@ R"(#define GENERIC_SLOT_<slot>__hashtable_init          <type>,      <tbl_type>_
 | 
			
		||||
		, type.Len, type.Ptr );
 | 
			
		||||
 | 
			
		||||
	return def_global_body(args(
 | 
			
		||||
		def_pragma( strbuilder_to_str( strbuilder_fmt_buf( GlobalAllocator, "region %SB", tbl_type ))),
 | 
			
		||||
		def_pragma( strbuilder_to_str( strbuilder_fmt_buf( FallbackAllocator, "region %SB", tbl_type ))),
 | 
			
		||||
		fmt_newline,
 | 
			
		||||
		generic_interface_slot,
 | 
			
		||||
		fmt_newline,
 | 
			
		||||
@@ -409,7 +409,7 @@ R"(#define GENERIC_SLOT_<slot>__hashtable_init          <type>,      <tbl_type>_
 | 
			
		||||
		entry_array,
 | 
			
		||||
		hashtable_def,
 | 
			
		||||
		fmt_newline,
 | 
			
		||||
		def_pragma( strbuilder_to_str( strbuilder_fmt_buf( GlobalAllocator, "endregion %SB", tbl_type ))),
 | 
			
		||||
		def_pragma( strbuilder_to_str( strbuilder_fmt_buf( FallbackAllocator, "endregion %SB", tbl_type ))),
 | 
			
		||||
		fmt_newline
 | 
			
		||||
	));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user