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

Unified Diff: mojo/public/tools/bindings/generators/go_templates/enum.tmpl

Issue 1943643002: Go bindings: Change generated enum value constants to be typed as the enum type. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 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/go_templates/enum.tmpl
diff --git a/mojo/public/tools/bindings/generators/go_templates/enum.tmpl b/mojo/public/tools/bindings/generators/go_templates/enum.tmpl
index a222fda4e3995505708b76c552ac1cfc42b0135f..15432bd5ababb84c6c7d908a34bf4a583a736f62 100644
--- a/mojo/public/tools/bindings/generators/go_templates/enum.tmpl
+++ b/mojo/public/tools/bindings/generators/go_templates/enum.tmpl
@@ -9,13 +9,17 @@ type {{enum|name}} int32
const (
{% for field in enum.fields %}
-{% if field.value %}
+{% if loop.first %}
+{% if field.value %}
+ {{enum|name}}_{{field|name}} {{enum|name}} = {{field.value|expression_to_text}}
+{% else %}
+ {{enum|name}}_{{field|name}} {{enum|name}} = 0
+{% endif %}
+{% elif field.value %}
{{enum|name}}_{{field|name}} = {{field.value|expression_to_text}}
-{% elif loop.first %}
- {{enum|name}}_{{field|name}} = 0
{% else %}
{{enum|name}}_{{field|name}} = {{enum|name}}_{{enum.fields[loop.index0 - 1]|name}} + 1;
-{% endif %}
+{% endif%}
{% endfor %}
)
« no previous file with comments | « mojo/public/interfaces/bindings/tests/test_enums.mojom ('k') | mojo/public/tools/bindings/generators/mojom_go_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698