diff options
Diffstat (limited to 'src/google')
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_message.cc | 6 | ||||
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_unittest.cc | 6 | ||||
-rw-r--r-- | src/google/protobuf/repeated_field.h | 2 | ||||
-rw-r--r-- | src/google/protobuf/stubs/port.h | 7 | ||||
-rw-r--r-- | src/google/protobuf/util/internal/protostream_objectwriter.cc | 4 | ||||
-rw-r--r-- | src/google/protobuf/util/json_util_test.cc | 11 |
6 files changed, 24 insertions, 12 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index aa10b0bb..fc1ce962 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -2536,13 +2536,7 @@ GenerateOneofClear(io::Printer* printer) { printer->Print(oneof_vars, "void $classname$::clear_$oneofname$() {\n"); printer->Indent(); - // In .proto.h mode, fields with a dependent type will generate - // clearing code that down casts from the dependent base class. - // However, clear_oneof() methods are always in the .cc file, and thus - // must remain in the derived base. So, to make the clearing code work, - // we add a typedef so that the down cast works (it will be a no-op). printer->Print(oneof_vars, - "typedef $classname$ T;\n" "switch($oneofname$_case()) {\n"); printer->Indent(); for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc index 7840cfaf..b7b6039a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc @@ -55,7 +55,9 @@ #include <google/protobuf/unittest.pb.h> #include <google/protobuf/unittest_optimize_for.pb.h> #include <google/protobuf/unittest_embed_optimize_for.pb.h> -#if !defined(_MSC_VER) // Too large for visual studio to compile +#if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER) +// We exclude this large proto from cmake build because it's too large for +// visual studio to compile (report internal errors). #include <google/protobuf/unittest_enormous_descriptor.pb.h> #endif #include <google/protobuf/unittest_no_generic_services.pb.h> @@ -135,7 +137,7 @@ TEST(GeneratedDescriptorTest, IdenticalDescriptors) { generated_decsriptor_proto.DebugString()); } -#if !defined(_MSC_VER) +#if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER) // Test that generated code has proper descriptors: // Touch a descriptor generated from an enormous message to validate special // handling for descriptors exceeding the C++ standard's recommended minimum diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index b42d4790..137b29be 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -1223,7 +1223,7 @@ void RepeatedField<Element>::Reserve(int new_size) { Arena* arena = GetArenaNoVirtual(); new_size = max(google::protobuf::internal::kMinRepeatedFieldAllocationSize, max(total_size_ * 2, new_size)); - GOOGLE_CHECK_LE(new_size, + GOOGLE_CHECK_LE(static_cast<size_t>(new_size), (std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(Element)) << "Requested size is too large to fit into size_t."; diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 5158a6f9..9ea34cde 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -45,12 +45,15 @@ #endif #undef PROTOBUF_LITTLE_ENDIAN -#ifdef _MSC_VER +#ifdef _WIN32 // Assuming windows is always little-endian. + // TODO(xiaofeng): The PROTOBUF_LITTLE_ENDIAN is not only used for + // optimization but also for correctness. We should define an + // different macro to test the big-endian code path in coded_stream. #if !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) #define PROTOBUF_LITTLE_ENDIAN 1 #endif - #if _MSC_VER >= 1300 + #if defined(_MSC_VER) && _MSC_VER >= 1300 // If MSVC has "/RTCc" set, it will complain about truncating casts at // runtime. This file contains some intentional truncating casts. #pragma runtime_checks("c", off) diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index 28779301..a935ac39 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc @@ -1602,8 +1602,10 @@ bool ProtoStreamObjectWriter::IsMap(const google::protobuf::Field& field) { const google::protobuf::Type* field_type = typeinfo_->GetTypeByTypeUrl(field.type_url()); + // TODO(xiaofeng): Unify option names. return GetBoolOptionOrDefault(field_type->options(), - "google.protobuf.MessageOptions.map_entry", false); + "google.protobuf.MessageOptions.map_entry", false) || + GetBoolOptionOrDefault(field_type->options(), "map_entry", false); } void ProtoStreamObjectWriter::WriteTag(const google::protobuf::Field& field) { diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 7f88e672..f4dc3562 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -47,6 +47,7 @@ namespace { using proto3::FOO; using proto3::BAR; using proto3::TestMessage; +using proto3::TestMap; static const char kTypeUrlPrefix[] = "type.googleapis.com"; @@ -147,6 +148,16 @@ TEST_F(JsonUtilTest, ParseMessage) { EXPECT_EQ(96, m.repeated_message_value(1).value()); } +TEST_F(JsonUtilTest, ParseMap) { + TestMap message; + (*message.mutable_string_map())["hello"] = 1234; + JsonOptions options; + EXPECT_EQ("{\"stringMap\":{\"hello\":1234}}", ToJson(message, options)); + TestMap other; + ASSERT_TRUE(FromJson(ToJson(message, options), &other)); + EXPECT_EQ(message.DebugString(), other.DebugString()); +} + typedef pair<char*, int> Segment; // A ZeroCopyOutputStream that writes to multiple buffers. class SegmentedZeroCopyOutputStream : public io::ZeroCopyOutputStream { |