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

Side by Side Diff: mojo/public/tools/bindings/generators/python_templates/module.py.tmpl

Issue 545433002: mojo: Generate top level enums for python bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Follow sdefresne suugestions. Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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
5 import mojo.bindings.reflection as _reflection
4 {% if imports %} 6 {% if imports %}
5 7
6 {% for import in imports %} 8 {% for import in imports %}
7 import {{import.python_module}} 9 import {{import.python_module}}
8 {% endfor %} 10 {% endfor %}
9 {% endif %} 11 {% endif %}
10 {#--- Constants #} 12 {#--- Constants #}
11 {% if module.constants %} 13 {% if module.constants %}
12 14
13 {% for constant in module.constants %} 15 {% for constant in module.constants %}
14 {{constant|name}} = {{constant.value|expression_to_text}} 16 {{constant|name}} = {{constant.value|expression_to_text}}
15 {% endfor %} 17 {% endfor %}
16 {% endif %} 18 {% endif %}
19 {% for enum in module.enums %}
20
21 class {{enum.name}}(object):
22 __metaclass__ = _reflection.MojoEnumType
23 VALUES = [
24 {% for field in enum.fields %}
25 {% if field.value %}
26 ('{{field.name}}', {{field.value|expression_to_text}}),
27 {% else %}
28 '{{field.name}}',
29 {% endif %}
30 {% endfor %}
31 ]
32 {% endfor %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698