| Index: Source/WebCore/bindings/dart/gyp/scripts/CodeGeneratorDart.pm
|
| diff --git a/Source/WebCore/bindings/dart/gyp/scripts/CodeGeneratorDart.pm b/Source/WebCore/bindings/dart/gyp/scripts/CodeGeneratorDart.pm
|
| index 5fc1fcbf692ff9d3dd611ca96be208cf7d783355..8c651565cd17ebb02f0d3a2fd9f2f4a5d08b0640 100644
|
| --- a/Source/WebCore/bindings/dart/gyp/scripts/CodeGeneratorDart.pm
|
| +++ b/Source/WebCore/bindings/dart/gyp/scripts/CodeGeneratorDart.pm
|
| @@ -102,14 +102,14 @@ sub GenerateModule
|
| }
|
|
|
| my %overrideConstructorParameters = (
|
| - "Float32Array" => 3,
|
| - "Float64Array" => 3,
|
| - "Int8Array" => 3,
|
| - "Int16Array" => 3,
|
| - "Int32Array" => 3,
|
| - "Uint8Array" => 3,
|
| - "Uint16Array" => 3,
|
| - "Uint32Array" => 3,
|
| + "Float32Array" => 1,
|
| + "Float64Array" => 1,
|
| + "Int8Array" => 1,
|
| + "Int16Array" => 1,
|
| + "Int32Array" => 1,
|
| + "Uint8Array" => 1,
|
| + "Uint16Array" => 1,
|
| + "Uint32Array" => 1,
|
| );
|
|
|
| sub ConstructorParameterCount
|
| @@ -145,13 +145,9 @@ sub GenerateInterface
|
| # Open files for writing
|
| my $headerFileName = "$outputHeadersDir/Dart${name}.h";
|
| my $implFileName = "$outputDir/Dart${name}.cpp";
|
| - my $dartInterfaceFileName = "$outputHeadersDir/${name}.dart";
|
| - my $dartImplFileName = "$outputHeadersDir/${name}Implementation.dart";
|
|
|
| open($IMPL, ">$implFileName") || die "Couldn't open file $implFileName";
|
| open($HEADER, ">$headerFileName") || die "Couldn't open file $headerFileName";
|
| - open($DART_INTERFACE, ">$dartInterfaceFileName") || die "Couldn't open file $dartInterfaceFileName";
|
| - open($DART_IMPL, ">$dartImplFileName") || die "Couldn't open file $dartImplFileName";
|
|
|
| $object->WriteData($dataNode);
|
| }
|
| @@ -216,11 +212,6 @@ sub HasOptionalParameters
|
| {
|
| my ($function) = @_;
|
|
|
| - # FIXME: useCapture was marked as optional upstream, however native
|
| - # implementation still requires all three parameters. JavaScript bindings
|
| - # have custom generation for addEventListener and removeEventListener.
|
| - return 0 if $function->signature->name eq "addEventListener" || $function->signature->name eq "removeEventListener";
|
| -
|
| foreach my $parameter (@{$function->parameters}) {
|
| return 1 if IsParameterOptionalInWebKit($parameter);
|
| }
|
| @@ -449,6 +440,13 @@ my %nonWrapperTypes = (
|
| "WebKitFlags" => 1,
|
| );
|
|
|
| +sub DartInterfaceName
|
| +{
|
| + my ($interfaceName,) = @_;
|
| + return "DOMException" if $interfaceName eq "DOMCoreException";
|
| + return $interfaceName;
|
| +}
|
| +
|
| sub IsIDLTypeWithDartBindings
|
| {
|
| my ($idlType,) = @_;
|
| @@ -749,6 +747,12 @@ END
|
| }
|
| @invocationParameters = (@invocationParameters, map { $_->name; } @{$parameters});
|
|
|
| + if ($functionName eq "addEventListener" or $functionName eq "removeEventListener") {
|
| + # addEventListener's and removeEventListener's last argument is marked
|
| + # as optional in idl, but is not optional in c++ implementation.
|
| + push(@invocationParameters, "false") if (@invocationParameters == 2);
|
| + }
|
| +
|
| if ($attributes->{CustomArgumentHandling}) {
|
| $implIncludes{"ScriptArguments.h"} = 1;
|
| $implIncludes{"ScriptCallStack.h"} = 1;
|
| @@ -965,10 +969,11 @@ sub GenerateDartImplementationClassname
|
| my ($interfaceName,) = @_;
|
|
|
| my $className = ClassName($interfaceName);
|
| + my $dartInterfaceName = DartInterfaceName($interfaceName);
|
|
|
| push(@implContent, <<END);
|
|
|
| -const char* const ${className}::dartImplementationClassName = "${interfaceName}Implementation";
|
| +const char* const ${className}::dartImplementationClassName = "${dartInterfaceName}Implementation";
|
| END
|
| }
|
|
|
| @@ -1246,9 +1251,11 @@ sub DartAnonymousNamedOptionalParameters
|
| sub CreateFunctionNativeDescriptor
|
| {
|
| my ($interfaceName, $functionName, $argumentCount) = @_;
|
| +
|
| + my $dartInterfaceName = DartInterfaceName($interfaceName);
|
| my $descriptor = NativeBindingDescriptor->new(
|
| cppCallbackName => "${functionName}Callback",
|
| - nativeId => "${interfaceName}_${functionName}_Callback",
|
| + nativeId => "${dartInterfaceName}_${functionName}_Callback",
|
| argumentCount => $argumentCount);
|
| push(@dartNatives, $descriptor);
|
| return $descriptor;
|
| @@ -1257,9 +1264,10 @@ sub CreateFunctionNativeDescriptor
|
| sub CreateGetterNativeDescriptor
|
| {
|
| my ($interfaceName, $attributeName) = @_;
|
| + my $dartInterfaceName = DartInterfaceName($interfaceName);
|
| my $descriptor = NativeBindingDescriptor->new(
|
| cppCallbackName => "${attributeName}Getter",
|
| - nativeId => "${interfaceName}_${attributeName}_Getter",
|
| + nativeId => "${dartInterfaceName}_${attributeName}_Getter",
|
| argumentCount => 1);
|
| push(@dartNatives, $descriptor);
|
| return $descriptor;
|
| @@ -1268,9 +1276,10 @@ sub CreateGetterNativeDescriptor
|
| sub CreateSetterNativeDescriptor
|
| {
|
| my ($interfaceName, $attributeName) = @_;
|
| + my $dartInterfaceName = DartInterfaceName($interfaceName);
|
| my $descriptor = NativeBindingDescriptor->new(
|
| cppCallbackName => "${attributeName}Setter",
|
| - nativeId => "${interfaceName}_${attributeName}_Setter",
|
| + nativeId => "${dartInterfaceName}_${attributeName}_Setter",
|
| argumentCount => 2);
|
| push(@dartNatives, $descriptor);
|
| return $descriptor;
|
| @@ -1566,7 +1575,7 @@ END
|
| END
|
| }
|
| if (HasCustomConstructor($dataNode)) {
|
| - my $descriptor = CreateFunctionNativeDescriptor($interfaceName, "constructor", 1 + $parameterCount);
|
| + my $descriptor = CreateFunctionNativeDescriptor($interfaceName, "constructor", $parameterCount);
|
| my $nativeId = $descriptor->nativeId;
|
| push(@dartImplContent, " void _bind($arguments) native \"$nativeId\";\n");
|
| } else {
|
| @@ -1686,11 +1695,22 @@ sub GenerateNativeBinding
|
| my ($interfaceName, $function, $parameters) = @_;
|
|
|
| my $functionName = DartName($interfaceName, $function->signature->name);
|
| - if (HasOverloads($function)) {
|
| - $functionName .= $function->{overloadIndex};
|
| + my $index = 0;
|
| + foreach my $overload (@{$function->{overloads}}) {
|
| + $index += 1;
|
| + last if $overload == $function;
|
| + foreach my $parameter (@{$overload->parameters}) {
|
| + $index += 1 if IsParameterOptionalInWebKit($parameter);
|
| + }
|
| + }
|
| + my $mandatoryParameterCount = 0;
|
| + foreach my $parameter (@{$function->parameters}) {
|
| + last if IsParameterOptionalInWebKit($parameter);
|
| + $mandatoryParameterCount += 1;
|
| }
|
| - if (HasOptionalParameters($function)) {
|
| - $functionName .= "_" . @$parameters;
|
| + $index += @{$parameters} - $mandatoryParameterCount;
|
| + if ($index != 1) {
|
| + $functionName .= "_" . $index;
|
| }
|
|
|
| my $extendedAttributes = $function->signature->extendedAttributes;
|
| @@ -1748,22 +1768,4 @@ sub WriteData
|
|
|
| @headerContent = ();
|
| }
|
| -
|
| - if (defined($DART_INTERFACE)) {
|
| - # Write content of Dart file.
|
| - print $DART_INTERFACE @dartInterfaceContent;
|
| - close($DART_INTERFACE);
|
| - undef($DART_INTERFACE);
|
| -
|
| - @dartInterfaceContent = ();
|
| - }
|
| -
|
| - if (defined($DART_IMPL)) {
|
| - # Write content of Dart file.
|
| - print $DART_IMPL @dartImplContent;
|
| - close($DART_IMPL);
|
| - undef($DART_IMPL);
|
| -
|
| - @dartImplContent = ();
|
| - }
|
| }
|
|
|