|
1 | 1 | {% macro field(field) %} |
2 | | -{% set kind = field|field_kind %} |
3 | | -{% if kind == 'attr' %} |
4 | | -{% if field.type|is_dict %}{{ record(field) }}{% else %}{{ scalar(field) }} |
5 | | -{% endif %} |
6 | | -{% elif kind in ['array', 'coord'] %} |
7 | | -{{ array(field) }} |
8 | | -{% elif kind == 'dim' %} |
| 2 | +{% set type = field|field_type %} |
| 3 | +{% if type in ['keyword', 'integer', 'double precision', 'string'] %} |
9 | 4 | {{ scalar(field) }} |
10 | | -{% elif kind == 'child' %} |
11 | | -{# TODO #} |
12 | | -{% endif -%} |
13 | | -{%- endmacro %} |
| 5 | +{% elif type == 'record' %} |
| 6 | +{{ record(field) }} |
| 7 | +{% elif type == 'keystring' %} |
| 8 | +{{ keystring(field) }} |
| 9 | +{% elif type == 'recarray' %} |
| 10 | +{{ recarray(field) }} |
| 11 | +{% endif %} |
| 12 | +{% endmacro %} |
14 | 13 |
|
15 | | -{% macro scalar(field) -%} |
| 14 | +{% macro scalar(field) %} |
16 | 15 | {% set value = field|field_value %} |
17 | 16 | {% if value is not none %}{{ field.name }} {{ value }}{% endif %} |
18 | | -{%- endmacro %} |
| 17 | +{% endmacro %} |
19 | 18 |
|
20 | | -{% macro keystring(field) %} {# union #} |
21 | | -{% for item in (field|field_value).items() %} |
| 19 | +{% macro keystring(field) %} |
| 20 | +{% for item in (field|field_value).values() -%} |
22 | 21 | {{ field(item) }} |
23 | | -{% endfor %} |
24 | | -{%- endmacro %} |
| 22 | +{%- endfor %} |
| 23 | +{% endmacro %} |
25 | 24 |
|
26 | 25 | {% macro record(field) %} |
27 | | -{% for item in field|field_value %} |
28 | | -{% if item.tagged %}{{ item.name }} {% endif %}{{ field(field) }} |
29 | | -{% endfor %} |
30 | | -{%- endmacro %} |
| 26 | +{% for item in (field|field_value).values() -%} |
| 27 | +{% if item.tagged %}{{ item.name }} {% endif %}{{ field(item) }} |
| 28 | +{%- endfor %} |
| 29 | +{% endmacro %} |
31 | 30 |
|
32 | | -{% macro array(field, how="internal") %} |
| 31 | +{% macro recarray(field, how="internal") %} |
33 | 32 | {% if how == "layered constant" %} |
34 | 33 | {{ field.name }} LAYERED |
35 | 34 | {% for val in field|field_value %} |
36 | 35 | CONSTANT |
37 | 36 | {% endfor %} |
38 | | -{% elif how == "constant" %} |
| 37 | +{%- elif how == "constant" %} |
39 | 38 | {{ field.name }} CONSTANT {{ field|field_value }} |
40 | | -{% elif how == "layered" %} |
| 39 | +{%- elif how == "layered" %} |
41 | 40 | {% if layered %} |
42 | 41 | {{ field.name }}{% for val in field|field_value %} {{ val }}{% endfor %} |
43 | 42 | {% endif %} |
44 | | -{% elif how == "internal" %} |
| 43 | +{%- elif how == "internal" %} |
45 | 44 | {{ field.name }} {{ internal_array(field) }} |
46 | | -{% elif how == "external" %} |
| 45 | +{%- elif how == "external" %} |
47 | 46 | {{ field.name}} OPEN/CLOSE {{ field|field_value }} |
48 | 47 | {% endif %} |
49 | | -{%- endmacro %} |
| 48 | +{% endmacro %} |
50 | 49 |
|
51 | 50 | {% macro internal_array(field) %} |
52 | | -{% for chunk in field|field_value|array_delay %} |
| 51 | +{% for chunk in field|field_value|array_delay -%} |
53 | 52 | {{ chunk|array2string }} |
54 | | -{% endfor %} |
55 | | -{%- endmacro %} |
56 | | - |
57 | | -{% macro list(field) %} |
58 | | -{# TODO #} |
59 | | -{%- endmacro %} |
| 53 | +{%- endfor %} |
| 54 | +{% endmacro %} |
0 commit comments