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

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

Issue 1345263002: Generate Mojom Types in Go (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Address Naming changes and Comment Updates Created 5 years, 1 month 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 {% macro define(enum) %} 5 {% import "mojom_type_macros.tmpl" as mojom_type_macros %}
6
7 {% macro define(enum, typepkg, package) %}
6 type {{enum|name}} int32 8 type {{enum|name}} int32
7 9
8 const ( 10 const (
9 {% for field in enum.fields %} 11 {% for field in enum.fields %}
10 {% if field.value %} 12 {% if field.value %}
11 {{enum|name}}_{{field|name}} = {{field.value|expression_to_text}} 13 {{enum|name}}_{{field|name}} = {{field.value|expression_to_text}}
12 {% elif loop.first %} 14 {% elif loop.first %}
13 {{enum|name}}_{{field|name}} = 0 15 {{enum|name}}_{{field|name}} = 0
14 {% else %} 16 {% else %}
15 {{enum|name}}_{{field|name}} = {{enum|name}}_{{enum.fields[loop.index0 - 1]|name}} + 1; 17 {{enum|name}}_{{field|name}} = {{enum|name}}_{{enum.fields[loop.index0 - 1]|name}} + 1;
16 {% endif %} 18 {% endif %}
17 {% endfor %} 19 {% endfor %}
18 ) 20 )
19 21
22 {{ mojom_type_macros.writeMojomTypeDef(typepkg, enum, package, exported) }}
23
20 {% endmacro %} 24 {% endmacro %}
OLDNEW
« no previous file with comments | « mojo/public/go/application/describer.go ('k') | mojo/public/tools/bindings/generators/go_templates/interface.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698