gencpp : General refactors to dependencies

Mostly just cleanup and renaming of certain stuff (mostly in dependencies).

* Changed uw and sw to usize and ssize.
* Removed zpl_cast usage throughout dependencies
* No longer using GEN_DEF_INLINE & GEN_IMPL_INLINE
* header_start.hpp renamed to platform.hpp for depdendencies header.
This commit is contained in:
2024-10-27 18:58:37 -04:00
parent 00df336610
commit 2e5e31ed3b
49 changed files with 1059 additions and 988 deletions

View File

@ -142,7 +142,7 @@ Code gen__array( StrC type )
if ( begin < 0 || end >= header.Num )
return false;
for ( sw idx = begin; idx < end; idx++ )
for ( ssize idx = begin; idx < end; idx++ )
{
Data[ idx ] = value;
}
@ -170,7 +170,7 @@ Code gen__array( StrC type )
, def_execution( code(
Header& header = * get_header();
uw new_capacity = grow_formula( header.Capacity );
usize new_capacity = grow_formula( header.Capacity );
if ( new_capacity < min_capacity )
new_capacity = 8;
@ -243,7 +243,7 @@ Code gen__array( StrC type )
if ( new_capacity < header.Num )
header.Num = new_capacity;
sw size = sizeof(Header) + sizeof(Type) * new_capacity;
ssize size = sizeof(Header) + sizeof(Type) * new_capacity;
Header* new_header = rcast( Header*, alloc( header.Allocator, size ));
if ( new_header == nullptr )
@ -314,7 +314,7 @@ void gen__array_request( StrC type, StrC dep = {} )
do_once_end
// Make sure we don't already have a request for the type.
for ( sw idx = 0; idx < GenArrayRequests.num(); ++idx )
for ( ssize idx = 0; idx < GenArrayRequests.num(); ++idx )
{
StrC const reqest_type = GenArrayRequests[ idx ].Type;

View File

@ -19,7 +19,7 @@ Code gen__buffer_base()
return def_global_body( 1, header );
}
Code gen__buffer( StrC type, sw type_size )
Code gen__buffer( StrC type, ssize type_size )
{
static CodeType t_allocator_info = def_type( name(AllocatorInfo));
@ -206,7 +206,7 @@ struct GenBufferRequest
{
StrC Dependency;
StrC Type;
sw TypeSize;
ssize TypeSize;
};
Array<GenBufferRequest> GenBufferRequests;
@ -217,7 +217,7 @@ void gen__buffer_request( StrC type, StrC dep = {} )
do_once_end
// Make sure we don't already have a request for the type.
for ( sw idx = 0; idx < GenBufferRequests.num(); ++idx )
for ( ssize idx = 0; idx < GenBufferRequests.num(); ++idx )
{
StrC const reqest_type = GenBufferRequests[ idx ].Type;

View File

@ -128,7 +128,7 @@ Code gen__hashtable( StrC type )
CodeFn get = def_function( name(get), def_param( t_u64, name(key)), t_type_ptr
, def_execution( code(
sw idx = find( key ).EntryIndex;
ssize idx = find( key ).EntryIndex;
if ( idx >= 0 )
return & Entries[ idx ].Value;
@ -153,7 +153,7 @@ Code gen__hashtable( StrC type )
Code body = def_execution( code(
GEN_ASSERT_NOT_NULL( map_proc );
for ( sw idx = 0; idx < Entries.num(); idx++ )
for ( ssize idx = 0; idx < Entries.num(); idx++ )
{
map_proc( Entries[ idx ].Key, Entries[ idx ].Value );
}
@ -179,7 +179,7 @@ Code gen__hashtable( StrC type )
Code body = def_execution( code(
GEN_ASSERT_NOT_NULL( map_proc );
for ( sw idx = 0; idx < Entries.num(); idx++ )
for ( ssize idx = 0; idx < Entries.num(); idx++ )
{
map_proc( Entries[ idx ].Key, & Entries[ idx ].Value );
}
@ -190,7 +190,7 @@ Code gen__hashtable( StrC type )
CodeFn grow = def_function( name(grow), __, t_void
, def_execution( code(
sw new_num = array_grow_formula( Entries.num() );
ssize new_num = array_grow_formula( Entries.num() );
rehash( new_num );
))
);
@ -198,8 +198,8 @@ Code gen__hashtable( StrC type )
CodeFn rehash;
{
char const* tmpl = stringize(
sw idx;
sw last_added_index;
ssize idx;
ssize last_added_index;
<type> new_ht = init_reserve( Hashes.get_header()->Allocator, new_num );
@ -242,7 +242,7 @@ Code gen__hashtable( StrC type )
CodeFn rehash_fast;
{
char const* tmpl = stringize(
sw idx;
ssize idx;
for ( idx = 0; idx < Entries.num(); idx++ )
Entries[ idx ].Next = -1;
@ -288,7 +288,7 @@ Code gen__hashtable( StrC type )
));
Code body = def_execution( code(
sw idx;
ssize idx;
FindResult find_result;
if ( Hashes.num() == 0 )
@ -325,7 +325,7 @@ Code gen__hashtable( StrC type )
CodeFn slot = def_function( name(slot), def_param( t_u64, name(key)), t_sw
, def_execution( code(
for ( sw idx = 0; idx < Hashes.num(); ++idx )
for ( ssize idx = 0; idx < Hashes.num(); ++idx )
if ( Hashes[ idx ] == key )
return idx;
@ -335,7 +335,7 @@ Code gen__hashtable( StrC type )
CodeFn add_entry = def_function( name(add_entry), def_param( t_u64, name(key)), t_sw
, def_execution( code(
sw idx;
ssize idx;
Entry entry = { key, -1 };
idx = Entries.num();
@ -421,11 +421,11 @@ void gen__hashtable_request( StrC type, StrC dep = {} )
do_once_start
GenHashTableRequests = Array<GenHashTableRequest>::init( GlobalAllocator );
gen_array( sw );
gen_array( ssize );
do_once_end
// Make sure we don't already have a request for the type.
for ( sw idx = 0; idx < GenHashTableRequests.num(); ++idx )
for ( ssize idx = 0; idx < GenHashTableRequests.num(); ++idx )
{
StrC const reqest_type = GenHashTableRequests[ idx ].Type;

View File

@ -87,7 +87,7 @@ Code gen__ring( StrC type )
);
Code body = def_execution( code(
for ( sw idx = 0; idx < num; idx++ )
for ( ssize idx = 0; idx < num; idx++ )
append( values[ idx ] );
));
@ -167,7 +167,7 @@ void gen__ring_request( StrC type, StrC dep = {} )
do_once_end
// Make sure we don't already have a request for the type.
for ( sw idx = 0; idx < GenRingRequests.num(); ++idx )
for ( ssize idx = 0; idx < GenRingRequests.num(); ++idx )
{
StrC const reqest_type = GenRingRequests[ idx ].Type;

View File

@ -22,7 +22,7 @@ int gen_main()
gen_sanity_upfront();
gen_array( u8 );
gen_array( sw );
gen_array( ssize );
gen_buffer( u8 );