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

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

Issue 2741943002: mojo bindings: Support enums with no values (Closed)
Patch Set: new test & template change Created 3 years, 9 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 92073bc5d5973e07791753c57e3de40799b4e286..f0d503e5e08e33376282358777b2d5e0c203ba63 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl
@@ -15,6 +15,7 @@ enum class {{enum_name}} : int32_t {
};
inline std::ostream& operator<<(std::ostream& os, {{enum_name}} value) {
+{%- if enum.fields %}
switch(value) {
{%- for _, values in enum.fields|groupby('numeric_value') %}
case {{enum_name}}::{{values[0].name}}:
@@ -31,6 +32,9 @@ inline std::ostream& operator<<(std::ostream& os, {{enum_name}} value) {
default:
return os << "Unknown {{enum_name}} value: " << static_cast<int32_t>(value);
}
+{%- else %}
+ return os << "Unknown {{enum_name}} value: " << static_cast<int32_t>(value);
+{%- endif %}
}
{#- Returns true if the given enum value exists in this version of enum. #}

Powered by Google App Engine
This is Rietveld 408576698