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