| OLD | NEW |
| (Empty) |
| 1 {%- set mojom_type = union|get_qualified_name_for_kind %} | |
| 2 | |
| 3 // static | |
| 4 bool UnionTraits<{{mojom_type}}::DataView, {{mojom_type}}Ptr>::Read( | |
| 5 {{mojom_type}}::DataView input, | |
| 6 {{mojom_type}}Ptr* output) { | |
| 7 *output = {{mojom_type}}::New(); | |
| 8 {{mojom_type}}Ptr& result = *output; | |
| 9 | |
| 10 internal::UnionAccessor<{{mojom_type}}> result_acc(result.get()); | |
| 11 switch (input.tag()) { | |
| 12 {%- for field in union.fields %} | |
| 13 case {{mojom_type}}::Tag::{{field.name|upper}}: { | |
| 14 {%- set name = field.name %} | |
| 15 {%- set kind = field.kind %} | |
| 16 {%- set serializer_type = kind|unmapped_type_for_serializer %} | |
| 17 {%- if kind|is_object_kind %} | |
| 18 result_acc.SwitchActive({{mojom_type}}::Tag::{{name|upper}}); | |
| 19 if (!input.Read{{name|under_to_camel}}(result_acc.data()->{{name}})) | |
| 20 return false; | |
| 21 | |
| 22 {%- elif kind|is_any_handle_or_interface_kind %} | |
| 23 auto result_{{name}} = input.Take{{name|under_to_camel}}(); | |
| 24 result->set_{{name}}(std::move(result_{{name}})); | |
| 25 | |
| 26 {%- elif kind|is_enum_kind %} | |
| 27 decltype(result->get_{{name}}()) result_{{name}}; | |
| 28 if (!input.Read{{name|under_to_camel}}(&result_{{name}})) | |
| 29 return false; | |
| 30 result->set_{{name}}(result_{{name}}); | |
| 31 | |
| 32 {%- else %} | |
| 33 result->set_{{name}}(input.{{name}}()); | |
| 34 {%- endif %} | |
| 35 break; | |
| 36 } | |
| 37 {%- endfor %} | |
| 38 default: | |
| 39 return false; | |
| 40 } | |
| 41 return true; | |
| 42 } | |
| OLD | NEW |