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

Side by Side Diff: Source/core/scripts/make_names.pl

Issue 20652002: Fix trailing whitespace in scripts and misc. files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Don't change literal diff. Created 7 years, 5 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/core/scripts/check_objc_rename.sh ('k') | Source/core/scripts/rule_bison.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, 2006, 2007, 2009 Apple Inc. All rights reserved. 3 # Copyright (C) 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
4 # Copyright (C) 2009, Julien Chaffraix <jchaffraix@webkit.org> 4 # Copyright (C) 2009, Julien Chaffraix <jchaffraix@webkit.org>
5 # Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmob ile.com/) 5 # Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmob ile.com/)
6 # Copyright (C) 2011 Ericsson AB. All rights reserved. 6 # Copyright (C) 2011 Ericsson AB. All rights reserved.
7 # 7 #
8 # Redistribution and use in source and binary forms, with or without 8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions 9 # modification, are permitted provided that the following conditions
10 # are met: 10 # are met:
11 # 11 #
12 # 1. Redistributions of source code must retain the above copyright 12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer. 13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright 14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the 15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution. 16 # documentation and/or other materials provided with the distribution.
17 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 17 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
18 # its contributors may be used to endorse or promote products derived 18 # its contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission. 19 # from this software without specific prior written permission.
20 # 20 #
21 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 21 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
22 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 24 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
25 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 31
32 use strict; 32 use strict;
33 33
34 use StaticString; 34 use StaticString;
35 use Config; 35 use Config;
36 use Getopt::Long; 36 use Getopt::Long;
37 use File::Path; 37 use File::Path;
38 use File::Spec; 38 use File::Spec;
39 use IO::File; 39 use IO::File;
40 use InFilesParser; 40 use InFilesParser;
41 41
42 sub readTags($$); 42 sub readTags($$);
43 sub readAttrs($$); 43 sub readAttrs($$);
44 44
45 my $printFactory = 0; 45 my $printFactory = 0;
46 my $fontNamesIn = ""; 46 my $fontNamesIn = "";
47 my $resourceTypesIn = ""; 47 my $resourceTypesIn = "";
48 my $tagsFile = ""; 48 my $tagsFile = "";
49 my $attrsFile = ""; 49 my $attrsFile = "";
50 my $outputDir = "."; 50 my $outputDir = ".";
51 my %parsedTags = (); 51 my %parsedTags = ();
52 my %parsedAttrs = (); 52 my %parsedAttrs = ();
53 my %enabledTags = (); 53 my %enabledTags = ();
54 my %enabledAttrs = (); 54 my %enabledAttrs = ();
55 my %allTags = (); 55 my %allTags = ();
(...skipping 10 matching lines...) Expand all
66 if ($ENV{CC}) { 66 if ($ENV{CC}) {
67 $gccLocation = $ENV{CC}; 67 $gccLocation = $ENV{CC};
68 } elsif (($Config::Config{'osname'}) =~ /solaris/i) { 68 } elsif (($Config::Config{'osname'}) =~ /solaris/i) {
69 $gccLocation = "/usr/sfw/bin/gcc"; 69 $gccLocation = "/usr/sfw/bin/gcc";
70 } else { 70 } else {
71 $gccLocation = "/usr/bin/gcc"; 71 $gccLocation = "/usr/bin/gcc";
72 } 72 }
73 my $preprocessor = $gccLocation . " -E -x c++"; 73 my $preprocessor = $gccLocation . " -E -x c++";
74 74
75 GetOptions( 75 GetOptions(
76 'tags=s' => \$tagsFile, 76 'tags=s' => \$tagsFile,
77 'attrs=s' => \$attrsFile, 77 'attrs=s' => \$attrsFile,
78 'factory' => \$printFactory, 78 'factory' => \$printFactory,
79 'outputDir=s' => \$outputDir, 79 'outputDir=s' => \$outputDir,
80 'extraDefines=s' => \$extraDefines, 80 'extraDefines=s' => \$extraDefines,
81 'preprocessor=s' => \$preprocessor, 81 'preprocessor=s' => \$preprocessor,
82 'fonts=s' => \$fontNamesIn, 82 'fonts=s' => \$fontNamesIn,
83 'resourceTypes=s' => \$resourceTypesIn 83 'resourceTypes=s' => \$resourceTypesIn
84 ); 84 );
85 85
86 mkpath($outputDir); 86 mkpath($outputDir);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 print F "static PassRefPtr<$parameters{namespace}Element> ${constructorName} Constructor(const QualifiedName& $constructorTagName, Document* document"; 340 print F "static PassRefPtr<$parameters{namespace}Element> ${constructorName} Constructor(const QualifiedName& $constructorTagName, Document* document";
341 if ($parameters{namespace} eq "HTML") { 341 if ($parameters{namespace} eq "HTML") {
342 print F ", HTMLFormElement*"; 342 print F ", HTMLFormElement*";
343 print F " formElement" if $enabledTags{$tagName}{constructorNeedsFormEle ment}; 343 print F " formElement" if $enabledTags{$tagName}{constructorNeedsFormEle ment};
344 } 344 }
345 print F ", bool"; 345 print F ", bool";
346 print F " createdByParser" if $enabledTags{$tagName}{constructorNeedsCreated ByParser}; 346 print F " createdByParser" if $enabledTags{$tagName}{constructorNeedsCreated ByParser};
347 print F ")\n{\n"; 347 print F ")\n{\n";
348 } 348 }
349 349
350 # Helper method to dump the constructor interior and call the 350 # Helper method to dump the constructor interior and call the
351 # Element constructor with the right arguments. 351 # Element constructor with the right arguments.
352 # The variable names should be kept in sync with the previous method. 352 # The variable names should be kept in sync with the previous method.
353 sub printConstructorInterior 353 sub printConstructorInterior
354 { 354 {
355 my ($F, $tagName, $interfaceName, $constructorTagName) = @_; 355 my ($F, $tagName, $interfaceName, $constructorTagName) = @_;
356 356
357 # Handle media elements. 357 # Handle media elements.
358 if ($enabledTags{$tagName}{wrapperOnlyIfMediaIsAvailable}) { 358 if ($enabledTags{$tagName}{wrapperOnlyIfMediaIsAvailable}) {
359 print F <<END 359 print F <<END
360 Settings* settings = document->settings(); 360 Settings* settings = document->settings();
361 if (!RuntimeEnabledFeatures::mediaEnabled() || (settings && !settings->media Enabled())) 361 if (!RuntimeEnabledFeatures::mediaEnabled() || (settings && !settings->media Enabled()))
362 return 0; 362 return 0;
363 363
364 END 364 END
365 ; 365 ;
366 } 366 }
367 367
368 my $contextConditional = $enabledTags{$tagName}{contextConditional}; 368 my $contextConditional = $enabledTags{$tagName}{contextConditional};
369 if ($contextConditional) { 369 if ($contextConditional) {
370 print F <<END 370 print F <<END
371 if (!ContextFeatures::${contextConditional}Enabled(document)) 371 if (!ContextFeatures::${contextConditional}Enabled(document))
372 return 0; 372 return 0;
373 END 373 END
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 my $name = shift; 465 my $name = shift;
466 466
467 $name = "FE" . ucfirst $1 if $name =~ /^fe(.+)$/; 467 $name = "FE" . ucfirst $1 if $name =~ /^fe(.+)$/;
468 468
469 return $name; 469 return $name;
470 } 470 }
471 471
472 sub upperCaseName 472 sub upperCaseName
473 { 473 {
474 my $name = shift; 474 my $name = shift;
475 475
476 $name = svgCapitalizationHacks($name) if ($parameters{namespace} eq "SVG"); 476 $name = svgCapitalizationHacks($name) if ($parameters{namespace} eq "SVG");
477 477
478 while ($name =~ /^(.*?)_(.*)/) { 478 while ($name =~ /^(.*?)_(.*)/) {
479 $name = $1 . ucfirst $2; 479 $name = $1 . ucfirst $2;
480 } 480 }
481 481
482 return ucfirst $name; 482 return ucfirst $name;
483 } 483 }
484 484
485 sub printHeaderHead 485 sub printHeaderHead
486 { 486 {
487 my ($F, $prefix, $nsName, $includes) = @_; 487 my ($F, $prefix, $nsName, $includes) = @_;
488 488
489 print F "#ifndef ${prefix}_${nsName}Names_h\n"; 489 print F "#ifndef ${prefix}_${nsName}Names_h\n";
490 print F "#define ${prefix}_${nsName}Names_h\n\n"; 490 print F "#define ${prefix}_${nsName}Names_h\n\n";
491 print F "$includes\n\n"; 491 print F "$includes\n\n";
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 604
605 printInit($F, 1); 605 printInit($F, 1);
606 close F; 606 close F;
607 } 607 }
608 608
609 sub printNamesCppFile 609 sub printNamesCppFile
610 { 610 {
611 my $cppPath = shift; 611 my $cppPath = shift;
612 my $F; 612 my $F;
613 open F, ">$cppPath"; 613 open F, ">$cppPath";
614 614
615 printLicenseHeader($F); 615 printLicenseHeader($F);
616 printCppHead($F, "DOM", $parameters{namespace}, "WebCore"); 616 printCppHead($F, "DOM", $parameters{namespace}, "WebCore");
617 617
618 my $lowerNamespace = lc($parameters{namespacePrefix}); 618 my $lowerNamespace = lc($parameters{namespacePrefix});
619 619
620 print F "DEFINE_GLOBAL(AtomicString, ${lowerNamespace}NamespaceURI)\n\n"; 620 print F "DEFINE_GLOBAL(AtomicString, ${lowerNamespace}NamespaceURI)\n\n";
621 621
622 print F StaticString::GenerateStrings(\%allStrings); 622 print F StaticString::GenerateStrings(\%allStrings);
623 623
624 if (keys %allTags) { 624 if (keys %allTags) {
625 print F "// Tags\n"; 625 print F "// Tags\n";
626 for my $name (sort keys %allTags) { 626 for my $name (sort keys %allTags) {
627 print F "DEFINE_GLOBAL(QualifiedName, ", $name, "Tag)\n"; 627 print F "DEFINE_GLOBAL(QualifiedName, ", $name, "Tag)\n";
628 } 628 }
629 629
630 print F "\n\nWebCore::QualifiedName** get$parameters{namespace}Tags()\n" ; 630 print F "\n\nWebCore::QualifiedName** get$parameters{namespace}Tags()\n" ;
631 print F "{\n static WebCore::QualifiedName* $parameters{namespace}Tag s[] = {\n"; 631 print F "{\n static WebCore::QualifiedName* $parameters{namespace}Tag s[] = {\n";
632 for my $name (sort keys %allTags) { 632 for my $name (sort keys %allTags) {
633 print F " (WebCore::QualifiedName*)&${name}Tag,\n"; 633 print F " (WebCore::QualifiedName*)&${name}Tag,\n";
634 } 634 }
635 print F " };\n"; 635 print F " };\n";
636 print F " return $parameters{namespace}Tags;\n"; 636 print F " return $parameters{namespace}Tags;\n";
637 print F "}\n"; 637 print F "}\n";
638 } 638 }
639 639
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 750 }
751 } 751 }
752 752
753 sub printDefinitions 753 sub printDefinitions
754 { 754 {
755 my ($F, $namesRef, $type, $namespaceURI) = @_; 755 my ($F, $namesRef, $type, $namespaceURI) = @_;
756 my $singularType = substr($type, 0, -1); 756 my $singularType = substr($type, 0, -1);
757 my $shortType = substr($singularType, 0, 4); 757 my $shortType = substr($singularType, 0, 4);
758 my $shortCamelType = ucfirst($shortType); 758 my $shortCamelType = ucfirst($shortType);
759 my $shortUpperType = uc($shortType); 759 my $shortUpperType = uc($shortType);
760 760
761 print F " // " . ucfirst($type) . "\n"; 761 print F " // " . ucfirst($type) . "\n";
762 762
763 for my $name (sort keys %$namesRef) { 763 for my $name (sort keys %$namesRef) {
764 # To generate less code in init(), the common case of nullAtom for the n amespace, we call createQualifiedName() without passing $namespaceURI. 764 # To generate less code in init(), the common case of nullAtom for the n amespace, we call createQualifiedName() without passing $namespaceURI.
765 if ($namespaceURI eq "nullAtom") { 765 if ($namespaceURI eq "nullAtom") {
766 print F " createQualifiedName((void*)&$name","${shortCamelType}, ${name}Impl);\n"; 766 print F " createQualifiedName((void*)&$name","${shortCamelType}, ${name}Impl);\n";
767 } else { 767 } else {
768 print F " createQualifiedName((void*)&$name","${shortCamelType}, ${name}Impl, $namespaceURI);\n"; 768 print F " createQualifiedName((void*)&$name","${shortCamelType}, ${name}Impl, $namespaceURI);\n";
769 } 769 }
770 } 770 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 { 835 {
836 gFunctionMap->set(tag.localName().impl(), func); 836 gFunctionMap->set(tag.localName().impl(), func);
837 } 837 }
838 838
839 static void createFunctionMap() 839 static void createFunctionMap()
840 { 840 {
841 ASSERT(!gFunctionMap); 841 ASSERT(!gFunctionMap);
842 842
843 // Create the table. 843 // Create the table.
844 gFunctionMap = new FunctionMap; 844 gFunctionMap = new FunctionMap;
845 845
846 // Populate it with constructor functions. 846 // Populate it with constructor functions.
847 END 847 END
848 ; 848 ;
849 849
850 printFunctionInits($F, \%tagConstructorMap); 850 printFunctionInits($F, \%tagConstructorMap);
851 851
852 print F "}\n"; 852 print F "}\n";
853 853
854 854
855 print F "\nPassRefPtr<$parameters{namespace}Element> $parameters{namespace}Eleme ntFactory::create$parameters{namespace}Element(const QualifiedName& qName, Docum ent* document"; 855 print F "\nPassRefPtr<$parameters{namespace}Element> $parameters{namespace}Eleme ntFactory::create$parameters{namespace}Element(const QualifiedName& qName, Docum ent* document";
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 1276
1277 while ( my ($name, $identifier) = each %parameters ) { 1277 while ( my ($name, $identifier) = each %parameters ) {
1278 print F " new ((void*)&$name) AtomicString(${name}Impl);\n"; 1278 print F " new ((void*)&$name) AtomicString(${name}Impl);\n";
1279 } 1279 }
1280 1280
1281 print F "}\n}\n}\n"; 1281 print F "}\n}\n}\n";
1282 close F; 1282 close F;
1283 exit 0; 1283 exit 0;
1284 } 1284 }
1285 1285
OLDNEW
« no previous file with comments | « Source/core/scripts/check_objc_rename.sh ('k') | Source/core/scripts/rule_bison.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698