From 634a52b589d7f3044151e629a7f9c47a582f6432 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Mon, 22 Aug 2022 14:14:32 +0100 Subject: [PATCH] WrapperGenerator: Clarify function-length getter name These all return the shortest length of the function, so let's name them as such. --- .../LibWeb/WrapperGenerator/IDLGenerators.cpp | 8 ++++---- .../CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp index 1bfeff97c1..410c27c34d 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp @@ -1760,7 +1760,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@@overload_suffi // Optimization: overloaded functions' arguments count is checked by the overload arbiter if (!function.is_overloaded) - generate_argument_count_check(generator, function.name, function.length()); + generate_argument_count_check(generator, function.name, function.shortest_length()); StringBuilder arguments_builder; generate_arguments(generator, function.parameters, arguments_builder, interface); @@ -1841,7 +1841,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@) generate_argument_count_check(function_generator, overload_set.key, minimum_argument_count); auto overloaded_functions = overload_set.value; - quick_sort(overloaded_functions, [](auto const& a, auto const& b) { return a.length() < b.length(); }); + quick_sort(overloaded_functions, [](auto const& a, auto const& b) { return a.shortest_length() < b.shortest_length(); }); auto fetched_arguments = 0u; for (auto i = 0u; i < overloaded_functions.size(); ++i) { auto const& overloaded_function = overloaded_functions[i]; @@ -2064,7 +2064,7 @@ JS::ThrowCompletionOr @constructor_class@::construct(FunctionObject // Single constructor auto& constructor = interface.constructors[0]; - generator.set("constructor.length", String::number(constructor.length())); + generator.set("constructor.length", String::number(constructor.shortest_length())); generator.append(R"~~~( auto& vm = this->vm(); @@ -2074,7 +2074,7 @@ JS::ThrowCompletionOr @constructor_class@::construct(FunctionObject )~~~"); if (!constructor.parameters.is_empty()) { - generate_argument_count_check(generator, constructor.name, constructor.length()); + generate_argument_count_check(generator, constructor.name, constructor.shortest_length()); StringBuilder arguments_builder; generate_arguments(generator, constructor.parameters, arguments_builder, interface); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h index dbb5aa6d6a..7dc9783753 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h @@ -21,7 +21,7 @@ namespace IDL { template -static size_t get_function_length(FunctionType& function) +static size_t get_function_shortest_length(FunctionType& function) { size_t length = 0; for (auto& parameter : function.parameters) { @@ -83,14 +83,14 @@ struct Function { size_t overload_index { 0 }; bool is_overloaded { false }; - size_t length() const { return get_function_length(*this); } + size_t shortest_length() const { return get_function_shortest_length(*this); } }; struct Constructor { String name; Vector parameters; - size_t length() const { return get_function_length(*this); } + size_t shortest_length() const { return get_function_shortest_length(*this); } }; struct Constant { @@ -163,7 +163,7 @@ static inline size_t get_shortest_function_length(Vector const& overl { size_t shortest_length = SIZE_MAX; for (auto const& function : overload_set) - shortest_length = min(function.length(), shortest_length); + shortest_length = min(function.shortest_length(), shortest_length); return shortest_length; }