LibWeb: Fix .length of functions generated from IDL

Function::length() is computing the right function length based on its
parameters, but we never called it - instead the *function name length*
was being used, which is obviously wrong. How silly! :^)
This commit is contained in:
Linus Groh 2021-02-17 22:21:39 +01:00 committed by Andreas Kling
parent b07799060f
commit ff324fe989

View file

@ -125,8 +125,6 @@ struct Function {
size_t length() const
{
// FIXME: This seems to produce a length that is way over what it's supposed to be.
// For example, getElementsByTagName has its length set to 20 when it should be 1.
size_t length = 0;
for (auto& parameter : parameters) {
if (!parameter.optional)
@ -990,10 +988,10 @@ void @prototype_class@::initialize(JS::GlobalObject& global_object)
auto function_generator = generator.fork();
function_generator.set("function.name", function.name);
function_generator.set("function.name:snakecase", snake_name(function.name));
function_generator.set("function.name:length", String::number(function.name.length()));
function_generator.set("function.length", String::number(function.length()));
function_generator.append(R"~~~(
define_native_function("@function.name@", @function.name:snakecase@, @function.name:length@, default_attributes);
define_native_function("@function.name@", @function.name:snakecase@, @function.length@, default_attributes);
)~~~");
}