aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar liujisi@google.com <liujisi@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-12-03 09:12:33 +0000
committerGravatar liujisi@google.com <liujisi@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-12-03 09:12:33 +0000
commit2726e7a6ebd72eec6f66abe4ced3c88983f20b8e (patch)
treedcf88bc5537ca5b35b1bee3af5c04505b7a90c94
parent0acafda8f424bb8a5adcf77bf2d4bdb3a9661d4b (diff)
Fix issues: 166 167 172 175 181 188 192 194 195.
-rw-r--r--java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java4
-rw-r--r--m4/acx_pthread.m46
-rwxr-xr-xpython/google/protobuf/message.py3
-rw-r--r--src/Makefile.am1
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc4
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_unittest.cc16
-rw-r--r--src/google/protobuf/descriptor_database.cc4
-rw-r--r--src/google/protobuf/repeated_field.h6
-rw-r--r--src/google/protobuf/stubs/common.h15
-rw-r--r--src/google/protobuf/stubs/hash.cc41
-rw-r--r--src/google/protobuf/wire_format_lite_inl.h2
11 files changed, 35 insertions, 67 deletions
diff --git a/java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java b/java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java
index a2a7448a..7cc72e9c 100644
--- a/java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java
+++ b/java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java
@@ -38,7 +38,9 @@ package com.google.protobuf;
*/
public interface MessageLiteOrBuilder {
/**
- * Get an instance of the type with all fields set to their default values.
+ * Get an instance of the type with no fields set. Because no fields are set,
+ * all getters for singular fields will return default values and repeated
+ * fields will appear empty.
* This may or may not be a singleton. This differs from the
* {@code getDefaultInstance()} method of generated message classes in that
* this method is an abstract method of the {@code MessageLite} interface
diff --git a/m4/acx_pthread.m4 b/m4/acx_pthread.m4
index 2cf20de1..cb1a4bbe 100644
--- a/m4/acx_pthread.m4
+++ b/m4/acx_pthread.m4
@@ -272,9 +272,11 @@ if test "x$acx_pthread_ok" = xyes; then
AC_TRY_LINK(,, , [done=yes])
if test "x$done" = xyes ; then
- AC_MSG_RESULT([no])
- else
AC_MSG_RESULT([yes])
+ done="no"
+ else
+ AC_MSG_RESULT([no])
+ done="yes"
fi
fi
diff --git a/python/google/protobuf/message.py b/python/google/protobuf/message.py
index 54cf35ea..6f19f85f 100755
--- a/python/google/protobuf/message.py
+++ b/python/google/protobuf/message.py
@@ -226,6 +226,9 @@ class Message(object):
raise NotImplementedError
def HasField(self, field_name):
+ """Checks if a certain field is set for the message. Note if the
+ field_name is not defined in the message descriptor, ValueError will be
+ raised."""
raise NotImplementedError
def ClearField(self, field_name):
diff --git a/src/Makefile.am b/src/Makefile.am
index 92bbe8cc..606e857b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -81,7 +81,6 @@ libprotobuf_lite_la_LDFLAGS = -version-info 6:0:0 -export-dynamic -no-undefined
libprotobuf_lite_la_SOURCES = \
google/protobuf/stubs/common.cc \
google/protobuf/stubs/once.cc \
- google/protobuf/stubs/hash.cc \
google/protobuf/stubs/hash.h \
google/protobuf/stubs/map-util.h \
google/protobuf/stubs/stl_util-inl.h \
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 9e9849cf..1c76994b 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -781,7 +781,7 @@ bool CommandLineInterface::ParseArguments(int argc, const char* const argv[]) {
// If no --proto_path was given, use the current working directory.
if (proto_path_.empty()) {
- proto_path_.push_back(make_pair("", "."));
+ proto_path_.push_back(make_pair<string, string>("", "."));
}
// Check some errror cases.
@@ -910,7 +910,7 @@ bool CommandLineInterface::InterpretArgument(const string& name,
cerr << disk_path << ": warning: directory does not exist." << endl;
}
- proto_path_.push_back(make_pair(virtual_path, disk_path));
+ proto_path_.push_back(make_pair<string, string>(virtual_path, disk_path));
}
} else if (name == "-o" || name == "--descriptor_set_out") {
diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc
index 41ba5e43..a950583e 100644
--- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc
@@ -853,14 +853,14 @@ TEST(GeneratedEnumTest, MinAndMax) {
EXPECT_EQ(12589235, unittest::TestSparseEnum_ARRAYSIZE);
// Make sure we can take the address of _MIN, _MAX and _ARRAYSIZE.
- void* nullptr = 0; // NULL may be integer-type, not pointer-type.
- EXPECT_NE(nullptr, &unittest::TestAllTypes::NestedEnum_MIN);
- EXPECT_NE(nullptr, &unittest::TestAllTypes::NestedEnum_MAX);
- EXPECT_NE(nullptr, &unittest::TestAllTypes::NestedEnum_ARRAYSIZE);
-
- EXPECT_NE(nullptr, &unittest::ForeignEnum_MIN);
- EXPECT_NE(nullptr, &unittest::ForeignEnum_MAX);
- EXPECT_NE(nullptr, &unittest::ForeignEnum_ARRAYSIZE);
+ void* null_pointer = 0; // NULL may be integer-type, not pointer-type.
+ EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_MIN);
+ EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_MAX);
+ EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_ARRAYSIZE);
+
+ EXPECT_NE(null_pointer, &unittest::ForeignEnum_MIN);
+ EXPECT_NE(null_pointer, &unittest::ForeignEnum_MAX);
+ EXPECT_NE(null_pointer, &unittest::ForeignEnum_ARRAYSIZE);
// Make sure we can use _MIN, _MAX and _ARRAYSIZE as switch cases.
switch (unittest::SPARSE_A) {
diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc
index 95708d94..23e48a67 100644
--- a/src/google/protobuf/descriptor_database.cc
+++ b/src/google/protobuf/descriptor_database.cc
@@ -101,7 +101,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
if (iter == by_symbol_.end()) {
// Apparently the map is currently empty. Just insert and be done with it.
- by_symbol_.insert(make_pair(name, value));
+ by_symbol_.insert(typename map<string, Value>::value_type(name, value));
return true;
}
@@ -128,7 +128,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
// Insert the new symbol using the iterator as a hint, the new entry will
// appear immediately before the one the iterator is pointing at.
- by_symbol_.insert(iter, make_pair(name, value));
+ by_symbol_.insert(iter, typename map<string, Value>::value_type(name, value));
return true;
}
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h
index ae96107a..f380e7c0 100644
--- a/src/google/protobuf/repeated_field.h
+++ b/src/google/protobuf/repeated_field.h
@@ -1199,7 +1199,7 @@ template<typename T> class RepeatedFieldBackInsertIterator
}
private:
- RepeatedField<T>* const field_;
+ RepeatedField<T>* field_;
};
// A back inserter for RepeatedPtrField objects.
@@ -1230,7 +1230,7 @@ template<typename T> class RepeatedPtrFieldBackInsertIterator
}
private:
- RepeatedPtrField<T>* const field_;
+ RepeatedPtrField<T>* field_;
};
// A back inserter for RepeatedPtrFields that inserts by transfering ownership
@@ -1259,7 +1259,7 @@ template<typename T> class AllocatedRepeatedPtrFieldBackInsertIterator
}
private:
- RepeatedPtrField<T>* const field_;
+ RepeatedPtrField<T>* field_;
};
} // namespace internal
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h
index 749e6e9d..0b4df8a9 100644
--- a/src/google/protobuf/stubs/common.h
+++ b/src/google/protobuf/stubs/common.h
@@ -71,8 +71,6 @@ namespace std {}
namespace google {
namespace protobuf {
-using namespace std; // Don't do this at home, kids.
-
#undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
TypeName(const TypeName&); \
@@ -126,7 +124,7 @@ void LIBPROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion,
const char* filename);
// Converts a numeric version number to a string.
-string LIBPROTOBUF_EXPORT VersionString(int version);
+std::string LIBPROTOBUF_EXPORT VersionString(int version);
} // namespace internal
@@ -369,6 +367,7 @@ struct CompileAssert {
typedef ::google::protobuf::internal::CompileAssert<(bool(expr))> \
msg[bool(expr) ? 1 : -1]
+
// Implementation details of COMPILE_ASSERT:
//
// - COMPILE_ASSERT works by defining an array type that has -1
@@ -636,7 +635,7 @@ class LIBPROTOBUF_EXPORT LogMessage {
LogMessage(LogLevel level, const char* filename, int line);
~LogMessage();
- LogMessage& operator<<(const string& value);
+ LogMessage& operator<<(const std::string& value);
LogMessage& operator<<(const char* value);
LogMessage& operator<<(char value);
LogMessage& operator<<(int value);
@@ -652,7 +651,7 @@ class LIBPROTOBUF_EXPORT LogMessage {
LogLevel level_;
const char* filename_;
int line_;
- string message_;
+ std::string message_;
};
// Used to make the entire "LOG(BLAH) << etc." expression have a void return
@@ -731,7 +730,7 @@ class LIBPROTOBUF_EXPORT LogFinisher {
#endif // !NDEBUG
typedef void LogHandler(LogLevel level, const char* filename, int line,
- const string& message);
+ const std::string& message);
// The protobuf library sometimes writes warning and error messages to
// stderr. These messages are primarily useful for developers, but may
@@ -1173,6 +1172,10 @@ LIBPROTOBUF_EXPORT void OnShutdown(void (*func)());
} // namespace internal
+// This is at the end of the file instead of the beginning to work around a bug
+// in some versions of MSVC.
+using namespace std; // Don't do this at home, kids.
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/stubs/hash.cc b/src/google/protobuf/stubs/hash.cc
deleted file mode 100644
index 9eaf4a1e..00000000
--- a/src/google/protobuf/stubs/hash.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Author: kenton@google.com (Kenton Varda)
-
-#include <google/protobuf/stubs/hash.h>
-
-namespace google {
-namespace protobuf {
-
-// Nothing needed here right now.
-
-} // namespace protobuf
-} // namespace google
diff --git a/src/google/protobuf/wire_format_lite_inl.h b/src/google/protobuf/wire_format_lite_inl.h
index a461a6ca..103b0bd0 100644
--- a/src/google/protobuf/wire_format_lite_inl.h
+++ b/src/google/protobuf/wire_format_lite_inl.h
@@ -222,7 +222,7 @@ inline const uint8* WireFormatLite::ReadPrimitiveFromArray<
}
template <typename CType, enum WireFormatLite::FieldType DeclaredType>
-inline bool WireFormatLite::ReadRepeatedPrimitive(int tag_size,
+inline bool WireFormatLite::ReadRepeatedPrimitive(int, // tag_size, unused.
uint32 tag,
io::CodedInputStream* input,
RepeatedField<CType>* values) {