|
| 1 | +{% macro render_field(field) -%}{# |
| 2 | + Macro for the output of a single field entry such as: |
| 3 | +
|
| 4 | + int16u identifyTime = 0; |
| 5 | + optional int16u transitionTime = 3; |
| 6 | + optional nullable int16u transitionTime = 2; |
| 7 | + optional ExtensionFieldSet extensionFieldSets[] = 5; |
| 8 | +#} |
| 9 | + |
| 10 | +{%- if field.qualities %}{{field.qualities | idltxt}} {% endif -%} |
| 11 | +{{field.data_type.name}} |
| 12 | +{%- if field.data_type.max_length -%} <{{field.data_type.max_length}}> {%- endif -%} |
| 13 | +{##} {{field.name}} |
| 14 | +{%- if field.is_list %}[]{% endif -%} |
| 15 | +{##} = {{field.code}}; |
| 16 | +{%- endmacro -%} |
| 17 | + |
| 18 | +{% macro render_struct(s) -%}{# |
| 19 | + Macro for the output of a complete struct |
| 20 | +#} |
| 21 | + {%- if s.tag %}{{s.tag | idltxt}} {% endif -%} |
| 22 | + {% if s.qualities %}{{s.qualities | idltxt}} {% endif -%} |
| 23 | + struct {{s.name}} {##} |
| 24 | + {%- if s.code is not none %}= {{s.code}} {% endif -%} |
| 25 | + { |
| 26 | + {% for field in s.fields %} |
| 27 | + {{render_field(field)}} |
| 28 | + {% endfor %} |
| 29 | + } |
| 30 | +{%- endmacro -%} |
| 31 | + |
| 32 | + |
| 33 | +// This IDL was auto-generated from a parsed data structure |
| 34 | + |
| 35 | +{% for cluster in idl.clusters %} |
| 36 | +{% if cluster.description %}/** {{cluster.description}} */ |
| 37 | +{% endif %} |
| 38 | +{{cluster.api_maturity | idltxt}}{{cluster.side | idltxt}} cluster {{cluster.name}} = {{cluster.code}} { |
| 39 | + {%- for enum in cluster.enums %} |
| 40 | + |
| 41 | + enum {{enum.name}} : {{ enum.base_type}} { |
| 42 | + {% for entry in enum.entries %} |
| 43 | + {{entry.name}} = {{entry.code}}; |
| 44 | + {% endfor %} |
| 45 | + } |
| 46 | + {% endfor %} |
| 47 | + |
| 48 | + {%- for bitmap in cluster.bitmaps %} |
| 49 | + |
| 50 | + bitmap {{bitmap.name}} : {{ bitmap.base_type}} { |
| 51 | + {% for entry in bitmap.entries %} |
| 52 | + {{entry.name}} = 0x{{"%X" | format(entry.code)}}; |
| 53 | + {% endfor %} |
| 54 | + } |
| 55 | + {% endfor %} |
| 56 | + |
| 57 | + {%- for s in cluster.structs | rejectattr("tag") %} |
| 58 | + {% if loop.first %} |
| 59 | + |
| 60 | + {% endif %} |
| 61 | + {{render_struct(s)}} |
| 62 | + {% if not loop.last %} |
| 63 | + |
| 64 | + {% endif %} |
| 65 | + {% endfor %} |
| 66 | + |
| 67 | + {%- for e in cluster.events %} |
| 68 | + {% if loop.first %} |
| 69 | + |
| 70 | + {% endif %} |
| 71 | + {##} {##}{% if e.qualities %}{{e.qualities | idltxt}} {% endif -%} |
| 72 | + {{e.priority | idltxt}} event {{e | event_access}}{{e.name}} = {{e.code}} { |
| 73 | + {% for field in e.fields %} |
| 74 | + {{render_field(field)}} |
| 75 | + {% endfor %} |
| 76 | + } |
| 77 | + {% if not loop.last %} |
| 78 | + |
| 79 | + {% endif %} |
| 80 | + {% endfor %} |
| 81 | + |
| 82 | + {%- for a in cluster.attributes %} |
| 83 | + {% if loop.first %} |
| 84 | + |
| 85 | + {% endif %} |
| 86 | + {{a.qualities | idltxt}}attribute {{a | attribute_access}}{{render_field(a.definition)}} |
| 87 | + {% endfor %} |
| 88 | + |
| 89 | + {%- for s in cluster.structs | selectattr("tag") %} |
| 90 | + |
| 91 | + {{render_struct(s)}} |
| 92 | + {% endfor %} |
| 93 | + |
| 94 | + {%- for c in cluster.commands %} |
| 95 | + {% if loop.first %} |
| 96 | + |
| 97 | + {% endif %} |
| 98 | + {% if c.description %} |
| 99 | + /** {{c.description}} */ |
| 100 | + {% endif %} |
| 101 | + {{c.qualities | idltxt}}command {{c | command_access}}{{c.name}}( |
| 102 | + {%- if c.input_param %}{{c.input_param}}{% endif -%} |
| 103 | + ): {{c.output_param}} = {{c.code}}; |
| 104 | + {% endfor %} |
| 105 | +} |
| 106 | + |
| 107 | +{% endfor %} |
| 108 | + |
| 109 | +{%- if idl.endpoints %} |
| 110 | +{%- for endpoint in idl.endpoints %} |
| 111 | +endpoint {{endpoint.number}} { |
| 112 | + {% for t in endpoint.device_types %} |
| 113 | + device type {{t.name}} = {{t.code}}, version {{t.version}}; |
| 114 | + {% endfor%} |
| 115 | + |
| 116 | + {%-for b in endpoint.client_bindings %} |
| 117 | + {% if loop.first %} |
| 118 | + |
| 119 | + {% endif %} |
| 120 | + binding cluster {{b}}; |
| 121 | + {% endfor %} |
| 122 | + |
| 123 | + {%-for c in endpoint.server_clusters %} |
| 124 | + |
| 125 | + server cluster {{c.name}} { |
| 126 | + {% for e in c.events_emitted %} |
| 127 | + emits event {{e}}; |
| 128 | + {% if loop.last %} |
| 129 | + |
| 130 | + {% endif %} |
| 131 | + {% endfor %} |
| 132 | + {% for a in c.attributes %} |
| 133 | + {{"%-8s" | format(a.storage|idltxt) }} attribute {{a.name}} |
| 134 | + {%- if a.default is not none %} default = {{a.default|render_default}} {%- endif %}; |
| 135 | + {% endfor %} |
| 136 | + {% for cmd in c.commands %} |
| 137 | + {% if loop.first %} |
| 138 | + |
| 139 | + {% endif %} |
| 140 | + handle command {{cmd.name}}; |
| 141 | + {% endfor %} |
| 142 | + } |
| 143 | + {% endfor %} |
| 144 | + |
| 145 | +} |
| 146 | +{% if not loop.last %} |
| 147 | + |
| 148 | +{% endif %} |
| 149 | +{% endfor %} |
| 150 | +{% endif %} |
0 commit comments