Opened 10 years ago
Last modified 8 years ago
#3020 assigned defect
Custom annotation cannot be read and proposed code changes to interactive.mo
Reported by: | anonymous | Owned by: | Adrian Pop |
---|---|---|---|
Priority: | normal | Milestone: | Future |
Component: | Interactive Environment | Version: | 1.8.0 |
Keywords: | component annotation | Cc: |
Description
The functions to read the component annotations try to parse the content of said annotation and fail if the format is different than the one expected.
Example OMShell commands demonstrating the problem follows. The first commands creates the problematic annotation. The second tries to read it.
loadString("model Test parameter Real v = 0 annotation(__MyTag(name = \"<String>\")); end Test;"); getComponentAnnotations(Test); -> {{__MyTag(error)}}
The proposed modifications to “interactive.mo” allow to get the raw (unparsed) annotation circumventing the current annotation interpretation code.
Note: the modifications to interactive.mo were made to version 10683 of OpenModelica but the added code could probably be used almost unmodified in the current versions. The reference interactive.mo version 10683 and the modified version are both provided to enable a diff between the two.
Here’s a resume of the changes to interactive.mo version 10683
1) The following functions were added to interactive.mo:
getComponentAnnotationsAsStr
getComponentAnnotationsFromEltsAsStr
getComponentitemsAnnotationsAsStr
getComponentitemsAnnotationsFromItemsAsStr
getNthComponentAnnotationAsStr
getComponentAnnotationAsStr
2) New case items to handle calls to getComponentAnnotationsAsStr and getNthComponentAnnotationAsStr were added to function
evaluateGraphicalApi_dispatch():
// CSA Addons: Dec 14, 2011. C.Adourian case (istmts, st as SYMBOLTABLE(ast = p)) equation matchApiFunction(istmts, "getComponentAnnotationsAsStr"); {Absyn.CREF(componentRef = cr)} = getApiFunctionArgs(istmts); ErrorExt.setCheckpoint("getComponentAnnotationsAsStr"); Config.setEvaluateParametersInAnnotations(true); resstr = getComponentAnnotationsAsStr(cr, p); Config.setEvaluateParametersInAnnotations(false); ErrorExt.rollBack("getComponentAnnotationsAsStr"); then (resstr,st); // CSA Addons: Dec 14, 2011. C.Adourian case (istmts, st as SYMBOLTABLE(ast = p)) equation matchApiFunction(istmts, "getNthComponentAnnotationAsStr"); {Absyn.CREF(componentRef = cr),Absyn.INTEGER(value = n)} = getApiFunctionArgs(istmts); ErrorExt.setCheckpoint("getNthComponentAnnotationAsStr"); Config.setEvaluateParametersInAnnotations(true); resstr = getNthComponentAnnotationAsStr(cr, p, n); Config.setEvaluateParametersInAnnotations(false); ErrorExt.rollBack("getNthComponentAnnotationAsStr"); then (resstr,st);
Attachments (1)
Change History (4)
by , 10 years ago
comment:1 by , 10 years ago
We should not have even more functions added to Interactive.mo. Any new functionality should be implemented in CevalScript.mo.
comment:2 by , 10 years ago
Hi,
any plans to add these suggested modifications to OpenModelica main branch. We've been adding those changes manually, compiling and using the OMC. It would be nice if this ends up in the default maintained OpenModelica code.
Chahé / CSA
comment:3 by , 8 years ago
Component: | *unknown* → Interactive Environment |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Original and modified "interactive.mo" file