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

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

Issue 1218023006: Implement python mojo bindings unions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
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 {% from "module_macros.tmpl" import struct_descriptor %}
3 {% from "module_macros.tmpl" import union_descriptor %}
3 # Copyright 2014 The Chromium Authors. All rights reserved. 4 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 6 # found in the LICENSE file.
6 7
7 import mojo_bindings.descriptor as _descriptor 8 import mojo_bindings.descriptor as _descriptor
8 import mojo_bindings.reflection as _reflection 9 import mojo_bindings.reflection as _reflection
9 {% if interfaces %} 10 {% if interfaces %}
10 import mojo_bindings.interface_reflection as _interface_reflection 11 import mojo_bindings.interface_reflection as _interface_reflection
11 {% endif %} 12 {% endif %}
12 {% if imports %} 13 {% if imports %}
(...skipping 14 matching lines...) Expand all
27 class {{enum|name}}(object): 28 class {{enum|name}}(object):
28 __metaclass__ = _reflection.MojoEnumType 29 __metaclass__ = _reflection.MojoEnumType
29 VALUES = {{enum_values(enum)|indent(2)}} 30 VALUES = {{enum_values(enum)|indent(2)}}
30 {% endfor %} 31 {% endfor %}
31 {% for struct in structs %} 32 {% for struct in structs %}
32 33
33 class {{struct|name}}(object): 34 class {{struct|name}}(object):
34 __metaclass__ = _reflection.MojoStructType 35 __metaclass__ = _reflection.MojoStructType
35 DESCRIPTOR = {{struct_descriptor(struct)|indent(2)}} 36 DESCRIPTOR = {{struct_descriptor(struct)|indent(2)}}
36 {% endfor %} 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
37 {% for interface in interfaces %} 45 {% for interface in interfaces %}
38 46
39 class {{interface|name}}(object): 47 class {{interface|name}}(object):
40 __metaclass__ = _interface_reflection.MojoInterfaceType 48 __metaclass__ = _interface_reflection.MojoInterfaceType
41 DESCRIPTOR = { 49 DESCRIPTOR = {
42 'fully_qualified_name': '{% if namespace %}{{namespace|replace(".","::")}}:: {% endif %}{{interface|fully_qualified_name|replace(".","::")}}', 50 'fully_qualified_name': '{% if namespace %}{{namespace|replace(".","::")}}:: {% endif %}{{interface|fully_qualified_name|replace(".","::")}}',
43 'version': {{interface.version}}, 51 'version': {{interface.version}},
44 'methods': [ 52 'methods': [
45 {% for method in interface.methods %} 53 {% for method in interface.methods %}
46 { 54 {
47 'name': '{{method|name}}', 55 'name': '{{method|name}}',
48 'ordinal': {{method.ordinal}}, 56 'ordinal': {{method.ordinal}},
49 'parameters': {{struct_descriptor(method.param_struct)|indent(8)}}, 57 'parameters': {{struct_descriptor(method.param_struct)|indent(8)}},
50 {% if method.response_parameters != None %} 58 {% if method.response_parameters != None %}
51 'responses': {{struct_descriptor(method.response_param_struct)|indent(8) }}, 59 'responses': {{struct_descriptor(method.response_param_struct)|indent(8) }},
52 {% endif %} 60 {% endif %}
53 }, 61 },
54 {% endfor %} 62 {% endfor %}
55 ], 63 ],
56 } 64 }
57 {% endfor %} 65 {% endfor %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698