﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3020	Custom annotation cannot be read and proposed code changes to interactive.mo	anonymous	Adrian Pop	"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);
}}}"	defect	assigned	normal	Future	Interactive Environment	1.8.0		component annotation	
