diff options
Diffstat (limited to 'src/compiler/ruby_generator.cc')
-rw-r--r-- | src/compiler/ruby_generator.cc | 34 |
1 files changed, 22 insertions, 12 deletions
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(); |