Skip to content

Commit

Permalink
Add redeclare attribute to modifiers in getModelInstance (#11318)
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and adeas31 committed Oct 4, 2023
1 parent 7d537c5 commit 6da8e5d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions OMCompiler/Compiler/Script/NFApi.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,8 @@ algorithm
json := JSON.addPair("each", JSON.makeBoolean(true), json);
end if;

json := JSON.addPair("redeclare", JSON.makeBoolean(true), json);

binding_json := JSON.makeString(SCodeDump.unparseElementStr(mod.element));
json := JSON.addPair("$value", binding_json, json);

Expand Down
4 changes: 4 additions & 0 deletions doc/instanceAPI/getModelInstance.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@
"each": {
"type": "boolean",
"description": "Whether the modifier is each or not"
},
"redeclare": {
"type": "boolean",
"description": "Whether the modifier is a redeclare or not"
}
},
"additionalProperties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,22 @@ getErrorString();
// \"choices\": {
// \"choice\": [
// {
// \"redeclare\": true,
// \"$value\": \"redeclare Real x = 1.0 \\\"A\\\"\",
// \"$type\": \"Real\"
// },
// {
// \"redeclare\": true,
// \"$value\": \"redeclare Real x = 2.0 \\\"B\\\"\",
// \"$type\": \"Real\"
// },
// {
// \"redeclare\": true,
// \"$value\": \"redeclare P2.OtherReal x = 3.0 \\\"C\\\"\",
// \"$type\": \"P.P2.OtherReal\"
// },
// {
// \"redeclare\": true,
// \"$value\": \"redeclare MissingReal x = 4.0 \\\"D\\\"\"
// }
// ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ getModelInstance(M, prettyPrint = true);
// \"$kind\": \"extends\",
// \"modifiers\": {
// \"B\": {
// \"redeclare\": true,
// \"$value\": \"redeclare model B = MB\"
// },
// \"C\": {
// \"redeclare\": true,
// \"$value\": \"redeclare model C = C(y = 2.0)\"
// }
// },
Expand Down
1 change: 1 addition & 0 deletions testsuite/openmodelica/instance-API/ModifierToJSON1.mos
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ getErrorString();
// "{
// \"a\": {
// \"y\": {
// \"redeclare\": true,
// \"$value\": \"redeclare MyReal y = 4\"
// },
// \"x\": \"3\"
Expand Down

0 comments on commit 6da8e5d

Please sign in to comment.