mirror of
https://github.com/Ed94/gencpp.git
synced 2025-07-30 00:46:59 -07:00
Parsing constructors passed the sanity test!
This commit is contained in:
@@ -258,12 +258,9 @@ Code gen__array( StrC type, sw type_size )
|
||||
set_capacity = def_function( name(set_capacity), def_param( t_uw, name(new_capacity)), t_bool, body );
|
||||
}
|
||||
|
||||
Code op_ptr = untyped_str( code(
|
||||
operator Type*()
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
));
|
||||
Code op_ptr = def_operator_cast( t_type_ptr, def_execution( code(
|
||||
return Data;
|
||||
)));
|
||||
|
||||
Code body = def_struct_body( 20
|
||||
, using_header
|
||||
@@ -327,7 +324,7 @@ void gen__array_request( StrC type, sw size, StrC dep = {} )
|
||||
GenArrayRequest request = { dep, type, size };
|
||||
array_append( GenArrayRequests, request );
|
||||
}
|
||||
#define gen_array( type ) gen__array_request( { txt_n_len(type) }, sizeof(type) )
|
||||
#define gen_array( type ) gen__array_request( { txt_to_StrC(type) }, sizeof(type) )
|
||||
|
||||
u32 gen_array_file()
|
||||
{
|
||||
|
@@ -172,12 +172,9 @@ Code gen__buffer( StrC type, sw type_size )
|
||||
))
|
||||
);
|
||||
|
||||
Code op_type_ptr = untyped_str( code(
|
||||
operator Type*()
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
));
|
||||
Code op_type_ptr = def_operator_cast( t_type_ptr, def_execution( code(
|
||||
return Data;
|
||||
)));
|
||||
|
||||
buffer = def_struct( name, def_struct_body( 14
|
||||
, using_header
|
||||
@@ -232,7 +229,7 @@ void gen__buffer_request( StrC type, sw size, StrC dep = {} )
|
||||
GenBufferRequest request = { dep, type, size};
|
||||
array_append( GenBufferRequests, request );
|
||||
}
|
||||
#define gen_buffer( type ) gen__buffer_request( { txt_n_len(type) }, sizeof( type ))
|
||||
#define gen_buffer( type ) gen__buffer_request( { txt_to_StrC(type) }, sizeof( type ))
|
||||
|
||||
u32 gen_buffer_file()
|
||||
{
|
||||
|
@@ -425,7 +425,7 @@ void gen__hashtable_request( StrC type, sw size, StrC dep = {} )
|
||||
GenHashTableRequest request = { dep, type, size};
|
||||
array_append( GenHashTableRequests, request );
|
||||
}
|
||||
#define gen_hashtable( type ) gen__hashtable_request( { txt_n_len(type) }, sizeof( type ))
|
||||
#define gen_hashtable( type ) gen__hashtable_request( { txt_to_StrC(type) }, sizeof( type ))
|
||||
|
||||
u32 gen_hashtable_file()
|
||||
{
|
||||
|
@@ -188,7 +188,7 @@ void gen__ring_request( StrC type, sw size, StrC dep = {} )
|
||||
GenRingRequest request = { dep, type, size};
|
||||
array_append( GenRingRequests, request );
|
||||
}
|
||||
#define gen_ring( type ) gen__ring_request( { txt_n_len(type) }, sizeof( type ))
|
||||
#define gen_ring( type ) gen__ring_request( { txt_to_StrC(type) }, sizeof( type ))
|
||||
|
||||
u32 gen_ring_file()
|
||||
{
|
||||
|
@@ -190,6 +190,19 @@ u32 gen_sanity()
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Operator cast
|
||||
{
|
||||
Code t_u8_ptr = def_type( name(u8), __, spec_ptr );
|
||||
|
||||
Code op_ptr = def_operator_cast( t_u8_ptr, __ );
|
||||
|
||||
Code op_class = def_class( name(TestOperatorCast), def_class_body( 1, op_ptr ) );
|
||||
|
||||
gen_sanity_file.print(op_class);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Parameters
|
||||
{
|
||||
Code fwd;
|
||||
@@ -295,6 +308,21 @@ u32 gen_sanity()
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Template
|
||||
{
|
||||
Code 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) ), __
|
||||
, def_function_body(1, def_comment( StrC::from("Empty template function body")))
|
||||
)
|
||||
);
|
||||
|
||||
gen_sanity_file.print(tmpl);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
gen_sanity_file.print( def_comment( StrC::from(
|
||||
"End of base case tests.\n"
|
||||
)));
|
||||
|
@@ -251,7 +251,7 @@ void gen__array_request( StrC type, sw size, StrC dep = {} )
|
||||
GenArrayRequest request = { dep, type, size };
|
||||
array_append( GenArrayRequests, request );
|
||||
}
|
||||
#define gen_array( type ) gen__array_request( { txt_n_len(type) }, sizeof(type) )
|
||||
#define gen_array( type ) gen__array_request( { txt_to_StrC(type) }, sizeof(type) )
|
||||
|
||||
u32 gen_array_file()
|
||||
{
|
||||
|
@@ -142,7 +142,6 @@ u32 gen_sanity()
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Operator
|
||||
if (0)
|
||||
{
|
||||
Code bitflagtest = parse_enum( code(
|
||||
enum class EBitFlagTest : u8
|
||||
@@ -171,6 +170,25 @@ u32 gen_sanity()
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Operator cast
|
||||
{
|
||||
Code op_ptr = parse_operator_cast( code(
|
||||
operator u8* ();
|
||||
));
|
||||
|
||||
Code class_def = parse_class( code(
|
||||
class TestClass
|
||||
{
|
||||
};
|
||||
));
|
||||
|
||||
class_def.body()->add_entry( op_ptr );
|
||||
|
||||
gen_sanity_file.print(class_def);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Parameters
|
||||
{
|
||||
Code fwd = parse_function( code(
|
||||
@@ -209,7 +227,6 @@ u32 gen_sanity()
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Struct
|
||||
if (0)
|
||||
{
|
||||
Code fwd = parse_struct( code(
|
||||
struct TestEmptyStruct;
|
||||
@@ -229,7 +246,6 @@ u32 gen_sanity()
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Union
|
||||
if (0)
|
||||
{
|
||||
Code empty = parse_union( code(
|
||||
union TestEmptyUnion
|
||||
@@ -239,10 +255,13 @@ u32 gen_sanity()
|
||||
|
||||
empty.body()->add_entry( def_comment( StrC::from("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; )) );
|
||||
|
||||
Code def = parse_union( code(
|
||||
union TestUnion
|
||||
{
|
||||
u8 a;
|
||||
u8 a;
|
||||
u16 b;
|
||||
u32 c;
|
||||
};
|
||||
@@ -255,28 +274,30 @@ u32 gen_sanity()
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Using
|
||||
if (0)
|
||||
{
|
||||
Code reg = parse_using( code(
|
||||
using TestUsing = u8;
|
||||
));
|
||||
|
||||
Code nspace = parse_using( code(
|
||||
Code nspace = parse_namespace( code(
|
||||
namespace TestNamespace
|
||||
{
|
||||
};
|
||||
|
||||
using namespace TestUsing;
|
||||
));
|
||||
|
||||
Code npspace_using = parse_using( code(
|
||||
using namespace TestNamespace;
|
||||
));
|
||||
|
||||
gen_sanity_file.print(reg);
|
||||
gen_sanity_file.print(nspace);
|
||||
gen_sanity_file.print(npspace_using);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Variable
|
||||
if (0)
|
||||
{
|
||||
Code bss = parse_variable( code(
|
||||
u8 test_variable;
|
||||
@@ -285,6 +306,26 @@ u32 gen_sanity()
|
||||
Code data = parse_variable( code(
|
||||
u8 test_variable = 0x12;
|
||||
));
|
||||
|
||||
gen_sanity_file.print(bss);
|
||||
gen_sanity_file.print(data);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// template
|
||||
{
|
||||
#pragma push_macro("template")
|
||||
#undef template
|
||||
Code tmpl = parse_template( code(
|
||||
template< typename Type >
|
||||
void test_template( Type a )
|
||||
{
|
||||
}
|
||||
));
|
||||
#pragma pop_macro("template")
|
||||
|
||||
gen_sanity_file.print(tmpl);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
@@ -17,7 +17,7 @@ int gen_main()
|
||||
Memory::setup();
|
||||
gen::init();
|
||||
|
||||
// gen_sanity();
|
||||
gen_sanity();
|
||||
|
||||
gen_array( u8 );
|
||||
// gen_array( sw );
|
||||
|
Reference in New Issue
Block a user