Skip to content

Commit

Permalink
- Generate command arguments as string for logging.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24496 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Feb 10, 2015
1 parent 0249252 commit ed7bdec
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Compiler/Template/GenerateAPIFunctionsTpl.tpl
Expand Up @@ -239,6 +239,18 @@ template getQtInArgBoxed(Text name, DAE.Type ty)
else error(sourceInfo(), 'getQtInArgBoxed failed for <%unparseType(ty)%>')
end getQtInArgBoxed;

template getQtCommandLogText(Text name, DAE.Type ty)
::=
match ty
case T_CODE(ty=C_TYPENAME(__))
case T_STRING(__) then '<%name%>'
case T_INTEGER(__)
case T_REAL(__) then 'QString::number(<%name%>)'
case T_BOOL(__) then 'QString(<%name%> ? "true" : "false")'
case aty as T_ARRAY(__) then 'QString("### Handle array arguments ###")'
else error(sourceInfo(), 'getQtCommandLogText failed for <%unparseType(ty)%>')
end getQtCommandLogText;

template getQtOutArg(Text name, Text shortName, DAE.Type ty, Text &varDecl, Text &postCall)
::=
match ty
Expand Down Expand Up @@ -297,6 +309,7 @@ template getQtInterfaceFunc(String name, list<DAE.FuncArg> args, DAE.Type res, S
let &responseLog = buffer ""
let &postCall = buffer ""
let inArgs = args |> arg as FUNCARG(__) => ', <%getQtInArg(arg.name, arg.ty, varDecl)%>'
let commandArgs = args |> arg as FUNCARG(__) => getQtCommandLogText(arg.name, arg.ty) ; separator='+"," +'
let outArgs = (match res
case T_NORETCALL(__) then
let &responseLog += '""'
Expand All @@ -319,7 +332,7 @@ template getQtInterfaceFunc(String name, list<DAE.FuncArg> args, DAE.Type res, S
QTime commandTime;
commandTime.start();
emit logCommand("<%replaceDotAndUnderscore(name)%>(### create string of parameters ###)", &commandTime);
emit logCommand("<%replaceDotAndUnderscore(name)%>("+<%if intGt(listLength(args), 0) then commandArgs else 'QString("")'%>+")", &commandTime);
st = omc_OpenModelicaScriptingAPI_<%replaceDotAndUnderscore(name)%>(threadData, st<%inArgs%><%outArgs%>);
<%postCall%>
emit logResponse(<%responseLog%>, &commandTime);
Expand Down

0 comments on commit ed7bdec

Please sign in to comment.