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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl

Issue 2076313002: Mojo C++ bindings: expose serialization public API for mojo structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « mojo/public/interfaces/bindings/tests/test_wtf_types.mojom ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
index b4abd686decf4d889ffbf2308a84016ffc88e987..1c4d9f71b890f167c95918582b6b721568c41a6a 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
@@ -52,6 +52,23 @@ class {{struct.name}} {
T, {{struct.name}}>::value>::type* = nullptr>
bool Equals(const T& other) const;
+{%- set serialization_result_type = "mojo::WTFArray<uint8_t>"
+ if for_blink else "mojo::Array<uint8_t>" %}
+
+ template <typename UserType>
+ static {{serialization_result_type}} Serialize(UserType* input) {
+ return mojo::internal::StructSerializeImpl<
+ {{struct.name}}Ptr, {{serialization_result_type}}>(input);
+ }
+
+ template <typename UserType>
+ static bool Deserialize({{serialization_result_type}} input,
+ UserType* output) {
+ return mojo::internal::StructDeserializeImpl<
+ {{struct.name}}Ptr, {{serialization_result_type}}>(
+ std::move(input), output);
+ }
+
{#--- Struct members #}
{% for field in struct.fields %}
{%- set type = field.kind|cpp_wrapper_type %}
« no previous file with comments | « mojo/public/interfaces/bindings/tests/test_wtf_types.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698