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

Refactoring; splitting up modelDescription & terminalsAndIcons parsing #136

Merged
merged 27 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5215d40
work in progress; testing possible approaching for separating modelDe…
Aug 1, 2024
7522d44
Adding xmlType enum to context; lots of renaming for better distincti…
Aug 2, 2024
dfc7d40
Replacing direct accesses of global variables (maps) via function calls
Aug 2, 2024
ae9ddee
Replace more global maps via function accesses + making the global li…
Aug 2, 2024
e6f0a32
Adding some intermitted duplication for refactoring
Aug 5, 2024
e56b211
prep
Aug 5, 2024
44e63c0
work in progress; replaced fmi3_xml_attr_enu
Aug 5, 2024
9af9b21
work in progress; switch to fmi3_xml_scheme_info_t
Aug 5, 2024
307ec7f
work in progress; rename element handle maps
Aug 5, 2024
408eb79
Separating maps 'constructors'
Aug 5, 2024
773d292
tentative successful separation
Aug 5, 2024
cf1a33e
duplicating common attributes
Aug 6, 2024
837ab1e
Replacing attr enum by union
Aug 6, 2024
e58345c
Replaced element enum with union
Aug 6, 2024
3753cb1
Renaming for better type names
Aug 6, 2024
29f177f
Fixing some messed up replaces
Aug 6, 2024
b7b8721
Some cleanup; fixing a number of TODOs
Aug 6, 2024
a045933
Some cleanup; more clarity when using enum = -1 none
Aug 6, 2024
0dd0229
Some enum renaming for consistency
Aug 6, 2024
0f2a8f5
various re-naming for consistency
Aug 6, 2024
8ed041d
Misc cleanup
Aug 7, 2024
01322b3
More cleanup; renamings for consistency
Aug 7, 2024
c687dba
more cleanup/renaming
Aug 7, 2024
01021b4
Some more small cleanup
Aug 7, 2024
1c33d6e
Apply suggestions from code review
PeterMeisrimelModelon Aug 8, 2024
d5115c9
Some more review fixes
Aug 8, 2024
6258cc4
A few more renamings for clarity/consistency
Aug 8, 2024
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
6 changes: 3 additions & 3 deletions src/XML/src/FMI/fmi_xml_terminals_and_icons.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ int fmi_xml_handle_fmiTerminalsAndIcons(fmi3_xml_parser_context_t* context, cons
fmi_xml_terminals_and_icons_t* termIcon = context->termIcon;
if (!data) {
int ret;
if (context->currentElmID != fmi3_xml_elmID_none) {
if (context->currentElmID.termIcon != fmi_xml_elmID_termIcon_none) {
fmi3_xml_parse_fatal(context, "fmiTerminalsAndIcons must be the root XML element");
return -1;
}
jm_log_verbose(context->callbacks, module, "Parsing XML element fmiTerminalsAndIcons");

ret = fmi3_xml_parse_attr_as_string(context, fmi3_xml_elmID_fmiTerminalsAndIcons, fmi_attr_id_fmiVersion, 1 /* required */,
ret = fmi3_xml_parse_attr_as_string(context, FMI_ELM_TERMICON(fmi_xml_elmID_termIcon_fmiTerminalsAndIcons), FMI_ATTR_TERMICON(fmi_attr_id_fmiVersion), 1 /* required */,
&(termIcon->fmi3_xml_standard_version));
if (ret) {
return ret;
Expand Down Expand Up @@ -193,7 +193,7 @@ int fmi_xml_handle_Terminal(fmi3_xml_parser_context_t* context, const char* data
// parse name
jm_vector(char)* bufName = fmi3_xml_reserve_parse_buffer(context, bufIdx++, 100);
if (!bufName) {return -1;}
if (fmi3_xml_parse_attr_as_string(context, fmi3_xml_elmID_Terminal, fmi_attr_id_name, 1 /* required */, bufName)) {return -1;}
if (fmi3_xml_parse_attr_as_string(context, FMI_ELM_TERMICON(fmi_xml_elmID_termIcon_Terminal), FMI_ATTR_TERMICON(fmi_attr_id_name), 1 /* required */, bufName)) {return -1;}

/* Add the name to the terminalsAndIcons-wide set and retrieve the pointer */
if (jm_vector_get_size(char)(bufName)) {
Expand Down
27 changes: 14 additions & 13 deletions src/XML/src/FMI/fmi_xml_terminals_and_icons_scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
extern "C" {
#endif

/* Attributes common to modelDescription.xml & terminalsAndIcons.xml
* are listed in FMI3_XML_ATTRLIST_COMMON in fmi3_xml_parser.h
*/
#define FMI_XML_ATTRLIST_TERM_ICON(EXPAND_XML_ATTRNAME) // XXX: Currently empty, but will be filled
/* Attribute names found in terminalsAndIcons.xml */
#define FMI_XML_ATTRLIST_TERM_ICON(EXPAND_XML_ATTRNAME) \
EXPAND_XML_ATTRNAME(fmiVersion) \
EXPAND_XML_ATTRNAME(name) \
EXPAND_XML_ATTRNAME(description)

/* Element names found in terminalsAndIcons.xml */
#define FMI_XML_ELMLIST_TERM_ICON(EXPAND_XML_ELMNAME) \
EXPAND_XML_ELMNAME(fmiTerminalsAndIcons) \
EXPAND_XML_ELMNAME(Terminals) \
Expand All @@ -36,24 +38,23 @@ extern "C" {
/** \brief Element that can be placed under different parents get alternative names from the info struct */
#define FMI_XML_ELMLIST_ALT_TERM_ICON(EXPAND_XML_ELMNAME) // TODO: Terminal should go here?

// XXX: fmi3_xml_elmID_none is defined in fmi3_xml_parser.h, not good style
/*
Define XML schema structure. Used to build the 'fmi3_xml_scheme_info_t' type (in fmi3_xml_parser.c).
Define XML schema structure. Used to build the 'fmi_xml_scheme_termIcon_info_t' type (in fmi3_xml_parser.c).

@sib_idx:
the index in a sequence among siblings
@multi_elem:
if the parent can have multiple elements of this type
*/
/* scheme_ID, super_type, parent_ID, sib_idx, multi_elem */
#define fmi3_xml_scheme_fmiTerminalsAndIcons {fmi3_xml_elmID_none, fmi3_xml_elmID_none, 0, 0}
/* scheme_ID, super_type, parent_ID, sib_idx, multi_elem */
#define fmi_xml_scheme_termIcon_fmiTerminalsAndIcons {fmi_xml_elmID_termIcon_none, fmi_xml_elmID_termIcon_none, 0, 0}

#define fmi3_xml_scheme_Terminals {fmi3_xml_elmID_none, fmi3_xml_elmID_fmiTerminalsAndIcons, 1, 0}
#define fmi3_xml_scheme_Terminal {fmi3_xml_elmID_none, fmi3_xml_elmID_Terminals, 0, 1}
#define fmi3_xml_scheme_TerminalMemberVariable {fmi3_xml_elmID_none, fmi3_xml_elmID_Terminal, 0, 1}
#define fmi3_xml_scheme_TerminalStreamMemberVariable {fmi3_xml_elmID_none, fmi3_xml_elmID_Terminal, 1, 1}
#define fmi_xml_scheme_termIcon_Terminals {fmi_xml_elmID_termIcon_none, fmi_xml_elmID_termIcon_fmiTerminalsAndIcons, 1, 0}
#define fmi_xml_scheme_termIcon_Terminal {fmi_xml_elmID_termIcon_none, fmi_xml_elmID_termIcon_Terminals, 0, 1}
#define fmi_xml_scheme_termIcon_TerminalMemberVariable {fmi_xml_elmID_termIcon_none, fmi_xml_elmID_termIcon_Terminal, 0, 1}
#define fmi_xml_scheme_termIcon_TerminalStreamMemberVariable {fmi_xml_elmID_termIcon_none, fmi_xml_elmID_termIcon_Terminal, 1, 1}
// TODO: How to handle nested Terminals?
#define fmi3_xml_scheme_TerminalGraphicalRepresentation {fmi3_xml_elmID_none, fmi3_xml_elmID_Terminal, 3, 0}
#define fmi_xml_scheme_termIcon_TerminalGraphicalRepresentation {fmi_xml_elmID_termIcon_none, fmi_xml_elmID_termIcon_Terminal, 3, 0}

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion src/XML/src/FMI2/fmi2_xml_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ struct fmi2_xml_parser_context_t {
jm_vector(char) elmData;

/**
* Element ID of the last processed sibling, or fmi3_xml_elmID_none if
* Element ID of the last processed sibling, or fmi2_xml_elmID_none if
* no siblings have been processed.
*/
fmi2_xml_elm_enu_t lastElmID;
Expand Down
Loading