Chromium Code Reviews| Index: Source/bindings/scripts/CodeGeneratorV8.pm |
| diff --git a/Source/bindings/scripts/CodeGeneratorV8.pm b/Source/bindings/scripts/CodeGeneratorV8.pm |
| index 39924de35f13b9c1a2fb606a286d1c822d392371..94912011a619ba67cf25fa8ea4eb0e1c79553482 100644 |
| --- a/Source/bindings/scripts/CodeGeneratorV8.pm |
| +++ b/Source/bindings/scripts/CodeGeneratorV8.pm |
| @@ -275,6 +275,21 @@ sub GetSVGPropertyTypes |
| return ($svgPropertyType, $svgListPropertyType, $svgNativeType); |
| } |
| +sub GetNamedGetterFunction |
| +{ |
| + my $interface = shift; |
| + |
| + foreach my $function (@{$interface->functions}) { |
| + my $specials = $function->signature->specials; |
| + my $parameters = $function->parameters; |
| + if (scalar(@$specials)==1 and $specials->[0] eq "getter" |
| + and scalar(@$parameters)==1 and $parameters->[0]->type eq "DOMString" ) { |
|
haraken
2013/04/26 11:47:15
Here you should just check whether "getter" is con
kojih
2013/04/26 12:03:24
OK for getter.
regarding assert DOMString, I'll su
|
| + return $function; |
| + } |
| + } |
| + return 0; |
| +} |
| + |
| sub GenerateHeader |
| { |
| my $object = shift; |
| @@ -719,7 +734,7 @@ sub GenerateHeaderNamedAndIndexedPropertyAccessors |
| my $interfaceName = $interface->name; |
| my $hasIndexedGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"CustomIndexedGetter"}; |
| my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexedSetter"}; |
| - my $hasCustomNamedGetter = $interface->extendedAttributes->{"NamedGetter"} || $interface->extendedAttributes->{"CustomNamedGetter"} || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}; |
| + my $hasCustomNamedGetter = GetNamedGetterFunction($interface) || $interface->extendedAttributes->{"CustomNamedGetter"} || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}; |
| my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSetter"}; |
| my $hasCustomDeleters = $interface->extendedAttributes->{"CustomDeleteProperty"}; |
| my $hasCustomEnumerator = $interface->extendedAttributes->{"CustomEnumerateProperty"}; |
| @@ -2916,20 +2931,17 @@ END |
| sub GenerateImplementationNamedPropertyGetter |
| { |
| my $interface = shift; |
| - my $namedPropertyGetter = shift; |
| - my $subCode = ""; |
| + my $subCode = ""; |
| my $interfaceName = $interface->name; |
| my $v8InterfaceName = "V8$interfaceName"; |
| - if (!$namedPropertyGetter) { |
| - $namedPropertyGetter = $codeGenerator->FindSuperMethod($interface, "namedItem"); |
| - } |
| - |
| - if ($interface->extendedAttributes->{"NamedGetter"}) { |
| - die "$interfaceName: [NamedGetter] but no namedItem() method." if (!$namedPropertyGetter); |
| + my $function = GetNamedGetterFunction($interface); |
| + if ($function) { |
| + my $returnType = $function->signature->type; |
| + my $methodName = $function->signature->name; |
| AddToImplIncludes("V8Collection.h"); |
| - my $type = $namedPropertyGetter->type; |
| + AddToImplIncludes("V8$returnType.h"); |
| $subCode .= <<END; |
| desc->InstanceTemplate()->SetNamedPropertyHandler(${v8InterfaceName}::namedPropertyGetter, 0, 0, 0, 0); |
| END |
| @@ -2943,20 +2955,17 @@ v8::Handle<v8::Value> ${v8InterfaceName}::namedPropertyGetter(v8::Local<v8::Stri |
| return v8Undefined(); |
| v8::Local<v8::Object> object = info.Holder(); |
| - v8::Handle<v8::Object> creationContext = info.Holder(); |
| - v8::Isolate* isolate = info.GetIsolate(); |
| - |
| ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); |
| ASSERT(toWrapperTypeInfo(object) != &V8Node::info); |
| $interfaceName* collection = toNative(object); |
| AtomicString propertyName = toWebCoreAtomicStringWithNullCheck(name); |
| - RefPtr<$type> element = collection->namedItem(propertyName); |
| + RefPtr<$returnType> element = collection->$methodName(propertyName); |
| if (!element) |
| return v8Undefined(); |
| - return toV8(element.release(), creationContext, isolate); |
| + return toV8Fast(element.release(), info, collection); |
| } |
| END |
| @@ -3213,7 +3222,6 @@ END |
| } |
| my $indexer; |
| - my $namedPropertyGetter; |
| my @enabledPerContextFunctions; |
| my @normalFunctions; |
| my $needsDomainSafeFunctionSetter = 0; |
| @@ -3238,8 +3246,6 @@ END |
| if ($function->signature->name eq "item") { |
| $indexer = $function->signature; |
| - } elsif ($function->signature->name eq "namedItem") { |
| - $namedPropertyGetter = $function->signature; |
| } |
| # If the function does not need domain security check, we need to |
| @@ -3516,7 +3522,7 @@ END |
| } |
| $code .= GenerateImplementationIndexedProperty($interface, $indexer); |
| - $code .= GenerateImplementationNamedPropertyGetter($interface, $namedPropertyGetter); |
| + $code .= GenerateImplementationNamedPropertyGetter($interface); |
| $code .= GenerateImplementationCustomCall($interface); |
| $code .= GenerateImplementationMasqueradesAsUndefined($interface); |