Commit 2726e7a6 authored by liujisi@google.com's avatar liujisi@google.com

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

parent 0acafda8
...@@ -38,7 +38,9 @@ package com.google.protobuf; ...@@ -38,7 +38,9 @@ package com.google.protobuf;
*/ */
public interface MessageLiteOrBuilder { 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 * This may or may not be a singleton. This differs from the
* {@code getDefaultInstance()} method of generated message classes in that * {@code getDefaultInstance()} method of generated message classes in that
* this method is an abstract method of the {@code MessageLite} interface * this method is an abstract method of the {@code MessageLite} interface
......
...@@ -272,9 +272,11 @@ if test "x$acx_pthread_ok" = xyes; then ...@@ -272,9 +272,11 @@ if test "x$acx_pthread_ok" = xyes; then
AC_TRY_LINK(,, , [done=yes]) AC_TRY_LINK(,, , [done=yes])
if test "x$done" = xyes ; then if test "x$done" = xyes ; then
AC_MSG_RESULT([no])
else
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
done="no"
else
AC_MSG_RESULT([no])
done="yes"
fi fi
fi fi
......
...@@ -226,6 +226,9 @@ class Message(object): ...@@ -226,6 +226,9 @@ class Message(object):
raise NotImplementedError raise NotImplementedError
def HasField(self, field_name): 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 raise NotImplementedError
def ClearField(self, field_name): def ClearField(self, field_name):
......
...@@ -81,7 +81,6 @@ libprotobuf_lite_la_LDFLAGS = -version-info 6:0:0 -export-dynamic -no-undefined ...@@ -81,7 +81,6 @@ libprotobuf_lite_la_LDFLAGS = -version-info 6:0:0 -export-dynamic -no-undefined
libprotobuf_lite_la_SOURCES = \ libprotobuf_lite_la_SOURCES = \
google/protobuf/stubs/common.cc \ google/protobuf/stubs/common.cc \
google/protobuf/stubs/once.cc \ google/protobuf/stubs/once.cc \
google/protobuf/stubs/hash.cc \
google/protobuf/stubs/hash.h \ google/protobuf/stubs/hash.h \
google/protobuf/stubs/map-util.h \ google/protobuf/stubs/map-util.h \
google/protobuf/stubs/stl_util-inl.h \ google/protobuf/stubs/stl_util-inl.h \
......
...@@ -781,7 +781,7 @@ bool CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { ...@@ -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 no --proto_path was given, use the current working directory.
if (proto_path_.empty()) { if (proto_path_.empty()) {
proto_path_.push_back(make_pair("", ".")); proto_path_.push_back(make_pair<string, string>("", "."));
} }
// Check some errror cases. // Check some errror cases.
...@@ -910,7 +910,7 @@ bool CommandLineInterface::InterpretArgument(const string& name, ...@@ -910,7 +910,7 @@ bool CommandLineInterface::InterpretArgument(const string& name,
cerr << disk_path << ": warning: directory does not exist." << endl; 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") { } else if (name == "-o" || name == "--descriptor_set_out") {
......
...@@ -853,14 +853,14 @@ TEST(GeneratedEnumTest, MinAndMax) { ...@@ -853,14 +853,14 @@ TEST(GeneratedEnumTest, MinAndMax) {
EXPECT_EQ(12589235, unittest::TestSparseEnum_ARRAYSIZE); EXPECT_EQ(12589235, unittest::TestSparseEnum_ARRAYSIZE);
// Make sure we can take the address of _MIN, _MAX and _ARRAYSIZE. // Make sure we can take the address of _MIN, _MAX and _ARRAYSIZE.
void* nullptr = 0; // NULL may be integer-type, not pointer-type. void* null_pointer = 0; // NULL may be integer-type, not pointer-type.
EXPECT_NE(nullptr, &unittest::TestAllTypes::NestedEnum_MIN); EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_MIN);
EXPECT_NE(nullptr, &unittest::TestAllTypes::NestedEnum_MAX); EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_MAX);
EXPECT_NE(nullptr, &unittest::TestAllTypes::NestedEnum_ARRAYSIZE); EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_ARRAYSIZE);
EXPECT_NE(nullptr, &unittest::ForeignEnum_MIN); EXPECT_NE(null_pointer, &unittest::ForeignEnum_MIN);
EXPECT_NE(nullptr, &unittest::ForeignEnum_MAX); EXPECT_NE(null_pointer, &unittest::ForeignEnum_MAX);
EXPECT_NE(nullptr, &unittest::ForeignEnum_ARRAYSIZE); EXPECT_NE(null_pointer, &unittest::ForeignEnum_ARRAYSIZE);
// Make sure we can use _MIN, _MAX and _ARRAYSIZE as switch cases. // Make sure we can use _MIN, _MAX and _ARRAYSIZE as switch cases.
switch (unittest::SPARSE_A) { switch (unittest::SPARSE_A) {
......
...@@ -101,7 +101,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol( ...@@ -101,7 +101,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
if (iter == by_symbol_.end()) { if (iter == by_symbol_.end()) {
// Apparently the map is currently empty. Just insert and be done with it. // 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; return true;
} }
...@@ -128,7 +128,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol( ...@@ -128,7 +128,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
// Insert the new symbol using the iterator as a hint, the new entry will // Insert the new symbol using the iterator as a hint, the new entry will
// appear immediately before the one the iterator is pointing at. // 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; return true;
} }
......
...@@ -1199,7 +1199,7 @@ template<typename T> class RepeatedFieldBackInsertIterator ...@@ -1199,7 +1199,7 @@ template<typename T> class RepeatedFieldBackInsertIterator
} }
private: private:
RepeatedField<T>* const field_; RepeatedField<T>* field_;
}; };
// A back inserter for RepeatedPtrField objects. // A back inserter for RepeatedPtrField objects.
...@@ -1230,7 +1230,7 @@ template<typename T> class RepeatedPtrFieldBackInsertIterator ...@@ -1230,7 +1230,7 @@ template<typename T> class RepeatedPtrFieldBackInsertIterator
} }
private: private:
RepeatedPtrField<T>* const field_; RepeatedPtrField<T>* field_;
}; };
// A back inserter for RepeatedPtrFields that inserts by transfering ownership // A back inserter for RepeatedPtrFields that inserts by transfering ownership
...@@ -1259,7 +1259,7 @@ template<typename T> class AllocatedRepeatedPtrFieldBackInsertIterator ...@@ -1259,7 +1259,7 @@ template<typename T> class AllocatedRepeatedPtrFieldBackInsertIterator
} }
private: private:
RepeatedPtrField<T>* const field_; RepeatedPtrField<T>* field_;
}; };
} // namespace internal } // namespace internal
......
...@@ -71,8 +71,6 @@ namespace std {} ...@@ -71,8 +71,6 @@ namespace std {}
namespace google { namespace google {
namespace protobuf { namespace protobuf {
using namespace std; // Don't do this at home, kids.
#undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS #undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ #define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
TypeName(const TypeName&); \ TypeName(const TypeName&); \
...@@ -126,7 +124,7 @@ void LIBPROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion, ...@@ -126,7 +124,7 @@ void LIBPROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion,
const char* filename); const char* filename);
// Converts a numeric version number to a string. // Converts a numeric version number to a string.
string LIBPROTOBUF_EXPORT VersionString(int version); std::string LIBPROTOBUF_EXPORT VersionString(int version);
} // namespace internal } // namespace internal
...@@ -369,6 +367,7 @@ struct CompileAssert { ...@@ -369,6 +367,7 @@ struct CompileAssert {
typedef ::google::protobuf::internal::CompileAssert<(bool(expr))> \ typedef ::google::protobuf::internal::CompileAssert<(bool(expr))> \
msg[bool(expr) ? 1 : -1] msg[bool(expr) ? 1 : -1]
// Implementation details of COMPILE_ASSERT: // Implementation details of COMPILE_ASSERT:
// //
// - COMPILE_ASSERT works by defining an array type that has -1 // - COMPILE_ASSERT works by defining an array type that has -1
...@@ -636,7 +635,7 @@ class LIBPROTOBUF_EXPORT LogMessage { ...@@ -636,7 +635,7 @@ class LIBPROTOBUF_EXPORT LogMessage {
LogMessage(LogLevel level, const char* filename, int line); LogMessage(LogLevel level, const char* filename, int line);
~LogMessage(); ~LogMessage();
LogMessage& operator<<(const string& value); LogMessage& operator<<(const std::string& value);
LogMessage& operator<<(const char* value); LogMessage& operator<<(const char* value);
LogMessage& operator<<(char value); LogMessage& operator<<(char value);
LogMessage& operator<<(int value); LogMessage& operator<<(int value);
...@@ -652,7 +651,7 @@ class LIBPROTOBUF_EXPORT LogMessage { ...@@ -652,7 +651,7 @@ class LIBPROTOBUF_EXPORT LogMessage {
LogLevel level_; LogLevel level_;
const char* filename_; const char* filename_;
int line_; int line_;
string message_; std::string message_;
}; };
// Used to make the entire "LOG(BLAH) << etc." expression have a void return // Used to make the entire "LOG(BLAH) << etc." expression have a void return
...@@ -731,7 +730,7 @@ class LIBPROTOBUF_EXPORT LogFinisher { ...@@ -731,7 +730,7 @@ class LIBPROTOBUF_EXPORT LogFinisher {
#endif // !NDEBUG #endif // !NDEBUG
typedef void LogHandler(LogLevel level, const char* filename, int line, 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 // The protobuf library sometimes writes warning and error messages to
// stderr. These messages are primarily useful for developers, but may // stderr. These messages are primarily useful for developers, but may
...@@ -1173,6 +1172,10 @@ LIBPROTOBUF_EXPORT void OnShutdown(void (*func)()); ...@@ -1173,6 +1172,10 @@ LIBPROTOBUF_EXPORT void OnShutdown(void (*func)());
} // namespace internal } // 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 protobuf
} // namespace google } // namespace google
......
// 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
...@@ -222,7 +222,7 @@ inline const uint8* WireFormatLite::ReadPrimitiveFromArray< ...@@ -222,7 +222,7 @@ inline const uint8* WireFormatLite::ReadPrimitiveFromArray<
} }
template <typename CType, enum WireFormatLite::FieldType DeclaredType> template <typename CType, enum WireFormatLite::FieldType DeclaredType>
inline bool WireFormatLite::ReadRepeatedPrimitive(int tag_size, inline bool WireFormatLite::ReadRepeatedPrimitive(int, // tag_size, unused.
uint32 tag, uint32 tag,
io::CodedInputStream* input, io::CodedInputStream* input,
RepeatedField<CType>* values) { RepeatedField<CType>* values) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment