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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/python_templates/module.py.tmpl
diff --git a/mojo/public/tools/bindings/generators/python_templates/module.py.tmpl b/mojo/public/tools/bindings/generators/python_templates/module.py.tmpl
index 531c4e15c6a055442227c6307e065eecd0aa8426..830ee03f1729ea7ad3ba15e1981535656d6d8a9c 100644
--- a/mojo/public/tools/bindings/generators/python_templates/module.py.tmpl
+++ b/mojo/public/tools/bindings/generators/python_templates/module.py.tmpl
@@ -1,6 +1,8 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+
+import mojo.bindings.reflection as _reflection
{% if imports %}
{% for import in imports %}
@@ -14,3 +16,17 @@ import {{import.python_module}}
{{constant|name}} = {{constant.value|expression_to_text}}
{% endfor %}
{% endif %}
+{% for enum in module.enums %}
+
+class {{enum.name}}(object):
+ __metaclass__ = _reflection.MojoEnumType
+ VALUES = [
+{% for field in enum.fields %}
+{% if field.value %}
+ ('{{field.name}}', {{field.value|expression_to_text}}),
+{% else %}
+ '{{field.name}}',
+{% endif %}
+{% endfor %}
+ ]
+{% endfor %}

Powered by Google App Engine
This is Rietveld 408576698