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

@ -42,7 +42,7 @@ constexpr s32 InitSize_DataArrays = 16;
// NOTE: This limits the maximum size of an allocation
// If you are generating a string larger than this, increase the size of the bucket here.
constexpr uw Global_BucketSize = GEN_GLOBAL_BUCKET_SIZE;
constexpr usize Global_BucketSize = GEN_GLOBAL_BUCKET_SIZE;
constexpr s32 CodePool_NumBlocks = GEN_CODEPOOL_NUM_BLOCKS;
constexpr s32 SizePer_StringArena = GEN_SIZE_PER_STRING_ARENA;
@ -122,8 +122,8 @@ extern CodeType t_typename;
extern CodeType t_u32;
extern CodeType t_u64;
extern CodeType t_sw;
extern CodeType t_uw;
extern CodeType t_ssize;
extern CodeType t_usize;
extern CodeType t_f32;
extern CodeType t_f64;

View File

@ -193,7 +193,7 @@ CodeBody def_body( CodeT type )
}
inline
StrC token_fmt_impl( sw num, ... )
StrC token_fmt_impl( ssize num, ... )
{
local_persist thread_local
char buf[GEN_PRINTF_MAXLEN] = { 0 };
@ -201,7 +201,7 @@ StrC token_fmt_impl( sw num, ... )
va_list va;
va_start(va, num );
sw result = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num, va);
ssize result = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num, va);
va_end(va);
return { result, buf };

View File

@ -9,7 +9,7 @@ internal void deinit();
}
internal
void* Global_Allocator_Proc( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags )
void* Global_Allocator_Proc( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags )
{
Arena* last = & Global_AllocatorBuckets.back();
@ -169,8 +169,8 @@ void define_constants()
def_constant_code_type( u32 );
def_constant_code_type( u64 );
def_constant_code_type( sw );
def_constant_code_type( uw );
def_constant_code_type( ssize );
def_constant_code_type( usize );
def_constant_code_type( f32 );
def_constant_code_type( f64 );
@ -298,8 +298,8 @@ void init()
void deinit()
{
uw index = 0;
uw left = CodePools.num();
usize index = 0;
usize left = CodePools.num();
do
{
Pool* code_pool = & CodePools[index];
@ -372,9 +372,9 @@ AllocatorInfo get_string_allocator( s32 str_length )
{
Arena* last = & StringArenas.back();
uw size_req = str_length + sizeof(String::Header) + sizeof(char*);
usize size_req = str_length + sizeof(String::Header) + sizeof(char*);
if ( last->TotalUsed + sw(size_req) > last->TotalSize )
if ( last->TotalUsed + ssize(size_req) > last->TotalSize )
{
Arena new_arena = Arena::init_from_allocator( Allocator_StringArena, SizePer_StringArena );

View File

@ -204,9 +204,9 @@ CodeVar parse_variable ( StrC var_def );
#pragma region Untyped text
sw token_fmt_va( char* buf, uw buf_size, s32 num_tokens, va_list va );
ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va );
//! Do not use directly. Use the token_fmt macro instead.
StrC token_fmt_impl( sw, ... );
StrC token_fmt_impl( ssize, ... );
Code untyped_str ( StrC content);
Code untyped_fmt ( char const* fmt, ... );

View File

@ -3,10 +3,10 @@
#include "interface.parsing.cpp"
#endif
sw token_fmt_va( char* buf, uw buf_size, s32 num_tokens, va_list va )
ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
{
char const* buf_begin = buf;
sw remaining = buf_size;
ssize remaining = buf_size;
local_persist
Arena tok_map_arena;
@ -37,7 +37,7 @@ sw token_fmt_va( char* buf, uw buf_size, s32 num_tokens, va_list va )
while ( current )
{
sw len = 0;
ssize len = 0;
while ( current && current != '<' && remaining )
{
@ -68,7 +68,7 @@ sw token_fmt_va( char* buf, uw buf_size, s32 num_tokens, va_list va )
if ( value )
{
sw left = value->Len;
ssize left = value->Len;
char const* str = value->Ptr;
while ( left-- )
@ -97,7 +97,7 @@ sw token_fmt_va( char* buf, uw buf_size, s32 num_tokens, va_list va )
tok_map.clear();
tok_map_arena.free();
sw result = buf_size - remaining;
ssize result = buf_size - remaining;
return result;
}
@ -138,7 +138,7 @@ Code untyped_fmt( char const* fmt, ...)
va_list va;
va_start(va, fmt);
sw length = str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va);
ssize length = str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va);
va_end(va);
Code
@ -169,7 +169,7 @@ Code untyped_token_fmt( s32 num_tokens, ... )
va_list va;
va_start(va, num_tokens);
sw length = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num_tokens, va);
ssize length = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num_tokens, va);
va_end(va);
Code

View File

@ -97,8 +97,8 @@ global CodeType t_u16;
global CodeType t_u32;
global CodeType t_u64;
global CodeType t_sw;
global CodeType t_uw;
global CodeType t_ssize;
global CodeType t_usize;
global CodeType t_f32;
global CodeType t_f64;

View File

@ -3,7 +3,7 @@
#include "header_start.hpp"
#endif
using LogFailType = sw(*)(char const*, ...);
using LogFailType = ssize(*)(char const*, ...);
// By default this library will either crash or exit if an error is detected while generating codes.
// Even if set to not use GEN_FATAL, GEN_FATAL will still be used for memory failures as the library is unusable when they occur.