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 |
index a87db5c45b19c61d6ab15e224d6ba9d8232f5c25..653cfaacbd0299c8ca18df43fa3131ecc80e7339 100644 |
--- a/mojo/public/bindings/generators/js_templates/enum_definition.tmpl |
+++ b/mojo/public/bindings/generators/js_templates/enum_definition.tmpl |
@@ -1,12 +1,14 @@ |
-{%- macro enum_def(enum_init, enum) %} |
- {{enum_init}} = { |
-{%- set next_value = 0 %} |
+{%- macro enum_def(enum_name, enum, module) -%} |
+ {{enum_name}} = {}; |
+ |
+{%- set prev_enum = 0 %} |
{%- for field in enum.fields %} |
{%- if field.value %} |
-{%- set next_value = field.value|int %} |
+ {{enum_name}}.{{field.name}} = {{field.value|expression_to_text(module)}}; |
+{%- elif loop.first %} |
+ {{enum_name}}.{{field.name}} = 0; |
+{%- else %} |
+ {{enum_name}}.{{field.name}} = {{enum_name}}.{{enum.fields[loop.index0 - 1].name}} + 1; |
{%- endif %} |
- {{field.name}}: {{next_value}}, |
-{%- set next_value = next_value + 1 %} |
{%- endfor %} |
- }; |
{%- endmacro %} |