From 7f3bb470f55f9d8559c00141b6790580345ac05e Mon Sep 17 00:00:00 2001 From: Jack White Date: Fri, 16 Feb 2024 05:10:21 +0100 Subject: [PATCH] Fix/enum representation types (#155) * Jack White: Added serialise/representation type to XML loader * Jack White: Amended new call to EnumType.contruct_type() * Jack White: Replaced explicit check-and-set for default enum serialize type with default value in dict.get() * Bumping fprime-tools version for representation types --------- Co-authored-by: Jack White Co-authored-by: M Starch --- pyproject.toml | 2 +- src/fprime_gds/common/loaders/xml_loader.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 98b6afd1..bd9efefd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ dependencies = [ "pexpect>=4.8.0", "pytest>=6.2.4", "flask_restful>=0.3.8", - "fprime-tools>=3.1.2a1", + "fprime-tools>=3.4.3", "argcomplete>=1.12.3", "Jinja2>=2.11.3", "openpyxl>=3.0.10", diff --git a/src/fprime_gds/common/loaders/xml_loader.py b/src/fprime_gds/common/loaders/xml_loader.py index 397c48e4..0fdc5259 100644 --- a/src/fprime_gds/common/loaders/xml_loader.py +++ b/src/fprime_gds/common/loaders/xml_loader.py @@ -49,6 +49,7 @@ class XmlLoader(dict_loader.DictLoader): ENUM_SECT = "enums" ENUM_TYPE_TAG = "type" + ENUM_SERIALIZE_TYPE_TAG = "serialize_type" ENUM_ELEM_NAME_TAG = "name" ENUM_ELEM_VAL_TAG = "value" ENUM_ELEM_DESC_TAG = "description" @@ -202,6 +203,9 @@ def get_enum_type(self, enum_name, xml_obj): for enum in enum_section: # Check enum name if enum.get(self.ENUM_TYPE_TAG) == enum_name: + # Get serialize/representation type, if present + serialize_type = enum.get(self.ENUM_SERIALIZE_TYPE_TAG, "I32") + # Go through all possible values of the enum members = {} for item in enum: @@ -209,7 +213,7 @@ def get_enum_type(self, enum_name, xml_obj): item_val = int(item.get(self.ENUM_ELEM_VAL_TAG)) members[item_name] = item_val - enum_obj = EnumType.construct_type(enum_name, members) + enum_obj = EnumType.construct_type(enum_name, members, serialize_type) self.enums[enum_name] = enum_obj return enum_obj