[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 11:52:29 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit ac17d303ac2e5bdc08f5a04aef7993f597abab10
Author: loislo at chromium.org <loislo at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Aug 10 08:41:17 2010 +0000
2010-08-09 Ilya Tikhonovsky <loislo at chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: small refactoring for CodeGeneratorInspector.
A number of push calls were replaced by embedded text.
Just for improve code readability.
https://bugs.webkit.org/show_bug.cgi?id=43770
* inspector/CodeGeneratorInspector.pm:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65058 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4df9639..5c6f1c9 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,14 @@
+2010-08-09 Ilya Tikhonovsky <loislo at chromium.org>
+
+ Reviewed by Yury Semikhatsky.
+
+ Web Inspector: small refactoring for CodeGeneratorInspector.
+ A number of push calls were replaced by embedded text.
+ Just for improve code readability.
+ https://bugs.webkit.org/show_bug.cgi?id=43770
+
+ * inspector/CodeGeneratorInspector.pm:
+
2010-08-09 Eric Seidel <eric at webkit.org>
Reviewed by Adam Barth.
diff --git a/WebCore/inspector/CodeGeneratorInspector.pm b/WebCore/inspector/CodeGeneratorInspector.pm
index f46857a..50a29b9 100644
--- a/WebCore/inspector/CodeGeneratorInspector.pm
+++ b/WebCore/inspector/CodeGeneratorInspector.pm
@@ -386,54 +386,57 @@ sub generateBackendDispatcher
{
my @body;
my @methods = map($backendMethods{$_}, keys %backendMethods);
- my @mapEntries = map("dispatchMap.add(\"$_\", &${backendClassName}::$_);", @methods);
-
- push(@body, "void ${backendClassName}::dispatch(const String& message)");
- push(@body, "{");
- push(@body, " typedef void (${backendClassName}::*CallHandler)(PassRefPtr<InspectorArray> args);");
- push(@body, " typedef HashMap<String, CallHandler> DispatchMap;");
- push(@body, " DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, );");
- push(@body, " if (dispatchMap.isEmpty()) {");
- push(@body, map(" $_", @mapEntries));
- push(@body, " }");
- push(@body, "");
- push(@body, " RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);");
- push(@body, " if (!parsedMessage) {");
- push(@body, " ASSERT_NOT_REACHED();");
- push(@body, " reportProtocolError(0, \"dispatch\", \"Error: Invalid message format. Message should be in JSON format.\");");
- push(@body, " return;");
- push(@body, " }");
- push(@body, "");
- push(@body, " RefPtr<InspectorArray> messageArray = parsedMessage->asArray();");
- push(@body, " if (!messageArray) {");
- push(@body, " ASSERT_NOT_REACHED();");
- push(@body, " reportProtocolError(0, \"dispatch\", \"Error: Invalid message format. The message should be a JSONified array of arguments.\");");
- push(@body, " return;");
- push(@body, " }");
- push(@body, "");
- push(@body, " if (!messageArray->length()) {");
- push(@body, " ASSERT_NOT_REACHED();");
- push(@body, " reportProtocolError(0, \"dispatch\", \"Error: Invalid message format. Empty message was received.\");");
- push(@body, " return;");
- push(@body, " }");
- push(@body, "");
- push(@body, " String methodName;");
- push(@body, " if (!messageArray->get(0)->asString(&methodName)) {");
- push(@body, " ASSERT_NOT_REACHED();");
- push(@body, " reportProtocolError(0, \"dispatch\", \"Error: Invalid message format. The first element of the message should be method name.\");");
- push(@body, " return;");
- push(@body, " }");
- push(@body, "");
- push(@body, " HashMap<String, CallHandler>::iterator it = dispatchMap.find(methodName);");
- push(@body, " if (it == dispatchMap.end()) {");
- push(@body, " ASSERT_NOT_REACHED();");
- push(@body, " reportProtocolError(0, \"dispatch\", String::format(\"Error: Invalid method name. '%s' wasn't found.\", methodName.utf8().data()));");
- push(@body, " return;");
- push(@body, " }");
- push(@body, "");
- push(@body, " ((*this).*it->second)(messageArray);");
- push(@body, "}");
- return @body;
+ my @mapEntries = map(" dispatchMap.add(\"$_\", &${backendClassName}::$_);", @methods);
+ my $mapEntries = join("\n", @mapEntries);
+
+ my $backendDispatcherBody = << "EOF";
+void ${backendClassName}::dispatch(const String& message)
+{
+ typedef void (${backendClassName}::*CallHandler)(PassRefPtr<InspectorArray> args);
+ typedef HashMap<String, CallHandler> DispatchMap;
+ DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, );
+ if (dispatchMap.isEmpty()) {
+$mapEntries
+ }
+
+ RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);
+ if (!parsedMessage) {
+ ASSERT_NOT_REACHED();
+ reportProtocolError(0, "dispatch", "Error: Invalid message format. Message should be in JSON format.");
+ return;
+ }
+
+ RefPtr<InspectorArray> messageArray = parsedMessage->asArray();
+ if (!messageArray) {
+ ASSERT_NOT_REACHED();
+ reportProtocolError(0, "dispatch", "Error: Invalid message format. The message should be a JSONified array of arguments.");
+ return;
+ }
+
+ if (!messageArray->length()) {
+ ASSERT_NOT_REACHED();
+ reportProtocolError(0, "dispatch", "Error: Invalid message format. Empty message was received.");
+ return;
+ }
+
+ String methodName;
+ if (!messageArray->get(0)->asString(&methodName)) {
+ ASSERT_NOT_REACHED();
+ reportProtocolError(0, "dispatch", "Error: Invalid message format. The first element of the message should be method name.");
+ return;
+ }
+
+ HashMap<String, CallHandler>::iterator it = dispatchMap.find(methodName);
+ if (it == dispatchMap.end()) {
+ ASSERT_NOT_REACHED();
+ reportProtocolError(0, "dispatch", String::format("Error: Invalid method name. '%s' wasn't found.", methodName.utf8().data()));
+ return;
+ }
+
+ ((*this).*it->second)(messageArray);
+}
+EOF
+ return split("\n", $backendDispatcherBody);
}
sub generateHeader
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list