From 6e33b00d5fd66ccf6bcf31f5c594704c3d0003df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Thu, 18 Jul 2024 14:21:23 +0200 Subject: [PATCH] gumjs: Generate simpler enum value lookup code Some C compilers limit how many `else if` branches they support. One such compiler is MSVC for arm64. We should implement a better lookup scheme at some point though. --- bindings/gumjs/generate-bindings.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bindings/gumjs/generate-bindings.py b/bindings/gumjs/generate-bindings.py index a9ece105b..c206e5571 100644 --- a/bindings/gumjs/generate-bindings.py +++ b/bindings/gumjs/generate-bindings.py @@ -2349,8 +2349,11 @@ def generate_enum_parser(name, type, prefix, values): statements = [] for i, value in enumerate(values): statements.extend([ - "{0}if (strcmp (name, \"{1}\") == 0)".format(" else " if i > 0 else "", value), - " *value = {0}{1};".format(prefix, value.upper().replace("-", "_")), + f" if (strcmp (name, \"{value}\") == 0)", + " {", + " *value = {}{};".format(prefix, value.upper().replace("-", "_")), + " return TRUE;", + " }", ]) code = """\ @@ -2359,10 +2362,9 @@ def generate_enum_parser(name, type, prefix, values): const gchar * name, {type} * value) {{ - {statements} - else - return FALSE; - return TRUE; +{statements} + + return FALSE; }} """.format( name=name,