diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/bindings/scripts/generate-bindings.pl | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/bindings/scripts/generate-bindings.pl')
-rwxr-xr-x | Source/WebCore/bindings/scripts/generate-bindings.pl | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/Source/WebCore/bindings/scripts/generate-bindings.pl b/Source/WebCore/bindings/scripts/generate-bindings.pl index f93434e40..1048a512e 100755 --- a/Source/WebCore/bindings/scripts/generate-bindings.pl +++ b/Source/WebCore/bindings/scripts/generate-bindings.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# Copyright (C) 2005 Apple Computer, Inc. +# Copyright (C) 2005 Apple Inc. # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> # # This file is part of WebKit @@ -29,6 +29,8 @@ # <rdar://problems/4251781&4251785> use strict; +use FindBin; +use lib '.', $FindBin::Bin; use File::Path; use File::Basename; @@ -80,7 +82,7 @@ $targetIdlFile = Cwd::realpath($targetIdlFile); if ($verbose) { print "$generator: $targetIdlFile\n"; } -my $targetInterfaceName = fileparse(basename($targetIdlFile), ".idl"); +my $targetInterfaceName = fileparse($targetIdlFile, ".idl"); my $idlFound = 0; my @supplementedIdlFiles; @@ -98,7 +100,7 @@ if ($supplementalDependencyFile) { open FH, "< $supplementalDependencyFile" or die "Cannot open $supplementalDependencyFile\n"; while (my $line = <FH>) { my ($idlFile, @followingIdlFiles) = split(/\s+/, $line); - if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) { + if ($idlFile and fileparse($idlFile) eq fileparse($targetIdlFile)) { $idlFound = 1; @supplementedIdlFiles = sort @followingIdlFiles; } @@ -110,11 +112,11 @@ if ($supplementalDependencyFile) { # dependency file) but should generate .h and .cpp files. if (!$idlFound and $additionalIdlFiles) { my @idlFiles = shellwords($additionalIdlFiles); - $idlFound = grep { $_ and basename($_) eq basename($targetIdlFile) } @idlFiles; + $idlFound = grep { $_ and fileparse($_) eq fileparse($targetIdlFile) } @idlFiles; } if (!$idlFound) { - my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, 0, $preprocessor, $writeDependencies, $verbose); + my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, $preprocessor, $writeDependencies, $verbose); # We generate empty .h and .cpp files just to tell build scripts that .h and .cpp files are created. generateEmptyHeaderAndCpp($codeGen->FileNamePrefix(), $targetInterfaceName, $outputHeadersDirectory, $outputDirectory); @@ -128,22 +130,26 @@ my $targetDocument = $targetParser->Parse($targetIdlFile, $defines, $preprocesso if ($idlAttributesFile) { my $idlAttributes = loadIDLAttributes($idlAttributesFile); - checkIDLAttributes($idlAttributes, $targetDocument, basename($targetIdlFile)); + checkIDLAttributes($idlAttributes, $targetDocument, fileparse($targetIdlFile)); } foreach my $idlFile (@supplementedIdlFiles) { next if $idlFile eq $targetIdlFile; - my $interfaceName = fileparse(basename($idlFile), ".idl"); + my $interfaceName = fileparse($idlFile, ".idl"); my $parser = IDLParser->new(!$verbose); my $document = $parser->Parse($idlFile, $defines, $preprocessor); foreach my $interface (@{$document->interfaces}) { - if (!$interface->isPartial || $interface->name eq $targetInterfaceName) { + if (!$interface->isPartial || $interface->type->name eq $targetInterfaceName) { my $targetDataNode; + my @targetGlobalContexts; foreach my $interface (@{$targetDocument->interfaces}) { - if ($interface->name eq $targetInterfaceName) { + if ($interface->type->name eq $targetInterfaceName) { $targetDataNode = $interface; + my $exposedAttribute = $targetDataNode->extendedAttributes->{"Exposed"} || "Window"; + $exposedAttribute = substr($exposedAttribute, 1, -1) if substr($exposedAttribute, 0, 1) eq "("; + @targetGlobalContexts = split(",", $exposedAttribute); last; } } @@ -151,30 +157,36 @@ foreach my $idlFile (@supplementedIdlFiles) { # Support for attributes of partial interfaces. foreach my $attribute (@{$interface->attributes}) { + next unless shouldPropertyBeExposed($attribute, \@targetGlobalContexts); + # Record that this attribute is implemented by $interfaceName. - $attribute->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial; + $attribute->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial; # Add interface-wide extended attributes to each attribute. foreach my $extendedAttributeName (keys %{$interface->extendedAttributes}) { - $attribute->signature->extendedAttributes->{$extendedAttributeName} = $interface->extendedAttributes->{$extendedAttributeName}; + $attribute->extendedAttributes->{$extendedAttributeName} = $interface->extendedAttributes->{$extendedAttributeName}; } push(@{$targetDataNode->attributes}, $attribute); } # Support for methods of partial interfaces. foreach my $function (@{$interface->functions}) { + next unless shouldPropertyBeExposed($function, \@targetGlobalContexts); + # Record that this method is implemented by $interfaceName. - $function->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial; + $function->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial; # Add interface-wide extended attributes to each method. foreach my $extendedAttributeName (keys %{$interface->extendedAttributes}) { - $function->signature->extendedAttributes->{$extendedAttributeName} = $interface->extendedAttributes->{$extendedAttributeName}; + $function->extendedAttributes->{$extendedAttributeName} = $interface->extendedAttributes->{$extendedAttributeName}; } push(@{$targetDataNode->functions}, $function); } # Support for constants of partial interfaces. foreach my $constant (@{$interface->constants}) { + next unless shouldPropertyBeExposed($constant, \@targetGlobalContexts); + # Record that this constant is implemented by $interfaceName. $constant->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial; @@ -191,9 +203,28 @@ foreach my $idlFile (@supplementedIdlFiles) { } # Generate desired output for the target IDL file. -my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, 0, $preprocessor, $writeDependencies, $verbose, $targetIdlFile); +my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, $preprocessor, $writeDependencies, $verbose, $targetIdlFile); $codeGen->ProcessDocument($targetDocument, $defines); +# Attributes / Operations / Constants of supplemental interfaces can have an [Exposed=XX] attribute which restricts +# on which global contexts they should be exposed. +sub shouldPropertyBeExposed +{ + my ($context, $targetGlobalContexts) = @_; + + my $exposed = $context->extendedAttributes->{Exposed}; + + return 1 unless $exposed; + + $exposed = substr($exposed, 1, -1) if substr($exposed, 0, 1) eq "("; + my @sourceGlobalContexts = split(",", $exposed); + + for my $targetGlobalContext (@$targetGlobalContexts) { + return 1 if grep(/^$targetGlobalContext$/, @sourceGlobalContexts); + } + return 0; +} + sub generateEmptyHeaderAndCpp { my ($prefix, $targetInterfaceName, $outputHeadersDirectory, $outputDirectory) = @_; @@ -240,7 +271,7 @@ sub loadIDLAttributes $idlAttributes{$name}{"VALUE_IS_MISSING"} = 1; } } else { - die "The format of " . basename($idlAttributesFile) . " is wrong: line $.\n"; + die "The format of " . fileparse($idlAttributesFile) . " is wrong: line $.\n"; } } close FH; @@ -258,13 +289,13 @@ sub checkIDLAttributes checkIfIDLAttributesExists($idlAttributes, $interface->extendedAttributes, $idlFile); foreach my $attribute (@{$interface->attributes}) { - checkIfIDLAttributesExists($idlAttributes, $attribute->signature->extendedAttributes, $idlFile); + checkIfIDLAttributesExists($idlAttributes, $attribute->extendedAttributes, $idlFile); } foreach my $function (@{$interface->functions}) { - checkIfIDLAttributesExists($idlAttributes, $function->signature->extendedAttributes, $idlFile); - foreach my $parameter (@{$function->parameters}) { - checkIfIDLAttributesExists($idlAttributes, $parameter->extendedAttributes, $idlFile); + checkIfIDLAttributesExists($idlAttributes, $function->extendedAttributes, $idlFile); + foreach my $argument (@{$function->arguments}) { + checkIfIDLAttributesExists($idlAttributes, $argument->extendedAttributes, $idlFile); } } } |