| Index: mojo/public/tools/bindings/generators/cpp_templates/struct_traits_declaration.tmpl
|
| diff --git a/mojo/public/tools/bindings/generators/cpp_templates/struct_traits_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/struct_traits_declaration.tmpl
|
| index 24efbd5531064d623c8922793359cd78f98022ac..aad9f66da51e1198b7811f5b06a38f444affa494 100644
|
| --- a/mojo/public/tools/bindings/generators/cpp_templates/struct_traits_declaration.tmpl
|
| +++ b/mojo/public/tools/bindings/generators/cpp_templates/struct_traits_declaration.tmpl
|
| @@ -9,9 +9,14 @@ struct {{export_attribute}} StructTraits<{{mojom_type}}::DataView,
|
| {%- for field in struct.fields %}
|
| {%- set return_ref = field.kind|is_object_kind or
|
| field.kind|is_any_handle_or_interface_kind %}
|
| +{# We want the field accessor to be const whenever possible to allow #}
|
| +{# structs to be used as map keys. #}
|
| +{# TODO(tibell): Make this change more precise to deal with e.g. #}
|
| +{# copyable_pass_by_value type-mapped structs. #}
|
| +{%- set maybe_const = "" if field.kind|contains_handles else "const" %}
|
| {%- if return_ref %}
|
| - static decltype({{mojom_type}}::{{field.name}})& {{field.name}}(
|
| - {{mojom_type}}Ptr& input) {
|
| + static {{maybe_const}} decltype({{mojom_type}}::{{field.name}})& {{field.name}}(
|
| + {{maybe_const}} {{mojom_type}}Ptr& input) {
|
| return input->{{field.name}};
|
| }
|
| {%- else %}
|
|
|