From 35845f037fab2323ebb54ff41e2de6db800f869a Mon Sep 17 00:00:00 2001 From: ehughsbaird <44244083+ehughsbaird@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:45:46 +0000 Subject: [PATCH] Clean up character script a bit Move preprocessor defines to a function, use multiline strings. --- build-scripts/get_translation_characters.py | 52 +++++++++++---------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/build-scripts/get_translation_characters.py b/build-scripts/get_translation_characters.py index e5d3db93598a9..a67c4560c058c 100755 --- a/build-scripts/get_translation_characters.py +++ b/build-scripts/get_translation_characters.py @@ -9,34 +9,36 @@ from cldr_language_helpers import alphabets +def add_preprocessor(): + print("#if defined(__GNUC__) or defined(__clang__)\n" + "#define NOINLINE __attribute__ ((noinline))\n" + "#else\n" + "#define NOINLINE __declspec(noinline)\n" + "#endif\n" + "#if defined(__clang__)\n" + "#define NOUNROLL _Pragma(\"clang loop unroll(disable)\")\n" + "#elif defined(__GNUC__)\n" + "#define NOUNROLL #pragma GCC unroll 0\n" + "#else\n" + "#define NOUNROLL\n" + "#endif\n") + + def main(): - print("// generated by get_translation_characters.py; example:") - print("// ./build-scripts/get_translation_characters.py en ar cs da de " + print("// generated by get_translation_characters.py; example:\n" + "// ./build-scripts/get_translation_characters.py en ar cs da de " "el es fr hu id is it ja ko nb nl pl pt ru sr tr uk_UA zh_Hans " - "zh_Hant > src/cldr/imgui-glyph-ranges.cpp\n") - print("// NOLINTBEGIN(cata-static-declarations,readability-function-size)") - print("") - print("#if defined(__GNUC__) or defined(__clang__)") - print("#define NOINLINE __attribute__ ((noinline))") - print("#else") - print("#define NOINLINE __declspec(noinline)") - print("#endif") - print("#if defined(__clang__)") - print("#define NOUNROLL _Pragma(\"clang loop unroll(disable)\")") - print("#elif defined(__GNUC__)") - print("#define NOUNROLL #pragma GCC unroll 0") - print("#else") - print("#define NOUNROLL") - print("#endif") - print("") + "zh_Hant > src/cldr/imgui-glyph-ranges.cpp\n\n" + "// NOLINTBEGIN(cata-static-declarations,readability-function-size)" + "\n") + add_preprocessor() print("static NOINLINE void AddGlyphs( ImFontGlyphRangesBuilder *b, " - "ImWchar const *glyphp, ImWchar const *end) {") - print(" NOUNROLL") - print(" for( ; glyphp != end; ++glyphp ) {") - print(" b->AddChar(*glyphp);") - print(" }") - print("}") - print("") + "ImWchar const *glyphp, ImWchar const *end) {\n" + " NOUNROLL\n" + " for( ; glyphp != end; ++glyphp ) {\n" + " b->AddChar(*glyphp);\n" + " }\n" + "}\n") try: for language in sys.argv[1:]: print_func(language)