fix(yaml): flex switch warnings (#4949)

Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: elecpower <neilh713@tpg.com.au>
This commit is contained in:
Raphael Coeffic
2024-05-03 13:14:50 +10:00
committed by GitHub
co-authored by raphaelcoeffic 3djc elecpower
parent dd87ecb89a
commit 0d6ce7d22d
22 changed files with 174 additions and 101 deletions
+5
View File
@@ -560,11 +560,16 @@ def max_bits(struct):
bits = s.bits
return bits
def padding_bits(array):
array_bits = (array.bits // array.length) * array.length
return array.bits - array_bits
template = jinja2.Template(open(sys.argv[2]).read(), lstrip_blocks=True, trim_blocks=True)
template.globals['max_len'] = max_len
template.globals['get_max_len'] = get_max_len
template.globals['max_bits'] = max_bits
template.globals['padding_bits'] = padding_bits
## fixme: root_node_name needs to be mangled (contains ',')
print(template.render(root=RootAST,root_nodes=top_node_names,root_node_name=root_nodes_name))
+3
View File
@@ -45,6 +45,9 @@ static const struct YamlNode {{ struct.name }}[] = {
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 %}