Merge pull request #6238 from gwvo/master
Some additional fixes to make the C++ codegen not depend on protobuf.
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index b133699..9319c41 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -86,7 +86,7 @@
}
}
-grpc::string GetHeaderPrologue(File *file, const Parameters ¶ms) {
+grpc::string GetHeaderPrologue(File *file, const Parameters & /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -96,6 +96,7 @@
vars["filename"] = file->filename();
vars["filename_identifier"] = FilenameIdentifier(file->filename());
vars["filename_base"] = file->filename_without_ext();
+ vars["message_header_ext"] = file->message_header_ext();
printer->Print(vars, "// Generated by the gRPC protobuf plugin.\n");
printer->Print(vars,
@@ -104,7 +105,7 @@
printer->Print(vars, "#ifndef GRPC_$filename_identifier$__INCLUDED\n");
printer->Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n");
printer->Print(vars, "\n");
- printer->Print(vars, "#include \"$filename_base$.pb.h\"\n");
+ printer->Print(vars, "#include \"$filename_base$$message_header_ext$\"\n");
printer->Print(vars, "\n");
}
return output;
@@ -794,8 +795,7 @@
return output;
}
-grpc::string GetHeaderEpilogue(File *file,
- const Parameters ¶ms) {
+grpc::string GetHeaderEpilogue(File *file, const Parameters & /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -821,8 +821,7 @@
return output;
}
-grpc::string GetSourcePrologue(File *file,
- const Parameters ¶ms) {
+grpc::string GetSourcePrologue(File *file, const Parameters & /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -831,13 +830,16 @@
vars["filename"] = file->filename();
vars["filename_base"] = file->filename_without_ext();
+ vars["message_header_ext"] = file->message_header_ext();
+ vars["service_header_ext"] = file->service_header_ext();
printer->Print(vars, "// Generated by the gRPC protobuf plugin.\n");
printer->Print(vars,
"// If you make any local change, they will be lost.\n");
printer->Print(vars, "// source: $filename$\n\n");
- printer->Print(vars, "#include \"$filename_base$.pb.h\"\n");
- printer->Print(vars, "#include \"$filename_base$.grpc.pb.h\"\n");
+ printer->Print(vars, "#include \"$filename_base$$message_header_ext$\"\n");
+ printer->Print(vars, "#include \"$filename_base$$service_header_ext$\"\n");
+ printer->Print(vars, file->additional_headers().c_str());
printer->Print(vars, "\n");
}
return output;
@@ -1180,8 +1182,7 @@
return output;
}
-grpc::string GetSourceEpilogue(File *file,
- const Parameters ¶ms) {
+grpc::string GetSourceEpilogue(File *file, const Parameters & /*params*/) {
grpc::string temp;
if (!file->package().empty()) {
diff --git a/src/compiler/cpp_generator.h b/src/compiler/cpp_generator.h
index 99a60a2..953ddfd 100644
--- a/src/compiler/cpp_generator.h
+++ b/src/compiler/cpp_generator.h
@@ -106,8 +106,11 @@
virtual grpc::string filename() const = 0;
virtual grpc::string filename_without_ext() const = 0;
+ virtual grpc::string message_header_ext() const = 0;
+ virtual grpc::string service_header_ext() const = 0;
virtual grpc::string package() const = 0;
virtual std::vector<grpc::string> package_parts() const = 0;
+ virtual grpc::string additional_headers() const = 0;
virtual int service_count() const = 0;
virtual std::unique_ptr<const Service> service(int i) const = 0;
diff --git a/src/compiler/cpp_plugin.cc b/src/compiler/cpp_plugin.cc
index f703c64..e321c64 100644
--- a/src/compiler/cpp_plugin.cc
+++ b/src/compiler/cpp_plugin.cc
@@ -120,11 +120,16 @@
return grpc_generator::StripProto(filename());
}
+ grpc::string message_header_ext() const { return ".pb.h"; }
+ grpc::string service_header_ext() const { return ".grpc.pb.h"; }
+
grpc::string package() const { return file_->package(); }
std::vector<grpc::string> package_parts() const {
return grpc_generator::tokenize(package(), ".");
}
+ grpc::string additional_headers() const { return ""; }
+
int service_count() const { return file_->service_count(); };
std::unique_ptr<const grpc_cpp_generator::Service> service(int i) const {
return std::unique_ptr<const grpc_cpp_generator::Service> (