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/bindings/generators/js_templates/enum_definition.tmpl

Issue 99623010: Add support for enums within structs and interfaces to mojom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 11 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/bindings/generators/js_templates/enum_definition.tmpl
diff --git a/mojo/public/bindings/generators/js_templates/enum_definition.tmpl b/mojo/public/bindings/generators/js_templates/enum_definition.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..a87db5c45b19c61d6ab15e224d6ba9d8232f5c25
--- /dev/null
+++ b/mojo/public/bindings/generators/js_templates/enum_definition.tmpl
@@ -0,0 +1,12 @@
+{%- macro enum_def(enum_init, enum) %}
+ {{enum_init}} = {
+{%- set next_value = 0 %}
+{%- for field in enum.fields %}
+{%- if field.value %}
+{%- set next_value = field.value|int %}
+{%- endif %}
+ {{field.name}}: {{next_value}},
+{%- set next_value = next_value + 1 %}
+{%- endfor %}
+ };
+{%- endmacro %}

Powered by Google App Engine
This is Rietveld 408576698