Skip to content

Commit

Permalink
- fix sending constant strings to external functions
Browse files Browse the repository at this point in the history
- added test for ExternalMedia model: testsuite/simulation/modelica/external_functions/ts.mos


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23968 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Jan 7, 2015
1 parent df2693c commit 2b389a7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Compiler/Template/CodegenC.tpl
Expand Up @@ -7968,16 +7968,24 @@ template daeExternalCExp(Exp exp, Context context, Text &preExp, Text &varDecls,
case T_ARRAY(__) then // Array-expressions
let shortTypeStr = expTypeShort(typeof(exp))
'(<%extType(typeof(exp),true,true)%>) data_of_<%shortTypeStr%>_array(&<%daeExp(exp, context, &preExp, &varDecls, &auxFunction)%>)'
case T_STRING(__) then
let mstr = daeExp(exp, context, &preExp, &varDecls, &auxFunction)
'MMC_STRINGDATA(<%mstr%>)'
else daeExp(exp, context, &preExp, &varDecls, &auxFunction)
end daeExternalCExp;

template daeExternalF77Exp(Exp exp, Context context, Text &preExp, Text &varDecls, Text &auxFunction)
"Like daeExp, but also converts the type to external C"
"Like daeExp, but also converts the type to external Fortran"
::=
match typeof(exp)
case T_ARRAY(__) then // Array-expressions
let shortTypeStr = expTypeShort(typeof(exp))
'(<%extType(typeof(exp),true,true)%>) data_of_<%shortTypeStr%>_array(&<%daeExp(exp, context, &preExp, &varDecls, &auxFunction)%>)'
case T_STRING(__) then
let texp = daeExp(exp, contextFunction, &preExp, &varDecls, &auxFunction)
let tvar = tempDecl(expTypeFromExpFlag(exp,8),&varDecls)
let &preExp += '<%tvar%> = MMC_STRINGDATA(<%texp%>);<%\n%>'
'&<%tvar%>'
else
let texp = daeExp(exp, contextFunction, &preExp, &varDecls, &auxFunction)
let tvar = tempDecl(expTypeFromExpFlag(exp,8),&varDecls)
Expand Down

0 comments on commit 2b389a7

Please sign in to comment.