Skip to content

Commit ed7bdec

Browse files
committed
- Generate command arguments as string for logging.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24496 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 0249252 commit ed7bdec

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Compiler/Template/GenerateAPIFunctionsTpl.tpl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,18 @@ template getQtInArgBoxed(Text name, DAE.Type ty)
239239
else error(sourceInfo(), 'getQtInArgBoxed failed for <%unparseType(ty)%>')
240240
end getQtInArgBoxed;
241241

242+
template getQtCommandLogText(Text name, DAE.Type ty)
243+
::=
244+
match ty
245+
case T_CODE(ty=C_TYPENAME(__))
246+
case T_STRING(__) then '<%name%>'
247+
case T_INTEGER(__)
248+
case T_REAL(__) then 'QString::number(<%name%>)'
249+
case T_BOOL(__) then 'QString(<%name%> ? "true" : "false")'
250+
case aty as T_ARRAY(__) then 'QString("### Handle array arguments ###")'
251+
else error(sourceInfo(), 'getQtCommandLogText failed for <%unparseType(ty)%>')
252+
end getQtCommandLogText;
253+
242254
template getQtOutArg(Text name, Text shortName, DAE.Type ty, Text &varDecl, Text &postCall)
243255
::=
244256
match ty
@@ -297,6 +309,7 @@ template getQtInterfaceFunc(String name, list<DAE.FuncArg> args, DAE.Type res, S
297309
let &responseLog = buffer ""
298310
let &postCall = buffer ""
299311
let inArgs = args |> arg as FUNCARG(__) => ', <%getQtInArg(arg.name, arg.ty, varDecl)%>'
312+
let commandArgs = args |> arg as FUNCARG(__) => getQtCommandLogText(arg.name, arg.ty) ; separator='+"," +'
300313
let outArgs = (match res
301314
case T_NORETCALL(__) then
302315
let &responseLog += '""'
@@ -319,7 +332,7 @@ template getQtInterfaceFunc(String name, list<DAE.FuncArg> args, DAE.Type res, S
319332
320333
QTime commandTime;
321334
commandTime.start();
322-
emit logCommand("<%replaceDotAndUnderscore(name)%>(### create string of parameters ###)", &commandTime);
335+
emit logCommand("<%replaceDotAndUnderscore(name)%>("+<%if intGt(listLength(args), 0) then commandArgs else 'QString("")'%>+")", &commandTime);
323336
st = omc_OpenModelicaScriptingAPI_<%replaceDotAndUnderscore(name)%>(threadData, st<%inArgs%><%outArgs%>);
324337
<%postCall%>
325338
emit logResponse(<%responseLog%>, &commandTime);

0 commit comments

Comments
 (0)