Chromium Code Reviews| Index: mojo/public/tools/bindings/generators/cpp_templates/union_traits_declaration.tmpl |
| diff --git a/mojo/public/tools/bindings/generators/cpp_templates/union_traits_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/union_traits_declaration.tmpl |
| index 583d5bebc1742d3f872336c77b3d57e6b1850547..f54a58508d62138c2c0e0eb1009ca53e40568ccf 100644 |
| --- a/mojo/public/tools/bindings/generators/cpp_templates/union_traits_declaration.tmpl |
| +++ b/mojo/public/tools/bindings/generators/cpp_templates/union_traits_declaration.tmpl |
| @@ -11,19 +11,13 @@ struct {{export_attribute}} UnionTraits<{{mojom_type}}::DataView, |
| } |
| {%- for field in union.fields %} |
| -{%- set return_ref = field.kind|is_object_kind or |
| - field.kind|is_any_handle_or_interface_kind %} |
| -{%- if return_ref %} |
| - static decltype(std::declval<{{mojom_type}}>().get_{{field.name}}()) |
| - {{field.name}}({{mojom_type}}Ptr& input) { |
| +{%- set maybe_const_in = "" if field.kind|contains_handles else "const" %} |
| +{%- set maybe_const_out = "" if field.kind|contains_handles or not field.kind|is_reference_kind else "const" %} |
| +{# We want the field accessor to be const whenever possible to allow |
|
yzshen1
2016/09/22 23:48:56
nit: use the same indent as line 15
tibell
2016/09/23 00:07:07
Done.
|
| + structs to be used as map keys. #} |
| + static {{maybe_const_out}} {{field.kind|cpp_union_trait_getter_return_type}} {{field.name}}({{maybe_const_in}} {{mojom_type}}Ptr& input) { |
| return input->get_{{field.name}}(); |
| } |
| -{%- else %} |
| - static decltype(std::declval<{{mojom_type}}>().get_{{field.name}}()) |
| - {{field.name}}(const {{mojom_type}}Ptr& input) { |
| - return input->get_{{field.name}}(); |
| - } |
| -{%- endif %} |
| {%- endfor %} |
| static bool Read({{mojom_type}}::DataView input, {{mojom_type}}Ptr* output); |