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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
691 "Storage" => 1, | 691 "Storage" => 1, |
692 "HTMLAppletElement" => 1, | 692 "HTMLAppletElement" => 1, |
693 "HTMLEmbedElement" => 1, | 693 "HTMLEmbedElement" => 1, |
694 "HTMLObjectElement" => 1 | 694 "HTMLObjectElement" => 1 |
695 ); | 695 ); |
696 | 696 |
697 sub GenerateHeaderNamedAndIndexedPropertyAccessors | 697 sub GenerateHeaderNamedAndIndexedPropertyAccessors |
698 { | 698 { |
699 my $interface = shift; | 699 my $interface = shift; |
700 my $interfaceName = $interface->name; | 700 my $interfaceName = $interface->name; |
701 my $hasCustomIndexedGetter = $interface->extendedAttributes->{"IndexedGetter "} || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}; | 701 my $hasCustomIndexedGetter = $interface->extendedAttributes->{"IndexedGetter "} || $interface->extendedAttributes->{"CustomIndexedGetter"}; |
702 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed Setter"} && !$interface->extendedAttributes->{"NumericIndexedGetter"}; | 702 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed Setter"} && !$interface->extendedAttributes->{"NumericIndexedGetter"}; |
703 my $hasCustomNamedGetter = $interface->extendedAttributes->{"NamedGetter"} | | $interface->extendedAttributes->{"CustomNamedGetter"} || $interface->extendedA ttributes->{"CustomGetOwnPropertySlot"}; | 703 my $hasCustomNamedGetter = $interface->extendedAttributes->{"NamedGetter"} | | $interface->extendedAttributes->{"CustomNamedGetter"} || $interface->extendedA ttributes->{"CustomGetOwnPropertySlot"}; |
704 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSett er"}; | 704 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSett er"}; |
705 my $hasCustomDeleters = $interface->extendedAttributes->{"CustomDeleteProper ty"}; | 705 my $hasCustomDeleters = $interface->extendedAttributes->{"CustomDeleteProper ty"}; |
706 my $hasCustomEnumerator = $interface->extendedAttributes->{"CustomEnumerateP roperty"}; | 706 my $hasCustomEnumerator = $interface->extendedAttributes->{"CustomEnumerateP roperty"}; |
707 if ($interfaceName eq "HTMLOptionsCollection") { | 707 if ($interfaceName eq "HTMLOptionsCollection") { |
708 $interfaceName = "HTMLCollection"; | 708 $interfaceName = "HTMLCollection"; |
709 $hasCustomIndexedGetter = 1; | 709 $hasCustomIndexedGetter = 1; |
710 $hasCustomNamedGetter = 1; | 710 $hasCustomNamedGetter = 1; |
711 } | 711 } |
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2603 push(@implContent, " ${conditional}$template->Set(v8::String::New Symbol(\"$name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name} MethodCallbackForMainWorld, v8Undefined(), ${signature})$property_attributes);\n "); | 2603 push(@implContent, " ${conditional}$template->Set(v8::String::New Symbol(\"$name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name} MethodCallbackForMainWorld, v8Undefined(), ${signature})$property_attributes);\n "); |
2604 push(@implContent, " } else {\n"); | 2604 push(@implContent, " } else {\n"); |
2605 push(@implContent, " ${conditional}$template->Set(v8::String::New Symbol(\"$name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name} MethodCallback, v8Undefined(), ${signature})$property_attributes);\n"); | 2605 push(@implContent, " ${conditional}$template->Set(v8::String::New Symbol(\"$name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name} MethodCallback, v8Undefined(), ${signature})$property_attributes);\n"); |
2606 push(@implContent, " }\n"); | 2606 push(@implContent, " }\n"); |
2607 } else { | 2607 } else { |
2608 push(@implContent, " ${conditional}$template->Set(v8::String::NewSymb ol(\"$name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}Meth odCallback, v8Undefined(), ${signature})$property_attributes);\n"); | 2608 push(@implContent, " ${conditional}$template->Set(v8::String::NewSymb ol(\"$name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}Meth odCallback, v8Undefined(), ${signature})$property_attributes);\n"); |
2609 } | 2609 } |
2610 push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString ; | 2610 push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString ; |
2611 } | 2611 } |
2612 | 2612 |
2613 sub GenerateImplementationIndexer | 2613 sub GenerateImplementationIndexedProperty |
2614 { | 2614 { |
2615 my $interface = shift; | 2615 my $interface = shift; |
2616 my $indexer = shift; | 2616 my $indexer = shift; |
2617 my $interfaceName = $interface->name; | 2617 my $interfaceName = $interface->name; |
2618 my $v8InterfaceName = "V8$interfaceName"; | 2618 my $v8InterfaceName = "V8$interfaceName"; |
2619 | 2619 |
2620 # FIXME: Figure out what NumericIndexedGetter is really supposed to do. Righ t now, it's only set on WebGL-related files. | 2620 # FIXME: Figure out what NumericIndexedGetter is really supposed to do. Righ t now, it's only set on WebGL-related files. |
2621 my $hasCustomSetter = $interface->extendedAttributes->{"CustomIndexedSetter" } && !$interface->extendedAttributes->{"NumericIndexedGetter"}; | 2621 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed Setter"} && !$interface->extendedAttributes->{"NumericIndexedGetter"}; |
2622 my $hasGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interf ace->extendedAttributes->{"CustomGetOwnPropertySlot"}; | 2622 my $hasIndexedGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"CustomIndexedGetter"}; |
2623 | 2623 |
2624 # FIXME: Investigate and remove this nastinesss. In V8, named property handl ing and indexer handling are apparently decoupled, | 2624 # FIXME: Investigate and remove this nastinesss. In V8, named property handl ing and indexer handling are apparently decoupled, |
2625 # which means that object[X] where X is a number doesn't reach named propert y indexer. So we need to provide | 2625 # which means that object[X] where X is a number doesn't reach named propert y indexer. So we need to provide |
2626 # simplistic, mirrored indexer handling in addition to named property handli ng. | 2626 # simplistic, mirrored indexer handling in addition to named property handli ng. |
2627 my $isSpecialCase = exists $indexerSpecialCases{$interfaceName}; | 2627 my $isSpecialCase = exists $indexerSpecialCases{$interfaceName}; |
2628 if ($isSpecialCase) { | 2628 if ($isSpecialCase) { |
2629 $hasGetter = 1; | 2629 $hasIndexedGetter = 1; |
2630 if ($interface->extendedAttributes->{"CustomNamedSetter"}) { | 2630 if ($interface->extendedAttributes->{"CustomNamedSetter"}) { |
2631 $hasCustomSetter = 1; | 2631 $hasCustomIndexedSetter = 1; |
2632 } | 2632 } |
2633 } | 2633 } |
2634 | 2634 |
2635 # FIXME: Remove the special cases. Interfaces that have indexedPropertyGette r should have indexedPropertyEnumerator. | |
2635 my $hasEnumerator = !$isSpecialCase && $codeGenerator->InheritsInterface($in terface, "Node"); | 2636 my $hasEnumerator = !$isSpecialCase && $codeGenerator->InheritsInterface($in terface, "Node"); |
2636 | 2637 |
2637 # FIXME: Find a way to not have to special-case HTMLOptionsCollection. | 2638 # FIXME: Find a way to not have to special-case HTMLOptionsCollection. |
2638 if ($interfaceName eq "HTMLOptionsCollection") { | 2639 if ($interfaceName eq "HTMLOptionsCollection") { |
2639 $hasEnumerator = 1; | 2640 $hasEnumerator = 1; |
2640 $hasGetter = 1; | 2641 $hasIndexedGetter = 1; |
2641 } | 2642 } |
2642 | 2643 |
2643 if (!$hasGetter) { | 2644 if (!$hasIndexedGetter) { |
2644 return; | 2645 return ""; |
2645 } | 2646 } |
2646 | 2647 |
2647 AddToImplIncludes("V8Collection.h"); | 2648 AddToImplIncludes("V8Collection.h"); |
2648 | 2649 |
2649 if (!$indexer) { | 2650 if (!$indexer) { |
2650 $indexer = $codeGenerator->FindSuperMethod($interface, "item"); | 2651 $indexer = $codeGenerator->FindSuperMethod($interface, "item"); |
2651 } | 2652 } |
2652 | 2653 |
2653 my $indexerType = $indexer ? $indexer->type : 0; | 2654 my $indexerType = $indexer ? $indexer->type : 0; |
2654 | 2655 |
2655 # FIXME: Remove this once toV8 helper methods are implemented (see https://b ugs.webkit.org/show_bug.cgi?id=32563). | 2656 if ($indexerType && !$hasCustomIndexedSetter) { |
2656 if ($interfaceName eq "WebKitCSSKeyframesRule") { | 2657 $hasEnumerator = 1; |
2657 $indexerType = "WebKitCSSKeyframeRule"; | |
2658 } | |
2659 | |
2660 if ($indexerType && !$hasCustomSetter) { | |
2661 if ($indexerType eq "DOMString") { | |
2662 my $conversion = $indexer->extendedAttributes->{"TreatReturnedNullSt ringAs"}; | |
2663 if ($conversion && $conversion eq "Null") { | |
2664 push(@implContent, <<END); | |
2665 setCollectionStringOrUndefinedIndexedGetter<${interfaceName}>(desc); | |
2666 END | |
2667 } else { | |
2668 push(@implContent, <<END); | |
2669 setCollectionStringIndexedGetter<${interfaceName}>(desc); | |
2670 END | |
2671 } | |
2672 } else { | |
2673 push(@implContent, <<END); | |
2674 setCollectionIndexedGetter<${interfaceName}, ${indexerType}>(desc); | |
2675 END | |
2676 # Include the header for this indexer type, because setCollectionInd exedGetter() requires toV8() for this type. | |
2677 AddToImplIncludes("V8${indexerType}.h"); | |
2678 } | |
2679 | |
2680 return; | |
2681 } | 2658 } |
2682 | 2659 |
2683 my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty"}; | 2660 my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty"}; |
2684 my $setOn = "Instance"; | 2661 my $setOn = "Instance"; |
2685 | 2662 |
2686 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba cks) and it's used on DOMWindow | 2663 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba cks) and it's used on DOMWindow |
2687 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to | 2664 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to |
2688 # get implementation straight out of the DOMWindow prototype regardless of w hat prototype is actually set | 2665 # get implementation straight out of the DOMWindow prototype regardless of w hat prototype is actually set |
2689 # on the object. | 2666 # on the object. |
2690 if ($interfaceName eq "DOMWindow") { | 2667 if ($interfaceName eq "DOMWindow") { |
2691 $setOn = "Prototype"; | 2668 $setOn = "Prototype"; |
2692 $hasDeleter = 0; | 2669 $hasDeleter = 0; |
2693 } | 2670 } |
2671 # FIXME: Implement V8DataTransferItemList::indexedPropertyDeleter | |
2672 if ($interfaceName eq "DataTransferItemList") { | |
2673 $hasDeleter = 0; | |
2674 } | |
2694 | 2675 |
2695 push(@implContent, " desc->${setOn}Template()->SetIndexedPropertyHandler( ${v8InterfaceName}::indexedPropertyGetter"); | 2676 push(@implContent, " desc->${setOn}Template()->SetIndexedPropertyHandler( ${v8InterfaceName}::indexedPropertyGetter"); |
2696 push(@implContent, $hasCustomSetter ? ", ${v8InterfaceName}::indexedProperty Setter" : ", 0"); | 2677 push(@implContent, $hasCustomIndexedSetter ? ", ${v8InterfaceName}::indexedP ropertySetter" : ", 0"); |
2697 push(@implContent, ", 0"); # IndexedPropertyQuery -- not being used at the m oment. | 2678 push(@implContent, ", 0"); # IndexedPropertyQuery -- not being used at the m oment. |
2698 push(@implContent, $hasDeleter ? ", ${v8InterfaceName}::indexedPropertyDelet er" : ", 0"); | 2679 push(@implContent, $hasDeleter ? ", ${v8InterfaceName}::indexedPropertyDelet er" : ", 0"); |
2699 push(@implContent, ", nodeCollectionIndexedPropertyEnumerator<${interfaceNam e}>") if $hasEnumerator; | 2680 push(@implContent, ", nodeCollectionIndexedPropertyEnumerator<${interfaceNam e}>") if $hasEnumerator; |
2700 push(@implContent, ");\n"); | 2681 push(@implContent, ");\n"); |
2682 | |
2683 if($interface->extendedAttributes->{"IndexedGetter"}) { | |
2684 # FIXME: add item() method to WebKitCSSKeyframesRule.idl or remove [Inde xedGetter] from WebKitCSSKeyframesRule.idl | |
2685 # Currently indexer type is hard coded because it can not be obtained fr om IDL. | |
2686 if ($interfaceName eq "WebKitCSSKeyframesRule") { | |
2687 $indexerType = "WebKitCSSKeyframeRule"; | |
2688 } | |
2689 my $jsValue = ""; | |
2690 my $elementType = GetNativeType($indexerType); | |
haraken
2013/04/17 10:29:52
$elementType => $nativeType
| |
2691 my $isNull = ""; | |
2692 | |
2693 if ($indexerType eq "DOMString") { | |
haraken
2013/04/17 10:29:52
Shall we use $codeGenerator->IsRefPtrType($indexer
| |
2694 $isNull = "element.isNull()"; | |
2695 $jsValue = NativeToJSValue($indexer, "element", "info.Holder()", "in fo.GetIsolate()"); | |
2696 } else { | |
2697 $isNull = "!element"; | |
2698 if ($interfaceName eq "WebKitCSSKeyframesRule") { | |
2699 $jsValue = "toV8(element.release(), info.Holder(), info.GetIsola te())"; | |
2700 } else { | |
2701 $jsValue = NativeToJSValue($indexer, "element.release()", "info. Holder()", "info.GetIsolate()"); | |
2702 } | |
2703 } | |
2704 | |
2705 return <<END; | |
2706 v8::Handle<v8::Value> ${v8InterfaceName}::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) | |
2707 { | |
2708 ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); | |
2709 ${interfaceName}* collection = toNative(info.Holder()); | |
2710 $elementType element = collection->item(index); | |
2711 if ($isNull) | |
2712 return v8Undefined(); | |
2713 return $jsValue; | |
2714 } | |
2715 END | |
2716 } | |
2717 return ""; | |
2701 } | 2718 } |
2702 | 2719 |
2703 sub GenerateImplementationNamedPropertyGetter | 2720 sub GenerateImplementationNamedPropertyGetter |
2704 { | 2721 { |
2705 my $interface = shift; | 2722 my $interface = shift; |
2706 my $namedPropertyGetter = shift; | 2723 my $namedPropertyGetter = shift; |
2707 my $interfaceName = $interface->name; | 2724 my $interfaceName = $interface->name; |
2708 my $v8InterfaceName = "V8$interfaceName"; | 2725 my $v8InterfaceName = "V8$interfaceName"; |
2709 | 2726 |
2710 if ($interface->extendedAttributes->{"NamedGetter"}) { | 2727 if ($interface->extendedAttributes->{"NamedGetter"}) { |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3218 push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString ; | 3235 push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString ; |
3219 push(@implContent, " if (${enable_function}()) {\n"); | 3236 push(@implContent, " if (${enable_function}()) {\n"); |
3220 push(@implContent, <<END); | 3237 push(@implContent, <<END); |
3221 static const V8DOMConfiguration::BatchedConstant constData = {"${name}", static_cast<signed int>(${value})}; | 3238 static const V8DOMConfiguration::BatchedConstant constData = {"${name}", static_cast<signed int>(${value})}; |
3222 V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1, isolate); | 3239 V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1, isolate); |
3223 END | 3240 END |
3224 push(@implContent, " }\n"); | 3241 push(@implContent, " }\n"); |
3225 push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional String; | 3242 push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional String; |
3226 } | 3243 } |
3227 | 3244 |
3228 GenerateImplementationIndexer($interface, $indexer); | 3245 my $indexPropertyGetterCode = GenerateImplementationIndexedProperty($interfa ce, $indexer); |
3229 GenerateImplementationNamedPropertyGetter($interface, $namedPropertyGetter); | 3246 GenerateImplementationNamedPropertyGetter($interface, $namedPropertyGetter); |
3230 GenerateImplementationCustomCall($interface); | 3247 GenerateImplementationCustomCall($interface); |
3231 GenerateImplementationMasqueradesAsUndefined($interface); | 3248 GenerateImplementationMasqueradesAsUndefined($interface); |
3232 | 3249 |
3233 # Define our functions with Set() or SetAccessor() | 3250 # Define our functions with Set() or SetAccessor() |
3234 my $total_functions = 0; | 3251 my $total_functions = 0; |
3235 foreach my $function (@normalFunctions) { | 3252 foreach my $function (@normalFunctions) { |
3236 # Only one accessor is needed for overloaded methods: | 3253 # Only one accessor is needed for overloaded methods: |
3237 next if $function->{overloadIndex} > 1; | 3254 next if $function->{overloadIndex} > 1; |
3238 | 3255 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3307 | 3324 |
3308 bool ${v8InterfaceName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8:: Isolate* isolate) | 3325 bool ${v8InterfaceName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8:: Isolate* isolate) |
3309 { | 3326 { |
3310 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) | 3327 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) |
3311 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld) | 3328 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld) |
3312 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d); | 3329 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d); |
3313 } | 3330 } |
3314 | 3331 |
3315 END | 3332 END |
3316 | 3333 |
3334 push(@implContent, $indexPropertyGetterCode); | |
3335 | |
3317 if (@enabledPerContextAttributes) { | 3336 if (@enabledPerContextAttributes) { |
3318 push(@implContent, <<END); | 3337 push(@implContent, <<END); |
3319 void ${v8InterfaceName}::installPerContextProperties(v8::Handle<v8::Object> inst ance, ${nativeType}* impl, v8::Isolate* isolate) | 3338 void ${v8InterfaceName}::installPerContextProperties(v8::Handle<v8::Object> inst ance, ${nativeType}* impl, v8::Isolate* isolate) |
3320 { | 3339 { |
3321 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type()); | 3340 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type()); |
3322 // When building QtWebkit with V8 this variable is unused when none of the f eatures are enabled. | 3341 // When building QtWebkit with V8 this variable is unused when none of the f eatures are enabled. |
3323 UNUSED_PARAM(proto); | 3342 UNUSED_PARAM(proto); |
3324 END | 3343 END |
3325 | 3344 |
3326 # Setup the enable-by-settings attrs if we have them | 3345 # Setup the enable-by-settings attrs if we have them |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4596 | 4615 |
4597 sub GetPassRefPtrType | 4616 sub GetPassRefPtrType |
4598 { | 4617 { |
4599 my $v8InterfaceName = shift; | 4618 my $v8InterfaceName = shift; |
4600 | 4619 |
4601 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; | 4620 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; |
4602 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; | 4621 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; |
4603 } | 4622 } |
4604 | 4623 |
4605 1; | 4624 1; |
OLD | NEW |