aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/third_party/inspector_protocol/templates/Imported_h.template
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/third_party/inspector_protocol/templates/Imported_h.template')
-rw-r--r--deps/v8/third_party/inspector_protocol/templates/Imported_h.template45
1 files changed, 39 insertions, 6 deletions
diff --git a/deps/v8/third_party/inspector_protocol/templates/Imported_h.template b/deps/v8/third_party/inspector_protocol/templates/Imported_h.template
index 4c9d24bd5f..f2e576a9c4 100644
--- a/deps/v8/third_party/inspector_protocol/templates/Imported_h.template
+++ b/deps/v8/third_party/inspector_protocol/templates/Imported_h.template
@@ -1,4 +1,4 @@
-// This file is generated
+// This file is generated by Imported_h.template.
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -17,6 +17,37 @@
{% for namespace in config.protocol.namespace %}
namespace {{namespace}} {
{% endfor %}
+
+using Exported = {{"::".join(config.imported.namespace)}}::Exported;
+
+#ifndef {{"_".join(config.protocol.namespace)}}_imported_imported_h
+#define {{"_".join(config.protocol.namespace)}}_imported_imported_h
+
+class {{config.lib.export_macro}} ImportedValue : public Value {
+public:
+ static std::unique_ptr<ImportedValue> fromExported(const Exported* value) {
+ return std::unique_ptr<ImportedValue>(new ImportedValue(value));
+ }
+
+ void writeJSON(StringBuilder* output) const override {
+ auto json = m_exported->toJSONString();
+ String local_json = ({{config.imported.from_imported_string % "std::move(json)"}});
+ StringUtil::builderAppend(*output, local_json);
+ }
+ void writeBinary(std::vector<uint8_t>* output) const override {
+ m_exported->writeBinary(output);
+ }
+ std::unique_ptr<Value> clone() const override {
+ return std::unique_ptr<Value>(new ImportedValue(m_exported));
+ }
+
+private:
+ explicit ImportedValue(const Exported* exported) : Value(TypeImported), m_exported(exported) { }
+ const Exported* m_exported;
+};
+
+#endif // !defined({{"_".join(config.protocol.namespace)}}_imported_imported_h)
+
{% for type in domain.types %}
{% if not (type.type == "object") or not ("properties" in type) or not protocol.is_imported(domain.domain, type.id) %}{% continue %}{% endif %}
@@ -28,17 +59,18 @@ struct ValueConversions<{{"::".join(config.imported.namespace)}}::{{domain.domai
errors->addError("value expected");
return nullptr;
}
- String json = value->serialize();
- auto result = {{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}::fromJSONString({{config.imported.to_imported_string % "json"}});
+
+ std::vector<uint8_t> binary;
+ value->writeBinary(&binary);
+ auto result = {{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}::fromBinary(binary.data(), binary.size());
if (!result)
errors->addError("cannot parse");
return result;
}
- static std::unique_ptr<protocol::Value> toValue(const {{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}* value)
+ static std::unique_ptr<protocol::Value> toValue(const {{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}* exported)
{
- auto json = value->toJSONString();
- return SerializedValue::create({{config.imported.from_imported_string % "std::move(json)"}});
+ return ImportedValue::fromExported(exported);
}
static std::unique_ptr<protocol::Value> toValue(const std::unique_ptr<{{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}>& value)
@@ -46,6 +78,7 @@ struct ValueConversions<{{"::".join(config.imported.namespace)}}::{{domain.domai
return toValue(value.get());
}
};
+
{% endfor %}
{% for namespace in config.protocol.namespace %}