jsonapi-generator fix support for void methods

Thanks sehraf for reporting
retroshare://forum?name=fucking%20genius&id=8fd22bd8f99754461e7ba1ca8a727995&msgid=503d75bf7ed7fa7568eeae4db5c8d31a7e124c98
This commit is contained in:
Gioacchino Mazzurco 2018-06-26 22:01:17 +02:00
parent cb11ad92ea
commit d14a455cf1
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051
4 changed files with 27 additions and 17 deletions

View file

@ -188,7 +188,14 @@ int main(int argc, char *argv[])
}
}
if(retvalType != "void") hasOutput = true;
QString functionCall("\t\t");
if(retvalType != "void")
{
functionCall += retvalType + " retval = ";
hasOutput = true;
}
functionCall += instanceName + "->" + methodName + "(";
functionCall += orderedParamNames.join(", ") + ");\n";
qDebug() << instanceName << apiPath << retvalType << typeName
<< methodName;
@ -236,15 +243,12 @@ int main(int argc, char *argv[])
if(hasOutput) outputParamsSerialization += "\t\t}\n";
QMap<QString,QString> substitutionsMap;
substitutionsMap.insert("instanceName", instanceName);
substitutionsMap.insert("methodName", methodName);
substitutionsMap.insert("paramsDeclaration", paramsDeclaration);
substitutionsMap.insert("inputParamsDeserialization", inputParamsDeserialization);
substitutionsMap.insert("outputParamsSerialization", outputParamsSerialization);
substitutionsMap.insert("retvalType", retvalType);
substitutionsMap.insert("callParamsList", orderedParamNames.join(", "));
substitutionsMap.insert("wrapperName", wrapperName);
substitutionsMap.insert("headerFileName", headerFileName);
substitutionsMap.insert("functionCall", functionCall);
QFile templFile(sourcePath + "/method-wrapper-template.cpp.tmpl");
templFile.open(QIODevice::ReadOnly);

View file

@ -50,7 +50,7 @@ $%paramsDeclaration%$
$%inputParamsDeserialization%$
// call retroshare C++ API
$%retvalType%$ retval = $%instanceName%$->$%methodName%$($%callParamsList%$);
$%functionCall%$
// serialize out parameters and return value to JSON
$%outputParamsSerialization%$