Просмотр исходного кода

Fix issues: 166 167 172 175 181 188 192 194 195.

liujisi@google.com 15 лет назад
Родитель
Сommit
2726e7a6eb

+ 3 - 1
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

+ 4 - 2
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
 	

+ 3 - 0
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):

+ 0 - 1
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                         \

+ 2 - 2
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") {

+ 8 - 8
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) {

+ 2 - 2
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;
 }

+ 3 - 3
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
 

+ 9 - 6
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
 

+ 0 - 41
src/google/protobuf/stubs/hash.cc

@@ -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

+ 1 - 1
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) {