aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/config.h4
-rw-r--r--src/compiler/cpp_generator.cc79
-rw-r--r--src/compiler/csharp_generator_helpers.h2
-rw-r--r--src/compiler/generator_helpers.h13
-rw-r--r--src/compiler/objective_c_generator.cc33
-rw-r--r--src/compiler/objective_c_plugin.cc28
-rw-r--r--src/compiler/python_generator.cc2
7 files changed, 83 insertions, 78 deletions
diff --git a/src/compiler/config.h b/src/compiler/config.h
index cd52aca57d..fea976c318 100644
--- a/src/compiler/config.h
+++ b/src/compiler/config.h
@@ -34,8 +34,8 @@
#ifndef SRC_COMPILER_CONFIG_H
#define SRC_COMPILER_CONFIG_H
-#include <grpc++/config.h>
-#include <grpc++/config_protobuf.h>
+#include <grpc++/support/config.h>
+#include <grpc++/support/config_protobuf.h>
#ifndef GRPC_CUSTOM_DESCRIPTOR
#include <google/protobuf/descriptor.h>
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index ea487bcd89..1bf2b16ed6 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -112,18 +112,18 @@ grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file,
grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) {
grpc::string temp =
- "#include <grpc++/impl/internal_stub.h>\n"
+ "#include <grpc++/support/async_stream.h>\n"
"#include <grpc++/impl/rpc_method.h>\n"
"#include <grpc++/impl/proto_utils.h>\n"
"#include <grpc++/impl/service_type.h>\n"
- "#include <grpc++/async_unary_call.h>\n"
- "#include <grpc++/status.h>\n"
- "#include <grpc++/stream.h>\n"
- "#include <grpc++/stub_options.h>\n"
+ "#include <grpc++/support/async_unary_call.h>\n"
+ "#include <grpc++/support/status.h>\n"
+ "#include <grpc++/support/stub_options.h>\n"
+ "#include <grpc++/support/sync_stream.h>\n"
"\n"
"namespace grpc {\n"
"class CompletionQueue;\n"
- "class ChannelInterface;\n"
+ "class Channel;\n"
"class RpcService;\n"
"class ServerCompletionQueue;\n"
"class ServerContext;\n"
@@ -554,17 +554,17 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
printer->Outdent();
printer->Print("};\n");
printer->Print(
- "class Stub GRPC_FINAL : public StubInterface,"
- " public ::grpc::InternalStub {\n public:\n");
+ "class Stub GRPC_FINAL : public StubInterface"
+ " {\n public:\n");
printer->Indent();
- printer->Print(
- "Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);\n");
+ printer->Print("Stub(const std::shared_ptr< ::grpc::Channel>& channel);\n");
for (int i = 0; i < service->method_count(); ++i) {
PrintHeaderClientMethod(printer, service->method(i), vars, true);
}
printer->Outdent();
printer->Print("\n private:\n");
printer->Indent();
+ printer->Print("std::shared_ptr< ::grpc::Channel> channel_;\n");
for (int i = 0; i < service->method_count(); ++i) {
PrintHeaderClientMethod(printer, service->method(i), vars, false);
}
@@ -575,7 +575,7 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
printer->Print("};\n");
printer->Print(
"static std::unique_ptr<Stub> NewStub(const std::shared_ptr< "
- "::grpc::ChannelInterface>& channel, "
+ "::grpc::Channel>& channel, "
"const ::grpc::StubOptions& options = ::grpc::StubOptions());\n");
printer->Print("\n");
@@ -702,12 +702,13 @@ grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
grpc::protobuf::io::Printer printer(&output_stream, '$');
std::map<grpc::string, grpc::string> vars;
- printer.Print(vars, "#include <grpc++/async_unary_call.h>\n");
- printer.Print(vars, "#include <grpc++/channel_interface.h>\n");
+ printer.Print(vars, "#include <grpc++/channel.h>\n");
printer.Print(vars, "#include <grpc++/impl/client_unary_call.h>\n");
printer.Print(vars, "#include <grpc++/impl/rpc_service_method.h>\n");
printer.Print(vars, "#include <grpc++/impl/service_type.h>\n");
- printer.Print(vars, "#include <grpc++/stream.h>\n");
+ printer.Print(vars, "#include <grpc++/support/async_unary_call.h>\n");
+ printer.Print(vars, "#include <grpc++/support/async_stream.h>\n");
+ printer.Print(vars, "#include <grpc++/support/sync_stream.h>\n");
if (!file->package().empty()) {
std::vector<grpc::string> parts =
@@ -738,7 +739,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::ClientContext* context, "
"const $Request$& request, $Response$* response) {\n");
printer->Print(*vars,
- " return ::grpc::BlockingUnaryCall(channel(), "
+ " return ::grpc::BlockingUnaryCall(channel_.get(), "
"rpcmethod_$Method$_, "
"context, request, response);\n"
"}\n\n");
@@ -751,7 +752,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
printer->Print(*vars,
" return new "
"::grpc::ClientAsyncResponseReader< $Response$>("
- "channel(), cq, "
+ "channel_.get(), cq, "
"rpcmethod_$Method$_, "
"context, request);\n"
"}\n\n");
@@ -762,7 +763,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::ClientContext* context, $Response$* response) {\n");
printer->Print(*vars,
" return new ::grpc::ClientWriter< $Request$>("
- "channel(), "
+ "channel_.get(), "
"rpcmethod_$Method$_, "
"context, response);\n"
"}\n\n");
@@ -773,7 +774,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::CompletionQueue* cq, void* tag) {\n");
printer->Print(*vars,
" return new ::grpc::ClientAsyncWriter< $Request$>("
- "channel(), cq, "
+ "channel_.get(), cq, "
"rpcmethod_$Method$_, "
"context, response, tag);\n"
"}\n\n");
@@ -785,7 +786,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::ClientContext* context, const $Request$& request) {\n");
printer->Print(*vars,
" return new ::grpc::ClientReader< $Response$>("
- "channel(), "
+ "channel_.get(), "
"rpcmethod_$Method$_, "
"context, request);\n"
"}\n\n");
@@ -796,7 +797,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::CompletionQueue* cq, void* tag) {\n");
printer->Print(*vars,
" return new ::grpc::ClientAsyncReader< $Response$>("
- "channel(), cq, "
+ "channel_.get(), cq, "
"rpcmethod_$Method$_, "
"context, request, tag);\n"
"}\n\n");
@@ -808,7 +809,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
printer->Print(*vars,
" return new ::grpc::ClientReaderWriter< "
"$Request$, $Response$>("
- "channel(), "
+ "channel_.get(), "
"rpcmethod_$Method$_, "
"context);\n"
"}\n\n");
@@ -820,7 +821,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
printer->Print(*vars,
" return new "
"::grpc::ClientAsyncReaderWriter< $Request$, $Response$>("
- "channel(), cq, "
+ "channel_.get(), cq, "
"rpcmethod_$Method$_, "
"context, tag);\n"
"}\n\n");
@@ -964,20 +965,19 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
}
printer->Print(*vars, "};\n\n");
- printer->Print(
- *vars,
- "std::unique_ptr< $ns$$Service$::Stub> $ns$$Service$::NewStub("
- "const std::shared_ptr< ::grpc::ChannelInterface>& channel, "
- "const ::grpc::StubOptions& options) {\n"
- " std::unique_ptr< $ns$$Service$::Stub> stub(new "
- "$ns$$Service$::Stub(channel));\n"
- " return stub;\n"
- "}\n\n");
+ printer->Print(*vars,
+ "std::unique_ptr< $ns$$Service$::Stub> $ns$$Service$::NewStub("
+ "const std::shared_ptr< ::grpc::Channel>& channel, "
+ "const ::grpc::StubOptions& options) {\n"
+ " std::unique_ptr< $ns$$Service$::Stub> stub(new "
+ "$ns$$Service$::Stub(channel));\n"
+ " return stub;\n"
+ "}\n\n");
printer->Print(*vars,
"$ns$$Service$::Stub::Stub(const std::shared_ptr< "
- "::grpc::ChannelInterface>& channel)\n");
+ "::grpc::Channel>& channel)\n");
printer->Indent();
- printer->Print(": ::grpc::InternalStub(channel)");
+ printer->Print(": channel_(channel)");
for (int i = 0; i < service->method_count(); ++i) {
const grpc::protobuf::MethodDescriptor *method = service->method(i);
(*vars)["Method"] = method->name();
@@ -991,13 +991,12 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
} else {
(*vars)["StreamingType"] = "BIDI_STREAMING";
}
- printer->Print(
- *vars,
- ", rpcmethod_$Method$_("
- "$prefix$$Service$_method_names[$Idx$], "
- "::grpc::RpcMethod::$StreamingType$, "
- "channel->RegisterMethod($prefix$$Service$_method_names[$Idx$])"
- ")\n");
+ printer->Print(*vars,
+ ", rpcmethod_$Method$_("
+ "$prefix$$Service$_method_names[$Idx$], "
+ "::grpc::RpcMethod::$StreamingType$, "
+ "channel"
+ ")\n");
}
printer->Print("{}\n\n");
printer->Outdent();
diff --git a/src/compiler/csharp_generator_helpers.h b/src/compiler/csharp_generator_helpers.h
index 1370627633..5639ea058b 100644
--- a/src/compiler/csharp_generator_helpers.h
+++ b/src/compiler/csharp_generator_helpers.h
@@ -41,7 +41,7 @@ namespace grpc_csharp_generator {
inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
grpc::string *file_name_or_error) {
- *file_name_or_error = grpc_generator::FileNameInUpperCamel(file) + "Grpc.cs";
+ *file_name_or_error = grpc_generator::FileNameInUpperCamel(file, false) + "Grpc.cs";
return true;
}
diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h
index 68b807b057..e1bb66a875 100644
--- a/src/compiler/generator_helpers.h
+++ b/src/compiler/generator_helpers.h
@@ -125,16 +125,23 @@ inline grpc::string LowerUnderscoreToUpperCamel(grpc::string str) {
return result;
}
-inline grpc::string FileNameInUpperCamel(const grpc::protobuf::FileDescriptor *file) {
+inline grpc::string FileNameInUpperCamel(const grpc::protobuf::FileDescriptor *file,
+ bool include_package_path) {
std::vector<grpc::string> tokens = tokenize(StripProto(file->name()), "/");
grpc::string result = "";
- for (unsigned int i = 0; i < tokens.size() - 1; i++) {
- result += tokens[i] + "/";
+ if (include_package_path) {
+ for (unsigned int i = 0; i < tokens.size() - 1; i++) {
+ result += tokens[i] + "/";
+ }
}
result += LowerUnderscoreToUpperCamel(tokens.back());
return result;
}
+inline grpc::string FileNameInUpperCamel(const grpc::protobuf::FileDescriptor *file) {
+ return FileNameInUpperCamel(file, true);
+}
+
enum MethodType {
METHODTYPE_NO_STREAMING,
METHODTYPE_CLIENT_STREAMING,
diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc
index 483c6573a8..a3157db0fb 100644
--- a/src/compiler/objective_c_generator.cc
+++ b/src/compiler/objective_c_generator.cc
@@ -44,7 +44,6 @@ using ::google::protobuf::compiler::objectivec::ClassName;
using ::grpc::protobuf::io::Printer;
using ::grpc::protobuf::MethodDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
-using ::grpc::string;
using ::std::map;
namespace grpc_objective_c_generator {
@@ -52,7 +51,7 @@ namespace {
void PrintProtoRpcDeclarationAsPragma(Printer *printer,
const MethodDescriptor *method,
- map<string, string> vars) {
+ map< ::grpc::string, ::grpc::string> vars) {
vars["client_stream"] = method->client_streaming() ? "stream " : "";
vars["server_stream"] = method->server_streaming() ? "stream " : "";
@@ -62,7 +61,7 @@ void PrintProtoRpcDeclarationAsPragma(Printer *printer,
}
void PrintMethodSignature(Printer *printer, const MethodDescriptor *method,
- const map<string, string> &vars) {
+ const map< ::grpc::string, ::grpc::string> &vars) {
// TODO(jcanizales): Print method comments.
printer->Print(vars, "- ($return_type$)$method_name$With");
@@ -85,7 +84,7 @@ void PrintMethodSignature(Printer *printer, const MethodDescriptor *method,
}
void PrintSimpleSignature(Printer *printer, const MethodDescriptor *method,
- map<string, string> vars) {
+ map< ::grpc::string, ::grpc::string> vars) {
vars["method_name"] =
grpc_generator::LowercaseFirstLetter(vars["method_name"]);
vars["return_type"] = "void";
@@ -93,14 +92,14 @@ void PrintSimpleSignature(Printer *printer, const MethodDescriptor *method,
}
void PrintAdvancedSignature(Printer *printer, const MethodDescriptor *method,
- map<string, string> vars) {
+ map< ::grpc::string, ::grpc::string> vars) {
vars["method_name"] = "RPCTo" + vars["method_name"];
vars["return_type"] = "ProtoRPC *";
PrintMethodSignature(printer, method, vars);
}
-inline map<string, string> GetMethodVars(const MethodDescriptor *method) {
- map<string, string> res;
+inline map< ::grpc::string, ::grpc::string> GetMethodVars(const MethodDescriptor *method) {
+ map< ::grpc::string, ::grpc::string> res;
res["method_name"] = method->name();
res["request_type"] = method->input_type()->name();
res["response_type"] = method->output_type()->name();
@@ -110,7 +109,7 @@ inline map<string, string> GetMethodVars(const MethodDescriptor *method) {
}
void PrintMethodDeclarations(Printer *printer, const MethodDescriptor *method) {
- map<string, string> vars = GetMethodVars(method);
+ map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method);
PrintProtoRpcDeclarationAsPragma(printer, method, vars);
@@ -121,7 +120,7 @@ void PrintMethodDeclarations(Printer *printer, const MethodDescriptor *method) {
}
void PrintSimpleImplementation(Printer *printer, const MethodDescriptor *method,
- map<string, string> vars) {
+ map< ::grpc::string, ::grpc::string> vars) {
printer->Print("{\n");
printer->Print(vars, " [[self RPCTo$method_name$With");
if (method->client_streaming()) {
@@ -139,7 +138,7 @@ void PrintSimpleImplementation(Printer *printer, const MethodDescriptor *method,
void PrintAdvancedImplementation(Printer *printer,
const MethodDescriptor *method,
- map<string, string> vars) {
+ map< ::grpc::string, ::grpc::string> vars) {
printer->Print("{\n");
printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n");
@@ -164,7 +163,7 @@ void PrintAdvancedImplementation(Printer *printer,
void PrintMethodImplementations(Printer *printer,
const MethodDescriptor *method) {
- map<string, string> vars = GetMethodVars(method);
+ map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method);
PrintProtoRpcDeclarationAsPragma(printer, method, vars);
@@ -179,14 +178,14 @@ void PrintMethodImplementations(Printer *printer,
} // namespace
-string GetHeader(const ServiceDescriptor *service) {
- string output;
+::grpc::string GetHeader(const ServiceDescriptor *service) {
+ ::grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
Printer printer(&output_stream, '$');
- map<string, string> vars = {{"service_class", ServiceClassName(service)}};
+ map< ::grpc::string, ::grpc::string> vars = {{"service_class", ServiceClassName(service)}};
printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n");
@@ -209,14 +208,14 @@ string GetHeader(const ServiceDescriptor *service) {
return output;
}
-string GetSource(const ServiceDescriptor *service) {
- string output;
+::grpc::string GetSource(const ServiceDescriptor *service) {
+ ::grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
Printer printer(&output_stream, '$');
- map<string, string> vars = {{"service_name", service->name()},
+ map< ::grpc::string,::grpc::string> vars = {{"service_name", service->name()},
{"service_class", ServiceClassName(service)},
{"package", service->file()->package()}};
diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc
index 10f06ad4df..17440358bb 100644
--- a/src/compiler/objective_c_plugin.cc
+++ b/src/compiler/objective_c_plugin.cc
@@ -39,44 +39,43 @@
#include "src/compiler/objective_c_generator.h"
#include "src/compiler/objective_c_generator_helpers.h"
-using ::grpc::string;
-
class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
public:
ObjectiveCGrpcGenerator() {}
virtual ~ObjectiveCGrpcGenerator() {}
virtual bool Generate(const grpc::protobuf::FileDescriptor *file,
- const string &parameter,
+ const ::grpc::string &parameter,
grpc::protobuf::compiler::GeneratorContext *context,
- string *error) const {
+ ::grpc::string *error) const {
if (file->service_count() == 0) {
// No services. Do nothing.
return true;
}
- string file_name = grpc_generator::FileNameInUpperCamel(file);
- string prefix = file->options().objc_class_prefix();
+ ::grpc::string file_name = grpc_generator::FileNameInUpperCamel(file);
+ ::grpc::string prefix = file->options().objc_class_prefix();
{
// Generate .pbrpc.h
- string imports = string("#import \"") + file_name + ".pbobjc.h\"\n\n"
+ ::grpc::string imports = ::grpc::string("#import \"") + file_name +
+ ".pbobjc.h\"\n\n"
"#import <ProtoRPC/ProtoService.h>\n"
"#import <RxLibrary/GRXWriteable.h>\n"
"#import <RxLibrary/GRXWriter.h>\n";
// TODO(jcanizales): Instead forward-declare the input and output types
// and import the files in the .pbrpc.m
- string proto_imports;
+ ::grpc::string proto_imports;
for (int i = 0; i < file->dependency_count(); i++) {
- string header = grpc_objective_c_generator::MessageHeaderName(
+ ::grpc::string header = grpc_objective_c_generator::MessageHeaderName(
file->dependency(i));
- proto_imports += string("#import \"") + header + "\"\n";
+ proto_imports += ::grpc::string("#import \"") + header + "\"\n";
}
- string declarations;
+ ::grpc::string declarations;
for (int i = 0; i < file->service_count(); i++) {
const grpc::protobuf::ServiceDescriptor *service = file->service(i);
declarations += grpc_objective_c_generator::GetHeader(service);
@@ -89,11 +88,12 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
{
// Generate .pbrpc.m
- string imports = string("#import \"") + file_name + ".pbrpc.h\"\n\n"
+ ::grpc::string imports = ::grpc::string("#import \"") + file_name +
+ ".pbrpc.h\"\n\n"
"#import <ProtoRPC/ProtoRPC.h>\n"
"#import <RxLibrary/GRXWriter+Immediate.h>\n";
- string definitions;
+ ::grpc::string definitions;
for (int i = 0; i < file->service_count(); i++) {
const grpc::protobuf::ServiceDescriptor *service = file->service(i);
definitions += grpc_objective_c_generator::GetSource(service);
@@ -108,7 +108,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
private:
// Write the given code into the given file.
void Write(grpc::protobuf::compiler::GeneratorContext *context,
- const string &filename, const string &code) const {
+ const ::grpc::string &filename, const ::grpc::string &code) const {
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output(
context->Open(filename));
grpc::protobuf::io::CodedOutputStream coded_out(output.get());
diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc
index 2982a89fad..72c457ac6b 100644
--- a/src/compiler/python_generator.cc
+++ b/src/compiler/python_generator.cc
@@ -42,7 +42,7 @@
#include <tuple>
#include <vector>
-#include <grpc++/config.h>
+#include <grpc++/support/config.h>
#include "src/compiler/config.h"
#include "src/compiler/generator_helpers.h"
#include "src/compiler/python_generator.h"