From a125653448f96dc8f3eb34c9ea7d05d673688e55 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Fri, 13 Dec 2024 16:34:47 -0500 Subject: [PATCH] attempted to fix formatting for _Generic macros in the c11 generation (failed) --- gen_c_library/Readme.md | 2 +- gen_c_library/components/misc.hpp | 33 ++++++++----------------------- scripts/.clang-format | 2 ++ 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/gen_c_library/Readme.md b/gen_c_library/Readme.md index d6517ca..992f0f3 100644 --- a/gen_c_library/Readme.md +++ b/gen_c_library/Readme.md @@ -18,6 +18,6 @@ If using the library's provided build scripts: .\build.ps1 c_library ``` -All free from tag identifiers will be prefixed with `gen_` or `GEN_` as the namespace. This can either be changed after generation with a `.refactor` script (or your preferred subst method), OR by modifying c_library.refactor. +All free from tag identifiers will be prefixed with `gen_` or `GEN_` as the namespace. This can either be changed after generation with a `.refactor` script (or your preferred subst method), OR by modifying [c_library.refactor](./c_library.refactor). **If c_library.refactor is modified you may need to modify c_library.cpp and its [components](./components/). As some of the container generation relies on that prefix.** diff --git a/gen_c_library/components/misc.hpp b/gen_c_library/components/misc.hpp index 0d66d4b..5693490 100644 --- a/gen_c_library/components/misc.hpp +++ b/gen_c_library/components/misc.hpp @@ -105,48 +105,31 @@ R"(#define (selector_arg, ...) _Generic( (selector_arg), \ for ( s32 slot = 1; slot <= num_slots; ++ slot ) { Str slot_str = StrBuilder::fmt_buf(GlobalAllocator, "%d", slot).to_str(); - if (slot == num_slots && false) - { - define_builder.append( token_fmt( "macro_name", macro_name, "slot", slot_str, -R"( GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT_LAST( GENERIC_SLOT___ ) \ -)" - )); - // if ( one_arg ) - // define_builder.append(token_fmt( "macro_name", macro_name, stringize( - // default: static_assert(false, ": Failed to select correct function signature (Did you pass the type?)") - // ))); - // else - // define_builder.append(token_fmt( "macro_name", macro_name, stringize( - // default: static_assert(false, ": Failed to select correct function signature") - // ))); - continue; - } - define_builder.append( token_fmt( "macro_name", macro_name, "slot", slot_str, -R"( GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GENERIC_SLOT___ ) \ +R"(GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GENERIC_SLOT___ ) \ )" )); } - define_builder.append( txt("default: gen_generic_selection_fail") ); + define_builder.append( txt("default: gen_generic_selection_fail\\\n") ); if ( ! one_arg ) { if (opts == GenericSel_By_Ref) - define_builder.append(txt("\t)\tGEN_RESOLVED_FUNCTION_CALL( & selector_arg, __VA_ARGS__ )")); + define_builder.append(txt(")\\\nGEN_RESOLVED_FUNCTION_CALL( & selector_arg, __VA_ARGS__ )")); else if (opts == GenericSel_Direct_Type) - define_builder.append(txt("\t)\tGEN_RESOLVED_FUNCTION_CALL( __VA_ARGS__ )")); + define_builder.append(txt(")\\\nGEN_RESOLVED_FUNCTION_CALL( __VA_ARGS__ )")); else - define_builder.append(txt("\t)\tGEN_RESOLVED_FUNCTION_CALL( selector_arg, __VA_ARGS__ )")); + define_builder.append(txt(")\\\nGEN_RESOLVED_FUNCTION_CALL( selector_arg, __VA_ARGS__ )")); } else { if (opts == GenericSel_By_Ref) - define_builder.append(txt("\t)\tGEN_RESOLVED_FUNCTION_CALL( & selector_arg )")); + define_builder.append(txt(")\\\nGEN_RESOLVED_FUNCTION_CALL( & selector_arg )")); else if (opts == GenericSel_Direct_Type) - define_builder.append(txt("\t)\tGEN_RESOLVED_FUNCTION_CALL()")); + define_builder.append(txt(")\\\nGEN_RESOLVED_FUNCTION_CALL()")); else - define_builder.append(txt("\t)\tGEN_RESOLVED_FUNCTION_CALL( selector_arg )")); + define_builder.append(txt(")\\\nGEN_RESOLVED_FUNCTION_CALL( selector_arg )")); } // Add gap for next definition diff --git a/scripts/.clang-format b/scripts/.clang-format index a33ffe6..ed9caa3 100644 --- a/scripts/.clang-format +++ b/scripts/.clang-format @@ -15,6 +15,8 @@ StatementMacros: [ Macros: - enum_underlying(type)=type - gen_enum_underlying(type)=type +# WhitespaceSensitiveMacros: [ +# ] TypenameMacros: [Array, Hashtable] SkipMacroDefinitionBody: false