From 81a630c66e23ef513a7cb585ea203bff11cc4167 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 3 Dec 2014 11:52:21 -0800 Subject: Update version number to v3.0.0-alpha-1 --- configure.ac | 2 +- java/pom.xml | 4 ++-- python/setup.py | 2 +- src/Makefile.am | 6 +++--- src/google/protobuf/stubs/common.h | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 034d0cdb..418889dc 100644 --- a/configure.ac +++ b/configure.ac @@ -12,7 +12,7 @@ AC_PREREQ(2.59) # In the SVN trunk, the version should always be the next anticipated release # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[2.6.2-pre],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.0.0-alpha-1],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/java/pom.xml b/java/pom.xml index 4ec6d776..bc339f66 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -10,7 +10,7 @@ com.google.protobuf protobuf-java - 2.6.2-pre + 3.0.0-alpha-1 bundle Protocol Buffer Java API @@ -152,7 +152,7 @@ https://developers.google.com/protocol-buffers/ com.google.protobuf - com.google.protobuf;version=2.6.2-pre + com.google.protobuf;version=3.0.0-alpha-1 diff --git a/python/setup.py b/python/setup.py index 69ffcd1d..e4120208 100755 --- a/python/setup.py +++ b/python/setup.py @@ -163,7 +163,7 @@ if __name__ == '__main__': )) setup(name = 'protobuf', - version = '2.6.2-pre', + version = '3.0.0-alpha-1', packages = [ 'google' ], namespace_packages = [ 'google' ], test_suite = 'setup.MakeTestSuite', diff --git a/src/Makefile.am b/src/Makefile.am index b88e32ea..b1fb1244 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -111,7 +111,7 @@ nobase_include_HEADERS = \ lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS) -libprotobuf_lite_la_LDFLAGS = -version-info 9:2:0 -export-dynamic -no-undefined +libprotobuf_lite_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined libprotobuf_lite_la_SOURCES = \ google/protobuf/stubs/atomicops_internals_x86_gcc.cc \ google/protobuf/stubs/atomicops_internals_x86_msvc.cc \ @@ -136,7 +136,7 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/io/zero_copy_stream_impl_lite.cc libprotobuf_la_LIBADD = $(PTHREAD_LIBS) -libprotobuf_la_LDFLAGS = -version-info 9:2:0 -export-dynamic -no-undefined +libprotobuf_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined libprotobuf_la_SOURCES = \ $(libprotobuf_lite_la_SOURCES) \ google/protobuf/stubs/strutil.cc \ @@ -166,7 +166,7 @@ libprotobuf_la_SOURCES = \ google/protobuf/compiler/parser.cc libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la -libprotoc_la_LDFLAGS = -version-info 9:2:0 -export-dynamic -no-undefined +libprotoc_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined libprotoc_la_SOURCES = \ google/protobuf/compiler/code_generator.cc \ google/protobuf/compiler/command_line_interface.cc \ diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index c0cfd414..17dd6671 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -113,24 +113,24 @@ namespace internal { // The current version, represented as a single integer to make comparison // easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 2006002 +#define GOOGLE_PROTOBUF_VERSION 3000000 // The minimum library version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 2006000 +#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3000000 // The minimum header version which works with the current version of // the library. This constant should only be used by protoc's C++ code // generator. -static const int kMinHeaderVersionForLibrary = 2006000; +static const int kMinHeaderVersionForLibrary = 3000000; // The minimum protoc version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 2006000 +#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3000000 // The minimum header version which works with the current version of // protoc. This constant should only be used in VerifyVersion(). -static const int kMinHeaderVersionForProtoc = 2006000; +static const int kMinHeaderVersionForProtoc = 3000000; // Verifies that the headers and libraries are compatible. Use the macro // below to call this. -- cgit v1.2.3 From 58dfce93847ece9ae05e70091f982b8882fd3c16 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 3 Dec 2014 12:12:17 -0800 Subject: Update version number in descriptor.pb.h and plugin.pb.h. Protect death tests with macro PROTOBUF_HAS_DEATH_TEST. --- src/google/protobuf/compiler/plugin.pb.h | 4 ++-- src/google/protobuf/descriptor.pb.h | 4 ++-- src/google/protobuf/map_test.cc | 2 ++ src/google/protobuf/repeated_field_reflection_unittest.cc | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 35a0a899..ad017005 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -8,12 +8,12 @@ #include -#if GOOGLE_PROTOBUF_VERSION < 2006000 +#if GOOGLE_PROTOBUF_VERSION < 3000000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 2006002 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 6bb5c6a6..cda25982 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -8,12 +8,12 @@ #include -#if GOOGLE_PROTOBUF_VERSION < 2006000 +#if GOOGLE_PROTOBUF_VERSION < 3000000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 2006002 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc index c680ccb2..9db67523 100644 --- a/src/google/protobuf/map_test.cc +++ b/src/google/protobuf/map_test.cc @@ -190,6 +190,7 @@ TEST_F(MapImplTest, MutableAt) { ExpectSingleElement(key, value2); } +#ifdef PROTOBUF_HAS_DEATH_TEST TEST_F(MapImplTest, MutableAtNonExistDeathTest) { EXPECT_DEATH(map_.at(0), ""); } @@ -197,6 +198,7 @@ TEST_F(MapImplTest, MutableAtNonExistDeathTest) { TEST_F(MapImplTest, ImmutableAtNonExistDeathTest) { EXPECT_DEATH(const_map_.at(0), ""); } +#endif // PROTOBUF_HAS_DEATH_TEST TEST_F(MapImplTest, CountNonExist) { EXPECT_EQ(0, map_.count(0)); diff --git a/src/google/protobuf/repeated_field_reflection_unittest.cc b/src/google/protobuf/repeated_field_reflection_unittest.cc index ae43dfab..00252674 100644 --- a/src/google/protobuf/repeated_field_reflection_unittest.cc +++ b/src/google/protobuf/repeated_field_reflection_unittest.cc @@ -410,6 +410,7 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForRegularFields) { EXPECT_TRUE(rf_message.empty()); EXPECT_TRUE(mrf_message.empty()); +#ifdef PROTOBUF_HAS_DEATH_TEST // Make sure types are checked correctly at runtime. const FieldDescriptor* fd_optional_int32 = desc->FindFieldByName("optional_int32"); @@ -419,6 +420,7 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForRegularFields) { message, fd_repeated_int32), ""); EXPECT_DEATH(refl->GetRepeatedFieldRef( message, fd_repeated_foreign_message), ""); +#endif // PROTOBUF_HAS_DEATH_TEST } TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForEnums) { -- cgit v1.2.3 From 35ef68056cf84f581c2eab389f78a876f13cd661 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 3 Dec 2014 15:45:28 -0800 Subject: Add a missing Java dist file. --- Makefile.am | 1 + post_process_dist.sh | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6bda5157..e6ce1d19 100644 --- a/Makefile.am +++ b/Makefile.am @@ -135,6 +135,7 @@ java_EXTRA_DIST= \ java/src/test/java/com/google/protobuf/field_presence_test.proto \ java/src/test/java/com/google/protobuf/lazy_fields_lite.proto \ java/src/test/java/com/google/protobuf/lite_equals_and_hash.proto \ + java/src/test/java/com/google/protobuf/map_for_proto2_lite_test.proto \ java/src/test/java/com/google/protobuf/map_for_proto2_test.proto \ java/src/test/java/com/google/protobuf/map_test.proto \ java/src/test/java/com/google/protobuf/multiple_files_test.proto \ diff --git a/post_process_dist.sh b/post_process_dist.sh index 7b2e599d..1a4d704e 100755 --- a/post_process_dist.sh +++ b/post_process_dist.sh @@ -15,8 +15,8 @@ # non-testdata .txt files are converted to Windows-style line endings. # 5) Cleans up after itself. -if [ "$1" == "" ]; then - echo "USAGE: $1 DISTFILE" >&2 +if [ "$1" == "" -o "$2" == "" ]; then + echo "USAGE: $0 DISTFILE LANGUAGE" >&2 exit 1 fi @@ -28,6 +28,7 @@ fi set -ex BASENAME=`basename $1 .tar.gz` +LANGUAGE=$2 # Create a directory called "dist", copy the tarball there and unpack it. mkdir dist @@ -45,7 +46,7 @@ cd $BASENAME/vsprojects cd .. # Build the dist again in .tar.gz and .tar.bz2 formats. -./configure +./configure DIST_LANG=$LANGUAGE make dist-gzip make dist-bzip2 -- cgit v1.2.3 From 137dd0f17f91ca008fa2ab0a17b1e02865e8f8ca Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 3 Dec 2014 16:31:47 -0800 Subject: Delete some globals in ShutdownProtobufLibrary(). --- src/google/protobuf/descriptor.cc | 5 +++++ src/google/protobuf/map_entry.h | 5 +++++ src/google/protobuf/map_field.cc | 27 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 19d49cab..b8dd198d 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -345,6 +345,10 @@ typedef hash_map LocationsByPathMap; set* allowed_proto3_extendees_ = NULL; GOOGLE_PROTOBUF_DECLARE_ONCE(allowed_proto3_extendees_init_); +void DeleteAllowedProto3Extendee() { + delete allowed_proto3_extendees_; +} + void InitAllowedProto3Extendee() { allowed_proto3_extendees_ = new set; allowed_proto3_extendees_->insert("google.protobuf.FileOptions"); @@ -354,6 +358,7 @@ void InitAllowedProto3Extendee() { allowed_proto3_extendees_->insert("google.protobuf.EnumValueOptions"); allowed_proto3_extendees_->insert("google.protobuf.ServiceOptions"); allowed_proto3_extendees_->insert("google.protobuf.MethodOptions"); + google::protobuf::internal::OnShutdown(&DeleteAllowedProto3Extendee); } // Checks whether the extendee type is allowed in proto3. diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index 6971c763..4d3fcfb6 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -43,6 +43,10 @@ class Arena; namespace protobuf { namespace internal { +// Register all MapEntry default instances so we can delete them in +// ShutdownProtobufLibrary(). +void RegisterMapEntryDefaultInstance(MessageLite* default_instance); + // This is the common base class for MapEntry. It is used by MapFieldBase in // reflection api, in which the static type of key and value is unknown. class LIBPROTOBUF_EXPORT MapEntryBase : public Message { @@ -317,6 +321,7 @@ class LIBPROTOBUF_EXPORT MapEntry : public MapEntryBase { entry->reflection_ = reflection; entry->default_instance_ = entry; entry->InitAsDefaultInstance(); + RegisterMapEntryDefaultInstance(entry); return entry; } diff --git a/src/google/protobuf/map_field.cc b/src/google/protobuf/map_field.cc index 74431628..b535ec28 100644 --- a/src/google/protobuf/map_field.cc +++ b/src/google/protobuf/map_field.cc @@ -30,10 +30,37 @@ #include +#include + namespace google { namespace protobuf { namespace internal { +ProtobufOnceType map_entry_default_instances_once_; +Mutex* map_entry_default_instances_mutex_; +vector* map_entry_default_instances_; + +void DeleteMapEntryDefaultInstances() { + for (int i = 0; i < map_entry_default_instances_->size(); ++i) { + delete map_entry_default_instances_->at(i); + } + delete map_entry_default_instances_mutex_; + delete map_entry_default_instances_; +} + +void InitMapEntryDefaultInstances() { + map_entry_default_instances_mutex_ = new Mutex(); + map_entry_default_instances_ = new vector(); + OnShutdown(&DeleteMapEntryDefaultInstances); +} + +void RegisterMapEntryDefaultInstance(MessageLite* default_instance) { + GoogleOnceInit(&map_entry_default_instances_once_, + &InitMapEntryDefaultInstances); + MutexLock lock(map_entry_default_instances_mutex_); + map_entry_default_instances_->push_back(default_instance); +} + MapFieldBase::~MapFieldBase() { if (repeated_field_ != NULL) delete repeated_field_; } -- cgit v1.2.3 From 6936f17b886f18b572cf5966f64d4a814a151044 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 3 Dec 2014 17:37:42 -0800 Subject: Update post_process_dist.sh to produce a separate package for each language. --- configure.ac | 2 +- post_process_dist.sh | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 418889dc..60076bd1 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)]) case "$DIST_LANG" in - "") DIST_LANG=cpp ;; + "") DIST_LANG=all ;; all | cpp | java | python | javanano) ;; *) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;; esac diff --git a/post_process_dist.sh b/post_process_dist.sh index 1a4d704e..733fa088 100755 --- a/post_process_dist.sh +++ b/post_process_dist.sh @@ -15,8 +15,8 @@ # non-testdata .txt files are converted to Windows-style line endings. # 5) Cleans up after itself. -if [ "$1" == "" -o "$2" == "" ]; then - echo "USAGE: $0 DISTFILE LANGUAGE" >&2 +if [ "$1" == "" ]; then + echo "USAGE: $0 DISTFILE" >&2 exit 1 fi @@ -27,8 +27,9 @@ fi set -ex +LANGUAGES="cpp java python" BASENAME=`basename $1 .tar.gz` -LANGUAGE=$2 +VERSION=${BASENAME:9} # Create a directory called "dist", copy the tarball there and unpack it. mkdir dist @@ -45,17 +46,23 @@ cd $BASENAME/vsprojects ./convert2008to2005.sh cd .. -# Build the dist again in .tar.gz and .tar.bz2 formats. -./configure DIST_LANG=$LANGUAGE -make dist-gzip -make dist-bzip2 +for LANG in $LANGUAGES; do + # Build the dist again in .tar.gz + ./configure DIST_LANG=$LANG + make dist-gzip + mv $BASENAME.tar.gz ../protobuf-$LANG-$VERSION.tar.gz +done # Convert all text files to use DOS-style line endings, then build a .zip # distribution. todos *.txt */*.txt -make dist-zip -# Clean up. -mv $BASENAME.tar.gz $BASENAME.tar.bz2 $BASENAME.zip .. +for LANG in $LANGUAGES; do + # Build the dist again in .zip + ./configure DIST_LANG=$LANG + make dist-zip + mv $BASENAME.zip ../protobuf-$LANG-$VERSION.zip +done + cd .. rm -rf $BASENAME -- cgit v1.2.3 From 0eaae1e6ce8767a10de49fb130f9e7f066210d7b Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 3 Dec 2014 18:15:19 -0800 Subject: Replace is_enum with is_proto_enum because is_enum is not supported on some platforms. --- src/google/protobuf/repeated_field_reflection.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/google/protobuf/repeated_field_reflection.h b/src/google/protobuf/repeated_field_reflection.h index 42f7be20..44d14d5b 100644 --- a/src/google/protobuf/repeated_field_reflection.h +++ b/src/google/protobuf/repeated_field_reflection.h @@ -38,6 +38,8 @@ #include #endif +#include + namespace google { namespace protobuf { namespace internal { @@ -273,7 +275,7 @@ struct RefTypeTraits< template struct RefTypeTraits< - T, typename internal::enable_if::value>::type> { + T, typename internal::enable_if::value>::type> { typedef RepeatedFieldRefIterator iterator; typedef RepeatedFieldAccessor AccessorType; // We use int32 for repeated enums in RepeatedFieldAccessor. -- cgit v1.2.3 From 6a949cda379c0ee38cce1a926e2982d45f53dfce Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 3 Dec 2014 18:23:49 -0800 Subject: Remove usage of features not supported in Java 1.6. --- java/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/java/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java b/java/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java index 6372b7a7..cec3da1e 100644 --- a/java/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java +++ b/java/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java @@ -38,7 +38,6 @@ import junit.framework.TestCase; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.nio.charset.StandardCharsets; /** * Tests for {@link UnknownFieldSetLite}. @@ -228,9 +227,9 @@ public class UnknownFieldSetLiteTest extends TestCase { assertEquals(foo, copyOfCopy); } - public void testMalformedBytes() { + public void testMalformedBytes() throws Exception { try { - Foo.parseFrom("this is a malformed protocol buffer".getBytes(StandardCharsets.UTF_8)); + Foo.parseFrom("this is a malformed protocol buffer".getBytes("UTF-8")); fail(); } catch (InvalidProtocolBufferException e) { // Expected. -- cgit v1.2.3 From d77877808fc9f00c3570353717d9659f8994ffc2 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Thu, 4 Dec 2014 17:30:58 -0800 Subject: Fix thread local annotatoin and add back type traits is_convertable for MSVC --- src/google/protobuf/arena.h | 2 +- src/google/protobuf/stubs/common.h | 6 ++++++ src/google/protobuf/stubs/type_traits.h | 4 ++-- src/google/protobuf/stubs/type_traits_unittest.cc | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 519e3569..b5822bdb 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -312,7 +312,7 @@ class LIBPROTOBUF_EXPORT Arena { static const size_t kHeaderSize = sizeof(Block); static google::protobuf::internal::SequenceNumber lifecycle_id_generator_; - static __thread ThreadCache thread_cache_; + static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_; // SFINAE for skipping addition to delete list for a Type. This is mainly to // skip proto2/proto1 message objects with cc_enable_arenas=true from being diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 17dd6671..c3f735a2 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -314,6 +314,12 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) { } #endif +#if defined(_MSC_VER) +#define GOOGLE_THREAD_LOCAL __declspec(thread) +#else +#define GOOGLE_THREAD_LOCAL __thread +#endif + // =================================================================== // from google3/base/basictypes.h diff --git a/src/google/protobuf/stubs/type_traits.h b/src/google/protobuf/stubs/type_traits.h index f5365c38..0c294677 100644 --- a/src/google/protobuf/stubs/type_traits.h +++ b/src/google/protobuf/stubs/type_traits.h @@ -103,7 +103,7 @@ template struct remove_reference; template struct add_reference; template struct remove_pointer; template struct is_same; -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) +#if !(defined(__GNUC__) && __GNUC__ <= 3) template struct is_convertible; #endif @@ -322,7 +322,7 @@ template struct is_same : public false_type { }; template struct is_same : public true_type { }; // Specified by TR1 [4.6] Relationships between types -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) +#if !(defined(__GNUC__) && __GNUC__ <= 3) namespace type_traits_internal { // This class is an implementation detail for is_convertible, and you diff --git a/src/google/protobuf/stubs/type_traits_unittest.cc b/src/google/protobuf/stubs/type_traits_unittest.cc index b42b9e83..49c10ace 100644 --- a/src/google/protobuf/stubs/type_traits_unittest.cc +++ b/src/google/protobuf/stubs/type_traits_unittest.cc @@ -610,7 +610,7 @@ TEST(TypeTraitsTest, TestIsSame) { } TEST(TypeTraitsTest, TestConvertible) { -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) +#if !(defined(__GNUC__) && __GNUC__ <= 3) EXPECT_TRUE((is_convertible::value)); EXPECT_TRUE((is_convertible::value)); EXPECT_TRUE((is_convertible::value)); -- cgit v1.2.3 From 7c939bcb25bff016ca63669c203e2ebfc0834825 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Thu, 4 Dec 2014 19:10:36 -0800 Subject: Update VC projects to include new source files. --- vsprojects/extract_includes.bat | 110 +++++--- vsprojects/libprotobuf-lite.vcproj | 34 ++- vsprojects/libprotobuf.vcproj | 86 ++++-- vsprojects/tests.vcproj | 536 +++++++++++++++++++++++++++++++++---- 4 files changed, 631 insertions(+), 135 deletions(-) diff --git a/vsprojects/extract_includes.bat b/vsprojects/extract_includes.bat index beab8c4a..d1638e3a 100755 --- a/vsprojects/extract_includes.bat +++ b/vsprojects/extract_includes.bat @@ -7,44 +7,72 @@ md include\google\protobuf\compiler md include\google\protobuf\compiler\cpp md include\google\protobuf\compiler\java md include\google\protobuf\compiler\python -copy ..\src\google\protobuf\stubs\atomicops.h include\google\protobuf\stubs\atomicops.h -copy ..\src\google\protobuf\stubs\atomicops_internals_x86_msvc.h include\google\protobuf\stubs\atomicops_internals_x86_msvc.h -copy ..\src\google\protobuf\stubs\common.h include\google\protobuf\stubs\common.h -copy ..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h -copy ..\src\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h -copy ..\src\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h -copy ..\src\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.h -copy ..\src\google\protobuf\descriptor.h include\google\protobuf\descriptor.h -copy ..\src\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h -copy ..\src\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h -copy ..\src\google\protobuf\dynamic_message.h include\google\protobuf\dynamic_message.h -copy ..\src\google\protobuf\extension_set.h include\google\protobuf\extension_set.h -copy ..\src\google\protobuf\generated_enum_reflection.h include\google\protobuf\generated_enum_reflection.h -copy ..\src\google\protobuf\generated_message_util.h include\google\protobuf\generated_message_util.h -copy ..\src\google\protobuf\generated_message_reflection.h include\google\protobuf\generated_message_reflection.h -copy ..\src\google\protobuf\message.h include\google\protobuf\message.h -copy ..\src\google\protobuf\message_lite.h include\google\protobuf\message_lite.h -copy ..\src\google\protobuf\reflection_ops.h include\google\protobuf\reflection_ops.h -copy ..\src\google\protobuf\repeated_field.h include\google\protobuf\repeated_field.h -copy ..\src\google\protobuf\service.h include\google\protobuf\service.h -copy ..\src\google\protobuf\text_format.h include\google\protobuf\text_format.h -copy ..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h -copy ..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h -copy ..\src\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h -copy ..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h -copy ..\src\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h -copy ..\src\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h -copy ..\src\google\protobuf\io\printer.h include\google\protobuf\io\printer.h -copy ..\src\google\protobuf\io\strtod.h include\google\protobuf\io\strtod.h -copy ..\src\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h -copy ..\src\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h -copy ..\src\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h -copy ..\src\google\protobuf\io\zero_copy_stream_impl_lite.h include\google\protobuf\io\zero_copy_stream_impl_lite.h -copy ..\src\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h -copy ..\src\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h -copy ..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h -copy ..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h -copy ..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h -copy ..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h -copy ..\src\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h -copy ..\src\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h +copy ..\google\protobuf\arena.h include\google\protobuf\arena.h +copy ..\google\protobuf\arenastring.h include\google\protobuf\arenastring.h +copy ..\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h +copy ..\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h +copy ..\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h +copy ..\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h +copy ..\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h +copy ..\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h +copy ..\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h +copy ..\google\protobuf\compiler\plugin.pb.h include\google\protobuf\compiler\plugin.pb.h +copy ..\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h +copy ..\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h +copy ..\google\protobuf\descriptor.h include\google\protobuf\descriptor.h +copy ..\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h +copy ..\google\protobuf\dynamic_message.h include\google\protobuf\dynamic_message.h +copy ..\google\protobuf\extension_set.h include\google\protobuf\extension_set.h +copy ..\google\protobuf\generated_enum_reflection.h include\google\protobuf\generated_enum_reflection.h +copy ..\google\protobuf\generated_message_reflection.h include\google\protobuf\generated_message_reflection.h +copy ..\google\protobuf\generated_message_util.h include\google\protobuf\generated_message_util.h +copy ..\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h +copy ..\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h +copy ..\google\protobuf\io\printer.h include\google\protobuf\io\printer.h +copy ..\google\protobuf\io\strtod.h include\google\protobuf\io\strtod.h +copy ..\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h +copy ..\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h +copy ..\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h +copy ..\google\protobuf\io\zero_copy_stream_impl_lite.h include\google\protobuf\io\zero_copy_stream_impl_lite.h +copy ..\google\protobuf\map_entry.h include\google\protobuf\map_entry.h +copy ..\google\protobuf\map_field.h include\google\protobuf\map_field.h +copy ..\google\protobuf\map_field_inl.h include\google\protobuf\map_field_inl.h +copy ..\google\protobuf\map.h include\google\protobuf\map.h +copy ..\google\protobuf\map_type_handler.h include\google\protobuf\map_type_handler.h +copy ..\google\protobuf\message.h include\google\protobuf\message.h +copy ..\google\protobuf\message_lite.h include\google\protobuf\message_lite.h +copy ..\google\protobuf\metadata.h include\google\protobuf\metadata.h +copy ..\google\protobuf\reflection.h include\google\protobuf\reflection.h +copy ..\google\protobuf\reflection_ops.h include\google\protobuf\reflection_ops.h +copy ..\google\protobuf\repeated_field.h include\google\protobuf\repeated_field.h +copy ..\google\protobuf\repeated_field_reflection.h include\google\protobuf\repeated_field_reflection.h +copy ..\google\protobuf\service.h include\google\protobuf\service.h +copy ..\google\protobuf\stubs\atomicops.h include\google\protobuf\stubs\atomicops.h +copy ..\google\protobuf\stubs\atomicops_internals_aix.h include\google\protobuf\stubs\atomicops_internals_aix.h +copy ..\google\protobuf\stubs\atomicops_internals_arm64_gcc.h include\google\protobuf\stubs\atomicops_internals_arm64_gcc.h +copy ..\google\protobuf\stubs\atomicops_internals_arm_gcc.h include\google\protobuf\stubs\atomicops_internals_arm_gcc.h +copy ..\google\protobuf\stubs\atomicops_internals_arm_qnx.h include\google\protobuf\stubs\atomicops_internals_arm_qnx.h +copy ..\google\protobuf\stubs\atomicops_internals_atomicword_compat.h include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h +copy ..\google\protobuf\stubs\atomicops_internals_generic_gcc.h include\google\protobuf\stubs\atomicops_internals_generic_gcc.h +copy ..\google\protobuf\stubs\atomicops_internals_macosx.h include\google\protobuf\stubs\atomicops_internals_macosx.h +copy ..\google\protobuf\stubs\atomicops_internals_mips_gcc.h include\google\protobuf\stubs\atomicops_internals_mips_gcc.h +copy ..\google\protobuf\stubs\atomicops_internals_pnacl.h include\google\protobuf\stubs\atomicops_internals_pnacl.h +copy ..\google\protobuf\stubs\atomicops_internals_solaris.h include\google\protobuf\stubs\atomicops_internals_solaris.h +copy ..\google\protobuf\stubs\atomicops_internals_tsan.h include\google\protobuf\stubs\atomicops_internals_tsan.h +copy ..\google\protobuf\stubs\atomicops_internals_x86_gcc.h include\google\protobuf\stubs\atomicops_internals_x86_gcc.h +copy ..\google\protobuf\stubs\atomicops_internals_x86_msvc.h include\google\protobuf\stubs\atomicops_internals_x86_msvc.h +copy ..\google\protobuf\stubs\atomic_sequence_num.h include\google\protobuf\stubs\atomic_sequence_num.h +copy ..\google\protobuf\stubs\casts.h include\google\protobuf\stubs\casts.h +copy ..\google\protobuf\stubs\common.h include\google\protobuf\stubs\common.h +copy ..\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastmem.h +copy ..\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h +copy ..\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h +copy ..\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h +copy ..\google\protobuf\stubs\stl_util.h include\google\protobuf\stubs\stl_util.h +copy ..\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h +copy ..\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.h +copy ..\google\protobuf\text_format.h include\google\protobuf\text_format.h +copy ..\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h +copy ..\google\protobuf\wire_format.h include\google\protobuf\wire_format.h +copy ..\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h +copy ..\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h diff --git a/vsprojects/libprotobuf-lite.vcproj b/vsprojects/libprotobuf-lite.vcproj index 06b15988..47642f5d 100644 --- a/vsprojects/libprotobuf-lite.vcproj +++ b/vsprojects/libprotobuf-lite.vcproj @@ -248,7 +248,11 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + + + + + + + diff --git a/vsprojects/libprotobuf.vcproj b/vsprojects/libprotobuf.vcproj index 1a488f7d..8bafcaad 100644 --- a/vsprojects/libprotobuf.vcproj +++ b/vsprojects/libprotobuf.vcproj @@ -328,7 +328,11 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + + + + + + + + + + + + + diff --git a/vsprojects/tests.vcproj b/vsprojects/tests.vcproj index fb815b5a..488feb71 100644 --- a/vsprojects/tests.vcproj +++ b/vsprojects/tests.vcproj @@ -247,23 +247,23 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + @@ -311,19 +315,35 @@ > + + + + + + + + + + + + + + @@ -371,7 +403,11 @@ > + + + + + + + + + + + + + + + + + + + + @@ -410,12 +482,24 @@ RelativePath=".\google\protobuf\unittest_lite_imports_nonlite.pb.cc" > + + + + + + + + + + + + + + + + + + + + + + + + @@ -468,7 +604,7 @@ @@ -478,11 +614,35 @@ + + + + + + + + @@ -492,7 +652,7 @@ @@ -502,11 +662,35 @@ + + + + + + + + @@ -516,7 +700,7 @@ @@ -526,11 +710,59 @@ + + + + + + + + + + + + + + + + @@ -540,7 +772,7 @@ @@ -550,11 +782,35 @@ + + + + + + + + @@ -564,7 +820,7 @@ @@ -574,7 +830,7 @@ @@ -588,7 +844,7 @@ @@ -598,11 +854,35 @@ + + + + + + + + @@ -612,7 +892,7 @@ @@ -622,22 +902,22 @@ + + + + + + + + + + + + + + + + @@ -660,7 +988,7 @@ @@ -670,11 +998,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From be20ae0b6975071563ecc61f8372fd7936f174ed Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Fri, 5 Dec 2014 02:54:43 -0800 Subject: Fix compile issues and test failures in VS2008. --- src/google/protobuf/arena.cc | 2 +- src/google/protobuf/arena_unittest.cc | 12 ++-- src/google/protobuf/arenastring.h | 1 - src/google/protobuf/compiler/cpp/cpp_message.cc | 2 +- src/google/protobuf/map_field_test.cc | 35 --------- src/google/protobuf/map_test_util.cc | 34 ++++----- src/google/protobuf/preserve_unknown_enum_test.cc | 2 + src/google/protobuf/repeated_field.h | 13 ++-- .../protobuf/repeated_field_reflection_unittest.cc | 3 +- src/google/protobuf/repeated_field_unittest.cc | 4 +- src/google/protobuf/stubs/fastmem.h | 1 - src/google/protobuf/stubs/type_traits.h | 7 +- src/google/protobuf/unknown_field_set_unittest.cc | 2 +- vsprojects/libprotoc.vcproj | 84 +++++++++++++++++----- 14 files changed, 112 insertions(+), 90 deletions(-) diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index 1cb6441e..2ce987cb 100644 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -38,7 +38,7 @@ namespace google { namespace protobuf { google::protobuf::internal::SequenceNumber Arena::lifecycle_id_generator_; -__thread Arena::ThreadCache Arena::thread_cache_ = { -1, NULL }; +GOOGLE_THREAD_LOCAL Arena::ThreadCache Arena::thread_cache_ = { -1, NULL }; void Arena::Init(const ArenaOptions& options) { lifecycle_id_ = lifecycle_id_generator_.GetNext(); diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index 76a4274f..9d3d3e3e 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -128,7 +128,7 @@ TEST(ArenaTest, InitialBlockTooSmall) { // initial block. std::vector arena_block(64); ArenaOptions options; - options.initial_block = arena_block.data(); + options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); Arena arena(options); @@ -137,7 +137,7 @@ TEST(ArenaTest, InitialBlockTooSmall) { // Ensure that the arena allocator did not return memory pointing into the // initial block of memory. - uintptr_t arena_start = reinterpret_cast(arena_block.data()); + uintptr_t arena_start = reinterpret_cast(&arena_block[0]); uintptr_t arena_end = arena_start + arena_block.size(); EXPECT_FALSE(allocation >= arena_start && allocation < arena_end); @@ -771,7 +771,7 @@ TEST(ArenaTest, RepeatedFieldOnArena) { // Preallocate an initial arena block to avoid mallocs during hooked region. std::vector arena_block(1024 * 1024); ArenaOptions options; - options.initial_block = arena_block.data(); + options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); Arena arena(options); @@ -898,7 +898,7 @@ TEST(ArenaTest, NoHeapAllocationsTest) { // Allocate a large initial block to avoid mallocs during hooked test. std::vector arena_block(128 * 1024); ArenaOptions options; - options.initial_block = arena_block.data(); + options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); Arena arena(options); @@ -918,7 +918,7 @@ TEST(ArenaTest, NoHeapAllocationsTest) { TEST(ArenaTest, MessageLiteOnArena) { std::vector arena_block(128 * 1024); ArenaOptions options; - options.initial_block = arena_block.data(); + options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); Arena arena(options); const google::protobuf::MessageLite* prototype = dynamic_cast< @@ -977,7 +977,7 @@ TEST(ArenaTest, SpaceUsed) { // Test with initial block. std::vector arena_block(1024); - options.initial_block = arena_block.data(); + options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); Arena arena_2(options); EXPECT_EQ(1024, arena_2.SpaceUsed()); diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index 50f13837..2adad16a 100755 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -31,7 +31,6 @@ #ifndef GOOGLE_PROTOBUF_ARENASTRING_H__ #define GOOGLE_PROTOBUF_ARENASTRING_H__ -#include #include #include diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 212bc3e9..e71d35fa 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -1226,7 +1226,7 @@ GenerateDescriptorDeclarations(io::Printer* printer) { for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); printer->Print(" "); - if (IsStringOrMessage(field)) { + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { printer->Print("const "); } field_generators_.get(field).GeneratePrivateMembers(printer); diff --git a/src/google/protobuf/map_field_test.cc b/src/google/protobuf/map_field_test.cc index 98551839..045f8f2c 100644 --- a/src/google/protobuf/map_field_test.cc +++ b/src/google/protobuf/map_field_test.cc @@ -430,41 +430,6 @@ TEST_P(MapFieldStateTest, MutableMapField) { } } -class MapFieldBaseStateStub : public MapFieldBaseStub { - public: - MapFieldBaseStateStub(Mutex* mutex, int* clean_counter, - int* completed_counter) - : mutex_(mutex), - clean_counter_(clean_counter), - completed_counter_(completed_counter) {} - ~MapFieldBaseStateStub() {} - - protected: - void SyncRepeatedFieldWithMapNoLock() const { Clean(); } - void SyncMapWithRepeatedFieldNoLock() const { Clean(); } - - private: - void Clean() const { - { - MutexLock lock(mutex_); - ++(*clean_counter_); - } - struct timespec tm; - tm.tv_sec = 0; - tm.tv_nsec = 100000000; // 100ms - nanosleep(&tm, NULL); - { - MutexLock lock(mutex_); - // No other thread should have completed while this one was initializing. - EXPECT_EQ(0, *completed_counter_); - } - } - Mutex* mutex_; - int* clean_counter_; - int* completed_counter_; -}; - - } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/map_test_util.cc b/src/google/protobuf/map_test_util.cc index b27c8f19..eb7ea511 100644 --- a/src/google/protobuf/map_test_util.cc +++ b/src/google/protobuf/map_test_util.cc @@ -1020,7 +1020,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_int32_int32_key_); int32 val = sub_message->GetReflection()->GetInt32( *sub_message, map_int32_int32_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1034,7 +1034,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_int64_int64_key_); int64 val = sub_message->GetReflection()->GetInt64( *sub_message, map_int64_int64_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1048,7 +1048,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_uint32_uint32_key_); uint32 val = sub_message->GetReflection()->GetUInt32( *sub_message, map_uint32_uint32_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1062,7 +1062,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_uint64_uint64_key_); uint64 val = sub_message->GetReflection()->GetUInt64( *sub_message, map_uint64_uint64_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1076,7 +1076,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_sint32_sint32_key_); int32 val = sub_message->GetReflection()->GetInt32( *sub_message, map_sint32_sint32_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1090,7 +1090,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_sint64_sint64_key_); int64 val = sub_message->GetReflection()->GetInt64( *sub_message, map_sint64_sint64_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1104,7 +1104,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_fixed32_fixed32_key_); uint32 val = sub_message->GetReflection()->GetUInt32( *sub_message, map_fixed32_fixed32_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1118,7 +1118,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_fixed64_fixed64_key_); uint64 val = sub_message->GetReflection()->GetUInt64( *sub_message, map_fixed64_fixed64_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1132,7 +1132,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_sfixed32_sfixed32_key_); int32 val = sub_message->GetReflection()->GetInt32( *sub_message, map_sfixed32_sfixed32_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1146,7 +1146,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_sfixed64_sfixed64_key_); int64 val = sub_message->GetReflection()->GetInt64( *sub_message, map_sfixed64_sfixed64_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1160,7 +1160,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_int32_float_key_); float val = sub_message->GetReflection()->GetFloat( *sub_message, map_int32_float_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1174,7 +1174,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_int32_double_key_); double val = sub_message->GetReflection()->GetDouble( *sub_message, map_int32_double_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1188,7 +1188,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_bool_bool_key_); bool val = sub_message->GetReflection()->GetBool( *sub_message, map_bool_bool_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1202,7 +1202,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_string_string_key_); string val = sub_message->GetReflection()->GetString( *sub_message, map_string_string_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1216,7 +1216,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_int32_bytes_key_); string val = sub_message->GetReflection()->GetString( *sub_message, map_int32_bytes_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1230,7 +1230,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_int32_enum_key_); const EnumValueDescriptor* val = sub_message->GetReflection()->GetEnum( *sub_message, map_int32_enum_val_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } { @@ -1246,7 +1246,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection( *sub_message, map_int32_foreign_message_val_); int32 val = foreign_message.GetReflection()->GetInt32( foreign_message, foreign_c_); - EXPECT_EQ(map.at(key), val); + EXPECT_EQ(map[key], val); } } } diff --git a/src/google/protobuf/preserve_unknown_enum_test.cc b/src/google/protobuf/preserve_unknown_enum_test.cc index 33e9ea10..816e52ca 100644 --- a/src/google/protobuf/preserve_unknown_enum_test.cc +++ b/src/google/protobuf/preserve_unknown_enum_test.cc @@ -200,6 +200,7 @@ TEST(PreserveUnknownEnumTest, Proto2CatchesUnknownValues) { EXPECT_TRUE(enum_value != NULL); r->AddEnum(&message, repeated_field, enum_value); +#ifdef PROTOBUF_HAS_DEATH_TEST // Enum-field integer-based setters GOOGLE_DCHECK-fail on invalid values, in order to // remain consistent with proto2 generated code. EXPECT_DEBUG_DEATH({ @@ -214,6 +215,7 @@ TEST(PreserveUnknownEnumTest, Proto2CatchesUnknownValues) { r->AddEnumValue(&message, repeated_field, 4242); r->GetRepeatedEnum(message, repeated_field, 1); }, "AddEnumValue accepts only valid integer values"); +#endif // PROTOBUF_HAS_DEATH_TEST } TEST(PreserveUnknownEnumTest, SupportsUnknownEnumValuesAPI) { diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index e14dcc62..4798eeda 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -236,10 +236,11 @@ class RepeatedField { Arena* arena; Element elements[1]; }; - // Why not sizeof(Rep) - sizeof(Element)? Because this is not accurate w.r.t. - // trailing padding on the struct -- e.g. if Element is int, this would yield - // 12 on x86-64, not 8 as we want. - static const size_t kRepHeaderSize = sizeof(Arena*); + // We can not use sizeof(Rep) - sizeof(Element) due to the trailing padding on + // the struct. We can not use sizeof(Arena*) as well because there might be + // a "gap" after the field arena and before the field elements (e.g., when + // Element is double and pointer is 32bit). + static const size_t kRepHeaderSize; // Contains arena ptr and the elements array. We also keep the invariant that // if rep_ is NULL, then arena is NULL. Rep* rep_; @@ -263,6 +264,10 @@ class RepeatedField { } }; +template +const size_t RepeatedField::kRepHeaderSize = + reinterpret_cast(&reinterpret_cast(16)->elements[0]) - 16; + namespace internal { template class RepeatedPtrIterator; template class RepeatedPtrOverPtrsIterator; diff --git a/src/google/protobuf/repeated_field_reflection_unittest.cc b/src/google/protobuf/repeated_field_reflection_unittest.cc index 00252674..8b821806 100644 --- a/src/google/protobuf/repeated_field_reflection_unittest.cc +++ b/src/google/protobuf/repeated_field_reflection_unittest.cc @@ -196,8 +196,7 @@ void TestRepeatedFieldRefIterator( int index = 0; for (typename Ref::const_iterator it = handle.begin(); it != handle.end(); ++it) { - ValueType value = static_cast(*it); - EXPECT_EQ((message.*GetFunc)(index), value); + EXPECT_EQ((message.*GetFunc)(index), *it); ++index; } EXPECT_EQ(handle.size(), index); diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index 9942af50..15c0c93e 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -92,8 +92,8 @@ TEST(RepeatedField, Small) { EXPECT_TRUE(field.empty()); EXPECT_EQ(field.size(), 0); - // Additional 8 bytes are for 'struct Rep' header. - int expected_usage = 4 * sizeof(int) + 8; + // Additional bytes are for 'struct Rep' header. + int expected_usage = 4 * sizeof(int) + sizeof(Arena*); EXPECT_EQ(field.SpaceUsedExcludingSelf(), expected_usage); } diff --git a/src/google/protobuf/stubs/fastmem.h b/src/google/protobuf/stubs/fastmem.h index e553f142..763a6e60 100644 --- a/src/google/protobuf/stubs/fastmem.h +++ b/src/google/protobuf/stubs/fastmem.h @@ -46,7 +46,6 @@ #define GOOGLE_PROTOBUF_STUBS_FASTMEM_H_ #include -#include #include #include diff --git a/src/google/protobuf/stubs/type_traits.h b/src/google/protobuf/stubs/type_traits.h index 0c294677..b58cae3f 100644 --- a/src/google/protobuf/stubs/type_traits.h +++ b/src/google/protobuf/stubs/type_traits.h @@ -339,6 +339,9 @@ struct ConvertHelper { static small_ Test(To); static big_ Test(...); static From Create(); + enum { + value = sizeof(Test(Create())) == sizeof(small_) + }; }; } // namespace type_traits_internal @@ -346,9 +349,7 @@ struct ConvertHelper { template struct is_convertible : integral_constant::Test( - type_traits_internal::ConvertHelper::Create())) - == sizeof(small_)> { + type_traits_internal::ConvertHelper::value> { }; #endif diff --git a/src/google/protobuf/unknown_field_set_unittest.cc b/src/google/protobuf/unknown_field_set_unittest.cc index 6bba8fc7..9b02f0b0 100644 --- a/src/google/protobuf/unknown_field_set_unittest.cc +++ b/src/google/protobuf/unknown_field_set_unittest.cc @@ -485,7 +485,7 @@ TEST_F(UnknownFieldSetTest, UnknownEnumValue) { TEST_F(UnknownFieldSetTest, SpaceUsedExcludingSelf) { UnknownFieldSet empty; empty.AddVarint(1, 0); - EXPECT_EQ(/* vector */ 24 + /* sizeof(UnknownField) */ 16, + EXPECT_EQ(sizeof(vector) + sizeof(UnknownField), empty.SpaceUsedExcludingSelf()); } diff --git a/vsprojects/libprotoc.vcproj b/vsprojects/libprotoc.vcproj index ccbc0b36..1feac924 100644 --- a/vsprojects/libprotoc.vcproj +++ b/vsprojects/libprotoc.vcproj @@ -323,22 +323,6 @@ RelativePath="..\src\google\protobuf\compiler\command_line_interface.cc" > - - - - - - - - @@ -367,6 +351,10 @@ RelativePath="..\src\google\protobuf\compiler\cpp\cpp_helpers.cc" > + + @@ -391,6 +379,10 @@ RelativePath="..\src\google\protobuf\compiler\java\java_context.cc" > + + @@ -427,6 +419,10 @@ RelativePath="..\src\google\protobuf\compiler\java\java_lazy_message_field.cc" > + + @@ -455,10 +451,66 @@ RelativePath="..\src\google\protobuf\compiler\java\java_string_field.cc" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 9104da3261db96779e80f4713a50f5d19921ade8 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Tue, 9 Dec 2014 11:57:52 -0800 Subject: Down-integrate from internal code base. --- CHANGES.txt | 104 +++++++++++++++++++++ .../java/com/google/protobuf/MapFieldLite.java | 2 +- .../src/test/java/com/google/protobuf/MapTest.java | 7 ++ 3 files changed, 112 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0d0ac814..0d4ce0ec 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,107 @@ +2014-12-01 version 3.0.0-alpha-1 (C++/Java): + + General + * Introduced Protocol Buffers language version 3 (aka proto3). + + When protobuf was initially opensourced it implemented Protocol Buffers + language version 2 (aka proto2), which is why the version number + started from v2.0.0. From v3.0.0, a new language version (proto3) is + introduced while the old version (proto2) will continue to be supported. + + The main intent of introducing proto3 is to clean up protobuf before + pushing the language as the foundation of Google's new API platform. + In proto3, the language is simplified, both for ease of use and to + make it available in a wider range of programming languages. At the + same time a few features are added to better support common idioms + found in APIs. + + The following are the main new features in language version 3: + + 1. Removal of field presence logic for primitive value fields, removal + of required fields, and removal of default values. This makes proto3 + significantly easier to implement with open struct representations, + as in languages like Android Java, Objective C, or Go. + 2. Removal of unknown fields. + 3. Removal of extensions, which are instead replaced by a new standard + type called Any. + 4. Fix semantics for unknown enum values. + 5. Addition of maps. + 6. Addition of a small set of standard types for representation of time, + dynamic data, etc. + 7. A well-defined encoding in JSON as an alternative to binary proto + encoding. + + This release (v3.0.0-alpha-1) includes partial proto3 support for C++ and + Java. Items 6 (well-known types) and 7 (JSON format) in the above feature + list are not impelmented. + + A new notion "syntax" is introduced to specify whether a .proto file + uses proto2 or proto3: + + // foo.proto + syntax = "proto3"; + message Bar {...} + + If omitted, the protocol compiler will generate a warning and "proto2" will + be used as the default. This warning will be turned into an error in a + future release. + + We recommend that new Protocol Buffers users use proto3. However, we do not + generally recommend that existing users migrate from proto2 from proto3 due + to API incompatibility, and we will continue to support proto2 for a long + time. + + * Added support for map fields (implemented in C++/Java for both proto2 and + proto3). + + Map fields can be declared using the following syntax: + + message Foo { + map values = 1; + } + + Data of a map field will be stored in memory as an unordered map and it + can be accessed through generated accessors. + + C++ + * Added arena allocation support (for both proto2 and proto3). + + Profiling shows memory allocation and deallocation constitutes a significant + fraction of CPU-time spent in protobuf code and arena allocation is a + technique introduced to reduce this cost. With arena allocation, new + objects will be allocated from a large piece of preallocated memory and + deallocation of these objects is almost free. Early adoption shows 20% to + 50% improvement in some Google binaries. + + To enable arena support, add the following option to your .proto file: + + option cc_enable_arenas = true; + + Protocol compiler will generate additional code to make the generated + message classes work with arenas. This does not change the existing API + of protobuf messages and does not affect wire format. Your existing code + should continue to work after adding this option. In the future we will + make this option enabled by default. + + To actually take advantage of arena allocation, you need to use the arena + APIs when creating messages. A quick example of using the arena API: + + { + google::protobuf::Arena arena; + // Allocate a protobuf message in the arena. + MyMessage* message = Arena::CreateMessage(&arena); + // All submessages will be allocated in the same arena. + if (!message->ParseFromString(data)) { + // Deal with malformed input data. + } + // Must not delete the message here. It will be deleted automatically + // when the arena is destroyed. + } + + Currently arena does not work with map fields. Enabling arena in a .proto + file containing map fields will result in compile errors in the generated + code. This will be addressed in a future release. + 2014-10-20 version 2.6.1: C++ diff --git a/java/src/main/java/com/google/protobuf/MapFieldLite.java b/java/src/main/java/com/google/protobuf/MapFieldLite.java index eea36d9e..7f94c690 100644 --- a/java/src/main/java/com/google/protobuf/MapFieldLite.java +++ b/java/src/main/java/com/google/protobuf/MapFieldLite.java @@ -97,7 +97,7 @@ public class MapFieldLite { if (a == b) { return true; } - if (a.size() != a.size()) { + if (a.size() != b.size()) { return false; } for (Map.Entry entry : a.entrySet()) { diff --git a/java/src/test/java/com/google/protobuf/MapTest.java b/java/src/test/java/com/google/protobuf/MapTest.java index 542a20e7..9a25e302 100644 --- a/java/src/test/java/com/google/protobuf/MapTest.java +++ b/java/src/test/java/com/google/protobuf/MapTest.java @@ -260,6 +260,13 @@ public class MapTest extends TestCase { assertFalse(m1.equals(m2)); // Don't check m1.hashCode() != m2.hashCode() because it's not guaranteed // to be different. + + // Regression test for b/18549190: if a map is a subset of the other map, + // equals() should return false. + b2.getMutableInt32ToInt32Field().remove(1); + m2 = b2.build(); + assertFalse(m1.equals(m2)); + assertFalse(m2.equals(m1)); } -- cgit v1.2.3 From 7da812177156330b4b105a83eae4bec837faddad Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Tue, 9 Dec 2014 13:43:46 -0800 Subject: Fix the intermediate directory of vc project files. --- vsprojects/libprotobuf-lite.vcproj | 4 ++-- vsprojects/libprotobuf.vcproj | 4 ++-- vsprojects/libprotoc.vcproj | 4 ++-- vsprojects/lite-test.vcproj | 4 ++-- vsprojects/protoc.vcproj | 4 ++-- vsprojects/test_plugin.vcproj | 4 ++-- vsprojects/tests.vcproj | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/vsprojects/libprotobuf-lite.vcproj b/vsprojects/libprotobuf-lite.vcproj index 47642f5d..4859eec0 100644 --- a/vsprojects/libprotobuf-lite.vcproj +++ b/vsprojects/libprotobuf-lite.vcproj @@ -18,7 +18,7 @@ Date: Tue, 9 Dec 2014 14:16:57 -0800 Subject: Fix vsprojects/extract_includes.bat --- vsprojects/extract_includes.bat | 138 ++++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/vsprojects/extract_includes.bat b/vsprojects/extract_includes.bat index d1638e3a..587c1a8a 100755 --- a/vsprojects/extract_includes.bat +++ b/vsprojects/extract_includes.bat @@ -7,72 +7,72 @@ md include\google\protobuf\compiler md include\google\protobuf\compiler\cpp md include\google\protobuf\compiler\java md include\google\protobuf\compiler\python -copy ..\google\protobuf\arena.h include\google\protobuf\arena.h -copy ..\google\protobuf\arenastring.h include\google\protobuf\arenastring.h -copy ..\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h -copy ..\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h -copy ..\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h -copy ..\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h -copy ..\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h -copy ..\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h -copy ..\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h -copy ..\google\protobuf\compiler\plugin.pb.h include\google\protobuf\compiler\plugin.pb.h -copy ..\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h -copy ..\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h -copy ..\google\protobuf\descriptor.h include\google\protobuf\descriptor.h -copy ..\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h -copy ..\google\protobuf\dynamic_message.h include\google\protobuf\dynamic_message.h -copy ..\google\protobuf\extension_set.h include\google\protobuf\extension_set.h -copy ..\google\protobuf\generated_enum_reflection.h include\google\protobuf\generated_enum_reflection.h -copy ..\google\protobuf\generated_message_reflection.h include\google\protobuf\generated_message_reflection.h -copy ..\google\protobuf\generated_message_util.h include\google\protobuf\generated_message_util.h -copy ..\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h -copy ..\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h -copy ..\google\protobuf\io\printer.h include\google\protobuf\io\printer.h -copy ..\google\protobuf\io\strtod.h include\google\protobuf\io\strtod.h -copy ..\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h -copy ..\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h -copy ..\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h -copy ..\google\protobuf\io\zero_copy_stream_impl_lite.h include\google\protobuf\io\zero_copy_stream_impl_lite.h -copy ..\google\protobuf\map_entry.h include\google\protobuf\map_entry.h -copy ..\google\protobuf\map_field.h include\google\protobuf\map_field.h -copy ..\google\protobuf\map_field_inl.h include\google\protobuf\map_field_inl.h -copy ..\google\protobuf\map.h include\google\protobuf\map.h -copy ..\google\protobuf\map_type_handler.h include\google\protobuf\map_type_handler.h -copy ..\google\protobuf\message.h include\google\protobuf\message.h -copy ..\google\protobuf\message_lite.h include\google\protobuf\message_lite.h -copy ..\google\protobuf\metadata.h include\google\protobuf\metadata.h -copy ..\google\protobuf\reflection.h include\google\protobuf\reflection.h -copy ..\google\protobuf\reflection_ops.h include\google\protobuf\reflection_ops.h -copy ..\google\protobuf\repeated_field.h include\google\protobuf\repeated_field.h -copy ..\google\protobuf\repeated_field_reflection.h include\google\protobuf\repeated_field_reflection.h -copy ..\google\protobuf\service.h include\google\protobuf\service.h -copy ..\google\protobuf\stubs\atomicops.h include\google\protobuf\stubs\atomicops.h -copy ..\google\protobuf\stubs\atomicops_internals_aix.h include\google\protobuf\stubs\atomicops_internals_aix.h -copy ..\google\protobuf\stubs\atomicops_internals_arm64_gcc.h include\google\protobuf\stubs\atomicops_internals_arm64_gcc.h -copy ..\google\protobuf\stubs\atomicops_internals_arm_gcc.h include\google\protobuf\stubs\atomicops_internals_arm_gcc.h -copy ..\google\protobuf\stubs\atomicops_internals_arm_qnx.h include\google\protobuf\stubs\atomicops_internals_arm_qnx.h -copy ..\google\protobuf\stubs\atomicops_internals_atomicword_compat.h include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h -copy ..\google\protobuf\stubs\atomicops_internals_generic_gcc.h include\google\protobuf\stubs\atomicops_internals_generic_gcc.h -copy ..\google\protobuf\stubs\atomicops_internals_macosx.h include\google\protobuf\stubs\atomicops_internals_macosx.h -copy ..\google\protobuf\stubs\atomicops_internals_mips_gcc.h include\google\protobuf\stubs\atomicops_internals_mips_gcc.h -copy ..\google\protobuf\stubs\atomicops_internals_pnacl.h include\google\protobuf\stubs\atomicops_internals_pnacl.h -copy ..\google\protobuf\stubs\atomicops_internals_solaris.h include\google\protobuf\stubs\atomicops_internals_solaris.h -copy ..\google\protobuf\stubs\atomicops_internals_tsan.h include\google\protobuf\stubs\atomicops_internals_tsan.h -copy ..\google\protobuf\stubs\atomicops_internals_x86_gcc.h include\google\protobuf\stubs\atomicops_internals_x86_gcc.h -copy ..\google\protobuf\stubs\atomicops_internals_x86_msvc.h include\google\protobuf\stubs\atomicops_internals_x86_msvc.h -copy ..\google\protobuf\stubs\atomic_sequence_num.h include\google\protobuf\stubs\atomic_sequence_num.h -copy ..\google\protobuf\stubs\casts.h include\google\protobuf\stubs\casts.h -copy ..\google\protobuf\stubs\common.h include\google\protobuf\stubs\common.h -copy ..\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastmem.h -copy ..\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h -copy ..\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h -copy ..\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h -copy ..\google\protobuf\stubs\stl_util.h include\google\protobuf\stubs\stl_util.h -copy ..\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h -copy ..\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.h -copy ..\google\protobuf\text_format.h include\google\protobuf\text_format.h -copy ..\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h -copy ..\google\protobuf\wire_format.h include\google\protobuf\wire_format.h -copy ..\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h -copy ..\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h +copy ..\src\google\protobuf\arena.h include\google\protobuf\arena.h +copy ..\src\google\protobuf\arenastring.h include\google\protobuf\arenastring.h +copy ..\src\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h +copy ..\src\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h +copy ..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h +copy ..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h +copy ..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h +copy ..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h +copy ..\src\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h +copy ..\src\google\protobuf\compiler\plugin.pb.h include\google\protobuf\compiler\plugin.pb.h +copy ..\src\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h +copy ..\src\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h +copy ..\src\google\protobuf\descriptor.h include\google\protobuf\descriptor.h +copy ..\src\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h +copy ..\src\google\protobuf\dynamic_message.h include\google\protobuf\dynamic_message.h +copy ..\src\google\protobuf\extension_set.h include\google\protobuf\extension_set.h +copy ..\src\google\protobuf\generated_enum_reflection.h include\google\protobuf\generated_enum_reflection.h +copy ..\src\google\protobuf\generated_message_reflection.h include\google\protobuf\generated_message_reflection.h +copy ..\src\google\protobuf\generated_message_util.h include\google\protobuf\generated_message_util.h +copy ..\src\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h +copy ..\src\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h +copy ..\src\google\protobuf\io\printer.h include\google\protobuf\io\printer.h +copy ..\src\google\protobuf\io\strtod.h include\google\protobuf\io\strtod.h +copy ..\src\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h +copy ..\src\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h +copy ..\src\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h +copy ..\src\google\protobuf\io\zero_copy_stream_impl_lite.h include\google\protobuf\io\zero_copy_stream_impl_lite.h +copy ..\src\google\protobuf\map_entry.h include\google\protobuf\map_entry.h +copy ..\src\google\protobuf\map_field.h include\google\protobuf\map_field.h +copy ..\src\google\protobuf\map_field_inl.h include\google\protobuf\map_field_inl.h +copy ..\src\google\protobuf\map.h include\google\protobuf\map.h +copy ..\src\google\protobuf\map_type_handler.h include\google\protobuf\map_type_handler.h +copy ..\src\google\protobuf\message.h include\google\protobuf\message.h +copy ..\src\google\protobuf\message_lite.h include\google\protobuf\message_lite.h +copy ..\src\google\protobuf\metadata.h include\google\protobuf\metadata.h +copy ..\src\google\protobuf\reflection.h include\google\protobuf\reflection.h +copy ..\src\google\protobuf\reflection_ops.h include\google\protobuf\reflection_ops.h +copy ..\src\google\protobuf\repeated_field.h include\google\protobuf\repeated_field.h +copy ..\src\google\protobuf\repeated_field_reflection.h include\google\protobuf\repeated_field_reflection.h +copy ..\src\google\protobuf\service.h include\google\protobuf\service.h +copy ..\src\google\protobuf\stubs\atomicops.h include\google\protobuf\stubs\atomicops.h +copy ..\src\google\protobuf\stubs\atomicops_internals_aix.h include\google\protobuf\stubs\atomicops_internals_aix.h +copy ..\src\google\protobuf\stubs\atomicops_internals_arm64_gcc.h include\google\protobuf\stubs\atomicops_internals_arm64_gcc.h +copy ..\src\google\protobuf\stubs\atomicops_internals_arm_gcc.h include\google\protobuf\stubs\atomicops_internals_arm_gcc.h +copy ..\src\google\protobuf\stubs\atomicops_internals_arm_qnx.h include\google\protobuf\stubs\atomicops_internals_arm_qnx.h +copy ..\src\google\protobuf\stubs\atomicops_internals_atomicword_compat.h include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h +copy ..\src\google\protobuf\stubs\atomicops_internals_generic_gcc.h include\google\protobuf\stubs\atomicops_internals_generic_gcc.h +copy ..\src\google\protobuf\stubs\atomicops_internals_macosx.h include\google\protobuf\stubs\atomicops_internals_macosx.h +copy ..\src\google\protobuf\stubs\atomicops_internals_mips_gcc.h include\google\protobuf\stubs\atomicops_internals_mips_gcc.h +copy ..\src\google\protobuf\stubs\atomicops_internals_pnacl.h include\google\protobuf\stubs\atomicops_internals_pnacl.h +copy ..\src\google\protobuf\stubs\atomicops_internals_solaris.h include\google\protobuf\stubs\atomicops_internals_solaris.h +copy ..\src\google\protobuf\stubs\atomicops_internals_tsan.h include\google\protobuf\stubs\atomicops_internals_tsan.h +copy ..\src\google\protobuf\stubs\atomicops_internals_x86_gcc.h include\google\protobuf\stubs\atomicops_internals_x86_gcc.h +copy ..\src\google\protobuf\stubs\atomicops_internals_x86_msvc.h include\google\protobuf\stubs\atomicops_internals_x86_msvc.h +copy ..\src\google\protobuf\stubs\atomic_sequence_num.h include\google\protobuf\stubs\atomic_sequence_num.h +copy ..\src\google\protobuf\stubs\casts.h include\google\protobuf\stubs\casts.h +copy ..\src\google\protobuf\stubs\common.h include\google\protobuf\stubs\common.h +copy ..\src\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastmem.h +copy ..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h +copy ..\src\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h +copy ..\src\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h +copy ..\src\google\protobuf\stubs\stl_util.h include\google\protobuf\stubs\stl_util.h +copy ..\src\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h +copy ..\src\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.h +copy ..\src\google\protobuf\text_format.h include\google\protobuf\text_format.h +copy ..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h +copy ..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h +copy ..\src\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h +copy ..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h -- cgit v1.2.3 From 496d47c27fd4301411156ebf108188b810f4e902 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Tue, 9 Dec 2014 15:47:25 -0800 Subject: Remove map_field.cc from lite-runtime. --- src/Makefile.am | 2 +- vsprojects/libprotobuf-lite.vcproj | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index b1fb1244..b39917e1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -126,7 +126,6 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/arenastring.cc \ google/protobuf/extension_set.cc \ google/protobuf/generated_message_util.cc \ - google/protobuf/map_field.cc \ google/protobuf/message_lite.cc \ google/protobuf/repeated_field.cc \ google/protobuf/wire_format_lite.cc \ @@ -150,6 +149,7 @@ libprotobuf_la_SOURCES = \ google/protobuf/dynamic_message.cc \ google/protobuf/extension_set_heavy.cc \ google/protobuf/generated_message_reflection.cc \ + google/protobuf/map_field.cc \ google/protobuf/message.cc \ google/protobuf/reflection_internal.h \ google/protobuf/reflection_ops.cc \ diff --git a/vsprojects/libprotobuf-lite.vcproj b/vsprojects/libprotobuf-lite.vcproj index 4859eec0..09eca4d8 100644 --- a/vsprojects/libprotobuf-lite.vcproj +++ b/vsprojects/libprotobuf-lite.vcproj @@ -283,10 +283,6 @@ RelativePath="..\src\google\protobuf\generated_message_util.cc" > - - -- cgit v1.2.3 From 8d5d7cc6d03b00fcb7162525100fbd4cc0d1929d Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Tue, 9 Dec 2014 17:05:10 -0800 Subject: Fix LIBPROTOBUF_PROTOBUF annotations for buliding protobuf as DLLs. --- src/google/protobuf/arena.cc | 19 +++++++++++++------ src/google/protobuf/arena.h | 9 +++++++-- src/google/protobuf/arenastring.h | 2 +- src/google/protobuf/compiler/cpp/cpp_unittest.cc | 2 ++ src/google/protobuf/map.h | 6 +++--- src/google/protobuf/map_entry.h | 10 +++++----- src/google/protobuf/map_field.h | 2 +- src/google/protobuf/message.h | 1 + 8 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index 2ce987cb..18536781 100644 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -38,7 +38,14 @@ namespace google { namespace protobuf { google::protobuf::internal::SequenceNumber Arena::lifecycle_id_generator_; +#ifdef PROTOBUF_USE_DLLS +Arena::ThreadCache& Arena::thread_cache() { + static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_ = { -1, NULL }; + return thread_cache_; +} +#else GOOGLE_THREAD_LOCAL Arena::ThreadCache Arena::thread_cache_ = { -1, NULL }; +#endif void Arena::Init(const ArenaOptions& options) { lifecycle_id_ = lifecycle_id_generator_.GetNext(); @@ -130,18 +137,18 @@ void* Arena::AllocateAligned(size_t n) { // If this thread already owns a block in this arena then try to use that. // This fast path optimizes the case where multiple threads allocate from the // same arena. - if (thread_cache_.last_lifecycle_id_seen == lifecycle_id_ && - thread_cache_.last_block_used_ != NULL) { - if (thread_cache_.last_block_used_->avail() < n) { + if (thread_cache().last_lifecycle_id_seen == lifecycle_id_ && + thread_cache().last_block_used_ != NULL) { + if (thread_cache().last_block_used_->avail() < n) { return SlowAlloc(n); } - return AllocFromBlock(thread_cache_.last_block_used_, n); + return AllocFromBlock(thread_cache().last_block_used_, n); } // Check whether we own the last accessed block on this arena. // This fast path optimizes the case where a single thread uses multiple // arenas. - void* me = &thread_cache_; + void* me = &thread_cache(); Block* b = reinterpret_cast(google::protobuf::internal::Acquire_Load(&hint_)); if (!b || b->owner != me || b->avail() < n) { // If the next block to allocate from is the first block, try to claim it @@ -169,7 +176,7 @@ void* Arena::AllocFromBlock(Block* b, size_t n) { } void* Arena::SlowAlloc(size_t n) { - void* me = &thread_cache_; + void* me = &thread_cache(); Block* b = FindBlock(me); // Find block owned by me. // See if allocation fits in my latest block. if (b != NULL && b->avail() >= n) { diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index b5822bdb..d0cb163c 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -312,7 +312,12 @@ class LIBPROTOBUF_EXPORT Arena { static const size_t kHeaderSize = sizeof(Block); static google::protobuf::internal::SequenceNumber lifecycle_id_generator_; +#ifdef PROTOBUF_USE_DLLS + static ThreadCache& thread_cache(); +#else static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_; + static ThreadCache& thread_cache() { return thread_cache_; } +#endif // SFINAE for skipping addition to delete list for a Type. This is mainly to // skip proto2/proto1 message objects with cc_enable_arenas=true from being @@ -434,8 +439,8 @@ class LIBPROTOBUF_EXPORT Arena { void CleanupList(); inline void SetThreadCacheBlock(Block* block) { - thread_cache_.last_block_used_ = block; - thread_cache_.last_lifecycle_id_seen = lifecycle_id_; + thread_cache().last_block_used_ = block; + thread_cache().last_lifecycle_id_seen = lifecycle_id_; } int64 lifecycle_id_; // Unique for each arena. Changes on Reset(). diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index 2adad16a..d829ed91 100755 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -53,7 +53,7 @@ namespace google { namespace protobuf { namespace internal { -struct ArenaStringPtr { +struct LIBPROTOBUF_EXPORT ArenaStringPtr { inline void Set(const ::std::string* default_value, const ::std::string& value, ::google::protobuf::Arena* arena) { if (ptr_ == default_value) { diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc index 20fcfa62..2a04b293 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc @@ -153,6 +153,7 @@ TEST(GeneratedMessageTest, Defaults) { &message.optional_import_message()); } +#ifndef PROTOBUF_USE_DLLS TEST(GeneratedMessageTest, Int32StringConversion) { EXPECT_EQ("971", Int32ToString(971)); EXPECT_EQ("(~0x7fffffff)", Int32ToString(kint32min)); @@ -165,6 +166,7 @@ TEST(GeneratedMessageTest, Int64StringConversion) { EXPECT_EQ("GOOGLE_LONGLONG(~0x7fffffffffffffff)", Int64ToString(kint64min)); EXPECT_EQ("GOOGLE_LONGLONG(9223372036854775807)", Int64ToString(kint64max)); } +#endif // !PROTOBUF_USE_DLLS TEST(GeneratedMessageTest, FloatingPointDefaults) { const unittest::TestExtremeDefaultValues& extreme_default = diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index f6ae3e52..6d8a9d03 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -110,7 +110,7 @@ class Map { ~Map() { clear(); } // Iterators - class LIBPROTOBUF_EXPORT const_iterator + class const_iterator : public std::iterator { typedef typename hash_map::const_iterator InnerIt; @@ -139,7 +139,7 @@ class Map { InnerIt it_; }; - class LIBPROTOBUF_EXPORT iterator : public std::iterator { + class iterator : public std::iterator { typedef typename hash_map::iterator InnerIt; public: @@ -302,7 +302,7 @@ class Map { template - friend class LIBPROTOBUF_EXPORT internal::MapField; + friend class internal::MapField; }; } // namespace protobuf diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index 4d3fcfb6..217b15f6 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -45,7 +45,7 @@ namespace internal { // Register all MapEntry default instances so we can delete them in // ShutdownProtobufLibrary(). -void RegisterMapEntryDefaultInstance(MessageLite* default_instance); +void LIBPROTOBUF_EXPORT RegisterMapEntryDefaultInstance(MessageLite* default_instance); // This is the common base class for MapEntry. It is used by MapFieldBase in // reflection api, in which the static type of key and value is unknown. @@ -84,7 +84,7 @@ class LIBPROTOBUF_EXPORT MapEntryBase : public Message { // Moreover, default_enum_value is used to initialize enum field in proto2. template -class LIBPROTOBUF_EXPORT MapEntry : public MapEntryBase { +class MapEntry : public MapEntryBase { // Handlers for key/value's proto field type. Used to infer internal layout // and provide parsing/serialization support. typedef MapProtoTypeHandler KeyProtoHandler; @@ -363,7 +363,7 @@ class LIBPROTOBUF_EXPORT MapEntry : public MapEntryBase { template - class LIBPROTOBUF_EXPORT MapEntryWrapper + class MapEntryWrapper : public MapEntry { typedef MapEntry - class LIBPROTOBUF_EXPORT MapEnumEntryWrapper + class MapEnumEntryWrapper : public MapEntry { typedef MapEntry - friend class LIBPROTOBUF_EXPORT internal::MapField; + friend class internal::MapField; friend class LIBPROTOBUF_EXPORT internal::GeneratedMessageReflection; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntry); diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h index 0fad1351..8516d74e 100644 --- a/src/google/protobuf/map_field.h +++ b/src/google/protobuf/map_field.h @@ -137,7 +137,7 @@ class LIBPROTOBUF_EXPORT MapFieldBase { template -class LIBPROTOBUF_EXPORT MapField : public MapFieldBase { +class MapField : public MapFieldBase { // Handlers for key/value's proto field type. typedef MapProtoTypeHandler KeyProtoHandler; typedef MapProtoTypeHandler ValueProtoHandler; diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 1d8f2499..a200bc92 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -967,6 +967,7 @@ const RepeatedField& Reflection::GetRepeatedField( \ const Message& message, const FieldDescriptor* field) const; \ \ template<> \ +LIBPROTOBUF_EXPORT \ RepeatedField* Reflection::MutableRepeatedField( \ Message* message, const FieldDescriptor* field) const; -- cgit v1.2.3