Add support for default parameters value in jsonapi-generator

This commit is contained in:
Gioacchino Mazzurco 2018-08-25 22:24:49 +02:00
parent 85c3332fae
commit e878ba99b2
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051

View File

@ -30,6 +30,7 @@ struct MethodParam
QString type;
QString name;
QString defval;
bool in;
bool out;
bool isMultiCallback;
@ -163,6 +164,8 @@ int main(int argc, char *argv[])
QString& pName(tmpParam.name);
QString& pType(tmpParam.type);
pName = tmpPE.firstChildElement("declname").text();
QDomElement tmpDefval = tmpPE.firstChildElement("defval");
if(!tmpDefval.isNull()) tmpParam.defval = tmpDefval.text();
QDomElement tmpType = tmpPE.firstChildElement("type");
pType = tmpType.text();
if(pType.startsWith("const ")) pType.remove(0,6);
@ -248,7 +251,10 @@ int main(int argc, char *argv[])
for (const QString& pn : orderedParamNames)
{
const MethodParam& mp(paramsMap[pn]);
paramsDeclaration += "\t\t" + mp.type + " " + mp.name + ";\n";
paramsDeclaration += "\t\t" + mp.type + " " + mp.name;
if(!mp.defval.isEmpty())
paramsDeclaration += "(" + mp.defval + ")";
paramsDeclaration += ";\n";
if(mp.in)
inputParamsDeserialization += "\t\t\tRS_SERIAL_PROCESS("
+ mp.name + ");\n";