Chromium Code Reviews| 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..82af93720fd02340daf4dfb2b720decc65fe6fda 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,12 @@ 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. #} |
| +{%- set const = "" if field.kind|contains_handles else "const" %} |
|
yzshen1
2016/09/20 23:44:40
Does it make sense to name this variable "maybe_co
tibell
2016/09/21 07:10:53
Done.
yzshen1
2016/09/21 23:17:52
It would require adding new attribute in typemap c
tibell
2016/09/22 05:17:23
Done.
|
| {%- if return_ref %} |
| - static decltype({{mojom_type}}::{{field.name}})& {{field.name}}( |
| - {{mojom_type}}Ptr& input) { |
| + static {{const}} decltype({{mojom_type}}::{{field.name}})& {{field.name}}( |
| + {{const}} {{mojom_type}}Ptr& input) { |
| return input->{{field.name}}; |
| } |
| {%- else %} |