diff options
author | 2015-01-06 10:35:03 -0800 | |
---|---|---|
committer | 2015-01-06 17:47:01 -0800 | |
commit | 5bcea0d0d5d88ef96f9f51f823b138fd228ad2b3 (patch) | |
tree | 66bd93016c84b8db642db8e4ec783f5bcd3640f9 /src/compiler | |
parent | ed5e7e006b1a60ef01a0ee1db144e959436b53d7 (diff) |
Add package name to the method string.
Changes:
C++ code generator
Go code generator and generated file
java code generator and test golden file
java server side Handler registry code
java shm channel (strips the package name from the method name)
ESF registering code
Tested:
[] test net/grpc/testing/interop:all
global presubmit:
[]
Change on 2015/01/06 by yangg <yangg@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83353207
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/cpp_generator.cc | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index fd4dab7c9c..14d5005dc0 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -266,32 +266,32 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer, "const $Request$& request, $Response$* response) {\n"); printer->Print(*vars, " return channel()->StartBlockingRpc(" - "::grpc::RpcMethod(\"/$Service$/$Method$\"), " + "::grpc::RpcMethod(\"/$Package$$Service$/$Method$\"), " "context, request, response);\n" "}\n\n"); } else if (ClientOnlyStreaming(method)) { printer->Print(*vars, "::grpc::ClientWriter<$Request$>* $Service$::Stub::$Method$(" "::grpc::ClientContext* context, $Response$* response) {\n"); - printer->Print( - *vars, - " return new ::grpc::ClientWriter<$Request$>(" - "channel()->CreateStream(::grpc::RpcMethod(\"/$Service$/$Method$\", " - "::grpc::RpcMethod::RpcType::CLIENT_STREAMING), " - "context, nullptr, response));\n" - "}\n\n"); + printer->Print(*vars, + " return new ::grpc::ClientWriter<$Request$>(" + "channel()->CreateStream(" + "::grpc::RpcMethod(\"/$Package$$Service$/$Method$\", " + "::grpc::RpcMethod::RpcType::CLIENT_STREAMING), " + "context, nullptr, response));\n" + "}\n\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, "::grpc::ClientReader<$Response$>* $Service$::Stub::$Method$(" "::grpc::ClientContext* context, const $Request$* request) {\n"); - printer->Print( - *vars, - " return new ::grpc::ClientReader<$Response$>(" - "channel()->CreateStream(::grpc::RpcMethod(\"/$Service$/$Method$\", " - "::grpc::RpcMethod::RpcType::SERVER_STREAMING), " - "context, request, nullptr));\n" - "}\n\n"); + printer->Print(*vars, + " return new ::grpc::ClientReader<$Response$>(" + "channel()->CreateStream(" + "::grpc::RpcMethod(\"/$Package$$Service$/$Method$\", " + "::grpc::RpcMethod::RpcType::SERVER_STREAMING), " + "context, request, nullptr));\n" + "}\n\n"); } else if (BidiStreaming(method)) { printer->Print( *vars, @@ -300,7 +300,8 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer, printer->Print( *vars, " return new ::grpc::ClientReaderWriter<$Request$, $Response$>(" - "channel()->CreateStream(::grpc::RpcMethod(\"/$Service$/$Method$\", " + "channel()->CreateStream(" + "::grpc::RpcMethod(\"/$Package$$Service$/$Method$\", " "::grpc::RpcMethod::RpcType::BIDI_STREAMING), " "context, nullptr, nullptr));\n" "}\n\n"); @@ -397,7 +398,8 @@ void PrintSourceService(google::protobuf::io::Printer* printer, printer->Print( *vars, "service_->AddMethod(new ::grpc::RpcServiceMethod(\n" - " \"/$Service$/$Method$\", ::grpc::RpcMethod::NORMAL_RPC,\n" + " \"/$Package$$Service$/$Method$\",\n" + " ::grpc::RpcMethod::NORMAL_RPC,\n" " new ::grpc::RpcMethodHandler<$Service$::Service, $Request$, " "$Response$>(\n" " std::function<::grpc::Status($Service$::Service*, " @@ -408,7 +410,8 @@ void PrintSourceService(google::protobuf::io::Printer* printer, printer->Print( *vars, "service_->AddMethod(new ::grpc::RpcServiceMethod(\n" - " \"/$Service$/$Method$\", ::grpc::RpcMethod::CLIENT_STREAMING,\n" + " \"/$Package$$Service$/$Method$\",\n" + " ::grpc::RpcMethod::CLIENT_STREAMING,\n" " new ::grpc::ClientStreamingHandler<" "$Service$::Service, $Request$, $Response$>(\n" " std::function<::grpc::Status($Service$::Service*, " @@ -420,7 +423,8 @@ void PrintSourceService(google::protobuf::io::Printer* printer, printer->Print( *vars, "service_->AddMethod(new ::grpc::RpcServiceMethod(\n" - " \"/$Service$/$Method$\", ::grpc::RpcMethod::SERVER_STREAMING,\n" + " \"/$Package$$Service$/$Method$\",\n" + " ::grpc::RpcMethod::SERVER_STREAMING,\n" " new ::grpc::ServerStreamingHandler<" "$Service$::Service, $Request$, $Response$>(\n" " std::function<::grpc::Status($Service$::Service*, " @@ -432,7 +436,8 @@ void PrintSourceService(google::protobuf::io::Printer* printer, printer->Print( *vars, "service_->AddMethod(new ::grpc::RpcServiceMethod(\n" - " \"/$Service$/$Method$\", ::grpc::RpcMethod::BIDI_STREAMING,\n" + " \"/$Package$$Service$/$Method$\",\n" + " ::grpc::RpcMethod::BIDI_STREAMING,\n" " new ::grpc::BidiStreamingHandler<" "$Service$::Service, $Request$, $Response$>(\n" " std::function<::grpc::Status($Service$::Service*, " @@ -452,6 +457,12 @@ string GetSourceServices(const google::protobuf::FileDescriptor* file) { google::protobuf::io::StringOutputStream output_stream(&output); google::protobuf::io::Printer printer(&output_stream, '$'); map<string, string> vars; + // Package string is empty or ends with a dot. It is used to fully qualify + // method names. + vars["Package"] = file->package(); + if (!file->package().empty()) { + vars["Package"].append("."); + } for (int i = 0; i < file->service_count(); ++i) { PrintSourceService(&printer, file->service(i), &vars); |