OLD | NEW |
1 {#--- | 1 {#--- |
2 Macro for enum definition, and the declaration of associated functions. | 2 Macro for enum definition, and the declaration of associated functions. |
3 ---#} | 3 ---#} |
4 {%- macro enum_decl(enum) %} | 4 {%- macro enum_decl(enum) %} |
5 enum class {{enum.name}} : int32_t { | 5 enum class {{enum.name}} : int32_t { |
6 {%- for field in enum.fields %} | 6 {%- for field in enum.fields %} |
7 {%- if field.value %} | 7 {%- if field.value %} |
8 {{field.name}} = {{field.value|expression_to_text}}, | 8 {{field.name}} = {{field.value|expression_to_text}}, |
9 {%- else %} | 9 {%- else %} |
10 {{field.name}}, | 10 {{field.name}}, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 } | 69 } |
70 {%- endmacro %} | 70 {%- endmacro %} |
71 | 71 |
72 {%- macro is_known_enum_value(enum) %} | 72 {%- macro is_known_enum_value(enum) %} |
73 inline bool IsKnownEnumValue({{enum|get_name_for_kind}} value) { | 73 inline bool IsKnownEnumValue({{enum|get_name_for_kind}} value) { |
74 return {{enum|get_qualified_name_for_kind(internal=True)}}::IsKnownValue( | 74 return {{enum|get_qualified_name_for_kind(internal=True)}}::IsKnownValue( |
75 static_cast<int32_t>(value)); | 75 static_cast<int32_t>(value)); |
76 } | 76 } |
77 {%- endmacro %} | 77 {%- endmacro %} |
| 78 |
| 79 {%- macro enum_hash(enum) %} |
| 80 template <> |
| 81 struct hash<{{enum|get_qualified_name_for_kind}}> |
| 82 : public mojo::internal::EnumHashImpl<{{enum|get_qualified_name_for_kind}}>
{}; |
| 83 {%- endmacro %} |
OLD | NEW |