| Index: Source/bindings/scripts/CodeGeneratorV8.pm
|
| diff --git a/Source/bindings/scripts/CodeGeneratorV8.pm b/Source/bindings/scripts/CodeGeneratorV8.pm
|
| index dbb1c56a26978f9f8378e0c343b7f91931113a41..d444f6621c34d2820676cfb6dd9574abe87a9574 100644
|
| --- a/Source/bindings/scripts/CodeGeneratorV8.pm
|
| +++ b/Source/bindings/scripts/CodeGeneratorV8.pm
|
| @@ -2139,6 +2139,30 @@ END
|
| push(@implContentInternals, "\n");
|
| }
|
|
|
| +# The Web IDL specification states that Interface objects for interfaces MUST have a property named
|
| +# "length" that returns the length of the shortest argument list of the entries in the effective
|
| +# overload set for constructors. In other words, use the lowest number of mandatory arguments among
|
| +# all constructors.
|
| +sub GetInterfaceLength
|
| +{
|
| + my $interface = shift;
|
| +
|
| + my $leastNumMandatoryParams = 0;
|
| + if ($codeGenerator->IsConstructorTemplate($interface, "Event") || $codeGenerator->IsConstructorTemplate($interface, "TypedArray")) {
|
| + $leastNumMandatoryParams = 1;
|
| + } elsif ($interface->extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"CustomConstructor"}) {
|
| + my @constructors = @{$interface->constructors};
|
| + my @customConstructors = @{$interface->customConstructors};
|
| + $leastNumMandatoryParams = 255;
|
| + foreach my $constructor (@constructors, @customConstructors) {
|
| + my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersCheck($constructor);
|
| + $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams);
|
| + }
|
| + }
|
| +
|
| + return $leastNumMandatoryParams;
|
| +}
|
| +
|
| sub GenerateConstructorCallback
|
| {
|
| my $interface = shift;
|
| @@ -3048,10 +3072,12 @@ END
|
| if ($function->signature->extendedAttributes->{"PerWorldBindings"}) {
|
| $methodForMainWorld = "${interfaceName}V8Internal::${name}MethodCallbackForMainWorld";
|
| }
|
| + # numMandatoryParams is used to set the "length" property of the Function object.
|
| + my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersCheck($function);
|
| my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature);
|
| push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
|
| push(@implContent, <<END);
|
| - {"$name", ${interfaceName}V8Internal::${name}MethodCallback, ${methodForMainWorld}},
|
| + {"$name", ${interfaceName}V8Internal::${name}MethodCallback, ${methodForMainWorld}, ${numMandatoryParams}},
|
| END
|
| push(@implContent, "#endif\n") if $conditionalString;
|
| $num_callbacks++;
|
| @@ -3186,6 +3212,8 @@ END
|
|
|
| if (IsConstructable($interface)) {
|
| push(@implContent, " desc->SetCallHandler(${v8InterfaceName}::constructorCallback);\n");
|
| + my $interfaceLength = GetInterfaceLength($interface);
|
| + push(@implContent, " desc->SetLength(${interfaceLength});\n");
|
| }
|
|
|
| if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has_constants) {
|
|
|