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%$

View File

@ -100,7 +100,11 @@ std::string pgp_pwd_callback(void * /*hook*/, const char *uid_title, const char
return password ;
}
void AuthGPG::init(const std::string& path_to_public_keyring,const std::string& path_to_secret_keyring,const std::string& path_to_trustdb,const std::string& pgp_lock_file)
void AuthGPG::init(
const std::string& path_to_public_keyring,
const std::string& path_to_secret_keyring,
const std::string& path_to_trustdb,
const std::string& pgp_lock_file)
{
if(_instance != NULL)
{
@ -108,8 +112,11 @@ void AuthGPG::init(const std::string& path_to_public_keyring,const std::string&
std::cerr << "AuthGPG::init() called twice!" << std::endl ;
}
PGPHandler::setPassphraseCallback(pgp_pwd_callback) ;
_instance = new AuthGPG(path_to_public_keyring,path_to_secret_keyring,path_to_trustdb,pgp_lock_file) ;
// if(cb) PGPHandler::setPassphraseCallback(cb);else
PGPHandler::setPassphraseCallback(pgp_pwd_callback);
_instance = new AuthGPG( path_to_public_keyring,
path_to_secret_keyring,
path_to_trustdb, pgp_lock_file );
}
void AuthGPG::exit()

View File

@ -89,8 +89,8 @@ public:
class AuthGPGService
{
public:
AuthGPGService() {};
~AuthGPGService() {};
AuthGPGService() {}
~AuthGPGService() {}
virtual AuthGPGOperation *getGPGOperation() = 0;
virtual void setGPGOperation(AuthGPGOperation *operation) = 0;
@ -98,9 +98,8 @@ public:
class AuthGPG: public p3Config, public RsTickingThread, public PGPHandler
{
public:
static void init( const std::string& path_to_pubring,
public:
static void init(const std::string& path_to_pubring,
const std::string& path_to_secring,
const std::string& path_to_trustdb,
const std::string& pgp_lock_file);