From 10c5b9c07b7ab6402b503f6d422a31c47bd18fd0 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Thu, 2 Jan 2025 12:38:54 +0000 Subject: [PATCH] IDLGenerators: Allow methods with multiple `sequence` arguments Previously, a method with multiple sequence arguments would cause a compile error, as the same variable name was redeclared when iterating the sequence for each argument. This change disambiguates these variable names. --- .../LibWeb/BindingsGenerator/IDLGenerators.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 03e027ef7236..ae2efb45d047 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -1030,12 +1030,12 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter if (!@js_name@@js_suffix@.is_object()) return vm.throw_completion(JS::ErrorType::NotAnObject, @js_name@@js_suffix@.to_string_without_side_effects()); - auto iterator_method@recursion_depth@ = TRY(@js_name@@js_suffix@.get_method(vm, vm.well_known_symbol_iterator())); - if (!iterator_method@recursion_depth@) + auto @js_name@@js_suffix@_iterator_method@recursion_depth@ = TRY(@js_name@@js_suffix@.get_method(vm, vm.well_known_symbol_iterator())); + if (!@js_name@@js_suffix@_iterator_method@recursion_depth@) return vm.throw_completion(JS::ErrorType::NotIterable, @js_name@@js_suffix@.to_string_without_side_effects()); )~~~"); - parameterized_type.generate_sequence_from_iterable(sequence_generator, ByteString::formatted("{}{}", acceptable_cpp_name, optional ? "_non_optional" : ""), ByteString::formatted("{}{}", js_name, js_suffix), ByteString::formatted("iterator_method{}", recursion_depth), interface, recursion_depth + 1); + parameterized_type.generate_sequence_from_iterable(sequence_generator, ByteString::formatted("{}{}", acceptable_cpp_name, optional ? "_non_optional" : ""), ByteString::formatted("{}{}", js_name, js_suffix), ByteString::formatted("{}{}_iterator_method{}", js_name, js_suffix, recursion_depth), interface, recursion_depth + 1); if (optional) { sequence_generator.append(R"~~~( @@ -1699,7 +1699,7 @@ void IDL::ParameterizedType::generate_sequence_from_iterable(SourceGenerator& ge // FIXME: The WebIDL spec is out of date - it should be using GetIteratorFromMethod. sequence_generator.append(R"~~~( - auto iterator@recursion_depth@ = TRY(JS::get_iterator_from_method(vm, @iterable_cpp_name@, *@iterator_method_cpp_name@)); + auto @iterable_cpp_name@_iterator@recursion_depth@ = TRY(JS::get_iterator_from_method(vm, @iterable_cpp_name@, *@iterator_method_cpp_name@)); )~~~"); if (sequence_cpp_type.sequence_storage_type == SequenceStorageType::Vector) { @@ -1714,7 +1714,7 @@ void IDL::ParameterizedType::generate_sequence_from_iterable(SourceGenerator& ge sequence_generator.append(R"~~~( for (;;) { - auto next@recursion_depth@ = TRY(JS::iterator_step(vm, iterator@recursion_depth@)); + auto next@recursion_depth@ = TRY(JS::iterator_step(vm, @iterable_cpp_name@_iterator@recursion_depth@)); if (!next@recursion_depth@) break;