Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1452)

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl

Issue 2339413004: Allow Mojo structs as map keys (Closed)
Patch Set: Remove left-over import Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 %}

Powered by Google App Engine
This is Rietveld 408576698