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

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

Issue 2635153002: Pref service: expose all read-only PrefStores through Mojo (Closed)
Patch Set: Remove debug print Created 3 years, 10 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/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 %}

Powered by Google App Engine
This is Rietveld 408576698