| OLD | NEW |
| 1 {% from "module_macros.tmpl" import enum_values %} | 1 {% from "module_macros.tmpl" import enum_values %} |
| 2 {% from "module_macros.tmpl" import struct_descriptor %} |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 5 | 6 |
| 6 import mojo.bindings.descriptor as _descriptor | 7 import mojo.bindings.descriptor as _descriptor |
| 7 import mojo.bindings.reflection as _reflection | 8 import mojo.bindings.reflection as _reflection |
| 8 {% if imports %} | 9 {% if imports %} |
| 9 | 10 |
| 10 {% for import in imports %} | 11 {% for import in imports %} |
| 11 import {{import.python_module}} | 12 import {{import.python_module}} |
| 12 {% endfor %} | 13 {% endfor %} |
| 13 {% endif %} | 14 {% endif %} |
| 14 {#--- Constants #} | 15 {#--- Constants #} |
| 15 {% if module.constants %} | 16 {% if module.constants %} |
| 16 | 17 |
| 17 {% for constant in module.constants %} | 18 {% for constant in module.constants %} |
| 18 {{constant|name}} = {{constant.value|expression_to_text}} | 19 {{constant|name}} = {{constant.value|expression_to_text}} |
| 19 {% endfor %} | 20 {% endfor %} |
| 20 {% endif %} | 21 {% endif %} |
| 21 {% for enum in module.enums %} | 22 {% for enum in enums %} |
| 22 | 23 |
| 23 class {{enum|name}}(object): | 24 class {{enum|name}}(object): |
| 24 __metaclass__ = _reflection.MojoEnumType | 25 __metaclass__ = _reflection.MojoEnumType |
| 25 VALUES = {{enum_values(enum)|indent(2)}} | 26 VALUES = {{enum_values(enum)|indent(2)}} |
| 26 {% endfor %} | 27 {% endfor %} |
| 27 {% for struct in module.structs %} | 28 {% for struct in structs %} |
| 28 | 29 |
| 29 class {{struct|name}}(object): | 30 class {{struct|name}}(object): |
| 30 __metaclass__ = _reflection.MojoStructType | 31 __metaclass__ = _reflection.MojoStructType |
| 32 DESCRIPTOR = {{struct_descriptor(struct)|indent(2)}} |
| 33 {% endfor %} |
| 34 {% for interface in interfaces %} |
| 35 |
| 36 class {{interface|name}}(object): |
| 37 __metaclass__ = _reflection.MojoInterfaceType |
| 31 DESCRIPTOR = { | 38 DESCRIPTOR = { |
| 32 {% if struct.constants %} | 39 {% if interface.client %} |
| 33 'constants': { | 40 'client': {{interface.qualified_client|fully_qualified_name}}, |
| 34 {% for constant in struct.constants %} | 41 {% endif %} |
| 35 '{{constant|name}}': {{constant.value|expression_to_text}}, | 42 'methods': [ |
| 36 {% endfor %} | 43 {% for method in interface.methods %} |
| 37 }, | 44 { |
| 38 {% endif %} | 45 'name': '{{method|name}}', |
| 39 {% if struct.enums %} | 46 'ordinal': {{method.ordinal}}, |
| 40 'enums': { | 47 {% set request_struct = method|struct_from_method %} |
| 41 {% for enum in struct.enums %} | 48 'parameters': {{struct_descriptor(request_struct)|indent(8)}}, |
| 42 '{{enum|name}}': {{enum_values(enum)|indent(6)}}, | 49 {% if method.response_parameters != None %} |
| 43 {% endfor %} | 50 {% set response_struct = method|response_struct_from_method %} |
| 44 }, | 51 'responses': {{struct_descriptor(response_struct)|indent(8)}}, |
| 45 {% endif %} | 52 {% endif %} |
| 46 {% if struct.fields %} | 53 }, |
| 47 'fields': [ | 54 {% endfor %} |
| 48 {% for byte in struct.bytes %} | |
| 49 {% if byte.packed_fields %} | |
| 50 {{byte|field_group}}, | |
| 51 {% endif %} | |
| 52 {% endfor %} | |
| 53 ], | 55 ], |
| 54 {% endif %} | |
| 55 } | 56 } |
| 56 {% endfor %} | 57 {% endfor %} |
| OLD | NEW |