[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

loislo at chromium.org loislo at chromium.org
Wed Dec 22 16:04:39 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a6822176a436d10a738539c45a32465ed0e8a59c
Author: loislo at chromium.org <loislo at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 18 15:33:56 2010 +0000

    2010-11-18  Ilya Tikhonovsky  <loislo at chromium.org>
    
            Reviewed by Yury Semikhatsky.
    
            Web Inspector: reduce the footprint of InspectorBackendDispatcher.
            InspectorBackendDispatcher is a generated file.
            Its content is not optimal and loc may be reduced by a quarter.
            In each generated function we have a code for getting 'in' values from
            the arguments properties object. I've extracted this code into separate getters.
            The side effect is better readability of the generated code.
    
            https://bugs.webkit.org/show_bug.cgi?id=49729
    
            * inspector/CodeGeneratorInspector.pm:
    
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72292 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index eb1687f..125bc58 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2010-11-18  Ilya Tikhonovsky  <loislo at chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: reduce the footprint of InspectorBackendDispatcher.
+        InspectorBackendDispatcher is a generated file.
+        Its content is not optimal and loc may be reduced by a quarter.
+        In each generated function we have a code for getting 'in' values from
+        the arguments properties object. I've extracted this code into separate getters.
+        The side effect is better readability of the generated code.
+
+        https://bugs.webkit.org/show_bug.cgi?id=49729
+
+        * inspector/CodeGeneratorInspector.pm:
+
 2010-11-18  Alexander Pavlov  <apavlov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/inspector/CodeGeneratorInspector.pm b/WebCore/inspector/CodeGeneratorInspector.pm
index f5f2453..95d5b5d 100644
--- a/WebCore/inspector/CodeGeneratorInspector.pm
+++ b/WebCore/inspector/CodeGeneratorInspector.pm
@@ -92,6 +92,7 @@ $typeTransform{"Value"} = {
 $typeTransform{"String"} = {
     "param" => "const String&",
     "variable" => "String",
+    "return" => "String",
     "defaultValue" => "\"\"",
     "forwardHeader" => "wtf/Forward.h",
     "header" => "PlatformString.h",
@@ -266,6 +267,16 @@ sub generateFunctions
     push(@backendMethodsImpl, generateBackendDispatcher());
     push(@backendMethodsImpl, generateBackendReportProtocolError());
 
+    my @backendGettersDeclarations;
+    push(@backendGettersDeclarations, "");
+    push(@backendGettersDeclarations, "private:");
+    foreach my $type (keys %backendTypes) {
+        if ($typeTransform{$type}{"JSONType"}) {
+            push(@backendMethodsImpl, generateArgumentGetters($type, \@backendGettersDeclarations));
+        }
+    }
+    push(@backendConstantDeclarations, @backendGettersDeclarations);
+
     @backendStubJS = generateBackendStubJS($interface);
 }
 
@@ -332,43 +343,30 @@ sub generateBackendFunction
     push(@function, "        protocolErrors->pushString(\"Protocol Error: $domain handler is not available.\");");
     push(@function, "");
 
+    # declare local variables for out arguments.
+    push(@function, map("    " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . " = " . $typeTransform{$_->type}->{"defaultValue"} . ";", @outArgs));
+
+    my $indent = "";
     if (scalar(@inArgs)) {
         # declare variables for all 'in' args;
-        push(@function, map("    " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . " = " . $typeTransform{$_->type}->{"defaultValue"} . ";", @inArgs));
-
-        push(@function, "");
-        push(@function, "    RefPtr<InspectorObject> argumentsContainer;");
-        push(@function, "    if (!(argumentsContainer = requestMessageObject->getObject(\"arguments\"))) {");
-        push(@function, "        protocolErrors->pushString(\"Protocol Error: 'arguments' property with type 'object' was not found.\");");
-        push(@function, "    } else {");
-        push(@function, "        InspectorObject::const_iterator argumentsEndIterator = argumentsContainer->end();");
+        push(@function, "    if (RefPtr<InspectorObject> argumentsContainer = getObject(requestMessageObject, \"arguments\", protocolErrors.get())) {");
 
         foreach my $parameter (@inArgs) {
             my $name = $parameter->name;
             my $type = $parameter->type;
-            my $variableType = $typeTransform{$type}->{"variable"};
-            my $JSONType = $typeTransform{$type}->{"JSONType"};
-
-            push(@function, "");
-            push(@function, "        InspectorObject::const_iterator ${name}ValueIterator = argumentsContainer->find(\"$name\");");
-            push(@function, "        if (${name}ValueIterator == argumentsEndIterator) {");
-            push(@function, "            protocolErrors->pushString(\"Protocol Error: Argument '$name' with type '$JSONType' was not found.\");");
-            push(@function, "        } else {");
-            push(@function, "            if (!${name}ValueIterator->second->as$JSONType(&$name)) {");
-            push(@function, "                protocolErrors->pushString(\"Protocol Error: Argument '$name' has wrong type. It should be '$JSONType'.\");");
-            push(@function, "            }");
-            push(@function, "        }");
+            my $typeString = $parameter->type;
+            $typeString =~ s/\b(\w)/\U$1/g;
+            $typeString =~ s/ //g;
+            push(@function, "        " . $typeTransform{$type}->{"variable"} . " $name = get$typeString(argumentsContainer.get(), \"$name\", protocolErrors.get());");
         }
-        push(@function, "    }");
+        push(@function, "");
+        $indent = "    ";
     }
 
-    # declare local variables for out arguments.
-    push(@function, map("    " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . " = " . $typeTransform{$_->type}->{"defaultValue"} . ";", @outArgs));
-
     my $args = join(", ", (map($_->name, @inArgs), map("&" . $_->name, @outArgs)));
-    push(@function, "    if (!protocolErrors->length())");
-    push(@function, "        $domainAccessor->$functionName($args);");
-    push(@function, "");
+    push(@function, "$indent    if (!protocolErrors->length())");
+    push(@function, "$indent        $domainAccessor->$functionName($args);");
+    push(@function, scalar(@inArgs) ? "    }" : "");
 
     push(@function, "    // use InspectorFrontend as a marker of WebInspector availability");
     push(@function, "    if ((callId || protocolErrors->length()) && m_inspectorController->hasFrontend()) {");
@@ -412,6 +410,42 @@ EOF
     return split("\n", $reportProtocolError);
 }
 
+sub generateArgumentGetters
+{
+    my $type = shift;
+    my $declarations = shift;
+    my $json = $typeTransform{$type}{"JSONType"};
+    my $variable = $typeTransform{$type}{"variable"};
+    my $return  = $typeTransform{$type}{"return"} ? $typeTransform{$type}{"return"} : $typeTransform{$type}{"param"};
+
+    my $typeString = $type;
+    $typeString =~ s/\b(\w)/\U$1/g;
+    $typeString =~ s/ //g;
+
+    push(@{$declarations}, "    static $return get$typeString(InspectorObject* object, const String& name, InspectorArray* protocolErrors);");
+    my $getterBody = << "EOF";
+
+$return InspectorBackendDispatcher::get$typeString(InspectorObject* object, const String& name, InspectorArray* protocolErrors)
+{
+    ASSERT(object);
+    ASSERT(protocolErrors);
+
+    $variable value;
+    InspectorObject::const_iterator end = object->end();
+    InspectorObject::const_iterator valueIterator = object->find(name);
+
+    if (valueIterator == end)
+        protocolErrors->pushString(String::format("Protocol Error: Argument '\%s' with type '$json' was not found.", name.utf8().data()));
+    else {
+        if (!valueIterator->second->as$json(&value))
+            protocolErrors->pushString(String::format("Protocol Error: Argument '\%s' has wrong type. It should be '$json'.", name.utf8().data()));
+    }
+    return value;
+}
+EOF
+
+    return split("\n", $getterBody);
+}
 
 sub generateBackendDispatcher
 {
@@ -642,7 +676,7 @@ sub generateSource
     push(@sourceContent, "");
     push(@sourceContent, "namespace $namespace {");
     push(@sourceContent, "");
-    push (@sourceContent, join("\n", @{$constants}));
+    push(@sourceContent, join("\n", @{$constants}));
     push(@sourceContent, "");
     push(@sourceContent, @{$methods});
     push(@sourceContent, "");

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list