mirror of
https://github.com/Ed94/HandmadeHero.git
synced 2025-06-16 11:41:47 -07:00
Day 28 complete!
This commit is contained in:
@ -93,7 +93,7 @@ int gen_main()
|
||||
builder.write();
|
||||
#pragma pop_macro("str_ascii")
|
||||
|
||||
log_fmt("Generaton finished for Handmade Hero: Engine Module\n");
|
||||
log_fmt("Generaton finished for Handmade Hero: Engine Module\n\n");
|
||||
// gen::deinit();
|
||||
return 0;
|
||||
}
|
||||
|
@ -6,11 +6,72 @@
|
||||
#include "dependencies/gen.hpp"
|
||||
using namespace gen;
|
||||
|
||||
#define path_gen "./gen/"
|
||||
|
||||
|
||||
int gen_main()
|
||||
{
|
||||
gen::init();
|
||||
log_fmt("Generating code for Handmade Hero: Platform Module\n");
|
||||
log_fmt("Generaton finished for Handmade Hero: Platform Module\n");
|
||||
|
||||
CodeComment generation_notice = def_comment( txt("This was generated by project/codegen/platform_gen.cpp") );
|
||||
|
||||
Builder builder = Builder::open( path_gen "context.gen.hpp");
|
||||
builder.print( generation_notice );
|
||||
builder.print( fmt_newline );
|
||||
|
||||
FileContents h_context = file_read_contents(GlobalAllocator, true, "context.hpp");
|
||||
CodeBody code_context = parse_global_body( { h_context.size, rcast( char const*, h_context.data ) } );
|
||||
|
||||
CodeStruct context_struct = {};
|
||||
for ( Code code : code_context )
|
||||
{
|
||||
if ( code->Type == ECode::Struct )
|
||||
{
|
||||
if ( str_compare( code->Name, txt("Context") ) == 0 )
|
||||
{
|
||||
context_struct = code;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Array<Code> context_data_members = Array<Code>::init_reserve( GlobalAllocator, kilobytes( 1 ) );
|
||||
for ( Code code : context_struct->Body )
|
||||
{
|
||||
if ( code->Type == ECode::Variable )
|
||||
{
|
||||
context_data_members.append( code );
|
||||
}
|
||||
}
|
||||
|
||||
CodeDefine using_context;
|
||||
{
|
||||
String using_context_content = String::make_reserve( GlobalAllocator, kilobytes( 1 ) );
|
||||
{
|
||||
String
|
||||
content = using_context_content;
|
||||
content.append( "\\\n" );
|
||||
|
||||
for ( s32 id = 0; id < context_data_members.num() - 1; ++id )
|
||||
{
|
||||
Code code = context_data_members[ id ];
|
||||
content.append( code.to_string() );
|
||||
|
||||
// Default serializer inserts a newline at the end of the string, we need to insert a line continuation
|
||||
content[ content.length() - 1 ] = '\\';
|
||||
content.append( "\n" );
|
||||
}
|
||||
content.append( context_data_members[ context_data_members.num() - 1 ]->to_string() );
|
||||
}
|
||||
using_context = def_define( txt("using_context()"), using_context_content );
|
||||
}
|
||||
|
||||
builder.print( using_context );
|
||||
builder.write();
|
||||
|
||||
log_fmt("Generaton finished for Handmade Hero: Platform Module\n\n");
|
||||
// gen::deinit();
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user