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

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

Issue 2014403002: Mojo C++ bindings: custom type mapping of map (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/tools/bindings/generators/cpp_templates/struct_data_view_declaration.tmpl ('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 {{struct.name}}DataView::{{struct.name}}DataView( 1 {{struct.name}}DataView::{{struct.name}}DataView(
2 internal::{{struct.name}}_Data* data, 2 internal::{{struct.name}}_Data* data,
3 mojo::internal::SerializationContext* context) 3 mojo::internal::SerializationContext* context)
4 : data_(data), context_(context) { 4 : data_(data), context_(context) {
5 DCHECK(data_); 5 DCHECK(data_);
6 } 6 }
7 7
8 {%- for pf in struct.packed.packed_fields_in_ordinal_order %} 8 {%- for pf in struct.packed.packed_fields_in_ordinal_order %}
9 {%- set kind = pf.field.kind -%} 9 {%- set kind = pf.field.kind -%}
10 {%- set name = pf.field.name -%} 10 {%- set name = pf.field.name -%}
11 {%- if kind|is_struct_kind or kind|is_array_kind or kind|is_string_kind %} 11 {%- if kind|is_struct_kind or kind|is_array_kind or kind|is_string_kind or
12 kind|is_map_kind %}
12 {#- Does nothing. They are already defined in the class declaration. #} 13 {#- Does nothing. They are already defined in the class declaration. #}
13 {%- elif kind|is_map_kind %}
14 bool {{struct.name}}DataView::Read{{name|under_to_camel}}(
15 {{kind|cpp_wrapper_type}}* value) {
16 {%- if pf.min_version != 0 %}
17 auto pointer = data_->header_.version >= {{pf.min_version}}
18 ? data_->{{name}}.ptr : nullptr;
19 {%- else %}
20 auto pointer = data_->{{name}}.ptr;
21 {%- endif %}
22 return mojo::internal::Deserialize<{{kind|unmapped_type_for_serializer}}>(
23 pointer, value, context_);
24 }
25 14
26 {%- elif kind|is_union_kind %} 15 {%- elif kind|is_union_kind %}
27 bool {{struct.name}}DataView::Read{{name|under_to_camel}}( 16 bool {{struct.name}}DataView::Read{{name|under_to_camel}}(
28 {{kind|cpp_wrapper_type}}* value) { 17 {{kind|cpp_wrapper_type}}* value) {
29 {%- if pf.min_version != 0 %} 18 {%- if pf.min_version != 0 %}
30 auto pointer = data_->header_.version >= {{pf.min_version}} 19 auto pointer = data_->header_.version >= {{pf.min_version}}
31 ? &data_->{{name}} : nullptr; 20 ? &data_->{{name}} : nullptr;
32 {%- else %} 21 {%- else %}
33 auto pointer = &data_->{{name}}; 22 auto pointer = &data_->{{name}};
34 {%- endif %} 23 {%- endif %}
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 {{kind|cpp_wrapper_type}} {{struct.name}}DataView::{{name}}() const { 87 {{kind|cpp_wrapper_type}} {{struct.name}}DataView::{{name}}() const {
99 {%- if pf.min_version != 0 %} 88 {%- if pf.min_version != 0 %}
100 if (data_->header_.version < {{pf.min_version}}) 89 if (data_->header_.version < {{pf.min_version}})
101 return {{kind|cpp_wrapper_type}}{}; 90 return {{kind|cpp_wrapper_type}}{};
102 {%- endif %} 91 {%- endif %}
103 return static_cast<{{kind|cpp_wrapper_type}}>(data_->{{name}}); 92 return static_cast<{{kind|cpp_wrapper_type}}>(data_->{{name}});
104 } 93 }
105 {%- endif %} 94 {%- endif %}
106 {%- endfor %} 95 {%- endfor %}
107 96
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/struct_data_view_declaration.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698