mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:17:46 +00:00
WrapperGenerator: Clarify function-length getter name
These all return the shortest length of the function, so let's name them as such.
This commit is contained in:
parent
4424a50bc4
commit
634a52b589
2 changed files with 8 additions and 8 deletions
|
@ -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<JS::Object*> @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<JS::Object*> @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);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
namespace IDL {
|
||||
|
||||
template<typename FunctionType>
|
||||
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<Parameter> 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<Function&> 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue