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

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

Issue 2253293002: Mojo C++ bindings: change the first template parameter of StructTraits and UnionTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@91_extra
Patch Set: rebase Created 4 years, 4 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
OLDNEW
1 {%- set mojom_type = union|get_qualified_name_for_kind %} 1 {%- set mojom_type = union|get_qualified_name_for_kind %}
2 2
3 // static 3 // static
4 bool UnionTraits<{{mojom_type}}, {{mojom_type}}Ptr>::Read( 4 bool UnionTraits<{{mojom_type}}::DataView, {{mojom_type}}Ptr>::Read(
5 {{mojom_type}}DataView input, 5 {{mojom_type}}::DataView input,
6 {{mojom_type}}Ptr* output) { 6 {{mojom_type}}Ptr* output) {
7 *output = {{mojom_type}}::New(); 7 *output = {{mojom_type}}::New();
8 {{mojom_type}}Ptr& result = *output; 8 {{mojom_type}}Ptr& result = *output;
9 9
10 internal::UnionAccessor<{{mojom_type}}> result_acc(result.get()); 10 internal::UnionAccessor<{{mojom_type}}> result_acc(result.get());
11 switch (input.tag()) { 11 switch (input.tag()) {
12 {%- for field in union.fields %} 12 {%- for field in union.fields %}
13 case {{mojom_type}}::Tag::{{field.name|upper}}: { 13 case {{mojom_type}}::Tag::{{field.name|upper}}: {
14 {%- set name = field.name %} 14 {%- set name = field.name %}
15 {%- set kind = field.kind %} 15 {%- set kind = field.kind %}
(...skipping 17 matching lines...) Expand all
33 result->set_{{name}}(input.{{name}}()); 33 result->set_{{name}}(input.{{name}}());
34 {%- endif %} 34 {%- endif %}
35 break; 35 break;
36 } 36 }
37 {%- endfor %} 37 {%- endfor %}
38 default: 38 default:
39 return false; 39 return false;
40 } 40 }
41 return true; 41 return true;
42 } 42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698