Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/enum representation types #155

Merged
merged 7 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion src/fprime_gds/common/loaders/xml_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -202,14 +203,17 @@ 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:
item_name = item.get(self.ENUM_ELEM_NAME_TAG)
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)
Fixed Show fixed Hide fixed

self.enums[enum_name] = enum_obj
return enum_obj
Expand Down
Loading