Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> | 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> |
| 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> | 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> |
| 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> | 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> |
| 5 # Copyright (C) 2006 Apple Computer, Inc. | 5 # Copyright (C) 2006 Apple Computer, Inc. |
| 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. | 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. |
| 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
| 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. | 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 # Copyright (C) 2012 Ericsson AB. All rights reserved. | 10 # Copyright (C) 2012 Ericsson AB. All rights reserved. |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 $headerIncludes{"SVGPathSegListPropertyTearOff.h"} = 1; | 268 $headerIncludes{"SVGPathSegListPropertyTearOff.h"} = 1; |
| 269 } | 269 } |
| 270 | 270 |
| 271 if ($svgPropertyType) { | 271 if ($svgPropertyType) { |
| 272 $svgPropertyType = "SVGPoint" if $svgPropertyType eq "FloatPoint"; | 272 $svgPropertyType = "SVGPoint" if $svgPropertyType eq "FloatPoint"; |
| 273 } | 273 } |
| 274 | 274 |
| 275 return ($svgPropertyType, $svgListPropertyType, $svgNativeType); | 275 return ($svgPropertyType, $svgListPropertyType, $svgNativeType); |
| 276 } | 276 } |
| 277 | 277 |
| 278 sub GetNamedGetterFunction | |
| 279 { | |
| 280 my $interface = shift; | |
| 281 | |
| 282 foreach my $function (@{$interface->functions}) { | |
| 283 my $specials = $function->signature->specials; | |
| 284 my $getterExists = grep { $_ eq "getter" } @$specials; | |
| 285 my $parameters = $function->parameters; | |
| 286 if ($getterExists and scalar(@$parameters)==1 and $parameters->[0]->type eq "DOMString" ) { | |
|
haraken
2013/04/26 12:09:52
Nit: Spaces needed around '=='
| |
| 287 return $function; | |
| 288 } | |
| 289 } | |
| 290 return 0; | |
| 291 } | |
| 292 | |
| 278 sub GenerateHeader | 293 sub GenerateHeader |
| 279 { | 294 { |
| 280 my $object = shift; | 295 my $object = shift; |
| 281 my $interface = shift; | 296 my $interface = shift; |
| 282 | 297 |
| 283 my $interfaceName = $interface->name; | 298 my $interfaceName = $interface->name; |
| 284 my $v8InterfaceName = "V8$interfaceName"; | 299 my $v8InterfaceName = "V8$interfaceName"; |
| 285 | 300 |
| 286 # Copy contents of parent interfaces except the first parent. | 301 # Copy contents of parent interfaces except the first parent. |
| 287 my @parents; | 302 my @parents; |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 712 "HTMLEmbedElement" => 1, | 727 "HTMLEmbedElement" => 1, |
| 713 "HTMLObjectElement" => 1 | 728 "HTMLObjectElement" => 1 |
| 714 ); | 729 ); |
| 715 | 730 |
| 716 sub GenerateHeaderNamedAndIndexedPropertyAccessors | 731 sub GenerateHeaderNamedAndIndexedPropertyAccessors |
| 717 { | 732 { |
| 718 my $interface = shift; | 733 my $interface = shift; |
| 719 my $interfaceName = $interface->name; | 734 my $interfaceName = $interface->name; |
| 720 my $hasIndexedGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"CustomIndexedGetter"}; | 735 my $hasIndexedGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"CustomIndexedGetter"}; |
| 721 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed Setter"}; | 736 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed Setter"}; |
| 722 my $hasCustomNamedGetter = $interface->extendedAttributes->{"NamedGetter"} | | $interface->extendedAttributes->{"CustomNamedGetter"} || $interface->extendedA ttributes->{"CustomGetOwnPropertySlot"}; | 737 my $hasCustomNamedGetter = GetNamedGetterFunction($interface) || $interface- >extendedAttributes->{"CustomNamedGetter"} || $interface->extendedAttributes->{" CustomGetOwnPropertySlot"}; |
| 723 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSett er"}; | 738 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSett er"}; |
| 724 my $hasCustomDeleters = $interface->extendedAttributes->{"CustomDeleteProper ty"}; | 739 my $hasCustomDeleters = $interface->extendedAttributes->{"CustomDeleteProper ty"}; |
| 725 my $hasCustomEnumerator = $interface->extendedAttributes->{"CustomEnumerateP roperty"}; | 740 my $hasCustomEnumerator = $interface->extendedAttributes->{"CustomEnumerateP roperty"}; |
| 726 if ($interfaceName eq "HTMLOptionsCollection") { | 741 if ($interfaceName eq "HTMLOptionsCollection") { |
| 727 $interfaceName = "HTMLCollection"; | 742 $interfaceName = "HTMLCollection"; |
| 728 $hasIndexedGetter = 1; | 743 $hasIndexedGetter = 1; |
| 729 $hasCustomNamedGetter = 1; | 744 $hasCustomNamedGetter = 1; |
| 730 } | 745 } |
| 731 if ($interfaceName eq "DOMWindow") { | 746 if ($interfaceName eq "DOMWindow") { |
| 732 $hasCustomDeleters = 0; | 747 $hasCustomDeleters = 0; |
| (...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2909 return $jsValue; | 2924 return $jsValue; |
| 2910 } | 2925 } |
| 2911 END | 2926 END |
| 2912 } | 2927 } |
| 2913 return $code; | 2928 return $code; |
| 2914 } | 2929 } |
| 2915 | 2930 |
| 2916 sub GenerateImplementationNamedPropertyGetter | 2931 sub GenerateImplementationNamedPropertyGetter |
| 2917 { | 2932 { |
| 2918 my $interface = shift; | 2933 my $interface = shift; |
| 2919 my $namedPropertyGetter = shift; | 2934 |
| 2920 my $subCode = ""; | 2935 my $subCode = ""; |
| 2921 | |
| 2922 my $interfaceName = $interface->name; | 2936 my $interfaceName = $interface->name; |
| 2923 my $v8InterfaceName = "V8$interfaceName"; | 2937 my $v8InterfaceName = "V8$interfaceName"; |
| 2924 | 2938 |
| 2925 if (!$namedPropertyGetter) { | 2939 my $function = GetNamedGetterFunction($interface); |
| 2926 $namedPropertyGetter = $codeGenerator->FindSuperMethod($interface, "name dItem"); | 2940 if ($function) { |
| 2927 } | 2941 my $returnType = $function->signature->type; |
| 2928 | 2942 my $methodName = $function->signature->name; |
| 2929 if ($interface->extendedAttributes->{"NamedGetter"}) { | |
| 2930 die "$interfaceName: [NamedGetter] but no namedItem() method." if (!$nam edPropertyGetter); | |
| 2931 AddToImplIncludes("V8Collection.h"); | 2943 AddToImplIncludes("V8Collection.h"); |
| 2932 my $type = $namedPropertyGetter->type; | 2944 AddToImplIncludes("V8$returnType.h"); |
| 2933 $subCode .= <<END; | 2945 $subCode .= <<END; |
| 2934 desc->InstanceTemplate()->SetNamedPropertyHandler(${v8InterfaceName}::namedP ropertyGetter, 0, 0, 0, 0); | 2946 desc->InstanceTemplate()->SetNamedPropertyHandler(${v8InterfaceName}::namedP ropertyGetter, 0, 0, 0, 0); |
| 2935 END | 2947 END |
| 2936 | 2948 |
| 2937 my $code .= <<END; | 2949 my $code .= <<END; |
| 2938 v8::Handle<v8::Value> ${v8InterfaceName}::namedPropertyGetter(v8::Local<v8::Stri ng> name, const v8::AccessorInfo& info) | 2950 v8::Handle<v8::Value> ${v8InterfaceName}::namedPropertyGetter(v8::Local<v8::Stri ng> name, const v8::AccessorInfo& info) |
| 2939 { | 2951 { |
| 2940 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | 2952 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
| 2941 return v8Undefined(); | 2953 return v8Undefined(); |
| 2942 if (info.Holder()->HasRealNamedCallbackProperty(name)) | 2954 if (info.Holder()->HasRealNamedCallbackProperty(name)) |
| 2943 return v8Undefined(); | 2955 return v8Undefined(); |
| 2944 | 2956 |
| 2945 v8::Local<v8::Object> object = info.Holder(); | 2957 v8::Local<v8::Object> object = info.Holder(); |
| 2946 v8::Handle<v8::Object> creationContext = info.Holder(); | |
| 2947 v8::Isolate* isolate = info.GetIsolate(); | |
| 2948 | |
| 2949 ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); | 2958 ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); |
| 2950 ASSERT(toWrapperTypeInfo(object) != &V8Node::info); | 2959 ASSERT(toWrapperTypeInfo(object) != &V8Node::info); |
| 2951 $interfaceName* collection = toNative(object); | 2960 $interfaceName* collection = toNative(object); |
| 2952 | 2961 |
| 2953 AtomicString propertyName = toWebCoreAtomicStringWithNullCheck(name); | 2962 AtomicString propertyName = toWebCoreAtomicStringWithNullCheck(name); |
| 2954 RefPtr<$type> element = collection->namedItem(propertyName); | 2963 RefPtr<$returnType> element = collection->$methodName(propertyName); |
| 2955 | 2964 |
| 2956 if (!element) | 2965 if (!element) |
| 2957 return v8Undefined(); | 2966 return v8Undefined(); |
| 2958 | 2967 |
| 2959 return toV8(element.release(), creationContext, isolate); | 2968 return toV8Fast(element.release(), info, collection); |
| 2960 } | 2969 } |
| 2961 | 2970 |
| 2962 END | 2971 END |
| 2963 AddToImplContent($code); | 2972 AddToImplContent($code); |
| 2964 } | 2973 } |
| 2965 | 2974 |
| 2966 my $hasCustomNamedGetter = $interface->extendedAttributes->{"CustomNamedGett er"}; | 2975 my $hasCustomNamedGetter = $interface->extendedAttributes->{"CustomNamedGett er"}; |
| 2967 # FIXME: make consistent between IDL and implementation. Then remove these s pecial cases. | 2976 # FIXME: make consistent between IDL and implementation. Then remove these s pecial cases. |
| 2968 $hasCustomNamedGetter = 1 if $interfaceName eq "HTMLAppletElement"; | 2977 $hasCustomNamedGetter = 1 if $interfaceName eq "HTMLAppletElement"; |
| 2969 $hasCustomNamedGetter = 1 if $interfaceName eq "HTMLEmbedElement"; | 2978 $hasCustomNamedGetter = 1 if $interfaceName eq "HTMLEmbedElement"; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3206 v8::Handle<v8::Object> wrapper = ${v8InterfaceName}::createWrapper(impl, cre ationContext, isolate); | 3215 v8::Handle<v8::Object> wrapper = ${v8InterfaceName}::createWrapper(impl, cre ationContext, isolate); |
| 3207 if (!wrapper.IsEmpty()) | 3216 if (!wrapper.IsEmpty()) |
| 3208 wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $v iewType, impl->length()); | 3217 wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $v iewType, impl->length()); |
| 3209 return wrapper; | 3218 return wrapper; |
| 3210 } | 3219 } |
| 3211 | 3220 |
| 3212 END | 3221 END |
| 3213 } | 3222 } |
| 3214 | 3223 |
| 3215 my $indexer; | 3224 my $indexer; |
| 3216 my $namedPropertyGetter; | |
| 3217 my @enabledPerContextFunctions; | 3225 my @enabledPerContextFunctions; |
| 3218 my @normalFunctions; | 3226 my @normalFunctions; |
| 3219 my $needsDomainSafeFunctionSetter = 0; | 3227 my $needsDomainSafeFunctionSetter = 0; |
| 3220 # Generate methods for functions. | 3228 # Generate methods for functions. |
| 3221 foreach my $function (@{$interface->functions}) { | 3229 foreach my $function (@{$interface->functions}) { |
| 3222 GenerateFunction($function, $interface, ""); | 3230 GenerateFunction($function, $interface, ""); |
| 3223 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { | 3231 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { |
| 3224 GenerateFunction($function, $interface, "ForMainWorld"); | 3232 GenerateFunction($function, $interface, "ForMainWorld"); |
| 3225 } | 3233 } |
| 3226 if ($function->{overloadIndex} == @{$function->{overloads}}) { | 3234 if ($function->{overloadIndex} == @{$function->{overloads}}) { |
| 3227 if ($function->{overloadIndex} > 1) { | 3235 if ($function->{overloadIndex} > 1) { |
| 3228 GenerateOverloadedFunction($function, $interface, ""); | 3236 GenerateOverloadedFunction($function, $interface, ""); |
| 3229 if ($function->signature->extendedAttributes->{"PerWorldBindings "}) { | 3237 if ($function->signature->extendedAttributes->{"PerWorldBindings "}) { |
| 3230 GenerateOverloadedFunction($function, $interface, "ForMainWo rld"); | 3238 GenerateOverloadedFunction($function, $interface, "ForMainWo rld"); |
| 3231 } | 3239 } |
| 3232 } | 3240 } |
| 3233 GenerateFunctionCallback($function, $interface, ""); | 3241 GenerateFunctionCallback($function, $interface, ""); |
| 3234 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { | 3242 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { |
| 3235 GenerateFunctionCallback($function, $interface, "ForMainWorld"); | 3243 GenerateFunctionCallback($function, $interface, "ForMainWorld"); |
| 3236 } | 3244 } |
| 3237 } | 3245 } |
| 3238 | 3246 |
| 3239 if ($function->signature->name eq "item") { | 3247 if ($function->signature->name eq "item") { |
| 3240 $indexer = $function->signature; | 3248 $indexer = $function->signature; |
| 3241 } elsif ($function->signature->name eq "namedItem") { | |
| 3242 $namedPropertyGetter = $function->signature; | |
| 3243 } | 3249 } |
| 3244 | 3250 |
| 3245 # If the function does not need domain security check, we need to | 3251 # If the function does not need domain security check, we need to |
| 3246 # generate an access getter that returns different function objects | 3252 # generate an access getter that returns different function objects |
| 3247 # for different calling context. | 3253 # for different calling context. |
| 3248 if ($interface->extendedAttributes->{"CheckSecurity"} && $function->sign ature->extendedAttributes->{"DoNotCheckSecurity"}) { | 3254 if ($interface->extendedAttributes->{"CheckSecurity"} && $function->sign ature->extendedAttributes->{"DoNotCheckSecurity"}) { |
| 3249 if (!HasCustomMethod($function->signature->extendedAttributes) || $f unction->{overloadIndex} == 1) { | 3255 if (!HasCustomMethod($function->signature->extendedAttributes) || $f unction->{overloadIndex} == 1) { |
| 3250 GenerateDomainSafeFunctionGetter($function, $interfaceName); | 3256 GenerateDomainSafeFunctionGetter($function, $interfaceName); |
| 3251 $needsDomainSafeFunctionSetter = 1; | 3257 $needsDomainSafeFunctionSetter = 1; |
| 3252 } | 3258 } |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3509 $code .= " if (${enable_function}()) {\n"; | 3515 $code .= " if (${enable_function}()) {\n"; |
| 3510 $code .= <<END; | 3516 $code .= <<END; |
| 3511 static const V8DOMConfiguration::BatchedConstant constData = {"${name}", static_cast<signed int>(${value})}; | 3517 static const V8DOMConfiguration::BatchedConstant constData = {"${name}", static_cast<signed int>(${value})}; |
| 3512 V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1, isolate); | 3518 V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1, isolate); |
| 3513 END | 3519 END |
| 3514 $code .= " }\n"; | 3520 $code .= " }\n"; |
| 3515 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; | 3521 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; |
| 3516 } | 3522 } |
| 3517 | 3523 |
| 3518 $code .= GenerateImplementationIndexedProperty($interface, $indexer); | 3524 $code .= GenerateImplementationIndexedProperty($interface, $indexer); |
| 3519 $code .= GenerateImplementationNamedPropertyGetter($interface, $namedPropert yGetter); | 3525 $code .= GenerateImplementationNamedPropertyGetter($interface); |
| 3520 $code .= GenerateImplementationCustomCall($interface); | 3526 $code .= GenerateImplementationCustomCall($interface); |
| 3521 $code .= GenerateImplementationMasqueradesAsUndefined($interface); | 3527 $code .= GenerateImplementationMasqueradesAsUndefined($interface); |
| 3522 | 3528 |
| 3523 # Define our functions with Set() or SetAccessor() | 3529 # Define our functions with Set() or SetAccessor() |
| 3524 my $total_functions = 0; | 3530 my $total_functions = 0; |
| 3525 foreach my $function (@normalFunctions) { | 3531 foreach my $function (@normalFunctions) { |
| 3526 # Only one accessor is needed for overloaded methods: | 3532 # Only one accessor is needed for overloaded methods: |
| 3527 next if $function->{overloadIndex} > 1; | 3533 next if $function->{overloadIndex} > 1; |
| 3528 | 3534 |
| 3529 $total_functions++; | 3535 $total_functions++; |
| (...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4882 | 4888 |
| 4883 sub GetPassRefPtrType | 4889 sub GetPassRefPtrType |
| 4884 { | 4890 { |
| 4885 my $v8InterfaceName = shift; | 4891 my $v8InterfaceName = shift; |
| 4886 | 4892 |
| 4887 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; | 4893 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; |
| 4888 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; | 4894 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; |
| 4889 } | 4895 } |
| 4890 | 4896 |
| 4891 1; | 4897 1; |
| OLD | NEW |