aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Per Grön <peck@spotify.com>2017-05-11 08:06:46 +0200
committerGravatar Per Grön <peck@spotify.com>2017-05-11 08:06:46 +0200
commitc72b1a312ce90453b5189e6f1e6648eaecebffa0 (patch)
tree79fef068d16d34ab74fb88fb1c3326e8c9ad81f6
parent8aa652ff8321132c4b63719bb4e1982f7804248f (diff)
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.
-rw-r--r--src/compiler/config.h7
-rw-r--r--src/compiler/cpp_generator.cc13
2 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/config.h b/src/compiler/config.h
index ba44cd8a31..fbc3e8fd71 100644
--- a/src/compiler/config.h
+++ b/src/compiler/config.h
@@ -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
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index a1a0258c68..42d4c498e6 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -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,