aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler
diff options
context:
space:
mode:
authorGravatar Garret Kelly <gdk@google.com>2017-10-10 15:58:41 -0400
committerGravatar Garret Kelly <gdk@google.com>2017-11-06 16:45:13 -0500
commitcf5a1f2c8162fbfefc0f4aa5d28e6a17d50a840f (patch)
tree18453d288ea86769cc138c6ee096d3c62154698b /src/compiler
parent0f2cfdcc0f57d21fe2823268263ef5bdc4b6704c (diff)
Do not interpolate variables in leading comments.
There is at least one well-known proto file (plugin.proto) with comments that include variable-like strings that are not actual variables. This leads to DFATAL log statements that clutter the output and don't provide any benefit.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/cpp_generator.cc2
-rw-r--r--src/compiler/csharp_generator.cc2
-rw-r--r--src/compiler/node_generator.cc2
-rw-r--r--src/compiler/objective_c_generator.cc2
-rw-r--r--src/compiler/php_generator.cc2
-rw-r--r--src/compiler/protobuf_plugin.h1
-rw-r--r--src/compiler/python_generator.cc2
-rw-r--r--src/compiler/ruby_generator.cc2
-rw-r--r--src/compiler/schema_interface.h1
9 files changed, 9 insertions, 7 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 3adf0fa451..dec8cd0f25 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -104,7 +104,7 @@ grpc::string GetHeaderPrologue(grpc_generator::File* file,
grpc::string leading_comments = file->GetLeadingComments("//");
if (!leading_comments.empty()) {
printer->Print(vars, "// Original file comments:\n");
- printer->Print(leading_comments.c_str());
+ printer->PrintRaw(leading_comments.c_str());
}
printer->Print(vars, "#ifndef GRPC_$filename_identifier$__INCLUDED\n");
printer->Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n");
diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc
index e0957bf9bb..40fe0b054a 100644
--- a/src/compiler/csharp_generator.cc
+++ b/src/compiler/csharp_generator.cc
@@ -666,7 +666,7 @@ grpc::string GetServices(const FileDescriptor* file, bool generate_client,
grpc::string leading_comments = GetCsharpComments(file, true);
if (!leading_comments.empty()) {
out.Print("// Original file comments:\n");
- out.Print(leading_comments.c_str());
+ out.PrintRaw(leading_comments.c_str());
}
out.Print("#pragma warning disable 1591\n");
diff --git a/src/compiler/node_generator.cc b/src/compiler/node_generator.cc
index ed835b4445..661587cbd6 100644
--- a/src/compiler/node_generator.cc
+++ b/src/compiler/node_generator.cc
@@ -250,7 +250,7 @@ grpc::string GenerateFile(const FileDescriptor* file) {
grpc::string leading_comments = GetNodeComments(file, true);
if (!leading_comments.empty()) {
out.Print("// Original file comments:\n");
- out.Print(leading_comments.c_str());
+ out.PrintRaw(leading_comments.c_str());
}
out.Print("'use strict';\n");
diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc
index 349f1dc281..8fe30e97e9 100644
--- a/src/compiler/objective_c_generator.cc
+++ b/src/compiler/objective_c_generator.cc
@@ -65,7 +65,7 @@ static void PrintAllComments(const DescriptorType* desc, Printer* printer) {
printer->Print(" * ");
size_t start_pos = it->find_first_not_of(' ');
if (start_pos != grpc::string::npos) {
- printer->Print(it->c_str() + start_pos);
+ printer->PrintRaw(it->c_str() + start_pos);
}
printer->Print("\n");
}
diff --git a/src/compiler/php_generator.cc b/src/compiler/php_generator.cc
index 1ff9520d7f..d9705e8077 100644
--- a/src/compiler/php_generator.cc
+++ b/src/compiler/php_generator.cc
@@ -164,7 +164,7 @@ grpc::string GenerateFile(const FileDescriptor* file,
grpc::string leading_comments = GetPHPComments(file, "//");
if (!leading_comments.empty()) {
out.Print("// Original file comments:\n");
- out.Print(leading_comments.c_str());
+ out.PrintRaw(leading_comments.c_str());
}
map<grpc::string, grpc::string> vars;
diff --git a/src/compiler/protobuf_plugin.h b/src/compiler/protobuf_plugin.h
index 1551908156..b971af1310 100644
--- a/src/compiler/protobuf_plugin.h
+++ b/src/compiler/protobuf_plugin.h
@@ -141,6 +141,7 @@ class ProtoBufPrinter : public grpc_generator::Printer {
}
void Print(const char* string) { printer_.Print(string); }
+ void PrintRaw(const char* string) { printer_.PrintRaw(string); }
void Indent() { printer_.Indent(); }
void Outdent() { printer_.Outdent(); }
diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc
index c1ae7d31ad..8a0b889454 100644
--- a/src/compiler/python_generator.cc
+++ b/src/compiler/python_generator.cc
@@ -101,7 +101,7 @@ void PrivateGenerator::PrintAllComments(StringVector comments,
++it) {
size_t start_pos = it->find_first_not_of(' ');
if (start_pos != grpc::string::npos) {
- out->Print(it->c_str() + start_pos);
+ out->PrintRaw(it->c_str() + start_pos);
}
out->Print("\n");
}
diff --git a/src/compiler/ruby_generator.cc b/src/compiler/ruby_generator.cc
index ed7e074b47..e81dea603b 100644
--- a/src/compiler/ruby_generator.cc
+++ b/src/compiler/ruby_generator.cc
@@ -174,7 +174,7 @@ grpc::string GetServices(const FileDescriptor* file) {
grpc::string leading_comments = GetRubyComments(file, true);
if (!leading_comments.empty()) {
out.Print("# Original file comments:\n");
- out.Print(leading_comments.c_str());
+ out.PrintRaw(leading_comments.c_str());
}
out.Print("\n");
diff --git a/src/compiler/schema_interface.h b/src/compiler/schema_interface.h
index b2021f2926..c000478e68 100644
--- a/src/compiler/schema_interface.h
+++ b/src/compiler/schema_interface.h
@@ -86,6 +86,7 @@ struct Printer {
virtual void Print(const std::map<grpc::string, grpc::string>& vars,
const char* template_string) = 0;
virtual void Print(const char* string) = 0;
+ virtual void PrintRaw(const char* string) = 0;
virtual void Indent() = 0;
virtual void Outdent() = 0;
};