Pārlūkot izejas kodu

已修改 tools/pb2tarscpp/CppGenCallback.cpp
已修改 tools/pb2tarscpp/CppGenProxy.cpp

hukai 3 gadi atpakaļ
vecāks
revīzija
4f26b2b41e

+ 5 - 5
tools/pb2tarscpp/CppGenCallback.cpp

@@ -115,18 +115,18 @@ std::string GenPrxCallback(const ::google::protobuf::ServiceDescriptor* desc, in
         out += LineFeed(indent);
         out += "case " + std::to_string((long long)i) + ":" + LineFeed(indent);
         out += "{" + LineFeed(++indent);
-        out += "if (msg->response.iRet != tars::TARSSERVERSUCCESS)" + LineFeed(indent);
+        out += "if (msg->response->iRet != tars::TARSSERVERSUCCESS)" + LineFeed(indent);
         out += "{" + LineFeed(++indent);
-        out += "callback_" + method->name() + "_exception(msg->response.iRet);" + LineFeed(indent);
-        out += "return msg->response.iRet;" + LineFeed(--indent) + "}";
+        out += "callback_" + method->name() + "_exception(msg->response->iRet);" + LineFeed(indent);
+        out += "return msg->response->iRet;" + LineFeed(--indent) + "}";
     
         out += LineFeed(indent);
         out += ToCppNamespace(method->output_type()->full_name()) + " _ret;" + LineFeed(indent);
-        out += "_ret.ParseFromArray(msg->response.sBuffer.data(), msg->response.sBuffer.size());" + LineFeed(indent);
+        out += "_ret.ParseFromArray(msg->response->sBuffer.data(), msg->response->sBuffer.size());" + LineFeed(indent);
         out += "CallbackThreadData * pCbtd = CallbackThreadData::getData();" + LineFeed(indent);
         out += "assert(pCbtd != NULL);" + LineFeed(indent);
         out += LineFeed(indent);
-        out += "pCbtd->setResponseContext(msg->response.context);" + LineFeed(indent);
+        out += "pCbtd->setResponseContext(msg->response->context);" + LineFeed(indent);
         out += "callback_" + method->name() + "(_ret);" + LineFeed(indent);
         out += "pCbtd->delResponseContext();" + LineFeed(indent);
         out += LineFeed(indent);

+ 4 - 5
tools/pb2tarscpp/CppGenProxy.cpp

@@ -25,15 +25,14 @@ static std::string GenSyncCall(const ::google::protobuf::MethodDescriptor* metho
            "req.SerializeToString(&_os);" + LineFeed(indent) +
            "std::vector<char> _vc(_os.begin(), _os.end());" + LineFeed(indent);
     out += LineFeed(indent);
-    out += "tars::ResponsePacket rep;" + LineFeed(indent) +
-           "std::map<std::string, std::string> _mStatus;" + LineFeed(indent);
-    out += "tars_invoke(tars::TARSNORMAL, \"" + method->name() + "\", _vc, context, _mStatus, rep);" + LineFeed(indent);
+    out += "std::map<std::string, std::string> _mStatus;" + LineFeed(indent);
+    out += "shared_ptr<tars::ResponsePacket> rep = tars_invoke(tars::TARSNORMAL, \"" + method->name() + "\", _vc, context, _mStatus);" + LineFeed(indent);
     out += "if (pResponseContext)" + LineFeed(++indent);
-    out += "*pResponseContext = rep.context;" + LineFeed(--indent);
+    out += "*pResponseContext = rep->context;" + LineFeed(--indent);
 
     out += LineFeed(indent);
     out += ToCppNamespace(method->output_type()->full_name()) + " _ret;" + LineFeed(indent);
-    out += "_ret.ParseFromArray(rep.sBuffer.data(), rep.sBuffer.size());" + LineFeed(indent) + 
+    out += "_ret.ParseFromArray(rep->sBuffer.data(), rep->sBuffer.size());" + LineFeed(indent) + 
            "return _ret;";
     out += LineFeed(--indent) + "}";
     out += LineFeed(indent);