mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-15 03:01:47 -07:00
Readme updates, Updated tests to use args macro more.
This commit is contained in:
@ -9,18 +9,19 @@ Code gen__array_base()
|
||||
{
|
||||
Code t_allocator_info = def_type( name(AllocatorInfo) );
|
||||
|
||||
Code header = def_struct( name(ArrayHeader), def_struct_body( 3
|
||||
, def_variable( t_allocator_info, name(Allocator) )
|
||||
Code header = def_struct( name(ArrayHeader),
|
||||
def_struct_body( args(
|
||||
def_variable( t_allocator_info, name(Allocator) )
|
||||
, def_variable( t_uw, name(Capacity) )
|
||||
, def_variable( t_uw, name(Num) )
|
||||
));
|
||||
)));
|
||||
|
||||
Code grow_formula = def_function( name(array_grow_formula), def_param( t_uw, name(value)), t_uw
|
||||
, def_execution( code( return 2 * value * 8; ) )
|
||||
, def_specifiers( 2, ESpecifier::Static_Member, ESpecifier::Inline )
|
||||
, def_specifiers( args( ESpecifier::Static_Member, ESpecifier::Inline ) )
|
||||
);
|
||||
|
||||
return def_global_body( 2, header, grow_formula );
|
||||
return def_global_body( args( header, grow_formula ) );
|
||||
}
|
||||
|
||||
Code gen__array( StrC type )
|
||||
@ -71,10 +72,10 @@ Code gen__array( StrC type )
|
||||
|
||||
Code init_reserve;
|
||||
{
|
||||
Code params = def_params( 2
|
||||
, def_param( t_allocator_info, name(allocator) )
|
||||
Code params = def_params( args(
|
||||
def_param( t_allocator_info, name(allocator) )
|
||||
, def_param( t_sw, name(capacity) )
|
||||
);
|
||||
));
|
||||
|
||||
Code body = def_execution( code(
|
||||
Header* header = rcast( Header*, alloc( allocator, sizeof(Header) + sizeof(Type) ));
|
||||
@ -264,8 +265,8 @@ Code gen__array( StrC type )
|
||||
return Data;
|
||||
)));
|
||||
|
||||
Code body = def_struct_body( 20
|
||||
, using_header
|
||||
Code body = def_struct_body( args(
|
||||
using_header
|
||||
, using_type
|
||||
, ct_grow_formula
|
||||
|
||||
@ -289,7 +290,7 @@ Code gen__array( StrC type )
|
||||
, op_ptr
|
||||
|
||||
, data
|
||||
);
|
||||
));
|
||||
array = def_struct( name, body );
|
||||
}
|
||||
|
||||
|
@ -9,11 +9,12 @@ Code gen__buffer_base()
|
||||
{
|
||||
Code t_allocator_info = def_type( name(AllocatorInfo) );
|
||||
|
||||
Code header = def_struct( name(BufferHeader), def_struct_body( 3
|
||||
, def_variable( t_allocator_info, name(Backing) )
|
||||
Code header = def_struct( name(BufferHeader),
|
||||
def_struct_body( args(
|
||||
def_variable( t_allocator_info, name(Backing) )
|
||||
, def_variable( t_uw, name(Capacity) )
|
||||
, def_variable( t_uw, name(Num) )
|
||||
));
|
||||
)));
|
||||
|
||||
return def_global_body( 1, header );
|
||||
}
|
||||
@ -49,10 +50,10 @@ Code gen__buffer( StrC type, sw type_size )
|
||||
|
||||
Code init;
|
||||
{
|
||||
Code params = def_params( 2
|
||||
Code params = def_params( args(
|
||||
, def_param( t_allocator_info, name(allocator))
|
||||
, def_param( t_sw, name(capacity))
|
||||
);
|
||||
));
|
||||
|
||||
Code body = def_execution( code(
|
||||
Header* header = rcast( Header*, alloc( allocator, sizeof(Header) + capacity * sizeof(Type) ) );
|
||||
@ -72,10 +73,10 @@ Code gen__buffer( StrC type, sw type_size )
|
||||
|
||||
Code init_copy;
|
||||
{
|
||||
Code params = def_params( 2
|
||||
, def_param( t_allocator_info, name(allocator))
|
||||
Code params = def_params( args(
|
||||
def_param( t_allocator_info, name(allocator))
|
||||
, def_param( t_buffer_type, name(other))
|
||||
);
|
||||
));
|
||||
|
||||
init_copy = def_function( name(init), params, t_buffer_type
|
||||
, def_execution( code(
|
||||
@ -105,10 +106,10 @@ Code gen__buffer( StrC type, sw type_size )
|
||||
|
||||
Code appendv;
|
||||
{
|
||||
Code params = def_params( 2
|
||||
, def_param( t_type_ptr, name( values))
|
||||
Code params = def_params( args(
|
||||
def_param( t_type_ptr, name( values))
|
||||
, def_param( t_sw, name( num))
|
||||
);
|
||||
));
|
||||
|
||||
appendv = def_function( name(append), params, t_void
|
||||
, def_execution( code(
|
||||
@ -176,8 +177,8 @@ Code gen__buffer( StrC type, sw type_size )
|
||||
return Data;
|
||||
)));
|
||||
|
||||
buffer = def_struct( name, def_struct_body( 14
|
||||
, using_header
|
||||
buffer = def_struct( name, def_struct_body( args(
|
||||
using_header
|
||||
, using_type
|
||||
|
||||
, init
|
||||
@ -194,7 +195,7 @@ Code gen__buffer( StrC type, sw type_size )
|
||||
, op_type_ptr
|
||||
|
||||
, data
|
||||
));
|
||||
)));
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
@ -50,11 +50,11 @@ Code gen__hashtable( StrC type )
|
||||
StringCached ht_entry_name = get_cached_string({ len, name_str });
|
||||
|
||||
t_ht_entry = def_type( ht_entry_name );
|
||||
ht_entry = def_struct( ht_entry_name, def_struct_body( 3
|
||||
, def_variable( t_u64, name(Key))
|
||||
ht_entry = def_struct( ht_entry_name, def_struct_body( args(
|
||||
def_variable( t_u64, name(Key))
|
||||
, def_variable( t_sw, name(Next))
|
||||
, def_variable( t_type, name(Value))
|
||||
));
|
||||
)));
|
||||
|
||||
array_ht_entry = gen__array( ht_entry_name );
|
||||
t_array_ht_entry = def_type( array_ht_entry->Name );
|
||||
@ -102,7 +102,7 @@ Code gen__hashtable( StrC type )
|
||||
);
|
||||
Code body = def_execution( token_fmt( "type", (StrC)name, tmpl ) );
|
||||
|
||||
Code params = def_params( 2, def_param( t_allocator_info, name(allocator)), def_param( t_sw, name(num)));
|
||||
Code params = def_params( args( def_param( t_allocator_info, name(allocator)), def_param( t_sw, name(num))));
|
||||
|
||||
init_reserve = def_function( name(init_reserve), params, t_ht_type, body, spec_static_member );
|
||||
}
|
||||
@ -281,10 +281,10 @@ Code gen__hashtable( StrC type )
|
||||
|
||||
Code set;
|
||||
{
|
||||
Code params = def_params( 2
|
||||
, def_param( t_u64, name(key))
|
||||
Code params = def_params( args(
|
||||
def_param( t_u64, name(key))
|
||||
, def_param( t_type, name(value))
|
||||
);
|
||||
));
|
||||
|
||||
Code body = def_execution( code(
|
||||
sw idx;
|
||||
@ -372,7 +372,7 @@ Code gen__hashtable( StrC type )
|
||||
))
|
||||
);
|
||||
|
||||
hashtable = def_struct( name, def_struct_body( 25
|
||||
hashtable = def_struct( name, def_struct_body( args(
|
||||
, using_entry
|
||||
, using_array_entry
|
||||
, using_find_result
|
||||
@ -402,10 +402,10 @@ Code gen__hashtable( StrC type )
|
||||
, add_entry
|
||||
, find
|
||||
, full
|
||||
));
|
||||
)));
|
||||
}
|
||||
|
||||
return def_global_body( 3, ht_entry, array_ht_entry, hashtable );
|
||||
return def_global_body( args( ht_entry, array_ht_entry, hashtable ));
|
||||
}
|
||||
|
||||
struct GenHashTableRequest
|
||||
|
@ -45,10 +45,10 @@ Code gen__ring( StrC type )
|
||||
|
||||
Code init;
|
||||
{
|
||||
Code params = def_params( 2
|
||||
Code params = def_params( args(
|
||||
, def_param( t_allocator_info, name(allocator) )
|
||||
, def_param( t_uw, name(max_size) )
|
||||
);
|
||||
));
|
||||
|
||||
char const* tmpl = stringize(
|
||||
<type> result = { 0 };
|
||||
@ -129,7 +129,7 @@ Code gen__ring( StrC type )
|
||||
))
|
||||
);
|
||||
|
||||
ring = def_struct( name, def_struct_body( 14,
|
||||
ring = def_struct( name, def_struct_body( args(
|
||||
using_type,
|
||||
|
||||
init,
|
||||
@ -147,7 +147,7 @@ Code gen__ring( StrC type )
|
||||
head,
|
||||
tail,
|
||||
buffer
|
||||
));
|
||||
)));
|
||||
}
|
||||
|
||||
return ring;
|
||||
|
@ -218,10 +218,10 @@ u32 gen_sanity()
|
||||
, def_comment( txt_StrC("Empty function body") )
|
||||
);
|
||||
|
||||
Code params = def_params( 2
|
||||
, def_param( t_u8, name(a) )
|
||||
Code 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 );
|
||||
|
||||
|
Reference in New Issue
Block a user