Title: [101506] trunk/Source/WebCore
Revision
101506
Author
[email protected]
Date
2011-11-30 06:33:40 -0800 (Wed, 30 Nov 2011)

Log Message

[Refactoring] In preprocessor.pm, remove double quotations from $defines
https://bugs.webkit.org/show_bug.cgi?id=73160

Reviewed by Adam Barth.

In preprocessor.pm, we need to extract gcc macros from $defines.
$defines can contain unnecessary double quotations.
For example, if $defines is ' "A=1" "B=1" C=1 ""    D  ',
then it should be converted into four macros, -DA=1, -DB=1, -DC=1 and -DD.
This patch refactors the logic in preprocessor.pm.

No new tests. No change in behavior.

* bindings/scripts/generate-bindings.pl: Removed a code for $defines conversion, since it is now done in preprocessor.pm.
* bindings/scripts/preprocessor.pm:
(applyPreprocessor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (101505 => 101506)


--- trunk/Source/WebCore/ChangeLog	2011-11-30 14:23:30 UTC (rev 101505)
+++ trunk/Source/WebCore/ChangeLog	2011-11-30 14:33:40 UTC (rev 101506)
@@ -1,3 +1,22 @@
+2011-11-30  Kentaro Hara  <[email protected]>
+
+        [Refactoring] In preprocessor.pm, remove double quotations from $defines
+        https://bugs.webkit.org/show_bug.cgi?id=73160
+
+        Reviewed by Adam Barth.
+
+        In preprocessor.pm, we need to extract gcc macros from $defines.
+        $defines can contain unnecessary double quotations.
+        For example, if $defines is ' "A=1" "B=1" C=1 ""    D  ',
+        then it should be converted into four macros, -DA=1, -DB=1, -DC=1 and -DD.
+        This patch refactors the logic in preprocessor.pm.
+
+        No new tests. No change in behavior.
+
+        * bindings/scripts/generate-bindings.pl: Removed a code for $defines conversion, since it is now done in preprocessor.pm.
+        * bindings/scripts/preprocessor.pm:
+        (applyPreprocessor):
+
 2011-11-30  Kenichi Ishibashi  <[email protected]>
 
         @font-face: unquoted local font names containing spaces don't work

Modified: trunk/Source/WebCore/bindings/scripts/generate-bindings.pl (101505 => 101506)


--- trunk/Source/WebCore/bindings/scripts/generate-bindings.pl	2011-11-30 14:23:30 UTC (rev 101505)
+++ trunk/Source/WebCore/bindings/scripts/generate-bindings.pl	2011-11-30 14:33:40 UTC (rev 101506)
@@ -67,12 +67,10 @@
 die('Must specify input file.') unless defined($targetIdlFile);
 die('Must specify generator') unless defined($generator);
 die('Must specify output directory.') unless defined($outputDirectory);
-die('Must specify defines') unless defined($defines);
 
 if (!$outputHeadersDirectory) {
     $outputHeadersDirectory = $outputDirectory;
 }
-$defines =~ s/^\s+|\s+$//g; # trim whitespace
 $targetIdlFile = Cwd::realpath($targetIdlFile);
 if ($verbose) {
     print "$generator: $targetIdlFile\n";

Modified: trunk/Source/WebCore/bindings/scripts/preprocessor.pm (101505 => 101506)


--- trunk/Source/WebCore/bindings/scripts/preprocessor.pm	2011-11-30 14:23:30 UTC (rev 101505)
+++ trunk/Source/WebCore/bindings/scripts/preprocessor.pm	2011-11-30 14:33:40 UTC (rev 101506)
@@ -53,11 +53,14 @@
         $preprocessor = $gccLocation . " -E -P -x c++";
     }
 
-    if (!$defines || ($defines eq "\"\"")) {
-        $defines = "";
-    }
+    # Remove double quotations from $defines and extract macros.
+    # For example, if $defines is ' "A=1" "B=1" C=1 ""    D  ',
+    # then it is converted into four macros -DA=1, -DB=1, -DC=1 and -DD.
+    $defines =~ s/\"//g;
+    my @macros = grep { $_ } split(/\s+/, $defines); # grep skips empty macros.
+    @macros = map { "-D$_" } @macros;
 
-    my $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), (map { $_ =~ s/^\"|\"$//g; "-D$_" if $_ } split(' ', $defines)), $fileName);
+    my $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), @macros, $fileName);
     close PP_IN;
     my @documentContent = <PP_OUT>;
     close PP_OUT;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to