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

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

Issue 2159633002: [DevTools] Generate public versions of protocol classes to be exposed in v8_inspector/public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed extra files Created 4 years, 5 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
index f1a252cc904890225326d3965e6d8b7f0830bc8f..e9489f4a7b84a50ad0fcd8ddb5cae49761873012 100644
--- a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template
+++ b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template
@@ -7,6 +7,7 @@
#include "{{output_package}}/{{domain.domain}}.h"
#include "platform/inspector_protocol/DispatcherBase.h"
+#include "platform/inspector_protocol/Parser.h"
namespace blink {
namespace protocol {
@@ -22,7 +23,17 @@ namespace {{type.id}}Enum {
{% for literal in type.enum %}
const char* {{ literal | dash_to_camelcase}} = "{{literal}}";
{% endfor %}
-} // {{type.id}}Enum
+} // namespace {{type.id}}Enum
+ {% if type.exported %}
+
+namespace API {
+namespace {{type.id}}Enum {
+ {% for literal in type.enum %}
+const char* {{ literal | dash_to_camelcase}} = "{{literal}}";
+ {% endfor %}
+} // namespace {{type.id}}Enum
+} // namespace API
+ {% endif %}
{% endif %}
{% for property in type.properties %}
{% if "enum" in property %}
@@ -81,6 +92,23 @@ std::unique_ptr<{{type.id}}> {{type.id}}::clone() const
ErrorSupport errors;
return parse(serialize().get(), &errors);
}
+ {% if type.exported %}
+
+String16 {{type.id}}::toJSONString() const
+{
+ return serialize()->toJSONString();
+}
+
+// static
+std::unique_ptr<API::{{type.id}}> API::{{type.id}}::fromJSONString(const String16& json)
+{
+ ErrorSupport errors;
+ std::unique_ptr<Value> value = parseJSON(json);
+ if (!value)
+ return nullptr;
+ return protocol::{{domain.domain}}::{{type.id}}::parse(value.get(), &errors);
+}
+ {% endif %}
{% endfor %}
// ------------- Enum values from params.
@@ -94,8 +122,20 @@ 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 }}
+} // namespace {{param.name | to_title_case}}Enum
+} // namespace {{command.name | to_title_case }}
+ {% if param.exported %}
+
+namespace API {
+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 %}
+} // namespace {{param.name | to_title_case}}Enum
+} // namespace {{command.name | to_title_case }}
+} // namespace API
+ {% endif %}
{% endif %}
{% endfor %}
{% endfor %}

Powered by Google App Engine
This is Rietveld 408576698