mirror of
https://github.com/Ed94/HandmadeHero.git
synced 2024-12-21 22:14:43 -08:00
update gencpp to latest
Using this project to test latest ver...
This commit is contained in:
parent
393f98a03d
commit
a86a2cc77c
22
.vscode/settings.json
vendored
22
.vscode/settings.json
vendored
@ -84,5 +84,25 @@
|
||||
"**/.vscode": true,
|
||||
"**/.vs": true,
|
||||
},
|
||||
"dimmer.enabled": true
|
||||
"dimmer.enabled": false,
|
||||
"workbench.colorCustomizations": {
|
||||
"activityBar.activeBackground": "#ff6433",
|
||||
"activityBar.background": "#ff6433",
|
||||
"activityBar.foreground": "#15202b",
|
||||
"activityBar.inactiveForeground": "#15202b99",
|
||||
"activityBarBadge.background": "#00ff3d",
|
||||
"activityBarBadge.foreground": "#15202b",
|
||||
"commandCenter.border": "#e7e7e799",
|
||||
"sash.hoverBorder": "#ff6433",
|
||||
"statusBar.background": "#ff3d00",
|
||||
"statusBar.foreground": "#e7e7e7",
|
||||
"statusBarItem.hoverBackground": "#ff6433",
|
||||
"statusBarItem.remoteBackground": "#ff3d00",
|
||||
"statusBarItem.remoteForeground": "#e7e7e7",
|
||||
"titleBar.activeBackground": "#ff3d00",
|
||||
"titleBar.activeForeground": "#e7e7e7",
|
||||
"titleBar.inactiveBackground": "#ff3d0099",
|
||||
"titleBar.inactiveForeground": "#e7e7e799"
|
||||
},
|
||||
"peacock.color": "#ff3d00"
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#undef do_once
|
||||
#undef do_once_start
|
||||
#undef do_once_end
|
||||
using namespace gen;
|
||||
#undef cast
|
||||
|
||||
#include "platform/platform_module.hpp"
|
||||
#include "platform/grime.hpp"
|
||||
@ -23,7 +23,10 @@ using namespace gen;
|
||||
#include "platform/strings.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
constexpr StrC fname_vec_header = txt("vectors.hpp");
|
||||
using namespace gen;
|
||||
using GStr = gen::Str;
|
||||
|
||||
constexpr GStr fname_vec_header = txt("vectors.hpp");
|
||||
|
||||
#pragma push_macro("scast")
|
||||
#pragma push_macro("Zero")
|
||||
@ -264,7 +267,7 @@ constexpr char const* vec2i_ops = stringize(
|
||||
#pragma pop_macro("Zero")
|
||||
|
||||
#define gen_vec2f( vec_name, type ) gen__vec2f( txt( stringize(vec_name) ), txt( stringize(type) ) )
|
||||
CodeBody gen__vec2f( StrC vec_name, StrC type )
|
||||
CodeBody gen__vec2f( GStr vec_name, GStr type )
|
||||
{
|
||||
CodeStruct vec_struct = parse_struct( token_fmt( "type", vec_name, "unit_type", type, stringize(
|
||||
struct <type>
|
||||
@ -290,7 +293,7 @@ CodeBody gen__vec2f( StrC vec_name, StrC type )
|
||||
}
|
||||
|
||||
#define gen_vec2i( vec_name, type ) gen__vec2i( txt( stringize(vec_name) ), txt( stringize(type) ) )
|
||||
CodeBody gen__vec2i( StrC vec_name, StrC type )
|
||||
CodeBody gen__vec2i( GStr vec_name, GStr type )
|
||||
{
|
||||
CodeStruct vec_struct = parse_struct( token_fmt( "type", vec_name, "unit_type", type, stringize(
|
||||
struct <type>
|
||||
@ -316,14 +319,14 @@ CodeBody gen__vec2i( StrC vec_name, StrC type )
|
||||
}
|
||||
|
||||
#define gen_phys2( type ) gen__phys2( txt( stringize(type) ) )
|
||||
Code gen__phys2( StrC type )
|
||||
Code gen__phys2( GStr type )
|
||||
{
|
||||
String sym_vec = String::fmt_buf( GlobalAllocator, "Vec2_%s", type.Ptr );
|
||||
String sym_pos = String::fmt_buf( GlobalAllocator, "Pos2_%s", type.Ptr );
|
||||
String sym_dir = String::fmt_buf( GlobalAllocator, "Dir2_%s", type.Ptr);
|
||||
String sym_dist = String::fmt_buf( GlobalAllocator, "Dist_%s", type.Ptr );
|
||||
String sym_vel = String::fmt_buf( GlobalAllocator, "Vel2_%s", type.Ptr );
|
||||
String sym_accel = String::fmt_buf( GlobalAllocator, "Accel2_%s", type.Ptr );
|
||||
StrBuilder sym_vec = StrBuilder::fmt_buf( _ctx->Allocator_Temp, "Vec2_%s", type.Ptr );
|
||||
StrBuilder sym_pos = StrBuilder::fmt_buf( _ctx->Allocator_Temp, "Pos2_%s", type.Ptr );
|
||||
StrBuilder sym_dir = StrBuilder::fmt_buf( _ctx->Allocator_Temp, "Dir2_%s", type.Ptr);
|
||||
StrBuilder sym_dist = StrBuilder::fmt_buf( _ctx->Allocator_Temp, "Dist_%s", type.Ptr );
|
||||
StrBuilder sym_vel = StrBuilder::fmt_buf( _ctx->Allocator_Temp, "Vel2_%s", type.Ptr );
|
||||
StrBuilder sym_accel = StrBuilder::fmt_buf( _ctx->Allocator_Temp, "Accel2_%s", type.Ptr );
|
||||
|
||||
#pragma push_macro("pcast")
|
||||
#pragma push_macro("rcast")
|
||||
@ -351,15 +354,15 @@ Code gen__phys2( StrC type )
|
||||
return pcast( <type>, vec );
|
||||
}
|
||||
);
|
||||
CodeBody pos_struct = parse_global_body( token_fmt( "type", (StrC)sym_pos, "unit_type", type, "vec_type", (StrC)sym_vec, tmpl_struct ));
|
||||
CodeBody pos_ops = parse_global_body( token_fmt( "type", (StrC)sym_pos, "unit_type", type, vec2f_ops ));
|
||||
CodeBody pos_struct = parse_global_body( token_fmt( "type", (GStr)sym_pos, "unit_type", type, "vec_type", (GStr)sym_vec, tmpl_struct ));
|
||||
CodeBody pos_ops = parse_global_body( token_fmt( "type", (GStr)sym_pos, "unit_type", type, vec2f_ops ));
|
||||
|
||||
CodeBody dir_struct = parse_global_body( token_fmt(
|
||||
"type", (StrC)sym_dir,
|
||||
"type", (GStr)sym_dir,
|
||||
"unit_type", type,
|
||||
"vec_type", (StrC)sym_vec,
|
||||
"vel_type", (StrC)sym_vel,
|
||||
"accel_type", (StrC)sym_accel,
|
||||
"vec_type", (GStr)sym_vec,
|
||||
"vel_type", (GStr)sym_vel,
|
||||
"accel_type", (GStr)sym_accel,
|
||||
stringize(
|
||||
struct <type>
|
||||
{
|
||||
@ -396,10 +399,10 @@ Code gen__phys2( StrC type )
|
||||
)));
|
||||
|
||||
CodeBody dist_def = parse_global_body( token_fmt(
|
||||
"type", (StrC)sym_dist,
|
||||
"type", (GStr)sym_dist,
|
||||
"unit_type", type,
|
||||
"dist_type", (StrC)sym_dist,
|
||||
"pos_type", (StrC)sym_pos,
|
||||
"dist_type", (GStr)sym_dist,
|
||||
"pos_type", (GStr)sym_pos,
|
||||
stringize(
|
||||
using <dist_type> = <unit_type>;
|
||||
|
||||
@ -413,20 +416,20 @@ Code gen__phys2( StrC type )
|
||||
}
|
||||
)));
|
||||
|
||||
CodeBody vel_struct = parse_global_body( token_fmt( "type", (StrC)sym_vel, "unit_type", type, "vec_type", (StrC)sym_vec, tmpl_struct ));
|
||||
CodeBody vel_ops = parse_global_body( token_fmt( "type", (StrC)sym_vel, "unit_type", type, vec2f_ops ));
|
||||
CodeBody vel_struct = parse_global_body( token_fmt( "type", (GStr)sym_vel, "unit_type", type, "vec_type", (GStr)sym_vec, tmpl_struct ));
|
||||
CodeBody vel_ops = parse_global_body( token_fmt( "type", (GStr)sym_vel, "unit_type", type, vec2f_ops ));
|
||||
|
||||
CodeBody accel_struct = parse_global_body( token_fmt( "type", (StrC)sym_accel, "unit_type", type, "vec_type", (StrC)sym_vec, tmpl_struct ));
|
||||
CodeBody accel_ops = parse_global_body( token_fmt( "type", (StrC)sym_accel, "unit_type", type, vec2f_ops ));
|
||||
CodeBody accel_struct = parse_global_body( token_fmt( "type", (GStr)sym_accel, "unit_type", type, "vec_type", (GStr)sym_vec, tmpl_struct ));
|
||||
CodeBody accel_ops = parse_global_body( token_fmt( "type", (GStr)sym_accel, "unit_type", type, vec2f_ops ));
|
||||
|
||||
// TODO(Ed): Is there a better name for this?
|
||||
Code ops = parse_global_body( token_fmt(
|
||||
"unit_type", (StrC)type,
|
||||
"vec_type", (StrC)sym_vec,
|
||||
"pos_type", (StrC)sym_pos,
|
||||
"dir_type", (StrC)sym_dir,
|
||||
"vel_type", (StrC)sym_vel,
|
||||
"accel_type", (StrC)sym_accel,
|
||||
"unit_type", (GStr)type,
|
||||
"vec_type", (GStr)sym_vec,
|
||||
"pos_type", (GStr)sym_pos,
|
||||
"dir_type", (GStr)sym_dir,
|
||||
"vel_type", (GStr)sym_vel,
|
||||
"accel_type", (GStr)sym_accel,
|
||||
stringize(
|
||||
inline
|
||||
<vel_type> velocity( <pos_type> a, <pos_type> b ) {
|
||||
@ -508,7 +511,8 @@ Code gen__phys2( StrC type )
|
||||
|
||||
int gen_main()
|
||||
{
|
||||
gen::init();
|
||||
gen::Context ctx {};
|
||||
gen::init( & ctx);
|
||||
log_fmt("Generating code for Handmade Hero: Engine Module\n");
|
||||
|
||||
CodeComment cmt_gen_notice = def_comment( txt("This was generated by project/codegen/engine_gen.cpp") );
|
||||
|
@ -15,7 +15,7 @@
|
||||
#undef do_once_end
|
||||
#undef min
|
||||
#undef max
|
||||
using namespace gen;
|
||||
#undef cast
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@ -37,9 +37,13 @@ using namespace gen;
|
||||
#include "engine/engine_to_platform_api.hpp"
|
||||
#include "engine/gen/physics.hpp"
|
||||
|
||||
constexpr StrC fname_handmade_engine_symbols = txt("handmade_engine.symbols");
|
||||
using namespace gen;
|
||||
|
||||
void get_symbols_from_module_table( FileContents symbol_table, Array<String> symbols )
|
||||
using GStr = gen::Str;
|
||||
|
||||
constexpr GStr fname_handmade_engine_symbols = txt("handmade_engine.symbols");
|
||||
|
||||
void get_symbols_from_module_table( FileContents symbol_table, Array<StrBuilder> symbols )
|
||||
{
|
||||
struct Token
|
||||
{
|
||||
@ -66,17 +70,18 @@ void get_symbols_from_module_table( FileContents symbol_table, Array<String> sym
|
||||
++ scanner;
|
||||
++ token.Len;
|
||||
}
|
||||
symbols.append( String::make_length( GlobalAllocator, token.Ptr, token.Len ) );
|
||||
symbols.append( StrBuilder::make_length( _ctx->Allocator_Temp, token.Ptr, token.Len ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int gen_main()
|
||||
{
|
||||
gen::init();
|
||||
gen::Context ctx {};
|
||||
gen::init( & ctx);
|
||||
log_fmt("Generating code for Handmade Hero: Engine Module (Post-Build)\n");
|
||||
|
||||
FileContents symbol_table = file_read_contents( GlobalAllocator, true, fname_handmade_engine_symbols );
|
||||
FileContents symbol_table = file_read_contents( ctx.Allocator_Temp, true, fname_handmade_engine_symbols );
|
||||
|
||||
#pragma push_macro("str_ascii")
|
||||
#undef str_ascii
|
||||
@ -86,24 +91,24 @@ int gen_main()
|
||||
builder.print( fmt_newline );
|
||||
builder.print_fmt( "NS_ENGINE_BEGIN\n\n" );
|
||||
|
||||
Array<String> symbols = Array<String>::init_reserve( GlobalAllocator, kilobytes(1) );
|
||||
Array<StrBuilder> symbols = Array<StrBuilder>::init_reserve( ctx.Allocator_Temp, kilobytes(1) );
|
||||
get_symbols_from_module_table( symbol_table, symbols );
|
||||
|
||||
using ModuleAPI = engine::ModuleAPI;
|
||||
|
||||
builder.print( parse_variable( token_fmt( "symbol", (StrC)symbols[ModuleAPI::Sym_OnModuleReload], stringize(
|
||||
builder.print( parse_variable( token_fmt( "symbol", (GStr)symbols[ModuleAPI::Sym_OnModuleReload], stringize(
|
||||
constexpr const Str symbol_on_module_load = str_ascii("<symbol>");
|
||||
))));
|
||||
builder.print( parse_variable( token_fmt( "symbol", (StrC)symbols[ModuleAPI::Sym_Startup], stringize(
|
||||
builder.print( parse_variable( token_fmt( "symbol", (GStr)symbols[ModuleAPI::Sym_Startup], stringize(
|
||||
constexpr const Str symbol_startup = str_ascii("<symbol>");
|
||||
))));
|
||||
builder.print( parse_variable( token_fmt( "symbol", (StrC)symbols[ModuleAPI::Sym_Shutdown], stringize(
|
||||
builder.print( parse_variable( token_fmt( "symbol", (GStr)symbols[ModuleAPI::Sym_Shutdown], stringize(
|
||||
constexpr const Str symbol_shutdown = str_ascii("<symbol>");
|
||||
))));
|
||||
builder.print( parse_variable( token_fmt( "symbol", (StrC)symbols[ModuleAPI::Sym_UpdateAndRender], stringize(
|
||||
builder.print( parse_variable( token_fmt( "symbol", (GStr)symbols[ModuleAPI::Sym_UpdateAndRender], stringize(
|
||||
constexpr const Str symbol_update_and_render = str_ascii("<symbol>");
|
||||
))));
|
||||
builder.print( parse_variable( token_fmt( "symbol", (StrC)symbols[ModuleAPI::Sym_UpdateAudio], stringize(
|
||||
builder.print( parse_variable( token_fmt( "symbol", (GStr)symbols[ModuleAPI::Sym_UpdateAudio], stringize(
|
||||
constexpr const Str symbol_update_audio = str_ascii("<symbol>");
|
||||
))));
|
||||
|
||||
|
@ -6,14 +6,17 @@
|
||||
#include "dependencies/gen.hpp"
|
||||
#undef min
|
||||
#undef max
|
||||
using namespace gen;
|
||||
#undef cast
|
||||
|
||||
#define path_gen "./gen/"
|
||||
|
||||
using namespace gen;
|
||||
using GStr = gen::Str;
|
||||
|
||||
int gen_main()
|
||||
{
|
||||
gen::init();
|
||||
gen::Context ctx {};
|
||||
gen::init( & ctx);
|
||||
log_fmt("Generating code for Handmade Hero: Platform Module\n");
|
||||
|
||||
CodeComment generation_notice = def_comment( txt("This was generated by project/codegen/platform_gen.cpp") );
|
||||
@ -22,15 +25,15 @@ int gen_main()
|
||||
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 ) } );
|
||||
FileContents h_context = file_read_contents(ctx.Allocator_Temp, true, "context.hpp");
|
||||
CodeBody code_context = parse_global_body( { rcast( char const*, h_context.data ), h_context.size } );
|
||||
|
||||
CodeStruct context_struct = {};
|
||||
for ( Code code : code_context )
|
||||
{
|
||||
if ( code->Type == ECode::Struct )
|
||||
if ( code->Type == CT_Struct )
|
||||
{
|
||||
if ( str_compare( code->Name, txt("Context") ) == 0 )
|
||||
if ( code->Name.is_equal(txt("Context")) )
|
||||
{
|
||||
context_struct = code;
|
||||
break;
|
||||
@ -39,10 +42,10 @@ int gen_main()
|
||||
}
|
||||
}
|
||||
|
||||
Array<Code> context_data_members = Array<Code>::init_reserve( GlobalAllocator, kilobytes( 1 ) );
|
||||
Array<Code> context_data_members = Array<Code>::init_reserve( ctx.Allocator_Temp, kilobytes( 1 ) );
|
||||
for ( Code code : context_struct->Body )
|
||||
{
|
||||
if ( code->Type == ECode::Variable )
|
||||
if ( code->Type == CT_Variable )
|
||||
{
|
||||
context_data_members.append( code );
|
||||
}
|
||||
@ -50,22 +53,22 @@ int gen_main()
|
||||
|
||||
CodeDefine using_context;
|
||||
{
|
||||
String using_context_content = String::make_reserve( GlobalAllocator, kilobytes( 1 ) );
|
||||
StrBuilder using_context_content = StrBuilder::make_reserve( ctx.Allocator_Temp, kilobytes( 1 ) );
|
||||
{
|
||||
String
|
||||
StrBuilder
|
||||
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() );
|
||||
content.append( code.to_strbuilder() );
|
||||
|
||||
// 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() );
|
||||
content.append( context_data_members[ context_data_members.num() - 1 ].to_strbuilder() );
|
||||
}
|
||||
using_context = def_define( txt("using_context()"), using_context_content );
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -732,7 +732,7 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
|
||||
}
|
||||
ReleaseDC( window_handle, refresh_dc );
|
||||
|
||||
Engine_Refresh_Hz = 30;
|
||||
Engine_Refresh_Hz = 165;
|
||||
Engine_Frame_Target_MS = 1000.f / scast(f32, Engine_Refresh_Hz);
|
||||
}
|
||||
|
||||
@ -974,7 +974,7 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
|
||||
|
||||
process_pending_window_messages( window_handle, new_keyboard, new_mouse );
|
||||
|
||||
// f32 delta_time = timing_get_seconds_elapsed( last_frame_clock, timing_get_wall_clock() );
|
||||
// f32 delta_time = timing_get_ms_elapsed( last_frame_clock, timing_get_wall_clock() );
|
||||
|
||||
// Engine's logical iteration and rendering process
|
||||
engine_api.update_and_render( delta_time, & input, rcast(engine::OffscreenBuffer*, & Surface_Back_Buffer.memory )
|
||||
|
Loading…
Reference in New Issue
Block a user