File tree Expand file tree Collapse file tree 4 files changed +26
-11
lines changed
OMCompiler/Compiler/Script
OMEdit/OMEditLIB/Modeling
testsuite/openmodelica/instance-API Expand file tree Collapse file tree 4 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -2158,6 +2158,10 @@ algorithm
21582158 json := JSON . addPair("each" , JSON . makeBoolean(true ), json);
21592159 end if ;
21602160
2161+ if isChoices and isSome(mod. comment) then
2162+ json := JSON . addPair("comment" , JSON . makeString(Util . getOption(mod. comment)), json);
2163+ end if ;
2164+
21612165 if isSome(mod. binding) then
21622166 binding_json := JSON . makeString(Dump . printExpStr(Util . getOption(mod. binding)));
21632167
Original file line number Diff line number Diff line change @@ -733,6 +733,8 @@ namespace ModelInstance
733733 mFinal = true ;
734734 } else if (modifierKey.compare (QStringLiteral (" each" )) == 0 ) {
735735 mEach = true ;
736+ } else if (modifierKey.compare (QStringLiteral (" comment" )) == 0 ) {
737+ mComment = modifierValue.toString ();
736738 } else if (modifierKey.compare (QStringLiteral (" $value" )) == 0 ) {
737739 if (modifierValue.isObject ()) {
738740 QJsonObject valueObject = modifierValue.toObject ();
@@ -777,15 +779,14 @@ namespace ModelInstance
777779 if (!subModifiers.isEmpty ()) {
778780 value.append (" (" % subModifiers.join (" , " ) % " )" );
779781 }
780- if (mValue .isEmpty ()) {
781- if (value.compare (mName ) != 0 ) {
782- return value;
783- } else {
784- return " " ;
785- }
786- } else {
787- return value.append (mName .isEmpty () ? mValue : " = " % mValue );
782+ if (!mValue .isEmpty ()) {
783+ value.append (mName .isEmpty () ? mValue : " = " % mValue );
788784 }
785+ if (!mComment .isEmpty ()) {
786+ value.append (" \" " % mComment % " \" " );
787+ }
788+
789+ return value.compare (mName ) == 0 ? " " : value;
789790 }
790791 }
791792
Original file line number Diff line number Diff line change @@ -487,6 +487,7 @@ namespace ModelInstance
487487 bool mEach = false ;
488488 QString mValue ;
489489 bool mValueDefined = false ;
490+ QString mComment ;
490491 Element *mpElement = 0 ;
491492 QList<Modifier*> mModifiers ;
492493
Original file line number Diff line number Diff line change @@ -40,9 +40,18 @@ getErrorString();
4040// \"annotation\": {
4141// \"choices\": {
4242// \"choice\": [
43- // \"1.0\",
44- // \"2.0\",
45- // \"3.0\"
43+ // {
44+ // \"comment\": \"A\",
45+ // \"$value\": \"1.0\"
46+ // },
47+ // {
48+ // \"comment\": \"B\",
49+ // \"$value\": \"2.0\"
50+ // },
51+ // {
52+ // \"comment\": \"C\",
53+ // \"$value\": \"3.0\"
54+ // }
4655// ],
4756// \"checkBox\": true
4857// }
You can’t perform that action at this time.
0 commit comments