Parsing constructors work, finally reached parity.

This commit is contained in:
2023-07-15 23:07:30 -04:00
parent 1e79c9190e
commit 805e69bb40
9 changed files with 74 additions and 58 deletions

View File

@@ -32,7 +32,7 @@ Code gen__array( StrC type )
name = { name_len, name_str };
};
Code array = parse_struct( token_fmt( "ArrayType", name, "type", type,
CodeStruct array = parse_struct( token_fmt( "ArrayType", name, "type", type,
stringize(
struct <ArrayType>
{
@@ -108,7 +108,7 @@ Code gen__array( StrC type )
void free( void )
{
Header& header = get_header();
zpl::free( header.Allocator, &header );
gen::free( header.Allocator, &header );
}
Header& get_header( void )
@@ -136,14 +136,14 @@ Code gen__array( StrC type )
{
Header& header = get_header();
ZPL_ASSERT( header.Num > 0 );
GEN_ASSERT( header.Num > 0 );
header.Num--;
}
void remove_at( uw idx )
{
Header* header = &get_header();
ZPL_ASSERT( idx < header->Num );
GEN_ASSERT( idx < header->Num );
mem_move( header + idx, header + idx + 1, sizeof( Type ) * ( header->Num - idx - 1 ) );
header->Num--;
@@ -195,7 +195,7 @@ Code gen__array( StrC type )
new_header->Num = header.Num;
new_header->Capacity = new_capacity;
zpl::free( header.Allocator, &header );
gen::free( header.Allocator, &header );
Data = ( Type* )new_header + 1;
return true;
@@ -251,8 +251,8 @@ u32 gen_array_file()
gen_array_file;
gen_array_file.open( "array.Parsed.gen.hpp" );
Code include_zpl = def_include( txt_StrC("gen.hpp") );
gen_array_file.print( include_zpl );
Code include_gen = def_include( txt_StrC("gen.hpp") );
gen_array_file.print( include_gen );
gen_array_file.print( def_using_namespace( name(gen)));

View File

@@ -75,7 +75,7 @@ Code gen__buffer( StrC type )
void append( Type* values, sw num )
{
Header& header = get_header();
ZPL_ASSERT( header.Num + num <= header.Capacity);
GEN_ASSERT( header.Num + num <= header.Capacity);
mem_copy( Data + header.Num, values, num * sizeof( Type ) );
header.Num += num;
@@ -96,7 +96,7 @@ Code gen__buffer( StrC type )
void free( void )
{
Header& header = get_header();
zpl::free( header.Backing, &header );
gen::free( header.Backing, &header );
}
Header& get_header( void )

View File

@@ -99,7 +99,7 @@ Code gen__hashtable( StrC type )
void map( MapProc map_proc )
{
ZPL_ASSERT_NOT_NULL( map_proc );
GEN_ASSERT_NOT_NULL( map_proc );
for ( sw idx = 0; idx < Entries.num(); idx++ )
{
@@ -109,7 +109,7 @@ Code gen__hashtable( StrC type )
void map_mut( MapMutProc map_proc )
{
ZPL_ASSERT_NOT_NULL( map_proc );
GEN_ASSERT_NOT_NULL( map_proc );
for ( sw idx = 0; idx < Entries.num(); idx++ )
{

View File

@@ -16,7 +16,7 @@ u32 gen_sanity()
// Typedef
{
Code u8_typedef = parse_typedef( code(
CodeTypedef u8_typedef = parse_typedef( code(
typedef unsigned char u8;
));
@@ -46,11 +46,11 @@ u32 gen_sanity()
// Enum
{
Code fwd = parse_enum( code(
CodeEnum fwd = parse_enum( code(
enum ETestEnum : u8;
));
Code def = parse_enum( code(
CodeEnum def = parse_enum( code(
enum ETestEnum : u8
{
A,
@@ -59,7 +59,7 @@ u32 gen_sanity()
};
));
Code fwd_enum_class = parse_enum( code(
CodeEnum fwd_enum_class = parse_enum( code(
enum class ETestEnumClass : u8;
));
@@ -89,11 +89,11 @@ u32 gen_sanity()
// Friend
{
Code fwd = parse_class( code(
CodeClass fwd = parse_class( code(
class TestFriendClass;
));
Code def = parse_class( code(
CodeClass def = parse_class( code(
class TestFriend
{
friend class TestFriendClass;
@@ -143,7 +143,7 @@ u32 gen_sanity()
// Operator
{
Code bitflagtest = parse_enum( code(
CodeEnum bitflagtest = parse_enum( code(
enum class EBitFlagTest : u8
{
A = 1 << 0,
@@ -152,11 +152,11 @@ u32 gen_sanity()
};
));
Code op_fwd = parse_operator( code(
CodeOperator op_fwd = parse_operator( code(
EBitFlagTest operator | ( EBitFlagTest a, EBitFlagTest b );
));
Code op_or = parse_operator( code(
CodeOperator op_or = parse_operator( code(
EBitFlagTest operator | ( EBitFlagTest a, EBitFlagTest b )
{
return EBitFlagTest( (u8)a | (u8)b );
@@ -211,12 +211,12 @@ u32 gen_sanity()
// Specifiers
{
Code fwd_fn = parse_function( code(
CodeFn fwd_fn = parse_function( code(
inline
void test_function_specifiers();
));
Code typedef_u8_ptr = parse_typedef( code(
CodeTypedef typedef_u8_ptr = parse_typedef( code(
typedef u8* u8_ptr;
));
@@ -258,7 +258,7 @@ u32 gen_sanity()
gen_sanity_file.print( parse_typedef( code( typedef unsigned short u16; )) );
gen_sanity_file.print( parse_typedef( code( typedef unsigned long u32; )) );
Code def = parse_union( code(
CodeUnion def = parse_union( code(
union TestUnion
{
u8 a;
@@ -275,18 +275,18 @@ u32 gen_sanity()
// Using
{
Code reg = parse_using( code(
CodeUsing reg = (CodeUsing) parse_using( code(
using TestUsing = u8;
));
Code nspace = parse_namespace( code(
CodeNamespace nspace = parse_namespace( code(
namespace TestNamespace
{
};
));
Code npspace_using = parse_using( code(
CodeUsingNamespace npspace_using = (CodeUsingNamespace) parse_using( code(
using namespace TestNamespace;
));
@@ -299,11 +299,11 @@ u32 gen_sanity()
// Variable
{
Code bss = parse_variable( code(
CodeVar bss = parse_variable( code(
u8 test_variable;
));
Code data = parse_variable( code(
CodeVar data = parse_variable( code(
u8 test_variable = 0x12;
));
@@ -317,7 +317,7 @@ u32 gen_sanity()
{
#pragma push_macro("template")
#undef template
Code tmpl = parse_template( code(
CodeTemplate tmpl = parse_template( code(
template< typename Type >
void test_template( Type a )
{

View File

@@ -24,7 +24,7 @@ Code gen_SOA( CodeStruct struct_def, s32 num_entries = 0 )
Array<CodeVar> vars = Array<CodeVar>::init( var_arena );;
CodeStruct soa = def_struct( name, def_body( ECode::Struct_Body ));
CodeStruct soa = def_struct( name, def_struct_body( args( soa_entry ) ));
{
for ( Code struct_mem : struct_def->Body )
{

View File

@@ -11,7 +11,7 @@ includes = include_directories(
# get_sources = files('./get_sources.ps1')
# sources = files(run_command('powershell', get_sources, check: true).stdout().strip().split('\n'))
sources = [ '../test.Upfront.cpp' ]
sources = [ '../test.cpp' ]
if get_option('buildtype').startswith('debug')

View File

@@ -1,7 +1,6 @@
#ifdef gen_time
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
#define GEN_FEATURE_PARSING
#include "Upfront\Sanity.Upfront.hpp"
#include "Parsed\Array.Parsed.hpp"
#include "Parsed\Buffer.Parsed.hpp"
#include "Parsed\HashTable.Parsed.hpp"
@@ -42,7 +41,7 @@ int gen_main()
using u16 = unsigned short;
)));
soa_test.print( def_include( txt_StrC("Bloat.hpp")));
soa_test.print( def_include( txt_StrC("gen.hpp")));
soa_test.print( def_using_namespace( name(gen) ) );
@@ -55,8 +54,7 @@ int gen_main()
u32 C;
u64 D;
};
)),
128
))
));
soa_test.write();