From dbfa8d784eed0949f3dd50c19a58873b5deb32c6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 23 Feb 2025 23:38:15 +0100 Subject: scanner: use separate guards for validator functions Generated XXX_is_valid() functions for enums are guarded behind the same #define as the enum itself. This worked fine until recently, but since fbd7460737c9 ("scanner: add new enum-header mode") we're also generating enum-only headers. When including the enum-only header first, and then the server header, the validator functions are missing. Define a separate guard to fix this. Signed-off-by: Simon Ser --- src/scanner.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/scanner.c b/src/scanner.c index 3cd05d1..1b71e60 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -1383,6 +1383,11 @@ emit_validator(struct interface *interface, struct enumeration *e) { struct entry *entry; + printf("#ifndef %s_%s_ENUM_IS_VALID\n", + interface->uppercase_name, e->uppercase_name); + printf("#define %s_%s_ENUM_IS_VALID\n", + interface->uppercase_name, e->uppercase_name); + printf("/**\n" " * @ingroup iface_%s\n" " * Validate a %s %s value.\n" @@ -1420,6 +1425,9 @@ emit_validator(struct interface *interface, struct enumeration *e) " }\n"); } printf("}\n"); + + printf("#endif /* %s_%s_ENUM_IS_VALID */\n\n", + interface->uppercase_name, e->uppercase_name); } static void @@ -1483,11 +1491,11 @@ emit_enumerations(struct interface *interface, bool with_validators) } - if (with_validators) - emit_validator(interface, e); - printf("#endif /* %s_%s_ENUM */\n\n", interface->uppercase_name, e->uppercase_name); + + if (with_validators) + emit_validator(interface, e); } } -- cgit v1.2.3-70-g09d2