mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-30 22:40:54 -07:00 
			
		
		
		
	successful compile of c_library for: platform, macros, basic_types, debug, and memory headers (and newly generated c-code)
This commit is contained in:
		| @@ -130,22 +130,6 @@ int gen_main() | ||||
| 		header.print( basic_types ); | ||||
| 		header.print( debug ); | ||||
|  | ||||
| 		// Array(StrC) to_rename = array_init_reserve(StrC, GlobalAllocator, 128); | ||||
| 		// to_rename.append(txt("align_forward")); | ||||
| 		// to_rename.append(txt("pointer_add")); | ||||
| 		// to_rename.append(txt("allocator_info")); | ||||
| 		// to_rename.append(txt("size_remaining")); | ||||
| 		// to_rename.append(txt("free")); | ||||
| 		// to_rename.append(txt("clear")); | ||||
| 		// to_rename.append(txt("init_sub")); | ||||
| 		// to_rename.append(txt("check")); | ||||
|  | ||||
| 		// NeedsSelectors needs_selectors; | ||||
| 		// needs_selectors.table = hashtable_init_reserve(Array(CodeFn), GlobalAllocator, 1024); | ||||
| 		// for ( StrC id : to_rename ) { | ||||
| 		// 	needs_selectors.set(id, array_init_reserve(CodeFn, GlobalAllocator, 128)); | ||||
| 		// } | ||||
|  | ||||
| 		CodeBody parsed_memory = parse_file( project_dir "dependencies/memory.hpp" ); | ||||
| 		CodeBody memory        = def_body(CT_Global_Body); | ||||
|  | ||||
| @@ -317,7 +301,7 @@ int gen_main() | ||||
|  | ||||
| 			containers.append( def_pragma(code(endregion Containers))); | ||||
| 		} | ||||
| 		header.print(fmt_newline); | ||||
| 		// header.print(fmt_newline); | ||||
| 		// header.print(dump_to_scratch_and_retireve(containers)); | ||||
|  | ||||
| 		Code hashing = scan_file( project_dir "dependencies/hashing.hpp" ); | ||||
| @@ -421,7 +405,7 @@ int gen_main() | ||||
| 		CodeBody especifier  = gen_especifier( project_dir "enums/ESpecifier.csv" ); | ||||
| 		CodeBody ast_inlines = gen_ast_inlines(); | ||||
|  | ||||
| #if 0 | ||||
| 	#if 0 | ||||
| 		header.print_fmt("#pragma region Types\n"); | ||||
| 		header.print( types ); | ||||
| 		header.print( fmt_newline ); | ||||
|   | ||||
| @@ -9,46 +9,48 @@ CodeBody gen_fixed_arenas() | ||||
| 	result.append(def_pragma(txt("region FixedArena"))); | ||||
|  | ||||
| 	char const* template_struct = stringize( | ||||
| 		struct FixedArena_<Name> | ||||
| 		struct FixedArena_<Name>_Def | ||||
| 		{ | ||||
| 			char  memory[<Size>]; | ||||
| 			Arena arena; | ||||
| 		}; | ||||
| 		typedef struct FixedArena_<Name>_Def FixedArena_<Name>; | ||||
| 	); | ||||
|  | ||||
| 	char const* template_interface = stringize( | ||||
| 		inline | ||||
| 		void fixed_arena_init_<Name>(FixedArena_<Name>* result) { | ||||
| 			zero_size(& result->memory[0], <Size>); | ||||
| 		void fixed_arena_init_<Name>(FixedArena_<Name>* result) | ||||
| 		{ | ||||
| 			result->arena = arena_init_from_memory(& result->memory[0], <Size>); | ||||
| 		} | ||||
|  | ||||
| 		inline | ||||
| 		ssize fixed_arena_size_remaining_<Name>(FixedArena_<Name>* fixed_arena, ssize alignment) { | ||||
| 			return size_remaining(fixed_arena->arena, alignment); | ||||
| 		ssize fixed_arena_size_remaining_<Name>(FixedArena_<Name>* fixed_arena, ssize alignment) | ||||
| 		{ | ||||
| 			return arena_size_remaining( & fixed_arena->arena, alignment); | ||||
| 		} | ||||
| 	); | ||||
|  | ||||
| 	CodeStruct arena_struct_1kb   = parse_struct( token_fmt_impl( 3, "Name", txt("1KB"),   "Size", txt("kilobytes(1)"),   template_struct )); | ||||
| 	CodeStruct arena_struct_4kb   = parse_struct( token_fmt_impl( 3, "Name", txt("4KB"),   "Size", txt("kilobytes(4)"),   template_struct )); | ||||
| 	CodeStruct arena_struct_8kb   = parse_struct( token_fmt_impl( 3, "Name", txt("8KB"),   "Size", txt("kilobytes(8)"),   template_struct )); | ||||
| 	CodeStruct arena_struct_16kb  = parse_struct( token_fmt_impl( 3, "Name", txt("16KB"),  "Size", txt("kilobytes(16)"),  template_struct )); | ||||
| 	CodeStruct arena_struct_32kb  = parse_struct( token_fmt_impl( 3, "Name", txt("32KB"),  "Size", txt("kilobytes(32)"),  template_struct )); | ||||
| 	CodeStruct arena_struct_64kb  = parse_struct( token_fmt_impl( 3, "Name", txt("64KB"),  "Size", txt("kilobytes(64)"),  template_struct )); | ||||
| 	CodeStruct arena_struct_128kb = parse_struct( token_fmt_impl( 3, "Name", txt("128KB"), "Size", txt("kilobytes(128)"), template_struct )); | ||||
| 	CodeStruct arena_struct_256kb = parse_struct( token_fmt_impl( 3, "Name", txt("256KB"), "Size", txt("kilobytes(256)"), template_struct )); | ||||
| 	CodeStruct arena_struct_512kb = parse_struct( token_fmt_impl( 3, "Name", txt("512KB"), "Size", txt("kilobytes(512)"), template_struct )); | ||||
| 	CodeStruct arena_struct_1mb   = parse_struct( token_fmt_impl( 3, "Name", txt("1MB"),   "Size", txt("megabytes(1)"),   template_struct )); | ||||
| 	CodeStruct arena_struct_2mb   = parse_struct( token_fmt_impl( 3, "Name", txt("2MB"),   "Size", txt("megabytes(2)"),   template_struct )); | ||||
| 	CodeStruct arena_struct_4mb   = parse_struct( token_fmt_impl( 3, "Name", txt("4MB"),   "Size", txt("megabytes(4)"),   template_struct )); | ||||
| 	CodeBody arena_struct_1kb   = parse_global_body( token_fmt_impl( 3, "Name", txt("1KB"),   "Size", txt("kilobytes(1)"),   template_struct )); | ||||
| 	CodeBody arena_struct_4kb   = parse_global_body( token_fmt_impl( 3, "Name", txt("4KB"),   "Size", txt("kilobytes(4)"),   template_struct )); | ||||
| 	CodeBody arena_struct_8kb   = parse_global_body( token_fmt_impl( 3, "Name", txt("8KB"),   "Size", txt("kilobytes(8)"),   template_struct )); | ||||
| 	CodeBody arena_struct_16kb  = parse_global_body( token_fmt_impl( 3, "Name", txt("16KB"),  "Size", txt("kilobytes(16)"),  template_struct )); | ||||
| 	CodeBody arena_struct_32kb  = parse_global_body( token_fmt_impl( 3, "Name", txt("32KB"),  "Size", txt("kilobytes(32)"),  template_struct )); | ||||
| 	CodeBody arena_struct_64kb  = parse_global_body( token_fmt_impl( 3, "Name", txt("64KB"),  "Size", txt("kilobytes(64)"),  template_struct )); | ||||
| 	CodeBody arena_struct_128kb = parse_global_body( token_fmt_impl( 3, "Name", txt("128KB"), "Size", txt("kilobytes(128)"), template_struct )); | ||||
| 	CodeBody arena_struct_256kb = parse_global_body( token_fmt_impl( 3, "Name", txt("256KB"), "Size", txt("kilobytes(256)"), template_struct )); | ||||
| 	CodeBody arena_struct_512kb = parse_global_body( token_fmt_impl( 3, "Name", txt("512KB"), "Size", txt("kilobytes(512)"), template_struct )); | ||||
| 	CodeBody arena_struct_1mb   = parse_global_body( token_fmt_impl( 3, "Name", txt("1MB"),   "Size", txt("megabytes(1)"),   template_struct )); | ||||
| 	CodeBody arena_struct_2mb   = parse_global_body( token_fmt_impl( 3, "Name", txt("2MB"),   "Size", txt("megabytes(2)"),   template_struct )); | ||||
| 	CodeBody arena_struct_4mb   = parse_global_body( token_fmt_impl( 3, "Name", txt("4MB"),   "Size", txt("megabytes(4)"),   template_struct )); | ||||
|  | ||||
|  | ||||
| 	CodeBody arena_interface_1kb   = parse_global_body( token_fmt_impl( 3, "Name", txt("1KB"),   "Size", txt("kilobytes(1)"),    template_interface )); | ||||
| 	CodeBody arena_interface_4kb   = parse_global_body( token_fmt_impl( 3, "Name", txt("4KB"),   "Size", txt("kilobytes(4)"),    template_interface )); | ||||
| 	CodeBody arena_interface_8kb   = parse_global_body( token_fmt_impl( 3, "Name", txt("8KB"),   "Size", txt("kilobytes(8)"),    template_interface )); | ||||
| 	CodeBody arena_interface_16kb  = parse_global_body( token_fmt_impl( 3, "Name", txt("16KB"),  "Size", txt("kilobytes(16)"),   template_interface )); | ||||
| 	CodeBody arena_interface_32kb  = parse_global_body( token_fmt_impl( 3, "Name", txt("32KB"),  "Size", txt("kilobytes(32)"),   template_interface )); | ||||
| 	CodeBody arena_interface_64kb  = parse_global_body( token_fmt_impl( 3, "Name", txt("64KB"),  "Size", txt("kilobytes(64)"),   template_interface )); | ||||
| 	CodeBody arena_interface_1kb   = parse_global_body( token_fmt_impl( 3, "Name", txt("1KB"),   "Size", txt("kilobytes(1)"),   template_interface )); | ||||
| 	CodeBody arena_interface_4kb   = parse_global_body( token_fmt_impl( 3, "Name", txt("4KB"),   "Size", txt("kilobytes(4)"),   template_interface )); | ||||
| 	CodeBody arena_interface_8kb   = parse_global_body( token_fmt_impl( 3, "Name", txt("8KB"),   "Size", txt("kilobytes(8)"),   template_interface )); | ||||
| 	CodeBody arena_interface_16kb  = parse_global_body( token_fmt_impl( 3, "Name", txt("16KB"),  "Size", txt("kilobytes(16)"),  template_interface )); | ||||
| 	CodeBody arena_interface_32kb  = parse_global_body( token_fmt_impl( 3, "Name", txt("32KB"),  "Size", txt("kilobytes(32)"),  template_interface )); | ||||
| 	CodeBody arena_interface_64kb  = parse_global_body( token_fmt_impl( 3, "Name", txt("64KB"),  "Size", txt("kilobytes(64)"),  template_interface )); | ||||
| 	CodeBody arena_interface_128kb = parse_global_body( token_fmt_impl( 3, "Name", txt("128KB"), "Size", txt("kilobytes(128)"), template_interface )); | ||||
| 	CodeBody arena_interface_256kb = parse_global_body( token_fmt_impl( 3, "Name", txt("256KB"), "Size", txt("kilobytes(256)"), template_interface )); | ||||
| 	CodeBody arena_interface_512kb = parse_global_body( token_fmt_impl( 3, "Name", txt("512KB"), "Size", txt("kilobytes(512)"), template_interface )); | ||||
| @@ -82,6 +84,7 @@ CodeBody gen_fixed_arenas() | ||||
|  | ||||
| 	CodeDefine def = def_define(txt("fixed_arena_allocator_info(fixed_arena)"), code({ arena_allocator_proc, & fixed_arena.arena }) ); | ||||
| 	result.append(def); | ||||
| 	result.append(fmt_newline); | ||||
|  | ||||
| 	result.append(parse_global_body(txt(R"( | ||||
| #define fixed_arena_init(expr) _Generic((expr), \ | ||||
| @@ -116,6 +119,7 @@ CodeBody gen_fixed_arenas() | ||||
| )" | ||||
| 	))); | ||||
|  | ||||
| 	result.append(fmt_newline); | ||||
| 	result.append(def_pragma(txt("endregion FixedArena"))); | ||||
|  | ||||
| 	return result; | ||||
|   | ||||
| @@ -3,38 +3,8 @@ | ||||
|  | ||||
| // using namespace gen; | ||||
|  | ||||
| using SwapContentProc = CodeBody(void); | ||||
|  | ||||
|  | ||||
| struct NeedsSelectors { | ||||
| 	HashTable(Array(CodeFn)) table; | ||||
|  | ||||
| 	void set(StrC sig, Array(CodeFn) list) { | ||||
| 		u32  key = crc32(sig.Ptr, sig.Len); | ||||
| 		table.set(key, list); | ||||
| 	} | ||||
| 	Array(CodeFn)* get(StrC sig) { | ||||
| 		u32  key = crc32(sig.Ptr, sig.Len); | ||||
| 		return table.get(key); | ||||
| 	} | ||||
| }; | ||||
| CodeBody generate_generic_selectors(Array(Array(CodeFn)) listing) | ||||
| { | ||||
| 	constexpr char const* tmpl_selector =  | ||||
| R"( #define <base_name>(<params>) \ | ||||
| _Generic(( | ||||
| )) | ||||
| ); | ||||
| )"; | ||||
|  | ||||
| 	CodeBody result = def_body(CT_Global_Body); | ||||
| 	for (Array(CodeFn) functions : listing) | ||||
| 	{ | ||||
| 		 | ||||
| 	} | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| b32 ignore_preprocess_cond_block( StrC cond_sig, Code& entry_iter, CodeBody& body ) | ||||
| { | ||||
| 	b32 found = false; | ||||
| @@ -153,6 +123,7 @@ CodeFn rename_function_to_unique_symbol(CodeFn fn, StrC optional_prefix = txt("" | ||||
|     return fn; | ||||
| } | ||||
|  | ||||
| using SwapContentProc = CodeBody(void); | ||||
| bool swap_pragma_region_implementation( StrC region_name, SwapContentProc* swap_content, Code& entry_iter, CodeBody& body ) | ||||
| { | ||||
| 	bool found = false; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user