Skip to content

Commit

Permalink
Fix dumping of component direction in instance API (#9117)
Browse files Browse the repository at this point in the history
- The previous code added an unnecessary space at the end of `input` or
  `output`. To avoid that and make the direction behave more like the
  other prefixes, split the direction into separate boolean input and
  output properties.
  • Loading branch information
perost committed Jun 17, 2022
1 parent a9687a6 commit a1b49d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions OMCompiler/Compiler/Script/NFApi.mo
Expand Up @@ -1187,9 +1187,12 @@ algorithm
json := JSON.addPair("variability", JSON.makeString(s), json);
end if;

s := Dump.unparseDirectionSymbolStr(attrs.direction);
if not stringEmpty(s) then
json := JSON.addPair("direction", JSON.makeString(s), json);
if AbsynUtil.isInput(attrs.direction) then
json := JSON.addPair("input", JSON.makeBoolean(true), json);
end if;

if AbsynUtil.isOutput(attrs.direction) then
json := JSON.addPair("output", JSON.makeBoolean(true), json);
end if;
end dumpJSONAttributes;

Expand Down
Expand Up @@ -81,7 +81,7 @@ getModelInstance(M, prettyPrint = true);
// \"type\": \"Real\",
// \"modifier\": \"\",
// \"prefixes\": {
// \"direction\": \"input \"
// \"input\": true
// }
// },
// {
Expand Down

0 comments on commit a1b49d8

Please sign in to comment.