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

Side by Side Diff: Source/bindings/scripts/CodeGenerator.pm

Issue 14179013: Add support for [NoInterfaceObject] extended attribute to bindings generator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 # 1 #
2 # WebKit IDL parser 2 # WebKit IDL parser
3 # 3 #
4 # Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org> 4 # Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org>
5 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 5 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
6 # Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 6 # Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
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 # 9 #
10 # This library is free software; you can redistribute it and/or 10 # This library is free software; you can redistribute it and/or
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 ); 84 );
85 85
86 my %svgTypeWithWritablePropertiesNeedingTearOff = ( 86 my %svgTypeWithWritablePropertiesNeedingTearOff = (
87 "SVGPoint" => 1, 87 "SVGPoint" => 1,
88 "SVGMatrix" => 1 88 "SVGMatrix" => 1
89 ); 89 );
90 90
91 # Cache of IDL file pathnames. 91 # Cache of IDL file pathnames.
92 my $idlFiles; 92 my $idlFiles;
93 my $cachedInterfaces = {}; 93 my $cachedInterfaces = {};
94 my $didCacheAllInterfaces = 0;
94 95
95 # Default constructor 96 # Default constructor
96 sub new 97 sub new
97 { 98 {
98 my $object = shift; 99 my $object = shift;
99 my $reference = { }; 100 my $reference = { };
100 101
101 $useDirectories = shift; 102 $useDirectories = shift;
102 $useOutputDir = shift; 103 $useOutputDir = shift;
103 $useOutputHeadersDir = shift; 104 $useOutputHeadersDir = shift;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 foreach my $function (@{$currentInterface->functions}) { 236 foreach my $function (@{$currentInterface->functions}) {
236 if ($function->signature->name eq $functionName) { 237 if ($function->signature->name eq $functionName) {
237 $indexer = $function->signature; 238 $indexer = $function->signature;
238 return 'prune'; 239 return 'prune';
239 } 240 }
240 } 241 }
241 }); 242 });
242 return $indexer; 243 return $indexer;
243 } 244 }
244 245
245 sub IDLFileForInterface 246 sub PopulateIDLFiles {
246 {
247 my $object = shift; 247 my $object = shift;
248 my $interfaceName = shift;
249 248
250 unless ($idlFiles) { 249 unless ($idlFiles) {
251 my $sourceRoot = $ENV{SOURCE_ROOT}; 250 my $sourceRoot = $ENV{SOURCE_ROOT};
252 my @directories = map { $_ = "$sourceRoot/$_" if $sourceRoot && -d "$sou rceRoot/$_"; $_ } @$useDirectories; 251 my @directories = map { $_ = "$sourceRoot/$_" if $sourceRoot && -d "$sou rceRoot/$_"; $_ } @$useDirectories;
253 push(@directories, "."); 252 push(@directories, ".");
254 253
255 $idlFiles = { }; 254 $idlFiles = { };
256 255
257 my $wanted = sub { 256 my $wanted = sub {
258 $idlFiles->{$1} = $File::Find::name if /^([A-Z].*)\.idl$/; 257 $idlFiles->{$1} = $File::Find::name if /^([A-Z].*)\.idl$/;
259 $File::Find::prune = 1 if /^\../; 258 $File::Find::prune = 1 if /^\../;
260 }; 259 };
261 find($wanted, @directories); 260 find($wanted, @directories);
262 } 261 }
262 }
263
264 sub GetAllInterfaces
265 {
266 my $object = shift;
267
268 unless ($didCacheAllInterfaces) {
haraken 2013/04/22 11:44:50 GetAllInterfaces() is called only once (i.e. from
269 $object->PopulateIDLFiles();
270
271 foreach my $filename (values $idlFiles) {
272 my $parser = IDLParser->new(1);
273 my $document = $parser->Parse($filename, $defines, $preprocessor);
274
275 foreach my $interface (@{$document->interfaces}) {
276 $cachedInterfaces->{$interface->name} = $interface;
277 }
278 }
279
280 $didCacheAllInterfaces = 1;
281 }
282
283 return (values $cachedInterfaces);
284 }
285
286 sub IDLFileForInterface
287 {
288 my $object = shift;
289 my $interfaceName = shift;
290
291 $object->PopulateIDLFiles();
263 292
264 return $idlFiles->{$interfaceName}; 293 return $idlFiles->{$interfaceName};
265 } 294 }
266 295
267 sub ParseInterface 296 sub ParseInterface
268 { 297 {
269 my $object = shift; 298 my $object = shift;
270 my $interfaceName = shift; 299 my $interfaceName = shift;
271 300
272 return undef if $interfaceName eq 'Object'; 301 return undef if $interfaceName eq 'Object';
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 791 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
763 $found = 1; 792 $found = 1;
764 } 793 }
765 return 1 if $found; 794 return 1 if $found;
766 }, 0); 795 }, 0);
767 796
768 return $found; 797 return $found;
769 } 798 }
770 799
771 1; 800 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698