minor updates for better unused code cleanup in the c_library

This commit is contained in:
2024-12-16 17:18:52 -05:00
parent 6533a3be29
commit 6689235691
6 changed files with 30 additions and 29 deletions

View File

@ -1129,6 +1129,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
CodeBody interface = def_body(CT_Global_Body);
for ( Code entry = parsed_interface.begin(); entry != parsed_interface.end(); ++ entry ) switch( entry->Type )
{
case CT_Preprocess_If:
case CT_Preprocess_IfDef:
{
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_interface, interface );
@ -1217,11 +1218,18 @@ R"(#define <interface_name>( code ) _Generic( (code), \
CodeBody inlines = def_body(CT_Global_Body);
for ( Code entry = parsed_inlines.begin(); entry != parsed_inlines.end(); ++ entry ) switch( entry->Type )
{
case CT_Preprocess_If:
case CT_Preprocess_IfDef:
{
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_inlines, inlines );
if (found) break;
found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP"), entry, parsed_interface, interface);
if (found) break;
found = ignore_preprocess_cond_block(txt("0"), entry, parsed_interface, interface);
if (found) break;
inlines.append(entry);
}
break;

View File

@ -28,10 +28,9 @@ b32 ignore_preprocess_cond_block( Str cond_sig, Code& entry_iter, CodeBody& pars
//log_fmt("Preprocess cond found: %S\n", cond->Content);
found = true;
s32 depth = 1;
++ entry_iter;
for(b32 continue_for = true; continue_for && entry_iter != parsed_body.end(); ) switch
(entry_iter->Type) {
s32 depth = 0;
for(b32 continue_for = true; continue_for && entry_iter != parsed_body.end(); ) switch (entry_iter->Type)
{
case CT_Preprocess_If:
case CT_Preprocess_IfDef:
case CT_Preprocess_IfNotDef:
@ -41,20 +40,18 @@ b32 ignore_preprocess_cond_block( Str cond_sig, Code& entry_iter, CodeBody& pars
case CT_Preprocess_Else:
++ entry_iter;
for(; continue_for && entry_iter != parsed_body.end(); ++ entry_iter)
if (depth == 1) for(; entry_iter != parsed_body.end(); ++ entry_iter)
{
if (entry_iter->Type == CT_Preprocess_EndIf)
{
continue_for = false;
if ( entry_iter->Type == CT_Preprocess_EndIf)
break;
}
body.append(entry_iter);
}
break;
case CT_Preprocess_EndIf:
{
depth --;
-- depth;
if (depth == 0) {
continue_for = false;
break;