From 6689235691df150c5afda7e681852c72547c268c Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 16 Dec 2024 17:18:52 -0500 Subject: [PATCH] minor updates for better unused code cleanup in the c_library --- base/components/gen/especifier.hpp | 18 +++++++++--------- base/components/interface.hpp | 2 -- base/components/parser.cpp | 12 +++++------- gen_c_library/c_library.cpp | 8 ++++++++ gen_c_library/components/misc.hpp | 17 +++++++---------- scripts/build.ci.ps1 | 2 +- 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/base/components/gen/especifier.hpp b/base/components/gen/especifier.hpp index 32e08b8..78e02a3 100644 --- a/base/components/gen/especifier.hpp +++ b/base/components/gen/especifier.hpp @@ -72,16 +72,16 @@ inline Str spec_to_str( Specifier type ) inline bool spec_is_trailing( Specifier specifier ) { - switch (specifier) { - case Spec_Const: - case Spec_Final: - case Spec_NoExceptions: - case Spec_Override: - case Spec_Pure: - case Spec_Volatile: + switch ( specifier ) + { + case Spec_Const : + case Spec_Final : + case Spec_NoExceptions : + case Spec_Override : + case Spec_Pure : + case Spec_Volatile : return true; - - default: + default : return false; } } diff --git a/base/components/interface.hpp b/base/components/interface.hpp index 90e7fbe..f945a56 100644 --- a/base/components/interface.hpp +++ b/base/components/interface.hpp @@ -327,8 +327,6 @@ forceinline CodeBody def_union_body ( s32 num, Code* codes ) #pragma region Parsing -// TODO(Ed) : Implmeent the new parser API design. - #if 0 struct StackNode { diff --git a/base/components/parser.cpp b/base/components/parser.cpp index 202c30d..e98475f 100644 --- a/base/components/parser.cpp +++ b/base/components/parser.cpp @@ -3684,9 +3684,6 @@ CodeEnum parser_parse_enum( bool inplace_def ) Code array_expr = { nullptr }; CodeTypename type = { nullptr }; - char entries_code[ kilobytes(128) ] = { 0 }; - s32 entries_length = 0; - bool is_enum_class = false; eat( Tok_Decl_Enum ); @@ -4684,11 +4681,12 @@ else if ( currtok.Type == Tok_DeclType ) } } } - // TODO(Ed): This needs updating else if ( currtok.Type == Tok_Preprocess_Macro_Typename ) { // Typename is a macro - name = currtok; - eat(Tok_Preprocess_Macro_Typename); + // name = currtok; + // eat(Tok_Preprocess_Macro_Typename); + Code macro = parse_simple_preprocess(Tok_Preprocess_Macro_Typename); + name.Text = macro->Content; } // The usual Identifier type signature that may have namespace qualifiers @@ -4734,7 +4732,7 @@ else if ( currtok.Type == Tok_DeclType ) // For function type signatures CodeTypename return_type = NullCode; - CodeParams params = NullCode; + CodeParams params = NullCode; #ifdef GEN_USE_NEW_TYPENAME_PARSING CodeParams params_nested = NullCode; diff --git a/gen_c_library/c_library.cpp b/gen_c_library/c_library.cpp index 679c680..c222d1a 100644 --- a/gen_c_library/c_library.cpp +++ b/gen_c_library/c_library.cpp @@ -1129,6 +1129,7 @@ R"(#define ( 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 ( 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; diff --git a/gen_c_library/components/misc.hpp b/gen_c_library/components/misc.hpp index b288663..0976652 100644 --- a/gen_c_library/components/misc.hpp +++ b/gen_c_library/components/misc.hpp @@ -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; diff --git a/scripts/build.ci.ps1 b/scripts/build.ci.ps1 index 3e5e4b7..8234477 100644 --- a/scripts/build.ci.ps1 +++ b/scripts/build.ci.ps1 @@ -326,7 +326,7 @@ if ( $unreal ) } # C Library testing -if ( $test -and $false ) +if ( $test -and $true ) { $path_test_c = join-path $path_test c_library $path_build = join-path $path_test_c build