blob: b42fc3047c4f744f4994c979a34bc851a20bf972 [file] [log] [blame]
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{%- macro enum_values(enum) -%}
[
{% for field in enum.fields %}
('{{field.name}}', {{field.computed_value}}),
{% endfor %}
]
{%- endmacro -%}
{%- macro struct_descriptor(struct) -%}
{
{% if struct.constants %}
'constants': {
{% for constant in struct.constants %}
'{{constant|name}}': {{constant.value|expression_to_text}},
{% endfor %}
},
{% endif %}
{% if struct.enums %}
'enums': {
{% for enum in struct.enums %}
'{{enum|name}}': {{enum_values(enum)|indent(6)}},
{% endfor %}
},
{% endif %}
{% if struct.fields %}
'fields': [
{% for byte in struct.bytes %}
{% if byte.packed_fields %}
{{byte|field_group}},
{% endif %}
{% endfor %}
],
{% endif %}
}
{%- endmacro -%}