| 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 | 610 |
| 611 sub GenerateHeader | 611 sub GenerateHeader |
| 612 { | 612 { |
| 613 my $object = shift; | 613 my $object = shift; |
| 614 my $interface = shift; | 614 my $interface = shift; |
| 615 | 615 |
| 616 my $interfaceName = $interface->name; | 616 my $interfaceName = $interface->name; |
| 617 my $implClassName = GetImplName($interface); | 617 my $implClassName = GetImplName($interface); |
| 618 my $v8ClassName = GetV8ClassName($interface); | 618 my $v8ClassName = GetV8ClassName($interface); |
| 619 | 619 |
| 620 # Copy contents of parent interfaces except the first parent. | |
| 621 my @parents; | |
| 622 AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@parents); | |
| 623 LinkOverloadedFunctions($interface); | 620 LinkOverloadedFunctions($interface); |
| 624 | 621 |
| 625 # Ensure the IsDOMNodeType function is in sync. | 622 # Ensure the IsDOMNodeType function is in sync. |
| 626 die("IsDOMNodeType is out of date with respect to $interfaceName") if IsDOMN
odeType($interfaceName) != InheritsInterface($interface, "Node"); | 623 die("IsDOMNodeType is out of date with respect to $interfaceName") if IsDOMN
odeType($interfaceName) != InheritsInterface($interface, "Node"); |
| 627 | 624 |
| 628 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); | 625 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); |
| 629 | 626 |
| 630 if ($v8ClassName !~ /SVG/) { | 627 my $parentInterface = $interface->parent; |
| 631 for my $parent (@{$interface->parents}) { | 628 AddToHeaderIncludes("V8${parentInterface}.h") if $parentInterface; |
| 632 AddToHeaderIncludes("V8${parent}.h"); | |
| 633 } | |
| 634 } | |
| 635 AddToHeaderIncludes("bindings/v8/WrapperTypeInfo.h"); | 629 AddToHeaderIncludes("bindings/v8/WrapperTypeInfo.h"); |
| 636 AddToHeaderIncludes("bindings/v8/V8Binding.h"); | 630 AddToHeaderIncludes("bindings/v8/V8Binding.h"); |
| 637 AddToHeaderIncludes("bindings/v8/V8DOMWrapper.h"); | 631 AddToHeaderIncludes("bindings/v8/V8DOMWrapper.h"); |
| 638 AddToHeaderIncludes(HeaderFilesForInterface($interfaceName, $implClassName))
; | 632 AddToHeaderIncludes(HeaderFilesForInterface($interfaceName, $implClassName))
; |
| 639 foreach my $headerInclude (sort keys(%headerIncludes)) { | 633 foreach my $headerInclude (sort keys(%headerIncludes)) { |
| 640 $header{includes}->add("#include \"${headerInclude}\"\n"); | 634 $header{includes}->add("#include \"${headerInclude}\"\n"); |
| 641 } | 635 } |
| 642 | 636 |
| 643 $header{nameSpaceWebCore}->addHeader("\ntemplate<typename PropertyType> clas
s SVGPropertyTearOff;\n") if $svgPropertyType; | 637 $header{nameSpaceWebCore}->addHeader("\ntemplate<typename PropertyType> clas
s SVGPropertyTearOff;\n") if $svgPropertyType; |
| 644 if ($svgNativeType) { | 638 if ($svgNativeType) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 template<> | 810 template<> |
| 817 class WrapperTypeTraits<${nativeType} > { | 811 class WrapperTypeTraits<${nativeType} > { |
| 818 public: | 812 public: |
| 819 static WrapperTypeInfo* info() { return &${v8ClassName}::info; } | 813 static WrapperTypeInfo* info() { return &${v8ClassName}::info; } |
| 820 }; | 814 }; |
| 821 | 815 |
| 822 END | 816 END |
| 823 | 817 |
| 824 my $customWrap = $interface->extendedAttributes->{"CustomToV8"}; | 818 my $customWrap = $interface->extendedAttributes->{"CustomToV8"}; |
| 825 if ($noToV8) { | 819 if ($noToV8) { |
| 826 die "Can't suppress toV8 for subclass\n" if @parents; | 820 die "Can't suppress toV8 for subclass\n" if $interface->parent; |
| 827 } elsif ($noWrap) { | 821 } elsif ($noWrap) { |
| 828 die "Must have custom toV8\n" if !$customWrap; | 822 die "Must have custom toV8\n" if !$customWrap; |
| 829 $header{nameSpaceWebCore}->add(<<END); | 823 $header{nameSpaceWebCore}->add(<<END); |
| 830 class ${nativeType}; | 824 class ${nativeType}; |
| 831 v8::Handle<v8::Value> toV8(${nativeType}*, v8::Handle<v8::Object> creationContex
t, v8::Isolate*); | 825 v8::Handle<v8::Value> toV8(${nativeType}*, v8::Handle<v8::Object> creationContex
t, v8::Isolate*); |
| 832 v8::Handle<v8::Value> toV8ForMainWorld(${nativeType}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); | 826 v8::Handle<v8::Value> toV8ForMainWorld(${nativeType}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); |
| 833 | 827 |
| 834 template<class HolderContainer, class Wrappable> | 828 template<class HolderContainer, class Wrappable> |
| 835 inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer
& container, Wrappable*) | 829 inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer
& container, Wrappable*) |
| 836 { | 830 { |
| (...skipping 1820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2657 args.GetReturnValue().Set(wrapper); | 2651 args.GetReturnValue().Set(wrapper); |
| 2658 } | 2652 } |
| 2659 END | 2653 END |
| 2660 | 2654 |
| 2661 my $code = ""; | 2655 my $code = ""; |
| 2662 $code .= <<END; | 2656 $code .= <<END; |
| 2663 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary&
options) | 2657 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary&
options) |
| 2664 { | 2658 { |
| 2665 END | 2659 END |
| 2666 | 2660 |
| 2667 foreach my $interfaceBase (@{$interface->parents}) { | 2661 if ($interface->parent) { |
| 2662 my $interfaceBase = $interface->parent; |
| 2668 $code .= <<END; | 2663 $code .= <<END; |
| 2669 if (!fill${interfaceBase}Init(eventInit, options)) | 2664 if (!fill${interfaceBase}Init(eventInit, options)) |
| 2670 return false; | 2665 return false; |
| 2671 | 2666 |
| 2672 END | 2667 END |
| 2673 } | 2668 } |
| 2674 | 2669 |
| 2675 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 2670 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
| 2676 my $attribute = @{$interface->attributes}[$index]; | 2671 my $attribute = @{$interface->attributes}[$index]; |
| 2677 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) { | 2672 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) { |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3854 | 3849 |
| 3855 AddIncludesForType($interfaceName); | 3850 AddIncludesForType($interfaceName); |
| 3856 | 3851 |
| 3857 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje
ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; | 3852 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje
ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; |
| 3858 my $toEventTarget = InheritsExtendedAttribute($interface, "EventTarget") ? "
${v8ClassName}::toEventTarget" : "0"; | 3853 my $toEventTarget = InheritsExtendedAttribute($interface, "EventTarget") ? "
${v8ClassName}::toEventTarget" : "0"; |
| 3859 my $rootForGC = NeedsOpaqueRootForGC($interface) ? "${v8ClassName}::opaqueRo
otForGC" : "0"; | 3854 my $rootForGC = NeedsOpaqueRootForGC($interface) ? "${v8ClassName}::opaqueRo
otForGC" : "0"; |
| 3860 | 3855 |
| 3861 # Find the super descriptor. | 3856 # Find the super descriptor. |
| 3862 my $parentClass = ""; | 3857 my $parentClass = ""; |
| 3863 my $parentClassTemplate = ""; | 3858 my $parentClassTemplate = ""; |
| 3864 foreach (@{$interface->parents}) { | 3859 if ($interface->parent) { |
| 3865 my $parent = $_; | 3860 my $parent = $interface->parent; |
| 3866 AddToImplIncludes("V8${parent}.h"); | 3861 AddToImplIncludes("V8${parent}.h"); |
| 3867 $parentClass = "V8" . $parent; | 3862 $parentClass = "V8" . $parent; |
| 3868 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor
ldType)"; | 3863 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor
ldType)"; |
| 3869 last; | |
| 3870 } | 3864 } |
| 3871 | 3865 |
| 3872 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; | 3866 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; |
| 3873 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot
ype" : "WrapperTypeObjectPrototype"; | 3867 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot
ype" : "WrapperTypeObjectPrototype"; |
| 3874 | 3868 |
| 3875 if (!IsSVGTypeNeedingTearOff($interfaceName)) { | 3869 if (!IsSVGTypeNeedingTearOff($interfaceName)) { |
| 3876 my $code = <<END; | 3870 my $code = <<END; |
| 3877 static void initializeScriptWrappableForInterface(${implClassName}* object) | 3871 static void initializeScriptWrappableForInterface(${implClassName}* object) |
| 3878 { | 3872 { |
| 3879 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | 3873 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4684 $code .= "}\n"; | 4678 $code .= "}\n"; |
| 4685 $implementation{nameSpaceWebCore}->add($code); | 4679 $implementation{nameSpaceWebCore}->add($code); |
| 4686 } | 4680 } |
| 4687 } | 4681 } |
| 4688 } | 4682 } |
| 4689 | 4683 |
| 4690 sub BaseInterfaceName | 4684 sub BaseInterfaceName |
| 4691 { | 4685 { |
| 4692 my $interface = shift; | 4686 my $interface = shift; |
| 4693 | 4687 |
| 4694 while (@{$interface->parents}) { | 4688 while ($interface->parent) { |
| 4695 $interface = ParseInterface(@{$interface->parents}[0]); | 4689 $interface = ParseInterface($interface->parent); |
| 4696 } | 4690 } |
| 4697 | 4691 |
| 4698 return $interface->name; | 4692 return $interface->name; |
| 4699 } | 4693 } |
| 4700 | 4694 |
| 4701 sub GenerateToV8Converters | 4695 sub GenerateToV8Converters |
| 4702 { | 4696 { |
| 4703 my $interface = shift; | 4697 my $interface = shift; |
| 4704 my $v8ClassName = shift; | 4698 my $v8ClassName = shift; |
| 4705 my $nativeType = shift; | 4699 my $nativeType = shift; |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5556 sub ForAllParents | 5550 sub ForAllParents |
| 5557 { | 5551 { |
| 5558 my $interface = shift; | 5552 my $interface = shift; |
| 5559 my $beforeRecursion = shift; | 5553 my $beforeRecursion = shift; |
| 5560 my $afterRecursion = shift; | 5554 my $afterRecursion = shift; |
| 5561 | 5555 |
| 5562 my $recurse; | 5556 my $recurse; |
| 5563 $recurse = sub { | 5557 $recurse = sub { |
| 5564 my $currentInterface = shift; | 5558 my $currentInterface = shift; |
| 5565 | 5559 |
| 5566 for (@{$currentInterface->parents}) { | 5560 if ($currentInterface->parent) { |
| 5567 my $interfaceName = $_; | 5561 my $parentInterface = ParseInterface($currentInterface->parent); |
| 5568 my $parentInterface = ParseInterface($interfaceName); | |
| 5569 | |
| 5570 if ($beforeRecursion) { | 5562 if ($beforeRecursion) { |
| 5571 &$beforeRecursion($parentInterface) eq 'prune' and next; | 5563 &$beforeRecursion($parentInterface) eq 'prune' and return; |
| 5572 } | 5564 } |
| 5573 &$recurse($parentInterface); | 5565 &$recurse($parentInterface); |
| 5574 &$afterRecursion($parentInterface) if $afterRecursion; | 5566 &$afterRecursion($parentInterface) if $afterRecursion; |
| 5575 } | 5567 } |
| 5576 }; | 5568 }; |
| 5577 | 5569 |
| 5578 &$recurse($interface); | 5570 &$recurse($interface); |
| 5579 } | 5571 } |
| 5580 | 5572 |
| 5581 sub AddMethodsConstantsAndAttributesFromParentInterfaces | |
| 5582 { | |
| 5583 # Add to $interface all of its inherited interface members, except for those | |
| 5584 # inherited through $interface's first listed parent. If an array reference | |
| 5585 # is passed in as $parents, the names of all ancestor interfaces visited | |
| 5586 # will be appended to the array. The names of $interface's first listed pare
nt | |
| 5587 # and its ancestors will also be appended to $parents. | |
| 5588 | |
| 5589 my $interface = shift; | |
| 5590 my $parents = shift; | |
| 5591 | |
| 5592 my $first = 1; | |
| 5593 ForAllParents($interface, sub { | |
| 5594 my $currentInterface = shift; | |
| 5595 | |
| 5596 if ($first) { | |
| 5597 # Ignore first parent class, already handled by the generation itsel
f. | |
| 5598 $first = 0; | |
| 5599 | |
| 5600 # Just collect the names of the direct ancestor interfaces, | |
| 5601 # if necessary. | |
| 5602 push(@$parents, $currentInterface->name); | |
| 5603 ForAllParents($currentInterface, sub { | |
| 5604 my $currentInterface = shift; | |
| 5605 push(@$parents, $currentInterface->name); | |
| 5606 }); | |
| 5607 return 'prune'; | |
| 5608 } | |
| 5609 | |
| 5610 # Collect the name of this additional parent. | |
| 5611 push(@$parents, $currentInterface->name) if $parents; | |
| 5612 | |
| 5613 # Add this parent's members to $interface. | |
| 5614 push(@{$interface->constants}, @{$currentInterface->constants}); | |
| 5615 push(@{$interface->functions}, @{$currentInterface->functions}); | |
| 5616 push(@{$interface->attributes}, @{$currentInterface->attributes}); | |
| 5617 }); | |
| 5618 } | |
| 5619 | |
| 5620 sub FindSuperMethod | 5573 sub FindSuperMethod |
| 5621 { | 5574 { |
| 5622 my ($interface, $functionName) = @_; | 5575 my ($interface, $functionName) = @_; |
| 5623 my $indexer; | 5576 my $indexer; |
| 5624 ForAllParents($interface, undef, sub { | 5577 ForAllParents($interface, undef, sub { |
| 5625 my $currentInterface = shift; | 5578 my $currentInterface = shift; |
| 5626 foreach my $function (@{$currentInterface->functions}) { | 5579 foreach my $function (@{$currentInterface->functions}) { |
| 5627 if ($function->name eq $functionName) { | 5580 if ($function->name eq $functionName) { |
| 5628 $indexer = $function; | 5581 $indexer = $function; |
| 5629 return 'prune'; | 5582 return 'prune'; |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6039 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 5992 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
| 6040 $found = 1; | 5993 $found = 1; |
| 6041 } | 5994 } |
| 6042 return 1 if $found; | 5995 return 1 if $found; |
| 6043 }, 0); | 5996 }, 0); |
| 6044 | 5997 |
| 6045 return $found; | 5998 return $found; |
| 6046 } | 5999 } |
| 6047 | 6000 |
| 6048 1; | 6001 1; |
| OLD | NEW |