aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/cpp_generator.cc149
-rw-r--r--src/compiler/cpp_generator.h64
-rw-r--r--src/compiler/cpp_generator_helpers.h12
-rw-r--r--src/compiler/cpp_plugin.cc16
-rw-r--r--src/compiler/csharp_generator.cc85
-rw-r--r--src/compiler/csharp_generator.h2
-rw-r--r--src/compiler/csharp_generator_helpers.h6
-rw-r--r--src/compiler/csharp_plugin.cc10
-rw-r--r--src/compiler/generator_helpers.h44
-rw-r--r--src/compiler/node_generator.cc56
-rw-r--r--src/compiler/node_generator.h2
-rw-r--r--src/compiler/node_plugin.cc10
-rw-r--r--src/compiler/objective_c_generator.cc36
-rw-r--r--src/compiler/objective_c_generator.h8
-rw-r--r--src/compiler/objective_c_generator_helpers.h8
-rw-r--r--src/compiler/objective_c_plugin.cc30
-rw-r--r--src/compiler/php_generator.cc30
-rw-r--r--src/compiler/php_generator.h6
-rw-r--r--src/compiler/php_generator_helpers.h16
-rw-r--r--src/compiler/php_plugin.cc12
-rw-r--r--src/compiler/protobuf_plugin.h30
-rw-r--r--src/compiler/python_generator.cc2
-rw-r--r--src/compiler/python_generator_helpers.h6
-rw-r--r--src/compiler/ruby_generator.cc34
-rw-r--r--src/compiler/ruby_generator.h2
-rw-r--r--src/compiler/ruby_generator_helpers-inl.h8
-rw-r--r--src/compiler/ruby_generator_map-inl.h2
-rw-r--r--src/compiler/ruby_generator_string-inl.h22
-rw-r--r--src/compiler/ruby_plugin.cc10
-rw-r--r--src/compiler/schema_interface.h12
30 files changed, 370 insertions, 360 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 253280bd24..3adf0fa451 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -32,15 +32,15 @@ grpc::string as_string(T x) {
return out.str();
}
-inline bool ClientOnlyStreaming(const grpc_generator::Method *method) {
+inline bool ClientOnlyStreaming(const grpc_generator::Method* method) {
return method->ClientStreaming() && !method->ServerStreaming();
}
-inline bool ServerOnlyStreaming(const grpc_generator::Method *method) {
+inline bool ServerOnlyStreaming(const grpc_generator::Method* method) {
return !method->ClientStreaming() && method->ServerStreaming();
}
-grpc::string FilenameIdentifier(const grpc::string &filename) {
+grpc::string FilenameIdentifier(const grpc::string& filename) {
grpc::string result;
for (unsigned i = 0; i < filename.size(); i++) {
char c = filename[i];
@@ -58,19 +58,19 @@ grpc::string FilenameIdentifier(const grpc::string &filename) {
} // namespace
template <class T, size_t N>
-T *array_end(T (&array)[N]) {
+T* array_end(T (&array)[N]) {
return array + N;
}
-void PrintIncludes(grpc_generator::Printer *printer,
- const std::vector<grpc::string> &headers,
- const Parameters &params) {
+void PrintIncludes(grpc_generator::Printer* printer,
+ const std::vector<grpc::string>& headers,
+ const Parameters& params) {
std::map<grpc::string, grpc::string> vars;
vars["l"] = params.use_system_headers ? '<' : '"';
vars["r"] = params.use_system_headers ? '>' : '"';
- auto &s = params.grpc_search_path;
+ auto& s = params.grpc_search_path;
if (!s.empty()) {
vars["l"] += s;
if (s[s.size() - 1] != '/') {
@@ -84,8 +84,8 @@ void PrintIncludes(grpc_generator::Printer *printer,
}
}
-grpc::string GetHeaderPrologue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetHeaderPrologue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -116,15 +116,15 @@ grpc::string GetHeaderPrologue(grpc_generator::File *file,
return output;
}
-grpc::string GetHeaderIncludes(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetHeaderIncludes(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
- static const char *headers_strs[] = {
+ static const char* headers_strs[] = {
"grpc++/impl/codegen/async_stream.h",
"grpc++/impl/codegen/async_unary_call.h",
"grpc++/impl/codegen/method_handler_impl.h",
@@ -158,8 +158,8 @@ grpc::string GetHeaderIncludes(grpc_generator::File *file,
}
void PrintHeaderClientMethodInterfaces(
- grpc_generator::Printer *printer, const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars, bool is_public) {
+ grpc_generator::Printer* printer, const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars, bool is_public) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -355,9 +355,9 @@ void PrintHeaderClientMethodInterfaces(
}
}
-void PrintHeaderClientMethod(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars,
+void PrintHeaderClientMethod(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars,
bool is_public) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
@@ -542,17 +542,17 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer,
}
}
-void PrintHeaderClientMethodData(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintHeaderClientMethodData(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
printer->Print(*vars,
"const ::grpc::internal::RpcMethod rpcmethod_$Method$_;\n");
}
-void PrintHeaderServerMethodSync(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintHeaderServerMethodSync(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -584,9 +584,9 @@ void PrintHeaderServerMethodSync(grpc_generator::Printer *printer,
printer->Print(method->GetTrailingComments("//").c_str());
}
-void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -700,8 +700,8 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
}
void PrintHeaderServerMethodStreamedUnary(
- grpc_generator::Printer *printer, const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+ grpc_generator::Printer* printer, const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -751,8 +751,8 @@ void PrintHeaderServerMethodStreamedUnary(
}
void PrintHeaderServerMethodSplitStreaming(
- grpc_generator::Printer *printer, const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+ grpc_generator::Printer* printer, const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -804,8 +804,8 @@ void PrintHeaderServerMethodSplitStreaming(
}
void PrintHeaderServerMethodGeneric(
- grpc_generator::Printer *printer, const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+ grpc_generator::Printer* printer, const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -873,9 +873,9 @@ void PrintHeaderServerMethodGeneric(
printer->Print(*vars, "};\n");
}
-void PrintHeaderService(grpc_generator::Printer *printer,
- const grpc_generator::Service *service,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintHeaderService(grpc_generator::Printer* printer,
+ const grpc_generator::Service* service,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Service"] = service->name();
printer->Print(service->GetLeadingComments("//").c_str());
@@ -1050,8 +1050,8 @@ void PrintHeaderService(grpc_generator::Printer *printer,
printer->Print(service->GetTrailingComments("//").c_str());
}
-grpc::string GetHeaderServices(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetHeaderServices(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1081,8 +1081,8 @@ grpc::string GetHeaderServices(grpc_generator::File *file,
return output;
}
-grpc::string GetHeaderEpilogue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetHeaderEpilogue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1110,8 +1110,8 @@ grpc::string GetHeaderEpilogue(grpc_generator::File *file,
return output;
}
-grpc::string GetSourcePrologue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetSourcePrologue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1135,15 +1135,15 @@ grpc::string GetSourcePrologue(grpc_generator::File *file,
return output;
}
-grpc::string GetSourceIncludes(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetSourceIncludes(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
- static const char *headers_strs[] = {
+ static const char* headers_strs[] = {
"grpc++/impl/codegen/async_stream.h",
"grpc++/impl/codegen/async_unary_call.h",
"grpc++/impl/codegen/channel_interface.h",
@@ -1169,9 +1169,9 @@ grpc::string GetSourceIncludes(grpc_generator::File *file,
return output;
}
-void PrintSourceClientMethod(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintSourceClientMethod(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -1305,9 +1305,9 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
}
}
-void PrintSourceServerMethod(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintSourceServerMethod(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -1364,9 +1364,9 @@ void PrintSourceServerMethod(grpc_generator::Printer *printer,
}
}
-void PrintSourceService(grpc_generator::Printer *printer,
- const grpc_generator::Service *service,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintSourceService(grpc_generator::Printer* printer,
+ const grpc_generator::Service* service,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Service"] = service->name();
if (service->method_count() > 0) {
@@ -1481,8 +1481,8 @@ void PrintSourceService(grpc_generator::Printer *printer,
}
}
-grpc::string GetSourceServices(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetSourceServices(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1510,8 +1510,8 @@ grpc::string GetSourceServices(grpc_generator::File *file,
return output;
}
-grpc::string GetSourceEpilogue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetSourceEpilogue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string temp;
if (!file->package().empty()) {
@@ -1529,8 +1529,8 @@ grpc::string GetSourceEpilogue(grpc_generator::File *file,
}
// TODO(mmukhi): Make sure we need parameters or not.
-grpc::string GetMockPrologue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetMockPrologue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1556,17 +1556,18 @@ grpc::string GetMockPrologue(grpc_generator::File *file,
}
// TODO(mmukhi): Add client-stream and completion-queue headers.
-grpc::string GetMockIncludes(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetMockIncludes(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
- static const char *headers_strs[] = {
+ static const char* headers_strs[] = {
"grpc++/impl/codegen/async_stream.h",
- "grpc++/impl/codegen/sync_stream.h", "gmock/gmock.h",
+ "grpc++/impl/codegen/sync_stream.h",
+ "gmock/gmock.h",
};
std::vector<grpc::string> headers(headers_strs, array_end(headers_strs));
PrintIncludes(printer.get(), headers, params);
@@ -1585,9 +1586,9 @@ grpc::string GetMockIncludes(grpc_generator::File *file,
return output;
}
-void PrintMockClientMethods(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintMockClientMethods(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -1668,9 +1669,9 @@ void PrintMockClientMethods(grpc_generator::Printer *printer,
}
}
-void PrintMockService(grpc_generator::Printer *printer,
- const grpc_generator::Service *service,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintMockService(grpc_generator::Printer* printer,
+ const grpc_generator::Service* service,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Service"] = service->name();
printer->Print(*vars,
@@ -1684,8 +1685,8 @@ void PrintMockService(grpc_generator::Printer *printer,
printer->Print("};\n");
}
-grpc::string GetMockServices(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetMockServices(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1715,8 +1716,8 @@ grpc::string GetMockServices(grpc_generator::File *file,
return output;
}
-grpc::string GetMockEpilogue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetMockEpilogue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string temp;
if (!file->package().empty()) {
diff --git a/src/compiler/cpp_generator.h b/src/compiler/cpp_generator.h
index 73f9fc662c..a93376acef 100644
--- a/src/compiler/cpp_generator.h
+++ b/src/compiler/cpp_generator.h
@@ -55,68 +55,68 @@ struct Parameters {
};
// Return the prologue of the generated header file.
-grpc::string GetHeaderPrologue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetHeaderPrologue(grpc_generator::File* file,
+ const Parameters& params);
// Return the includes needed for generated header file.
-grpc::string GetHeaderIncludes(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetHeaderIncludes(grpc_generator::File* file,
+ const Parameters& params);
// Return the includes needed for generated source file.
-grpc::string GetSourceIncludes(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetSourceIncludes(grpc_generator::File* file,
+ const Parameters& params);
// Return the epilogue of the generated header file.
-grpc::string GetHeaderEpilogue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetHeaderEpilogue(grpc_generator::File* file,
+ const Parameters& params);
// Return the prologue of the generated source file.
-grpc::string GetSourcePrologue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetSourcePrologue(grpc_generator::File* file,
+ const Parameters& params);
// Return the services for generated header file.
-grpc::string GetHeaderServices(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetHeaderServices(grpc_generator::File* file,
+ const Parameters& params);
// Return the services for generated source file.
-grpc::string GetSourceServices(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetSourceServices(grpc_generator::File* file,
+ const Parameters& params);
// Return the epilogue of the generated source file.
-grpc::string GetSourceEpilogue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetSourceEpilogue(grpc_generator::File* file,
+ const Parameters& params);
// Return the prologue of the generated mock file.
-grpc::string GetMockPrologue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockPrologue(grpc_generator::File* file,
+ const Parameters& params);
// Return the includes needed for generated mock file.
-grpc::string GetMockIncludes(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockIncludes(grpc_generator::File* file,
+ const Parameters& params);
// Return the services for generated mock file.
-grpc::string GetMockServices(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockServices(grpc_generator::File* file,
+ const Parameters& params);
// Return the epilogue of generated mock file.
-grpc::string GetMockEpilogue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockEpilogue(grpc_generator::File* file,
+ const Parameters& params);
// Return the prologue of the generated mock file.
-grpc::string GetMockPrologue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockPrologue(grpc_generator::File* file,
+ const Parameters& params);
// Return the includes needed for generated mock file.
-grpc::string GetMockIncludes(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockIncludes(grpc_generator::File* file,
+ const Parameters& params);
// Return the services for generated mock file.
-grpc::string GetMockServices(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockServices(grpc_generator::File* file,
+ const Parameters& params);
// Return the epilogue of generated mock file.
-grpc::string GetMockEpilogue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockEpilogue(grpc_generator::File* file,
+ const Parameters& params);
} // namespace grpc_cpp_generator
diff --git a/src/compiler/cpp_generator_helpers.h b/src/compiler/cpp_generator_helpers.h
index 28606d46b8..b8efcbdb84 100644
--- a/src/compiler/cpp_generator_helpers.h
+++ b/src/compiler/cpp_generator_helpers.h
@@ -26,22 +26,22 @@
namespace grpc_cpp_generator {
-inline grpc::string DotsToColons(const grpc::string &name) {
+inline grpc::string DotsToColons(const grpc::string& name) {
return grpc_generator::StringReplace(name, ".", "::");
}
-inline grpc::string DotsToUnderscores(const grpc::string &name) {
+inline grpc::string DotsToUnderscores(const grpc::string& name) {
return grpc_generator::StringReplace(name, ".", "_");
}
-inline grpc::string ClassName(const grpc::protobuf::Descriptor *descriptor,
+inline grpc::string ClassName(const grpc::protobuf::Descriptor* descriptor,
bool qualified) {
// Find "outer", the descriptor of the top-level message in which
// "descriptor" is embedded.
- const grpc::protobuf::Descriptor *outer = descriptor;
+ const grpc::protobuf::Descriptor* outer = descriptor;
while (outer->containing_type() != NULL) outer = outer->containing_type();
- const grpc::string &outer_name = outer->full_name();
+ const grpc::string& outer_name = outer->full_name();
grpc::string inner_name = descriptor->full_name().substr(outer_name.size());
if (qualified) {
@@ -54,7 +54,7 @@ inline grpc::string ClassName(const grpc::protobuf::Descriptor *descriptor,
// Get leading or trailing comments in a string. Comment lines start with "// ".
// Leading detached comments are put in in front of leading comments.
template <typename DescriptorType>
-inline grpc::string GetCppComments(const DescriptorType *desc, bool leading) {
+inline grpc::string GetCppComments(const DescriptorType* desc, bool leading) {
return grpc_generator::GetPrefixedComments(desc, leading, "//");
}
diff --git a/src/compiler/cpp_plugin.cc b/src/compiler/cpp_plugin.cc
index ebe3aa3860..adac0e23d3 100644
--- a/src/compiler/cpp_plugin.cc
+++ b/src/compiler/cpp_plugin.cc
@@ -33,10 +33,10 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
CppGrpcGenerator() {}
virtual ~CppGrpcGenerator() {}
- virtual bool Generate(const grpc::protobuf::FileDescriptor *file,
- const grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- grpc::string *error) const {
+ virtual bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ grpc::string* error) const {
if (file->options().cc_generic_services()) {
*error =
"cpp grpc proto compiler plugin does not work with generic "
@@ -125,9 +125,9 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
private:
// Insert the given code into the given file at the given insertion point.
- void Insert(grpc::protobuf::compiler::GeneratorContext *context,
- const grpc::string &filename, const grpc::string &insertion_point,
- const grpc::string &code) const {
+ void Insert(grpc::protobuf::compiler::GeneratorContext* context,
+ const grpc::string& filename, const grpc::string& insertion_point,
+ const grpc::string& code) const {
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output(
context->OpenForInsert(filename, insertion_point));
grpc::protobuf::io::CodedOutputStream coded_out(output.get());
@@ -135,7 +135,7 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
CppGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc
index bc3b0f24cd..e0957bf9bb 100644
--- a/src/compiler/csharp_generator.cc
+++ b/src/compiler/csharp_generator.cc
@@ -23,24 +23,23 @@
#include "src/compiler/config.h"
#include "src/compiler/csharp_generator.h"
-#include "src/compiler/csharp_generator.h"
#include "src/compiler/csharp_generator_helpers.h"
-using google::protobuf::compiler::csharp::GetFileNamespace;
using google::protobuf::compiler::csharp::GetClassName;
+using google::protobuf::compiler::csharp::GetFileNamespace;
using google::protobuf::compiler::csharp::GetReflectionClassName;
-using grpc::protobuf::FileDescriptor;
using grpc::protobuf::Descriptor;
-using grpc::protobuf::ServiceDescriptor;
+using grpc::protobuf::FileDescriptor;
using grpc::protobuf::MethodDescriptor;
+using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
-using grpc_generator::MethodType;
using grpc_generator::GetMethodType;
-using grpc_generator::METHODTYPE_NO_STREAMING;
+using grpc_generator::METHODTYPE_BIDI_STREAMING;
using grpc_generator::METHODTYPE_CLIENT_STREAMING;
+using grpc_generator::METHODTYPE_NO_STREAMING;
using grpc_generator::METHODTYPE_SERVER_STREAMING;
-using grpc_generator::METHODTYPE_BIDI_STREAMING;
+using grpc_generator::MethodType;
using grpc_generator::StringReplace;
using std::map;
using std::vector;
@@ -53,7 +52,7 @@ namespace {
// Currently, we cannot easily reuse the functionality as
// google/protobuf/compiler/csharp/csharp_doc_comment.h is not a public header.
// TODO(jtattermusch): reuse the functionality from google/protobuf.
-bool GenerateDocCommentBodyImpl(grpc::protobuf::io::Printer *printer,
+bool GenerateDocCommentBodyImpl(grpc::protobuf::io::Printer* printer,
grpc::protobuf::SourceLocation location) {
grpc::string comments = location.leading_comments.empty()
? location.trailing_comments
@@ -100,8 +99,8 @@ bool GenerateDocCommentBodyImpl(grpc::protobuf::io::Printer *printer,
}
template <typename DescriptorType>
-bool GenerateDocCommentBody(grpc::protobuf::io::Printer *printer,
- const DescriptorType *descriptor) {
+bool GenerateDocCommentBody(grpc::protobuf::io::Printer* printer,
+ const DescriptorType* descriptor) {
grpc::protobuf::SourceLocation location;
if (!descriptor->GetSourceLocation(&location)) {
return false;
@@ -109,8 +108,8 @@ bool GenerateDocCommentBody(grpc::protobuf::io::Printer *printer,
return GenerateDocCommentBodyImpl(printer, location);
}
-void GenerateDocCommentServerMethod(grpc::protobuf::io::Printer *printer,
- const MethodDescriptor *method) {
+void GenerateDocCommentServerMethod(grpc::protobuf::io::Printer* printer,
+ const MethodDescriptor* method) {
if (GenerateDocCommentBody(printer, method)) {
if (method->client_streaming()) {
printer->Print(
@@ -141,8 +140,8 @@ void GenerateDocCommentServerMethod(grpc::protobuf::io::Printer *printer,
}
}
-void GenerateDocCommentClientMethod(grpc::protobuf::io::Printer *printer,
- const MethodDescriptor *method,
+void GenerateDocCommentClientMethod(grpc::protobuf::io::Printer* printer,
+ const MethodDescriptor* method,
bool is_sync, bool use_call_options) {
if (GenerateDocCommentBody(printer, method)) {
if (!method->client_streaming()) {
@@ -173,15 +172,15 @@ void GenerateDocCommentClientMethod(grpc::protobuf::io::Printer *printer,
}
}
-std::string GetServiceClassName(const ServiceDescriptor *service) {
+std::string GetServiceClassName(const ServiceDescriptor* service) {
return service->name();
}
-std::string GetClientClassName(const ServiceDescriptor *service) {
+std::string GetClientClassName(const ServiceDescriptor* service) {
return service->name() + "Client";
}
-std::string GetServerClassName(const ServiceDescriptor *service) {
+std::string GetServerClassName(const ServiceDescriptor* service) {
return service->name() + "Base";
}
@@ -202,15 +201,15 @@ std::string GetCSharpMethodType(MethodType method_type) {
std::string GetServiceNameFieldName() { return "__ServiceName"; }
-std::string GetMarshallerFieldName(const Descriptor *message) {
+std::string GetMarshallerFieldName(const Descriptor* message) {
return "__Marshaller_" + message->name();
}
-std::string GetMethodFieldName(const MethodDescriptor *method) {
+std::string GetMethodFieldName(const MethodDescriptor* method) {
return "__Method_" + method->name();
}
-std::string GetMethodRequestParamMaybe(const MethodDescriptor *method,
+std::string GetMethodRequestParamMaybe(const MethodDescriptor* method,
bool invocation_param = false) {
if (method->client_streaming()) {
return "";
@@ -225,7 +224,7 @@ std::string GetAccessLevel(bool internal_access) {
return internal_access ? "internal" : "public";
}
-std::string GetMethodReturnTypeClient(const MethodDescriptor *method) {
+std::string GetMethodReturnTypeClient(const MethodDescriptor* method) {
switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING:
return "grpc::AsyncUnaryCall<" + GetClassName(method->output_type()) +
@@ -246,7 +245,7 @@ std::string GetMethodReturnTypeClient(const MethodDescriptor *method) {
return "";
}
-std::string GetMethodRequestParamServer(const MethodDescriptor *method) {
+std::string GetMethodRequestParamServer(const MethodDescriptor* method) {
switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING:
case METHODTYPE_SERVER_STREAMING:
@@ -260,7 +259,7 @@ std::string GetMethodRequestParamServer(const MethodDescriptor *method) {
return "";
}
-std::string GetMethodReturnTypeServer(const MethodDescriptor *method) {
+std::string GetMethodReturnTypeServer(const MethodDescriptor* method) {
switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING:
case METHODTYPE_CLIENT_STREAMING:
@@ -274,7 +273,7 @@ std::string GetMethodReturnTypeServer(const MethodDescriptor *method) {
return "";
}
-std::string GetMethodResponseStreamMaybe(const MethodDescriptor *method) {
+std::string GetMethodResponseStreamMaybe(const MethodDescriptor* method) {
switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING:
case METHODTYPE_CLIENT_STREAMING:
@@ -289,13 +288,13 @@ std::string GetMethodResponseStreamMaybe(const MethodDescriptor *method) {
}
// Gets vector of all messages used as input or output types.
-std::vector<const Descriptor *> GetUsedMessages(
- const ServiceDescriptor *service) {
- std::set<const Descriptor *> descriptor_set;
- std::vector<const Descriptor *>
+std::vector<const Descriptor*> GetUsedMessages(
+ const ServiceDescriptor* service) {
+ std::set<const Descriptor*> descriptor_set;
+ std::vector<const Descriptor*>
result; // vector is to maintain stable ordering
for (int i = 0; i < service->method_count(); i++) {
- const MethodDescriptor *method = service->method(i);
+ const MethodDescriptor* method = service->method(i);
if (descriptor_set.find(method->input_type()) == descriptor_set.end()) {
descriptor_set.insert(method->input_type());
result.push_back(method->input_type());
@@ -308,10 +307,10 @@ std::vector<const Descriptor *> GetUsedMessages(
return result;
}
-void GenerateMarshallerFields(Printer *out, const ServiceDescriptor *service) {
- std::vector<const Descriptor *> used_messages = GetUsedMessages(service);
+void GenerateMarshallerFields(Printer* out, const ServiceDescriptor* service) {
+ std::vector<const Descriptor*> used_messages = GetUsedMessages(service);
for (size_t i = 0; i < used_messages.size(); i++) {
- const Descriptor *message = used_messages[i];
+ const Descriptor* message = used_messages[i];
out->Print(
"static readonly grpc::Marshaller<$type$> $fieldname$ = "
"grpc::Marshallers.Create((arg) => "
@@ -323,7 +322,7 @@ void GenerateMarshallerFields(Printer *out, const ServiceDescriptor *service) {
out->Print("\n");
}
-void GenerateStaticMethodField(Printer *out, const MethodDescriptor *method) {
+void GenerateStaticMethodField(Printer* out, const MethodDescriptor* method) {
out->Print(
"static readonly grpc::Method<$request$, $response$> $fieldname$ = new "
"grpc::Method<$request$, $response$>(\n",
@@ -346,8 +345,8 @@ void GenerateStaticMethodField(Printer *out, const MethodDescriptor *method) {
out->Outdent();
}
-void GenerateServiceDescriptorProperty(Printer *out,
- const ServiceDescriptor *service) {
+void GenerateServiceDescriptorProperty(Printer* out,
+ const ServiceDescriptor* service) {
std::ostringstream index;
index << service->index();
out->Print("/// <summary>Service descriptor</summary>\n");
@@ -362,7 +361,7 @@ void GenerateServiceDescriptorProperty(Printer *out,
out->Print("\n");
}
-void GenerateServerClass(Printer *out, const ServiceDescriptor *service) {
+void GenerateServerClass(Printer* out, const ServiceDescriptor* service) {
out->Print(
"/// <summary>Base class for server-side implementations of "
"$servicename$</summary>\n",
@@ -372,7 +371,7 @@ void GenerateServerClass(Printer *out, const ServiceDescriptor *service) {
out->Print("{\n");
out->Indent();
for (int i = 0; i < service->method_count(); i++) {
- const MethodDescriptor *method = service->method(i);
+ const MethodDescriptor* method = service->method(i);
GenerateDocCommentServerMethod(out, method);
out->Print(
"public virtual $returntype$ "
@@ -395,7 +394,7 @@ void GenerateServerClass(Printer *out, const ServiceDescriptor *service) {
out->Print("\n");
}
-void GenerateClientStub(Printer *out, const ServiceDescriptor *service) {
+void GenerateClientStub(Printer* out, const ServiceDescriptor* service) {
out->Print("/// <summary>Client for $servicename$</summary>\n", "servicename",
GetServiceClassName(service));
out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", "name",
@@ -443,7 +442,7 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) {
out->Print("}\n\n");
for (int i = 0; i < service->method_count(); i++) {
- const MethodDescriptor *method = service->method(i);
+ const MethodDescriptor* method = service->method(i);
MethodType method_type = GetMethodType(method);
if (method_type == METHODTYPE_NO_STREAMING) {
@@ -573,7 +572,7 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) {
out->Print("\n");
}
-void GenerateBindServiceMethod(Printer *out, const ServiceDescriptor *service) {
+void GenerateBindServiceMethod(Printer* out, const ServiceDescriptor* service) {
out->Print(
"/// <summary>Creates service definition that can be registered with a "
"server</summary>\n");
@@ -591,7 +590,7 @@ void GenerateBindServiceMethod(Printer *out, const ServiceDescriptor *service) {
out->Indent();
out->Indent();
for (int i = 0; i < service->method_count(); i++) {
- const MethodDescriptor *method = service->method(i);
+ const MethodDescriptor* method = service->method(i);
out->Print(".AddMethod($methodfield$, serviceImpl.$methodname$)",
"methodfield", GetMethodFieldName(method), "methodname",
method->name());
@@ -608,7 +607,7 @@ void GenerateBindServiceMethod(Printer *out, const ServiceDescriptor *service) {
out->Print("\n");
}
-void GenerateService(Printer *out, const ServiceDescriptor *service,
+void GenerateService(Printer* out, const ServiceDescriptor* service,
bool generate_client, bool generate_server,
bool internal_access) {
GenerateDocCommentBody(out, service);
@@ -644,7 +643,7 @@ void GenerateService(Printer *out, const ServiceDescriptor *service,
} // anonymous namespace
-grpc::string GetServices(const FileDescriptor *file, bool generate_client,
+grpc::string GetServices(const FileDescriptor* file, bool generate_client,
bool generate_server, bool internal_access) {
grpc::string output;
{
diff --git a/src/compiler/csharp_generator.h b/src/compiler/csharp_generator.h
index 0eca292870..fd36e11851 100644
--- a/src/compiler/csharp_generator.h
+++ b/src/compiler/csharp_generator.h
@@ -25,7 +25,7 @@
namespace grpc_csharp_generator {
-grpc::string GetServices(const grpc::protobuf::FileDescriptor *file,
+grpc::string GetServices(const grpc::protobuf::FileDescriptor* file,
bool generate_client, bool generate_server,
bool internal_access);
diff --git a/src/compiler/csharp_generator_helpers.h b/src/compiler/csharp_generator_helpers.h
index bdf10dfc74..8c89925551 100644
--- a/src/compiler/csharp_generator_helpers.h
+++ b/src/compiler/csharp_generator_helpers.h
@@ -24,8 +24,8 @@
namespace grpc_csharp_generator {
-inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
- grpc::string *file_name_or_error) {
+inline bool ServicesFilename(const grpc::protobuf::FileDescriptor* file,
+ grpc::string* file_name_or_error) {
*file_name_or_error =
grpc_generator::FileNameInUpperCamel(file, false) + "Grpc.cs";
return true;
@@ -34,7 +34,7 @@ inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
// Get leading or trailing comments in a string. Comment lines start with "// ".
// Leading detached comments are put in in front of leading comments.
template <typename DescriptorType>
-inline grpc::string GetCsharpComments(const DescriptorType *desc,
+inline grpc::string GetCsharpComments(const DescriptorType* desc,
bool leading) {
return grpc_generator::GetPrefixedComments(desc, leading, "//");
}
diff --git a/src/compiler/csharp_plugin.cc b/src/compiler/csharp_plugin.cc
index 224a89c0d9..5f13aa6749 100644
--- a/src/compiler/csharp_plugin.cc
+++ b/src/compiler/csharp_plugin.cc
@@ -29,10 +29,10 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
CSharpGrpcGenerator() {}
~CSharpGrpcGenerator() {}
- bool Generate(const grpc::protobuf::FileDescriptor *file,
- const grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- grpc::string *error) const {
+ bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ grpc::string* error) const {
std::vector<std::pair<grpc::string, grpc::string> > options;
grpc::protobuf::compiler::ParseGeneratorParameter(parameter, &options);
@@ -71,7 +71,7 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
CSharpGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h
index e7005d84b0..747096f065 100644
--- a/src/compiler/generator_helpers.h
+++ b/src/compiler/generator_helpers.h
@@ -29,7 +29,7 @@
namespace grpc_generator {
-inline bool StripSuffix(grpc::string *filename, const grpc::string &suffix) {
+inline bool StripSuffix(grpc::string* filename, const grpc::string& suffix) {
if (filename->length() >= suffix.length()) {
size_t suffix_pos = filename->length() - suffix.length();
if (filename->compare(suffix_pos, grpc::string::npos, suffix) == 0) {
@@ -41,7 +41,7 @@ inline bool StripSuffix(grpc::string *filename, const grpc::string &suffix) {
return false;
}
-inline bool StripPrefix(grpc::string *name, const grpc::string &prefix) {
+inline bool StripPrefix(grpc::string* name, const grpc::string& prefix) {
if (name->length() >= prefix.length()) {
if (name->substr(0, prefix.size()) == prefix) {
*name = name->substr(prefix.size());
@@ -58,8 +58,8 @@ inline grpc::string StripProto(grpc::string filename) {
return filename;
}
-inline grpc::string StringReplace(grpc::string str, const grpc::string &from,
- const grpc::string &to, bool replace_all) {
+inline grpc::string StringReplace(grpc::string str, const grpc::string& from,
+ const grpc::string& to, bool replace_all) {
size_t pos = 0;
do {
@@ -74,13 +74,13 @@ inline grpc::string StringReplace(grpc::string str, const grpc::string &from,
return str;
}
-inline grpc::string StringReplace(grpc::string str, const grpc::string &from,
- const grpc::string &to) {
+inline grpc::string StringReplace(grpc::string str, const grpc::string& from,
+ const grpc::string& to) {
return StringReplace(str, from, to, true);
}
-inline std::vector<grpc::string> tokenize(const grpc::string &input,
- const grpc::string &delimiters) {
+inline std::vector<grpc::string> tokenize(const grpc::string& input,
+ const grpc::string& delimiters) {
std::vector<grpc::string> tokens;
size_t pos, last_pos = 0;
@@ -125,7 +125,7 @@ inline grpc::string LowerUnderscoreToUpperCamel(grpc::string str) {
}
inline grpc::string FileNameInUpperCamel(
- const grpc::protobuf::FileDescriptor *file, bool include_package_path) {
+ const grpc::protobuf::FileDescriptor* file, bool include_package_path) {
std::vector<grpc::string> tokens = tokenize(StripProto(file->name()), "/");
grpc::string result = "";
if (include_package_path) {
@@ -138,7 +138,7 @@ inline grpc::string FileNameInUpperCamel(
}
inline grpc::string FileNameInUpperCamel(
- const grpc::protobuf::FileDescriptor *file) {
+ const grpc::protobuf::FileDescriptor* file) {
return FileNameInUpperCamel(file, true);
}
@@ -150,7 +150,7 @@ enum MethodType {
};
inline MethodType GetMethodType(
- const grpc::protobuf::MethodDescriptor *method) {
+ const grpc::protobuf::MethodDescriptor* method) {
if (method->client_streaming()) {
if (method->server_streaming()) {
return METHODTYPE_BIDI_STREAMING;
@@ -166,8 +166,8 @@ inline MethodType GetMethodType(
}
}
-inline void Split(const grpc::string &s, char delim,
- std::vector<grpc::string> *append_to) {
+inline void Split(const grpc::string& s, char delim,
+ std::vector<grpc::string>* append_to) {
std::istringstream iss(s);
grpc::string piece;
while (std::getline(iss, piece)) {
@@ -183,14 +183,14 @@ enum CommentType {
// Get all the raw comments and append each line without newline to out.
template <typename DescriptorType>
-inline void GetComment(const DescriptorType *desc, CommentType type,
- std::vector<grpc::string> *out) {
+inline void GetComment(const DescriptorType* desc, CommentType type,
+ std::vector<grpc::string>* out) {
grpc::protobuf::SourceLocation location;
if (!desc->GetSourceLocation(&location)) {
return;
}
if (type == COMMENTTYPE_LEADING || type == COMMENTTYPE_TRAILING) {
- const grpc::string &comments = type == COMMENTTYPE_LEADING
+ const grpc::string& comments = type == COMMENTTYPE_LEADING
? location.leading_comments
: location.trailing_comments;
Split(comments, '\n', out);
@@ -210,8 +210,8 @@ inline void GetComment(const DescriptorType *desc, CommentType type,
// For file level leading and detached leading comments, we return comments
// above syntax line. Return nothing for trailing comments.
template <>
-inline void GetComment(const grpc::protobuf::FileDescriptor *desc,
- CommentType type, std::vector<grpc::string> *out) {
+inline void GetComment(const grpc::protobuf::FileDescriptor* desc,
+ CommentType type, std::vector<grpc::string>* out) {
if (type == COMMENTTYPE_TRAILING) {
return;
}
@@ -238,10 +238,10 @@ inline void GetComment(const grpc::protobuf::FileDescriptor *desc,
// Add prefix and newline to each comment line and concatenate them together.
// Make sure there is a space after the prefix unless the line is empty.
inline grpc::string GenerateCommentsWithPrefix(
- const std::vector<grpc::string> &in, const grpc::string &prefix) {
+ const std::vector<grpc::string>& in, const grpc::string& prefix) {
std::ostringstream oss;
for (auto it = in.begin(); it != in.end(); it++) {
- const grpc::string &elem = *it;
+ const grpc::string& elem = *it;
if (elem.empty()) {
oss << prefix << "\n";
} else if (elem[0] == ' ') {
@@ -254,9 +254,9 @@ inline grpc::string GenerateCommentsWithPrefix(
}
template <typename DescriptorType>
-inline grpc::string GetPrefixedComments(const DescriptorType *desc,
+inline grpc::string GetPrefixedComments(const DescriptorType* desc,
bool leading,
- const grpc::string &prefix) {
+ const grpc::string& prefix) {
std::vector<grpc::string> out;
if (leading) {
grpc_generator::GetComment(
diff --git a/src/compiler/node_generator.cc b/src/compiler/node_generator.cc
index c0fef9128f..ed835b4445 100644
--- a/src/compiler/node_generator.cc
+++ b/src/compiler/node_generator.cc
@@ -22,10 +22,10 @@
#include "src/compiler/generator_helpers.h"
#include "src/compiler/node_generator_helpers.h"
+using grpc::protobuf::Descriptor;
using grpc::protobuf::FileDescriptor;
-using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::MethodDescriptor;
-using grpc::protobuf::Descriptor;
+using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
using std::map;
@@ -53,15 +53,15 @@ grpc::string ModuleAlias(const grpc::string filename) {
// Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript
// message file foo/bar/baz.js
-grpc::string GetJSMessageFilename(const grpc::string &filename) {
+grpc::string GetJSMessageFilename(const grpc::string& filename) {
grpc::string name = filename;
return grpc_generator::StripProto(name) + "_pb.js";
}
// Given a filename like foo/bar/baz.proto, returns the root directory
// path ../../
-grpc::string GetRootPath(const grpc::string &from_filename,
- const grpc::string &to_filename) {
+grpc::string GetRootPath(const grpc::string& from_filename,
+ const grpc::string& to_filename) {
if (to_filename.find("google/protobuf") == 0) {
// Well-known types (.proto files in the google/protobuf directory) are
// assumed to come from the 'google-protobuf' npm package. We may want to
@@ -82,24 +82,24 @@ grpc::string GetRootPath(const grpc::string &from_filename,
// Return the relative path to load to_file from the directory containing
// from_file, assuming that both paths are relative to the same directory
-grpc::string GetRelativePath(const grpc::string &from_file,
- const grpc::string &to_file) {
+grpc::string GetRelativePath(const grpc::string& from_file,
+ const grpc::string& to_file) {
return GetRootPath(from_file, to_file) + to_file;
}
/* Finds all message types used in all services in the file, and returns them
* as a map of fully qualified message type name to message descriptor */
-map<grpc::string, const Descriptor *> GetAllMessages(
- const FileDescriptor *file) {
- map<grpc::string, const Descriptor *> message_types;
+map<grpc::string, const Descriptor*> GetAllMessages(
+ const FileDescriptor* file) {
+ map<grpc::string, const Descriptor*> message_types;
for (int service_num = 0; service_num < file->service_count();
service_num++) {
- const ServiceDescriptor *service = file->service(service_num);
+ const ServiceDescriptor* service = file->service(service_num);
for (int method_num = 0; method_num < service->method_count();
method_num++) {
- const MethodDescriptor *method = service->method(method_num);
- const Descriptor *input_type = method->input_type();
- const Descriptor *output_type = method->output_type();
+ const MethodDescriptor* method = service->method(method_num);
+ const Descriptor* input_type = method->input_type();
+ const Descriptor* output_type = method->output_type();
message_types[input_type->full_name()] = input_type;
message_types[output_type->full_name()] = output_type;
}
@@ -107,11 +107,11 @@ map<grpc::string, const Descriptor *> GetAllMessages(
return message_types;
}
-grpc::string MessageIdentifierName(const grpc::string &name) {
+grpc::string MessageIdentifierName(const grpc::string& name) {
return grpc_generator::StringReplace(name, ".", "_");
}
-grpc::string NodeObjectPath(const Descriptor *descriptor) {
+grpc::string NodeObjectPath(const Descriptor* descriptor) {
grpc::string module_alias = ModuleAlias(descriptor->file()->name());
grpc::string name = descriptor->full_name();
grpc_generator::StripPrefix(&name, descriptor->file()->package() + ".");
@@ -119,7 +119,7 @@ grpc::string NodeObjectPath(const Descriptor *descriptor) {
}
// Prints out the message serializer and deserializer functions
-void PrintMessageTransformer(const Descriptor *descriptor, Printer *out) {
+void PrintMessageTransformer(const Descriptor* descriptor, Printer* out) {
map<grpc::string, grpc::string> template_vars;
grpc::string full_name = descriptor->full_name();
template_vars["identifier_name"] = MessageIdentifierName(full_name);
@@ -149,9 +149,9 @@ void PrintMessageTransformer(const Descriptor *descriptor, Printer *out) {
out->Print("}\n\n");
}
-void PrintMethod(const MethodDescriptor *method, Printer *out) {
- const Descriptor *input_type = method->input_type();
- const Descriptor *output_type = method->output_type();
+void PrintMethod(const MethodDescriptor* method, Printer* out) {
+ const Descriptor* input_type = method->input_type();
+ const Descriptor* output_type = method->output_type();
map<grpc::string, grpc::string> vars;
vars["service_name"] = method->service()->full_name();
vars["name"] = method->name();
@@ -177,7 +177,7 @@ void PrintMethod(const MethodDescriptor *method, Printer *out) {
}
// Prints out the service descriptor object
-void PrintService(const ServiceDescriptor *service, Printer *out) {
+void PrintService(const ServiceDescriptor* service, Printer* out) {
map<grpc::string, grpc::string> template_vars;
out->Print(GetNodeComments(service, true).c_str());
template_vars["name"] = service->name();
@@ -200,7 +200,7 @@ void PrintService(const ServiceDescriptor *service, Printer *out) {
out->Print(GetNodeComments(service, false).c_str());
}
-void PrintImports(const FileDescriptor *file, Printer *out) {
+void PrintImports(const FileDescriptor* file, Printer* out) {
out->Print("var grpc = require('grpc');\n");
if (file->message_type_count() > 0) {
grpc::string file_path =
@@ -219,9 +219,9 @@ void PrintImports(const FileDescriptor *file, Printer *out) {
out->Print("\n");
}
-void PrintTransformers(const FileDescriptor *file, Printer *out) {
- map<grpc::string, const Descriptor *> messages = GetAllMessages(file);
- for (std::map<grpc::string, const Descriptor *>::iterator it =
+void PrintTransformers(const FileDescriptor* file, Printer* out) {
+ map<grpc::string, const Descriptor*> messages = GetAllMessages(file);
+ for (std::map<grpc::string, const Descriptor*>::iterator it =
messages.begin();
it != messages.end(); it++) {
PrintMessageTransformer(it->second, out);
@@ -229,14 +229,14 @@ void PrintTransformers(const FileDescriptor *file, Printer *out) {
out->Print("\n");
}
-void PrintServices(const FileDescriptor *file, Printer *out) {
+void PrintServices(const FileDescriptor* file, Printer* out) {
for (int i = 0; i < file->service_count(); i++) {
PrintService(file->service(i), out);
}
}
-}
+} // namespace
-grpc::string GenerateFile(const FileDescriptor *file) {
+grpc::string GenerateFile(const FileDescriptor* file) {
grpc::string output;
{
StringOutputStream output_stream(&output);
diff --git a/src/compiler/node_generator.h b/src/compiler/node_generator.h
index 7b0335b8d2..a9ffe75fc8 100644
--- a/src/compiler/node_generator.h
+++ b/src/compiler/node_generator.h
@@ -23,7 +23,7 @@
namespace grpc_node_generator {
-grpc::string GenerateFile(const grpc::protobuf::FileDescriptor *file);
+grpc::string GenerateFile(const grpc::protobuf::FileDescriptor* file);
} // namespace grpc_node_generator
diff --git a/src/compiler/node_plugin.cc b/src/compiler/node_plugin.cc
index f4334c96ab..bc38e9018a 100644
--- a/src/compiler/node_plugin.cc
+++ b/src/compiler/node_plugin.cc
@@ -32,10 +32,10 @@ class NodeGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
NodeGrpcGenerator() {}
~NodeGrpcGenerator() {}
- bool Generate(const grpc::protobuf::FileDescriptor *file,
- const grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- grpc::string *error) const {
+ bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ grpc::string* error) const {
grpc::string code = GenerateFile(file);
if (code.size() == 0) {
return true;
@@ -52,7 +52,7 @@ class NodeGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
NodeGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc
index 33b5fedd5c..349f1dc281 100644
--- a/src/compiler/objective_c_generator.cc
+++ b/src/compiler/objective_c_generator.cc
@@ -27,10 +27,10 @@
#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
using ::google::protobuf::compiler::objectivec::ClassName;
-using ::grpc::protobuf::io::Printer;
+using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::MethodDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
-using ::grpc::protobuf::FileDescriptor;
+using ::grpc::protobuf::io::Printer;
using ::std::map;
using ::std::set;
@@ -38,7 +38,7 @@ namespace grpc_objective_c_generator {
namespace {
void PrintProtoRpcDeclarationAsPragma(
- Printer *printer, const MethodDescriptor *method,
+ Printer* printer, const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
vars["client_stream"] = method->client_streaming() ? "stream " : "";
vars["server_stream"] = method->server_streaming() ? "stream " : "";
@@ -49,7 +49,7 @@ void PrintProtoRpcDeclarationAsPragma(
}
template <typename DescriptorType>
-static void PrintAllComments(const DescriptorType *desc, Printer *printer) {
+static void PrintAllComments(const DescriptorType* desc, Printer* printer) {
std::vector<grpc::string> comments;
grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING_DETACHED,
&comments);
@@ -72,8 +72,8 @@ static void PrintAllComments(const DescriptorType *desc, Printer *printer) {
printer->Print(" */\n");
}
-void PrintMethodSignature(Printer *printer, const MethodDescriptor *method,
- const map< ::grpc::string, ::grpc::string> &vars) {
+void PrintMethodSignature(Printer* printer, const MethodDescriptor* method,
+ const map< ::grpc::string, ::grpc::string>& vars) {
// Print comment
PrintAllComments(method, printer);
@@ -97,7 +97,7 @@ void PrintMethodSignature(Printer *printer, const MethodDescriptor *method,
}
}
-void PrintSimpleSignature(Printer *printer, const MethodDescriptor *method,
+void PrintSimpleSignature(Printer* printer, const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
vars["method_name"] =
grpc_generator::LowercaseFirstLetter(vars["method_name"]);
@@ -105,7 +105,7 @@ void PrintSimpleSignature(Printer *printer, const MethodDescriptor *method,
PrintMethodSignature(printer, method, vars);
}
-void PrintAdvancedSignature(Printer *printer, const MethodDescriptor *method,
+void PrintAdvancedSignature(Printer* printer, const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
vars["method_name"] = "RPCTo" + vars["method_name"];
vars["return_type"] = "GRPCProtoCall *";
@@ -113,7 +113,7 @@ void PrintAdvancedSignature(Printer *printer, const MethodDescriptor *method,
}
inline map< ::grpc::string, ::grpc::string> GetMethodVars(
- const MethodDescriptor *method) {
+ const MethodDescriptor* method) {
map< ::grpc::string, ::grpc::string> res;
res["method_name"] = method->name();
res["request_type"] = method->input_type()->name();
@@ -123,7 +123,7 @@ inline map< ::grpc::string, ::grpc::string> GetMethodVars(
return res;
}
-void PrintMethodDeclarations(Printer *printer, const MethodDescriptor *method) {
+void PrintMethodDeclarations(Printer* printer, const MethodDescriptor* method) {
map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method);
PrintProtoRpcDeclarationAsPragma(printer, method, vars);
@@ -134,7 +134,7 @@ void PrintMethodDeclarations(Printer *printer, const MethodDescriptor *method) {
printer->Print(";\n\n\n");
}
-void PrintSimpleImplementation(Printer *printer, const MethodDescriptor *method,
+void PrintSimpleImplementation(Printer* printer, const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
printer->Print("{\n");
printer->Print(vars, " [[self RPCTo$method_name$With");
@@ -151,8 +151,8 @@ void PrintSimpleImplementation(Printer *printer, const MethodDescriptor *method,
printer->Print("}\n");
}
-void PrintAdvancedImplementation(Printer *printer,
- const MethodDescriptor *method,
+void PrintAdvancedImplementation(Printer* printer,
+ const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
printer->Print("{\n");
printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n");
@@ -176,8 +176,8 @@ void PrintAdvancedImplementation(Printer *printer,
printer->Print("}\n");
}
-void PrintMethodImplementations(Printer *printer,
- const MethodDescriptor *method) {
+void PrintMethodImplementations(Printer* printer,
+ const MethodDescriptor* method) {
map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method);
PrintProtoRpcDeclarationAsPragma(printer, method, vars);
@@ -193,7 +193,7 @@ void PrintMethodImplementations(Printer *printer,
} // namespace
-::grpc::string GetAllMessageClasses(const FileDescriptor *file) {
+::grpc::string GetAllMessageClasses(const FileDescriptor* file) {
::grpc::string output;
set< ::grpc::string> classes;
for (int i = 0; i < file->service_count(); i++) {
@@ -211,7 +211,7 @@ void PrintMethodImplementations(Printer *printer,
return output;
}
-::grpc::string GetHeader(const ServiceDescriptor *service) {
+::grpc::string GetHeader(const ServiceDescriptor* service) {
::grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -245,7 +245,7 @@ void PrintMethodImplementations(Printer *printer,
return output;
}
-::grpc::string GetSource(const ServiceDescriptor *service) {
+::grpc::string GetSource(const ServiceDescriptor* service) {
::grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h
index e912a52415..2337abaf6a 100644
--- a/src/compiler/objective_c_generator.h
+++ b/src/compiler/objective_c_generator.h
@@ -23,20 +23,20 @@
namespace grpc_objective_c_generator {
-using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::protobuf::FileDescriptor;
+using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::string;
// Returns forward declaration of classes in the generated header file.
-string GetAllMessageClasses(const FileDescriptor *file);
+string GetAllMessageClasses(const FileDescriptor* file);
// Returns the content to be included in the "global_scope" insertion point of
// the generated header file.
-string GetHeader(const ServiceDescriptor *service);
+string GetHeader(const ServiceDescriptor* service);
// Returns the content to be included in the "global_scope" insertion point of
// the generated implementation file.
-string GetSource(const ServiceDescriptor *service);
+string GetSource(const ServiceDescriptor* service);
} // namespace grpc_objective_c_generator
diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h
index 9c9589e1db..4004e6aef8 100644
--- a/src/compiler/objective_c_generator_helpers.h
+++ b/src/compiler/objective_c_generator_helpers.h
@@ -31,14 +31,14 @@ using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::string;
-inline string MessageHeaderName(const FileDescriptor *file) {
+inline string MessageHeaderName(const FileDescriptor* file) {
return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h";
}
-inline string ServiceClassName(const ServiceDescriptor *service) {
- const FileDescriptor *file = service->file();
+inline string ServiceClassName(const ServiceDescriptor* service) {
+ const FileDescriptor* file = service->file();
string prefix = file->options().objc_class_prefix();
return prefix + service->name();
}
-}
+} // namespace grpc_objective_c_generator
#endif // GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_HELPERS_H
diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc
index e751d0562e..53ff81f94a 100644
--- a/src/compiler/objective_c_plugin.cc
+++ b/src/compiler/objective_c_plugin.cc
@@ -26,19 +26,19 @@
#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-using ::google::protobuf::compiler::objectivec::ProtobufLibraryFrameworkName;
using ::google::protobuf::compiler::objectivec::
IsProtobufLibraryBundledProtoFile;
+using ::google::protobuf::compiler::objectivec::ProtobufLibraryFrameworkName;
class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
public:
ObjectiveCGrpcGenerator() {}
virtual ~ObjectiveCGrpcGenerator() {}
- virtual bool Generate(const grpc::protobuf::FileDescriptor *file,
- const ::grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- ::grpc::string *error) const {
+ virtual bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const ::grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ ::grpc::string* error) const {
if (file->service_count() == 0) {
// No services. Do nothing.
return true;
@@ -65,7 +65,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
for (int i = 0; i < file->dependency_count(); i++) {
::grpc::string header =
grpc_objective_c_generator::MessageHeaderName(file->dependency(i));
- const grpc::protobuf::FileDescriptor *dependency = file->dependency(i);
+ const grpc::protobuf::FileDescriptor* dependency = file->dependency(i);
if (IsProtobufLibraryBundledProtoFile(dependency)) {
::grpc::string base_name = header;
grpc_generator::StripPrefix(&base_name, "google/protobuf/");
@@ -88,7 +88,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
::grpc::string declarations;
for (int i = 0; i < file->service_count(); i++) {
- const grpc::protobuf::ServiceDescriptor *service = file->service(i);
+ const grpc::protobuf::ServiceDescriptor* service = file->service(i);
declarations += grpc_objective_c_generator::GetHeader(service);
}
@@ -96,9 +96,9 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
"\nNS_ASSUME_NONNULL_BEGIN\n\n";
static const ::grpc::string kNonNullEnd = "\nNS_ASSUME_NONNULL_END\n";
- Write(context, file_name + ".pbrpc.h", imports + '\n' + proto_imports +
- '\n' + kNonNullBegin +
- declarations + kNonNullEnd);
+ Write(context, file_name + ".pbrpc.h",
+ imports + '\n' + proto_imports + '\n' + kNonNullBegin +
+ declarations + kNonNullEnd);
}
{
@@ -111,7 +111,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
for (int i = 0; i < file->dependency_count(); i++) {
::grpc::string header =
grpc_objective_c_generator::MessageHeaderName(file->dependency(i));
- const grpc::protobuf::FileDescriptor *dependency = file->dependency(i);
+ const grpc::protobuf::FileDescriptor* dependency = file->dependency(i);
if (IsProtobufLibraryBundledProtoFile(dependency)) {
::grpc::string base_name = header;
grpc_generator::StripPrefix(&base_name, "google/protobuf/");
@@ -133,7 +133,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
::grpc::string definitions;
for (int i = 0; i < file->service_count(); i++) {
- const grpc::protobuf::ServiceDescriptor *service = file->service(i);
+ const grpc::protobuf::ServiceDescriptor* service = file->service(i);
definitions += grpc_objective_c_generator::GetSource(service);
}
@@ -145,8 +145,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
private:
// Write the given code into the given file.
- void Write(grpc::protobuf::compiler::GeneratorContext *context,
- const ::grpc::string &filename, const ::grpc::string &code) const {
+ void Write(grpc::protobuf::compiler::GeneratorContext* context,
+ const ::grpc::string& filename, const ::grpc::string& code) const {
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output(
context->Open(filename));
grpc::protobuf::io::CodedOutputStream coded_out(output.get());
@@ -154,7 +154,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
ObjectiveCGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/php_generator.cc b/src/compiler/php_generator.cc
index 6d9ff3a29c..1ff9520d7f 100644
--- a/src/compiler/php_generator.cc
+++ b/src/compiler/php_generator.cc
@@ -22,10 +22,10 @@
#include "src/compiler/generator_helpers.h"
#include "src/compiler/php_generator_helpers.h"
+using grpc::protobuf::Descriptor;
using grpc::protobuf::FileDescriptor;
-using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::MethodDescriptor;
-using grpc::protobuf::Descriptor;
+using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
using std::map;
@@ -33,7 +33,7 @@ using std::map;
namespace grpc_php_generator {
namespace {
-grpc::string ConvertToPhpNamespace(const grpc::string &name) {
+grpc::string ConvertToPhpNamespace(const grpc::string& name) {
std::vector<grpc::string> tokens = grpc_generator::tokenize(name, ".");
std::ostringstream oss;
for (unsigned int i = 0; i < tokens.size(); i++) {
@@ -43,7 +43,7 @@ grpc::string ConvertToPhpNamespace(const grpc::string &name) {
return oss.str();
}
-grpc::string PackageName(const FileDescriptor *file) {
+grpc::string PackageName(const FileDescriptor* file) {
if (file->options().has_php_namespace()) {
return file->options().php_namespace();
} else {
@@ -51,8 +51,8 @@ grpc::string PackageName(const FileDescriptor *file) {
}
}
-grpc::string MessageIdentifierName(const grpc::string &name,
- const FileDescriptor *file) {
+grpc::string MessageIdentifierName(const grpc::string& name,
+ const FileDescriptor* file) {
std::vector<grpc::string> tokens = grpc_generator::tokenize(name, ".");
std::ostringstream oss;
oss << PackageName(file) << "\\"
@@ -60,9 +60,9 @@ grpc::string MessageIdentifierName(const grpc::string &name,
return oss.str();
}
-void PrintMethod(const MethodDescriptor *method, Printer *out) {
- const Descriptor *input_type = method->input_type();
- const Descriptor *output_type = method->output_type();
+void PrintMethod(const MethodDescriptor* method, Printer* out) {
+ const Descriptor* input_type = method->input_type();
+ const Descriptor* output_type = method->output_type();
map<grpc::string, grpc::string> vars;
vars["service_name"] = method->service()->full_name();
vars["name"] = method->name();
@@ -116,8 +116,8 @@ void PrintMethod(const MethodDescriptor *method, Printer *out) {
}
// Prints out the service descriptor object
-void PrintService(const ServiceDescriptor *service,
- const grpc::string &class_suffix, Printer *out) {
+void PrintService(const ServiceDescriptor* service,
+ const grpc::string& class_suffix, Printer* out) {
map<grpc::string, grpc::string> vars;
out->Print("/**\n");
out->Print(GetPHPComments(service, " *").c_str());
@@ -148,11 +148,11 @@ void PrintService(const ServiceDescriptor *service,
out->Outdent();
out->Print("}\n");
}
-}
+} // namespace
-grpc::string GenerateFile(const FileDescriptor *file,
- const ServiceDescriptor *service,
- const grpc::string &class_suffix) {
+grpc::string GenerateFile(const FileDescriptor* file,
+ const ServiceDescriptor* service,
+ const grpc::string& class_suffix) {
grpc::string output;
{
StringOutputStream output_stream(&output);
diff --git a/src/compiler/php_generator.h b/src/compiler/php_generator.h
index 5412d774a9..46222b3d8e 100644
--- a/src/compiler/php_generator.h
+++ b/src/compiler/php_generator.h
@@ -23,9 +23,9 @@
namespace grpc_php_generator {
-grpc::string GenerateFile(const grpc::protobuf::FileDescriptor *file,
- const grpc::protobuf::ServiceDescriptor *service,
- const grpc::string &class_suffix);
+grpc::string GenerateFile(const grpc::protobuf::FileDescriptor* file,
+ const grpc::protobuf::ServiceDescriptor* service,
+ const grpc::string& class_suffix);
} // namespace grpc_php_generator
diff --git a/src/compiler/php_generator_helpers.h b/src/compiler/php_generator_helpers.h
index 3c886794b8..3ad1997764 100644
--- a/src/compiler/php_generator_helpers.h
+++ b/src/compiler/php_generator_helpers.h
@@ -27,14 +27,14 @@
namespace grpc_php_generator {
inline grpc::string GetPHPServiceClassname(
- const grpc::protobuf::ServiceDescriptor *service,
- const grpc::string &class_suffix) {
+ const grpc::protobuf::ServiceDescriptor* service,
+ const grpc::string& class_suffix) {
return service->name() + (class_suffix == "" ? "Client" : class_suffix);
}
// ReplaceAll replaces all instances of search with replace in s.
-inline grpc::string ReplaceAll(grpc::string s, const grpc::string &search,
- const grpc::string &replace) {
+inline grpc::string ReplaceAll(grpc::string s, const grpc::string& search,
+ const grpc::string& replace) {
size_t pos = 0;
while ((pos = s.find(search, pos)) != grpc::string::npos) {
s.replace(pos, search.length(), replace);
@@ -44,9 +44,9 @@ inline grpc::string ReplaceAll(grpc::string s, const grpc::string &search,
}
inline grpc::string GetPHPServiceFilename(
- const grpc::protobuf::FileDescriptor *file,
- const grpc::protobuf::ServiceDescriptor *service,
- const grpc::string &class_suffix) {
+ const grpc::protobuf::FileDescriptor* file,
+ const grpc::protobuf::ServiceDescriptor* service,
+ const grpc::string& class_suffix) {
std::ostringstream oss;
if (file->options().has_php_namespace()) {
oss << ReplaceAll(file->options().php_namespace(), "\\", "/");
@@ -65,7 +65,7 @@ inline grpc::string GetPHPServiceFilename(
// Get leading or trailing comments in a string. Comment lines start with "// ".
// Leading detached comments are put in in front of leading comments.
template <typename DescriptorType>
-inline grpc::string GetPHPComments(const DescriptorType *desc,
+inline grpc::string GetPHPComments(const DescriptorType* desc,
grpc::string prefix) {
return ReplaceAll(grpc_generator::GetPrefixedComments(desc, true, prefix),
"*/", "&#42;/");
diff --git a/src/compiler/php_plugin.cc b/src/compiler/php_plugin.cc
index 7b0da87eb2..d01cbf87a0 100644
--- a/src/compiler/php_plugin.cc
+++ b/src/compiler/php_plugin.cc
@@ -24,19 +24,19 @@
#include "src/compiler/php_generator.h"
#include "src/compiler/php_generator_helpers.h"
+using google::protobuf::compiler::ParseGeneratorParameter;
using grpc_php_generator::GenerateFile;
using grpc_php_generator::GetPHPServiceFilename;
-using google::protobuf::compiler::ParseGeneratorParameter;
class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
public:
PHPGrpcGenerator() {}
~PHPGrpcGenerator() {}
- bool Generate(const grpc::protobuf::FileDescriptor *file,
- const grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- grpc::string *error) const {
+ bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ grpc::string* error) const {
if (file->service_count() == 0) {
return true;
}
@@ -71,7 +71,7 @@ class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
PHPGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/protobuf_plugin.h b/src/compiler/protobuf_plugin.h
index e14740cc0c..1551908156 100644
--- a/src/compiler/protobuf_plugin.h
+++ b/src/compiler/protobuf_plugin.h
@@ -29,14 +29,14 @@
// Get leading or trailing comments in a string.
template <typename DescriptorType>
-inline grpc::string GetCommentsHelper(const DescriptorType *desc, bool leading,
- const grpc::string &prefix) {
+inline grpc::string GetCommentsHelper(const DescriptorType* desc, bool leading,
+ const grpc::string& prefix) {
return grpc_generator::GetPrefixedComments(desc, leading, prefix);
}
class ProtoBufMethod : public grpc_generator::Method {
public:
- ProtoBufMethod(const grpc::protobuf::MethodDescriptor *method)
+ ProtoBufMethod(const grpc::protobuf::MethodDescriptor* method)
: method_(method) {}
grpc::string name() const { return method_->name(); }
@@ -55,7 +55,7 @@ class ProtoBufMethod : public grpc_generator::Method {
return method_->output_type()->file()->name();
}
- bool get_module_and_message_path_input(grpc::string *str,
+ bool get_module_and_message_path_input(grpc::string* str,
grpc::string generator_file_name,
bool generate_in_pb2_grpc,
grpc::string import_prefix) const {
@@ -64,7 +64,7 @@ class ProtoBufMethod : public grpc_generator::Method {
import_prefix);
}
- bool get_module_and_message_path_output(grpc::string *str,
+ bool get_module_and_message_path_output(grpc::string* str,
grpc::string generator_file_name,
bool generate_in_pb2_grpc,
grpc::string import_prefix) const {
@@ -98,12 +98,12 @@ class ProtoBufMethod : public grpc_generator::Method {
}
private:
- const grpc::protobuf::MethodDescriptor *method_;
+ const grpc::protobuf::MethodDescriptor* method_;
};
class ProtoBufService : public grpc_generator::Service {
public:
- ProtoBufService(const grpc::protobuf::ServiceDescriptor *service)
+ ProtoBufService(const grpc::protobuf::ServiceDescriptor* service)
: service_(service) {}
grpc::string name() const { return service_->name(); }
@@ -127,20 +127,20 @@ class ProtoBufService : public grpc_generator::Service {
}
private:
- const grpc::protobuf::ServiceDescriptor *service_;
+ const grpc::protobuf::ServiceDescriptor* service_;
};
class ProtoBufPrinter : public grpc_generator::Printer {
public:
- ProtoBufPrinter(grpc::string *str)
+ ProtoBufPrinter(grpc::string* str)
: output_stream_(str), printer_(&output_stream_, '$') {}
- void Print(const std::map<grpc::string, grpc::string> &vars,
- const char *string_template) {
+ void Print(const std::map<grpc::string, grpc::string>& vars,
+ const char* string_template) {
printer_.Print(vars, string_template);
}
- void Print(const char *string) { printer_.Print(string); }
+ void Print(const char* string) { printer_.Print(string); }
void Indent() { printer_.Indent(); }
void Outdent() { printer_.Outdent(); }
@@ -151,7 +151,7 @@ class ProtoBufPrinter : public grpc_generator::Printer {
class ProtoBufFile : public grpc_generator::File {
public:
- ProtoBufFile(const grpc::protobuf::FileDescriptor *file) : file_(file) {}
+ ProtoBufFile(const grpc::protobuf::FileDescriptor* file) : file_(file) {}
grpc::string filename() const { return file_->name(); }
grpc::string filename_without_ext() const {
@@ -172,7 +172,7 @@ class ProtoBufFile : public grpc_generator::File {
}
std::unique_ptr<grpc_generator::Printer> CreatePrinter(
- grpc::string *str) const {
+ grpc::string* str) const {
return std::unique_ptr<grpc_generator::Printer>(new ProtoBufPrinter(str));
}
@@ -189,7 +189,7 @@ class ProtoBufFile : public grpc_generator::File {
}
private:
- const grpc::protobuf::FileDescriptor *file_;
+ const grpc::protobuf::FileDescriptor* file_;
};
#endif // GRPC_INTERNAL_COMPILER_PROTOBUF_PLUGIN_H
diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc
index ef2d90de9e..c1ae7d31ad 100644
--- a/src/compiler/python_generator.cc
+++ b/src/compiler/python_generator.cc
@@ -45,9 +45,9 @@ using std::make_pair;
using std::map;
using std::pair;
using std::replace;
+using std::set;
using std::tuple;
using std::vector;
-using std::set;
namespace grpc_python_generator {
diff --git a/src/compiler/python_generator_helpers.h b/src/compiler/python_generator_helpers.h
index fb3e860d3e..b1b58befdf 100644
--- a/src/compiler/python_generator_helpers.h
+++ b/src/compiler/python_generator_helpers.h
@@ -29,9 +29,6 @@
#include "src/compiler/python_generator.h"
#include "src/compiler/python_private_generator.h"
-using std::vector;
-using grpc_generator::StringReplace;
-using grpc_generator::StripProto;
using grpc::protobuf::Descriptor;
using grpc::protobuf::FileDescriptor;
using grpc::protobuf::MethodDescriptor;
@@ -41,6 +38,9 @@ using grpc::protobuf::io::CodedOutputStream;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
using grpc::protobuf::io::ZeroCopyOutputStream;
+using grpc_generator::StringReplace;
+using grpc_generator::StripProto;
+using std::vector;
namespace grpc_python_generator {
diff --git a/src/compiler/ruby_generator.cc b/src/compiler/ruby_generator.cc
index 54d8a42597..ed7e074b47 100644
--- a/src/compiler/ruby_generator.cc
+++ b/src/compiler/ruby_generator.cc
@@ -27,8 +27,8 @@
#include "src/compiler/ruby_generator_string-inl.h"
using grpc::protobuf::FileDescriptor;
-using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::MethodDescriptor;
+using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
using std::map;
@@ -38,8 +38,8 @@ namespace grpc_ruby_generator {
namespace {
// Prints out the method using the ruby gRPC DSL.
-void PrintMethod(const MethodDescriptor *method, const grpc::string &package,
- Printer *out) {
+void PrintMethod(const MethodDescriptor* method, const grpc::string& package,
+ Printer* out) {
grpc::string input_type =
RubyTypeOf(method->input_type()->full_name(), package);
if (method->client_streaming()) {
@@ -51,7 +51,11 @@ void PrintMethod(const MethodDescriptor *method, const grpc::string &package,
output_type = "stream(" + output_type + ")";
}
std::map<grpc::string, grpc::string> method_vars = ListToDict({
- "mth.name", method->name(), "input.type", input_type, "output.type",
+ "mth.name",
+ method->name(),
+ "input.type",
+ input_type,
+ "output.type",
output_type,
});
out->Print(GetRubyComments(method, true).c_str());
@@ -60,15 +64,16 @@ void PrintMethod(const MethodDescriptor *method, const grpc::string &package,
}
// Prints out the service using the ruby gRPC DSL.
-void PrintService(const ServiceDescriptor *service, const grpc::string &package,
- Printer *out) {
+void PrintService(const ServiceDescriptor* service, const grpc::string& package,
+ Printer* out) {
if (service->method_count() == 0) {
return;
}
// Begin the service module
std::map<grpc::string, grpc::string> module_vars = ListToDict({
- "module.name", CapitalizeFirst(service->name()),
+ "module.name",
+ CapitalizeFirst(service->name()),
});
out->Print(module_vars, "module $module.name$\n");
out->Indent();
@@ -119,7 +124,7 @@ char ToUpper(char ch) { return IsLower(ch) ? (ch - 'a' + 'A') : ch; }
// names must be PascalCased.
//
// foo_bar_baz -> FooBarBaz
-grpc::string PackageToModule(const grpc::string &name) {
+grpc::string PackageToModule(const grpc::string& name) {
bool next_upper = true;
grpc::string result;
result.reserve(name.size());
@@ -141,7 +146,7 @@ grpc::string PackageToModule(const grpc::string &name) {
}
// end copying of protoc generator for ruby code
-grpc::string GetServices(const FileDescriptor *file) {
+grpc::string GetServices(const FileDescriptor* file) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -157,7 +162,10 @@ grpc::string GetServices(const FileDescriptor *file) {
// Write out a file header.
std::map<grpc::string, grpc::string> header_comment_vars = ListToDict({
- "file.name", file->name(), "file.package", file->package(),
+ "file.name",
+ file->name(),
+ "file.package",
+ file->package(),
});
out.Print("# Generated by the protocol buffer compiler. DO NOT EDIT!\n");
out.Print(header_comment_vars,
@@ -175,7 +183,8 @@ grpc::string GetServices(const FileDescriptor *file) {
// that defines the messages used by the service. This is generated by the
// main ruby plugin.
std::map<grpc::string, grpc::string> dep_vars = ListToDict({
- "dep.name", MessagesRequireName(file),
+ "dep.name",
+ MessagesRequireName(file),
});
out.Print(dep_vars, "require '$dep.name$'\n");
@@ -184,7 +193,8 @@ grpc::string GetServices(const FileDescriptor *file) {
std::vector<grpc::string> modules = Split(file->package(), '.');
for (size_t i = 0; i < modules.size(); ++i) {
std::map<grpc::string, grpc::string> module_vars = ListToDict({
- "module.name", PackageToModule(modules[i]),
+ "module.name",
+ PackageToModule(modules[i]),
});
out.Print(module_vars, "module $module.name$\n");
out.Indent();
diff --git a/src/compiler/ruby_generator.h b/src/compiler/ruby_generator.h
index cdc03aa0d4..9a03e0d139 100644
--- a/src/compiler/ruby_generator.h
+++ b/src/compiler/ruby_generator.h
@@ -23,7 +23,7 @@
namespace grpc_ruby_generator {
-grpc::string GetServices(const grpc::protobuf::FileDescriptor *file);
+grpc::string GetServices(const grpc::protobuf::FileDescriptor* file);
} // namespace grpc_ruby_generator
diff --git a/src/compiler/ruby_generator_helpers-inl.h b/src/compiler/ruby_generator_helpers-inl.h
index ac09f8dcdb..2323770425 100644
--- a/src/compiler/ruby_generator_helpers-inl.h
+++ b/src/compiler/ruby_generator_helpers-inl.h
@@ -25,8 +25,8 @@
namespace grpc_ruby_generator {
-inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
- grpc::string *file_name_or_error) {
+inline bool ServicesFilename(const grpc::protobuf::FileDescriptor* file,
+ grpc::string* file_name_or_error) {
// Get output file name.
static const unsigned proto_suffix_length = 6; // length of ".proto"
if (file->name().size() > proto_suffix_length &&
@@ -42,14 +42,14 @@ inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
}
inline grpc::string MessagesRequireName(
- const grpc::protobuf::FileDescriptor *file) {
+ const grpc::protobuf::FileDescriptor* file) {
return Replace(file->name(), ".proto", "_pb");
}
// Get leading or trailing comments in a string. Comment lines start with "# ".
// Leading detached comments are put in in front of leading comments.
template <typename DescriptorType>
-inline grpc::string GetRubyComments(const DescriptorType *desc, bool leading) {
+inline grpc::string GetRubyComments(const DescriptorType* desc, bool leading) {
return grpc_generator::GetPrefixedComments(desc, leading, "#");
}
diff --git a/src/compiler/ruby_generator_map-inl.h b/src/compiler/ruby_generator_map-inl.h
index 12973e4fb4..89a74b1d41 100644
--- a/src/compiler/ruby_generator_map-inl.h
+++ b/src/compiler/ruby_generator_map-inl.h
@@ -36,7 +36,7 @@ namespace grpc_ruby_generator {
// Converts an initializer list of the form { key0, value0, key1, value1, ... }
// into a map of key* to value*. Is merely a readability helper for later code.
inline std::map<grpc::string, grpc::string> ListToDict(
- const initializer_list<grpc::string> &values) {
+ const initializer_list<grpc::string>& values) {
if (values.size() % 2 != 0) {
std::cerr << "Not every 'key' has a value in `values`." << std::endl;
}
diff --git a/src/compiler/ruby_generator_string-inl.h b/src/compiler/ruby_generator_string-inl.h
index def92edec6..fb429784bb 100644
--- a/src/compiler/ruby_generator_string-inl.h
+++ b/src/compiler/ruby_generator_string-inl.h
@@ -31,8 +31,8 @@ using std::transform;
namespace grpc_ruby_generator {
// Split splits a string using char into elems.
-inline std::vector<grpc::string> &Split(const grpc::string &s, char delim,
- std::vector<grpc::string> *elems) {
+inline std::vector<grpc::string>& Split(const grpc::string& s, char delim,
+ std::vector<grpc::string>* elems) {
std::stringstream ss(s);
grpc::string item;
while (getline(ss, item, delim)) {
@@ -42,15 +42,15 @@ inline std::vector<grpc::string> &Split(const grpc::string &s, char delim,
}
// Split splits a string using char, returning the result in a vector.
-inline std::vector<grpc::string> Split(const grpc::string &s, char delim) {
+inline std::vector<grpc::string> Split(const grpc::string& s, char delim) {
std::vector<grpc::string> elems;
Split(s, delim, &elems);
return elems;
}
// Replace replaces from with to in s.
-inline grpc::string Replace(grpc::string s, const grpc::string &from,
- const grpc::string &to) {
+inline grpc::string Replace(grpc::string s, const grpc::string& from,
+ const grpc::string& to) {
size_t start_pos = s.find(from);
if (start_pos == grpc::string::npos) {
return s;
@@ -60,8 +60,8 @@ inline grpc::string Replace(grpc::string s, const grpc::string &from,
}
// ReplaceAll replaces all instances of search with replace in s.
-inline grpc::string ReplaceAll(grpc::string s, const grpc::string &search,
- const grpc::string &replace) {
+inline grpc::string ReplaceAll(grpc::string s, const grpc::string& search,
+ const grpc::string& replace) {
size_t pos = 0;
while ((pos = s.find(search, pos)) != grpc::string::npos) {
s.replace(pos, search.length(), replace);
@@ -71,8 +71,8 @@ inline grpc::string ReplaceAll(grpc::string s, const grpc::string &search,
}
// ReplacePrefix replaces from with to in s if search is a prefix of s.
-inline bool ReplacePrefix(grpc::string *s, const grpc::string &from,
- const grpc::string &to) {
+inline bool ReplacePrefix(grpc::string* s, const grpc::string& from,
+ const grpc::string& to) {
size_t start_pos = s->find(from);
if (start_pos == grpc::string::npos || start_pos != 0) {
return false;
@@ -91,8 +91,8 @@ inline grpc::string CapitalizeFirst(grpc::string s) {
}
// RubyTypeOf updates a proto type to the required ruby equivalent.
-inline grpc::string RubyTypeOf(const grpc::string &a_type,
- const grpc::string &package) {
+inline grpc::string RubyTypeOf(const grpc::string& a_type,
+ const grpc::string& package) {
grpc::string res(a_type);
ReplacePrefix(&res, package, ""); // remove the leading package if present
ReplacePrefix(&res, ".", ""); // remove the leading . (no package)
diff --git a/src/compiler/ruby_plugin.cc b/src/compiler/ruby_plugin.cc
index f1b1d0182a..9c234bd7cb 100644
--- a/src/compiler/ruby_plugin.cc
+++ b/src/compiler/ruby_plugin.cc
@@ -29,10 +29,10 @@ class RubyGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
RubyGrpcGenerator() {}
~RubyGrpcGenerator() {}
- bool Generate(const grpc::protobuf::FileDescriptor *file,
- const grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- grpc::string *error) const {
+ bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ grpc::string* error) const {
grpc::string code = grpc_ruby_generator::GetServices(file);
if (code.size() == 0) {
return true; // don't generate a file if there are no services
@@ -51,7 +51,7 @@ class RubyGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
RubyGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/schema_interface.h b/src/compiler/schema_interface.h
index 828c7753df..b2021f2926 100644
--- a/src/compiler/schema_interface.h
+++ b/src/compiler/schema_interface.h
@@ -56,10 +56,10 @@ struct Method : public CommentHolder {
virtual grpc::string output_type_name() const = 0;
virtual bool get_module_and_message_path_input(
- grpc::string *str, grpc::string generator_file_name,
+ grpc::string* str, grpc::string generator_file_name,
bool generate_in_pb2_grpc, grpc::string import_prefix) const = 0;
virtual bool get_module_and_message_path_output(
- grpc::string *str, grpc::string generator_file_name,
+ grpc::string* str, grpc::string generator_file_name,
bool generate_in_pb2_grpc, grpc::string import_prefix) const = 0;
virtual grpc::string get_input_type_name() const = 0;
@@ -83,9 +83,9 @@ struct Service : public CommentHolder {
struct Printer {
virtual ~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 Print(const std::map<grpc::string, grpc::string>& vars,
+ const char* template_string) = 0;
+ virtual void Print(const char* string) = 0;
virtual void Indent() = 0;
virtual void Outdent() = 0;
};
@@ -104,7 +104,7 @@ struct File : public CommentHolder {
virtual int service_count() const = 0;
virtual std::unique_ptr<const Service> service(int i) const = 0;
- virtual std::unique_ptr<Printer> CreatePrinter(grpc::string *str) const = 0;
+ virtual std::unique_ptr<Printer> CreatePrinter(grpc::string* str) const = 0;
};
} // namespace grpc_generator