Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Unified Diff: third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template

Issue 1702673002: DevTools: migrate remote debugging protocol generators to jinja2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template
diff --git a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template
new file mode 100644
index 0000000000000000000000000000000000000000..96db1577221ec1589daab6ddb4cb04593b9918e0
--- /dev/null
+++ b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template
@@ -0,0 +1,69 @@
+// This file is generated
+
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "platform/inspector_protocol/{{class_name}}.h"
+
+namespace blink {
+namespace protocol {
+
+template<>
+PassRefPtr<JSONValue> toValue(const String& param)
+{
+ return JSONString::create(param);
+}
+
+OptionalValue<String> optional(const String& value)
+{
+ return value.isNull() ? OptionalValue<String>() : OptionalValue<String>(value);
+}
+
+// ------------- Enum values from types.
+{% for domain in api.domains %}
+ {% for type in domain.types %}
+ {% if "enum" in type %}
+
+namespace {{domain.domain}} {
+namespace {{type.id}}Enum {
+ {% for literal in type.enum %}
+const char* {{ literal | dash_to_camelcase}} = "{{literal}}";
+ {% endfor %}
+} // {{type.id}}Enum
+} // {{domain.domain}}
+ {% endif %}
+ {% for property in type.properties %}
+ {% if "enum" in property %}
+namespace {{domain.domain}} {
+ {% for literal in property.enum %}
+const char* {{type.id}}::{{property.name | to_title_case}}Enum::{{ literal | dash_to_camelcase}} = "{{literal}}";
+ {% endfor %}
+} // {{domain.domain}}
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+{% endfor %}
+
+// ------------- Enum values from params.
+{% for domain in api.domains %}
+ {% for command in join_arrays(domain, ["commands", "events"]) %}
+ {% for param in join_arrays(command, ["parameters", "returns"]) %}
+ {% if "enum" in param %}
+
+namespace {{domain.domain}} {
+namespace {{command.name | to_title_case}} {
+namespace {{param.name | to_title_case}}Enum {
+ {% for literal in param.enum %}
+const char* {{ literal | to_title_case}} = "{{literal}}";
+ {% endfor %}
+} // {{param.name | to_title_case}}Enum
+} // {{command.name | to_title_case }}
+} // {{domain.domain}}
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+{% endfor %}
+
+} // namespace protocol
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698