OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |