diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2015-07-20 11:06:17 -0700 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2015-07-20 11:06:17 -0700 |
commit | aba42edd8c3c5ae4edeebdacd1a3b4192bd5550f (patch) | |
tree | b6f22f84e6109a51b59bf8092e36b69dbe9c6e49 /src | |
parent | 58035596e7864c66008a1f6222dce54031610ff4 (diff) | |
parent | c2c43a4917d7da263e360a4096d6603da8535bdf (diff) | |
download | protobuf-aba42edd8c3c5ae4edeebdacd1a3b4192bd5550f.tar.gz protobuf-aba42edd8c3c5ae4edeebdacd1a3b4192bd5550f.tar.bz2 protobuf-aba42edd8c3c5ae4edeebdacd1a3b4192bd5550f.zip |
Merge pull request #604 from haberman/ruby-conformance
Added Ruby to conformance tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/ruby/ruby_generated_code.rb | 6 | ||||
-rw-r--r-- | src/google/protobuf/compiler/ruby/ruby_generator.cc | 34 |
2 files changed, 24 insertions, 16 deletions
diff --git a/src/google/protobuf/compiler/ruby/ruby_generated_code.rb b/src/google/protobuf/compiler/ruby/ruby_generated_code.rb index 100d6fa7..49b23fbe 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generated_code.rb +++ b/src/google/protobuf/compiler/ruby/ruby_generated_code.rb @@ -13,7 +13,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do optional :optional_double, :double, 6 optional :optional_float, :float, 7 optional :optional_string, :string, 8 - optional :optional_bytes, :string, 9 + optional :optional_bytes, :bytes, 9 optional :optional_enum, :enum, 10, "A.B.C.TestEnum" optional :optional_msg, :message, 11, "A.B.C.TestMessage" repeated :repeated_int32, :int32, 21 @@ -24,7 +24,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do repeated :repeated_double, :double, 26 repeated :repeated_float, :float, 27 repeated :repeated_string, :string, 28 - repeated :repeated_bytes, :string, 29 + repeated :repeated_bytes, :bytes, 29 repeated :repeated_enum, :enum, 30, "A.B.C.TestEnum" repeated :repeated_msg, :message, 31, "A.B.C.TestMessage" map :map_int32_string, :int32, :string, 61 @@ -47,7 +47,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do optional :oneof_double, :double, 46 optional :oneof_float, :float, 47 optional :oneof_string, :string, 48 - optional :oneof_bytes, :string, 49 + optional :oneof_bytes, :bytes, 49 optional :oneof_enum, :enum, 50, "A.B.C.TestEnum" optional :oneof_msg, :message, 51, "A.B.C.TestMessage" end diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.cc b/src/google/protobuf/compiler/ruby/ruby_generator.cc index a9b6837e..9692f1bf 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generator.cc +++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc @@ -47,7 +47,7 @@ namespace compiler { namespace ruby { // Forward decls. -std::string IntToString(uint32 value); +std::string IntToString(int32 value); std::string StripDotProto(const std::string& proto_file); std::string LabelForField(google::protobuf::FieldDescriptor* field); std::string TypeName(google::protobuf::FieldDescriptor* field); @@ -64,7 +64,7 @@ void GenerateEnumAssignment( const google::protobuf::EnumDescriptor* en, google::protobuf::io::Printer* printer); -std::string IntToString(uint32 value) { +std::string IntToString(int32 value) { std::ostringstream os; os << value; return os.str(); @@ -85,17 +85,25 @@ std::string LabelForField(const google::protobuf::FieldDescriptor* field) { } std::string TypeName(const google::protobuf::FieldDescriptor* field) { - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: return "int32"; - case FieldDescriptor::CPPTYPE_INT64: return "int64"; - case FieldDescriptor::CPPTYPE_UINT32: return "uint32"; - case FieldDescriptor::CPPTYPE_UINT64: return "uint64"; - case FieldDescriptor::CPPTYPE_DOUBLE: return "double"; - case FieldDescriptor::CPPTYPE_FLOAT: return "float"; - case FieldDescriptor::CPPTYPE_BOOL: return "bool"; - case FieldDescriptor::CPPTYPE_ENUM: return "enum"; - case FieldDescriptor::CPPTYPE_STRING: return "string"; - case FieldDescriptor::CPPTYPE_MESSAGE: return "message"; + switch (field->type()) { + case FieldDescriptor::TYPE_INT32: return "int32"; + case FieldDescriptor::TYPE_INT64: return "int64"; + case FieldDescriptor::TYPE_UINT32: return "uint32"; + case FieldDescriptor::TYPE_UINT64: return "uint64"; + case FieldDescriptor::TYPE_SINT32: return "sint32"; + case FieldDescriptor::TYPE_SINT64: return "sint64"; + case FieldDescriptor::TYPE_FIXED32: return "fixed32"; + case FieldDescriptor::TYPE_FIXED64: return "fixed64"; + case FieldDescriptor::TYPE_SFIXED32: return "sfixed32"; + case FieldDescriptor::TYPE_SFIXED64: return "sfixed64"; + case FieldDescriptor::TYPE_DOUBLE: return "double"; + case FieldDescriptor::TYPE_FLOAT: return "float"; + case FieldDescriptor::TYPE_BOOL: return "bool"; + case FieldDescriptor::TYPE_ENUM: return "enum"; + case FieldDescriptor::TYPE_STRING: return "string"; + case FieldDescriptor::TYPE_BYTES: return "bytes"; + case FieldDescriptor::TYPE_MESSAGE: return "message"; + case FieldDescriptor::TYPE_GROUP: return "group"; default: assert(false); return ""; } } |