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

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

Issue 2339413004: Allow Mojo structs as map keys (Closed)
Patch Set: Address sammc's comments and improve Blink tests 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_class_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
index 0bb1cda14b5a6917971ebe470edf935e6bc7de2b..e6d04268520aa5f0f0a77a4c4e14839711d1c5ed 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
@@ -13,3 +13,16 @@
{{struct.name}}::~{{struct.name}}() {
}
+
+{%- if struct|is_hashable %}
+size_t {{struct.name}}::Hash(size_t seed) const {
+{%- for field in struct.fields %}
+{%- if for_blink %}
+ seed = mojo::internal::WTFHash(seed, this->{{field.name}});
+{%- else %}
+ seed = mojo::internal::Hash(seed, this->{{field.name}});
+{%- endif %}
+{%- endfor %}
+ return seed;
+}
+{%- endif %}

Powered by Google App Engine
This is Rietveld 408576698