Chromium Code Reviews| 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 a41c472f02821d2fbdcfcc9dd66cd78f23064c7e..5b906f0c39586f44a68d51706e9080096ac768d6 100644 |
| --- a/Source/WebCore/bindings/dart/gyp/scripts/CodeGeneratorDart.pm |
| +++ b/Source/WebCore/bindings/dart/gyp/scripts/CodeGeneratorDart.pm |
| @@ -109,14 +109,14 @@ sub GenerateModule |
| } |
| my %overrideConstructorParameters = ( |
| - "Float32Array" => 3, |
| - "Float64Array" => 3, |
| - "Int8Array" => 3, |
| - "Int16Array" => 3, |
| - "Int32Array" => 3, |
| - "Uint8Array" => 3, |
| - "Uint16Array" => 3, |
| - "Uint32Array" => 3, |
| + "Float32Array" => 1, |
|
antonm
2012/01/25 18:56:40
hmm?
podivilov
2012/01/25 19:04:05
See client/dom/src/_FactoryProviders.dart
Anton Muhin
2012/01/26 12:13:35
Sorry, may you elaborate? If this knowledge is hi
podivilov
2012/01/30 18:27:54
TypedArray constructors are declared with a single
antonm
2012/01/31 10:48:02
Sorry, I wasn't clear enough.
I believe those exc
|
| + "Float64Array" => 1, |
| + "Int8Array" => 1, |
| + "Int16Array" => 1, |
| + "Int32Array" => 1, |
| + "Uint8Array" => 1, |
| + "Uint16Array" => 1, |
| + "Uint32Array" => 1, |
| ); |
| sub ConstructorParameterCount |
| @@ -152,13 +152,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"; |
| } |
| # If the node has a [Conditional=XXX] attribute, returns an "ENABLE(XXX)" string for use in an #if. |
| @@ -221,11 +217,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); |
| } |
| @@ -454,6 +445,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; |
| @@ -964,10 +968,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 |
| } |
| @@ -1245,9 +1250,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; |
| @@ -1256,9 +1263,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; |
| @@ -1267,9 +1275,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; |
| @@ -1548,7 +1557,7 @@ sub GenerateSource |
| } |
| 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 { |
| @@ -1668,11 +1677,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; |
| @@ -1730,22 +1750,4 @@ sub WriteData |
| @headerContent = (); |
| } |
| - |
| - if (defined($DART_INTERFACE)) { |
|
antonm
2012/01/25 18:56:40
is it the only piece of this file which can R.I.P?
podivilov
2012/01/25 19:04:05
Don't want to add extra noise. Let's delete this s
|
| - # 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 = (); |
| - } |
| } |