Merge pull request #1257 from yang-g/codegennamespace

When the proto file does not contain a package, do not generate namespac...
pull/1264/head
Nicolas Noble 10 years ago
commit 05f2d9f826
  1. 13
      src/compiler/cpp_generator.cc

@ -198,6 +198,7 @@ grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
temp.append("\n");
if (!file->package().empty()) {
std::vector<grpc::string> parts =
grpc_generator::tokenize(file->package(), ".");
@ -206,8 +207,8 @@ grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
temp.append(*part);
temp.append(" {\n");
}
temp.append("\n");
}
return temp;
}
@ -431,6 +432,7 @@ grpc::string GetHeaderEpilogue(const grpc::protobuf::FileDescriptor *file,
vars["filename"] = file->name();
vars["filename_identifier"] = FilenameIdentifier(file->name());
if (!file->package().empty()) {
std::vector<grpc::string> parts =
grpc_generator::tokenize(file->package(), ".");
@ -438,8 +440,10 @@ grpc::string GetHeaderEpilogue(const grpc::protobuf::FileDescriptor *file,
vars["part"] = *part;
printer.Print(vars, "} // namespace $part$\n");
}
printer.Print(vars, "\n");
}
printer.Print(vars, "\n\n");
printer.Print(vars, "\n");
printer.Print(vars, "#endif // GRPC_$filename_identifier$__INCLUDED\n");
return output;
@ -480,6 +484,7 @@ grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
printer.Print(vars, "#include <grpc++/impl/service_type.h>\n");
printer.Print(vars, "#include <grpc++/stream.h>\n");
if (!file->package().empty()) {
std::vector<grpc::string> parts =
grpc_generator::tokenize(file->package(), ".");
@ -487,6 +492,7 @@ grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
vars["part"] = *part;
printer.Print(vars, "namespace $part$ {\n");
}
}
printer.Print(vars, "\n");
@ -860,6 +866,7 @@ grpc::string GetSourceEpilogue(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) {
grpc::string temp;
if (!file->package().empty()) {
std::vector<grpc::string> parts =
grpc_generator::tokenize(file->package(), ".");
@ -868,8 +875,8 @@ grpc::string GetSourceEpilogue(const grpc::protobuf::FileDescriptor *file,
temp.append(*part);
temp.append("\n");
}
temp.append("\n");
}
return temp;
}

Loading…
Cancel
Save