Web Inspector: optional arguments support for the frontend needs to be extended.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2011 16:57:17 +0000 (16:57 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2011 16:57:17 +0000 (16:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69005

Generator supports optional arguments but they are transferred by value.
It is not suitable if the used type doesn't have operator bool.
I'll transfer such arguments by pointer.

Reviewed by Pavel Feldman.

Build is the test.

* inspector/CodeGeneratorInspector.pm:
(generateFrontendFunction):
(paramTypeTraits):
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::didParseSource):
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::didFailLoading):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/CodeGeneratorInspector.pm
Source/WebCore/inspector/InspectorDebuggerAgent.cpp
Source/WebCore/inspector/InspectorResourceAgent.cpp

index 982c8aa5a1d1115d9a79ce9e9fda624ae61b79cb..57f7201f4d115bd09d9534df4dcf4f8c14288ca8 100644 (file)
@@ -1,3 +1,24 @@
+2011-09-28  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: optional arguments support for the frontend needs to be extended.
+        https://bugs.webkit.org/show_bug.cgi?id=69005
+
+        Generator supports optional arguments but they are transferred by value.
+        It is not suitable if the used type doesn't have operator bool.
+        I'll transfer such arguments by pointer.
+
+        Reviewed by Pavel Feldman.
+
+        Build is the test.
+
+        * inspector/CodeGeneratorInspector.pm:
+        (generateFrontendFunction):
+        (paramTypeTraits):
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::InspectorDebuggerAgent::didParseSource):
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::didFailLoading):
+
 2011-09-28  Antaryami Pandia  <antaryami.pandia@motorola.com>
 
         Reflected attribute input.size wraps on negative values (Chrome), or
index a4f72ebf66ea94c70e45b49d90653240fcf44cc1..72e2183c1f29c467958926050cbd984ca939ca18 100644 (file)
@@ -134,6 +134,8 @@ $typeTransform{"Value"} = {
 };
 $typeTransform{"String"} = {
     "param" => "const String&",
+    "optional_param" => "const String* const",
+    "optional_valueAccessor" => "*",
     "variable" => "String",
     "return" => "String",
     "defaultValue" => "\"\"",
@@ -144,6 +146,8 @@ $typeTransform{"String"} = {
 };
 $typeTransform{"long"} = {
     "param" => "long",
+    "optional_param" => "const long* const",
+    "optional_valueAccessor" => "*",
     "variable" => "long",
     "defaultValue" => "0",
     "forward" => "",
@@ -153,6 +157,8 @@ $typeTransform{"long"} = {
 };
 $typeTransform{"int"} = {
     "param" => "int",
+    "optional_param" => "const int* const",
+    "optional_valueAccessor" => "*",
     "variable" => "int",
     "defaultValue" => "0",
     "forward" => "",
@@ -162,6 +168,8 @@ $typeTransform{"int"} = {
 };
 $typeTransform{"unsigned long"} = {
     "param" => "unsigned long",
+    "optional_param" => "const unsigned long* const",
+    "optional_valueAccessor" => "*",
     "variable" => "unsigned long",
     "defaultValue" => "0u",
     "forward" => "",
@@ -171,6 +179,8 @@ $typeTransform{"unsigned long"} = {
 };
 $typeTransform{"unsigned int"} = {
     "param" => "unsigned int",
+    "optional_param" => "const unsigned int* const",
+    "optional_valueAccessor" => "*",
     "variable" => "unsigned int",
     "defaultValue" => "0u",
     "forward" => "",
@@ -180,6 +190,8 @@ $typeTransform{"unsigned int"} = {
 };
 $typeTransform{"double"} = {
     "param" => "double",
+    "optional_param" => "const double* const",
+    "optional_valueAccessor" => "*",
     "variable" => "double",
     "defaultValue" => "0.0",
     "forward" => "",
@@ -189,6 +201,8 @@ $typeTransform{"double"} = {
 };
 $typeTransform{"boolean"} = {
     "param" => "bool",
+    "optional_param" => "const bool* const",
+    "optional_valueAccessor" => "*",
     "variable"=> "bool",
     "defaultValue" => "false",
     "forward" => "",
@@ -376,7 +390,7 @@ sub generateFrontendFunction
     my $domain = $interface->name;
     my @argsFiltered = grep($_->direction eq "out", @{$function->parameters}); # just keep only out parameters for frontend interface.
     map($frontendTypes{$_->type} = 1, @argsFiltered); # register required types.
-    my $arguments = join(", ", map(typeTraits($_->type, "param") . " " . $_->name, @argsFiltered)); # prepare arguments for function signature.
+    my $arguments = join(", ", map(paramTypeTraits($_, "param") . " " . $_->name, @argsFiltered)); # prepare arguments for function signature.
 
     my $signature = "        void ${functionName}(${arguments});";
     !$agent->{methodSignatures}->{$signature} || die "Duplicate frontend function was detected for signature '$signature'.";
@@ -393,7 +407,7 @@ sub generateFrontendFunction
 
         foreach my $parameter (@argsFiltered) {
             my $optional = $parameter->extendedAttributes->{"optional"} ? "if (" . $parameter->name . ")\n        " : "";
-            push(@function, "    " . $optional . "paramsObject->set" . typeTraits($parameter->type, "JSONType") . "(\"" . $parameter->name . "\", " . $parameter->name . ");");
+            push(@function, "    " . $optional . "paramsObject->set" . paramTypeTraits($parameter, "JSONType") . "(\"" . $parameter->name . "\", " . paramTypeTraits($parameter, "valueAccessor") . $parameter->name . ");");
         }
         push(@function, "    ${functionName}Message->setObject(\"params\", paramsObject);");
     }
@@ -1096,6 +1110,18 @@ sub typeTraits
     return $typeTransform{$type}->{$trait};
 }
 
+sub paramTypeTraits
+{
+    my $paramDescription = shift;
+    my $trait = shift;
+    if ($paramDescription->extendedAttributes->{"optional"}) {
+        my $optionalResult = typeTraits($paramDescription->type, "optional_" . $trait);
+        return $optionalResult if defined $optionalResult;
+    }
+    my $result = typeTraits($paramDescription->type, $trait);
+    return defined $result ? $result : "";
+}
+
 sub generateBackendAgentFieldsAndConstructor
 {
     my @arguments;
index b8fbb5d9baa207801c90495cc3052539fa9ccdeb..0b2120dba80ae7f292e328fec5743b3319e8129d 100644 (file)
@@ -437,7 +437,7 @@ PassRefPtr<InspectorArray> InspectorDebuggerAgent::currentCallFrames()
 void InspectorDebuggerAgent::didParseSource(const String& scriptId, const Script& script)
 {
     // Don't send script content to the front end until it's really needed.
-    m_frontend->scriptParsed(scriptId, script.url, script.startLine, script.startColumn, script.endLine, script.endColumn, script.isContentScript);
+    m_frontend->scriptParsed(scriptId, script.url, script.startLine, script.startColumn, script.endLine, script.endColumn, script.isContentScript ? &script.isContentScript : 0);
 
     m_scripts.set(scriptId, script);
 
index 77e5d6da5f5c813d1a2074f17073cf710ddd5c27..a79363038b2af6309f85c26e5a23d0fcfa3bd029 100644 (file)
@@ -299,7 +299,8 @@ void InspectorResourceAgent::didFailLoading(unsigned long identifier, DocumentLo
             m_resourcesData->addResourceSharedBuffer(requestId, frame->loader()->documentLoader()->mainResourceData(), frame->document()->inputEncoding());
     }
 
-    m_frontend->loadingFailed(requestId, currentTime(), error.localizedDescription(), error.isCancellation());
+    bool canceled = error.isCancellation();
+    m_frontend->loadingFailed(requestId, currentTime(), error.localizedDescription(), canceled ? &canceled : 0);
 }
 
 void InspectorResourceAgent::didLoadResourceFromMemoryCache(DocumentLoader* loader, CachedResource* resource)