Title: [104438] trunk/Source/WebCore
Revision
104438
Author
[email protected]
Date
2012-01-09 00:26:21 -0800 (Mon, 09 Jan 2012)

Log Message

[Refactoring] Use join(", ", @arguments) to build a method argument
string in CodeGeneratorV8.pm
https://bugs.webkit.org/show_bug.cgi?id=75828

Reviewed by Darin Adler.

The code in CodeGeneratorV8.pm to build a method argument string is dirty
and error-prone. It is concatenating arguments one by one judging whether
", " is necessary or not. This patch refactors the code so that it pushes
all arguments into @arguments and then builds a method string by
join(", ", @arguments).

Test: bindings/scripts/test/*

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateFunctionCallString):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (104437 => 104438)


--- trunk/Source/WebCore/ChangeLog	2012-01-09 08:06:41 UTC (rev 104437)
+++ trunk/Source/WebCore/ChangeLog	2012-01-09 08:26:21 UTC (rev 104438)
@@ -1,3 +1,22 @@
+2012-01-09  Kentaro Hara  <[email protected]>
+
+        [Refactoring] Use join(", ", @arguments) to build a method argument
+        string in CodeGeneratorV8.pm
+        https://bugs.webkit.org/show_bug.cgi?id=75828
+
+        Reviewed by Darin Adler.
+
+        The code in CodeGeneratorV8.pm to build a method argument string is dirty
+        and error-prone. It is concatenating arguments one by one judging whether
+        ", " is necessary or not. This patch refactors the code so that it pushes
+        all arguments into @arguments and then builds a method string by
+        join(", ", @arguments).
+
+        Test: bindings/scripts/test/*
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateFunctionCallString):
+
 2012-01-08  Benjamin Poulain  <[email protected]>
 
         Build fix: ScrollAnimatorMac has missing initializer in systemUptime()

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (104437 => 104438)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-01-09 08:06:41 UTC (rev 104437)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-01-09 08:26:21 UTC (rev 104438)
@@ -3185,11 +3185,7 @@
         $name = $function->signature->extendedAttributes->{"ImplementationFunction"};
     }
 
-    my $functionString = "imp->${name}(";
-    if ($function->isStatic) {
-        $functionString = "${implClassName}::${name}(";
-    }
-
+    my @arguments;
     my $index = 0;
     my $hasScriptState = 0;
 
@@ -3206,8 +3202,7 @@
             $result .= $indent . "    return v8::Undefined();\n";
             $callWithArg = "scriptContext";
         }
-        $functionString .= ", " if $index;
-        $functionString .= $callWithArg;
+        push @arguments, $callWithArg;
         $index++;
         $numberOfParameters++
     }
@@ -3216,39 +3211,35 @@
         if ($index eq $numberOfParameters) {
             last;
         }
-        $functionString .= ", " if $index;
         my $paramName = $parameter->name;
         my $paramType = $parameter->type;
 
         if ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") {
-            $functionString .= "$paramName.get()";
+            push @arguments, "$paramName.get()";
         } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($parameter->type) and not $implClassName =~ /List$/) {
-            $functionString .= "$paramName->propertyReference()";
+            push @arguments, "$paramName->propertyReference()";
             $result .= $indent . "if (!$paramName) {\n";
             $result .= $indent . "    V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR);\n";
             $result .= $indent . "    return v8::Handle<v8::Value>();\n";
             $result .= $indent . "}\n";
         } elsif ($parameter->type eq "SVGMatrix" and $implClassName eq "SVGTransformList") {
-            $functionString .= "$paramName.get()";
+            push @arguments, "$paramName.get()";
         } else {
-            $functionString .= $paramName;
+            push @arguments, $paramName;
         }
         $index++;
     }
 
     if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
-        $functionString .= ", " if $index;
-        $functionString .= "scriptArguments, callStack";
-        $index += 2;
+        push @arguments, "scriptArguments, callStack";
     }
 
     if (@{$function->raisesExceptions}) {
-        $functionString .= ", " if $index;
-        $functionString .= "ec";
-        $index++;
+        push @arguments, "ec";
     }
-    $functionString .= ")";
 
+    my $functionString = ($function->isStatic ? "${implClassName}::${name}(" : "imp->${name}(") . join(", ", @arguments) . ")";
+
     my $return = "result";
     my $returnIsRef = IsRefPtrType($returnType);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to