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

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

Issue 538613005: mojo: Start generating structs for python bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + fix constant array 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 f76d255839551a57aa1fa9477a8a05b1f921abd5..aa631d92fe6016ef5b2961f4efc27b6c929041d2 100644
--- a/mojo/public/tools/bindings/generators/python_templates/module.py.tmpl
+++ b/mojo/public/tools/bindings/generators/python_templates/module.py.tmpl
@@ -1,3 +1,4 @@
+{% from "module_macros.tmpl" import enum_values %}
# 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.
@@ -18,11 +19,28 @@ import {{import.python_module}}
{% endif %}
{% for enum in module.enums %}
-class {{enum.name}}(object):
+class {{enum|name}}(object):
__metaclass__ = _reflection.MojoEnumType
- VALUES = [
-{% for field in enum.fields %}
- ('{{field.name}}', {{field.computed_value}}),
-{% endfor %}
- ]
+ VALUES = {{enum_values(enum)|indent(2)}}
+{% endfor %}
+{% for struct in module.structs %}
+
+class {{struct|name}}(object):
+ __metaclass__ = _reflection.MojoStructType
+ DESCRIPTOR = {
+{% if struct.constants %}
+ 'constants': {
+{% for constant in struct.constants %}
+ '{{constant|name}}': {{constant.value|expression_to_text}},
+{% endfor %}
+ },
+{% endif %}
+{% if struct.enums %}
+ 'enums': {
+{% for enum in struct.enums %}
+ '{{enum|name}}': {{enum_values(enum)|indent(6)}},
+{% endfor %}
+ },
+{% endif %}
+ }
{% endfor %}

Powered by Google App Engine
This is Rietveld 408576698