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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% from "enum_macros.tmpl" import enum_decl -%} 1 {% from "enum_macros.tmpl" import enum_decl -%}
2 2
3 class {{struct.name}} { 3 class {{struct.name}} {
4 public: 4 public:
5 using DataView = {{struct.name}}DataView; 5 using DataView = {{struct.name}}DataView;
6 using Data_ = internal::{{struct.name}}_Data; 6 using Data_ = internal::{{struct.name}}_Data;
7 7
8 {#--- Enums #} 8 {#--- Enums #}
9 {%- for enum in struct.enums -%} 9 {%- for enum in struct.enums -%}
10 {%- if enum|is_native_only_kind %} 10 {%- if enum|is_native_only_kind %}
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 {{struct.name}}Ptr Clone() const; 45 {{struct.name}}Ptr Clone() const;
46 46
47 // Equals() is a template so it is only instantiated if it is used. Thus, the 47 // Equals() is a template so it is only instantiated if it is used. Thus, the
48 // bindings generator does not need to know whether Equals() or == operator 48 // bindings generator does not need to know whether Equals() or == operator
49 // are available for members. 49 // are available for members.
50 template <typename T, 50 template <typename T,
51 typename std::enable_if<std::is_same< 51 typename std::enable_if<std::is_same<
52 T, {{struct.name}}>::value>::type* = nullptr> 52 T, {{struct.name}}>::value>::type* = nullptr>
53 bool Equals(const T& other) const; 53 bool Equals(const T& other) const;
54 54
55 {%- set serialization_result_type = "mojo::WTFArray<uint8_t>"
56 if for_blink else "mojo::Array<uint8_t>" %}
57
58 template <typename UserType>
59 static {{serialization_result_type}} Serialize(UserType* input) {
60 return mojo::internal::StructSerializeImpl<
61 {{struct.name}}Ptr, {{serialization_result_type}}>(input);
62 }
63
64 template <typename UserType>
65 static bool Deserialize({{serialization_result_type}} input,
66 UserType* output) {
67 return mojo::internal::StructDeserializeImpl<
68 {{struct.name}}Ptr, {{serialization_result_type}}>(
69 std::move(input), output);
70 }
71
55 {#--- Struct members #} 72 {#--- Struct members #}
56 {% for field in struct.fields %} 73 {% for field in struct.fields %}
57 {%- set type = field.kind|cpp_wrapper_type %} 74 {%- set type = field.kind|cpp_wrapper_type %}
58 {%- set name = field.name %} 75 {%- set name = field.name %}
59 {{type}} {{name}}; 76 {{type}} {{name}};
60 {%- endfor %} 77 {%- endfor %}
61 }; 78 };
62 79
OLDNEW
« 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