• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{% from "module_macros.tmpl" import enum_values %}
2# 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# found in the LICENSE file.
5
6import mojo.bindings.descriptor as _descriptor
7import mojo.bindings.reflection as _reflection
8{% if imports %}
9
10{% for import in imports %}
11import {{import.python_module}}
12{% endfor %}
13{% endif %}
14{#--- Constants #}
15{% if module.constants %}
16
17{% for constant in module.constants %}
18{{constant|name}} = {{constant.value|expression_to_text}}
19{% endfor %}
20{% endif %}
21{% for enum in module.enums %}
22
23class {{enum|name}}(object):
24  __metaclass__ = _reflection.MojoEnumType
25  VALUES = {{enum_values(enum)|indent(2)}}
26{% endfor %}
27{% for struct in module.structs %}
28
29class {{struct|name}}(object):
30  __metaclass__ = _reflection.MojoStructType
31  DESCRIPTOR = {
32{%   if struct.constants %}
33    'constants': {
34{%     for constant in struct.constants %}
35      '{{constant|name}}': {{constant.value|expression_to_text}},
36{%     endfor %}
37    },
38{%   endif %}
39{%   if struct.enums %}
40    'enums': {
41{%     for enum in struct.enums %}
42      '{{enum|name}}': {{enum_values(enum)|indent(6)}},
43{%     endfor %}
44    },
45{%   endif %}
46{%   if struct.fields %}
47    'fields': [
48{%    for byte in struct.bytes %}
49{%      if byte.packed_fields %}
50      {{byte|field_group}},
51{%      endif %}
52{%   endfor %}
53    ],
54{%   endif %}
55  }
56{% endfor %}
57