| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 bless($reference, $object); | 271 bless($reference, $object); |
| 272 return $reference; | 272 return $reference; |
| 273 } | 273 } |
| 274 | 274 |
| 275 | 275 |
| 276 sub IDLFileForInterface | 276 sub IDLFileForInterface |
| 277 { | 277 { |
| 278 my $interfaceName = shift; | 278 my $interfaceName = shift; |
| 279 | 279 |
| 280 unless ($idlFiles) { | 280 unless ($idlFiles) { |
| 281 # use Data::Dumper; |
| 282 # print "[direc]", Dumper($idlDirectories), "\n"; |
| 281 my @directories = map { $_ = "$sourceRoot/$_" if -d "$sourceRoot/$_"; $_
} @$idlDirectories; | 283 my @directories = map { $_ = "$sourceRoot/$_" if -d "$sourceRoot/$_"; $_
} @$idlDirectories; |
| 282 push(@directories, "."); | 284 push(@directories, "."); |
| 285 # print "[directories]", Dumper(@directories), "\n"; |
| 283 | 286 |
| 284 $idlFiles = { }; | 287 $idlFiles = { }; |
| 285 foreach my $idlFile (@$dependentIdlFiles) { | 288 foreach my $idlFile (@$dependentIdlFiles) { |
| 286 $idlFiles->{fileparse(basename($idlFile), ".idl")} = $idlFile; | 289 $idlFiles->{fileparse(basename($idlFile), ".idl")} = $idlFile; |
| 287 } | 290 } |
| 291 # use Data::Dumper; |
| 292 # print "[idlFiles]", Dumper($idlFiles), "\n"; |
| 288 | 293 |
| 289 my $wanted = sub { | 294 my $wanted = sub { |
| 295 # print "<find> ", $File::Find::name, "\n"; |
| 290 $idlFiles->{$1} = $File::Find::name if /^([A-Z].*)\.idl$/; | 296 $idlFiles->{$1} = $File::Find::name if /^([A-Z].*)\.idl$/; |
| 291 $File::Find::prune = 1 if /^\../; | 297 $File::Find::prune = 1 if /^\../; |
| 292 }; | 298 }; |
| 293 find($wanted, @directories); | 299 find($wanted, @directories); |
| 300 # print "[idlFiles]", scalar(keys($idlFiles)), "\n"; |
| 294 } | 301 } |
| 295 | 302 |
| 296 return $idlFiles->{$interfaceName}; | 303 return $idlFiles->{$interfaceName}; |
| 297 } | 304 } |
| 298 | 305 |
| 299 sub ParseInterface | 306 sub ParseInterface |
| 300 { | 307 { |
| 301 my $interfaceName = shift; | 308 my $interfaceName = shift; |
| 302 | 309 |
| 303 if (exists $cachedInterfaces->{$interfaceName}) { | 310 if (exists $cachedInterfaces->{$interfaceName}) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 322 } | 329 } |
| 323 | 330 |
| 324 die("Could NOT find interface definition for $interfaceName in $filename"); | 331 die("Could NOT find interface definition for $interfaceName in $filename"); |
| 325 } | 332 } |
| 326 | 333 |
| 327 sub GenerateInterface | 334 sub GenerateInterface |
| 328 { | 335 { |
| 329 my $object = shift; | 336 my $object = shift; |
| 330 my $interface = shift; | 337 my $interface = shift; |
| 331 | 338 |
| 339 print "[Parents of] ", $interface->name, "\n"; |
| 340 # ForAllParents($interface, sub { |
| 341 # my $parent = shift; |
| 342 # print " - ", $parent->name, "\n" |
| 343 # }); |
| 332 %callbackFunctionTypeHash = map { $_->name => $_ } @{$idlDocument->callbackF
unctions}; | 344 %callbackFunctionTypeHash = map { $_->name => $_ } @{$idlDocument->callbackF
unctions}; |
| 333 %enumTypeHash = map { $_->name => $_->values } @{$idlDocument->enumerations}
; | 345 %enumTypeHash = map { $_->name => $_->values } @{$idlDocument->enumerations}
; |
| 334 my $v8ClassName = GetV8ClassName($interface); | 346 my $v8ClassName = GetV8ClassName($interface); |
| 335 my $defineName = $v8ClassName . "_h"; | 347 my $defineName = $v8ClassName . "_h"; |
| 336 my $internalNamespace = GetImplName($interface) . "V8Internal"; | 348 my $internalNamespace = GetImplName($interface) . "V8Internal"; |
| 337 | 349 |
| 338 my $conditionalString = GenerateConditionalString($interface); | 350 my $conditionalString = GenerateConditionalString($interface); |
| 339 my $conditionalIf = ""; | 351 my $conditionalIf = ""; |
| 340 my $conditionalEndif = ""; | 352 my $conditionalEndif = ""; |
| 341 if ($conditionalString) { | 353 if ($conditionalString) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 if ($type eq "CSSStyleSheet") { | 461 if ($type eq "CSSStyleSheet") { |
| 450 AddToImplIncludes("core/css/CSSImportRule.h"); | 462 AddToImplIncludes("core/css/CSSImportRule.h"); |
| 451 } | 463 } |
| 452 } | 464 } |
| 453 | 465 |
| 454 sub HeaderFilesForInterface | 466 sub HeaderFilesForInterface |
| 455 { | 467 { |
| 456 my $interfaceName = shift; | 468 my $interfaceName = shift; |
| 457 my $implClassName = shift; | 469 my $implClassName = shift; |
| 458 | 470 |
| 471 use Data::Dumper; |
| 459 my @includes = (); | 472 my @includes = (); |
| 460 if (IsTypedArrayType($interfaceName)) { | 473 if (IsTypedArrayType($interfaceName)) { |
| 461 push(@includes, "wtf/${interfaceName}.h"); | 474 push(@includes, "wtf/${interfaceName}.h"); |
| 462 } elsif ($interfaceName =~ /SVGPathSeg/) { | 475 } elsif ($interfaceName =~ /SVGPathSeg/) { |
| 463 $interfaceName =~ s/Abs|Rel//; | 476 $interfaceName =~ s/Abs|Rel//; |
| 464 push(@includes, "core/svg/${interfaceName}.h"); | 477 push(@includes, "core/svg/${interfaceName}.h"); |
| 465 } elsif (!SkipIncludeHeader($interfaceName)) { | 478 } elsif (!SkipIncludeHeader($interfaceName)) { |
| 466 my $idlFilename = IDLFileForInterface($interfaceName) or die("Could NOT
find IDL file for interface \"$interfaceName\" $!\n"); | 479 my $idlFilename = IDLFileForInterface($interfaceName) or die("Could NOT
find IDL file for interface \"$interfaceName\" $!\n"); |
| 467 my $idlRelPath= "bindings/" . File::Spec->abs2rel($idlFilename, $sourceR
oot); | 480 my $idlRelPath= "bindings/" . File::Spec->abs2rel($idlFilename, $sourceR
oot); |
| 468 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); | 481 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); |
| 469 } | 482 } |
| 483 # print "[HeaderFilesForInterface]", Dumper(@includes); |
| 470 return @includes; | 484 return @includes; |
| 471 } | 485 } |
| 472 | 486 |
| 473 sub NeedsOpaqueRootForGC | 487 sub NeedsOpaqueRootForGC |
| 474 { | 488 { |
| 475 my $interface = shift; | 489 my $interface = shift; |
| 476 return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface
->extendedAttributes->{"CustomIsReachable"}; | 490 return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface
->extendedAttributes->{"CustomIsReachable"}; |
| 477 } | 491 } |
| 478 | 492 |
| 479 sub GenerateOpaqueRootForGC | 493 sub GenerateOpaqueRootForGC |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 sub GenerateHeader | 625 sub GenerateHeader |
| 612 { | 626 { |
| 613 my $object = shift; | 627 my $object = shift; |
| 614 my $interface = shift; | 628 my $interface = shift; |
| 615 | 629 |
| 616 my $interfaceName = $interface->name; | 630 my $interfaceName = $interface->name; |
| 617 my $implClassName = GetImplName($interface); | 631 my $implClassName = GetImplName($interface); |
| 618 my $v8ClassName = GetV8ClassName($interface); | 632 my $v8ClassName = GetV8ClassName($interface); |
| 619 | 633 |
| 620 # Copy contents of parent interfaces except the first parent. | 634 # Copy contents of parent interfaces except the first parent. |
| 621 my @parents; | 635 AddMethodsConstantsAndAttributesFromParentInterfaces($interface); # needed f
or SVG* only |
| 622 AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@parents); | |
| 623 LinkOverloadedFunctions($interface); | 636 LinkOverloadedFunctions($interface); |
| 624 | 637 |
| 625 # Ensure the IsDOMNodeType function is in sync. | 638 # 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"); | 639 my $_dom = IsDOMNodeType($interfaceName) ? "DOM" : ""; |
| 640 my $_inh = InheritsInterface($interface, "Node") ? "INH" : ""; |
| 641 if(IsDOMNodeType($interfaceName) != InheritsInterface($interface, "Node")) { |
| 642 # print "[DOMDOM] $_dom $_inh ", $interface->name, "\n"; |
| 643 die("IsDOMNodeType is out of date with respect to $interfaceName") |
| 644 } |
| 627 | 645 |
| 628 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); | 646 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); |
| 629 | 647 |
| 630 if ($v8ClassName !~ /SVG/) { | 648 if ($v8ClassName !~ /SVG/) { |
| 649 use Data::Dumper; |
| 650 print "Parents", Dumper($interface->parents); |
| 631 for my $parent (@{$interface->parents}) { | 651 for my $parent (@{$interface->parents}) { |
| 652 print "ADD H $parent\n"; |
| 632 AddToHeaderIncludes("V8${parent}.h"); | 653 AddToHeaderIncludes("V8${parent}.h"); |
| 633 } | 654 } |
| 634 } | 655 } |
| 635 AddToHeaderIncludes("bindings/v8/WrapperTypeInfo.h"); | 656 AddToHeaderIncludes("bindings/v8/WrapperTypeInfo.h"); |
| 636 AddToHeaderIncludes("bindings/v8/V8Binding.h"); | 657 AddToHeaderIncludes("bindings/v8/V8Binding.h"); |
| 637 AddToHeaderIncludes("bindings/v8/V8DOMWrapper.h"); | 658 AddToHeaderIncludes("bindings/v8/V8DOMWrapper.h"); |
| 638 AddToHeaderIncludes(HeaderFilesForInterface($interfaceName, $implClassName))
; | 659 AddToHeaderIncludes(HeaderFilesForInterface($interfaceName, $implClassName))
; |
| 639 foreach my $headerInclude (sort keys(%headerIncludes)) { | 660 foreach my $headerInclude (sort keys(%headerIncludes)) { |
| 640 $header{includes}->add("#include \"${headerInclude}\"\n"); | 661 $header{includes}->add("#include \"${headerInclude}\"\n"); |
| 641 } | 662 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 static v8::Handle<v8::ObjectTemplate> GetShadowObjectTemplate(v8::Isolate*,
WrapperWorldType); | 717 static v8::Handle<v8::ObjectTemplate> GetShadowObjectTemplate(v8::Isolate*,
WrapperWorldType); |
| 697 END | 718 END |
| 698 } | 719 } |
| 699 | 720 |
| 700 my @enabledPerContextFunctions; | 721 my @enabledPerContextFunctions; |
| 701 foreach my $function (@{$interface->functions}) { | 722 foreach my $function (@{$interface->functions}) { |
| 702 my $name = $function->name; | 723 my $name = $function->name; |
| 703 next if $name eq ""; | 724 next if $name eq ""; |
| 704 my $attrExt = $function->extendedAttributes; | 725 my $attrExt = $function->extendedAttributes; |
| 705 | 726 |
| 706 if (HasCustomMethod($attrExt) && !$attrExt->{"ImplementedBy"} && $functi
on->{overloadIndex} == 1) { | 727 # if (HasCustomMethod($attrExt) && !$attrExt->{"ImplementedBy"} && $funct
ion->{overloadIndex} == 1) { |
| 728 if (HasCustomMethod($attrExt) && $function->{overloadIndex} == 1) { |
| 707 my $conditionalString = GenerateConditionalString($function); | 729 my $conditionalString = GenerateConditionalString($function); |
| 708 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio
nalString; | 730 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio
nalString; |
| 709 $header{classPublic}->add(<<END); | 731 $header{classPublic}->add(<<END); |
| 710 static void ${name}MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&); | 732 static void ${name}MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&); |
| 711 END | 733 END |
| 712 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co
nditionalString; | 734 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co
nditionalString; |
| 713 } | 735 } |
| 714 if ($attrExt->{"EnabledPerContext"}) { | 736 if ($attrExt->{"EnabledPerContext"}) { |
| 715 push(@enabledPerContextFunctions, $function); | 737 push(@enabledPerContextFunctions, $function); |
| 716 } | 738 } |
| 717 } | 739 } |
| 718 | 740 |
| 719 if (IsConstructable($interface)) { | 741 if (IsConstructable($interface)) { |
| 720 $header{classPublic}->add(" static void constructorCallback(const v8:
:FunctionCallbackInfo<v8::Value>&);\n"); | 742 $header{classPublic}->add(" static void constructorCallback(const v8:
:FunctionCallbackInfo<v8::Value>&);\n"); |
| 721 END | 743 END |
| 722 } | 744 } |
| 723 if (HasCustomConstructor($interface)) { | 745 if (HasCustomConstructor($interface)) { |
| 724 $header{classPublic}->add(" static void constructorCustom(const v8::F
unctionCallbackInfo<v8::Value>&);\n"); | 746 $header{classPublic}->add(" static void constructorCustom(const v8::F
unctionCallbackInfo<v8::Value>&);\n"); |
| 725 } | 747 } |
| 726 | 748 |
| 727 my @enabledPerContextAttributes; | 749 my @enabledPerContextAttributes; |
| 728 foreach my $attribute (@{$interface->attributes}) { | 750 foreach my $attribute (@{$interface->attributes}) { |
| 729 my $name = $attribute->name; | 751 my $name = $attribute->name; |
| 730 my $attrExt = $attribute->extendedAttributes; | 752 my $attrExt = $attribute->extendedAttributes; |
| 731 my $conditionalString = GenerateConditionalString($attribute); | 753 my $conditionalString = GenerateConditionalString($attribute); |
| 732 if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) { | 754 # if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) { |
| 755 if (HasCustomGetter($attrExt)) { |
| 733 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio
nalString; | 756 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio
nalString; |
| 734 $header{classPublic}->add(<<END); | 757 $header{classPublic}->add(<<END); |
| 735 static void ${name}AttrGetterCustom(v8::Local<v8::String> name, const v8::Pr
opertyCallbackInfo<v8::Value>&); | 758 static void ${name}AttrGetterCustom(v8::Local<v8::String> name, const v8::Pr
opertyCallbackInfo<v8::Value>&); |
| 736 END | 759 END |
| 737 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co
nditionalString; | 760 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co
nditionalString; |
| 738 } | 761 } |
| 739 if (HasCustomSetter($attrExt) && !$attrExt->{"ImplementedBy"}) { | 762 # if (HasCustomSetter($attrExt) && !$attrExt->{"ImplementedBy"}) { |
| 763 if (HasCustomSetter($attrExt)) { |
| 740 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio
nalString; | 764 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio
nalString; |
| 741 $header{classPublic}->add(<<END); | 765 $header{classPublic}->add(<<END); |
| 742 static void ${name}AttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8
::Value>, const v8::PropertyCallbackInfo<void>&); | 766 static void ${name}AttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8
::Value>, const v8::PropertyCallbackInfo<void>&); |
| 743 END | 767 END |
| 744 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co
nditionalString; | 768 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co
nditionalString; |
| 745 } | 769 } |
| 746 if ($attrExt->{"EnabledPerContext"}) { | 770 if ($attrExt->{"EnabledPerContext"}) { |
| 747 push(@enabledPerContextAttributes, $attribute); | 771 push(@enabledPerContextAttributes, $attribute); |
| 748 } | 772 } |
| 749 } | 773 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 template<> | 840 template<> |
| 817 class WrapperTypeTraits<${nativeType} > { | 841 class WrapperTypeTraits<${nativeType} > { |
| 818 public: | 842 public: |
| 819 static WrapperTypeInfo* info() { return &${v8ClassName}::info; } | 843 static WrapperTypeInfo* info() { return &${v8ClassName}::info; } |
| 820 }; | 844 }; |
| 821 | 845 |
| 822 END | 846 END |
| 823 | 847 |
| 824 my $customWrap = $interface->extendedAttributes->{"CustomToV8"}; | 848 my $customWrap = $interface->extendedAttributes->{"CustomToV8"}; |
| 825 if ($noToV8) { | 849 if ($noToV8) { |
| 826 die "Can't suppress toV8 for subclass\n" if @parents; | 850 my $hasParent = 0; |
| 851 ForAllParents($interface, sub { |
| 852 my $parent = shift; |
| 853 $hasParent = 1; |
| 854 }); |
| 855 die "Can't suppress toV8 for subclass\n" if $hasParent; |
| 827 } elsif ($noWrap) { | 856 } elsif ($noWrap) { |
| 828 die "Must have custom toV8\n" if !$customWrap; | 857 die "Must have custom toV8\n" if !$customWrap; |
| 829 $header{nameSpaceWebCore}->add(<<END); | 858 $header{nameSpaceWebCore}->add(<<END); |
| 830 class ${nativeType}; | 859 class ${nativeType}; |
| 831 v8::Handle<v8::Value> toV8(${nativeType}*, v8::Handle<v8::Object> creationContex
t, v8::Isolate*); | 860 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*); | 861 v8::Handle<v8::Value> toV8ForMainWorld(${nativeType}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); |
| 833 | 862 |
| 834 template<class HolderContainer, class Wrappable> | 863 template<class HolderContainer, class Wrappable> |
| 835 inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer
& container, Wrappable*) | 864 inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer
& container, Wrappable*) |
| 836 { | 865 { |
| (...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3830 my $interface = shift; | 3859 my $interface = shift; |
| 3831 my $code = ""; | 3860 my $code = ""; |
| 3832 | 3861 |
| 3833 if ($interface->extendedAttributes->{"MasqueradesAsUndefined"}) | 3862 if ($interface->extendedAttributes->{"MasqueradesAsUndefined"}) |
| 3834 { | 3863 { |
| 3835 $code .= " desc->InstanceTemplate()->MarkAsUndetectable();\n"; | 3864 $code .= " desc->InstanceTemplate()->MarkAsUndetectable();\n"; |
| 3836 } | 3865 } |
| 3837 return $code; | 3866 return $code; |
| 3838 } | 3867 } |
| 3839 | 3868 |
| 3869 # __IMPL__ |
| 3840 sub GenerateImplementation | 3870 sub GenerateImplementation |
| 3841 { | 3871 { |
| 3842 my $object = shift; | 3872 my $object = shift; |
| 3843 my $interface = shift; | 3873 my $interface = shift; |
| 3844 my $interfaceName = $interface->name; | 3874 my $interfaceName = $interface->name; |
| 3845 my $implClassName = GetImplName($interface); | 3875 my $implClassName = GetImplName($interface); |
| 3846 my $v8ClassName = GetV8ClassName($interface); | 3876 my $v8ClassName = GetV8ClassName($interface); |
| 3847 my $nativeType = GetNativeTypeForConversions($interface); | 3877 my $nativeType = GetNativeTypeForConversions($interface); |
| 3848 | 3878 |
| 3849 AddToImplIncludes("bindings/v8/V8Binding.h"); | 3879 AddToImplIncludes("bindings/v8/V8Binding.h"); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4198 v8::Local<v8::Signature> defaultSignature; | 4228 v8::Local<v8::Signature> defaultSignature; |
| 4199 END | 4229 END |
| 4200 if ($interface->extendedAttributes->{"EnabledAtRuntime"}) { | 4230 if ($interface->extendedAttributes->{"EnabledAtRuntime"}) { |
| 4201 my $enable_function = GetRuntimeEnableFunctionName($interface); | 4231 my $enable_function = GetRuntimeEnableFunctionName($interface); |
| 4202 $code .= <<END; | 4232 $code .= <<END; |
| 4203 if (!${enable_function}()) | 4233 if (!${enable_function}()) |
| 4204 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"\", $pa
rentClassTemplate, ${v8ClassName}::internalFieldCount, 0, 0, 0, 0, isolate, curr
entWorldType); | 4234 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"\", $pa
rentClassTemplate, ${v8ClassName}::internalFieldCount, 0, 0, 0, 0, isolate, curr
entWorldType); |
| 4205 else | 4235 else |
| 4206 END | 4236 END |
| 4207 } | 4237 } |
| 4238 =memo |
| 4239 static v8::Local<v8::Signature> configureTemplate( |
| 4240 v8::Handle<v8::FunctionTemplate>, |
| 4241 const char* interfaceName, |
| 4242 v8::Handle<v8::FunctionTemplate> parentClass, |
| 4243 size_t fieldCount, |
| 4244 |
| 4245 const BatchedAttribute*, |
| 4246 size_t attributeCount, |
| 4247 const BatchedMethod*, |
| 4248 size_t callbackCount, |
| 4249 v8::Isolate*, |
| 4250 WrapperWorldType); |
| 4251 =cut |
| 4208 $code .= <<END; | 4252 $code .= <<END; |
| 4209 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"${interface
Name}\", $parentClassTemplate, ${v8ClassName}::internalFieldCount, | 4253 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"${interface
Name}\", $parentClassTemplate, ${v8ClassName}::internalFieldCount, |
| 4210 END | 4254 END |
| 4211 # Set up our attributes if we have them | 4255 # Set up our attributes if we have them |
| 4212 if ($has_attributes) { | 4256 if ($has_attributes) { |
| 4213 $code .= <<END; | 4257 $code .= <<END; |
| 4214 ${v8ClassName}Attrs, WTF_ARRAY_LENGTH(${v8ClassName}Attrs), | 4258 ${v8ClassName}Attrs, WTF_ARRAY_LENGTH(${v8ClassName}Attrs), |
| 4215 END | 4259 END |
| 4216 } else { | 4260 } else { |
| 4217 $code .= <<END; | 4261 $code .= <<END; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4547 { | 4591 { |
| 4548 ASSERT(value->IsObject()); | 4592 ASSERT(value->IsObject()); |
| 4549 ASSERT(context); | 4593 ASSERT(context); |
| 4550 return adoptRef(new ${v8ClassName}(v8::Handle<v8::Object>::Cast(value),
context)); | 4594 return adoptRef(new ${v8ClassName}(v8::Handle<v8::Object>::Cast(value),
context)); |
| 4551 } | 4595 } |
| 4552 | 4596 |
| 4553 virtual ~${v8ClassName}(); | 4597 virtual ~${v8ClassName}(); |
| 4554 | 4598 |
| 4555 END | 4599 END |
| 4556 | 4600 |
| 4601 #print "[CallbackHeader]", $interface->name, "\n"; |
| 4602 |
| 4557 # Functions | 4603 # Functions |
| 4558 my $numFunctions = @{$interface->functions}; | 4604 my $numFunctions = @{$interface->functions}; |
| 4559 if ($numFunctions > 0) { | 4605 if ($numFunctions > 0) { |
| 4560 $header{classPublic}->add(" // Functions\n"); | 4606 $header{classPublic}->add(" // Functions\n"); |
| 4561 foreach my $function (@{$interface->functions}) { | 4607 foreach my $function (@{$interface->functions}) { |
| 4562 my $code = " virtual " . GetNativeTypeForCallbacks($function->typ
e) . " " . $function->name . "("; | 4608 my $code = " virtual " . GetNativeTypeForCallbacks($function->typ
e) . " " . $function->name . "("; |
| 4563 | 4609 |
| 4564 my @args = (); | 4610 my @args = (); |
| 4565 my @params = @{$function->parameters}; | 4611 my @params = @{$function->parameters}; |
| 4566 foreach my $param (@params) { | 4612 foreach my $param (@params) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4606 | 4652 |
| 4607 END | 4653 END |
| 4608 | 4654 |
| 4609 $implementation{nameSpaceWebCore}->add(<<END); | 4655 $implementation{nameSpaceWebCore}->add(<<END); |
| 4610 ${v8ClassName}::~${v8ClassName}() | 4656 ${v8ClassName}::~${v8ClassName}() |
| 4611 { | 4657 { |
| 4612 } | 4658 } |
| 4613 | 4659 |
| 4614 END | 4660 END |
| 4615 | 4661 |
| 4662 #print "[CallbackImp]", $interface->name, "\n"; |
| 4663 |
| 4616 # Functions | 4664 # Functions |
| 4617 my $numFunctions = @{$interface->functions}; | 4665 my $numFunctions = @{$interface->functions}; |
| 4618 if ($numFunctions > 0) { | 4666 if ($numFunctions > 0) { |
| 4619 $implementation{nameSpaceWebCore}->add("// Functions\n"); | 4667 $implementation{nameSpaceWebCore}->add("// Functions\n"); |
| 4620 foreach my $function (@{$interface->functions}) { | 4668 foreach my $function (@{$interface->functions}) { |
| 4621 my $code = ""; | 4669 my $code = ""; |
| 4622 my @params = @{$function->parameters}; | 4670 my @params = @{$function->parameters}; |
| 4623 next if $function->extendedAttributes->{"Custom"}; | 4671 next if $function->extendedAttributes->{"Custom"}; |
| 4624 | 4672 |
| 4625 AddIncludesForType($function->type); | 4673 AddIncludesForType($function->type); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4990 $type .= "<$mode>"; | 5038 $type .= "<$mode>"; |
| 4991 } | 5039 } |
| 4992 | 5040 |
| 4993 return $type; | 5041 return $type; |
| 4994 } | 5042 } |
| 4995 | 5043 |
| 4996 sub GetNativeType | 5044 sub GetNativeType |
| 4997 { | 5045 { |
| 4998 my $type = shift; | 5046 my $type = shift; |
| 4999 my $isParameter = shift; | 5047 my $isParameter = shift; |
| 5048 my $isw = IsWrapperType($type) ? "WT":""; |
| 5049 print "[GetNativeType] $type, $isParameter $isw\n" if $type eq "ObjectArray"; |
| 5000 | 5050 |
| 5001 my $svgNativeType = GetSVGTypeNeedingTearOff($type); | 5051 my $svgNativeType = GetSVGTypeNeedingTearOff($type); |
| 5002 if ($svgNativeType) { | 5052 if ($svgNativeType) { |
| 5003 if ($svgNativeType =~ /List$/) { | 5053 if ($svgNativeType =~ /List$/) { |
| 5004 return "${svgNativeType}*"; | 5054 return "${svgNativeType}*"; |
| 5005 } else { | 5055 } else { |
| 5006 return "RefPtr<${svgNativeType} >"; | 5056 return "RefPtr<${svgNativeType} >"; |
| 5007 } | 5057 } |
| 5008 } | 5058 } |
| 5009 | 5059 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5025 return "Dictionary" if $type eq "Dictionary"; | 5075 return "Dictionary" if $type eq "Dictionary"; |
| 5026 | 5076 |
| 5027 return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; | 5077 return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; |
| 5028 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"
; | 5078 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"
; |
| 5029 return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; | 5079 return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; |
| 5030 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; | 5080 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; |
| 5031 return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; | 5081 return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; |
| 5032 | 5082 |
| 5033 die "UnionType is not supported" if IsUnionType($type); | 5083 die "UnionType is not supported" if IsUnionType($type); |
| 5034 | 5084 |
| 5085 print "[GetNativeType] here\n" if $type eq "ObjectArray"; |
| 5035 # We need to check [ImplementedAs] extended attribute for wrapper types. | 5086 # We need to check [ImplementedAs] extended attribute for wrapper types. |
| 5036 if (IsWrapperType($type)) { | 5087 if (IsWrapperType($type)) { |
| 5037 my $interface = ParseInterface($type); | 5088 my $interface = ParseInterface($type); |
| 5038 my $implClassName = GetImplName($interface); | 5089 my $implClassName = GetImplName($interface); |
| 5039 return $isParameter ? "${implClassName}*" : "RefPtr<${implClassName}>"; | 5090 return $isParameter ? "${implClassName}*" : "RefPtr<${implClassName}>"; |
| 5040 } | 5091 } |
| 5041 return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter; | 5092 return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter; |
| 5042 | 5093 |
| 5043 my $arrayOrSequenceType = GetArrayOrSequenceType($type); | 5094 my $arrayOrSequenceType = GetArrayOrSequenceType($type); |
| 5044 | 5095 |
| 5045 if ($arrayOrSequenceType) { | 5096 if ($arrayOrSequenceType) { |
| 5046 my $nativeType = GetNativeType($arrayOrSequenceType); | 5097 my $nativeType = GetNativeType($arrayOrSequenceType); |
| 5047 $nativeType .= " " if ($nativeType =~ />$/); | 5098 $nativeType .= " " if ($nativeType =~ />$/); |
| 5048 return "Vector<${nativeType}>"; | 5099 return "Vector<${nativeType}>"; |
| 5049 } | 5100 } |
| 5050 | 5101 |
| 5051 # Default, assume native type is a pointer with same type name as idl type | 5102 # Default, assume native type is a pointer with same type name as idl type |
| 5052 return "${type}*"; | 5103 return "${type}*"; |
| 5053 } | 5104 } |
| 5054 | 5105 |
| 5055 sub GetNativeTypeForCallbacks | 5106 sub GetNativeTypeForCallbacks |
| 5056 { | 5107 { |
| 5057 my $type = shift; | 5108 my $type = shift; |
| 5109 # print "#####\n[Callback] DOMString\n" if $type eq "DOMString"; |
| 5110 # print "#####\n[Callback] SerializedScriptValue\n" if $type eq "SerializedSc
riptValue"; |
| 5111 |
| 5058 return "const String&" if $type eq "DOMString"; | 5112 return "const String&" if $type eq "DOMString"; |
| 5059 return "PassRefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValu
e"; | 5113 return "PassRefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValu
e"; |
| 5060 | 5114 |
| 5061 # Callbacks use raw pointers, so pass isParameter = 1 | 5115 # Callbacks use raw pointers, so pass isParameter = 1 |
| 5062 return GetNativeType($type, 1); | 5116 return GetNativeType($type, 1); |
| 5063 } | 5117 } |
| 5064 | 5118 |
| 5065 sub JSValueToNative | 5119 sub JSValueToNative |
| 5066 { | 5120 { |
| 5067 my $type = shift; | 5121 my $type = shift; |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5547 } | 5601 } |
| 5548 open FH, ">", $fileName or die "Couldn't open $fileName: $!\n"; | 5602 open FH, ">", $fileName or die "Couldn't open $fileName: $!\n"; |
| 5549 print FH $contents; | 5603 print FH $contents; |
| 5550 close FH; | 5604 close FH; |
| 5551 } | 5605 } |
| 5552 | 5606 |
| 5553 sub ForAllParents | 5607 sub ForAllParents |
| 5554 { | 5608 { |
| 5555 my $interface = shift; | 5609 my $interface = shift; |
| 5556 my $beforeRecursion = shift; | 5610 my $beforeRecursion = shift; |
| 5557 my $afterRecursion = shift; | |
| 5558 | 5611 |
| 5559 my $recurse; | 5612 my $recurse; |
| 5560 $recurse = sub { | 5613 $recurse = sub { |
| 5561 my $currentInterface = shift; | 5614 my $currentInterface = shift; |
| 5562 | 5615 |
| 5563 for (@{$currentInterface->parents}) { | 5616 for (@{$currentInterface->parents}) { |
| 5564 my $interfaceName = $_; | 5617 my $interfaceName = $_; |
| 5565 my $parentInterface = ParseInterface($interfaceName); | 5618 my $parentInterface = ParseInterface($interfaceName); |
| 5566 | 5619 |
| 5567 if ($beforeRecursion) { | 5620 if ($beforeRecursion) { |
| 5568 &$beforeRecursion($parentInterface) eq 'prune' and next; | 5621 &$beforeRecursion($parentInterface) eq 'prune' and next; |
| 5569 } | 5622 } |
| 5570 &$recurse($parentInterface); | 5623 &$recurse($parentInterface); |
| 5571 &$afterRecursion($parentInterface) if $afterRecursion; | |
| 5572 } | 5624 } |
| 5573 }; | 5625 }; |
| 5574 | 5626 |
| 5575 &$recurse($interface); | 5627 &$recurse($interface); |
| 5576 } | 5628 } |
| 5577 | 5629 |
| 5578 sub AddMethodsConstantsAndAttributesFromParentInterfaces | 5630 sub AddMethodsConstantsAndAttributesFromParentInterfaces |
| 5579 { | 5631 { |
| 5580 # Add to $interface all of its inherited interface members, except for those | 5632 # Add to $interface all of its inherited interface members, except for those |
| 5581 # inherited through $interface's first listed parent. If an array reference | 5633 # inherited through $interface's first listed parent. If an array reference |
| 5582 # is passed in as $parents, the names of all ancestor interfaces visited | 5634 # is passed in as $parents, the names of all ancestor interfaces visited |
| 5583 # will be appended to the array. The names of $interface's first listed pare
nt | 5635 # will be appended to the array. The names of $interface's first listed pare
nt |
| 5584 # and its ancestors will also be appended to $parents. | 5636 # and its ancestors will also be appended to $parents. |
| 5585 | 5637 |
| 5586 my $interface = shift; | 5638 my $interface = shift; |
| 5587 my $parents = shift; | |
| 5588 | 5639 |
| 5589 my $first = 1; | 5640 my $first = 1; |
| 5590 ForAllParents($interface, sub { | 5641 ForAllParents($interface, sub { |
| 5591 my $currentInterface = shift; | 5642 my $currentInterface = shift; |
| 5592 | 5643 |
| 5593 if ($first) { | 5644 if ($first) { |
| 5594 # Ignore first parent class, already handled by the generation itsel
f. | 5645 # Ignore first parent class, already handled by the generation itsel
f. |
| 5595 $first = 0; | 5646 $first = 0; |
| 5596 | 5647 |
| 5597 # Just collect the names of the direct ancestor interfaces, | |
| 5598 # if necessary. | |
| 5599 push(@$parents, $currentInterface->name); | |
| 5600 ForAllParents($currentInterface, sub { | |
| 5601 my $currentInterface = shift; | |
| 5602 push(@$parents, $currentInterface->name); | |
| 5603 }); | |
| 5604 return 'prune'; | 5648 return 'prune'; |
| 5605 } | 5649 } |
| 5606 | 5650 |
| 5607 # Collect the name of this additional parent. | 5651 # SVG* only! |
| 5608 push(@$parents, $currentInterface->name) if $parents; | 5652 # print $interface->name, "[Came here with]", $currentInterface->name, "\
n"; |
| 5609 | |
| 5610 # Add this parent's members to $interface. | 5653 # Add this parent's members to $interface. |
| 5611 push(@{$interface->constants}, @{$currentInterface->constants}); | 5654 push(@{$interface->constants}, @{$currentInterface->constants}); |
| 5612 push(@{$interface->functions}, @{$currentInterface->functions}); | 5655 push(@{$interface->functions}, @{$currentInterface->functions}); |
| 5613 push(@{$interface->attributes}, @{$currentInterface->attributes}); | 5656 push(@{$interface->attributes}, @{$currentInterface->attributes}); |
| 5614 }); | 5657 }); |
| 5615 } | 5658 } |
| 5616 | 5659 |
| 5617 sub FindSuperMethod | 5660 sub FindSuperMethod |
| 5618 { | 5661 { |
| 5619 my ($interface, $functionName) = @_; | 5662 my ($interface, $functionName) = @_; |
| 5620 my $indexer; | 5663 my $indexer; |
| 5621 ForAllParents($interface, undef, sub { | 5664 ForAllParents($interface, sub { |
| 5622 my $currentInterface = shift; | 5665 my $currentInterface = shift; |
| 5623 foreach my $function (@{$currentInterface->functions}) { | 5666 foreach my $function (@{$currentInterface->functions}) { |
| 5624 if ($function->name eq $functionName) { | 5667 if ($function->name eq $functionName) { |
| 5625 $indexer = $function; | 5668 $indexer = $function; |
| 5626 return 'prune'; | 5669 return 'prune'; |
| 5627 } | 5670 } |
| 5628 } | 5671 } |
| 5629 }); | 5672 }); |
| 5630 return $indexer; | 5673 return $indexer; |
| 5631 } | 5674 } |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6036 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 6079 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
| 6037 $found = 1; | 6080 $found = 1; |
| 6038 } | 6081 } |
| 6039 return 1 if $found; | 6082 return 1 if $found; |
| 6040 }, 0); | 6083 }, 0); |
| 6041 | 6084 |
| 6042 return $found; | 6085 return $found; |
| 6043 } | 6086 } |
| 6044 | 6087 |
| 6045 1; | 6088 1; |
| OLD | NEW |