[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:11:40 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2585c11bab6a48b308ad24608a88d24dd88c210e
Author: loislo at chromium.org <loislo at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Nov 19 15:34:10 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@72398 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index fd2aa1a..280c0f0 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-19  John Knottenbelt  <jknotten at chromium.org>
 
         Reviewed by Jeremy Orlow.
diff --git a/WebCore/inspector/CodeGeneratorInspector.pm b/WebCore/inspector/CodeGeneratorInspector.pm
index f5f2453..c2b0eb4 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,12 @@ sub generateFunctions
     push(@backendMethodsImpl, generateBackendDispatcher());
     push(@backendMethodsImpl, generateBackendReportProtocolError());
 
+    foreach my $type (keys %backendTypes) {
+        if ($typeTransform{$type}{"JSONType"}) {
+            push(@backendMethodsImpl, generateArgumentGetters($type));
+        }
+    }
+
     @backendStubJS = generateBackendStubJS($interface);
 }
 
@@ -301,6 +308,14 @@ sub generateFrontendFunction
     }
 }
 
+sub camelCase
+{
+    my $value = shift;
+    $value =~ s/\b(\w)/\U$1/g; # make a camel-case name for type name
+    $value =~ s/ //g;
+    return $value;
+}
+
 sub generateBackendFunction
 {
     my $function = shift;
@@ -332,43 +347,31 @@ sub generateBackendFunction
     push(@function, "        protocolErrors->pushString(\"Protocol Error: $domain handler is not available.\");");
     push(@function, "");
 
-    if (scalar(@inArgs)) {
-        # declare variables for all 'in' args;
-        push(@function, map("    " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . " = " . $typeTransform{$_->type}->{"defaultValue"} . ";", @inArgs));
+    # declare local variables for out arguments.
+    push(@function, map("    " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . " = " . $typeTransform{$_->type}->{"defaultValue"} . ";", @outArgs));
 
-        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();");
+    my $indent = "";
+    if (scalar(@inArgs)) {
+        push(@function, "    if (RefPtr<InspectorObject> argumentsContainer = requestMessageObject->getObject(\"arguments\")) {");
 
         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 = camelCase($parameter->type);
+            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);");
+    if (scalar(@inArgs)) {
+        push(@function, "    } else {");
+        push(@function, "        protocolErrors->pushString(\"Protocol Error: 'arguments' property with type 'object' was not found.\");");
+        push(@function, "    }");
+    }
 
     push(@function, "    // use InspectorFrontend as a marker of WebInspector availability");
     push(@function, "    if ((callId || protocolErrors->length()) && m_inspectorController->hasFrontend()) {");
@@ -412,6 +415,39 @@ EOF
     return split("\n", $reportProtocolError);
 }
 
+sub generateArgumentGetters
+{
+    my $type = shift;
+    my $json = $typeTransform{$type}{"JSONType"};
+    my $variable = $typeTransform{$type}{"variable"};
+    my $defaultValue = $typeTransform{$type}{"defaultValue"};
+    my $return  = $typeTransform{$type}{"return"} ? $typeTransform{$type}{"return"} : $typeTransform{$type}{"param"};
+
+    my $typeString = camelCase($type);
+    push(@backendConstantDeclarations, "$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 = $defaultValue;
+    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
 {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list