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

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl

Issue 1524703002: [mojo] Support native types with mojom wire format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-5-pickles
Patch Set: doc Created 5 years 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
OLDNEW
1 {%- import "struct_macros.tmpl" as struct_macros %} 1 {%- import "struct_macros.tmpl" as struct_macros %}
2 size_t GetSerializedSize_(const {{struct.name}}Ptr& input) { 2 size_t GetSerializedSize_(const {{struct.name}}Ptr& input) {
3 if (!input) 3 if (!input)
4 return 0; 4 return 0;
5 {{struct_macros.get_serialized_size(struct, "input->%s")}} 5 {{struct_macros.get_serialized_size(struct, "input->%s")}}
6 return size; 6 return size;
7 } 7 }
8 8
9 void Serialize_({{struct.name}}Ptr input, mojo::internal::Buffer* buf, 9 void Serialize_({{struct.name}}Ptr input, mojo::internal::Buffer* buf,
10 internal::{{struct.name}}_Data** output) { 10 internal::{{struct.name}}_Data** output) {
(...skipping 11 matching lines...) Expand all
22 bool success = true; 22 bool success = true;
23 if (input) { 23 if (input) {
24 {{struct.name}}Ptr result({{struct.name}}::New()); 24 {{struct.name}}Ptr result({{struct.name}}::New());
25 {{struct_macros.deserialize(struct, "input", "result->%s", "context", "succe ss")|indent(2)}} 25 {{struct_macros.deserialize(struct, "input", "result->%s", "context", "succe ss")|indent(2)}}
26 *output = result.Pass(); 26 *output = result.Pass();
27 } else { 27 } else {
28 output->reset(); 28 output->reset();
29 } 29 }
30 return success; 30 return success;
31 } 31 }
32
33 {%- if not variant %}
34
35 {{struct.name}}_Reader::{{struct.name}}_Reader(
36 internal::{{struct.name}}_Data* data,
37 mojo::internal::SerializationContext* context)
38 : data_(data), context_(context) { }
39
40 {%- for pf in struct.packed.packed_fields_in_ordinal_order %}
41 {%- set name = pf.field.name -%}
42 {%- set kind = pf.field.kind -%}
43 {%- if kind|is_struct_kind %}
44 {{kind|get_name_for_kind}}_Reader {{struct.name}}_Reader::{{name}}() const {
45 return {{kind|get_name_for_kind}}_Reader(data_->{{name}}.ptr, context_);
46 }
47 {%- endif %}
48 {%- endfor %}
49
50 {%- endif %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698