diff options
author | xiaofeng@google.com <xiaofeng@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2012-11-30 16:29:03 +0000 |
---|---|---|
committer | xiaofeng@google.com <xiaofeng@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2012-11-30 16:29:03 +0000 |
commit | 9c1c31ff165fceb76a0ec50cd7097038264c6908 (patch) | |
tree | fedeb0fa7ce102cc9037fe1822adc1620e2cdbf2 | |
parent | d2d50f9a73184ea77e7b907b7767a6f4c8c8d4bf (diff) | |
download | protobuf-9c1c31ff165fceb76a0ec50cd7097038264c6908.tar.gz protobuf-9c1c31ff165fceb76a0ec50cd7097038264c6908.tar.bz2 protobuf-9c1c31ff165fceb76a0ec50cd7097038264c6908.zip |
Fix compile issues under GCC 3.4.6
-rw-r--r-- | src/google/protobuf/repeated_field_reflection_unittest.cc | 4 | ||||
-rw-r--r-- | src/google/protobuf/stubs/common.h | 6 | ||||
-rw-r--r-- | src/google/protobuf/text_format.cc | 6 | ||||
-rw-r--r-- | src/google/protobuf/text_format.h | 21 |
4 files changed, 26 insertions, 11 deletions
diff --git a/src/google/protobuf/repeated_field_reflection_unittest.cc b/src/google/protobuf/repeated_field_reflection_unittest.cc index 5fcfb007..6924ae89 100644 --- a/src/google/protobuf/repeated_field_reflection_unittest.cc +++ b/src/google/protobuf/repeated_field_reflection_unittest.cc @@ -120,7 +120,7 @@ TEST(RepeatedFieldReflectionTest, RegularFields) { EXPECT_EQ(rf_double.Get(i), Func(i, 2)); EXPECT_EQ(rpf_string.Get(i), StrFunc(i, 5)); EXPECT_EQ(rpf_foreign_message.Get(i).c(), Func(i, 6)); - EXPECT_EQ(down_cast<const ForeignMessage&>(rpf_message.Get(i)).c(), + EXPECT_EQ(down_cast<const ForeignMessage*>(&rpf_message.Get(i))->c(), Func(i, 6)); // Check gets through mutable objects. @@ -128,7 +128,7 @@ TEST(RepeatedFieldReflectionTest, RegularFields) { EXPECT_EQ(mrf_double->Get(i), Func(i, 2)); EXPECT_EQ(mrpf_string->Get(i), StrFunc(i, 5)); EXPECT_EQ(mrpf_foreign_message->Get(i).c(), Func(i, 6)); - EXPECT_EQ(down_cast<const ForeignMessage&>(mrpf_message->Get(i)).c(), + EXPECT_EQ(down_cast<const ForeignMessage*>(&mrpf_message->Get(i))->c(), Func(i, 6)); // Check sets through mutable objects. diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 07ae5307..66b91291 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -341,12 +341,6 @@ inline To down_cast(From* f) { // so we only accept pointers return static_cast<To>(f); } -// Simplified down_cast for reference type. -template<typename To, typename From> -inline To down_cast(From& f) { - return static_cast<To>(f); -} - } // namespace internal // We made these internal so that they would show up as such in the docs, diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 1ee3df50..cabb99ed 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -434,8 +434,8 @@ class TextFormat::Parser::ParserImpl { // If a parse info tree exists, add the location for the parsed // field. if (parse_info_tree_ != NULL) { - parse_info_tree_->RecordLocation(field, - ParseLocation(start_line, start_column)); + RecordLocation(parse_info_tree_, field, + ParseLocation(start_line, start_column)); } return true; @@ -483,7 +483,7 @@ class TextFormat::Parser::ParserImpl { // for the nested message. ParseInfoTree* parent = parse_info_tree_; if (parent != NULL) { - parse_info_tree_ = parent->CreateNested(field); + parse_info_tree_ = CreateNested(parent, field); } string delimeter; diff --git a/src/google/protobuf/text_format.h b/src/google/protobuf/text_format.h index 09741397..01f3ffb0 100644 --- a/src/google/protobuf/text_format.h +++ b/src/google/protobuf/text_format.h @@ -339,9 +339,30 @@ class LIBPROTOBUF_EXPORT TextFormat { }; private: + // Hack: ParseInfoTree declares TextFormat as a friend which should extend + // the friendship to TextFormat::Parser::ParserImpl, but unfortunately some + // old compilers (e.g. GCC 3.4.6) don't implement this correctly. We provide + // helpers for ParserImpl to call methods of ParseInfoTree. + static inline void RecordLocation(ParseInfoTree* info_tree, + const FieldDescriptor* field, + ParseLocation location); + static inline ParseInfoTree* CreateNested(ParseInfoTree* info_tree, + const FieldDescriptor* field); + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormat); }; +inline void TextFormat::RecordLocation(ParseInfoTree* info_tree, + const FieldDescriptor* field, + ParseLocation location) { + info_tree->RecordLocation(field, location); +} + +inline TextFormat::ParseInfoTree* TextFormat::CreateNested( + ParseInfoTree* info_tree, const FieldDescriptor* field) { + return info_tree->CreateNested(field); +} + } // namespace protobuf } // namespace google |