From ae11cf1450d810b4ecac1c151dbfcfceb9d96d35 Mon Sep 17 00:00:00 2001 From: Corey Lewis Date: Wed, 31 Aug 2022 15:58:47 +1000 Subject: [PATCH] tools: Support multiple methods with the same id The check for both label and condition is there to handle cases like: enum invocation_label { Invalid, #if A LabelOne, #endif #if B LabelOne, #endif } Co-authored-by: Indan Zupancic Signed-off-by: Corey Lewis --- libsel4/tools/sel4_idl.xsd | 1 + tools/invocation_header_gen.py | 14 +++++++++++--- tools/invocation_json_gen.py | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libsel4/tools/sel4_idl.xsd b/libsel4/tools/sel4_idl.xsd index 2118fb238..8fbac4809 100644 --- a/libsel4/tools/sel4_idl.xsd +++ b/libsel4/tools/sel4_idl.xsd @@ -40,6 +40,7 @@ + diff --git a/tools/invocation_header_gen.py b/tools/invocation_header_gen.py index a2fde07d0..86258a2bf 100755 --- a/tools/invocation_header_gen.py +++ b/tools/invocation_header_gen.py @@ -147,10 +147,18 @@ def parse_xml(xml_file): sys.exit(-1) invocation_labels = [] + invocation_ids = set() for method in doc.getElementsByTagName("method"): - invocation_labels.append((str(method.getAttribute("id")), - str(condition_to_cpp(method.getElementsByTagName("condition"))))) - + label = str(method.getAttribute("id")) + condition = str(condition_to_cpp(method.getElementsByTagName("condition"))) + uid = label + condition + dup = method.getAttribute("duplicate") + if uid not in invocation_ids: + invocation_ids.add(uid) + invocation_labels.append((label, condition)) + elif dup not in ("true", "1"): + print("Error: Implicit duplicate id '%s' in xml file" % label, file=sys.stderr) + sys.exit(-1) return invocation_labels diff --git a/tools/invocation_json_gen.py b/tools/invocation_json_gen.py index e23b8597f..694bfb59b 100644 --- a/tools/invocation_json_gen.py +++ b/tools/invocation_json_gen.py @@ -32,7 +32,7 @@ def xml_to_json_invocations(xml, gen_config, counter, invocations_dict, ): for method in xml.getElementsByTagName("method"): label = str(method.getAttribute("id")) exists = condition_to_bool(method.getElementsByTagName("condition"), gen_config) - if exists: + if exists and label not in invocations_dict: invocations_dict[label] = counter counter += 1