mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-30 14:30:53 -07:00 
			
		
		
		
	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:
		| @@ -15,11 +15,11 @@ Code gen__array_base() | ||||
| 		struct ArrayHeader | ||||
| 		{ | ||||
| 			AllocatorInfo Allocator; | ||||
| 			uw            Capacity; | ||||
| 			uw            Num; | ||||
| 			usize            Capacity; | ||||
| 			usize            Num; | ||||
| 		}; | ||||
|  | ||||
| 		static inline uw array_grow_formula( uw value ) | ||||
| 		static inline usize array_grow_formula( usize value ) | ||||
| 		{ | ||||
| 			return 2 * value * 8; | ||||
| 		} | ||||
| @@ -52,7 +52,7 @@ Code gen__array( StrC type ) | ||||
| 				} | ||||
|  | ||||
| 				static | ||||
| 				<ArrayType> init_reserve( AllocatorInfo allocator, sw capacity ) | ||||
| 				<ArrayType> init_reserve( AllocatorInfo allocator, ssize capacity ) | ||||
| 				{ | ||||
| 					Header* header = rcast( Header*, alloc( allocator, sizeof(Header) + sizeof(Type) )); | ||||
|  | ||||
| @@ -94,14 +94,14 @@ Code gen__array( StrC type ) | ||||
| 					header.Num     = 0; | ||||
| 				} | ||||
|  | ||||
| 				bool fill( uw begin, uw end, Type value ) | ||||
| 				bool fill( usize begin, usize end, Type value ) | ||||
| 				{ | ||||
| 					Header& header = get_header(); | ||||
|  | ||||
| 					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; | ||||
| 					} | ||||
| @@ -120,10 +120,10 @@ Code gen__array( StrC type ) | ||||
| 					return *( reinterpret_cast< Header* >( Data ) - 1 ); | ||||
| 				} | ||||
|  | ||||
| 				bool grow( uw min_capacity ) | ||||
| 				bool grow( usize min_capacity ) | ||||
| 				{ | ||||
| 					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; | ||||
| @@ -131,7 +131,7 @@ Code gen__array( StrC type ) | ||||
| 					return set_capacity( new_capacity ); | ||||
| 				} | ||||
|  | ||||
| 				uw num( void ) | ||||
| 				usize num( void ) | ||||
| 				{ | ||||
| 					return get_header().Num; | ||||
| 				} | ||||
| @@ -144,7 +144,7 @@ Code gen__array( StrC type ) | ||||
| 					header.Num--; | ||||
| 				} | ||||
|  | ||||
| 				void remove_at( uw idx ) | ||||
| 				void remove_at( usize idx ) | ||||
| 				{ | ||||
| 					Header* header = &get_header(); | ||||
| 					GEN_ASSERT( idx < header->Num ); | ||||
| @@ -153,7 +153,7 @@ Code gen__array( StrC type ) | ||||
| 					header->Num--; | ||||
| 				} | ||||
|  | ||||
| 				bool reserve( uw new_capacity ) | ||||
| 				bool reserve( usize new_capacity ) | ||||
| 				{ | ||||
| 					Header& header = get_header(); | ||||
|  | ||||
| @@ -163,7 +163,7 @@ Code gen__array( StrC type ) | ||||
| 					return true; | ||||
| 				} | ||||
|  | ||||
| 				bool resize( uw num ) | ||||
| 				bool resize( usize num ) | ||||
| 				{ | ||||
| 					Header& header = get_header(); | ||||
|  | ||||
| @@ -177,7 +177,7 @@ Code gen__array( StrC type ) | ||||
| 					return true; | ||||
| 				} | ||||
|  | ||||
| 				bool set_capacity( uw new_capacity ) | ||||
| 				bool set_capacity( usize new_capacity ) | ||||
| 				{ | ||||
| 					Header& header = get_header(); | ||||
|  | ||||
| @@ -187,7 +187,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 ) | ||||
| @@ -233,7 +233,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; | ||||
|  | ||||
|   | ||||
| @@ -15,8 +15,8 @@ Code gen__buffer_base() | ||||
| 		struct BufferHeader | ||||
| 		{ | ||||
| 			AllocatorInfo Backing; | ||||
| 			uw            Capacity; | ||||
| 			uw            Num; | ||||
| 			usize            Capacity; | ||||
| 			usize            Num; | ||||
| 		}; | ||||
| 	)); | ||||
| } | ||||
| @@ -38,7 +38,7 @@ Code gen__buffer( StrC type ) | ||||
| 				using Header = BufferHeader; | ||||
| 				using Type   = <type>; | ||||
|  | ||||
| 				static <BufferName> init( AllocatorInfo allocator, sw capacity ) | ||||
| 				static <BufferName> init( AllocatorInfo allocator, ssize capacity ) | ||||
| 				{ | ||||
| 					Header* header = rcast( Header*, alloc( allocator, sizeof( Header ) + capacity * sizeof( Type ) ) ); | ||||
|  | ||||
| @@ -76,7 +76,7 @@ Code gen__buffer( StrC type ) | ||||
| 					header.Num++; | ||||
| 				} | ||||
|  | ||||
| 				void append( Type* values, sw num ) | ||||
| 				void append( Type* values, ssize num ) | ||||
| 				{ | ||||
| 					Header& header = get_header(); | ||||
| 					GEN_ASSERT( header.Num + num <= header.Capacity); | ||||
| @@ -108,7 +108,7 @@ Code gen__buffer( StrC type ) | ||||
| 					return *( rcast( Header*, Data ) - 1 ); | ||||
| 				} | ||||
|  | ||||
| 				sw num( void ) | ||||
| 				ssize num( void ) | ||||
| 				{ | ||||
| 					return get_header().Num; | ||||
| 				} | ||||
| @@ -147,7 +147,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; | ||||
|  | ||||
|   | ||||
| @@ -15,9 +15,9 @@ Code gen__hashtable_base() | ||||
| 	return parse_global_body( code( | ||||
| 		struct HashTable_FindResult | ||||
| 		{ | ||||
| 			sw HashIndex; | ||||
| 			sw PrevIndex; | ||||
| 			sw EntryIndex; | ||||
| 			ssize HashIndex; | ||||
| 			ssize PrevIndex; | ||||
| 			ssize EntryIndex; | ||||
| 		}; | ||||
| 	)); | ||||
| } | ||||
| @@ -37,7 +37,7 @@ Code gen__hashtable( StrC type ) | ||||
| 			struct <HashTableName>_Entry | ||||
| 			{ | ||||
| 				u64 Key; | ||||
| 				sw  Next; | ||||
| 				ssize  Next; | ||||
| 				<type> Value; | ||||
| 			}; | ||||
| 		) | ||||
| @@ -86,7 +86,7 @@ Code gen__hashtable( StrC type ) | ||||
|  | ||||
| 				Type* get( u64 key ) | ||||
| 				{ | ||||
| 					sw idx = find( key ).EntryIndex; | ||||
| 					ssize idx = find( key ).EntryIndex; | ||||
|  | ||||
| 					if ( idx > 0 ) | ||||
| 						return &Entries[ idx ].Value; | ||||
| @@ -96,7 +96,7 @@ Code gen__hashtable( StrC type ) | ||||
|  | ||||
| 				void grow( void ) | ||||
| 				{ | ||||
| 					sw new_num = array_grow_formula( Entries.num() ); | ||||
| 					ssize new_num = array_grow_formula( Entries.num() ); | ||||
|  | ||||
| 					rehash( new_num ); | ||||
| 				} | ||||
| @@ -105,7 +105,7 @@ Code gen__hashtable( StrC type ) | ||||
| 				{ | ||||
| 					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 ); | ||||
| 					} | ||||
| @@ -115,16 +115,16 @@ Code gen__hashtable( StrC type ) | ||||
| 				{ | ||||
| 					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 ); | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				void rehash( sw new_num ) | ||||
| 				void rehash( ssize new_num ) | ||||
| 				{ | ||||
| 					sw            idx; | ||||
| 					sw            last_added_index; | ||||
| 					ssize            idx; | ||||
| 					ssize            last_added_index; | ||||
| 					HashTable_u32 new_ht = HashTable_u32::init( Hashes.get_header().Allocator ); | ||||
|  | ||||
| 					new_ht.Hashes.resize( new_num ); | ||||
| @@ -163,7 +163,7 @@ Code gen__hashtable( StrC type ) | ||||
|  | ||||
| 				void rehash_fast( void ) | ||||
| 				{ | ||||
| 					sw idx; | ||||
| 					ssize idx; | ||||
|  | ||||
| 					for ( idx = 0; idx < Entries.num(); idx++ ) | ||||
| 						Entries[ idx ].Next = -1; | ||||
| @@ -189,14 +189,14 @@ Code gen__hashtable( StrC type ) | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				void remove_entry( sw idx ) | ||||
| 				void remove_entry( ssize idx ) | ||||
| 				{ | ||||
| 					Entries.remove_at( idx ); | ||||
| 				} | ||||
|  | ||||
| 				void set( u64 key, Type value ) | ||||
| 				{ | ||||
| 					sw         idx; | ||||
| 					ssize         idx; | ||||
| 					FindResult find_result; | ||||
|  | ||||
| 					if ( Hashes.num() == 0 ) | ||||
| @@ -228,9 +228,9 @@ Code gen__hashtable( StrC type ) | ||||
| 						grow(); | ||||
| 				} | ||||
|  | ||||
| 				sw slot( u64 key ) | ||||
| 				ssize slot( u64 key ) | ||||
| 				{ | ||||
| 					for ( sw idx = 0; idx < Hashes.num(); ++idx ) | ||||
| 					for ( ssize idx = 0; idx < Hashes.num(); ++idx ) | ||||
| 						if ( Hashes[ idx ] == key ) | ||||
| 							return idx; | ||||
|  | ||||
| @@ -242,9 +242,9 @@ Code gen__hashtable( StrC type ) | ||||
|  | ||||
| 			protected: | ||||
|  | ||||
| 				sw add_entry( u64 key ) | ||||
| 				ssize add_entry( u64 key ) | ||||
| 				{ | ||||
| 					sw    idx; | ||||
| 					ssize    idx; | ||||
| 					Entry entry = { key, -1 }; | ||||
| 					idx         = Entries.num(); | ||||
| 					Entries.append( entry ); | ||||
| @@ -294,11 +294,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; | ||||
|  | ||||
|   | ||||
| @@ -30,7 +30,7 @@ Code gen__ring( StrC type ) | ||||
| 			{ | ||||
| 				using Type = <type>; | ||||
|  | ||||
| 				static <RingName> init( AllocatorInfo allocator, uw max_size ) | ||||
| 				static <RingName> init( AllocatorInfo allocator, usize max_size ) | ||||
| 				{ | ||||
| 					<RingName> result = { 0 }; | ||||
|  | ||||
| @@ -52,9 +52,9 @@ Code gen__ring( StrC type ) | ||||
| 						Tail = ( Tail + 1 ) % Capacity; | ||||
| 				} | ||||
|  | ||||
| 				inline void append( Type* values, sw num ) | ||||
| 				inline void append( Type* values, ssize num ) | ||||
| 				{ | ||||
| 					for ( sw idx = 0; idx < num; idx++ ) | ||||
| 					for ( ssize idx = 0; idx < num; idx++ ) | ||||
| 						append( values[ idx ] ); | ||||
| 				} | ||||
|  | ||||
| @@ -88,9 +88,9 @@ Code gen__ring( StrC type ) | ||||
| 				} | ||||
|  | ||||
| 				AllocatorInfo Backing; | ||||
| 				uw            Capacity; | ||||
| 				uw            Head; | ||||
| 				uw            Tail; | ||||
| 				usize            Capacity; | ||||
| 				usize            Head; | ||||
| 				usize            Tail; | ||||
| 				<BufferName>  Buffer; | ||||
| 			}; | ||||
| 		) | ||||
| @@ -113,7 +113,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; | ||||
|  | ||||
|   | ||||
| @@ -23,14 +23,14 @@ int gen_main() | ||||
| 	gen_sanity(); | ||||
|  | ||||
| 	gen_array( u8 ); | ||||
| 	gen_array( sw ); | ||||
| 	gen_array( ssize ); | ||||
|  | ||||
| 	gen_buffer( u8 ); | ||||
|  | ||||
| 	gen_hashtable( u32 ); | ||||
|  | ||||
| 	gen_ring( s16 ); | ||||
| 	gen_ring( uw ); | ||||
| 	gen_ring( usize ); | ||||
|  | ||||
| 	gen_array_file(); | ||||
| 	gen_buffer_file(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user