| OLD | NEW |
| 1 {% from "module_macros.tmpl" import enum_values %} |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 4 | 5 |
| 5 import mojo.bindings.reflection as _reflection | 6 import mojo.bindings.reflection as _reflection |
| 6 {% if imports %} | 7 {% if imports %} |
| 7 | 8 |
| 8 {% for import in imports %} | 9 {% for import in imports %} |
| 9 import {{import.python_module}} | 10 import {{import.python_module}} |
| 10 {% endfor %} | 11 {% endfor %} |
| 11 {% endif %} | 12 {% endif %} |
| 12 {#--- Constants #} | 13 {#--- Constants #} |
| 13 {% if module.constants %} | 14 {% if module.constants %} |
| 14 | 15 |
| 15 {% for constant in module.constants %} | 16 {% for constant in module.constants %} |
| 16 {{constant|name}} = {{constant.value|expression_to_text}} | 17 {{constant|name}} = {{constant.value|expression_to_text}} |
| 17 {% endfor %} | 18 {% endfor %} |
| 18 {% endif %} | 19 {% endif %} |
| 19 {% for enum in module.enums %} | 20 {% for enum in module.enums %} |
| 20 | 21 |
| 21 class {{enum.name}}(object): | 22 class {{enum|name}}(object): |
| 22 __metaclass__ = _reflection.MojoEnumType | 23 __metaclass__ = _reflection.MojoEnumType |
| 23 VALUES = [ | 24 VALUES = {{enum_values(enum)|indent(2)}} |
| 24 {% for field in enum.fields %} | |
| 25 ('{{field.name}}', {{field.computed_value}}), | |
| 26 {% endfor %} | |
| 27 ] | |
| 28 {% endfor %} | 25 {% endfor %} |
| 26 {% for struct in module.structs %} |
| 27 |
| 28 class {{struct|name}}(object): |
| 29 __metaclass__ = _reflection.MojoStructType |
| 30 DESCRIPTOR = { |
| 31 {% if struct.constants %} |
| 32 'constants': { |
| 33 {% for constant in struct.constants %} |
| 34 '{{constant|name}}': {{constant.value|expression_to_text}}, |
| 35 {% endfor %} |
| 36 }, |
| 37 {% endif %} |
| 38 {% if struct.enums %} |
| 39 'enums': { |
| 40 {% for enum in struct.enums %} |
| 41 '{{enum|name}}': {{enum_values(enum)|indent(6)}}, |
| 42 {% endfor %} |
| 43 }, |
| 44 {% endif %} |
| 45 } |
| 46 {% endfor %} |
| OLD | NEW |