From 69c6b6df91282a7c53f45abe337104f4d0a49db7 Mon Sep 17 00:00:00 2001 From: stelar7 Date: Thu, 31 Jul 2025 11:41:16 +0200 Subject: [PATCH] Meta/IDL: Correctly generate variable names when value contains a dot --- .../LibWeb/BindingsGenerator/IDLGenerators.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 58f102c4c49..ed52e11d5d2 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -1845,6 +1845,7 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const { auto scoped_generator = generator.fork(); scoped_generator.set("value", value); + scoped_generator.set("value_cpp_name", value.replace("."sv, "_"sv)); if (!libweb_interface_namespaces.span().contains_slow(type.name())) { if (is_javascript_builtin(type)) scoped_generator.set("type", ByteString::formatted("JS::{}", type.name())); @@ -1916,9 +1917,9 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const if (type.is_nullable() || is_optional) { scoped_generator.append(R"~~~( - auto& @value@_non_optional = @value@.value(); - for (size_t i@recursion_depth@ = 0; i@recursion_depth@ < @value@_non_optional.size(); ++i@recursion_depth@) { - auto& element@recursion_depth@ = @value@_non_optional.at(i@recursion_depth@); + auto& @value_cpp_name@_non_optional = @value@.value(); + for (size_t i@recursion_depth@ = 0; i@recursion_depth@ < @value_cpp_name@_non_optional.size(); ++i@recursion_depth@) { + auto& element@recursion_depth@ = @value_cpp_name@_non_optional.at(i@recursion_depth@); )~~~"); } else { scoped_generator.append(R"~~~(