Finished refactoring library, still working on cleaning up tests.

This commit is contained in:
Edward R. Gonzalez 2023-07-15 15:20:55 -04:00
parent 9ce859ec64
commit 8f4a94545c
10 changed files with 1895 additions and 1599 deletions

View File

@ -22,5 +22,6 @@
},
"C_Cpp.intelliSenseEngineFallback": "disabled",
"mesonbuild.configureOnOpen": true,
"C_Cpp.errorSquiggles": "enabled"
"C_Cpp.errorSquiggles": "enabled",
"godot_tools.scene_file_config": ""
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<StepFilter xmlns="http://schemas.microsoft.com/vstudio/debugger/natstepfilter/2010">
<Function>
<Name>gen::.*::raw</Name>
<Action>NoStepInto</Action>
</Function>
<Function>
<Name>gen::Code.*::debug_str</Name>
<Action>NoStepInto</Action>
</Function>
<Function>
<Name>gen::Code.*::duplicate</Name>
<Action>NoStepInto</Action>
</Function>
<Function>
<Name>gen::Code.*::has_entries</Name>
<Action>NoStepInto</Action>
</Function>
<Function>
<Name>gen::Code.*::is_equal</Name>
<Action>NoStepInto</Action>
</Function>
<Function>
<Name>gen::Code.*::to_string</Name>
<Action>NoStepInto</Action>
</Function>
</StepFilter>

View File

@ -743,7 +743,7 @@
</Expand>
</Type>
<Type Name="gen::CodeSpecifiers">
<Type Name="gen::CodeSpecifier">
<DisplayString Condition="ast != nullptr">{ast->Name} {ast->Type}</DisplayString>
<Expand>
<ArrayItems Name="ArrSpecs" Condition="ast != nullptr" Size="ast->NumEntries">

View File

@ -36,7 +36,7 @@ u32 gen_sanity()
{};
));
empty_body.body()->add_entry( def_comment( txt_StrC("Empty class body") ) );
empty_body->Body.append( def_comment( txt_StrC("Empty class body") ) );
gen_sanity_file.print(fwd);
gen_sanity_file.print(empty_body);
@ -80,7 +80,7 @@ u32 gen_sanity()
};
));
c_extern.body()->add_entry( empty_comment );
c_extern->Body.append( empty_comment );
gen_sanity_file.print(c_extern);
}
@ -118,7 +118,7 @@ u32 gen_sanity()
}
));
def.body()->add_entry( def_comment( txt_StrC("Empty function body") ) );
def->Body.append( def_comment( txt_StrC("Empty function body") ) );
gen_sanity_file.print(fwd);
gen_sanity_file.print(def);
@ -134,7 +134,7 @@ u32 gen_sanity()
}
));
def.body()->add_entry( def_comment( txt_StrC("Empty namespace body") ) );
def->Body.append( def_comment( txt_StrC("Empty namespace body") ) );
gen_sanity_file.print(def);
}
@ -172,7 +172,7 @@ u32 gen_sanity()
// Operator cast
{
CodeClass op_ptr = parse_operator_cast( code(
CodeOpCast op_ptr = parse_operator_cast( code(
operator u8* ();
));
@ -182,7 +182,7 @@ u32 gen_sanity()
};
));
class_def.body()->add_entry( op_ptr );
class_def->Body.append( op_ptr );
gen_sanity_file.print(class_def);
}
@ -201,7 +201,7 @@ u32 gen_sanity()
}
));
def.body()->add_entry( def_comment( txt_StrC("Empty function body") ) );
def->Body.append( def_comment( txt_StrC("Empty function body") ) );
gen_sanity_file.print(fwd);
gen_sanity_file.print(def);
@ -237,7 +237,7 @@ u32 gen_sanity()
{};
));
empty_body.body()->add_entry( def_comment( txt_StrC("Empty struct body") ) );
empty_body->Body.append( def_comment( txt_StrC("Empty struct body") ) );
gen_sanity_file.print(fwd);
gen_sanity_file.print(empty_body);
@ -253,7 +253,7 @@ u32 gen_sanity()
};
));
empty.body()->add_entry( def_comment( txt_StrC("Empty union body") ) );
empty->Body.append( def_comment( txt_StrC("Empty union body") ) );
gen_sanity_file.print( parse_typedef( code( typedef unsigned short u16; )) );
gen_sanity_file.print( parse_typedef( code( typedef unsigned long u32; )) );

View File

@ -11,7 +11,7 @@ Code gen_SOA( CodeStruct struct_def, s32 num_entries = 0 )
));
Code
soa_entry = { struct_def->duplicate() };
soa_entry = { struct_def.raw()->duplicate() };
soa_entry->Name = get_cached_string( name(Entry) );
constexpr s32 Num_Vars_Cap = 128;
@ -26,11 +26,11 @@ Code gen_SOA( CodeStruct struct_def, s32 num_entries = 0 )
CodeStruct soa = def_struct( name, def_body( ECode::Struct_Body ));
{
for ( Code struct_mem : struct_def.body() )
for ( Code struct_mem : struct_def->Body )
{
if ( struct_mem->Type == ECode::Variable )
{
CodeType var_type = CodeVar(struct_mem).type();
CodeType var_type = struct_mem->cast<CodeVar>()->ValueType;
StrC num_entries_str = to_StrC( str_fmt_buf( "%d", num_entries ) );
CodeVar entry_arr = { nullptr };
@ -48,7 +48,7 @@ Code gen_SOA( CodeStruct struct_def, s32 num_entries = 0 )
}
vars.append( entry_arr );
soa.body()->add_entry( entry_arr );
soa->Body.append( entry_arr );
}
}
}
@ -69,15 +69,15 @@ Code gen_SOA( CodeStruct struct_def, s32 num_entries = 0 )
{
for ( CodeVar member : vars )
{
Code arr_init = def_execution( token_fmt( "var_name", (StrC)member->Name, "var_type", (StrC)member->entry(0)->Name,
Code arr_init = def_execution( token_fmt( "var_name", (StrC)member->Name, "var_type", (StrC)member->ValueType->Name,
stringize( soa.<var_name> = <var_type>::init( allocator ); )
));
make.body()->add_entry( arr_init );
make->Body.append( arr_init );
}
}
make.body()->add_entry( def_execution( code( return soa; ) ));
make->Body.append( def_execution( code( return soa; ) ));
}
CodeFn get;
@ -101,12 +101,12 @@ Code gen_SOA( CodeStruct struct_def, s32 num_entries = 0 )
CodeExec ret = def_execution( content );
get.body()->add_entry( ret );
get->Body.append( ret );
}
soa.body()->add_entry( make );
soa.body()->add_entry( get );
soa.body()->validate_body();
soa->Body.append( make );
soa->Body.append( get );
soa->Body.raw()->validate_body();
vars.free();
return soa;

View File

@ -7,9 +7,9 @@ using namespace gen;
Code gen__array_base()
{
Code t_allocator_info = def_type( name(AllocatorInfo) );
CodeType t_allocator_info = def_type( name(AllocatorInfo) );
CodeStruct header = def_struct( name(ArrayHeader),
CodeStruct header = def_struct( name(ArrayHeader),
def_struct_body( args(
def_variable( t_allocator_info, name(Allocator) )
, def_variable( t_uw, name(Capacity) )
@ -29,9 +29,9 @@ Code gen__array( StrC type )
static CodeType t_allocator_info = def_type( name(AllocatorInfo) );
static Code v_nullptr = code_str(nullptr);
static CodeSpecifiers spec_ct_member = def_specifiers( 2, ESpecifier::Constexpr, ESpecifier::Static_Member );
static CodeSpecifiers spec_static_inline = def_specifiers( 2, ESpecifier::Static_Member, ESpecifier::Inline );
static CodeSpecifiers spec_static = def_specifier( ESpecifier::Static_Member );
static CodeSpecifier spec_ct_member = def_specifiers( 2, ESpecifier::Constexpr, ESpecifier::Static_Member );
static CodeSpecifier spec_static_inline = def_specifiers( 2, ESpecifier::Static_Member, ESpecifier::Inline );
static CodeSpecifier spec_static = def_specifier( ESpecifier::Static_Member );
static CodeUsing using_header = def_using( name(Header), def_type( name(ArrayHeader) ) );
static CodeVar ct_grow_formula = def_variable( t_auto, name(grow_formula), untyped_str( code( & array_grow_formula )), spec_ct_member );
@ -44,35 +44,35 @@ Code gen__array( StrC type )
name = { name_len, name_str };
};
Code t_array_type = def_type( name );
CodeType t_array_type = def_type( name );
Code t_type = def_type( type );
Code t_type_ptr = def_type( type, __, spec_ptr );
Code t_type_ref = def_type( type, __, spec_ref );
CodeType t_type = def_type( type );
CodeType t_type_ptr = def_type( type, __, spec_ptr );
CodeType t_type_ref = def_type( type, __, spec_ref );
Code t_alias = def_type( name(Type) );
Code t_alias_ptr = def_type( name(Type), __, spec_ptr );
Code t_alias_ref = def_type( name(Type), __, spec_ref );
CodeType t_alias = def_type( name(Type) );
CodeType t_alias_ptr = def_type( name(Type), __, spec_ptr );
CodeType t_alias_ref = def_type( name(Type), __, spec_ref );
Code t_header = def_type( name(Header) );
Code t_header_ptr = def_type( name(Header), __, spec_ptr );
Code t_header_ref = def_type( name(Header), __, spec_ref );
CodeType t_header = def_type( name(Header) );
CodeType t_header_ptr = def_type( name(Header), __, spec_ptr );
CodeType t_header_ref = def_type( name(Header), __, spec_ref );
Code array = {0};
CodeStruct array = {0};
{
Code using_type = def_using( name(Type), t_type );
Code data = def_variable( t_alias_ptr, name(Data) );
CodeUsing using_type = def_using( name(Type), t_type );
CodeVar data = def_variable( t_alias_ptr, name(Data) );
Code init = def_function( name(init), def_param( t_allocator_info, name(allocator) ), t_array_type
CodeFn init = def_function( name(init), def_param( t_allocator_info, name(allocator) ), t_array_type
, def_execution( code(
return init_reserve( allocator, grow_formula(0) );
))
, spec_static
);
Code init_reserve;
CodeFn init_reserve;
{
Code params = def_params( args(
CodeParam params = def_params( args(
def_param( t_allocator_info, name(allocator) )
, def_param( t_sw, name(capacity) )
));
@ -93,7 +93,7 @@ Code gen__array( StrC type )
init_reserve = def_function( name(init_reserve), params, t_array_type, body, spec_static );
}
Code append = def_function( name(append), def_param(t_alias, name(value)), t_bool
CodeFn append = def_function( name(append), def_param(t_alias, name(value)), t_bool
, def_execution( code(
Header* header = get_header();
@ -112,23 +112,23 @@ Code gen__array( StrC type )
))
);
Code back = def_function( name(back), __, t_alias_ref
CodeFn back = def_function( name(back), __, t_alias_ref
, def_execution( code(
Header& header = * get_header();
return Data[ header.Num - 1 ];
))
);
Code clear = def_function( name(clear), __, t_void
CodeFn clear = def_function( name(clear), __, t_void
, def_execution( code(
Header& header = * get_header();
header.Num = 0;
))
);
Code fill;
CodeFn fill;
{
Code params = def_params( 3
CodeParam params = def_params( 3
, def_param( t_uw, name(begin) )
, def_param( t_uw, name(end) )
, def_param( t_alias, name(value) )
@ -151,20 +151,20 @@ Code gen__array( StrC type )
fill = def_function( name(fill), params, t_bool, body );
}
Code free = def_function( name(free), __, t_void
CodeFn free = def_function( name(free), __, t_void
, def_execution( code(
Header* header = get_header();
gen::free( header->Allocator, header );
))
);
Code get_header = def_function( name(get_header), __, t_header_ptr
CodeFn get_header = def_function( name(get_header), __, t_header_ptr
, def_execution( code(
return rcast( Header*, Data ) - 1;
))
);
Code grow = def_function( name(grow), def_param( t_uw, name(min_capacity)), t_bool
CodeFn grow = def_function( name(grow), def_param( t_uw, name(min_capacity)), t_bool
, def_execution( code(
Header& header = * get_header();
@ -177,13 +177,13 @@ Code gen__array( StrC type )
))
);
Code num = def_function( name(num), __, t_uw
CodeFn num = def_function( name(num), __, t_uw
, def_execution( code(
return get_header()->Num;
))
);
Code pop = def_function( name(pop), __, t_bool
CodeFn pop = def_function( name(pop), __, t_bool
, def_execution( code(
Header& header = * get_header();
@ -192,7 +192,7 @@ Code gen__array( StrC type )
))
);
Code remove_at = def_function( name(remove_at), def_param( t_uw, name(idx)), t_void
CodeFn remove_at = def_function( name(remove_at), def_param( t_uw, name(idx)), t_void
, def_execution( code(
Header* header = get_header();
ZPL_ASSERT( idx < header->Num );
@ -202,7 +202,7 @@ Code gen__array( StrC type )
))
);
Code reserve = def_function( name(reserve), def_param( t_uw, name(new_capacity)), t_bool
CodeFn reserve = def_function( name(reserve), def_param( t_uw, name(new_capacity)), t_bool
, def_execution( code(
Header& header = * get_header();
@ -213,7 +213,7 @@ Code gen__array( StrC type )
))
);
Code resize = def_function( name(resize), def_param( t_uw, name(num)), t_bool
CodeFn resize = def_function( name(resize), def_param( t_uw, name(num)), t_bool
, def_execution( code(
Header* header = get_header();
@ -230,7 +230,7 @@ Code gen__array( StrC type )
))
);
Code set_capacity;
CodeFn set_capacity;
{
Code body = def_execution( code(
Header& header = * get_header();
@ -261,11 +261,11 @@ Code gen__array( StrC type )
set_capacity = def_function( name(set_capacity), def_param( t_uw, name(new_capacity)), t_bool, body );
}
Code op_ptr = def_operator_cast( t_type_ptr, def_execution( code(
CodeOpCast op_ptr = def_operator_cast( t_type_ptr, def_execution( code(
return Data;
)));
Code body = def_struct_body( args(
CodeBody body = def_struct_body( args(
using_header
, using_type
, ct_grow_formula
@ -334,7 +334,7 @@ u32 gen_array_file()
gen_array_file;
gen_array_file.open( "array.Upfront.gen.hpp" );
Code include_zpl = def_include( txt_StrC("Bloat.hpp") );
CodeInclude include_zpl = def_include( txt_StrC("Bloat.hpp") );
gen_array_file.print( include_zpl );
gen_array_file.print( def_using_namespace( name(gen)));
@ -355,8 +355,8 @@ u32 gen_array_file()
char const* cmt_str = str_fmt_buf( "// Dependency for %s type", request.Type );
s32 cmt_len = str_len( cmt_str );
Code cmt = def_comment( { cmt_len, cmt_str } );
Code include = def_include( request.Dependency );
CodeComment cmt = def_comment( { cmt_len, cmt_str } );
CodeInclude include = def_include( request.Dependency );
gen_array_file.print( cmt );
gen_array_file.print( include );

View File

@ -7,9 +7,9 @@ using namespace gen;
Code gen__buffer_base()
{
Code t_allocator_info = def_type( name(AllocatorInfo) );
CodeType t_allocator_info = def_type( name(AllocatorInfo) );
Code header = def_struct( name(BufferHeader),
Code header = def_struct( name(BufferHeader),
def_struct_body( args(
def_variable( t_allocator_info, name(Backing) )
, def_variable( t_uw, name(Capacity) )
@ -21,9 +21,9 @@ Code gen__buffer_base()
Code gen__buffer( StrC type, sw type_size )
{
static Code t_allocator_info = def_type( name(AllocatorInfo));
static CodeType t_allocator_info = def_type( name(AllocatorInfo));
static Code using_header = def_using( name(Header), def_type( name(BufferHeader) ) );
static CodeUsing using_header = def_using( name(Header), def_type( name(BufferHeader) ) );
StrC name;
{
@ -33,24 +33,24 @@ Code gen__buffer( StrC type, sw type_size )
name = { name_len, name_str };
};
Code t_buffer_type = def_type( name );
CodeType t_buffer_type = def_type( name );
Code t_type = def_type( type );
Code t_type_ptr = def_type( type, __, spec_ptr );
Code t_type_ref = def_type( type, __, spec_ref );
CodeType t_type = def_type( type );
CodeType t_type_ptr = def_type( type, __, spec_ptr );
CodeType t_type_ref = def_type( type, __, spec_ref );
Code t_header = def_type( name(Header) );
Code t_header_ptr = def_type( name(Header), __, spec_ptr );
Code t_header_ref = def_type( name(Header), __, spec_ref );
CodeType t_header = def_type( name(Header) );
CodeType t_header_ptr = def_type( name(Header), __, spec_ptr );
CodeType t_header_ref = def_type( name(Header), __, spec_ref );
Code buffer = {0};
CodeStruct buffer = {0};
{
Code using_type = def_using( name(Type), t_type );
Code data = def_variable( t_type_ptr, name(Data) );
CodeUsing using_type = def_using( name(Type), t_type );
CodeVar data = def_variable( t_type_ptr, name(Data) );
Code init;
CodeFn init;
{
Code params = def_params( args(
CodeParam params = def_params( args(
def_param( t_allocator_info, name(allocator))
, def_param( t_sw, name(capacity))
));

View File

@ -26,8 +26,8 @@ u32 gen_sanity_upfront()
CodeClass fwd = def_class( name(TestEmptyClass) );
CodeClass empty_body;
{
CodeComment cmt = def_comment( txt_StrC("Empty class body") );
CodeClassBody body = def_class_body( args( cmt ) );
CodeComment cmt = def_comment( txt_StrC("Empty class body") );
CodeBody body = def_class_body( args( cmt ) );
empty_body = def_class( name(TestEmptyClass), body );
}
@ -77,7 +77,7 @@ u32 gen_sanity_upfront()
, def_comment( txt_StrC("Empty extern body") )
);
Code c_extern = def_extern_link( name(C), body );
CodeExtern c_extern = def_extern_link( name(C), body );
gen_sanity_file.print(c_extern);
}
@ -86,8 +86,8 @@ u32 gen_sanity_upfront()
// Friend
{
CodeClass fwd = def_class( name(TestFriendFwd));
CodeClassBody body = def_class_body( args( def_friend( fwd ) ) );
CodeClass fwd = def_class( name(TestFriendFwd));
CodeBody body = def_class_body( args( def_friend( fwd ) ) );
gen_sanity_file.print( def_class( name(TestFriend), body ) );
}
@ -99,7 +99,7 @@ u32 gen_sanity_upfront()
CodeFn fwd = def_function( name(test_function) );
CodeFn def;
{
CodeFnBody body = def_function_body( 1
CodeBody body = def_function_body( 1
, def_comment( txt_StrC("Empty function body") )
);
@ -166,14 +166,14 @@ u32 gen_sanity_upfront()
)));
bitflagtest = def_enum( name(EBitFlagtest), body, t_u8, EnumClass );
}
Code t_bitflag = def_type( name(EBitFlagtest) );
CodeType t_bitflag = def_type( name(EBitFlagtest) );
CodeOperator op_fwd, op_or;
{
CodeParams params = def_params( 2,
CodeParam params = def_params( args(
def_param( t_bitflag, name(a) ),
def_param( t_bitflag, name(b) )
);
));
op_fwd = def_operator( EOperator::BOr, params, t_bitflag );
op_or = def_operator( EOperator::BOr, params, t_bitflag, untyped_str( code(
@ -203,31 +203,31 @@ u32 gen_sanity_upfront()
// Parameters
{
Code fwd;
CodeFn fwd;
{
Code params = def_param( t_u8, name(a) );
CodeParam params = def_param( t_u8, name(a) );
fwd = def_function( name(test_function_wparam), params );
}
Code def, def2;
CodeFn def, def2;
{
Code body = def_function_body( 1
CodeBody body = def_function_body( 1
, def_comment( txt_StrC("Empty function body") )
);
Code params = def_params( args(
CodeParam params = def_params( args(
def_param( t_u8, name(a) )
, def_param( t_u8, name(b) )
));
def = def_function( name(test_function_wparams), params, __, body );
Code param_a = def_param( t_u8, name(a));
Code param_b = def_param( t_u8, name(b));
Code params_arr[2] = { param_a, param_b };
CodeParam param_a = def_param( t_u8, name(a));
CodeParam param_b = def_param( t_u8, name(b));
CodeParam params_arr[2] = { param_a, param_b };
Code params2 = def_params( 2, params_arr );
CodeParam params2 = def_params( 2, params_arr );
def2 = def_function( name(test_function_wparams2), params2, __, body );
}
@ -241,12 +241,12 @@ u32 gen_sanity_upfront()
// Specifiers
{
Code fwd_fn = def_function( name(test_function_specifiers), __, __, __, spec_inline );
CodeFn fwd_fn = def_function( name(test_function_specifiers), __, __, __, spec_inline );
// TODO : Need an op overload here
Code u8_ptr = def_type( name(u8), __, spec_ptr );
Code typedef_u8_ptr = def_typedef( name(ConstExprTest), u8_ptr );
CodeType u8_ptr = def_type( name(u8), __, spec_ptr );
CodeTypedef typedef_u8_ptr = def_typedef( name(ConstExprTest), u8_ptr );
gen_sanity_file.print(fwd_fn);
gen_sanity_file.print(typedef_u8_ptr);
@ -256,11 +256,11 @@ u32 gen_sanity_upfront()
// Struct
{
Code fwd = def_class( name(TestEmptyStruct) );
Code empty_body;
CodeClass fwd = def_class( name(TestEmptyStruct) );
CodeClass empty_body;
{
Code cmt = def_comment( txt_StrC("Empty struct body") );
Code body = def_class_body( args( cmt ) );
CodeComment cmt = def_comment( txt_StrC("Empty struct body") );
CodeBody body = def_class_body( args( cmt ) );
empty_body = def_class( name(TestEmptyStruct), body );
}
@ -273,11 +273,11 @@ u32 gen_sanity_upfront()
// Union
{
Code body = def_union_body( 1
CodeBody body = def_union_body( 1
, def_comment( txt_StrC("Empty union body") )
);
Code def = def_union( name(TestEmptyUnion), body );
CodeUnion def = def_union( name(TestEmptyUnion), body );
gen_sanity_file.print(def);
}
@ -286,8 +286,8 @@ u32 gen_sanity_upfront()
// Using
{
Code reg = def_using( name(TestUsing), t_u8 );
Code nspace = def_using_namespace( name(TestNamespace) );
CodeUsing reg = def_using( name(TestUsing), t_u8 );
CodeUsingNamespace nspace = def_using_namespace( name(TestNamespace) );
gen_sanity_file.print(reg);
gen_sanity_file.print(nspace);
@ -308,7 +308,7 @@ u32 gen_sanity_upfront()
// Template
{
Code t_Type = def_type( name(Type) );
CodeType t_Type = def_type( name(Type) );
Code tmpl = def_template( def_param( t_class, name(Type) )
, def_function( name(test_template), def_param( t_Type, name(a) ), __