summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/inspector/CodeGeneratorInspector.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/inspector/CodeGeneratorInspector.pm')
-rw-r--r--Source/WebCore/inspector/CodeGeneratorInspector.pm142
1 files changed, 92 insertions, 50 deletions
diff --git a/Source/WebCore/inspector/CodeGeneratorInspector.pm b/Source/WebCore/inspector/CodeGeneratorInspector.pm
index 70eb61d..ea65f2e 100644
--- a/Source/WebCore/inspector/CodeGeneratorInspector.pm
+++ b/Source/WebCore/inspector/CodeGeneratorInspector.pm
@@ -13,71 +13,77 @@ my %typeTransform;
$typeTransform{"ApplicationCache"} = {
"forward" => "InspectorApplicationCacheAgent",
"header" => "InspectorApplicationCacheAgent.h",
- "domainAccessor" => "m_inspectorAgent->applicationCacheAgent()",
+ "domainAccessor" => "m_applicationCacheAgent",
};
$typeTransform{"CSS"} = {
"forward" => "InspectorCSSAgent",
"header" => "InspectorCSSAgent.h",
- "domainAccessor" => "m_inspectorAgent->cssAgent()",
+ "domainAccessor" => "m_cssAgent",
};
$typeTransform{"Console"} = {
"forward" => "InspectorConsoleAgent",
"header" => "InspectorConsoleAgent.h",
- "domainAccessor" => "m_inspectorAgent->consoleAgent()",
+ "domainAccessor" => "m_consoleAgent",
+};
+$typeTransform{"Page"} = {
+ "forward" => "InspectorPageAgent",
+ "header" => "InspectorPageAgent.h",
+ "domainAccessor" => "m_pageAgent",
};
$typeTransform{"Debugger"} = {
"forward" => "InspectorDebuggerAgent",
"header" => "InspectorDebuggerAgent.h",
- "domainAccessor" => "m_inspectorAgent->debuggerAgent()",
+ "domainAccessor" => "m_debuggerAgent",
};
$typeTransform{"BrowserDebugger"} = {
"forward" => "InspectorBrowserDebuggerAgent",
"header" => "InspectorBrowserDebuggerAgent.h",
- "domainAccessor" => "m_inspectorAgent->browserDebuggerAgent()",
+ "domainAccessor" => "m_browserDebuggerAgent",
};
$typeTransform{"Database"} = {
"forward" => "InspectorDatabaseAgent",
"header" => "InspectorDatabaseAgent.h",
- "domainAccessor" => "m_inspectorAgent->databaseAgent()",
+ "domainAccessor" => "m_databaseAgent",
};
$typeTransform{"DOM"} = {
"forward" => "InspectorDOMAgent",
"header" => "InspectorDOMAgent.h",
- "domainAccessor" => "m_inspectorAgent->domAgent()",
+ "domainAccessor" => "m_domAgent",
};
$typeTransform{"DOMStorage"} = {
"forward" => "InspectorDOMStorageAgent",
"header" => "InspectorDOMStorageAgent.h",
- "domainAccessor" => "m_inspectorAgent->domStorageAgent()",
+ "domainAccessor" => "m_domStorageAgent",
};
$typeTransform{"FileSystem"} = {
"forward" => "InspectorFileSystemAgent",
"header" => "InspectorFileSystemAgent.h",
- "domainAccessor" => "m_inspectorAgent->fileSystemAgent()",
+ "domainAccessor" => "m_fileSystemAgent",
};
$typeTransform{"Inspector"} = {
- "forwardHeader" => "InspectorAgent.h",
+ "forward" => "InspectorAgent",
+ "header" => "InspectorAgent.h",
"domainAccessor" => "m_inspectorAgent",
};
$typeTransform{"Network"} = {
"forward" => "InspectorResourceAgent",
"header" => "InspectorResourceAgent.h",
- "domainAccessor" => "m_inspectorAgent->resourceAgent()",
+ "domainAccessor" => "m_resourceAgent",
};
$typeTransform{"Profiler"} = {
"forward" => "InspectorProfilerAgent",
"header" => "InspectorProfilerAgent.h",
- "domainAccessor" => "m_inspectorAgent->profilerAgent()",
+ "domainAccessor" => "m_profilerAgent",
};
$typeTransform{"Runtime"} = {
"forward" => "InspectorRuntimeAgent",
"header" => "InspectorRuntimeAgent.h",
- "domainAccessor" => "m_inspectorAgent->runtimeAgent()",
+ "domainAccessor" => "m_runtimeAgent",
};
$typeTransform{"Timeline"} = {
"forward" => "InspectorTimelineAgent",
"header" => "InspectorTimelineAgent.h",
- "domainAccessor" => "m_inspectorAgent->timelineAgent()",
+ "domainAccessor" => "m_timelineAgent",
};
$typeTransform{"Frontend"} = {
@@ -215,8 +221,9 @@ my %backendMethodSignatures;
my $backendConstructor;
my @backendConstantDeclarations;
my @backendConstantDefinitions;
-my $backendFooter;
+my @backendFooter;
my @backendJSStubs;
+my %backendDomains;
my $frontendClassName;
my %frontendTypes;
@@ -269,13 +276,6 @@ sub GenerateModule
$backendClassName = "InspectorBackendDispatcher";
$backendJSStubName = "InspectorBackendStub";
- my @backendHead;
- push(@backendHead, " ${backendClassName}(InspectorAgent* inspectorAgent) : m_inspectorAgent(inspectorAgent) { }");
- push(@backendHead, " void reportProtocolError(const long callId, const String& errorText) const;");
- push(@backendHead, " void dispatch(const String& message);");
- push(@backendHead, " static bool getCommandName(const String& message, String* result);");
- $backendConstructor = join("\n", @backendHead);
- $backendFooter = " InspectorAgent* m_inspectorAgent;";
$backendTypes{"Inspector"} = 1;
$backendTypes{"InspectorClient"} = 1;
$backendTypes{"PassRefPtr"} = 1;
@@ -418,7 +418,6 @@ sub generateDocumentationEvent
push(@lines, "<pre style='background: lightGrey; padding: 10px'>");
push(@lines, "{");
- push(@lines, " seq: &lt;number&gt;,");
push(@lines, " type: \"event\",");
push(@lines, " domain: \"$domain\",");
if (scalar(@argsFiltered)) {
@@ -476,12 +475,16 @@ sub generateBackendFunction
my $domain = $interface->name;
my $domainAccessor = typeTraits($domain, "domainAccessor");
$backendTypes{$domain} = 1;
+ $backendDomains{$domain} = 1;
push(@function, " if (!$domainAccessor)");
push(@function, " protocolErrors->pushString(\"Protocol Error: $domain handler is not available.\");");
push(@function, "");
# declare local variables for out arguments.
push(@function, map(" " . typeTraits($_->type, "variable") . " " . $_->name . " = " . typeTraits($_->type, "defaultValue") . ";", @outArgs));
+ push(@function, "");
+ push(@function, " ErrorString error;");
+ push(@function, "");
my $indent = "";
if (scalar(@inArgs)) {
@@ -497,12 +500,9 @@ sub generateBackendFunction
$indent = " ";
}
- push(@function, "$indent ErrorString error;");
my $args = join(", ", ("&error", map($_->name, @inArgs), map("&" . $_->name, @outArgs)));
push(@function, "$indent if (!protocolErrors->length())");
push(@function, "$indent $domainAccessor->$functionName($args);");
- push(@function, "$indent if (error.length())");
- push(@function, "$indent protocolErrors->pushString(error);");
if (scalar(@inArgs)) {
push(@function, " } else {");
push(@function, " protocolErrors->pushString(\"Protocol Error: 'arguments' property with type 'object' was not found.\");");
@@ -510,20 +510,22 @@ sub generateBackendFunction
}
push(@function, " // use InspectorFrontend as a marker of WebInspector availability");
- push(@function, " if ((callId || protocolErrors->length()) && m_inspectorAgent->hasFrontend()) {");
+ push(@function, " if (callId || protocolErrors->length()) {");
push(@function, " RefPtr<InspectorObject> responseMessage = InspectorObject::create();");
- push(@function, " responseMessage->setNumber(\"seq\", callId);");
+ push(@function, " responseMessage->setNumber(\"requestId\", callId);");
push(@function, "");
push(@function, " if (protocolErrors->length())");
- push(@function, " responseMessage->setArray(\"errors\", protocolErrors);");
+ push(@function, " responseMessage->setArray(\"protocolErrors\", protocolErrors);");
if (scalar(@outArgs)) {
push(@function, " else {");
+ push(@function, " if (error.length())");
+ push(@function, " responseMessage->setString(\"error\", error);");
push(@function, " RefPtr<InspectorObject> responseBody = InspectorObject::create();");
push(@function, map(" responseBody->set" . typeTraits($_->type, "JSONType") . "(\"" . $_->name . "\", " . $_->name . ");", @outArgs));
push(@function, " responseMessage->setObject(\"body\", responseBody);");
push(@function, " }");
}
- push(@function, " m_inspectorAgent->inspectorClient()->sendMessageToFrontend(responseMessage->toJSONString());");
+ push(@function, " m_inspectorClient->sendMessageToFrontend(responseMessage->toJSONString());");
push(@function, " }");
@@ -551,7 +553,7 @@ sub generateDocumentationCommand
my @inArgs = grep($_->direction eq "in" && !($_->name eq "callId") , @{$function->parameters});
push(@lines, "<pre style='background: lightGrey; padding: 10px'>");
push(@lines, "request: {");
- push(@lines, " seq: &lt;number&gt;,");
+ push(@lines, " id: &lt;number&gt;,");
push(@lines, " type: \"request\",");
push(@lines, " domain: \"" . $interface->name . "\",");
if (scalar(@inArgs)) {
@@ -571,7 +573,7 @@ sub generateDocumentationCommand
my @outArgs = grep($_->direction eq "out", @{$function->parameters});
push(@lines, "");
push(@lines, "response: {");
- push(@lines, " seq: &lt;number&gt;,");
+ push(@lines, " requestId: &lt;number&gt;,");
if (scalar(@outArgs)) {
push(@lines, " type: \"response\",");
push(@lines, " body: {");
@@ -597,11 +599,11 @@ sub generateBackendReportProtocolError
void ${backendClassName}::reportProtocolError(const long callId, const String& errorText) const
{
RefPtr<InspectorObject> message = InspectorObject::create();
- message->setNumber("seq", callId);
+ message->setNumber("requestId", callId);
RefPtr<InspectorArray> errors = InspectorArray::create();
errors->pushString(errorText);
- message->setArray("errors", errors);
- m_inspectorAgent->inspectorClient()->sendMessageToFrontend(message->toJSONString());
+ message->setArray("protocolErrors", errors);
+ m_inspectorClient->sendMessageToFrontend(message->toJSONString());
}
EOF
return split("\n", $reportProtocolError);
@@ -700,14 +702,14 @@ $mapEntries
return;
}
- RefPtr<InspectorValue> callIdValue = messageObject->get("seq");
+ RefPtr<InspectorValue> callIdValue = messageObject->get("id");
if (!callIdValue) {
- reportProtocolError(callId, "Protocol Error: Invalid message format. 'seq' property was not found in the request.");
+ reportProtocolError(callId, "Protocol Error: Invalid message format. 'id' property was not found in the request.");
return;
}
if (!callIdValue->asNumber(&callId)) {
- reportProtocolError(callId, "Protocol Error: Invalid message format. The type of 'seq' property should be number.");
+ reportProtocolError(callId, "Protocol Error: Invalid message format. The type of 'id' property should be number.");
return;
}
@@ -761,7 +763,7 @@ sub collectBackendJSStubFunctions
my $name = $function->signature->name;
my $argumentNames = join(",", map("\"" . $_->name . "\": \"" . typeTraits($_->type, "JSType") . "\"", grep($_->direction eq "in", @{$function->parameters})));
push(@backendJSStubs, " this._registerDelegate('{" .
- "\"seq\": 0, " .
+ "\"id\": 0, " .
"\"domain\": \"$domain\", " .
"\"command\": \"$name\", " .
"\"arguments\": {$argumentNames}" .
@@ -827,7 +829,7 @@ InspectorBackendStub.prototype = {
}
callback = args[0];
}
- request.seq = this._wrap(callback || function() {});
+ request.id = this._wrap(callback || function() {});
if (window.dumpInspectorProtocolMessages)
console.log("frontend: " + JSON.stringify(request));
@@ -855,14 +857,19 @@ InspectorBackendStub.prototype = {
for (var key in messageObject.body)
arguments.push(messageObject.body[key]);
- if ("seq" in messageObject) { // just a response for some request
- if (!messageObject.errors)
- this._callbacks[messageObject.seq].apply(null, arguments);
- else
+ if ("requestId" in messageObject) { // just a response for some request
+ if (messageObject.protocolErrors)
this.reportProtocolError(messageObject);
- --this._pendingResponsesCount;
- delete this._callbacks[messageObject.seq];
+ var callback = this._callbacks[messageObject.requestId];
+ if (callback) {
+ if (!messageObject.protocolErrors) {
+ arguments.unshift(messageObject.error);
+ callback.apply(null, arguments);
+ }
+ --this._pendingResponsesCount;
+ delete this._callbacks[messageObject.requestId];
+ }
if (this._scripts && !this._pendingResponsesCount)
this.runAfterPendingDispatches();
@@ -880,15 +887,16 @@ InspectorBackendStub.prototype = {
console.error("Protocol Error: Attempted to dispatch an unimplemented method '" + messageObject.domain + "." + messageObject.event + "'");
return;
}
+
dispatcher[messageObject.event].apply(dispatcher, arguments);
}
},
reportProtocolError: function(messageObject)
{
- console.error("Protocol Error: InspectorBackend request with seq = " + messageObject.seq + " failed.");
- for (var i = 0; i < messageObject.errors.length; ++i)
- console.error(" " + messageObject.errors[i]);
+ console.error("Protocol Error: InspectorBackend request with id = " + messageObject.requestId + " failed.");
+ for (var i = 0; i < messageObject.protocolErrors.length; ++i)
+ console.error(" " + messageObject.protocolErrors[i]);
},
runAfterPendingDispatches: function(script)
@@ -1032,6 +1040,39 @@ sub parameterDocLine
return $result;
}
+sub generateBackendAgentFieldsAndConstructor
+{
+ my @arguments;
+ my @fieldInitializers;
+
+ push(@arguments, "InspectorClient* inspectorClient");
+ push(@fieldInitializers, " : m_inspectorClient(inspectorClient)");
+ push(@backendFooter, " InspectorClient* m_inspectorClient;");
+
+ foreach my $domain (sort keys %backendDomains) {
+ # Add agent field declaration to the footer.
+ my $agentClassName = typeTraits($domain, "forward");
+ my $field = typeTraits($domain, "domainAccessor");
+ push(@backendFooter, " ${agentClassName}* ${field};");
+
+ # Add agent parameter and initializer.
+ my $arg = substr($field, 2);
+ push(@fieldInitializers, " , ${field}(${arg})");
+ push(@arguments, "${agentClassName}* ${arg}");
+ }
+
+ my $argumentString = join(", ", @arguments);
+
+ my @backendHead;
+ push(@backendHead, " ${backendClassName}(${argumentString})");
+ push(@backendHead, @fieldInitializers);
+ push(@backendHead, " { }");
+ push(@backendHead, " void reportProtocolError(const long callId, const String& errorText) const;");
+ push(@backendHead, " void dispatch(const String& message);");
+ push(@backendHead, " static bool getCommandName(const String& message, String* result);");
+ $backendConstructor = join("\n", @backendHead);
+}
+
sub finish
{
my $object = shift;
@@ -1059,6 +1100,7 @@ sub finish
push(@backendMethodsImpl, generateArgumentGetters($type));
}
}
+ generateBackendAgentFieldsAndConstructor();
push(@backendMethodsImpl, generateBackendMessageParser());
push(@backendMethodsImpl, "");
@@ -1071,7 +1113,7 @@ sub finish
undef($SOURCE);
open($HEADER, ">$outputHeadersDir/$backendClassName.h") || die "Couldn't open file $outputHeadersDir/$backendClassName.h";
- print $HEADER join("\n", generateHeader($backendClassName, \%backendTypes, $backendConstructor, \@backendConstantDeclarations, \@backendMethods, $backendFooter));
+ print $HEADER join("\n", generateHeader($backendClassName, \%backendTypes, $backendConstructor, \@backendConstantDeclarations, \@backendMethods, join("\n", @backendFooter)));
close($HEADER);
undef($HEADER);