fixes for c library

This commit is contained in:
2024-12-15 22:53:32 -05:00
parent 980d1d7134
commit c90c210e04
24 changed files with 244 additions and 92 deletions

View File

@ -1126,6 +1126,9 @@ R"(#define <interface_name>( code ) _Generic( (code), \
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_interface, interface );
if (found) break;
found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP"), entry, parsed_interface, interface);
if (found) break;
interface.append(entry);
}
break;
@ -1136,12 +1139,14 @@ R"(#define <interface_name>( code ) _Generic( (code), \
CodeFn fn = cast(CodeFn, entry);
Code prev = entry->Prev;
#if 0
if (prev && prev->Name.is_equal(entry->Name)) {
// rename second definition so there isn't a symbol conflict
StrBuilder postfix_arr = StrBuilder::fmt_buf(_ctx->Allocator_Temp, "%S_arr", entry->Name);
entry->Name = cache_str(postfix_arr.to_str());
postfix_arr.free();
}
#endif
b32 handled= false;
for ( CodeParams opt_param : fn->Params ) if (opt_param->ValueType->Name.starts_with(txt("Opts_")))
@ -1368,6 +1373,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
{
CodeFn fn = cast(CodeFn, entry);
Code prev = entry->Prev;
#if 0
for ( CodeParams arr_param : fn->Params )
{
b32 repeat_register_macros = fn->Name.is_equal(txt("register_macros")) && arr_param->Name.is_equal(txt("num")) && ! arr_param->Next->Name.is_equal(txt("..."));
@ -1377,6 +1383,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
fn->Name = cache_str(postfix_arr.to_str());
}
}
#endif
src_interface.append(fn);
}
break;
@ -1444,6 +1451,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
CodeFn fn = cast(CodeFn, entry);
Code prev = entry->Prev;
#if 0
for ( CodeParams arr_param : fn->Params )
{
b32 repeat_def_array = fn->Name.starts_with(txt("def_")) && arr_param->Name.is_equal(txt("num")) && ! arr_param->Next->Name.is_equal(txt("..."));
@ -1453,6 +1461,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
fn->Name = cache_str(postfix_arr.to_str());
}
}
#endif
for ( CodeParams opt_param : fn->Params ) if (opt_param->ValueType->Name.starts_with(txt("Opts_")))
{
// The frontend names are warapped in macros so we need to give it the intenral symbol name

View File

@ -21,7 +21,7 @@ word global, gen_global
word internal, gen_internal
word local_persist, gen_local_persist
word bit, gen_bit
word bitfield_is_set, gen_bitfield_is_set
word bitfield_is_set, gen_bitfield_is_set
word cast, gen_cast
word ccast, gen_ccast
word pcast, gen_pcast
@ -408,6 +408,8 @@ namespace var_, gen_var_
// Gen Interface
word _ctx, gen__ctx
word init, gen_init
word deinit, gen_deinit
word reset, gen_reset

View File

@ -238,10 +238,10 @@ CodeBody gen_array( Str type, Str array_name )
GEN_ASSERT(begin <= end);
ArrayHeader* header = array_get_header( self );
if ( begin < 0 || end >= header->Num )
if ( begin < 0 || end > header->Num )
return false;
for ( ssize idx = begin; idx < end; idx ++ )
for ( ssize idx = (ssize)begin; idx < (ssize)end; idx ++ )
self[ idx ] = value;
return true;