Chromium Code Reviews| Index: mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl |
| diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl |
| index e905904174d920db89fbd7ef087b7fb70b890929..d12554c19e07130eac5549dc5213f3c9716e1df3 100644 |
| --- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl |
| +++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl |
| @@ -65,3 +65,18 @@ void {{union.name}}::DestroyActive() { |
| {%- endfor %} |
| } |
| } |
| + |
| +{%- if union|is_hashable %} |
| +size_t {{union.name}}::Hash(size_t seed) const { |
| + switch (tag_) { |
|
Sam McNally
2016/09/21 04:57:58
Should |tag_| influence the hash?
tibell
2016/09/21 07:10:54
Done.
We better if we have an empty union (e.g. a
|
| +{% for field in union.fields %} |
| + case Tag::{{field.name|upper}}: |
| + return mojo::internal::Hash(seed, data_.{{field.name}}); |
| +{%- endfor %} |
| + default: |
| + NOTREACHED(); |
| + return seed; |
| + } |
| +} |
| + |
| +{%- endif %} |