mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-20 12:24:24 -04:00
Add support for default parameters value in jsonapi-generator
This commit is contained in:
parent
85c3332fae
commit
e878ba99b2
1 changed files with 7 additions and 1 deletions
|
@ -30,6 +30,7 @@ struct MethodParam
|
||||||
|
|
||||||
QString type;
|
QString type;
|
||||||
QString name;
|
QString name;
|
||||||
|
QString defval;
|
||||||
bool in;
|
bool in;
|
||||||
bool out;
|
bool out;
|
||||||
bool isMultiCallback;
|
bool isMultiCallback;
|
||||||
|
@ -163,6 +164,8 @@ int main(int argc, char *argv[])
|
||||||
QString& pName(tmpParam.name);
|
QString& pName(tmpParam.name);
|
||||||
QString& pType(tmpParam.type);
|
QString& pType(tmpParam.type);
|
||||||
pName = tmpPE.firstChildElement("declname").text();
|
pName = tmpPE.firstChildElement("declname").text();
|
||||||
|
QDomElement tmpDefval = tmpPE.firstChildElement("defval");
|
||||||
|
if(!tmpDefval.isNull()) tmpParam.defval = tmpDefval.text();
|
||||||
QDomElement tmpType = tmpPE.firstChildElement("type");
|
QDomElement tmpType = tmpPE.firstChildElement("type");
|
||||||
pType = tmpType.text();
|
pType = tmpType.text();
|
||||||
if(pType.startsWith("const ")) pType.remove(0,6);
|
if(pType.startsWith("const ")) pType.remove(0,6);
|
||||||
|
@ -248,7 +251,10 @@ int main(int argc, char *argv[])
|
||||||
for (const QString& pn : orderedParamNames)
|
for (const QString& pn : orderedParamNames)
|
||||||
{
|
{
|
||||||
const MethodParam& mp(paramsMap[pn]);
|
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)
|
if(mp.in)
|
||||||
inputParamsDeserialization += "\t\t\tRS_SERIAL_PROCESS("
|
inputParamsDeserialization += "\t\t\tRS_SERIAL_PROCESS("
|
||||||
+ mp.name + ");\n";
|
+ mp.name + ");\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue