Skip to content
Snippets Groups Projects
Unverified Commit 974f3d79 authored by Harsh Vardhan's avatar Harsh Vardhan
Browse files

remove lang specific streaming methods

parent cacd5e84
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,14 @@ grpc::string as_string(T x) { ...@@ -50,6 +50,14 @@ grpc::string as_string(T x) {
return out.str(); return out.str();
} }
inline bool ClientOnlyStreaming(const grpc_generator::Method *method) {
return method->ClientStreaming() && !method->ServerStreaming();
}
inline bool ServerOnlyStreaming(const grpc_generator::Method *method) {
return !method->ClientStreaming() && method->ServerStreaming();
}
grpc::string FilenameIdentifier(const grpc::string &filename) { grpc::string FilenameIdentifier(const grpc::string &filename) {
grpc::string result; grpc::string result;
for (unsigned i = 0; i < filename.size(); i++) { for (unsigned i = 0; i < filename.size(); i++) {
...@@ -193,7 +201,7 @@ void PrintHeaderClientMethodInterfaces( ...@@ -193,7 +201,7 @@ void PrintHeaderClientMethodInterfaces(
"Async$Method$Raw(context, request, cq));\n"); "Async$Method$Raw(context, request, cq));\n");
printer->Outdent(); printer->Outdent();
printer->Print("}\n"); printer->Print("}\n");
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"std::unique_ptr< ::grpc::ClientWriterInterface< $Request$>>" "std::unique_ptr< ::grpc::ClientWriterInterface< $Request$>>"
...@@ -219,7 +227,7 @@ void PrintHeaderClientMethodInterfaces( ...@@ -219,7 +227,7 @@ void PrintHeaderClientMethodInterfaces(
"Async$Method$Raw(context, response, cq, tag));\n"); "Async$Method$Raw(context, response, cq, tag));\n");
printer->Outdent(); printer->Outdent();
printer->Print("}\n"); printer->Print("}\n");
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"std::unique_ptr< ::grpc::ClientReaderInterface< $Response$>>" "std::unique_ptr< ::grpc::ClientReaderInterface< $Response$>>"
...@@ -281,7 +289,7 @@ void PrintHeaderClientMethodInterfaces( ...@@ -281,7 +289,7 @@ void PrintHeaderClientMethodInterfaces(
"Async$Method$Raw(::grpc::ClientContext* context, " "Async$Method$Raw(::grpc::ClientContext* context, "
"const $Request$& request, " "const $Request$& request, "
"::grpc::CompletionQueue* cq) = 0;\n"); "::grpc::CompletionQueue* cq) = 0;\n");
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"virtual ::grpc::ClientWriterInterface< $Request$>*" "virtual ::grpc::ClientWriterInterface< $Request$>*"
...@@ -292,7 +300,7 @@ void PrintHeaderClientMethodInterfaces( ...@@ -292,7 +300,7 @@ void PrintHeaderClientMethodInterfaces(
" Async$Method$Raw(::grpc::ClientContext* context, " " Async$Method$Raw(::grpc::ClientContext* context, "
"$Response$* response, " "$Response$* response, "
"::grpc::CompletionQueue* cq, void* tag) = 0;\n"); "::grpc::CompletionQueue* cq, void* tag) = 0;\n");
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"virtual ::grpc::ClientReaderInterface< $Response$>* $Method$Raw(" "virtual ::grpc::ClientReaderInterface< $Response$>* $Method$Raw("
...@@ -343,7 +351,7 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer, ...@@ -343,7 +351,7 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer,
"Async$Method$Raw(context, request, cq));\n"); "Async$Method$Raw(context, request, cq));\n");
printer->Outdent(); printer->Outdent();
printer->Print("}\n"); printer->Print("}\n");
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"std::unique_ptr< ::grpc::ClientWriter< $Request$>>" "std::unique_ptr< ::grpc::ClientWriter< $Request$>>"
...@@ -367,7 +375,7 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer, ...@@ -367,7 +375,7 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer,
"Async$Method$Raw(context, response, cq, tag));\n"); "Async$Method$Raw(context, response, cq, tag));\n");
printer->Outdent(); printer->Outdent();
printer->Print("}\n"); printer->Print("}\n");
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"std::unique_ptr< ::grpc::ClientReader< $Response$>>" "std::unique_ptr< ::grpc::ClientReader< $Response$>>"
...@@ -425,7 +433,7 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer, ...@@ -425,7 +433,7 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer,
"Async$Method$Raw(::grpc::ClientContext* context, " "Async$Method$Raw(::grpc::ClientContext* context, "
"const $Request$& request, " "const $Request$& request, "
"::grpc::CompletionQueue* cq) override;\n"); "::grpc::CompletionQueue* cq) override;\n");
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"::grpc::ClientWriter< $Request$>* $Method$Raw(" "::grpc::ClientWriter< $Request$>* $Method$Raw("
"::grpc::ClientContext* context, $Response$* response) " "::grpc::ClientContext* context, $Response$* response) "
...@@ -434,7 +442,7 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer, ...@@ -434,7 +442,7 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer,
"::grpc::ClientAsyncWriter< $Request$>* Async$Method$Raw(" "::grpc::ClientAsyncWriter< $Request$>* Async$Method$Raw("
"::grpc::ClientContext* context, $Response$* response, " "::grpc::ClientContext* context, $Response$* response, "
"::grpc::CompletionQueue* cq, void* tag) override;\n"); "::grpc::CompletionQueue* cq, void* tag) override;\n");
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"::grpc::ClientReader< $Response$>* $Method$Raw(" "::grpc::ClientReader< $Response$>* $Method$Raw("
"::grpc::ClientContext* context, const $Request$& request)" "::grpc::ClientContext* context, const $Request$& request)"
...@@ -475,13 +483,13 @@ void PrintHeaderServerMethodSync(grpc_generator::Printer *printer, ...@@ -475,13 +483,13 @@ void PrintHeaderServerMethodSync(grpc_generator::Printer *printer,
"virtual ::grpc::Status $Method$(" "virtual ::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, " "::grpc::ServerContext* context, const $Request$* request, "
"$Response$* response);\n"); "$Response$* response);\n");
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"virtual ::grpc::Status $Method$(" "virtual ::grpc::Status $Method$("
"::grpc::ServerContext* context, " "::grpc::ServerContext* context, "
"::grpc::ServerReader< $Request$>* reader, " "::grpc::ServerReader< $Request$>* reader, "
"$Response$* response);\n"); "$Response$* response);\n");
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"virtual ::grpc::Status $Method$(" "virtual ::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, " "::grpc::ServerContext* context, const $Request$* request, "
...@@ -540,7 +548,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer, ...@@ -540,7 +548,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
" ::grpc::Service::RequestAsyncUnary($Idx$, context, " " ::grpc::Service::RequestAsyncUnary($Idx$, context, "
"request, response, new_call_cq, notification_cq, tag);\n"); "request, response, new_call_cq, notification_cq, tag);\n");
printer->Print("}\n"); printer->Print("}\n");
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"// disable synchronous version of this method\n" "// disable synchronous version of this method\n"
...@@ -562,7 +570,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer, ...@@ -562,7 +570,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
" ::grpc::Service::RequestAsyncClientStreaming($Idx$, " " ::grpc::Service::RequestAsyncClientStreaming($Idx$, "
"context, reader, new_call_cq, notification_cq, tag);\n"); "context, reader, new_call_cq, notification_cq, tag);\n");
printer->Print("}\n"); printer->Print("}\n");
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"// disable synchronous version of this method\n" "// disable synchronous version of this method\n"
...@@ -669,7 +677,7 @@ void PrintHeaderServerMethodSplitStreaming( ...@@ -669,7 +677,7 @@ void PrintHeaderServerMethodSplitStreaming(
(*vars)["Method"] = method->name(); (*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name(); (*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name(); (*vars)["Response"] = method->output_type_name();
if (method->ServerStreaming()) { if (ServerOnlyStreaming(method)) {
printer->Print(*vars, "template <class BaseClass>\n"); printer->Print(*vars, "template <class BaseClass>\n");
printer->Print(*vars, printer->Print(*vars,
"class WithSplitStreamingMethod_$Method$ : " "class WithSplitStreamingMethod_$Method$ : "
...@@ -747,7 +755,7 @@ void PrintHeaderServerMethodGeneric( ...@@ -747,7 +755,7 @@ void PrintHeaderServerMethodGeneric(
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"// disable synchronous version of this method\n" "// disable synchronous version of this method\n"
...@@ -758,7 +766,7 @@ void PrintHeaderServerMethodGeneric( ...@@ -758,7 +766,7 @@ void PrintHeaderServerMethodGeneric(
" abort();\n" " abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"// disable synchronous version of this method\n" "// disable synchronous version of this method\n"
...@@ -914,13 +922,15 @@ void PrintHeaderService(grpc_generator::Printer *printer, ...@@ -914,13 +922,15 @@ void PrintHeaderService(grpc_generator::Printer *printer,
printer->Print("typedef "); printer->Print("typedef ");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
(*vars)["method_name"] = service->method(i).get()->name(); (*vars)["method_name"] = service->method(i).get()->name();
if (service->method(i)->ServerStreaming()) { auto method = service->method(i);
if (ServerOnlyStreaming(method.get())) {
printer->Print(*vars, "WithSplitStreamingMethod_$method_name$<"); printer->Print(*vars, "WithSplitStreamingMethod_$method_name$<");
} }
} }
printer->Print("Service"); printer->Print("Service");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
if (service->method(i)->ServerStreaming()) { auto method = service->method(i);
if (ServerOnlyStreaming(method.get())) {
printer->Print(" >"); printer->Print(" >");
} }
} }
...@@ -930,7 +940,8 @@ void PrintHeaderService(grpc_generator::Printer *printer, ...@@ -930,7 +940,8 @@ void PrintHeaderService(grpc_generator::Printer *printer,
printer->Print("typedef "); printer->Print("typedef ");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
(*vars)["method_name"] = service->method(i).get()->name(); (*vars)["method_name"] = service->method(i).get()->name();
if (service->method(i)->ServerStreaming()) { auto method = service->method(i);
if (ServerOnlyStreaming(method.get())) {
printer->Print(*vars, "WithSplitStreamingMethod_$method_name$<"); printer->Print(*vars, "WithSplitStreamingMethod_$method_name$<");
} }
if (service->method(i)->NoStreaming()) { if (service->method(i)->NoStreaming()) {
...@@ -939,8 +950,9 @@ void PrintHeaderService(grpc_generator::Printer *printer, ...@@ -939,8 +950,9 @@ void PrintHeaderService(grpc_generator::Printer *printer,
} }
printer->Print("Service"); printer->Print("Service");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i);
if (service->method(i)->NoStreaming() || if (service->method(i)->NoStreaming() ||
service->method(i)->ServerStreaming()) { ServerOnlyStreaming(method.get())) {
printer->Print(" >"); printer->Print(" >");
} }
} }
...@@ -1100,7 +1112,7 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer, ...@@ -1100,7 +1112,7 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
"rpcmethod_$Method$_, " "rpcmethod_$Method$_, "
"context, request);\n" "context, request);\n"
"}\n\n"); "}\n\n");
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"::grpc::ClientWriter< $Request$>* " "::grpc::ClientWriter< $Request$>* "
"$ns$$Service$::Stub::$Method$Raw(" "$ns$$Service$::Stub::$Method$Raw("
...@@ -1122,7 +1134,7 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer, ...@@ -1122,7 +1134,7 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
"rpcmethod_$Method$_, " "rpcmethod_$Method$_, "
"context, response, tag);\n" "context, response, tag);\n"
"}\n\n"); "}\n\n");
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"::grpc::ClientReader< $Response$>* " "::grpc::ClientReader< $Response$>* "
...@@ -1190,7 +1202,7 @@ void PrintSourceServerMethod(grpc_generator::Printer *printer, ...@@ -1190,7 +1202,7 @@ void PrintSourceServerMethod(grpc_generator::Printer *printer,
" return ::grpc::Status(" " return ::grpc::Status("
"::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"); "::grpc::StatusCode::UNIMPLEMENTED, \"\");\n");
printer->Print("}\n\n"); printer->Print("}\n\n");
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"::grpc::Status $ns$$Service$::Service::$Method$(" "::grpc::Status $ns$$Service$::Service::$Method$("
"::grpc::ServerContext* context, " "::grpc::ServerContext* context, "
...@@ -1203,7 +1215,7 @@ void PrintSourceServerMethod(grpc_generator::Printer *printer, ...@@ -1203,7 +1215,7 @@ void PrintSourceServerMethod(grpc_generator::Printer *printer,
" return ::grpc::Status(" " return ::grpc::Status("
"::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"); "::grpc::StatusCode::UNIMPLEMENTED, \"\");\n");
printer->Print("}\n\n"); printer->Print("}\n\n");
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"::grpc::Status $ns$$Service$::Service::$Method$(" "::grpc::Status $ns$$Service$::Service::$Method$("
"::grpc::ServerContext* context, " "::grpc::ServerContext* context, "
...@@ -1268,9 +1280,9 @@ void PrintSourceService(grpc_generator::Printer *printer, ...@@ -1268,9 +1280,9 @@ void PrintSourceService(grpc_generator::Printer *printer,
// NOTE: There is no reason to consider streamed-unary as a separate // NOTE: There is no reason to consider streamed-unary as a separate
// category here since this part is setting up the client-side stub // category here since this part is setting up the client-side stub
// and this appears as a NORMAL_RPC from the client-side. // and this appears as a NORMAL_RPC from the client-side.
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method.get())) {
(*vars)["StreamingType"] = "CLIENT_STREAMING"; (*vars)["StreamingType"] = "CLIENT_STREAMING";
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method.get())) {
(*vars)["StreamingType"] = "SERVER_STREAMING"; (*vars)["StreamingType"] = "SERVER_STREAMING";
} else { } else {
(*vars)["StreamingType"] = "BIDI_STREAMING"; (*vars)["StreamingType"] = "BIDI_STREAMING";
...@@ -1308,7 +1320,7 @@ void PrintSourceService(grpc_generator::Printer *printer, ...@@ -1308,7 +1320,7 @@ void PrintSourceService(grpc_generator::Printer *printer,
"$Request$, " "$Request$, "
"$Response$>(\n" "$Response$>(\n"
" std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n"); " std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n");
} else if (method->ClientStreaming()) { } else if (ClientOnlyStreaming(method.get())) {
printer->Print( printer->Print(
*vars, *vars,
"AddMethod(new ::grpc::RpcServiceMethod(\n" "AddMethod(new ::grpc::RpcServiceMethod(\n"
...@@ -1317,7 +1329,7 @@ void PrintSourceService(grpc_generator::Printer *printer, ...@@ -1317,7 +1329,7 @@ void PrintSourceService(grpc_generator::Printer *printer,
" new ::grpc::ClientStreamingHandler< " " new ::grpc::ClientStreamingHandler< "
"$ns$$Service$::Service, $Request$, $Response$>(\n" "$ns$$Service$::Service, $Request$, $Response$>(\n"
" std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n"); " std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n");
} else if (method->ServerStreaming()) { } else if (ServerOnlyStreaming(method.get())) {
printer->Print( printer->Print(
*vars, *vars,
"AddMethod(new ::grpc::RpcServiceMethod(\n" "AddMethod(new ::grpc::RpcServiceMethod(\n"
......
...@@ -88,17 +88,9 @@ class ProtoBufMethod : public grpc_generator::Method { ...@@ -88,17 +88,9 @@ class ProtoBufMethod : public grpc_generator::Method {
return !method_->client_streaming() && !method_->server_streaming(); return !method_->client_streaming() && !method_->server_streaming();
} }
bool ClientStreaming() const { bool ClientStreaming() const { return method_->client_streaming(); }
return method_->client_streaming() && !method_->server_streaming();
}
bool python_ClientStreaming() const { return method_->client_streaming(); }
bool ServerStreaming() const {
return !method_->client_streaming() && method_->server_streaming();
}
bool python_ServerStreaming() const { return method_->server_streaming(); } bool ServerStreaming() const { return method_->server_streaming(); }
bool BidiStreaming() const { bool BidiStreaming() const {
return method_->client_streaming() && method_->server_streaming(); return method_->client_streaming() && method_->server_streaming();
......
...@@ -48,9 +48,9 @@ ...@@ -48,9 +48,9 @@
#include "src/compiler/config.h" #include "src/compiler/config.h"
#include "src/compiler/generator_helpers.h" #include "src/compiler/generator_helpers.h"
#include "src/compiler/protobuf_plugin.h" #include "src/compiler/protobuf_plugin.h"
#include "src/compiler/python_generator.h"
#include "src/compiler/python_generator_helpers.h" #include "src/compiler/python_generator_helpers.h"
#include "src/compiler/python_private_generator.h" #include "src/compiler/python_private_generator.h"
#include "src/compiler/schema_interface.h"
using grpc::protobuf::FileDescriptor; using grpc::protobuf::FileDescriptor;
using grpc::protobuf::compiler::GeneratorContext; using grpc::protobuf::compiler::GeneratorContext;
...@@ -135,7 +135,7 @@ bool PrivateGenerator::PrintBetaServicer(const grpc_generator::Service* service, ...@@ -135,7 +135,7 @@ bool PrivateGenerator::PrintBetaServicer(const grpc_generator::Service* service,
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i); auto method = service->method(i);
grpc::string arg_name = grpc::string arg_name =
method->python_ClientStreaming() ? "request_iterator" : "request"; method->ClientStreaming() ? "request_iterator" : "request";
StringMap method_dict; StringMap method_dict;
method_dict["Method"] = method->name(); method_dict["Method"] = method->name();
method_dict["ArgName"] = arg_name; method_dict["ArgName"] = arg_name;
...@@ -171,7 +171,7 @@ bool PrivateGenerator::PrintBetaStub(const grpc_generator::Service* service, ...@@ -171,7 +171,7 @@ bool PrivateGenerator::PrintBetaStub(const grpc_generator::Service* service,
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i); auto method = service->method(i);
grpc::string arg_name = grpc::string arg_name =
method->python_ClientStreaming() ? "request_iterator" : "request"; method->ClientStreaming() ? "request_iterator" : "request";
StringMap method_dict; StringMap method_dict;
method_dict["Method"] = method->name(); method_dict["Method"] = method->name();
method_dict["ArgName"] = arg_name; method_dict["ArgName"] = arg_name;
...@@ -184,7 +184,7 @@ bool PrivateGenerator::PrintBetaStub(const grpc_generator::Service* service, ...@@ -184,7 +184,7 @@ bool PrivateGenerator::PrintBetaStub(const grpc_generator::Service* service,
PrintAllComments(method_comments, out); PrintAllComments(method_comments, out);
out->Print("raise NotImplementedError()\n"); out->Print("raise NotImplementedError()\n");
} }
if (!method->python_ServerStreaming()) { if (!method->ServerStreaming()) {
out->Print(method_dict, "$Method$.future = None\n"); out->Print(method_dict, "$Method$.future = None\n");
} }
} }
...@@ -215,10 +215,8 @@ bool PrivateGenerator::PrintBetaServerFactory( ...@@ -215,10 +215,8 @@ bool PrivateGenerator::PrintBetaServerFactory(
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i); auto method = service->method(i);
const grpc::string method_implementation_constructor = const grpc::string method_implementation_constructor =
grpc::string(method->python_ClientStreaming() ? "stream_" grpc::string(method->ClientStreaming() ? "stream_" : "unary_") +
: "unary_") + grpc::string(method->ServerStreaming() ? "stream_" : "unary_") +
grpc::string(method->python_ServerStreaming() ? "stream_"
: "unary_") +
"inline"; "inline";
grpc::string input_message_module_and_class; grpc::string input_message_module_and_class;
if (!method->get_module_and_message_path_input( if (!method->get_module_and_message_path_input(
...@@ -324,9 +322,8 @@ bool PrivateGenerator::PrintBetaStubFactory( ...@@ -324,9 +322,8 @@ bool PrivateGenerator::PrintBetaStubFactory(
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i); auto method = service->method(i);
const grpc::string method_cardinality = const grpc::string method_cardinality =
grpc::string(method->python_ClientStreaming() ? "STREAM" : "UNARY") + grpc::string(method->ClientStreaming() ? "STREAM" : "UNARY") + "_" +
"_" + grpc::string(method->ServerStreaming() ? "STREAM" : "UNARY");
grpc::string(method->python_ServerStreaming() ? "STREAM" : "UNARY");
grpc::string input_message_module_and_class; grpc::string input_message_module_and_class;
if (!method->get_module_and_message_path_input( if (!method->get_module_and_message_path_input(
&input_message_module_and_class, generator_file_name, &input_message_module_and_class, generator_file_name,
...@@ -430,10 +427,8 @@ bool PrivateGenerator::PrintStub( ...@@ -430,10 +427,8 @@ bool PrivateGenerator::PrintStub(
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i); auto method = service->method(i);
grpc::string multi_callable_constructor = grpc::string multi_callable_constructor =
grpc::string(method->python_ClientStreaming() ? "stream" grpc::string(method->ClientStreaming() ? "stream" : "unary") + "_" +
: "unary") + grpc::string(method->ServerStreaming() ? "stream" : "unary");
"_" +
grpc::string(method->python_ServerStreaming() ? "stream" : "unary");
grpc::string request_module_and_class; grpc::string request_module_and_class;
if (!method->get_module_and_message_path_input( if (!method->get_module_and_message_path_input(
&request_module_and_class, generator_file_name, &request_module_and_class, generator_file_name,
...@@ -486,7 +481,7 @@ bool PrivateGenerator::PrintServicer(const grpc_generator::Service* service, ...@@ -486,7 +481,7 @@ bool PrivateGenerator::PrintServicer(const grpc_generator::Service* service,
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i); auto method = service->method(i);
grpc::string arg_name = grpc::string arg_name =
method->python_ClientStreaming() ? "request_iterator" : "request"; method->ClientStreaming() ? "request_iterator" : "request";
StringMap method_dict; StringMap method_dict;
method_dict["Method"] = method->name(); method_dict["Method"] = method->name();
method_dict["ArgName"] = arg_name; method_dict["ArgName"] = arg_name;
...@@ -522,10 +517,8 @@ bool PrivateGenerator::PrintAddServicerToServer( ...@@ -522,10 +517,8 @@ bool PrivateGenerator::PrintAddServicerToServer(
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto method = service->method(i); auto method = service->method(i);
grpc::string method_handler_constructor = grpc::string method_handler_constructor =
grpc::string(method->python_ClientStreaming() ? "stream" grpc::string(method->ClientStreaming() ? "stream" : "unary") + "_" +
: "unary") + grpc::string(method->ServerStreaming() ? "stream" : "unary") +
"_" + grpc::string(method->python_ServerStreaming() ? "stream"
: "unary") +
"_rpc_method_handler"; "_rpc_method_handler";
grpc::string request_module_and_class; grpc::string request_module_and_class;
if (!method->get_module_and_message_path_input( if (!method->get_module_and_message_path_input(
......
...@@ -81,9 +81,7 @@ struct Method : public CommentHolder { ...@@ -81,9 +81,7 @@ struct Method : public CommentHolder {
virtual grpc::string get_output_type_name() const = 0; virtual grpc::string get_output_type_name() const = 0;
virtual bool NoStreaming() const = 0; virtual bool NoStreaming() const = 0;
virtual bool ClientStreaming() const = 0; virtual bool ClientStreaming() const = 0;
virtual bool python_ClientStreaming() const = 0;
virtual bool ServerStreaming() const = 0; virtual bool ServerStreaming() const = 0;
virtual bool python_ServerStreaming() const = 0;
virtual bool BidiStreaming() const = 0; virtual bool BidiStreaming() const = 0;
}; };
......
...@@ -5992,8 +5992,8 @@ ...@@ -5992,8 +5992,8 @@
"src/compiler/php_generator_helpers.h", "src/compiler/php_generator_helpers.h",
"src/compiler/protobuf_plugin.h", "src/compiler/protobuf_plugin.h",
"src/compiler/python_generator.h", "src/compiler/python_generator.h",
"src/compiler/python_private_generator.h",
"src/compiler/python_generator_helpers.h", "src/compiler/python_generator_helpers.h",
"src/compiler/python_private_generator.h",
"src/compiler/ruby_generator.h", "src/compiler/ruby_generator.h",
"src/compiler/ruby_generator_helpers-inl.h", "src/compiler/ruby_generator_helpers-inl.h",
"src/compiler/ruby_generator_map-inl.h", "src/compiler/ruby_generator_map-inl.h",
......
...@@ -163,11 +163,15 @@ ...@@ -163,11 +163,15 @@
<ClInclude Include="$(SolutionDir)\..\src\compiler\objective_c_generator_helpers.h" /> <ClInclude Include="$(SolutionDir)\..\src\compiler\objective_c_generator_helpers.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\php_generator.h" /> <ClInclude Include="$(SolutionDir)\..\src\compiler\php_generator.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\php_generator_helpers.h" /> <ClInclude Include="$(SolutionDir)\..\src\compiler\php_generator_helpers.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\protobuf_plugin.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\python_generator.h" /> <ClInclude Include="$(SolutionDir)\..\src\compiler\python_generator.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\python_generator_helpers.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\python_private_generator.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator.h" /> <ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator_helpers-inl.h" /> <ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator_helpers-inl.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator_map-inl.h" /> <ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator_map-inl.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator_string-inl.h" /> <ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator_string-inl.h" />
<ClInclude Include="$(SolutionDir)\..\src\compiler\schema_interface.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="$(SolutionDir)\..\src\compiler\cpp_generator.cc"> <ClCompile Include="$(SolutionDir)\..\src\compiler\cpp_generator.cc">
......
...@@ -65,9 +65,18 @@ ...@@ -65,9 +65,18 @@
<ClInclude Include="$(SolutionDir)\..\src\compiler\php_generator_helpers.h"> <ClInclude Include="$(SolutionDir)\..\src\compiler\php_generator_helpers.h">
<Filter>src\compiler</Filter> <Filter>src\compiler</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\compiler\protobuf_plugin.h">
<Filter>src\compiler</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\compiler\python_generator.h"> <ClInclude Include="$(SolutionDir)\..\src\compiler\python_generator.h">
<Filter>src\compiler</Filter> <Filter>src\compiler</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\compiler\python_generator_helpers.h">
<Filter>src\compiler</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\compiler\python_private_generator.h">
<Filter>src\compiler</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator.h"> <ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator.h">
<Filter>src\compiler</Filter> <Filter>src\compiler</Filter>
</ClInclude> </ClInclude>
...@@ -80,6 +89,9 @@ ...@@ -80,6 +89,9 @@
<ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator_string-inl.h"> <ClInclude Include="$(SolutionDir)\..\src\compiler\ruby_generator_string-inl.h">
<Filter>src\compiler</Filter> <Filter>src\compiler</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\compiler\schema_interface.h">
<Filter>src\compiler</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment