[Refactoring] Makes finish() of CodeGeneratorV8.pm empty
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2012 10:32:48 +0000 (10:32 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2012 10:32:48 +0000 (10:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76841

Reviewed by Adam Barth.

This is one of steps to stop rebuilding .h/.cpp files
generated by unchanged IDLs (bug 76836).

As refactoring, we are planning to remove finish() from
all CodeGenerators. This patch makes finish() of
CodeGeneratorV8.pm empty.

No new tests. No change in behavior.

* bindings/scripts/CodeGeneratorV8.pm:
(finish): Made it empty. We will remove finish() after
making finish() of all CodeGenerators empty.
(GenerateInterface): Modified to call WriteData().
(WriteData): Simple code refactoring.
Removed if(defined $IMPL).
Removed if(defined $HEADER).
$IMPL -> IMPL.
$HEADER -> HEADER.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105714 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

index 92fe5f1..40553fd 100644 (file)
@@ -1,3 +1,29 @@
+2012-01-24  Kentaro Hara  <haraken@chromium.org>
+
+        [Refactoring] Makes finish() of CodeGeneratorV8.pm empty
+        https://bugs.webkit.org/show_bug.cgi?id=76841
+
+        Reviewed by Adam Barth.
+
+        This is one of steps to stop rebuilding .h/.cpp files
+        generated by unchanged IDLs (bug 76836).
+
+        As refactoring, we are planning to remove finish() from
+        all CodeGenerators. This patch makes finish() of
+        CodeGeneratorV8.pm empty.
+
+        No new tests. No change in behavior.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (finish): Made it empty. We will remove finish() after
+        making finish() of all CodeGenerators empty.
+        (GenerateInterface): Modified to call WriteData().
+        (WriteData): Simple code refactoring.
+        Removed if(defined $IMPL).
+        Removed if(defined $HEADER).
+        $IMPL -> IMPL.
+        $HEADER -> HEADER.
+
 2012-01-24  Mario Sanchez Prada  <msanchez@igalia.com>
 
         Unreviewed build fix for GTK after r105698.
index 9ef0691..4d34d2a 100644 (file)
@@ -32,7 +32,7 @@ use Digest::MD5;
 
 use constant FileNamePrefix => "V8";
 
-my ($codeGenerator, $IMPL, $HEADER);
+my ($codeGenerator);
 
 my $module = "";
 my $outputDir = "";
@@ -85,12 +85,10 @@ sub new
     return $reference;
 }
 
+# FIXME(haraken): finish() will be soon removed from all CodeGenerators.
 sub finish
 {
     my $object = shift;
-
-    # Commit changes!
-    $object->WriteData();
 }
 
 # Params: 'domClass' struct
@@ -109,15 +107,7 @@ sub GenerateInterface
         $object->GenerateImplementation($dataNode);
     }
 
-    my $name = $dataNode->name;
-
-    # Open files for writing
-    my $prefix = FileNamePrefix;
-    my $headerFileName = "$outputHeadersDir/$prefix$name.h";
-    my $implFileName = "$outputDir/$prefix$name.cpp";
-
-    open($IMPL, ">$implFileName") || die "Couldn't open file $implFileName";
-    open($HEADER, ">$headerFileName") || die "Couldn't open file $headerFileName";
+    $object->WriteData($dataNode);
 }
 
 # Params: 'idlDocument' struct
@@ -3807,63 +3797,67 @@ sub ReturnNativeToJSValue
 # Internal helper
 sub WriteData
 {
-    if (defined($IMPL)) {
-        # Write content to file.
-        print $IMPL @implContentHeader;
+    my $object = shift;
+    my $dataNode = shift;
 
-        print $IMPL @implFixedHeader;
+    my $name = $dataNode->name;
+    my $prefix = FileNamePrefix;
+    my $headerFileName = "$outputHeadersDir/$prefix$name.h";
+    my $implFileName = "$outputDir/$prefix$name.cpp";
 
-        my @includes = ();
-        my %implIncludeConditions = ();
-        foreach my $include (keys %implIncludes) {
-            my $condition = $implIncludes{$include};
-            my $checkType = $include;
-            $checkType =~ s/\.h//;
-            next if $codeGenerator->IsSVGAnimatedType($checkType);
+    open(IMPL, ">$implFileName") || die "Couldn't open file $implFileName";
 
-            if ($include =~ /wtf/) {
-                $include = "\<$include\>";
-            } else {
-                $include = "\"$include\"";
-            }
+    # Write content to file.
+    print IMPL @implContentHeader;
+    print IMPL @implFixedHeader;
 
-            if ($condition eq 1) {
-                push @includes, $include;
-            } else {
-                push @{$implIncludeConditions{$condition}}, $include;
-            }
+    my @includes = ();
+    my %implIncludeConditions = ();
+    foreach my $include (keys %implIncludes) {
+        my $condition = $implIncludes{$include};
+        my $checkType = $include;
+        $checkType =~ s/\.h//;
+        next if $codeGenerator->IsSVGAnimatedType($checkType);
+
+        if ($include =~ /wtf/) {
+            $include = "\<$include\>";
+        } else {
+            $include = "\"$include\"";
         }
-        foreach my $include (sort @includes) {
-            print $IMPL "#include $include\n";
+
+        if ($condition eq 1) {
+            push @includes, $include;
+        } else {
+            push @{$implIncludeConditions{$condition}}, $include;
         }
-        foreach my $condition (sort keys %implIncludeConditions) {
-            print $IMPL "\n#if " . $codeGenerator->GenerateConditionalStringFromAttributeValue($condition) . "\n";
-            foreach my $include (sort @{$implIncludeConditions{$condition}}) {
-                print $IMPL "#include $include\n";
-            }
-            print $IMPL "#endif\n";
+    }
+    foreach my $include (sort @includes) {
+        print IMPL "#include $include\n";
+    }
+    foreach my $condition (sort keys %implIncludeConditions) {
+        print IMPL "\n#if " . $codeGenerator->GenerateConditionalStringFromAttributeValue($condition) . "\n";
+        foreach my $include (sort @{$implIncludeConditions{$condition}}) {
+            print IMPL "#include $include\n";
         }
+        print IMPL "#endif\n";
+    }
 
-        print $IMPL "\n";
-        print $IMPL @implContentDecls;
-        print $IMPL @implContent;
-        close($IMPL);
-        undef($IMPL);
+    print IMPL "\n";
+    print IMPL @implContentDecls;
+    print IMPL @implContent;
+    close(IMPL);
 
-        %implIncludes = ();
-        @implFixedHeader = ();
-        @implContentDecls = ();
-        @implContent = ();
-    }
+    %implIncludes = ();
+    @implFixedHeader = ();
+    @implContentDecls = ();
+    @implContent = ();
 
-    if (defined($HEADER)) {
-        # Write content to file.
-        print $HEADER @headerContent;
-        close($HEADER);
-        undef($HEADER);
+    # Write content to file.
+    open(HEADER, ">$headerFileName") || die "Couldn't open file $headerFileName";
+    print HEADER @headerContent;
+    close(HEADER);
 
-        @headerContent = ();
-    }
+    @headerContent = ();
 }
 
 sub GetVisibleInterfaceName