JSON API expose retroshare version

Added a couple of macro to reduce boilerplate in manually written API
wrappers, use them in auto-generated wrappers too
This commit is contained in:
Gioacchino Mazzurco 2018-09-12 00:35:42 +02:00
parent 92f90178c4
commit 5245765964
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051
3 changed files with 62 additions and 67 deletions

View file

@ -31,19 +31,7 @@ registerHandler("$%apiPath%$",
const std::shared_ptr<rb::Session> session,
const rb::Bytes& body )
{
RsGenericSerializer::SerializeContext cReq(
nullptr, 0,
RsGenericSerializer::SERIALIZATION_FLAG_YIELDING );
RsJson& jReq(cReq.mJson);
jReq.Parse(reinterpret_cast<const char*>(body.data()), body.size());
RsGenericSerializer::SerializeContext cAns;
RsJson& jAns(cAns.mJson);
// if caller specified caller_data put it back in the answhere
const char kcd[] = "caller_data";
if(jReq.HasMember(kcd))
jAns.AddMember(kcd, jReq[kcd], jAns.GetAllocator());
INITIALIZE_API_CALL_JSON_CONTEXT;
if( !checkRsServicePtrReady(
$%instanceName%$, "$%instanceName%$", cAns, session ) )