# HG changeset patch # User Edouard Tisserant # Date 1588949272 -7200 # Node ID faaf677ea99da509b88b31a0632b652d50f40d4b # Parent 25f5935735791b067be0e701d6005a1dcab49936 SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes. diff -r 25f593573579 -r faaf677ea99d svghmi/widgets_common.ysl2 --- a/svghmi/widgets_common.ysl2 Fri May 08 16:44:20 2020 +0200 +++ b/svghmi/widgets_common.ysl2 Fri May 08 16:47:52 2020 +0200 @@ -47,6 +47,31 @@ apply "$widget", mode="widget_defs" with "hmi_element","."; apply "$widget", mode="widget_subscribe" with "hmi_element","."; | }`if "position()!=last()" > ,` + +def "func:unique_types" { + param "elts_with_type"; + choose { + when "count($elts_with_type) > 1" { + const "prior_results","func:unique_types($elts_with_type[position()!=last()])"; + choose { + when "$elts_with_type[last()][@type = $prior_results/@type]"{ + // type already in + result "$prior_results"; + } + otherwise { + result "$prior_results | $elts_with_type[last()]"; + } + } + } + otherwise { + result "$elts_with_type"; + } + } +} + +emit "preamble:hmi-classes" { + const "used_widget_types", "func:unique_types($parsed_widgets/widget)"; + apply "$used_widget_types", mode="widget_class"; } emit "preamble:hmi-elements" {