Some additional fixes to make the C++ codegen not depend on protobuf.

pull/6238/head
Wouter van Oortmerssen 9 years ago
parent 241dea56c8
commit b695b9b035
  1. 21
      src/compiler/cpp_generator.cc
  2. 3
      src/compiler/cpp_generator.h
  3. 5
      src/compiler/cpp_plugin.cc

@ -86,7 +86,7 @@ void PrintIncludes(Printer *printer, const std::vector<grpc::string>& headers, c
}
}
grpc::string GetHeaderPrologue(File *file, const Parameters &params) {
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 @@ grpc::string GetHeaderPrologue(File *file, const Parameters &params) {
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 @@ grpc::string GetHeaderPrologue(File *file, const Parameters &params) {
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 @@ grpc::string GetHeaderServices(File *file,
return output;
}
grpc::string GetHeaderEpilogue(File *file,
const Parameters &params) {
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 @@ grpc::string GetHeaderEpilogue(File *file,
return output;
}
grpc::string GetSourcePrologue(File *file,
const Parameters &params) {
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 @@ grpc::string GetSourcePrologue(File *file,
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 @@ grpc::string GetSourceServices(File *file,
return output;
}
grpc::string GetSourceEpilogue(File *file,
const Parameters &params) {
grpc::string GetSourceEpilogue(File *file, const Parameters & /*params*/) {
grpc::string temp;
if (!file->package().empty()) {

@ -106,8 +106,11 @@ struct File {
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;

@ -120,11 +120,16 @@ class ProtoBufFile : public grpc_cpp_generator::File {
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> (

Loading…
Cancel
Save