make sure printers are properly flushed

pull/1772/head
Jan Tattermusch 10 years ago
parent 7fb570e2de
commit 5dcebd9015
  1. 23
      src/compiler/cpp_generator.cc
  2. 4
      src/compiler/csharp_generator.cc
  3. 6
      src/compiler/objective_c_generator.cc
  4. 5
      src/compiler/ruby_generator.cc

@ -86,6 +86,8 @@ grpc::string FilenameIdentifier(const grpc::string &filename) {
grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
grpc::protobuf::io::Printer printer(&output_stream, '$');
std::map<grpc::string, grpc::string> vars;
@ -102,7 +104,7 @@ grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file,
printer.Print(vars, "\n");
printer.Print(vars, "#include \"$filename_base$.pb.h\"\n");
printer.Print(vars, "\n");
}
return output;
}
@ -626,6 +628,8 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
grpc::string GetHeaderServices(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
grpc::protobuf::io::Printer printer(&output_stream, '$');
std::map<grpc::string, grpc::string> vars;
@ -643,13 +647,15 @@ grpc::string GetHeaderServices(const grpc::protobuf::FileDescriptor *file,
if (!params.services_namespace.empty()) {
printer.Print(vars, "} // namespace $services_namespace$\n\n");
}
}
return output;
}
grpc::string GetHeaderEpilogue(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
grpc::protobuf::io::Printer printer(&output_stream, '$');
std::map<grpc::string, grpc::string> vars;
@ -670,13 +676,15 @@ grpc::string GetHeaderEpilogue(const grpc::protobuf::FileDescriptor *file,
printer.Print(vars, "\n");
printer.Print(vars, "#endif // GRPC_$filename_identifier$__INCLUDED\n");
}
return output;
}
grpc::string GetSourcePrologue(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
grpc::protobuf::io::Printer printer(&output_stream, '$');
std::map<grpc::string, grpc::string> vars;
@ -690,13 +698,15 @@ grpc::string GetSourcePrologue(const grpc::protobuf::FileDescriptor *file,
printer.Print(vars, "#include \"$filename_base$.pb.h\"\n");
printer.Print(vars, "#include \"$filename_base$.grpc.pb.h\"\n");
printer.Print(vars, "\n");
}
return output;
}
grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
const Parameters &param) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
grpc::protobuf::io::Printer printer(&output_stream, '$');
std::map<grpc::string, grpc::string> vars;
@ -719,7 +729,7 @@ grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
}
printer.Print(vars, "\n");
}
return output;
}
@ -1077,6 +1087,8 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
grpc::string GetSourceServices(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
grpc::protobuf::io::Printer printer(&output_stream, '$');
std::map<grpc::string, grpc::string> vars;
@ -1098,6 +1110,7 @@ grpc::string GetSourceServices(const grpc::protobuf::FileDescriptor *file,
PrintSourceService(&printer, file->service(i), &vars);
printer.Print("\n");
}
}
return output;
}

@ -474,6 +474,9 @@ void GenerateService(Printer* out, const ServiceDescriptor *service) {
grpc::string GetServices(const FileDescriptor *file) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
StringOutputStream output_stream(&output);
Printer out(&output_stream, '$');
@ -503,6 +506,7 @@ grpc::string GetServices(const FileDescriptor *file) {
out.Outdent();
out.Print("}\n");
out.Print("#endregion\n");
}
return output;
}

@ -176,6 +176,8 @@ void PrintMethodImplementations(Printer *printer,
string GetHeader(const ServiceDescriptor *service, const string prefix) {
string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
Printer printer(&output_stream, '$');
@ -198,11 +200,14 @@ string GetHeader(const ServiceDescriptor *service, const string prefix) {
printer.Print("- (instancetype)initWithHost:(NSString *)host"
" NS_DESIGNATED_INITIALIZER;\n");
printer.Print("@end\n");
}
return output;
}
string GetSource(const ServiceDescriptor *service, const string prefix) {
string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
Printer printer(&output_stream, '$');
@ -235,6 +240,7 @@ string GetSource(const ServiceDescriptor *service, const string prefix) {
}
printer.Print("@end\n");
}
return output;
}

@ -119,6 +119,9 @@ void PrintService(const ServiceDescriptor *service, const grpc::string &package,
grpc::string GetServices(const FileDescriptor *file) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
StringOutputStream output_stream(&output);
Printer out(&output_stream, '$');
@ -161,7 +164,7 @@ grpc::string GetServices(const FileDescriptor *file) {
out.Outdent();
out.Print("end\n");
}
}
return output;
}

Loading…
Cancel
Save