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

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

Issue 2136733002: Mojo C++ bindings: add a new mode to generator to use native STL/WTF types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@67_new
Patch Set: . Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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
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 %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698