Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: Source/bindings/scripts/preprocess-idls.pl

Issue 14179013: Add support for [NoInterfaceObject] extended attribute to bindings generator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Take Adam's feedback into consideration Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/scripts/IDLParser.pm ('k') | Source/core/css/CSSFontFaceLoadEvent.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/preprocess-idls.pl
diff --git a/Source/bindings/scripts/preprocess-idls.pl b/Source/bindings/scripts/preprocess-idls.pl
index 1f3190eb48f424d49bcf7fe643733c1a329e7b61..ba0e842a35966cf18d313fb2431bebe1b18b3714 100644
--- a/Source/bindings/scripts/preprocess-idls.pl
+++ b/Source/bindings/scripts/preprocess-idls.pl
@@ -23,20 +23,24 @@ use strict;
use File::Basename;
use Getopt::Long;
use Cwd;
+use IDLParser;
my $defines;
my $preprocessor;
my $idlFilesList;
my $supplementalDependencyFile;
+my $windowConstructorsSupplementalFile;
my $supplementalMakefileDeps;
GetOptions('defines=s' => \$defines,
'preprocessor=s' => \$preprocessor,
'idlFilesList=s' => \$idlFilesList,
'supplementalDependencyFile=s' => \$supplementalDependencyFile,
+ 'windowConstructorsSupplementalFile=s' => \$windowConstructorsSupplementalFile,
'supplementalMakefileDeps=s' => \$supplementalMakefileDeps);
die('Must specify an output file using --supplementalDependencyFile.') unless defined($supplementalDependencyFile);
+die('Must specify an output file using --windowConstructorsSupplementalFile.') unless defined($windowConstructorsSupplementalFile);
die('Must specify the file listing all IDLs using --idlFilesList.') unless defined($idlFilesList);
open FH, "< $idlFilesList" or die "Cannot open $idlFilesList\n";
@@ -49,18 +53,37 @@ my %interfaceNameToIdlFile;
my %idlFileToInterfaceName;
my %supplementalDependencies;
my %supplementals;
+my $constructorAttributesCode = "";
foreach my $idlFile (@idlFiles) {
my $fullPath = Cwd::realpath($idlFile);
- my $partialInterfaceName = getPartialInterfaceNameFromIDLFile($fullPath);
- if ($partialInterfaceName) {
- $supplementalDependencies{$fullPath} = $partialInterfaceName;
+ my $parser = IDLParser->new(1);
+ my $document = $parser->Parse($fullPath, $defines, $preprocessor);
abarth-chromium 2013/05/06 18:06:48 How does this effect compile time? Previously, we
+ my $isPartialInterface = 0;
+ foreach my $interface (@{$document->interfaces}) {
+ if ($interface->isPartial) {
+ $supplementalDependencies{$fullPath} = $interface->name;
+ $isPartialInterface = 1;
+ last;
+ }
+ unless ($interface->isCallback || $interface->extendedAttributes->{"NoInterfaceObject"}) {
+ $constructorAttributesCode .= GenerateConstructorAttribute($interface);
+ }
}
+ next if $isPartialInterface;
my $interfaceName = fileparse(basename($idlFile), ".idl");
$interfaceNameToIdlFile{$interfaceName} = $fullPath;
$idlFileToInterfaceName{$fullPath} = $interfaceName;
$supplementals{$fullPath} = [];
}
+# Generate DOMWindow Constructors partial interface.
+open PARTIAL_WINDOW_FH, "> $windowConstructorsSupplementalFile" or die "Cannot open $windowConstructorsSupplementalFile\n";
+print PARTIAL_WINDOW_FH "partial interface DOMWindow {\n";
+print PARTIAL_WINDOW_FH $constructorAttributesCode;
+print PARTIAL_WINDOW_FH "};\n";
+close PARTIAL_WINDOW_FH;
+$supplementalDependencies{$windowConstructorsSupplementalFile} = "DOMWindow";
+
# Resolves partial interfaces dependencies.
foreach my $idlFile (keys %supplementalDependencies) {
my $baseFile = $supplementalDependencies{$idlFile};
@@ -108,17 +131,30 @@ if ($supplementalMakefileDeps) {
close MAKE_FH;
}
-
-sub getPartialInterfaceNameFromIDLFile
+sub GenerateConstructorAttribute
{
- my $idlFile = shift;
-
- open FILE, "<", $idlFile;
- my @lines = <FILE>;
- close FILE;
-
- my $fileContents = join('', @lines);
- if ($fileContents =~ /partial\s+interface\s+(\w+)/gs) {
- return $1;
+ my $interface = shift;
+ my $code = " ";
+ my @extendedAttributesList;
+ foreach my $attributeName (keys $interface->extendedAttributes) {
+ next unless ($attributeName eq "Conditional" || $attributeName eq "EnabledAtRuntime" || $attributeName eq "EnabledPerContext");
+ my $extendedAttribute = $attributeName;
+ $extendedAttribute .= "=" . $interface->extendedAttributes->{$attributeName} unless $interface->extendedAttributes->{$attributeName} eq "VALUE_IS_MISSING";
+ push(@extendedAttributesList, $extendedAttribute);
+ }
+ $code .= "[" . join(', ', @extendedAttributesList) . "] " if @extendedAttributesList;
+ my $interfaceName = $interface->name;
+ $interfaceName = $interface->extendedAttributes->{"InterfaceName"} if $interface->extendedAttributes->{"InterfaceName"};
+ $interfaceName = $interface->extendedAttributes->{"ConstructorPrefix"} . $interfaceName if $interface->extendedAttributes->{"ConstructorPrefix"};
+ $code .= "attribute " . $interface->name . "Constructor $interfaceName;\n";
+
+ # In addition to the regular property, for every [NamedConstructor] extended attribute on an interface,
+ # a corresponding property MUST exist on the ECMAScript global object.
+ if ($interface->extendedAttributes->{"NamedConstructor"}) {
+ my $constructorName = $interface->extendedAttributes->{"NamedConstructor"};
+ $code .= " ";
+ $code .= "[" . join(', ', @extendedAttributesList) . "] " if @extendedAttributesList;
+ $code .= "attribute " . $interface->name . "ConstructorConstructor $constructorName;\n";
}
+ return $code;
}
« no previous file with comments | « Source/bindings/scripts/IDLParser.pm ('k') | Source/core/css/CSSFontFaceLoadEvent.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698