Index: mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl |
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl |
index 9400ca77041e65cf319e0512101d619d4b63ecb6..a1a9b5d01aea0c0aae6f07b6239e220f46224b0c 100644 |
--- a/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl |
+++ b/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl |
@@ -78,3 +78,42 @@ template <> |
struct hash<{{enum_name}}> |
: public mojo::internal::EnumHashImpl<{{enum_name}}> {}; |
{%- endmacro %} |
+ |
+{%- macro enum_hash_blink(enum) %} |
+{%- set enum_name = enum|get_qualified_name_for_kind( |
+ flatten_nested_kind=True, include_variant=False) %} |
+{%- set hash_fn_name = enum|get_name_for_kind ~ "HashFn" %} |
+{%- set empty_value = -1000 %} |
+{%- set deleted_value = -1001 %} |
+namespace WTF { |
+struct {{hash_fn_name}} { |
+ static unsigned hash(const {{enum_name}}& value) { |
+ return 0; // TODO(tibell): Implement. |
+ } |
+ static bool equal(const {{enum_name}}& left, const {{enum_name}}& right) { |
+ return left == right; |
+ } |
+ static const bool safeToCompareToEmptyOrDeleted = true; |
+}; |
+ |
+template <> |
+struct DefaultHash<{{enum_name}}> { |
+ using Hash = {{hash_fn_name}}; |
+}; |
+ |
+template <> |
+struct HashTraits<{{enum_name}}> |
+ : public GenericHashTraits<{{enum_name}}> { |
+ static const bool hasIsEmptyValueFunction = true; |
+ static bool isEmptyValue(const {{enum_name}}& value) { |
+ return value == static_cast<{{enum_name}}>({{empty_value}}); |
+ } |
+ static void constructDeletedValue({{enum_name}}& slot, bool) { |
+ slot = static_cast<{{enum_name}}>({{deleted_value}}); |
+ } |
+ static bool isDeletedValue(const {{enum_name}}& value) { |
+ return value == static_cast<{{enum_name}}>({{deleted_value}}); |
+ } |
+}; |
+} // namespace WTF |
+{%- endmacro %} |