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

Side by Side Diff: Source/bindings/scripts/generate-bindings.pl

Issue 17031006: Rename DOMWindow interface to Window (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/scripts/CodeGeneratorV8.pm ('k') | Source/bindings/scripts/preprocess_idls.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/perl -w 1 #!/usr/bin/perl -w
2 # 2 #
3 # Copyright (C) 2005 Apple Computer, Inc. 3 # Copyright (C) 2005 Apple Computer, Inc.
4 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 4 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
5 # 5 #
6 # This file is part of WebKit 6 # This file is part of WebKit
7 # 7 #
8 # This library is free software; you can redistribute it and/or 8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Library General Public 9 # modify it under the terms of the GNU Library General Public
10 # License as published by the Free Software Foundation; either 10 # License as published by the Free Software Foundation; either
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 if ($verbose) { 77 if ($verbose) {
78 print "$targetIdlFile\n"; 78 print "$targetIdlFile\n";
79 } 79 }
80 my $targetInterfaceName = fileparse(basename($targetIdlFile), ".idl"); 80 my $targetInterfaceName = fileparse(basename($targetIdlFile), ".idl");
81 81
82 my $idlFound = 0; 82 my $idlFound = 0;
83 my @supplementedIdlFiles; 83 my @supplementedIdlFiles;
84 if ($supplementalDependencyFile) { 84 if ($supplementalDependencyFile) {
85 # The format of a supplemental dependency file: 85 # The format of a supplemental dependency file:
86 # 86 #
87 # DOMWindow.idl P.idl Q.idl R.idl 87 # Window.idl P.idl Q.idl R.idl
88 # Document.idl S.idl 88 # Document.idl S.idl
89 # Event.idl 89 # Event.idl
90 # ... 90 # ...
91 # 91 #
92 # The above indicates that DOMWindow.idl is supplemented by P.idl, Q.idl and R.idl, 92 # The above indicates that Window.idl is supplemented by P.idl, Q.idl and R. idl,
93 # Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs. 93 # Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs.
94 # The IDL that supplements another IDL (e.g. P.idl) never appears in the dep endency file. 94 # The IDL that supplements another IDL (e.g. P.idl) never appears in the dep endency file.
95 open FH, "< $supplementalDependencyFile" or die "Cannot open $supplementalDe pendencyFile\n"; 95 open FH, "< $supplementalDependencyFile" or die "Cannot open $supplementalDe pendencyFile\n";
96 while (my $line = <FH>) { 96 while (my $line = <FH>) {
97 my ($idlFile, @followingIdlFiles) = split(/\s+/, $line); 97 my ($idlFile, @followingIdlFiles) = split(/\s+/, $line);
98 if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) { 98 if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) {
99 $idlFound = 1; 99 $idlFound = 1;
100 @supplementedIdlFiles = @followingIdlFiles; 100 @supplementedIdlFiles = @followingIdlFiles;
101 } 101 }
102 } 102 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 143 }
144 } 144 }
145 die "Not found an interface ${targetInterfaceName} in ${targetInterf aceName}.idl." unless defined $targetDataNode; 145 die "Not found an interface ${targetInterfaceName} in ${targetInterf aceName}.idl." unless defined $targetDataNode;
146 146
147 # Support for attributes of partial interfaces. 147 # Support for attributes of partial interfaces.
148 foreach my $attribute (@{$interface->attributes}) { 148 foreach my $attribute (@{$interface->attributes}) {
149 # Record that this attribute is implemented by $interfaceName. 149 # Record that this attribute is implemented by $interfaceName.
150 $attribute->signature->extendedAttributes->{"ImplementedBy"} = $ interfaceName; 150 $attribute->signature->extendedAttributes->{"ImplementedBy"} = $ interfaceName;
151 151
152 # Add interface-wide extended attributes to each attribute. 152 # Add interface-wide extended attributes to each attribute.
153 foreach my $extendedAttributeName (keys %{$interface->extendedAt tributes}) { 153 applyInterfaceExtendedAttributes($interface, $attribute->signatu re->extendedAttributes);
154 $attribute->signature->extendedAttributes->{$extendedAttribu teName} = $interface->extendedAttributes->{$extendedAttributeName}; 154
155 }
156 push(@{$targetDataNode->attributes}, $attribute); 155 push(@{$targetDataNode->attributes}, $attribute);
157 } 156 }
158 157
159 # Support for methods of partial interfaces. 158 # Support for methods of partial interfaces.
160 foreach my $function (@{$interface->functions}) { 159 foreach my $function (@{$interface->functions}) {
161 # Record that this method is implemented by $interfaceName. 160 # Record that this method is implemented by $interfaceName.
162 $function->extendedAttributes->{"ImplementedBy"} = $interfaceNam e; 161 $function->extendedAttributes->{"ImplementedBy"} = $interfaceNam e;
163 162
164 # Add interface-wide extended attributes to each method. 163 # Add interface-wide extended attributes to each method.
165 foreach my $extendedAttributeName (keys %{$interface->extendedAt tributes}) { 164 applyInterfaceExtendedAttributes($interface, $function->extended Attributes);
166 $function->extendedAttributes->{$extendedAttributeName} = $i nterface->extendedAttributes->{$extendedAttributeName}; 165
167 }
168 push(@{$targetDataNode->functions}, $function); 166 push(@{$targetDataNode->functions}, $function);
169 } 167 }
170 168
171 # Support for constants of partial interfaces. 169 # Support for constants of partial interfaces.
172 foreach my $constant (@{$interface->constants}) { 170 foreach my $constant (@{$interface->constants}) {
173 # Record that this constant is implemented by $interfaceName. 171 # Record that this constant is implemented by $interfaceName.
174 $constant->extendedAttributes->{"ImplementedBy"} = $interfaceNam e; 172 $constant->extendedAttributes->{"ImplementedBy"} = $interfaceNam e;
175 173
176 # Add interface-wide extended attributes to each constant. 174 # Add interface-wide extended attributes to each constant.
177 foreach my $extendedAttributeName (keys %{$interface->extendedAt tributes}) { 175 applyInterfaceExtendedAttributes($interface, $constant->extended Attributes);
178 $constant->extendedAttributes->{$extendedAttributeName} = $i nterface->extendedAttributes->{$extendedAttributeName}; 176
179 }
180 push(@{$targetDataNode->constants}, $constant); 177 push(@{$targetDataNode->constants}, $constant);
181 } 178 }
182 } else { 179 } else {
183 die "$idlFile is not a supplemental dependency of $targetIdlFile. Th ere maybe a bug in the the supplemental dependency generator (preprocess_idls.py ).\n"; 180 die "$idlFile is not a supplemental dependency of $targetIdlFile. Th ere maybe a bug in the the supplemental dependency generator (preprocess_idls.py ).\n";
184 } 181 }
185 } 182 }
186 } 183 }
187 184
188 # FIXME: This code will be removed once IDLParser.pm and CodeGeneratorV8.pm 185 # FIXME: This code will be removed once IDLParser.pm and CodeGeneratorV8.pm
189 # are connected via JSON files. See http://crbug.com/242795 186 # are connected via JSON files. See http://crbug.com/242795
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 265
269 foreach my $function (@{$interface->functions}) { 266 foreach my $function (@{$interface->functions}) {
270 checkIfIDLAttributesExists($idlAttributes, $function->extendedAttrib utes, $idlFile); 267 checkIfIDLAttributesExists($idlAttributes, $function->extendedAttrib utes, $idlFile);
271 foreach my $parameter (@{$function->parameters}) { 268 foreach my $parameter (@{$function->parameters}) {
272 checkIfIDLAttributesExists($idlAttributes, $parameter->extendedA ttributes, $idlFile); 269 checkIfIDLAttributesExists($idlAttributes, $parameter->extendedA ttributes, $idlFile);
273 } 270 }
274 } 271 }
275 } 272 }
276 } 273 }
277 274
275 sub applyInterfaceExtendedAttributes
276 {
277 my $interface = shift;
278 my $extendedAttributes = shift;
279
280 foreach my $extendedAttributeName (keys %{$interface->extendedAttributes}) {
281 next if $extendedAttributeName eq "ImplementedAs";
282 $extendedAttributes->{$extendedAttributeName} = $interface->extendedAttr ibutes->{$extendedAttributeName};
283 }
284 }
285
278 sub checkIfIDLAttributesExists 286 sub checkIfIDLAttributesExists
279 { 287 {
280 my $idlAttributes = shift; 288 my $idlAttributes = shift;
281 my $extendedAttributes = shift; 289 my $extendedAttributes = shift;
282 my $idlFile = shift; 290 my $idlFile = shift;
283 291
284 my $error; 292 my $error;
285 OUTER: for my $name (keys %$extendedAttributes) { 293 OUTER: for my $name (keys %$extendedAttributes) {
286 if (!exists $idlAttributes->{$name}) { 294 if (!exists $idlAttributes->{$name}) {
287 $error = "Unknown IDL attribute [$name] is found at $idlFile."; 295 $error = "Unknown IDL attribute [$name] is found at $idlFile.";
288 last OUTER; 296 last OUTER;
289 } 297 }
290 if ($idlAttributes->{$name}{"*"}) { 298 if ($idlAttributes->{$name}{"*"}) {
291 next; 299 next;
292 } 300 }
293 for my $rightValue (split /\s*\|\s*/, $extendedAttributes->{$name}) { 301 for my $rightValue (split /\s*\|\s*/, $extendedAttributes->{$name}) {
294 if (!exists $idlAttributes->{$name}{$rightValue}) { 302 if (!exists $idlAttributes->{$name}{$rightValue}) {
295 $error = "Unknown IDL attribute [$name=" . $extendedAttributes-> {$name} . "] is found at $idlFile."; 303 $error = "Unknown IDL attribute [$name=" . $extendedAttributes-> {$name} . "] is found at $idlFile.";
296 last OUTER; 304 last OUTER;
297 } 305 }
298 } 306 }
299 } 307 }
300 if ($error) { 308 if ($error) {
301 die "IDL ATTRIBUTE CHECKER ERROR: $error 309 die "IDL ATTRIBUTE CHECKER ERROR: $error
302 If you want to add a new IDL attribute, you need to add it to bindings/scripts/I DLAttributes.txt and add explanations to the Blink IDL document (http://chromium .org/blink/webidl). 310 If you want to add a new IDL attribute, you need to add it to bindings/scripts/I DLAttributes.txt and add explanations to the Blink IDL document (http://chromium .org/blink/webidl).
303 "; 311 ";
304 } 312 }
305 } 313 }
OLDNEW
« no previous file with comments | « Source/bindings/scripts/CodeGeneratorV8.pm ('k') | Source/bindings/scripts/preprocess_idls.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698