Lines Matching +full:out +full:- +full:file
6 * you may not use this file except in compliance with the License.
9 * http://www.apache.org/licenses/LICENSE-2.0
26 #include "src/compiler/ruby_generator_helpers-inl.h"
27 #include "src/compiler/ruby_generator_map-inl.h"
28 #include "src/compiler/ruby_generator_string-inl.h"
41 // Prints out the method using the ruby gRPC DSL.
42 void PrintMethod(const MethodDescriptor* method, Printer* out) { in PrintMethod() argument
43 std::string input_type = RubyTypeOf(method->input_type()); in PrintMethod()
44 if (method->client_streaming()) { in PrintMethod()
47 std::string output_type = RubyTypeOf(method->output_type()); in PrintMethod()
48 if (method->server_streaming()) { in PrintMethod()
53 method->name(), in PrintMethod()
59 out->Print(GetRubyComments(method, true).c_str()); in PrintMethod()
60 out->Print(method_vars, "rpc :$mth.name$, $input.type$, $output.type$\n"); in PrintMethod()
61 out->Print(GetRubyComments(method, false).c_str()); in PrintMethod()
64 // Prints out the service using the ruby gRPC DSL.
65 void PrintService(const ServiceDescriptor* service, Printer* out) { in PrintService() argument
66 if (service->method_count() == 0) { in PrintService()
73 Modularize(service->name()), in PrintService()
75 out->Print(module_vars, "module $module.name$\n"); in PrintService()
76 out->Indent(); in PrintService()
78 out->Print(GetRubyComments(service, true).c_str()); in PrintService()
79 out->Print("class Service\n"); in PrintService()
82 out->Indent(); in PrintService()
83 out->Print("\n"); in PrintService()
84 out->Print("include ::GRPC::GenericService\n"); in PrintService()
85 out->Print("\n"); in PrintService()
86 out->Print("self.marshal_class_method = :encode\n"); in PrintService()
87 out->Print("self.unmarshal_class_method = :decode\n"); in PrintService()
89 ListToDict({"service_full_name", service->full_name()}); in PrintService()
90 out->Print(pkg_vars, "self.service_name = '$service_full_name$'\n"); in PrintService()
91 out->Print("\n"); in PrintService()
92 for (int i = 0; i < service->method_count(); ++i) { in PrintService()
93 PrintMethod(service->method(i), out); in PrintService()
95 out->Outdent(); in PrintService()
97 out->Print("end\n"); in PrintService()
98 out->Print("\n"); in PrintService()
99 out->Print("Stub = Service.rpc_stub_class\n"); in PrintService()
102 out->Outdent(); in PrintService()
103 out->Print("end\n"); in PrintService()
104 out->Print(GetRubyComments(service, false).c_str()); in PrintService()
117 // Locale-agnostic utility functions.
124 char UpperChar(char ch) { return IsLower(ch) ? (ch - 'a' + 'A') : ch; } in UpperChar()
129 // foo_bar_baz -> FooBarBaz
154 // an upper-case letter.
166 // well-known suffix. in RubifyConstant()
175 std::string GetServices(const FileDescriptor* file) { in GetServices() argument
181 Printer out(&output_stream, '$'); in GetServices() local
183 // Don't write out any output if there no services, to avoid empty service in GetServices()
185 if (file->service_count() == 0) { in GetServices()
189 std::string package_name = RubyPackage(file); in GetServices()
191 // Write out a file header. in GetServices()
193 "file.name", in GetServices()
194 file->name(), in GetServices()
195 "file.package", in GetServices()
198 out.Print("# Generated by the protocol buffer compiler. DO NOT EDIT!\n"); in GetServices()
199 out.Print(header_comment_vars, in GetServices()
200 "# Source: $file.name$ for package '$file.package$'\n"); in GetServices()
202 std::string leading_comments = GetRubyComments(file, true); in GetServices()
204 out.Print("# Original file comments:\n"); in GetServices()
205 out.PrintRaw(leading_comments.c_str()); in GetServices()
208 out.Print("\n"); in GetServices()
209 out.Print("require 'grpc'\n"); in GetServices()
210 // Write out require statemment to import the separately generated file in GetServices()
215 MessagesRequireName(file), in GetServices()
217 out.Print(dep_vars, "require '$dep.name$'\n"); in GetServices()
219 // Write out services within the modules in GetServices()
220 out.Print("\n"); in GetServices()
227 out.Print(module_vars, "module $module.name$\n"); in GetServices()
228 out.Indent(); in GetServices()
230 for (int i = 0; i < file->service_count(); ++i) { in GetServices()
231 auto service = file->service(i); in GetServices()
232 PrintService(service, &out); in GetServices()
235 out.Outdent(); in GetServices()
236 out.Print("end\n"); in GetServices()
239 out.Print(GetRubyComments(file, false).c_str()); in GetServices()