78 lines
2.5 KiB
Cheetah
78 lines
2.5 KiB
Cheetah
// generated by generate_yaml.py
|
|
|
|
//
|
|
// Enums first
|
|
//
|
|
|
|
{% for enum in root.get_enums() %}
|
|
const struct YamlIdStr {{ enum.name }}[] = {
|
|
{% for elmt in enum.get_elmts() %}
|
|
{ {{ elmt.value }}, "{{ max_len(elmt.name) }}" },
|
|
{% endfor %}
|
|
{ 0, NULL }
|
|
};
|
|
{% endfor %}
|
|
|
|
//
|
|
// Structs last
|
|
//
|
|
|
|
{% for struct in root.get_structs() %}
|
|
{% if struct.name.startswith('union_') %}
|
|
static const struct YamlNode {{ struct.name }}_elmts[] = {
|
|
{% else %}
|
|
static const struct YamlNode {{ struct.name }}[] = {
|
|
{% if struct.use_idx %}
|
|
YAML_IDX,
|
|
{% endif%}
|
|
{% endif %}
|
|
{% for elmt in struct.get_elmts() %}
|
|
{% if elmt.skip %}
|
|
YAML_PADDING( {{ elmt.bits }} ),
|
|
{% elif elmt.type == 'string' %}
|
|
YAML_STRING("{{ max_len(elmt.name) }}", {{elmt.length}}),
|
|
{% elif elmt.type in ['signed','unsigned'] %}
|
|
{% if elmt.f_read and elmt.f_write %}
|
|
YAML_{{elmt.type|upper}}_CUST( "{{ max_len(elmt.name) }}", {{ elmt.bits }}, {{ elmt.f_read}}, {{ elmt.f_write}} ),
|
|
{% else %}
|
|
YAML_{{elmt.type|upper}}( "{{ max_len(elmt.name) }}", {{ elmt.bits }} ),
|
|
{% endif %}
|
|
{% elif elmt.type == 'enum' %}
|
|
YAML_ENUM("{{ max_len(elmt.name) }}", {{elmt.bits}}, {{elmt.var_type}}, {{ elmt.func }}),
|
|
{% elif elmt.type == 'struct' %}
|
|
YAML_STRUCT("{{ max_len(elmt.name) }}", {{elmt.bits}}, {{elmt.var_type}}, {{ elmt.func }}),
|
|
{% elif elmt.type == 'union' %}
|
|
YAML_UNION("{{ max_len(elmt.name) }}", {{elmt.bits}}, {{elmt.var_type}}_elmts, {{ elmt.func}}),
|
|
{% elif elmt.type == 'array' %}
|
|
YAML_ARRAY("{{ max_len(elmt.name) }}", {{elmt.bits // elmt.length}}, {{elmt.length}}, {{elmt.var_type}}, {{ elmt.func }}),
|
|
{% if padding_bits(elmt) > 0 %}
|
|
YAML_PADDING({{ padding_bits(elmt) }}),
|
|
{% endif %}
|
|
{% elif elmt.raw %}
|
|
{{ elmt.raw }},
|
|
{% else %}
|
|
// name='{{elmt.name}}', type='{{elmt.type}}', bits='{{elmt.bits}}', is_array='{{elmt.is_array}}', var_type='{{elmt.var_type}}', kind='{{elmt.cursor.kind}}' , type.kind='{{elmt.cursor.type.kind}}', raw='{{elmt.raw}}'
|
|
{% endif %}
|
|
{% endfor %}
|
|
YAML_END
|
|
};
|
|
{% if struct.name.startswith('union_') and struct.used_in_arrays %}
|
|
static const struct YamlNode {{ struct.name }}[] = {
|
|
YAML_IDX,
|
|
YAML_UNION("u", {{ max_bits(struct) }}, {{ struct.name }}_elmts, {{ struct.func }}),
|
|
YAML_END
|
|
};
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
#define MAX_{{ root_node_name | upper }}_STR_LEN {{ get_max_len() }}
|
|
|
|
{% for tn in root_nodes %}
|
|
static const struct YamlNode __{{ tn }}_root_node = YAML_ROOT( struct_{{ tn }} );
|
|
|
|
const YamlNode* get_{{ tn | lower }}_nodes()
|
|
{
|
|
return &__{{ tn }}_root_node;
|
|
}
|
|
{% endfor %}
|