Don't hard code protobuf specific file extensions in cpp_generator.cc

This file is shared with the Flatbuffers project as well, which does not
use "pb" file extensions.
pull/11080/head
Per Grön 8 years ago
parent 8aa652ff83
commit c72b1a312c
  1. 7
      src/compiler/config.h
  2. 13
      src/compiler/cpp_generator.cc

@ -96,4 +96,11 @@ typedef GRPC_CUSTOM_STRINGOUTPUTSTREAM StringOutputStream;
} // namespace protobuf
} // namespace grpc
namespace grpc_cpp_generator {
static const char * const kCppGeneratorMessageHeaderExt = ".pb.h";
static const char * const kCppGeneratorServiceHeaderExt = ".grpc.pb.h";
} // namespace grpc_cpp_generator
#endif // SRC_COMPILER_CONFIG_H

@ -40,9 +40,6 @@
namespace grpc_cpp_generator {
namespace {
grpc::string message_header_ext() { return ".pb.h"; }
grpc::string service_header_ext() { return ".grpc.pb.h"; }
template <class T>
grpc::string as_string(T x) {
std::ostringstream out;
@ -113,7 +110,7 @@ grpc::string GetHeaderPrologue(grpc_generator::File *file,
vars["filename"] = file->filename();
vars["filename_identifier"] = FilenameIdentifier(file->filename());
vars["filename_base"] = file->filename_without_ext();
vars["message_header_ext"] = message_header_ext();
vars["message_header_ext"] = kCppGeneratorMessageHeaderExt;
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
printer->Print(vars,
@ -1039,8 +1036,8 @@ grpc::string GetSourcePrologue(grpc_generator::File *file,
vars["filename"] = file->filename();
vars["filename_base"] = file->filename_without_ext();
vars["message_header_ext"] = message_header_ext();
vars["service_header_ext"] = service_header_ext();
vars["message_header_ext"] = kCppGeneratorMessageHeaderExt;
vars["service_header_ext"] = kCppGeneratorServiceHeaderExt;
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
printer->Print(vars,
@ -1425,8 +1422,8 @@ grpc::string GetMockPrologue(grpc_generator::File *file,
vars["filename"] = file->filename();
vars["filename_base"] = file->filename_without_ext();
vars["message_header_ext"] = message_header_ext();
vars["service_header_ext"] = service_header_ext();
vars["message_header_ext"] = kCppGeneratorMessageHeaderExt;
vars["service_header_ext"] = kCppGeneratorServiceHeaderExt;
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
printer->Print(vars,

Loading…
Cancel
Save