ruby: Use fully-qualified type name when necessary

- Use full_name() instead of name(), otherwise package names
  are omitted.
- Fix a minor bug on RubyTypeOf(), to replace dotted protobuf
  package name by ruby's module names correctly.
pull/6103/head
Jun Mukai 9 years ago
parent adc53ade9b
commit cac9ba4f22
  1. 4
      src/compiler/ruby_generator.cc
  2. 1
      src/compiler/ruby_generator_string-inl.h

@ -55,11 +55,11 @@ namespace {
// Prints out the method using the ruby gRPC DSL.
void PrintMethod(const MethodDescriptor *method, const grpc::string &package,
Printer *out) {
grpc::string input_type = RubyTypeOf(method->input_type()->name(), package);
grpc::string input_type = RubyTypeOf(method->input_type()->full_name(), package);
if (method->client_streaming()) {
input_type = "stream(" + input_type + ")";
}
grpc::string output_type = RubyTypeOf(method->output_type()->name(), package);
grpc::string output_type = RubyTypeOf(method->output_type()->full_name(), package);
if (method->server_streaming()) {
output_type = "stream(" + output_type + ")";
}

@ -115,6 +115,7 @@ inline grpc::string RubyTypeOf(const grpc::string &a_type,
return res;
} else {
std::vector<grpc::string> prefixes_and_type = Split(res, '.');
res.clear();
for (unsigned int i = 0; i < prefixes_and_type.size(); ++i) {
if (i != 0) {
res += "::"; // switch '.' to the ruby module delim

Loading…
Cancel
Save