diff options
author | 2015-01-13 11:13:42 -0800 | |
---|---|---|
committer | 2015-01-13 11:13:42 -0800 | |
commit | b5dcec5a2e917aebd0d59772ee4aa6737064494e (patch) | |
tree | d2b8011a5eaec439677d31e4a6385d6aef1e3c5c /src/compiler | |
parent | d8532af01c00ea46431e21c6000a5f7fe44110ca (diff) |
clang-format codebase
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/cpp_generator.cc | 57 | ||||
-rw-r--r-- | src/compiler/cpp_generator_helpers.h | 3 | ||||
-rw-r--r-- | src/compiler/cpp_plugin.cc | 7 | ||||
-rw-r--r-- | src/compiler/go_generator.cc | 214 | ||||
-rw-r--r-- | src/compiler/go_plugin.cc | 4 | ||||
-rw-r--r-- | src/compiler/ruby_generator.cc | 13 | ||||
-rw-r--r-- | src/compiler/ruby_generator_helpers-inl.h | 8 | ||||
-rw-r--r-- | src/compiler/ruby_generator_map-inl.h | 6 | ||||
-rw-r--r-- | src/compiler/ruby_generator_string-inl.h | 6 |
9 files changed, 165 insertions, 153 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 43a04be931..1116049806 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -43,13 +43,11 @@ namespace grpc_cpp_generator { namespace { bool NoStreaming(const google::protobuf::MethodDescriptor* method) { - return !method->client_streaming() && - !method->server_streaming(); + return !method->client_streaming() && !method->server_streaming(); } bool ClientOnlyStreaming(const google::protobuf::MethodDescriptor* method) { - return method->client_streaming() && - !method->server_streaming(); + return method->client_streaming() && !method->server_streaming(); } bool ServerOnlyStreaming(const google::protobuf::MethodDescriptor* method) { @@ -57,8 +55,7 @@ bool ServerOnlyStreaming(const google::protobuf::MethodDescriptor* method) { } bool BidiStreaming(const google::protobuf::MethodDescriptor* method) { - return method->client_streaming() && - method->server_streaming(); + return method->client_streaming() && method->server_streaming(); } bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor* file) { @@ -132,8 +129,8 @@ string GetSourceIncludes() { } void PrintHeaderClientMethod(google::protobuf::io::Printer* printer, - const google::protobuf::MethodDescriptor* method, - map<string, string>* vars) { + const google::protobuf::MethodDescriptor* method, + map<string, string>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = grpc_cpp_generator::ClassName(method->input_type(), true); @@ -204,8 +201,9 @@ void PrintHeaderService(google::protobuf::io::Printer* printer, printer->Indent(); // Client side - printer->Print("class Stub : public ::grpc::InternalStub {\n" - " public:\n"); + printer->Print( + "class Stub : public ::grpc::InternalStub {\n" + " public:\n"); printer->Indent(); for (int i = 0; i < service->method_count(); ++i) { PrintHeaderClientMethod(printer, service->method(i), vars); @@ -219,8 +217,9 @@ void PrintHeaderService(google::protobuf::io::Printer* printer, printer->Print("\n"); // Server side - printer->Print("class Service {\n" - " public:\n"); + printer->Print( + "class Service {\n" + " public:\n"); printer->Indent(); printer->Print("Service() : service_(nullptr) {}\n"); printer->Print("virtual ~Service();\n"); @@ -229,8 +228,9 @@ void PrintHeaderService(google::protobuf::io::Printer* printer, } printer->Print("::grpc::RpcService* service();\n"); printer->Outdent(); - printer->Print(" private:\n" - " ::grpc::RpcService* service_;\n"); + printer->Print( + " private:\n" + " ::grpc::RpcService* service_;\n"); printer->Print("};\n"); printer->Outdent(); @@ -251,8 +251,8 @@ string GetHeaderServices(const google::protobuf::FileDescriptor* file) { } void PrintSourceClientMethod(google::protobuf::io::Printer* printer, - const google::protobuf::MethodDescriptor* method, - map<string, string>* vars) { + const google::protobuf::MethodDescriptor* method, + map<string, string>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = grpc_cpp_generator::ClassName(method->input_type(), true); @@ -308,8 +308,8 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer, } void PrintSourceServerMethod(google::protobuf::io::Printer* printer, - const google::protobuf::MethodDescriptor* method, - map<string, string>* vars) { + const google::protobuf::MethodDescriptor* method, + map<string, string>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = grpc_cpp_generator::ClassName(method->input_type(), true); @@ -362,12 +362,12 @@ void PrintSourceService(google::protobuf::io::Printer* printer, map<string, string>* vars) { (*vars)["Service"] = service->name(); printer->Print(*vars, - "$Service$::Stub* $Service$::NewStub(" - "const std::shared_ptr<::grpc::ChannelInterface>& channel) {\n" - " $Service$::Stub* stub = new $Service$::Stub();\n" - " stub->set_channel(channel);\n" - " return stub;\n" - "};\n\n"); + "$Service$::Stub* $Service$::NewStub(" + "const std::shared_ptr<::grpc::ChannelInterface>& channel) {\n" + " $Service$::Stub* stub = new $Service$::Stub();\n" + " stub->set_channel(channel);\n" + " return stub;\n" + "};\n\n"); for (int i = 0; i < service->method_count(); ++i) { PrintSourceClientMethod(printer, service->method(i), vars); } @@ -380,11 +380,12 @@ void PrintSourceService(google::protobuf::io::Printer* printer, PrintSourceServerMethod(printer, service->method(i), vars); } printer->Print(*vars, - "::grpc::RpcService* $Service$::Service::service() {\n"); + "::grpc::RpcService* $Service$::Service::service() {\n"); printer->Indent(); - printer->Print("if (service_ != nullptr) {\n" - " return service_;\n" - "}\n"); + printer->Print( + "if (service_ != nullptr) {\n" + " return service_;\n" + "}\n"); printer->Print("service_ = new ::grpc::RpcService();\n"); for (int i = 0; i < service->method_count(); ++i) { const google::protobuf::MethodDescriptor* method = service->method(i); diff --git a/src/compiler/cpp_generator_helpers.h b/src/compiler/cpp_generator_helpers.h index 8d8b03ea43..ba251faf29 100644 --- a/src/compiler/cpp_generator_helpers.h +++ b/src/compiler/cpp_generator_helpers.h @@ -85,7 +85,8 @@ inline string DotsToUnderscores(const string& name) { return StringReplace(name, ".", "_"); } -inline string ClassName(const google::protobuf::Descriptor* descriptor, bool qualified) { +inline string ClassName(const google::protobuf::Descriptor* descriptor, + bool qualified) { // Find "outer", the descriptor of the top-level message in which // "descriptor" is embedded. const google::protobuf::Descriptor* outer = descriptor; diff --git a/src/compiler/cpp_plugin.cc b/src/compiler/cpp_plugin.cc index 7aa745a4f1..17836b1612 100644 --- a/src/compiler/cpp_plugin.cc +++ b/src/compiler/cpp_plugin.cc @@ -54,9 +54,10 @@ class CppGrpcGenerator : public google::protobuf::compiler::CodeGenerator { google::protobuf::compiler::GeneratorContext* context, string* error) const { if (file->options().cc_generic_services()) { - *error = "cpp grpc proto compiler plugin does not work with generic " - "services. To generate cpp grpc APIs, please set \"" - "cc_generic_service = false\"."; + *error = + "cpp grpc proto compiler plugin does not work with generic " + "services. To generate cpp grpc APIs, please set \"" + "cc_generic_service = false\"."; return false; } diff --git a/src/compiler/go_generator.cc b/src/compiler/go_generator.cc index 8beae8dccc..3873eae3bb 100644 --- a/src/compiler/go_generator.cc +++ b/src/compiler/go_generator.cc @@ -45,23 +45,19 @@ using namespace std; namespace grpc_go_generator { bool NoStreaming(const google::protobuf::MethodDescriptor* method) { - return !method->client_streaming() && - !method->server_streaming(); + return !method->client_streaming() && !method->server_streaming(); } bool ClientOnlyStreaming(const google::protobuf::MethodDescriptor* method) { - return method->client_streaming() && - !method->server_streaming(); + return method->client_streaming() && !method->server_streaming(); } bool ServerOnlyStreaming(const google::protobuf::MethodDescriptor* method) { - return !method->client_streaming() && - method->server_streaming(); + return !method->client_streaming() && method->server_streaming(); } bool BidiStreaming(const google::protobuf::MethodDescriptor* method) { - return method->client_streaming() && - method->server_streaming(); + return method->client_streaming() && method->server_streaming(); } bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor* file) { @@ -91,20 +87,22 @@ void PrintClientMethodDef(google::protobuf::io::Printer* printer, (*vars)["Response"] = method->output_type()->name(); if (NoStreaming(method)) { printer->Print(*vars, - "\t$Method$(ctx context.Context, in *$Request$, opts ...rpc.CallOption) " - "(*$Response$, error)\n"); + "\t$Method$(ctx context.Context, in *$Request$, opts " + "...rpc.CallOption) " + "(*$Response$, error)\n"); } else if (BidiStreaming(method)) { printer->Print(*vars, - "\t$Method$(ctx context.Context, opts ...rpc.CallOption) " - "($Service$_$Method$Client, error)\n"); + "\t$Method$(ctx context.Context, opts ...rpc.CallOption) " + "($Service$_$Method$Client, error)\n"); } else if (ServerOnlyStreaming(method)) { - printer->Print(*vars, + printer->Print( + *vars, "\t$Method$(ctx context.Context, m *$Request$, opts ...rpc.CallOption) " "($Service$_$Method$Client, error)\n"); } else if (ClientOnlyStreaming(method)) { printer->Print(*vars, - "\t$Method$(ctx context.Context, opts ...rpc.CallOption) " - "($Service$_$Method$Client, error)\n"); + "\t$Method$(ctx context.Context, opts ...rpc.CallOption) " + "($Service$_$Method$Client, error)\n"); } } @@ -116,11 +114,11 @@ void PrintClientMethodImpl(google::protobuf::io::Printer* printer, (*vars)["Response"] = method->output_type()->name(); if (NoStreaming(method)) { - printer->Print(*vars, + printer->Print( + *vars, "func (c *$ServiceStruct$Client) $Method$(ctx context.Context, " "in *$Request$, opts ...rpc.CallOption) (*$Response$, error) {\n"); - printer->Print(*vars, - "\tout := new($Response$)\n"); + printer->Print(*vars, "\tout := new($Response$)\n"); printer->Print(*vars, "\terr := rpc.Invoke(ctx, \"/$Package$$Service$/$Method$\", " "in, out, c.cc, opts...)\n"); @@ -142,20 +140,22 @@ void PrintClientMethodImpl(google::protobuf::io::Printer* printer, "\treturn &$ServiceStruct$$Method$Client{stream}, nil\n" "}\n\n"); printer->Print(*vars, - "type $Service$_$Method$Client interface {\n" - "\tSend(*$Request$) error\n" - "\tRecv() (*$Response$, error)\n" - "\trpc.ClientStream\n" - "}\n\n"); - printer->Print(*vars, - "type $ServiceStruct$$Method$Client struct {\n" - "\trpc.ClientStream\n" - "}\n\n"); + "type $Service$_$Method$Client interface {\n" + "\tSend(*$Request$) error\n" + "\tRecv() (*$Response$, error)\n" + "\trpc.ClientStream\n" + "}\n\n"); printer->Print(*vars, + "type $ServiceStruct$$Method$Client struct {\n" + "\trpc.ClientStream\n" + "}\n\n"); + printer->Print( + *vars, "func (x *$ServiceStruct$$Method$Client) Send(m *$Request$) error {\n" "\treturn x.ClientStream.SendProto(m)\n" "}\n\n"); - printer->Print(*vars, + printer->Print( + *vars, "func (x *$ServiceStruct$$Method$Client) Recv() (*$Response$, error) " "{\n" "\tm := new($Response$)\n" @@ -185,15 +185,16 @@ void PrintClientMethodImpl(google::protobuf::io::Printer* printer, "\treturn x, nil\n" "}\n\n"); printer->Print(*vars, - "type $Service$_$Method$Client interface {\n" - "\tRecv() (*$Response$, error)\n" - "\trpc.ClientStream\n" - "}\n\n"); - printer->Print(*vars, - "type $ServiceStruct$$Method$Client struct {\n" - "\trpc.ClientStream\n" - "}\n\n"); + "type $Service$_$Method$Client interface {\n" + "\tRecv() (*$Response$, error)\n" + "\trpc.ClientStream\n" + "}\n\n"); printer->Print(*vars, + "type $ServiceStruct$$Method$Client struct {\n" + "\trpc.ClientStream\n" + "}\n\n"); + printer->Print( + *vars, "func (x *$ServiceStruct$$Method$Client) Recv() (*$Response$, error) " "{\n" "\tm := new($Response$)\n" @@ -215,20 +216,22 @@ void PrintClientMethodImpl(google::protobuf::io::Printer* printer, "\treturn &$ServiceStruct$$Method$Client{stream}, nil\n" "}\n\n"); printer->Print(*vars, - "type $Service$_$Method$Client interface {\n" - "\tSend(*$Request$) error\n" - "\tCloseAndRecv() (*$Response$, error)\n" - "\trpc.ClientStream\n" - "}\n\n"); - printer->Print(*vars, - "type $ServiceStruct$$Method$Client struct {\n" - "\trpc.ClientStream\n" - "}\n\n"); + "type $Service$_$Method$Client interface {\n" + "\tSend(*$Request$) error\n" + "\tCloseAndRecv() (*$Response$, error)\n" + "\trpc.ClientStream\n" + "}\n\n"); printer->Print(*vars, + "type $ServiceStruct$$Method$Client struct {\n" + "\trpc.ClientStream\n" + "}\n\n"); + printer->Print( + *vars, "func (x *$ServiceStruct$$Method$Client) Send(m *$Request$) error {\n" "\treturn x.ClientStream.SendProto(m)\n" "}\n\n"); - printer->Print(*vars, + printer->Print( + *vars, "func (x *$ServiceStruct$$Method$Client) CloseAndRecv() (*$Response$, " "error) {\n" "\tif err := x.ClientStream.CloseSend(); err != nil {\n" @@ -264,7 +267,8 @@ void PrintClient(google::protobuf::io::Printer* printer, "type $ServiceStruct$Client struct {\n" "\tcc *rpc.ClientConn\n" "}\n\n"); - printer->Print(*vars, + printer->Print( + *vars, "func New$Service$Client(cc *rpc.ClientConn) $Service$Client {\n" "\treturn &$ServiceStruct$Client{cc}\n" "}\n\n"); @@ -280,17 +284,16 @@ void PrintServerMethodDef(google::protobuf::io::Printer* printer, (*vars)["Request"] = method->input_type()->name(); (*vars)["Response"] = method->output_type()->name(); if (NoStreaming(method)) { - printer->Print(*vars, + printer->Print( + *vars, "\t$Method$(context.Context, *$Request$) (*$Response$, error)\n"); } else if (BidiStreaming(method)) { - printer->Print(*vars, - "\t$Method$($Service$_$Method$Server) error\n"); + printer->Print(*vars, "\t$Method$($Service$_$Method$Server) error\n"); } else if (ServerOnlyStreaming(method)) { printer->Print(*vars, - "\t$Method$(*$Request$, $Service$_$Method$Server) error\n"); + "\t$Method$(*$Request$, $Service$_$Method$Server) error\n"); } else if (ClientOnlyStreaming(method)) { - printer->Print(*vars, - "\t$Method$($Service$_$Method$Server) error\n"); + printer->Print(*vars, "\t$Method$($Service$_$Method$Server) error\n"); } } @@ -301,11 +304,11 @@ void PrintServerHandler(google::protobuf::io::Printer* printer, (*vars)["Request"] = method->input_type()->name(); (*vars)["Response"] = method->output_type()->name(); if (NoStreaming(method)) { - printer->Print(*vars, + printer->Print( + *vars, "func _$Service$_$Method$_Handler(srv interface{}, ctx context.Context," " buf []byte) (proto.Message, error) {\n"); - printer->Print(*vars, - "\tin := new($Request$)\n"); + printer->Print(*vars, "\tin := new($Request$)\n"); printer->Print("\tif err := proto.Unmarshal(buf, in); err != nil {\n"); printer->Print("\t\treturn nil, err\n"); printer->Print("\t}\n"); @@ -317,27 +320,30 @@ void PrintServerHandler(google::protobuf::io::Printer* printer, printer->Print("\treturn out, nil\n"); printer->Print("}\n\n"); } else if (BidiStreaming(method)) { - printer->Print(*vars, + printer->Print( + *vars, "func _$Service$_$Method$_Handler(srv interface{}, stream rpc.Stream) " "error {\n" "\treturn srv.($Service$Server).$Method$(&$ServiceStruct$$Method$Server" "{stream})\n" "}\n\n"); printer->Print(*vars, - "type $Service$_$Method$Server interface {\n" - "\tSend(*$Response$) error\n" - "\tRecv() (*$Request$, error)\n" - "\trpc.Stream\n" - "}\n\n"); - printer->Print(*vars, - "type $ServiceStruct$$Method$Server struct {\n" - "\trpc.Stream\n" - "}\n\n"); + "type $Service$_$Method$Server interface {\n" + "\tSend(*$Response$) error\n" + "\tRecv() (*$Request$, error)\n" + "\trpc.Stream\n" + "}\n\n"); printer->Print(*vars, + "type $ServiceStruct$$Method$Server struct {\n" + "\trpc.Stream\n" + "}\n\n"); + printer->Print( + *vars, "func (x *$ServiceStruct$$Method$Server) Send(m *$Response$) error {\n" "\treturn x.Stream.SendProto(m)\n" "}\n\n"); - printer->Print(*vars, + printer->Print( + *vars, "func (x *$ServiceStruct$$Method$Server) Recv() (*$Request$, error) " "{\n" "\tm := new($Request$)\n" @@ -347,7 +353,8 @@ void PrintServerHandler(google::protobuf::io::Printer* printer, "\treturn m, nil\n" "}\n\n"); } else if (ServerOnlyStreaming(method)) { - printer->Print(*vars, + printer->Print( + *vars, "func _$Service$_$Method$_Handler(srv interface{}, stream rpc.Stream) " "error {\n" "\tm := new($Request$)\n" @@ -358,36 +365,39 @@ void PrintServerHandler(google::protobuf::io::Printer* printer, "&$ServiceStruct$$Method$Server{stream})\n" "}\n\n"); printer->Print(*vars, - "type $Service$_$Method$Server interface {\n" - "\tSend(*$Response$) error\n" - "\trpc.Stream\n" - "}\n\n"); - printer->Print(*vars, - "type $ServiceStruct$$Method$Server struct {\n" - "\trpc.Stream\n" - "}\n\n"); + "type $Service$_$Method$Server interface {\n" + "\tSend(*$Response$) error\n" + "\trpc.Stream\n" + "}\n\n"); printer->Print(*vars, + "type $ServiceStruct$$Method$Server struct {\n" + "\trpc.Stream\n" + "}\n\n"); + printer->Print( + *vars, "func (x *$ServiceStruct$$Method$Server) Send(m *$Response$) error {\n" "\treturn x.Stream.SendProto(m)\n" "}\n\n"); } else if (ClientOnlyStreaming(method)) { - printer->Print(*vars, + printer->Print( + *vars, "func _$Service$_$Method$_Handler(srv interface{}, stream rpc.Stream) " "error {\n" "\treturn srv.($Service$Server).$Method$(&$ServiceStruct$$Method$Server" "{stream})\n" "}\n\n"); printer->Print(*vars, - "type $Service$_$Method$Server interface {\n" - "\tSendAndClose(*$Response$) error\n" - "\tRecv() (*$Request$, error)\n" - "\trpc.Stream\n" - "}\n\n"); - printer->Print(*vars, - "type $ServiceStruct$$Method$Server struct {\n" - "\trpc.Stream\n" - "}\n\n"); + "type $Service$_$Method$Server interface {\n" + "\tSendAndClose(*$Response$) error\n" + "\tRecv() (*$Request$, error)\n" + "\trpc.Stream\n" + "}\n\n"); printer->Print(*vars, + "type $ServiceStruct$$Method$Server struct {\n" + "\trpc.Stream\n" + "}\n\n"); + printer->Print( + *vars, "func (x *$ServiceStruct$$Method$Server) SendAndClose(m *$Response$) " "error {\n" "\tif err := x.Stream.SendProto(m); err != nil {\n" @@ -395,7 +405,8 @@ void PrintServerHandler(google::protobuf::io::Printer* printer, "\t}\n" "\treturn nil\n" "}\n\n"); - printer->Print(*vars, + printer->Print( + *vars, "func (x *$ServiceStruct$$Method$Server) Recv() (*$Request$, error) {\n" "\tm := new($Request$)\n" "\tif err := x.Stream.RecvProto(m); err != nil {\n" @@ -411,22 +422,19 @@ void PrintServerMethodDesc(google::protobuf::io::Printer* printer, map<string, string>* vars) { (*vars)["Method"] = method->name(); printer->Print("\t\t{\n"); - printer->Print(*vars, - "\t\t\tMethodName:\t\"$Method$\",\n"); - printer->Print(*vars, - "\t\t\tHandler:\t_$Service$_$Method$_Handler,\n"); + printer->Print(*vars, "\t\t\tMethodName:\t\"$Method$\",\n"); + printer->Print(*vars, "\t\t\tHandler:\t_$Service$_$Method$_Handler,\n"); printer->Print("\t\t},\n"); } -void PrintServerStreamingMethodDesc(google::protobuf::io::Printer* printer, - const google::protobuf::MethodDescriptor* method, - map<string, string>* vars) { +void PrintServerStreamingMethodDesc( + google::protobuf::io::Printer* printer, + const google::protobuf::MethodDescriptor* method, + map<string, string>* vars) { (*vars)["Method"] = method->name(); printer->Print("\t\t{\n"); - printer->Print(*vars, - "\t\t\tStreamName:\t\"$Method$\",\n"); - printer->Print(*vars, - "\t\t\tHandler:\t_$Service$_$Method$_Handler,\n"); + printer->Print(*vars, "\t\t\tStreamName:\t\"$Method$\",\n"); + printer->Print(*vars, "\t\t\tHandler:\t_$Service$_$Method$_Handler,\n"); printer->Print("\t\t},\n"); } @@ -467,8 +475,9 @@ void PrintServer(google::protobuf::io::Printer* printer, PrintServerStreamingMethodDesc(printer, service->method(i), vars); } } - printer->Print("\t},\n" - "}\n\n"); + printer->Print( + "\t},\n" + "}\n\n"); } std::string BadToUnderscore(std::string str) { @@ -493,8 +502,9 @@ string GetServices(const google::protobuf::FileDescriptor* file) { printer.Print(vars, "package $PackageName$\n\n"); printer.Print("import (\n"); if (HasClientOnlyStreaming(file)) { - printer.Print("\t\"fmt\"\n" - "\t\"io\"\n"); + printer.Print( + "\t\"fmt\"\n" + "\t\"io\"\n"); } printer.Print( "\t\"google/net/grpc/go/rpc\"\n" diff --git a/src/compiler/go_plugin.cc b/src/compiler/go_plugin.cc index f941840815..c81612c0ab 100644 --- a/src/compiler/go_plugin.cc +++ b/src/compiler/go_plugin.cc @@ -61,8 +61,8 @@ class GoGrpcGenerator : public google::protobuf::compiler::CodeGenerator { string file_name; if (file->name().size() > 6 && file->name().find_last_of(".proto") == file->name().size() - 1) { - file_name = file->name().substr(0, file->name().size() - 6) + - "_grpc.pb.go"; + file_name = + file->name().substr(0, file->name().size() - 6) + "_grpc.pb.go"; } else { *error = "Invalid proto file name. Proto file must end with .proto"; return false; diff --git a/src/compiler/ruby_generator.cc b/src/compiler/ruby_generator.cc index 20485b47a5..fae8858ff7 100644 --- a/src/compiler/ruby_generator.cc +++ b/src/compiler/ruby_generator.cc @@ -67,9 +67,8 @@ void PrintMethod(const MethodDescriptor* method, const string& package, output_type = "stream(" + output_type + ")"; } map<string, string> method_vars = ListToDict({ - "mth.name", method->name(), - "input.type", input_type, - "output.type", output_type, + "mth.name", method->name(), "input.type", input_type, "output.type", + output_type, }); out->Print(method_vars, "rpc :$mth.name$, $input.type$, $output.type$\n"); } @@ -105,8 +104,7 @@ void PrintService(const ServiceDescriptor* service, const string& package, out->Print("self.marshal_class_method = :encode\n"); out->Print("self.unmarshal_class_method = :decode\n"); map<string, string> pkg_vars = ListToDict({ - "service.name", service->name(), - "pkg.name", package, + "service.name", service->name(), "pkg.name", package, }); out->Print(pkg_vars, "self.service_name = '$pkg.name$.$service.name$'\n"); out->Print("\n"); @@ -139,9 +137,8 @@ string GetServices(const FileDescriptor* file) { // Write out a file header. map<string, 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, "# Source: $file.name$ for package '$file.package$'\n"); diff --git a/src/compiler/ruby_generator_helpers-inl.h b/src/compiler/ruby_generator_helpers-inl.h index 67a5eedd09..8263e353b2 100644 --- a/src/compiler/ruby_generator_helpers-inl.h +++ b/src/compiler/ruby_generator_helpers-inl.h @@ -47,8 +47,9 @@ inline bool ServicesFilename(const google::protobuf::FileDescriptor* file, static const unsigned proto_suffix_length = 6; // length of ".proto" if (file->name().size() > proto_suffix_length && file->name().find_last_of(".proto") == file->name().size() - 1) { - *file_name_or_error = file->name().substr( - 0, file->name().size() - proto_suffix_length) + "_services.rb"; + *file_name_or_error = + file->name().substr(0, file->name().size() - proto_suffix_length) + + "_services.rb"; return true; } else { *file_name_or_error = "Invalid proto file name: must end with .proto"; @@ -56,7 +57,8 @@ inline bool ServicesFilename(const google::protobuf::FileDescriptor* file, } } -inline string MessagesRequireName(const google::protobuf::FileDescriptor* file) { +inline string MessagesRequireName( + const google::protobuf::FileDescriptor* file) { return Replace(file->name(), ".proto", ""); } diff --git a/src/compiler/ruby_generator_map-inl.h b/src/compiler/ruby_generator_map-inl.h index ea5050652b..fa86fbb956 100644 --- a/src/compiler/ruby_generator_map-inl.h +++ b/src/compiler/ruby_generator_map-inl.h @@ -40,7 +40,6 @@ #include <string> #include <vector> - using std::initializer_list; using std::map; using std::vector; @@ -51,11 +50,12 @@ namespace grpc_ruby_generator { // into a map of key* to value*. Is merely a readability helper for later code. inline map<string, string> ListToDict(const initializer_list<string>& values) { if (values.size() % 2 != 0) { - // MOE: insert std::cerr << "Not every 'key' has a value in `values`." << std::endl; + // MOE: insert std::cerr << "Not every 'key' has a value in `values`." + // << std::endl; } map<string, string> value_map; auto value_iter = values.begin(); - for (unsigned i = 0; i < values.size()/2; ++i) { + for (unsigned i = 0; i < values.size() / 2; ++i) { string key = *value_iter; ++value_iter; string value = *value_iter; diff --git a/src/compiler/ruby_generator_string-inl.h b/src/compiler/ruby_generator_string-inl.h index 85a76fa421..44e17a202a 100644 --- a/src/compiler/ruby_generator_string-inl.h +++ b/src/compiler/ruby_generator_string-inl.h @@ -45,7 +45,7 @@ using std::transform; namespace grpc_ruby_generator { // Split splits a string using char into elems. -inline vector<string> &Split(const string &s, char delim, +inline vector<string>& Split(const string& s, char delim, vector<string>* elems) { stringstream ss(s); string item; @@ -56,7 +56,7 @@ inline vector<string> &Split(const string &s, char delim, } // Split splits a string using char, returning the result in a vector. -inline vector<string> Split(const string &s, char delim) { +inline vector<string> Split(const string& s, char delim) { vector<string> elems; Split(s, delim, &elems); return elems; @@ -106,7 +106,7 @@ inline string CapitalizeFirst(string s) { inline string RubyTypeOf(const string& a_type, const string& package) { string res(a_type); ReplacePrefix(&res, package, ""); // remove the leading package if present - ReplacePrefix(&res, ".", ""); // remove the leading . (no package) + ReplacePrefix(&res, ".", ""); // remove the leading . (no package) if (res.find('.') == string::npos) { return res; } else { |