rom_filter: support default input values

Fixes #4286
This commit is contained in:
Norman Feske 2021-10-07 10:20:38 +02:00
parent cb67d07e61
commit bc5a7eb495
3 changed files with 21 additions and 5 deletions

View File

@ -6,13 +6,13 @@
<timeout meaning="failed" sec="20" />
<log meaning="succeeded">
[init -> rom_logger] ROM 'generated':
[init -> rom_logger] &lt;config>&lt;!-- ... fallback ... -->&lt;/config>*
[init -> rom_logger] &lt;config color="transparent">&lt;!-- ... fallback ... -->&lt;/config>*
[init -> rom_logger] ROM 'generated':
[init -> rom_logger] &lt;config>&lt;!-- ... fallback ... -->&lt;/config>*
[init -> rom_logger] &lt;config color="transparent">&lt;!-- ... fallback ... -->&lt;/config>*
[init -> rom_logger] ROM 'generated':
[init -> rom_logger] &lt;config>&lt;!-- xray enabled -->&lt;/config>*
[init -> rom_logger] &lt;config color="yellow">&lt;!-- xray enabled -->&lt;/config>*
[init -> rom_logger] ROM 'generated':
[init -> rom_logger] &lt;config message="system locked">&lt;!-- ... fallback ... -->&lt;/config>*
[init -> rom_logger] &lt;config message="system locked" color="transparent">&lt;!-- ... fallback ... -->&lt;/config>*
[init -> dynamic_rom] xray: change (finished)
</log>
<log meaning="failed">Error: </log>
@ -54,7 +54,9 @@
</inline>
<sleep milliseconds="1000" />
<inline description="enable X-ray mode">
<xray enabled="yes"/>
<xray enabled="yes">
<style color="yellow"/>
</xray>
</inline>
<sleep milliseconds="1000" />
<inline description="leave X-ray mode undefined">
@ -80,6 +82,13 @@
<attribute name="enabled" />
</input>
<!-- test fallback to default value -->
<input name="color" rom="xray" node="xray" default="transparent">
<node type="style">
<attribute name="color" />
</node>
</input>
<input name="diagnostic_message" rom="xray" node="xray">
<node type="details">
<node type="message" attribute="reason" value="no access">
@ -90,6 +99,7 @@
<output node="config">
<attribute name="message" input="diagnostic_message"/>
<attribute name="color" input="color"/>
<if>
<has_value input="xray_enabled" value="yes" />
<then>

View File

@ -17,6 +17,9 @@ attribute. The 'rom' attribute specifies the ROM module to take the input
from. If not specified, the 'name' is used as the ROM name. The type of the
top-level XML node can be specified via the 'node' attribute. If not present,
the top-level XML node is expected to correspond to the 'name' attribute.
The optional 'default' attribute defines the input value used whenever the
ROM module lacks the structure or attribute expected by the '<input>'.
The '<input>' node may contain a hierarchy of '<node type="type">' nodes that
denote a path within the XML input. If specified, the optional attributes
'attribute' and 'value' constrain the selection of the input depending of the

View File

@ -233,6 +233,9 @@ class Rom_filter::Input_rom_registry
} catch (...) { }
if (input_node.has_attribute("default"))
return input_node.attribute_value("default", Input_value(""));
throw Nonexistent_input_value();
}