mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Compare commits
No commits in common. "8bb2bc7b1b0c4673ef2807cf9ddeab5957d14feb" and "47b9c37e948e5e7c07fdcb30861b4062ad84c107" have entirely different histories.
8bb2bc7b1b
...
47b9c37e94
@ -9,9 +9,7 @@
|
||||
#include "helpers/helper.hpp"
|
||||
|
||||
GEN_NS_BEGIN
|
||||
#include "helpers/push_container_defines.inline.hpp"
|
||||
#include "dependencies/parsing.cpp"
|
||||
#include "helpers/pop_container_defines.inline.hpp"
|
||||
GEN_NS_END
|
||||
|
||||
#include "auxillary/builder.hpp"
|
||||
@ -120,33 +118,22 @@ int gen_main()
|
||||
{
|
||||
header.print( c_library_header_start );
|
||||
|
||||
#pragma region Scan, Parse, and Generate Components
|
||||
Code types = scan_file( project_dir "components/types.hpp" );
|
||||
Code ast = scan_file( project_dir "components/ast.hpp" );
|
||||
Code ast_types = scan_file( project_dir "components/ast_types.hpp" );
|
||||
Code code_types = scan_file( project_dir "components/code_types.hpp" );
|
||||
Code interface = scan_file( project_dir "components/interface.hpp" );
|
||||
Code inlines = scan_file( project_dir "components/inlines.hpp" );
|
||||
Code header_end = scan_file( project_dir "components/header_end.hpp" );
|
||||
|
||||
CodeBody ecode = gen_ecode ( project_dir "enums/ECode.csv" );
|
||||
CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv" );
|
||||
CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv" );
|
||||
CodeBody ast_inlines = gen_ast_inlines();
|
||||
#pragma endregion Scan, Parse, and Generate Components
|
||||
|
||||
#pragma region Scan, Parse, and Generate Dependencies
|
||||
Code platform = scan_file( project_dir "dependencies/platform.hpp" );
|
||||
Code macros = scan_file( project_dir "dependencies/macros.hpp" );
|
||||
Code basic_types = scan_file( project_dir "dependencies/basic_types.hpp" );
|
||||
Code debug = scan_file( project_dir "dependencies/debug.hpp" );
|
||||
Code string_ops = scan_file( project_dir "dependencies/string_ops.hpp" );
|
||||
Code hashing = scan_file( project_dir "dependencies/hashing.hpp" );
|
||||
Code filesystem = scan_file( project_dir "dependencies/filesystem.hpp" );
|
||||
Code timing = scan_file( project_dir "dependencies/timing.hpp" );
|
||||
|
||||
header.print_fmt( roll_own_dependencies_guard_start );
|
||||
header.print( platform );
|
||||
header.print_fmt( "\nGEN_NS_BEGIN\n" );
|
||||
|
||||
header.print( macros );
|
||||
header.print( basic_types );
|
||||
header.print( debug );
|
||||
|
||||
CodeBody parsed_memory = parse_file( project_dir "dependencies/memory.hpp" );
|
||||
CodeBody memory = def_body(CT_Global_Body);
|
||||
|
||||
for ( Code entry = parsed_memory.begin(); entry != parsed_memory.end(); ++ entry )
|
||||
{
|
||||
switch (entry->Type)
|
||||
@ -265,6 +252,11 @@ int gen_main()
|
||||
}
|
||||
}
|
||||
|
||||
header.print( dump_to_scratch_and_retireve(memory) );
|
||||
|
||||
Code string_ops = scan_file( project_dir "dependencies/string_ops.hpp" );
|
||||
header.print( string_ops );
|
||||
|
||||
CodeBody printing_parsed = parse_file( project_dir "dependencies/printing.hpp" );
|
||||
CodeBody printing = def_body(CT_Global_Body);
|
||||
for ( Code entry = printing_parsed.begin(); entry != printing_parsed.end(); ++ entry )
|
||||
@ -295,6 +287,27 @@ int gen_main()
|
||||
break;
|
||||
}
|
||||
}
|
||||
header.print(dump_to_scratch_and_retireve(printing));
|
||||
|
||||
CodeBody containers = def_body(CT_Global_Body);
|
||||
{
|
||||
containers.append( def_pragma(code(region Containers)));
|
||||
|
||||
containers.append( gen_array_base() );
|
||||
containers.append( gen_hashtable_base() );
|
||||
|
||||
containers.append(fmt_newline);
|
||||
|
||||
CodeBody array_ssize = gen_array(txt("ssize"), txt("Array_ssize"));
|
||||
containers.append(array_ssize);
|
||||
|
||||
containers.append( def_pragma(code(endregion Containers)));
|
||||
}
|
||||
header.print(fmt_newline);
|
||||
header.print(dump_to_scratch_and_retireve(containers));
|
||||
|
||||
Code hashing = scan_file( project_dir "dependencies/hashing.hpp" );
|
||||
header.print( hashing );
|
||||
|
||||
CodeBody parsed_strings = parse_file( project_dir "dependencies/strings.hpp" );
|
||||
CodeBody strings = def_body(CT_Global_Body);
|
||||
@ -373,8 +386,9 @@ int gen_main()
|
||||
CodeTypedef td = cast(CodeTypedef, entry);
|
||||
if (td->Name.contains(name_string_table))
|
||||
{
|
||||
CodeBody ht = gen_hashtable(txt("StrC"), name_string_table);
|
||||
CodeBody ht = gen_hashtable(name_string_table, name_string_table);
|
||||
strings.append(ht);
|
||||
strings.append(td);
|
||||
break;
|
||||
}
|
||||
strings.append(td);
|
||||
@ -386,49 +400,30 @@ int gen_main()
|
||||
break;
|
||||
}
|
||||
}
|
||||
header.print(dump_to_scratch_and_retireve(strings));
|
||||
|
||||
CodeBody containers = def_body(CT_Global_Body);
|
||||
{
|
||||
CodeBody array_ssize = gen_array(txt("ssize"), txt("Array_ssize"));
|
||||
|
||||
containers.append( def_pragma(code(region Containers)));
|
||||
|
||||
// At this point all arrays required should have been defined so its safe to generate the generic selectors.
|
||||
containers.append( gen_array_base() );
|
||||
containers.append( gen_array_generic_selection_interface());
|
||||
containers.append( gen_hashtable_base() );
|
||||
|
||||
containers.append(fmt_newline);
|
||||
containers.append(array_ssize);
|
||||
|
||||
containers.append( def_pragma(code(endregion Containers)));
|
||||
containers.append(fmt_newline);
|
||||
}
|
||||
#pragma endregion Scan, Parse, and Generate Dependencies
|
||||
|
||||
#pragma region Print Dependencies
|
||||
header.print_fmt( roll_own_dependencies_guard_start );
|
||||
header.print( platform );
|
||||
header.print_fmt( "\nGEN_NS_BEGIN\n" );
|
||||
|
||||
header.print( macros );
|
||||
header.print( basic_types );
|
||||
header.print( debug );
|
||||
header.print( dump_to_scratch_and_retireve(memory) );
|
||||
header.print( dump_to_scratch_and_retireve(printing));
|
||||
header.print( string_ops );
|
||||
header.print( dump_to_scratch_and_retireve(containers));
|
||||
header.print( hashing );
|
||||
header.print( dump_to_scratch_and_retireve(strings));
|
||||
Code filesystem = scan_file( project_dir "dependencies/filesystem.hpp" );
|
||||
Code timing = scan_file( project_dir "dependencies/timing.hpp" );
|
||||
// header.print( filesystem );
|
||||
// header.print( timing );
|
||||
|
||||
header.print_fmt( "\nGEN_NS_END\n" );
|
||||
header.print_fmt( roll_own_dependencies_guard_end );
|
||||
#pragma endregion Print Dependencies
|
||||
|
||||
Code types = scan_file( project_dir "components/types.hpp" );
|
||||
Code ast = scan_file( project_dir "components/ast.hpp" );
|
||||
Code ast_types = scan_file( project_dir "components/ast_types.hpp" );
|
||||
Code code_types = scan_file( project_dir "components/code_types.hpp" );
|
||||
Code interface = scan_file( project_dir "components/interface.hpp" );
|
||||
Code inlines = scan_file( project_dir "components/inlines.hpp" );
|
||||
Code header_end = scan_file( project_dir "components/header_end.hpp" );
|
||||
|
||||
#if 0
|
||||
#region region Print Components
|
||||
CodeBody ecode = gen_ecode ( project_dir "enums/ECode.csv" );
|
||||
CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv" );
|
||||
CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv" );
|
||||
CodeBody ast_inlines = gen_ast_inlines();
|
||||
|
||||
#if 0
|
||||
header.print_fmt("#pragma region Types\n");
|
||||
header.print( types );
|
||||
header.print( fmt_newline );
|
||||
@ -439,8 +434,7 @@ int gen_main()
|
||||
header.print( dump_to_scratch_and_retireve( especifier ));
|
||||
header.print( fmt_newline );
|
||||
header.print_fmt("#pragma endregion Types\n\n");
|
||||
#pragma endregion Print Compoennts
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
header.print( pop_ignores );
|
||||
|
@ -4,9 +4,6 @@
|
||||
|
||||
using namespace gen;
|
||||
|
||||
// Used to know what slot the array will be for generic selection
|
||||
global s32 ArrayDefinitionCounter = 0;
|
||||
|
||||
CodeBody gen_array_base()
|
||||
{
|
||||
CodeTypedef td_header = parse_typedef( code( typedef struct ArrayHeader ArrayHeader; ));
|
||||
@ -19,82 +16,70 @@ CodeBody gen_array_base()
|
||||
};
|
||||
));
|
||||
|
||||
Code grow_formula = untyped_str( txt( "#define array_grow_formula( value ) ( 2 * value + 8 )\n" ));
|
||||
Code get_header = untyped_str( txt( "#define array_get_header( self ) ( (ArrayHeader*)( self ) - 1)\n" ));
|
||||
// Code grow_formula = untyped_str( txt( "#define gen_array_grow_formula( value ) ( 2 * value + 8 )\n" ));
|
||||
Code get_header = untyped_str( txt( "#define array_get_header( Type, self ) ( (ArrayHeader*)( self ) - 1)\n" ));
|
||||
|
||||
return def_global_body( args( fmt_newline, td_header, header, grow_formula, get_header, fmt_newline ) );
|
||||
return def_global_body( args( fmt_newline, td_header, header, get_header, fmt_newline ) );
|
||||
};
|
||||
|
||||
CodeBody gen_array( StrC type, StrC array_name )
|
||||
{
|
||||
String array_type = String::fmt_buf( GlobalAllocator, "%.*s", array_name.Len, array_name.Ptr );
|
||||
String fn = String::fmt_buf( GlobalAllocator, "%.*s", array_name.Len, array_name.Ptr );
|
||||
// str_to_lower(fn.Data);
|
||||
str_to_lower(fn.Data);
|
||||
|
||||
#pragma push_macro( "GEN_ASSERT" )
|
||||
#pragma push_macro( "rcast" )
|
||||
#pragma push_macro( "cast" )
|
||||
#undef GEN_ASSERT
|
||||
#undef rcast
|
||||
#undef cast
|
||||
CodeBody result = parse_global_body( token_fmt( "array_type", (StrC)array_type, "fn", (StrC)fn, "type", (StrC)type
|
||||
, stringize(
|
||||
typedef <type>* <array_type>;
|
||||
|
||||
void <fn>_init ( <array_type>* self, AllocatorInfo allocator );
|
||||
void <fn>_init_reserve ( <array_type>* self, AllocatorInfo allocator, usize capacity );
|
||||
bool <fn>_append_array ( <array_type>* self, <array_type> other );
|
||||
<array_type> <fn>_init ( AllocatorInfo allocator );
|
||||
<array_type> <fn>_init_reserve ( AllocatorInfo allocator, usize capacity );
|
||||
bool <fn>_append ( <array_type>* self, <type> value );
|
||||
bool <fn>_append_items ( <array_type>* self, <type>* items, usize item_num );
|
||||
bool <fn>_append_at ( <array_type>* self, <type> item, usize idx );
|
||||
bool <fn>_append_items_at( <array_type>* self, <type>* items, usize item_num, usize idx );
|
||||
<type>* <fn>_back ( <array_type> self );
|
||||
void <fn>_clear ( <array_type> self );
|
||||
bool <fn>_fill ( <array_type> self, usize begin, usize end, <type> value );
|
||||
void <fn>_free ( <array_type>* self );
|
||||
bool <fn>_grow ( <array_type>* self, usize min_capacity );
|
||||
usize <fn>_num ( <array_type> self );
|
||||
<type> <fn>_pop ( <array_type> self );
|
||||
void <fn>_remove_at ( <array_type> self, usize idx );
|
||||
bool <fn>_reserve ( <array_type>* self, usize new_capacity );
|
||||
bool <fn>_resize ( <array_type>* self, usize num );
|
||||
bool <fn>_set_capacity ( <array_type>* self, usize new_capacity );
|
||||
<type>* <fn>_back ( <array_type> self );
|
||||
void <fn>_clear ( <array_type> self );
|
||||
bool <fn>_fill ( <array_type> self, usize begin, usize end, <type> value );
|
||||
void <fn>_free ( <array_type> self );
|
||||
bool <fn>_grow ( <array_type>* self, usize min_capacity );
|
||||
usize <fn>_num ( <array_type> self );
|
||||
<type> <fn>_pop ( <array_type> self );
|
||||
bool <fn>_reserve ( <array_type>* self, usize new_capacity );
|
||||
bool <fn>_resize ( <array_type>* self, usize num );
|
||||
bool <fn>_set_capacity ( <array_type>* self, usize new_capacity );
|
||||
|
||||
void <fn>_init( <array_type>* self, AllocatorInfo allocator )
|
||||
<array_type> <fn>_init( AllocatorInfo allocator )
|
||||
{
|
||||
size_t initial_size = array_grow_formula(0);
|
||||
array_init_reserve( * self, allocator, initial_size );
|
||||
return <fn>_init_reserve( allocator, array_grow_formula( 0 ) );
|
||||
}
|
||||
|
||||
void <fn>_init_reserve( <array_type>* self, AllocatorInfo allocator, usize capacity )
|
||||
<array_type> <fn>_init_reserve( AllocatorInfo allocator, usize capacity )
|
||||
{
|
||||
ArrayHeader* header = rcast(ArrayHeader*, alloc(allocator, sizeof(ArrayHeader) + sizeof(<type>) * capacity));
|
||||
ArrayHeader* header = cast(ArrayHeader*, alloc( allocator, sizeof(ArrayHeader) + sizeof(<type>) * capacity ) );
|
||||
|
||||
if (header == nullptr)
|
||||
self = nullptr;
|
||||
if ( header == NULL )
|
||||
return NULL;
|
||||
|
||||
header->Allocator = allocator;
|
||||
header->Capacity = capacity;
|
||||
header->Num = 0;
|
||||
|
||||
self = rcast(<array_type>*, header + 1);
|
||||
}
|
||||
|
||||
bool <fn>_append_array( <array_type>* self, <array_type> other )
|
||||
{
|
||||
return array_append_items( * self, (<array_type>)other, <fn>_num(other));
|
||||
return cast( <type>*, header + 1 );
|
||||
}
|
||||
|
||||
bool <fn>_append( <array_type>* self, <type> value )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( * self );
|
||||
ArrayHeader* header = get_header( * self );
|
||||
|
||||
if ( header->Num == header->Capacity )
|
||||
{
|
||||
if ( ! array_grow( self, header->Capacity))
|
||||
if ( ! <fn>_grow( self, header->Capacity))
|
||||
return false;
|
||||
|
||||
header = array_get_header( * self );
|
||||
header = get_header( * self );
|
||||
}
|
||||
|
||||
(* self)[ header->Num ] = value;
|
||||
@ -105,14 +90,14 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
|
||||
bool <fn>_append_items( <array_type>* self, <type>* items, usize item_num )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( * self );
|
||||
ArrayHeader* header = get_header( * self );
|
||||
|
||||
if ( header->Num + item_num > header->Capacity )
|
||||
{
|
||||
if ( ! array_grow( self, header->Capacity + item_num ))
|
||||
if ( ! <fn>_grow( self, header->Capacity + item_num ))
|
||||
return false;
|
||||
|
||||
header = array_get_header( * self );
|
||||
header = get_header( * self );
|
||||
}
|
||||
|
||||
mem_copy( (* self) + header->Num, items, sizeof(<type>) * item_num );
|
||||
@ -123,7 +108,7 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
|
||||
bool <fn>_append_at( <array_type>* self, <type> item, usize idx )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( * self );
|
||||
ArrayHeader* header = get_header( * self );
|
||||
|
||||
if ( idx >= header->Num )
|
||||
idx = header->Num - 1;
|
||||
@ -133,10 +118,10 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
|
||||
if ( header->Capacity < header->Num + 1 )
|
||||
{
|
||||
if ( ! array_grow( self, header->Capacity + 1 ) )
|
||||
if ( ! <fn>_grow( self, header->Capacity + 1 ) )
|
||||
return false;
|
||||
|
||||
header = array_get_header( * self );
|
||||
header = get_header( * self );
|
||||
}
|
||||
|
||||
<array_type> target = (* self) + idx;
|
||||
@ -149,19 +134,19 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
|
||||
bool <fn>_append_items_at( <array_type>* self, <type>* items, usize item_num, usize idx )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( * self );
|
||||
ArrayHeader* header = get_header( * self );
|
||||
|
||||
if ( idx >= header->Num )
|
||||
{
|
||||
return array_append_items( * self, items, item_num );
|
||||
return <fn>_append_items( self, items, item_num );
|
||||
}
|
||||
|
||||
if ( item_num > header->Capacity )
|
||||
{
|
||||
if ( ! array_grow( self, item_num + header->Capacity ) )
|
||||
if ( ! <fn>_grow( self, item_num + header->Capacity ) )
|
||||
return false;
|
||||
|
||||
header = array_get_header( * self );
|
||||
header = get_header( * self );
|
||||
}
|
||||
|
||||
<type>* target = (* self) + idx + item_num;
|
||||
@ -176,7 +161,7 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
|
||||
<type>* <fn>_back( <array_type> self )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( self );
|
||||
ArrayHeader* header = get_header( self );
|
||||
|
||||
if ( header->Num == 0 )
|
||||
return NULL;
|
||||
@ -186,13 +171,13 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
|
||||
void <fn>_clear( <array_type> self )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( self );
|
||||
ArrayHeader* header = get_header( self );
|
||||
header->Num = 0;
|
||||
}
|
||||
|
||||
bool <fn>_fill( <array_type> self, usize begin, usize end, <type> value )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( self );
|
||||
ArrayHeader* header = get_header( self );
|
||||
|
||||
if ( begin < 0 || end >= header->Num )
|
||||
return false;
|
||||
@ -203,32 +188,32 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
return true;
|
||||
}
|
||||
|
||||
void <fn>_free( <array_type>* self )
|
||||
void <fn>_free( <array_type> self )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( * self );
|
||||
allocator_free( header->Allocator, header );
|
||||
ArrayHeader* header = get_header( self );
|
||||
free( header->Allocator, header );
|
||||
self = NULL;
|
||||
}
|
||||
|
||||
bool <fn>_grow( <array_type>* self, usize min_capacity )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( *self );
|
||||
ArrayHeader* header = get_header( *self );
|
||||
usize new_capacity = array_grow_formula( header->Capacity );
|
||||
|
||||
if ( new_capacity < min_capacity )
|
||||
new_capacity = min_capacity;
|
||||
|
||||
return array_set_capacity( self, new_capacity );
|
||||
return <fn>_set_capacity( self, new_capacity );
|
||||
}
|
||||
|
||||
usize <fn>_num( <array_type> self )
|
||||
{
|
||||
return array_get_header(self)->Num;
|
||||
return get_header(self)->Num;
|
||||
}
|
||||
|
||||
<type> <fn>_pop( <array_type> self )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( self );
|
||||
ArrayHeader* header = get_header( self );
|
||||
GEN_ASSERT( header->Num > 0 );
|
||||
|
||||
<type> result = self[ header->Num - 1 ];
|
||||
@ -238,7 +223,7 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
|
||||
void <fn>_remove_at( <array_type> self, usize idx )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( self );
|
||||
ArrayHeader* header = get_header( self );
|
||||
GEN_ASSERT( idx < header->Num );
|
||||
|
||||
mem_move( self + idx, self + idx + 1, sizeof( <type> ) * ( header->Num - idx - 1 ) );
|
||||
@ -247,24 +232,24 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
|
||||
bool <fn>_reserve( <array_type>* self, usize new_capacity )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( * self );
|
||||
ArrayHeader* header = get_header( * self );
|
||||
|
||||
if ( header->Capacity < new_capacity )
|
||||
return array_set_capacity( self, new_capacity );
|
||||
return <fn>_set_capacity( self, new_capacity );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool <fn>_resize( <array_type>* self, usize num )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( * self );
|
||||
ArrayHeader* header = get_header( * self );
|
||||
|
||||
if ( header->Capacity < num )
|
||||
{
|
||||
if ( ! array_grow( self, num ) )
|
||||
if ( ! <fn>_grow( self, num ) )
|
||||
return false;
|
||||
|
||||
header = array_get_header( * self );
|
||||
header = get_header( * self );
|
||||
}
|
||||
|
||||
header->Num = num;
|
||||
@ -273,7 +258,7 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
|
||||
bool <fn>_set_capacity( <array_type>* self, usize new_capacity )
|
||||
{
|
||||
ArrayHeader* header = array_get_header( * self );
|
||||
ArrayHeader* header = get_header( * self );
|
||||
|
||||
if ( new_capacity == header->Capacity )
|
||||
return true;
|
||||
@ -281,14 +266,14 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
if ( new_capacity < header->Num )
|
||||
header->Num = new_capacity;
|
||||
|
||||
usize size = sizeof( ArrayHeader ) + sizeof( <type> ) * new_capacity;
|
||||
usize size = sizeof( ArrayHeader ) + sizeof( <type> ) * new_capacity;
|
||||
ArrayHeader* new_header = cast( ArrayHeader*, alloc( header->Allocator, size ));
|
||||
|
||||
if ( new_header == NULL )
|
||||
return false;
|
||||
|
||||
mem_move( new_header, header, sizeof( ArrayHeader ) + sizeof( <type> ) * header->Num );
|
||||
allocator_free( header->Allocator, & header );
|
||||
free( header->Allocator, & header );
|
||||
|
||||
new_header->Capacity = new_capacity;
|
||||
* self = cast( <type>*, new_header + 1 );
|
||||
@ -296,38 +281,10 @@ CodeBody gen_array( StrC type, StrC array_name )
|
||||
}
|
||||
)));
|
||||
#pragma pop_macro( "GEN_ASSERT" )
|
||||
#pragma pop_macro( "rcast" )
|
||||
#pragma pop_macro( "cast" )
|
||||
|
||||
++ ArrayDefinitionCounter;
|
||||
StrC slot_str = String::fmt_buf(GlobalAllocator, "%d", ArrayDefinitionCounter).to_strc();
|
||||
|
||||
Code generic_interface_slot = untyped_str(token_fmt( "type_delimiter", (StrC)array_type, "slot", (StrC)slot_str,
|
||||
R"(#define GENERIC_SLOT_<slot>__array_init <type_delimiter>, <type_delimiter>_init
|
||||
#define GENERIC_SLOT_<slot>__array_init_reserve <type_delimiter>, <type_delimiter>_init_reserve
|
||||
#define GENERIC_SLOT_<slot>__array_append <type_delimiter>, <type_delimiter>_append
|
||||
#define GENERIC_SLOT_<slot>__array_append_items <type_delimiter>, <type_delimiter>_append_items
|
||||
#define GENERIC_SLOT_<slot>__array_append_at <type_delimiter>, <type_delimiter>_append_at
|
||||
#define GENERIC_SLOT_<slot>__array_append_items_at <type_delimiter>, <type_delimiter>_append_items_at
|
||||
#define GENERIC_SLOT_<slot>__array_back <type_delimiter>, <type_delimiter>_back
|
||||
#define GENERIC_SLOT_<slot>__array_clear <type_delimiter>, <type_delimiter>_clear
|
||||
#define GENERIC_SLOT_<slot>__array_fill <type_delimiter>, <type_delimiter>_fill
|
||||
#define GENERIC_SLOT_<slot>__array_free <type_delimiter>, <type_delimiter>_free
|
||||
#define GENERIC_SLOT_<slot>__array_grow <type_delimiter>*, <type_delimiter>_grow
|
||||
#define GENERIC_SLOT_<slot>__array_num <type_delimiter>, <type_delimiter>_num
|
||||
#define GENERIC_SLOT_<slot>__array_pop <type_delimiter>, <type_delimiter>_pop
|
||||
#define GENERIC_SLOT_<slot>__array_remove_at <type_delimiter>, <type_delimiter>_remove_at
|
||||
#define GENERIC_SLOT_<slot>__array_reserve <type_delimiter>, <type_delimiter>_reserve
|
||||
#define GENERIC_SLOT_<slot>__array_resize <type_delimiter>, <type_delimiter>_resize
|
||||
#define GENERIC_SLOT_<slot>__array_set_capacity <type_delimiter>*, <type_delimiter>_set_capacity
|
||||
)"
|
||||
));
|
||||
|
||||
return def_global_body( args(
|
||||
def_pragma( string_to_strc( string_fmt_buf( GlobalAllocator, "region %S", array_type ))),
|
||||
fmt_newline,
|
||||
generic_interface_slot,
|
||||
fmt_newline,
|
||||
result,
|
||||
fmt_newline,
|
||||
def_pragma( string_to_strc(string_fmt_buf( GlobalAllocator, "endregion %S", array_type ))),
|
||||
@ -335,67 +292,4 @@ R"(#define GENERIC_SLOT_<slot>__array_init <type_delimiter>, <type_deli
|
||||
));
|
||||
};
|
||||
|
||||
constexpr bool array_by_ref = true;
|
||||
Code gen_array_generic_selection_function_macro( StrC macro_name, bool by_ref = false )
|
||||
{
|
||||
local_persist
|
||||
String define_builder = String::make_reserve(GlobalAllocator, kilobytes(64));
|
||||
define_builder.clear();
|
||||
|
||||
StrC macro_begin = token_fmt( "macro_name", (StrC)macro_name,
|
||||
R"(#define <macro_name>(selector_arg, ...) _Generic( \
|
||||
(selector_arg), /* Select Via Expression*/ \
|
||||
/* Extendibility slots: */ \
|
||||
)"
|
||||
);
|
||||
define_builder.append(macro_begin);
|
||||
|
||||
for ( s32 slot = 1; slot <= ArrayDefinitionCounter; ++ slot )
|
||||
{
|
||||
StrC slot_str = String::fmt_buf(GlobalAllocator, "%d", slot).to_strc();
|
||||
if (slot == ArrayDefinitionCounter)
|
||||
{
|
||||
define_builder.append( token_fmt( "macro_name", macro_name, "slot", slot_str,
|
||||
R"( GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT_LAST( GENERIC_SLOT_<slot>__<macro_name> ) \
|
||||
)"
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
define_builder.append( token_fmt( "macro_name", macro_name, "slot", slot_str,
|
||||
R"( GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GENERIC_SLOT_<slot>__<macro_name> ) \
|
||||
)"
|
||||
));
|
||||
}
|
||||
|
||||
if (by_ref)
|
||||
define_builder.append(txt(")\tGEN_RESOLVED_FUNCTION_CALL( & selector_arg, __VA_ARGS__ )"));
|
||||
else
|
||||
define_builder.append(txt(")\tGEN_RESOLVED_FUNCTION_CALL( selector_arg, __VA_ARGS__ )"));
|
||||
|
||||
// Add gap for next definition
|
||||
define_builder.append(txt("\n\n"));
|
||||
|
||||
Code macro = untyped_str(define_builder.to_strc());
|
||||
return macro;
|
||||
}
|
||||
|
||||
CodeBody gen_array_generic_selection_interface()
|
||||
{
|
||||
CodeBody interface_defines = def_body(CT_Global_Body);
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_init"), array_by_ref) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_init_reserve"), array_by_ref) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_append"), array_by_ref) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_append_items"), array_by_ref) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_back")) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_clear")) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_fill")) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_free"), array_by_ref) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_grow")) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_num")) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("arary_pop")) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_remove_at")) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("arary_reserve"), array_by_ref) );
|
||||
interface_defines.append( gen_array_generic_selection_function_macro(txt("array_set_capacity")) );
|
||||
return interface_defines;
|
||||
}
|
||||
// CodeBody gen_
|
||||
|
@ -30,10 +30,10 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
|
||||
String tbl_type = {(char*) hashtable_name.duplicate(GlobalAllocator).Ptr};
|
||||
String fn = tbl_type.duplicate(GlobalAllocator);
|
||||
// str_to_lower(fn.Data);
|
||||
str_to_lower(fn.Data);
|
||||
|
||||
String name_lower = String::make( GlobalAllocator, hashtable_name );
|
||||
// str_to_lower( name_lower.Data );
|
||||
str_to_lower( name_lower.Data );
|
||||
|
||||
String hashtable_entry = String::fmt_buf( GlobalAllocator, "HTE_%.*s", hashtable_name.Len, hashtable_name.Ptr );
|
||||
String entry_array_name = String::fmt_buf( GlobalAllocator, "Arr_HTE_%.*s", hashtable_name.Len, hashtable_name.Ptr );
|
||||
@ -44,7 +44,6 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
"tbl_name", (StrC) hashtable_name,
|
||||
"tbl_type", (StrC) tbl_type,
|
||||
stringize(
|
||||
typedef struct HashTable_<type> <tbl_type>;
|
||||
typedef struct HTE_<tbl_name> HTE_<tbl_name>;
|
||||
struct HTE_<tbl_name>
|
||||
{
|
||||
@ -72,7 +71,8 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
"array_entry", (StrC) entry_array_name,
|
||||
"fn_array", (StrC) entry_array_fn_ns,
|
||||
stringize(
|
||||
struct HashTable_<type>
|
||||
typedef struct <tbl_type> <tbl_type>;
|
||||
struct <tbl_type>
|
||||
{
|
||||
Array_ssize Hashes;
|
||||
<array_entry> Entries;
|
||||
@ -101,8 +101,8 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
{
|
||||
<tbl_type>
|
||||
result = { NULL, NULL };
|
||||
array_init(result.Hashes, allocator );
|
||||
array_init(result.Entries, allocator );
|
||||
result.Hashes = array_ssize_make( allocator );
|
||||
result.Entries = <fn_array>_make( allocator );
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -111,27 +111,27 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
{
|
||||
<tbl_type>
|
||||
result = { NULL, NULL };
|
||||
array_init_reserve(result.Hashes, allocator, num );
|
||||
array_init_reserve(result.Entries, allocator, num );
|
||||
result.Hashes = array_ssize_make_reserve( allocator, num );
|
||||
result.Entries = <fn_array>_make_reserve( allocator, num );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void <fn>_clear( <tbl_type> self )
|
||||
{
|
||||
for ( ssize idx = 0; idx < array_get_header( self.Hashes )->Num; idx++ )
|
||||
for ( ssize idx = 0; idx < array_header( self.Hashes )->Num; idx++ )
|
||||
self.Hashes[idx] = -1;
|
||||
|
||||
array_clear( self.Hashes );
|
||||
array_clear( self.Entries );
|
||||
array_ssize_clear( self.Hashes );
|
||||
<fn_array>_clear( self.Entries );
|
||||
}
|
||||
|
||||
void <fn>_destroy( <tbl_type> self )
|
||||
{
|
||||
if ( self.Hashes && self.Entries )
|
||||
{
|
||||
array_free( self.Hashes );
|
||||
array_free( self.Entries );
|
||||
array_ssize_free( self.Hashes );
|
||||
<fn_array>_free( self.Entries );
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
{
|
||||
GEN_ASSERT_NOT_NULL( map_proc );
|
||||
|
||||
for ( ssize idx = 0; idx < array_get_header( self.Entries )->Num; idx++ )
|
||||
for ( ssize idx = 0; idx < array_header( self.Entries )->Num; idx++ )
|
||||
{
|
||||
map_proc( self, self.Entries[idx].Key, self.Entries[idx].Value );
|
||||
}
|
||||
@ -158,7 +158,7 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
{
|
||||
GEN_ASSERT_NOT_NULL( map_proc );
|
||||
|
||||
for ( ssize idx = 0; idx < array_get_header( self.Entries )->Num; idx++ )
|
||||
for ( ssize idx = 0; idx < array_header( self.Entries )->Num; idx++ )
|
||||
{
|
||||
map_proc( self, self.Entries[idx].Key, & self.Entries[idx].Value );
|
||||
}
|
||||
@ -166,7 +166,7 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
|
||||
void <fn>_grow( <tbl_type>* self )
|
||||
{
|
||||
ssize new_num = array_grow_formula( array_get_header( self->Entries )->Num );
|
||||
ssize new_num = array_grow_formula( array_header( self->Entries )->Num );
|
||||
<fn>_rehash( self, new_num );
|
||||
}
|
||||
|
||||
@ -175,12 +175,12 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
ssize idx;
|
||||
ssize last_added_index;
|
||||
|
||||
ArrayHeader* old_hash_header = array_get_header( self->Hashes );
|
||||
ArrayHeader* old_entries_header = array_get_header( self->Entries );
|
||||
ArrayHeader* old_hash_header = array_header( self->Hashes );
|
||||
ArrayHeader* old_entries_header = array_header( self->Entries );
|
||||
|
||||
<tbl_type> new_tbl = <fn>_make_reserve( old_hash_header->Allocator, old_hash_header->Num );
|
||||
|
||||
ArrayHeader* new_hash_header = array_get_header( new_tbl.Hashes );
|
||||
ArrayHeader* new_hash_header = array_header( new_tbl.Hashes );
|
||||
|
||||
for ( idx = 0; idx < new_hash_header->Num; idx++ )
|
||||
new_tbl.Hashes[idx] = -1;
|
||||
@ -214,13 +214,13 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
{
|
||||
ssize idx;
|
||||
|
||||
for ( idx = 0; idx < array_get_header( self.Entries )->Num; idx++ )
|
||||
for ( idx = 0; idx < array_header( self.Entries )->Num; idx++ )
|
||||
self.Entries[ idx ].Next = -1;
|
||||
|
||||
for ( idx = 0; idx < array_get_header( self.Hashes )->Num; idx++ )
|
||||
for ( idx = 0; idx < array_header( self.Hashes )->Num; idx++ )
|
||||
self.Hashes[ idx ] = -1;
|
||||
|
||||
for ( idx = 0; idx < array_get_header( self.Entries )->Num; idx++ )
|
||||
for ( idx = 0; idx < array_header( self.Entries )->Num; idx++ )
|
||||
{
|
||||
<entry_type>* entry;
|
||||
HT_FindResult find_result;
|
||||
@ -241,22 +241,22 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
|
||||
if ( find_result.EntryIndex >= 0 )
|
||||
{
|
||||
array_remove_at( self.Entries, find_result.EntryIndex );
|
||||
<fn_array>_remove_at( self.Entries, find_result.EntryIndex );
|
||||
<fn>_rehash_fast( self );
|
||||
}
|
||||
}
|
||||
|
||||
void <fn>_remove_entry( <tbl_type> self, ssize idx )
|
||||
{
|
||||
array_remove_at( self.Entries, idx );
|
||||
<fn_array>_remove_at( self.Entries, idx );
|
||||
}
|
||||
|
||||
void <fn>_set( <tbl_type>* self, u64 key, <type> value )
|
||||
{
|
||||
ssize idx;
|
||||
ssize idx;
|
||||
HT_FindResult find_result;
|
||||
|
||||
if ( array_get_header( self->Hashes )->Num == 0 )
|
||||
if ( array_header( self->Hashes )->Num == 0 )
|
||||
<fn>_grow( self );
|
||||
|
||||
find_result = <fn>__find( * self, key );
|
||||
@ -287,7 +287,7 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
|
||||
ssize <fn>_slot( <tbl_type> self, u64 key )
|
||||
{
|
||||
for ( ssize idx = 0; idx < array_get_header( self.Hashes )->Num; ++idx )
|
||||
for ( ssize idx = 0; idx < array_header( self.Hashes )->Num; ++idx )
|
||||
if ( self.Hashes[ idx ] == key )
|
||||
return idx;
|
||||
|
||||
@ -299,8 +299,8 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
ssize idx;
|
||||
<entry_type> entry = { key, -1 };
|
||||
|
||||
idx = array_get_header( self.Entries )->Num;
|
||||
array_append( self.Entries, entry );
|
||||
idx = array_header( self.Entries )->Num;
|
||||
<fn_array>_append( & self.Entries, entry );
|
||||
return idx;
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
{
|
||||
HT_FindResult result = { -1, -1, -1 };
|
||||
|
||||
ArrayHeader* hash_header = array_get_header( self.Hashes );
|
||||
ArrayHeader* hash_header = array_header( self.Hashes );
|
||||
|
||||
if ( hash_header->Num > 0 )
|
||||
{
|
||||
@ -330,8 +330,8 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||
|
||||
b32 <fn>__full( <tbl_type> self )
|
||||
{
|
||||
ArrayHeader* hash_header = array_get_header( self.Hashes );
|
||||
ArrayHeader* entries_header = array_get_header( self.Entries );
|
||||
ArrayHeader* hash_header = array_header( self.Hashes );
|
||||
ArrayHeader* entries_header = array_header( self.Entries );
|
||||
|
||||
return 0.75f * hash_header->Num < entries_header->Num;
|
||||
}
|
||||
|
@ -63,7 +63,6 @@ CodeBody gen_fixed_arenas()
|
||||
result.append(arena_struct_8kb);
|
||||
result.append(arena_struct_16kb);
|
||||
result.append(arena_struct_32kb);
|
||||
result.append(arena_struct_64kb);
|
||||
result.append(arena_struct_128kb);
|
||||
result.append(arena_struct_256kb);
|
||||
result.append(arena_struct_512kb);
|
||||
@ -76,7 +75,6 @@ CodeBody gen_fixed_arenas()
|
||||
result.append(arena_interface_8kb);
|
||||
result.append(arena_interface_16kb);
|
||||
result.append(arena_interface_32kb);
|
||||
result.append(arena_interface_64kb);
|
||||
result.append(arena_interface_128kb);
|
||||
result.append(arena_interface_256kb);
|
||||
result.append(arena_interface_512kb);
|
||||
@ -102,7 +100,7 @@ CodeBody gen_fixed_arenas()
|
||||
FixedArena_1MB* : fixed_arena_init_1MB, \
|
||||
FixedArena_2MB* : fixed_arena_init_2MB, \
|
||||
FixedArena_4MB* : fixed_arena_init_4MB \
|
||||
) GEN_RESOLVED_FUNCTION_CALL(& expr)
|
||||
)(expr)
|
||||
|
||||
#define fixed_arena_size_remaining(expr, alignment) _Generic((expr), \
|
||||
FixedArena_1KB* : fixed_arena_size_remaining_1KB, \
|
||||
@ -117,7 +115,7 @@ CodeBody gen_fixed_arenas()
|
||||
FixedArena_1MB* : fixed_arena_size_remaining_1MB, \
|
||||
FixedArena_2MB* : fixed_arena_size_remaining_2MB, \
|
||||
FixedArena_4MB* : fixed_arena_size_remaining_4MB \
|
||||
) GEN_RESOLVED_FUNCTION_CALL(& expr, alignment)
|
||||
)(expr, alignment)
|
||||
)"
|
||||
)));
|
||||
|
||||
|
@ -9,9 +9,7 @@
|
||||
#include "helpers/helper.hpp"
|
||||
|
||||
GEN_NS_BEGIN
|
||||
#include "helpers/push_container_defines.inline.hpp"
|
||||
#include "dependencies/parsing.cpp"
|
||||
#include "helpers/pop_container_defines.inline.hpp"
|
||||
GEN_NS_END
|
||||
|
||||
#include "auxillary/builder.hpp"
|
||||
|
@ -24,7 +24,7 @@ void* Global_Allocator_Proc( void* allocator_data, AllocType type, ssize size, s
|
||||
if ( bucket.PhysicalStart == nullptr )
|
||||
GEN_FATAL( "Failed to create bucket for Global_AllocatorBuckets");
|
||||
|
||||
if ( ! array_append( Global_AllocatorBuckets, bucket ) )
|
||||
if ( ! array_append( & Global_AllocatorBuckets, bucket ) )
|
||||
GEN_FATAL( "Failed to append bucket to Global_AllocatorBuckets");
|
||||
|
||||
last = array_back(Global_AllocatorBuckets);
|
||||
@ -51,7 +51,7 @@ void* Global_Allocator_Proc( void* allocator_data, AllocType type, ssize size, s
|
||||
if ( bucket.PhysicalStart == nullptr )
|
||||
GEN_FATAL( "Failed to create bucket for Global_AllocatorBuckets");
|
||||
|
||||
if ( ! array_append( Global_AllocatorBuckets, bucket ) )
|
||||
if ( ! array_append( & Global_AllocatorBuckets, bucket ) )
|
||||
GEN_FATAL( "Failed to append bucket to Global_AllocatorBuckets");
|
||||
|
||||
last = array_back(Global_AllocatorBuckets);
|
||||
@ -249,7 +249,7 @@ void init()
|
||||
if ( bucket.PhysicalStart == nullptr )
|
||||
GEN_FATAL( "Failed to create first bucket for Global_AllocatorBuckets");
|
||||
|
||||
array_append( Global_AllocatorBuckets, bucket );
|
||||
array_append( & Global_AllocatorBuckets, bucket );
|
||||
}
|
||||
|
||||
// Setup the arrays
|
||||
@ -272,7 +272,7 @@ void init()
|
||||
if ( code_pool.PhysicalStart == nullptr )
|
||||
GEN_FATAL( "gen::init: Failed to initialize the code pool" );
|
||||
|
||||
array_append( CodePools, code_pool );
|
||||
array_append( & CodePools, code_pool );
|
||||
|
||||
LexArena = arena_init_from_allocator( Allocator_Lexer, LexAllocator_Size );
|
||||
|
||||
@ -281,7 +281,7 @@ void init()
|
||||
if ( string_arena.PhysicalStart == nullptr )
|
||||
GEN_FATAL( "gen::init: Failed to initialize the string arena" );
|
||||
|
||||
array_append( StringArenas, string_arena );
|
||||
array_append( & StringArenas, string_arena );
|
||||
}
|
||||
|
||||
// Setup the hash tables
|
||||
@ -381,7 +381,7 @@ AllocatorInfo get_string_allocator( s32 str_length )
|
||||
{
|
||||
Arena new_arena = arena_init_from_allocator( Allocator_StringArena, SizePer_StringArena );
|
||||
|
||||
if ( ! array_append( StringArenas, new_arena ) )
|
||||
if ( ! array_append( & StringArenas, new_arena ) )
|
||||
GEN_FATAL( "gen::get_string_allocator: Failed to allocate a new string arena" );
|
||||
|
||||
last = array_back(StringArenas);
|
||||
@ -419,7 +419,7 @@ Code make_code()
|
||||
if ( code_pool.PhysicalStart == nullptr )
|
||||
GEN_FATAL( "gen::make_code: Failed to allocate a new code pool - CodePool allcoator returned nullptr." );
|
||||
|
||||
if ( ! array_append( CodePools, code_pool ) )
|
||||
if ( ! array_append( & CodePools, code_pool ) )
|
||||
GEN_FATAL( "gen::make_code: Failed to allocate a new code pool - CodePools failed to append new pool." );
|
||||
|
||||
allocator = array_back( CodePools);
|
||||
|
@ -236,8 +236,7 @@ forceinline
|
||||
s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
{
|
||||
char const* hash = ctx->scanner;
|
||||
Token hash_tok = { hash, 1, Tok_Preprocess_Hash, ctx->line, ctx->column, TF_Preprocess };
|
||||
array_append( Tokens, hash_tok );
|
||||
array_append( & Tokens, { hash, 1, Tok_Preprocess_Hash, ctx->line, ctx->column, TF_Preprocess } );
|
||||
|
||||
move_forward();
|
||||
SkipWhitespace();
|
||||
@ -313,14 +312,14 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
|
||||
ctx->token.Length = ctx->token.Length + ctx->token.Text - hash;
|
||||
ctx->token.Text = hash;
|
||||
array_append( Tokens, ctx->token );
|
||||
array_append( & Tokens, ctx->token );
|
||||
return Lex_Continue; // Skip found token, its all handled here.
|
||||
}
|
||||
|
||||
if ( ctx->token.Type == Tok_Preprocess_Else || ctx->token.Type == Tok_Preprocess_EndIf )
|
||||
{
|
||||
ctx->token.Flags |= TF_Preprocess_Cond;
|
||||
array_append( Tokens, ctx->token );
|
||||
array_append( & Tokens, ctx->token );
|
||||
end_line();
|
||||
return Lex_Continue;
|
||||
}
|
||||
@ -329,7 +328,7 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
ctx->token.Flags |= TF_Preprocess_Cond;
|
||||
}
|
||||
|
||||
array_append( Tokens, ctx->token );
|
||||
array_append( & Tokens, ctx->token );
|
||||
|
||||
SkipWhitespace();
|
||||
|
||||
@ -353,7 +352,7 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
name.Length++;
|
||||
}
|
||||
|
||||
array_append( Tokens, name );
|
||||
array_append( & Tokens, name );
|
||||
|
||||
u64 key = crc32( name.Text, name.Length );
|
||||
hashtable_set(ctx->defines, key, to_str(name) );
|
||||
@ -399,7 +398,7 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
move_forward();
|
||||
}
|
||||
|
||||
array_append( Tokens, preprocess_content );
|
||||
array_append( & Tokens, preprocess_content );
|
||||
return Lex_Continue; // Skip found token, its all handled here.
|
||||
}
|
||||
|
||||
@ -462,7 +461,7 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
preprocess_content.Length++;
|
||||
}
|
||||
|
||||
array_append( Tokens, preprocess_content );
|
||||
array_append( & Tokens, preprocess_content );
|
||||
return Lex_Continue; // Skip found token, its all handled here.
|
||||
}
|
||||
|
||||
@ -471,7 +470,7 @@ void lex_found_token( LexContext* ctx )
|
||||
{
|
||||
if ( ctx->token.Type != Tok_Invalid )
|
||||
{
|
||||
array_append( Tokens, ctx->token );
|
||||
array_append( & Tokens, ctx->token );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -498,7 +497,7 @@ void lex_found_token( LexContext* ctx )
|
||||
}
|
||||
|
||||
ctx->token.Type = type;
|
||||
array_append( Tokens, ctx->token );
|
||||
array_append( & Tokens, ctx->token );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -508,7 +507,7 @@ void lex_found_token( LexContext* ctx )
|
||||
{
|
||||
ctx->token.Type = type;
|
||||
ctx->token.Flags |= TF_Specifier;
|
||||
array_append( Tokens, ctx->token );
|
||||
array_append( & Tokens, ctx->token );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -516,7 +515,7 @@ void lex_found_token( LexContext* ctx )
|
||||
if ( type != Tok_Invalid )
|
||||
{
|
||||
ctx->token.Type = type;
|
||||
array_append( Tokens, ctx->token );
|
||||
array_append( & Tokens, ctx->token );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -570,7 +569,7 @@ void lex_found_token( LexContext* ctx )
|
||||
ctx->token.Type = Tok_Identifier;
|
||||
}
|
||||
|
||||
array_append( Tokens, ctx->token );
|
||||
array_append( & Tokens, ctx->token );
|
||||
}
|
||||
|
||||
neverinline
|
||||
@ -644,7 +643,7 @@ TokArray lex( StrC content )
|
||||
c.token.Type = Tok_NewLine;
|
||||
c.token.Length++;
|
||||
|
||||
array_append( Tokens, c.token );
|
||||
array_append( & Tokens, c.token );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -680,7 +679,7 @@ TokArray lex( StrC content )
|
||||
c.token.Length++;
|
||||
move_forward();
|
||||
|
||||
array_append( Tokens, c.token );
|
||||
array_append( & Tokens, c.token );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1135,7 +1134,7 @@ TokArray lex( StrC content )
|
||||
move_forward();
|
||||
c.token.Length++;
|
||||
}
|
||||
array_append( Tokens, c.token );
|
||||
array_append( & Tokens, c.token );
|
||||
continue;
|
||||
}
|
||||
else if ( current == '*' )
|
||||
@ -1171,7 +1170,7 @@ TokArray lex( StrC content )
|
||||
move_forward();
|
||||
c.token.Length++;
|
||||
}
|
||||
array_append( Tokens, c.token );
|
||||
array_append( & Tokens, c.token );
|
||||
// end_line();
|
||||
continue;
|
||||
}
|
||||
@ -1304,7 +1303,7 @@ TokArray lex( StrC content )
|
||||
c.token.Length++;
|
||||
move_forward();
|
||||
|
||||
array_append( Tokens, c.token );
|
||||
array_append( & Tokens, c.token );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -755,7 +755,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false )
|
||||
}
|
||||
Token interface_tok = parse_identifier();
|
||||
|
||||
array_append( interfaces, def_type( to_str(interface_tok) ) );
|
||||
array_append( & interfaces, def_type( to_str(interface_tok) ) );
|
||||
// <ModuleFlags> <class/struct> <Attributes> <Name> : <Access Specifier> <Name>, ...
|
||||
}
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ usize array_grow_formula(ssize value);
|
||||
template<class Type> Array<Type> array_init (AllocatorInfo allocator);
|
||||
template<class Type> Array<Type> array_init_reserve (AllocatorInfo allocator, ssize capacity);
|
||||
template<class Type> bool array_append_array (Array<Type>* array, Array<Type> other);
|
||||
template<class Type> bool array_append (Array<Type>* array, Type value);
|
||||
template<class Type> bool array_append_value (Array<Type>* array, Type value);
|
||||
template<class Type> bool array_append_items (Array<Type>* array, Type* items, usize item_num);
|
||||
template<class Type> bool array_append_at (Array<Type>* array, Type item, usize idx);
|
||||
template<class Type> bool array_append_items_at(Array<Type>* array, Type* items, usize item_num, usize idx);
|
||||
template<class Type> bool array_append_at_items(Array<Type>* array, Type* items, usize item_num, usize idx);
|
||||
template<class Type> Type* array_back (Array<Type> array);
|
||||
template<class Type> void array_clear (Array<Type> array);
|
||||
template<class Type> bool array_fill (Array<Type> array, usize begin, usize end, Type value);
|
||||
@ -73,11 +73,11 @@ struct Array
|
||||
forceinline static Array init_reserve(AllocatorInfo allocator, ssize capacity) { return GEN_NS array_init_reserve<Type>(allocator, capacity); }
|
||||
forceinline static usize grow_formula(ssize value) { return GEN_NS array_grow_formula<Type>(value); }
|
||||
|
||||
forceinline bool append(Array other) { return GEN_NS array_append_array<Type>(this, other); }
|
||||
forceinline bool append(Array other) { return GEN_NS array_append<Type>(this, other); }
|
||||
forceinline bool append(Type value) { return GEN_NS array_append<Type>(this, value); }
|
||||
forceinline bool append(Type* items, usize item_num) { return GEN_NS array_append_items<Type>(this, items, item_num); }
|
||||
forceinline bool append(Type* items, usize item_num) { return GEN_NS array_append<Type>(this, items, item_num); }
|
||||
forceinline bool append_at(Type item, usize idx) { return GEN_NS array_append_at<Type>(this, item, idx); }
|
||||
forceinline bool append_at(Type* items, usize item_num, usize idx) { return GEN_NS array_append_items_at<Type>(this, items, item_num, idx); }
|
||||
forceinline bool append_at(Type* items, usize item_num, usize idx) { return GEN_NS array_append_at<Type>(this, items, item_num, idx); }
|
||||
forceinline Type* back() { return GEN_NS array_back<Type>(* this); }
|
||||
forceinline void clear() { GEN_NS array_clear<Type>(* this); }
|
||||
forceinline bool fill(usize begin, usize end, Type value) { return GEN_NS array_fill<Type>(* this, begin, end, value); }
|
||||
@ -150,8 +150,8 @@ usize array_grow_formula(ssize value) {
|
||||
}
|
||||
|
||||
template<class Type> inline
|
||||
bool array_append_array(Array<Type>* array, Array<Type> other) {
|
||||
return array_append_items(array, (Type*)other, num(other));
|
||||
bool array_append(Array<Type>* array, Array<Type> other) {
|
||||
return append(array, other, num(other));
|
||||
}
|
||||
|
||||
template<class Type> inline
|
||||
@ -173,7 +173,7 @@ bool array_append(Array<Type>* array, Type value)
|
||||
}
|
||||
|
||||
template<class Type> inline
|
||||
bool array_append_items(Array<Type>* array, Type* items, usize item_num)
|
||||
bool array_append(Array<Type>* array, Type* items, usize item_num)
|
||||
{
|
||||
ArrayHeader* header = array_get_header(array);
|
||||
|
||||
@ -221,7 +221,7 @@ bool array_append_at(Array<Type>* array, Type item, usize idx)
|
||||
}
|
||||
|
||||
template<class Type> inline
|
||||
bool array_append_items_at(Array<Type>* array, Type* items, usize item_num, usize idx)
|
||||
bool array_append_at(Array<Type>* array, Type* items, usize item_num, usize idx)
|
||||
{
|
||||
ArrayHeader* header = get_header(array);
|
||||
|
||||
@ -396,9 +396,9 @@ bool array_set_capacity(Array<Type>* array, usize new_capacity)
|
||||
|
||||
#define array_init(type, allocator) array_init <type> (allocator )
|
||||
#define array_init_reserve(type, allocator, cap) array_init_reserve <type> (allocator, cap)
|
||||
#define array_append_array(array, other) array_append_array < get_array_underlying_type(array) > (& array, other )
|
||||
#define array_append(array, value) array_append < get_array_underlying_type(array) > (& array, value )
|
||||
#define array_append_items(array, items, item_num) array_append_items < get_array_underlying_type(array) > (& array, items, item_num )
|
||||
#define array_append_array(array, other) array_append < get_array_underlying_type(array) > (& array, other )
|
||||
#define array_append_value(array, value) array_append < get_array_underlying_type(array) > (& array, value )
|
||||
#define array_append_items(array, items, item_num) array_append < get_array_underlying_type(array) > (& array, items, item_num )
|
||||
#define array_append_at(array, item, idx ) array_append_at < get_array_underlying_type(array) > (& array, item, idx )
|
||||
#define array_append_at_items(array, items, item_num, idx) array_append_at_items< get_array_underlying_type(array) > (& items, item_num, idx )
|
||||
#define array_back(array) array_back < get_array_underlying_type(array) > (array )
|
||||
@ -680,7 +680,7 @@ ssize hashtable_add_entry(HashTable<Type>* table, u64 key) {
|
||||
HashTableEntry<Type> entry = { key, -1 };
|
||||
|
||||
idx = array_num(table->Entries);
|
||||
array_append( table->Entries, entry);
|
||||
array_append( & table->Entries, entry);
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
@ -89,10 +89,6 @@
|
||||
#endif
|
||||
|
||||
#ifndef num_args_impl
|
||||
|
||||
// This is essentially an arg couneter version of GEN_SELECT_ARG macros
|
||||
// See section : _Generic function overloading for that usage (explains this heavier case)
|
||||
|
||||
#define num_args_impl( _0, \
|
||||
_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \
|
||||
_11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
|
||||
@ -269,98 +265,4 @@
|
||||
#define struct_init(type, value) {value}
|
||||
#endif
|
||||
|
||||
// ------------------------ _Generic function overloading -----------------------------------------
|
||||
#if GEN_COMPILER_C
|
||||
// This implemnents macros for utilizing "The Naive Extendible _Generic Macro" explained in:
|
||||
// https://github.com/JacksonAllan/CC/blob/main/articles/Better_C_Generics_Part_1_The_Extendible_Generic.md
|
||||
// Since gencpp is used to generate the c-library, it was choosen over the more novel implementations to keep the macros as easy to understand and unopaque as possible.
|
||||
// Extensive effort was put in below to make this as easy as possible to understand what is going on with this mess of a preoprocessor.
|
||||
|
||||
#define GEN_COMMA_OPERATOR , // The comma operator is used by preprocessor macros to delimit arguments, so we have to represent it via a macro to prevent parsing incorrectly.
|
||||
|
||||
// Helper macros for argument selection
|
||||
#define GEN_SELECT_ARG_1( _1, ... ) _1 // <-- Of all th args passed pick _1.
|
||||
#define GEN_SELECT_ARG_2( _1, _2, ... ) _2 // <-- Of all the args passed pick _2.
|
||||
#define GEN_SELECT_ARG_3( _1, _2, _3, ... ) _3 // etc.. (by induction until _8, which we don't support any more beyond)
|
||||
// #define GEN_SELECT_ARG_4( _1, _2, _3, _4, ... ) _4
|
||||
// #define GEN_SELECT_ARG_5( _1, _2, _3, _4, _5, ... ) _5
|
||||
// #define GEN_SELECT_ARG_6( _1, _2, _3, _4, _5, _6, ... ) _6
|
||||
// #define GEN_SELECT_ARG_7( _1, _2, _3, _4, _5, _6, _7, ... ) _7
|
||||
// #define GEN_SELECT_ARG_8( _1, _2, _3, _4, _5, _6, _7, _8, ... ) _8
|
||||
|
||||
#define GEN_GENERIC_SEL_ENTRY_TYPE GEN_SELECT_ARG_1 // Use the arg expansion macro to select arg 1 which should have the type.
|
||||
#define GEN_GENERIC_SEL_ENTRY_FUNCTION GEN_SELECT_ARG_2 // Use the arg expansion macro to select arg 2 which should have the function.
|
||||
#define GEN_GENERIC_SEL_ENTRY_COMMA_DELIMITER GEN_SELECT_ARG_3 // Use the arg expansion macro to select arg 3 which should have the comma delimiter ','.
|
||||
|
||||
#define GEN_RESOLVED_FUNCTION_CALL // Just used to indicate where the call "occurs"
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( macro ) includes a _Generic slot only if the specified macro is defined (as type, function_name).
|
||||
// It takes advantage of the fact that if the macro is defined, then the expanded text will contain a comma.
|
||||
// Expands to ',' if it can find (type): (function) <comma_operator: ',' >
|
||||
// Where GEN_GENERIC_SEL_ENTRY_COMMA_DELIMITER is specifically looking for that <comma> ,
|
||||
#define GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( slot_exp ) GEN_SELECT_ARG_3( slot_exp, GEN_SELECT_ARG_1( slot_exp, ): GEN_SELECT_ARG_2( slot_exp, ) GEN_COMMA_OPERATOR, , )
|
||||
// ^Selects the comma ^ is the type ^ is the function ^ comma delimiter to select ^ Insert a comma
|
||||
// The slot won't exist if that comma is not found.
|
||||
// |
|
||||
// This is the same as above but it does not insert a comma V no comma here.
|
||||
#define GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT_LAST( slot_exp ) GEN_GENERIC_SEL_ENTRY_COMMA_DELIMITER( slot_exp, GEN_GENERIC_SEL_ENTRY_TYPE( slot_exp, ): GEN_GENERIC_SEL_ENTRY_FUNCTION( slot_exp, ), , )
|
||||
// Needed for the last slot as they don't allow trailing commas.
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Below are generated on demand for a generated function
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
#define GEN_FUNCTION_GENERIC_EXAMPLE( function_arguments ) _Generic( \
|
||||
(function_arguments), /* Select Via Expression*/ \
|
||||
/* Extendibility slots: */ \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( FunctionID__ARGS_SIG_1 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( FunctionID__ARGS_SIG_1 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( FunctionID__ARGS_SIG_1 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( FunctionID__ARGS_SIG_1 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( FunctionID__ARGS_SIG_1 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( FunctionID__ARGS_SIG_1 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( FunctionID__ARGS_SIG_1 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT_LAST FunctionID__ARGS_SIG_1 ) \
|
||||
) GEN_RESOLVED_FUNCTION_CALL( function_arguments )
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Then each definiton of a function has an associated define:
|
||||
// #define <function_id_macro> GEN_GENERIC_FUNCTION_ARG_SIGNATURE( <function_id>, <arguments> )
|
||||
#define GEN_GENERIC_FUNCTION_ARG_SIGNATURE( name_of_function, type_delimiter ) type_delimiter name_of_function
|
||||
|
||||
// Then somehwere later on
|
||||
// <etc> <return_type> <function_id> ( <arguments> ) { <implementation> }
|
||||
|
||||
// Concrete example:
|
||||
#define ENABLE_GENERIC_EXAMPLE 0
|
||||
#if ENABLE_GENERIC_EXAMPLE
|
||||
|
||||
// To add support for long:
|
||||
#define HASH__ARGS_SIG_1 GEN_GENERIC_FUNCTION_ARG_SIGNATURE( hash__P_long, long long )
|
||||
size_t hash__P_long ( long val ) { return val * 2654435761ull; }
|
||||
|
||||
// To add support for long long:
|
||||
#define HASH__ARGS_SIG_2 GEN_GENERIC_FUNCTION_ARG_SIGNATURE( hash__P_long_long, long long )
|
||||
size_t hash__P_long_long( long long val ) { return val * 2654435761ull; }
|
||||
|
||||
// If using an Editor with support for syntax hightlighting macros: HASH__ARGS_SIG_1 and HASH_ARGS_SIG_2 should show color highlighting indicating the slot is enabled,
|
||||
// or, "defined" for usage during the compilation pass that handles the _Generic instrinsic.
|
||||
#define hash( function_arguments ) _Generic( \
|
||||
(function_arguments), /* Select Via Expression*/ \
|
||||
/* Extendibility slots: */ \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( HASH__ARGS_SIG_1 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( HASH__ARGS_SIG_2 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( HASH__ARGS_SIG_3 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( HASH__ARGS_SIG_4 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( HASH__ARGS_SIG_5 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( HASH__ARGS_SIG_6 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( HASH__ARGS_SIG_7 ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT_LAST( HASH__ARGS_SIG_8 ) \
|
||||
) GEN_RESOLVED_FUNCTION_CALL( function_arguments )
|
||||
|
||||
#endif // ENABLE_GENERIC_EXAMPLE
|
||||
|
||||
// END OF ------------------------ _Generic function overloading ----------------------------------------- END OF
|
||||
#endif
|
||||
|
||||
#pragma endregion Macros
|
||||
|
@ -1,6 +1,5 @@
|
||||
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
||||
# pragma once
|
||||
# include "parsing.hpp"
|
||||
#endif
|
||||
|
||||
#pragma region ADT
|
||||
@ -43,7 +42,7 @@ u8 adt_destroy_branch( ADT_Node* node )
|
||||
adt_destroy_branch( node->nodes + i );
|
||||
}
|
||||
|
||||
array_free(node->nodes);
|
||||
array_free(& node->nodes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -289,7 +288,7 @@ ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index )
|
||||
|
||||
ADT_Node o = { 0 };
|
||||
o.parent = parent;
|
||||
if ( ! array_append_at( parent->nodes, o, index ) )
|
||||
if ( ! array_append_at( & parent->nodes, o, index ) )
|
||||
return NULL;
|
||||
|
||||
ADT_Node* node = & parent->nodes[index];
|
||||
@ -956,7 +955,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
adt_append_arr( root, NULL );
|
||||
}
|
||||
|
||||
array_append( root->nodes[ columnIndex ].nodes, rowItem );
|
||||
array_append( & root->nodes[ columnIndex ].nodes, rowItem );
|
||||
|
||||
if ( delimiter == delim )
|
||||
{
|
||||
|
@ -13,7 +13,43 @@
|
||||
// They are undefined in gen.hpp and gen.cpp at the end of the files.
|
||||
// We cpp library expects the user to use the regular calls as they can resolve the type fine.
|
||||
|
||||
#include "helpers/push_container_defines.inline.hpp"
|
||||
#define array_init(type, allocator) array_init <type> (allocator )
|
||||
#define array_init_reserve(type, allocator, cap) array_init_reserve <type> (allocator, cap)
|
||||
#define array_append_array(array, other) array_append < get_array_underlying_type(array) > (& array, other )
|
||||
#define array_append_value(array, value) array_append < get_array_underlying_type(array) > (& array, value )
|
||||
#define array_append_items(array, items, item_num) array_append < get_array_underlying_type(array) > (& array, items, item_num )
|
||||
#define array_append_at(array, item, idx ) array_append_at < get_array_underlying_type(array) > (& array, item, idx )
|
||||
#define array_append_at_items(array, items, item_num, idx) array_append_at_items< get_array_underlying_type(array) > (& items, item_num, idx )
|
||||
#define array_back(array) array_back < get_array_underlying_type(array) > (array )
|
||||
#define array_clear(array) array_clear < get_array_underlying_type(array) > (array )
|
||||
#define array_fill(array, begin, end, value) array_fill < get_array_underlying_type(array) > (array, begin, end, value )
|
||||
#define array_free(array) array_free < get_array_underlying_type(array) > (& array )
|
||||
#define arary_grow(array, min_capacity) arary_grow < get_array_underlying_type(array) > (& array, min_capacity)
|
||||
#define array_num(array) array_num < get_array_underlying_type(array) > (array )
|
||||
#define arary_pop(array) arary_pop < get_array_underlying_type(array) > (array )
|
||||
#define arary_remove_at(array, idx) arary_remove_at < get_array_underlying_type(array) > (idx)
|
||||
#define arary_reserve(array, new_capacity) arary_reserve < get_array_underlying_type(array) > (& array, new_capacity )
|
||||
#define arary_resize(array, num) arary_resize < get_array_underlying_type(array) > (& array, num)
|
||||
#define arary_set_capacity(new_capacity) arary_set_capacity < get_array_underlying_type(array) > (& array, new_capacity )
|
||||
#define arary_get_header(array) arary_get_header < get_array_underlying_type(array) > (array )
|
||||
|
||||
#define hashtable_init(type, allocator) hashtable_init <type >(allocator)
|
||||
#define hashtable_init_reserve(type, allocator, num) hashtable_init_reserve<type >(allocator, num)
|
||||
#define hashtable_clear(table) hashtable_clear < get_hashtable_underlying_type(table) >(table)
|
||||
#define hashtable_destroy(table) hashtable_destroy < get_hashtable_underlying_type(table) >(& table)
|
||||
#define hashtable_get(table, key) hashtable_get < get_hashtable_underlying_type(table) >(table, key)
|
||||
#define hashtable_grow(table) hashtable_grow < get_hashtable_underlying_type(table) >(& table)
|
||||
#define hashtable_rehash(table, new_num) hashtable_rehash < get_hashtable_underlying_type(table) >(& table, new_num)
|
||||
#define hashtable_rehash_fast(table) hashtable_rehash_fast < get_hashtable_underlying_type(table) >(table)
|
||||
#define hashtable_remove(table, key) hashtable_remove < get_hashtable_underlying_type(table) >(table, key)
|
||||
#define hashtable_remove_entry(table, idx) hashtable_remove_entry< get_hashtable_underlying_type(table) >(table, idx)
|
||||
#define hashtable_set(table, key, value) hashtable_set < get_hashtable_underlying_type(table) >(& table, key, value)
|
||||
#define hashtable_slot(table, key) hashtable_slot < get_hashtable_underlying_type(table) >(table, key)
|
||||
#define hashtable_add_entry(table, key) hashtable_add_entry < get_hashtable_underlying_type(table) >(& table, key)
|
||||
#define hashtable_find(table, key) hashtable_find < get_hashtable_underlying_type(table) >(table, key)
|
||||
#define hashtable_full(table) hashtable_full < get_hashtable_underlying_type(table) >(table)
|
||||
#define hashtable_map(table, map_proc) hashtable_map < get_hashtable_underlying_type(table) >(table, map_proc)
|
||||
#define hashtable_map_mut(table, map_proc) hashtable_map_mut < get_hashtable_underlying_type(table) >(table, map_proc)
|
||||
|
||||
//! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file.
|
||||
//! Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl
|
||||
@ -39,5 +75,42 @@ GEN_NS_BEGIN
|
||||
|
||||
GEN_NS_END
|
||||
|
||||
#include "helpers/pop_container_defines.inline.hpp"
|
||||
#include "helpers/pop_ignores.inline.hpp"
|
||||
|
||||
#undef array_init
|
||||
#undef array_init_reserve
|
||||
#undef array_append_array
|
||||
#undef array_append_value
|
||||
#undef array_append_items
|
||||
#undef array_append_at
|
||||
#undef array_append_at
|
||||
#undef array_back
|
||||
#undef array_clear
|
||||
#undef array_fill
|
||||
#undef array_free
|
||||
#undef arary_grow
|
||||
#undef array_num
|
||||
#undef arary_pop
|
||||
#undef arary_remove_at
|
||||
#undef arary_reserve
|
||||
#undef arary_resize
|
||||
#undef arary_set_capacity
|
||||
#undef arary_get_header
|
||||
|
||||
#undef hashtable_init
|
||||
#undef hashtable_init_reserve
|
||||
#undef hashtable_clear
|
||||
#undef hashtable_destroy
|
||||
#undef hashtable_get
|
||||
#undef hashtable_grow
|
||||
#undef hashtable_rehash
|
||||
#undef hashtable_rehash_fast
|
||||
#undef hashtable_remove
|
||||
#undef hashtable_remove_entry
|
||||
#undef hashtable_set
|
||||
#undef hashtable_slot
|
||||
#undef hashtable_add_entry
|
||||
#undef hashtable_find
|
||||
#undef hashtable_full
|
||||
#undef hashtable_map
|
||||
#undef hashtable_map_mut
|
||||
|
@ -11,9 +11,6 @@
|
||||
#include "helpers/push_ignores.inline.hpp"
|
||||
#include "components/header_start.hpp"
|
||||
|
||||
// Has container defines pushed
|
||||
#include "gen.dep.hpp"
|
||||
|
||||
GEN_NS_BEGIN
|
||||
|
||||
#include "components/types.hpp"
|
||||
@ -33,5 +30,42 @@ GEN_NS_BEGIN
|
||||
|
||||
GEN_NS_END
|
||||
|
||||
#include "helpers/pop_container_defines.inline.hpp"
|
||||
#include "helpers/pop_ignores.inline.hpp"
|
||||
|
||||
#undef array_init
|
||||
#undef array_init_reserve
|
||||
#undef array_append_array
|
||||
#undef array_append_value
|
||||
#undef array_append_items
|
||||
#undef array_append_at
|
||||
#undef array_append_at
|
||||
#undef array_back
|
||||
#undef array_clear
|
||||
#undef array_fill
|
||||
#undef array_free
|
||||
#undef arary_grow
|
||||
#undef array_num
|
||||
#undef arary_pop
|
||||
#undef arary_remove_at
|
||||
#undef arary_reserve
|
||||
#undef arary_resize
|
||||
#undef arary_set_capacity
|
||||
#undef arary_get_header
|
||||
|
||||
#undef hashtable_init
|
||||
#undef hashtable_init_reserve
|
||||
#undef hashtable_clear
|
||||
#undef hashtable_destroy
|
||||
#undef hashtable_get
|
||||
#undef hashtable_grow
|
||||
#undef hashtable_rehash
|
||||
#undef hashtable_rehash_fast
|
||||
#undef hashtable_remove
|
||||
#undef hashtable_remove_entry
|
||||
#undef hashtable_set
|
||||
#undef hashtable_slot
|
||||
#undef hashtable_add_entry
|
||||
#undef hashtable_find
|
||||
#undef hashtable_full
|
||||
#undef hashtable_map
|
||||
#undef hashtable_map_mut
|
||||
|
@ -1,38 +0,0 @@
|
||||
|
||||
#undef array_init
|
||||
#undef array_init_reserve
|
||||
#undef array_append_array
|
||||
#undef array_append
|
||||
#undef array_append_items
|
||||
#undef array_append_at
|
||||
#undef array_append_items_at
|
||||
#undef array_back
|
||||
#undef array_clear
|
||||
#undef array_fill
|
||||
#undef array_free
|
||||
#undef arary_grow
|
||||
#undef array_num
|
||||
#undef arary_pop
|
||||
#undef arary_remove_at
|
||||
#undef arary_reserve
|
||||
#undef arary_resize
|
||||
#undef arary_set_capacity
|
||||
#undef arary_get_header
|
||||
|
||||
#undef hashtable_init
|
||||
#undef hashtable_init_reserve
|
||||
#undef hashtable_clear
|
||||
#undef hashtable_destroy
|
||||
#undef hashtable_get
|
||||
#undef hashtable_grow
|
||||
#undef hashtable_rehash
|
||||
#undef hashtable_rehash_fast
|
||||
#undef hashtable_remove
|
||||
#undef hashtable_remove_entry
|
||||
#undef hashtable_set
|
||||
#undef hashtable_slot
|
||||
#undef hashtable_add_entry
|
||||
#undef hashtable_find
|
||||
#undef hashtable_full
|
||||
#undef hashtable_map
|
||||
#undef hashtable_map_mut
|
@ -1,9 +1,8 @@
|
||||
|
||||
#define array_init(type, allocator) array_init <type> (allocator )
|
||||
#define array_init_reserve(type, allocator, cap) array_init_reserve <type> (allocator, cap)
|
||||
#define array_append_array(array, other) array_append_array < get_array_underlying_type(array) > (& array, other )
|
||||
#define array_append(array, value) array_append < get_array_underlying_type(array) > (& array, value )
|
||||
#define array_append_items(array, items, item_num) array_append_items < get_array_underlying_type(array) > (& array, items, item_num )
|
||||
#define array_append_array(array, other) array_append < get_array_underlying_type(array) > (& array, other )
|
||||
#define array_append_value(array, value) array_append < get_array_underlying_type(array) > (& array, value )
|
||||
#define array_append_items(array, items, item_num) array_append < get_array_underlying_type(array) > (& array, items, item_num )
|
||||
#define array_append_at(array, item, idx ) array_append_at < get_array_underlying_type(array) > (& array, item, idx )
|
||||
#define array_append_at_items(array, items, item_num, idx) array_append_at_items< get_array_underlying_type(array) > (& items, item_num, idx )
|
||||
#define array_back(array) array_back < get_array_underlying_type(array) > (array )
|
||||
@ -18,21 +17,3 @@
|
||||
#define arary_resize(array, num) arary_resize < get_array_underlying_type(array) > (& array, num)
|
||||
#define arary_set_capacity(new_capacity) arary_set_capacity < get_array_underlying_type(array) > (& array, new_capacity )
|
||||
#define arary_get_header(array) arary_get_header < get_array_underlying_type(array) > (array )
|
||||
|
||||
#define hashtable_init(type, allocator) hashtable_init <type >(allocator)
|
||||
#define hashtable_init_reserve(type, allocator, num) hashtable_init_reserve<type >(allocator, num)
|
||||
#define hashtable_clear(table) hashtable_clear < get_hashtable_underlying_type(table) >(table)
|
||||
#define hashtable_destroy(table) hashtable_destroy < get_hashtable_underlying_type(table) >(& table)
|
||||
#define hashtable_get(table, key) hashtable_get < get_hashtable_underlying_type(table) >(table, key)
|
||||
#define hashtable_grow(table) hashtable_grow < get_hashtable_underlying_type(table) >(& table)
|
||||
#define hashtable_rehash(table, new_num) hashtable_rehash < get_hashtable_underlying_type(table) >(& table, new_num)
|
||||
#define hashtable_rehash_fast(table) hashtable_rehash_fast < get_hashtable_underlying_type(table) >(table)
|
||||
#define hashtable_remove(table, key) hashtable_remove < get_hashtable_underlying_type(table) >(table, key)
|
||||
#define hashtable_remove_entry(table, idx) hashtable_remove_entry< get_hashtable_underlying_type(table) >(table, idx)
|
||||
#define hashtable_set(table, key, value) hashtable_set < get_hashtable_underlying_type(table) >(& table, key, value)
|
||||
#define hashtable_slot(table, key) hashtable_slot < get_hashtable_underlying_type(table) >(table, key)
|
||||
#define hashtable_add_entry(table, key) hashtable_add_entry < get_hashtable_underlying_type(table) >(& table, key)
|
||||
#define hashtable_find(table, key) hashtable_find < get_hashtable_underlying_type(table) >(table, key)
|
||||
#define hashtable_full(table) hashtable_full < get_hashtable_underlying_type(table) >(table)
|
||||
#define hashtable_map(table, map_proc) hashtable_map < get_hashtable_underlying_type(table) >(table, map_proc)
|
||||
#define hashtable_map_mut(table, map_proc) hashtable_map_mut < get_hashtable_underlying_type(table) >(table, map_proc)
|
||||
|
@ -237,7 +237,6 @@ if ( $c_library )
|
||||
} elseif ($vendor -eq "msvc") {
|
||||
$compiler_args += "/TC" # Compile as C
|
||||
$compiler_args += "/Zc:__cplusplus" # Fix __cplusplus macro
|
||||
$compiler_args += "/std:c11"
|
||||
}
|
||||
|
||||
build-simple $path_build $includes $compiler_args $linker_args $unit $executable
|
||||
|
Loading…
Reference in New Issue
Block a user