diff options
41 files changed, 348 insertions, 78 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 5a74cd3c0..72ee37175 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,74 @@ +2019-04-29 version 3.8.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + C++ + * Use std::atomic<int32> in case of myriad2 platform + * Always declare enums to be int-sized + * Added DebugString() and ShortDebugString() methods on MessageLite + * Specialized different parse loop control flows + * Make hasbits potentially in register. The or's start forming an obstacle because it's a read modify store on the same mem address on each iteration. + * Move to an internal MACRO for parser validity checks. + * Improve map parsing performance. + * Make MergePartialFromCodedStream non virtual. This allows direct calls, potential inlining and is also a code health improvement + * Add an overall limit to parse_context to prevent reading past it. This allows to remove a annoying level of indirection. + * Fix a mistake, we shouldn't verify map key/value strings for utf8 in opt mode for proto2. + * Further improvements to cut binary size. + * Prepare to make MergePartialFromCodedStream non-virtual. + * A report on some interesting behavior change in python (caused by b/27494216) made me realize there is a check that needs to be done in case the parse ended on a end group tag. + * Add a note of caution to the comments around skip in CodedOutputStream. + * Simplify end check. + * Add overload for ParseMessage for MessageLite/Message types. If the explicit type is not known inlining won't help de-virtualizing the virtual call. + * Reduce linker input. It turns out that ParseMessage is not inlined, producing template instantiations that are used only once and save nothing but cost more. + * Improve the parser. + * [c++17] Changed proto2::RepeatedPtrField iterators to no longer derive from the deprecated std::iterator class. + * Change the default value of case_insensitive_enum_parsing to false for JsonStringToMessage. + * Add a warning if a field name doesn't match the style guide. + * Fix TextFormat not round-trip correctly when float value is max float. + * Added locationed info for some errors at compiler + * Python reserved keywords are now working with getattr()/setattr() for most descriptors. + * Added AllowUnknownField() in text_format + * Append '_' to C++ reserved keywords for message, enum, extension + * Fix MSVC warning C4244 in protobuf's parse_context.h. + * Updating Iterators to be compatible with C++17 in MSVC. + * Use capability annotation in mutex.h + * Fix "UndefinedBehaviorSanitizer: cfi-bad-type" + * CriticalSectionLock class as a lightweight replacement for std::mutex on Windows platforms. + * Removed vestigial wire_format_lite_inl.h + + C# + * Added System.Memory dependency. + + Java + * Make Java protoc code generator ignore optimize_for LITE_RUNTIME. Users should instead use the Java lite protoc plugin. + * Change Extension getMessageDefaultInstance() to return Message instead of MessageLite. + * Prevent malicious input streams from leaking buffers for ByteString or ByteBuffer parsing. + * Release new Javalite runtime. + * Show warning in case potential file name conflict. + * Allow Java reserved keywords to be used in extensions. + * Added setAllowUnknownFields() in text format + * Add memoization to ExtensionRegistryLite.getEmptyRegistry() + * Improve performance of CodedOutputStream.writeUInt32NoTag + * Add an optimized mismatch-finding algorithm to UnsafeUtil. + * When serializing uint32 varints, check that we have MAX_VARINT32_SIZE bytes left, not just MAX_VARINT_SIZE. + * Minor optimization to RopeByteString.PieceIterator + + JavaScript + * Simplify generated toObject code when the default value is used. + + Python + * Changes implementation of Name() for enums that allow aliases in proto2 in Python to be in line with claims in C++ implementation (to return first value). + * Added double_format option in text format printer. + * Added iter and __contains__ to extension dict + * Added allow_unknown_field option in python text format parser + * Fixed Timestamp.ToDatetime() loses precision issue + * Support unknown field in text format printer. + * Float field will be convert to inf if bigger than struct.unpack('f', b'\xff\xff\x7f\x7f')[0] which is about 3.4028234664e+38, + convert to -inf if smaller than -3.4028234664e+38 + * Allowed casting str->bytes in Message.__setstate__ + + Ruby + * Helper methods to get enum name for Ruby. + + 2019-01-24 version 3.7.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) C++ diff --git a/Makefile.am b/Makefile.am index 57b1032c2..8396f6e0c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1235,6 +1235,7 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ python/release/wheel/protobuf_optimized_pip.sh \ python/release/wheel/README.md \ six.BUILD \ + third_party/zlib.BUILD \ util/python/BUILD diff --git a/Protobuf.podspec b/Protobuf.podspec index 1a6699bac..a05d4bb91 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -5,7 +5,7 @@ # dependent projects use the :git notation to refer to the library. Pod::Spec.new do |s| s.name = 'Protobuf' - s.version = '3.7.1' + s.version = '3.8.0' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index f99817ee6..2f025b7ee 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,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],[3.7.1],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.8.0],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/conformance/failure_list_ruby_mac.txt b/conformance/failure_list_ruby_mac.txt index 0abc41247..19be38a30 100644 --- a/conformance/failure_list_ruby_mac.txt +++ b/conformance/failure_list_ruby_mac.txt @@ -51,11 +51,6 @@ Required.Proto3.JsonInput.RepeatedUint32Wrapper.JsonOutput Required.Proto3.JsonInput.RepeatedUint64Wrapper.JsonOutput Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput -Required.Proto3.JsonInput.TimestampJsonInputTooSmall -Required.Proto3.JsonInput.TimestampMinValue.JsonOutput -Required.Proto3.JsonInput.TimestampMinValue.ProtobufOutput -Required.Proto3.JsonInput.TimestampRepeatedValue.JsonOutput -Required.Proto3.JsonInput.TimestampRepeatedValue.ProtobufOutput Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 7e7a3fd43..ccb2dd2c4 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ <title>Google Protocol Buffers tools</title> <summary>Tools for Protocol Buffers - Google's data interchange format.</summary> <description>See project site for more info.</description> - <version>3.7.1</version> + <version>3.8.0</version> <authors>Google Inc.</authors> <owners>protobuf-packages</owners> <licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl> diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 57901d8cc..5b292b1dc 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description> <Copyright>Copyright 2015, Google Inc.</Copyright> <AssemblyTitle>Google Protocol Buffers</AssemblyTitle> - <VersionPrefix>3.7.1</VersionPrefix> + <VersionPrefix>3.8.0</VersionPrefix> <LangVersion>6</LangVersion> <Authors>Google Inc.</Authors> <TargetFrameworks>netstandard1.0;netstandard2.0;net45</TargetFrameworks> @@ -32,11 +32,11 @@ </PropertyGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> - <PackageReference Include="System.Memory" Version="4.5.2" /> + <PackageReference Include="System.Memory" Version="4.5.2"/> </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" /> + <PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Version="1.0.0-beta2-18618-05"/> </ItemGroup> </Project> diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 90fc53366..9f09b91ab 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ <groupId>com.google.protobuf</groupId> <artifactId>protobuf-bom</artifactId> - <version>3.7.1</version> + <version>3.8.0</version> <packaging>pom</packaging> <name>Protocol Buffers [BOM]</name> diff --git a/java/core/pom.xml b/java/core/pom.xml index c9161b69a..5a355b69b 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.7.1</version> + <version>3.8.0</version> </parent> <artifactId>protobuf-java</artifactId> diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 800cdded9..0e360a708 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.7.0</version> + <version>3.8.0-rc-1</version> </parent> <artifactId>protobuf-javalite</artifactId> diff --git a/java/pom.xml b/java/pom.xml index 79456cb26..e3a7224f8 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.7.1</version> + <version>3.8.0</version> <packaging>pom</packaging> <name>Protocol Buffers [Parent]</name> diff --git a/java/util/pom.xml b/java/util/pom.xml index 17ecacf11..657f9fe91 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.7.1</version> + <version>3.8.0</version> </parent> <artifactId>protobuf-java-util</artifactId> diff --git a/js/package.json b/js/package.json index dfa1d1f1e..5043963d2 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.7.1", + "version": "3.8.0", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 6f5659ff4..bf0389de7 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ <email>protobuf-opensource@google.com</email> <active>yes</active> </lead> - <date>2019-03-25</date> - <time>13:23:39</time> + <date>2019-05-21</date> + <time>14:07:13</time> <version> - <release>3.7.1</release> - <api>3.7.1</api> + <release>3.8.0</release> + <api>3.8.0</api> </version> <stability> <release>stable</release> @@ -26,6 +26,7 @@ <dir baseinstalldir="/" name="/"> <file baseinstalldir="/" name="config.m4" role="src"/> <file baseinstalldir="/" name="array.c" role="src"/> + <file baseinstalldir="/" name="builtin_descriptors.inc" role="src"/> <file baseinstalldir="/" name="def.c" role="src"/> <file baseinstalldir="/" name="encode_decode.c" role="src"/> <file baseinstalldir="/" name="map.c" role="src"/> @@ -318,5 +319,33 @@ G A release. <license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license> <notes>GA release.</notes> </release> + <release> + <version> + <release>3.8.0RC1</release> + <api>3.8.0</api> + </version> + <stability> + <release>beta</release> + <api>beta</api> + </stability> + <date>2019-04-23</date> + <time>16:14:52</time> + <license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license> + <notes>GA release.</notes> + </release> + <release> + <version> + <release>3.8.0</release> + <api>3.8.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2019-05-21</date> + <time>14:07:13</time> + <license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license> + <notes>GA release.</notes> + </release> </changelog> </package> diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index cc5c1943a..058337d97 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -37,7 +37,7 @@ #include "upb.h" #define PHP_PROTOBUF_EXTNAME "protobuf" -#define PHP_PROTOBUF_VERSION "3.7.1" +#define PHP_PROTOBUF_VERSION "3.8.0" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c index 233c2a2e6..1d977437f 100644 --- a/php/ext/google/protobuf/upb.c +++ b/php/ext/google/protobuf/upb.c @@ -10460,6 +10460,48 @@ static void start_timestamp_zone(upb_json_parser *p, const char *ptr) { capture_begin(p, ptr); } +#define EPOCH_YEAR 1970 +#define TM_YEAR_BASE 1900 + +static bool isleap(int year) { + return (year % 4) == 0 && (year % 100 != 0 || (year % 400) == 0); +} + +const unsigned short int __mon_yday[2][13] = { + /* Normal years. */ + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + /* Leap years. */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } +}; + +int64_t epoch(int year, int yday, int hour, int min, int sec) { + int64_t years = year - EPOCH_YEAR; + + int64_t leap_days = years / 4 - years / 100 + years / 400; + + int64_t days = years * 365 + yday + leap_days; + int64_t hours = days * 24 + hour; + int64_t mins = hours * 60 + min; + int64_t secs = mins * 60 + sec; + return secs; +} + + +static int64_t upb_mktime(const struct tm *tp) { + int sec = tp->tm_sec; + int min = tp->tm_min; + int hour = tp->tm_hour; + int mday = tp->tm_mday; + int mon = tp->tm_mon; + int year = tp->tm_year + TM_YEAR_BASE; + + /* Calculate day of year from year, month, and day of month. */ + int mon_yday = ((__mon_yday[isleap(year)][mon]) - 1); + int yday = mon_yday + mday; + + return epoch(year, yday, hour, min, sec); +} + static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) { size_t len; const char *buf; @@ -10487,7 +10529,7 @@ static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) { } /* Normalize tm */ - seconds = mktime(&p->tm); + seconds = upb_mktime(&p->tm); /* Check timestamp boundary */ if (seconds < -62135596800) { diff --git a/php/src/Google/Protobuf/Internal/DescriptorPool.php b/php/src/Google/Protobuf/Internal/DescriptorPool.php index 9b4dcc011..419bbf4dc 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorPool.php +++ b/php/src/Google/Protobuf/Internal/DescriptorPool.php @@ -55,7 +55,7 @@ class DescriptorPool return self::$pool; } - public function internalAddGeneratedFile($data) + public function internalAddGeneratedFile($data, $use_nested = false) { $files = new FileDescriptorSet(); $files->mergeFromString($data); diff --git a/php/tests/proto/test_wrapper_type_setters.proto b/php/tests/proto/test_wrapper_type_setters.proto index 41ca7f3f3..119bd2547 100644 --- a/php/tests/proto/test_wrapper_type_setters.proto +++ b/php/tests/proto/test_wrapper_type_setters.proto @@ -24,3 +24,14 @@ message TestWrapperSetters { map<string, google.protobuf.StringValue> map_string_value = 13; } + +message TestWrapperAccessorConflicts { + int32 normal_vs_wrapper_value = 1; + google.protobuf.Int32Value normal_vs_wrapper = 2; + + int32 normal_vs_normal_value = 3; + int32 normal_vs_normal = 4; + + google.protobuf.Int32Value wrapper_vs_wrapper_value = 5; + google.protobuf.Int32Value wrapper_vs_wrapper = 6; +} diff --git a/php/tests/wrapper_type_setters_test.php b/php/tests/wrapper_type_setters_test.php index 5509a175a..35e3a7dec 100644 --- a/php/tests/wrapper_type_setters_test.php +++ b/php/tests/wrapper_type_setters_test.php @@ -16,6 +16,44 @@ use Google\Protobuf\UInt64Value; class WrapperTypeSettersTest extends TestBase { + public function testConflictNormalVsWrapper() + { + $m = new Foo\TestWrapperAccessorConflicts(); + + $m->setNormalVsWrapperValue1(1); + $this->assertSame(1, $m->getNormalVsWrapperValue1()); + + $m->setNormalVsWrapperValue2(1); + $this->assertSame(1, $m->getNormalVsWrapperValue2()); + + $wrapper = new Int32Value(["value" => 1]); + $m->setNormalVsWrapper($wrapper); + $this->assertSame(1, $m->getNormalVsWrapper()->getValue()); + } + + public function testConflictNormalVsNormal() + { + $m = new Foo\TestWrapperAccessorConflicts(); + + $m->setNormalVsNormalValue(1); + $this->assertSame(1, $m->getNormalVsNormalValue()); + + $m->setNormalVsNormal(1); + $this->assertSame(1, $m->getNormalVsNormal()); + } + + public function testConflictWrapperVsWrapper() + { + $m = new Foo\TestWrapperAccessorConflicts(); + + $m->setWrapperVsWrapperValueValue(1); + $this->assertSame(1, $m->getWrapperVsWrapperValueValue()); + + $wrapper = new Int32Value(["value" => 1]); + $m->setWrapperVsWrapperValue5($wrapper); + $this->assertSame(1, $m->getWrapperVsWrapperValue5()->getValue()); + } + /** * @dataProvider gettersAndSettersDataProvider */ diff --git a/protobuf.pc.in b/protobuf.pc.in index 055a9d056..4e88b514a 100644 --- a/protobuf.pc.in +++ b/protobuf.pc.in @@ -8,6 +8,5 @@ Description: Google's Data Interchange Format Version: @VERSION@ Libs: -L${libdir} -lprotobuf @PTHREAD_LIBS@ Libs.private: @LIBS@ - Cflags: -I${includedir} @PTHREAD_CFLAGS@ Conflicts: protobuf-lite diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index a3f610b2b..68f12f503 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ </parent> <groupId>com.google.protobuf</groupId> <artifactId>protoc</artifactId> - <version>3.7.1</version> + <version>3.8.0</version> <packaging>pom</packaging> <name>Protobuf Compiler</name> <description> diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 36213d143..92d2d8190 100755 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,7 +30,7 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.7.1' +__version__ = '3.8.0' if __name__ != '__main__': try: diff --git a/ruby/ext/google/protobuf_c/upb.c b/ruby/ext/google/protobuf_c/upb.c index 28bba7f99..3d96c5ccc 100644 --- a/ruby/ext/google/protobuf_c/upb.c +++ b/ruby/ext/google/protobuf_c/upb.c @@ -14299,6 +14299,47 @@ static void start_timestamp_zone(upb_json_parser *p, const char *ptr) { capture_begin(p, ptr); } +#define EPOCH_YEAR 1970 +#define TM_YEAR_BASE 1900 + +static bool isleap(int year) { + return (year % 4) == 0 && (year % 100 != 0 || (year % 400) == 0); +} + +const unsigned short int __mon_yday[2][13] = { + /* Normal years. */ + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + /* Leap years. */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } +}; + +int64_t epoch(int year, int yday, int hour, int min, int sec) { + int64_t years = year - EPOCH_YEAR; + + int64_t leap_days = years / 4 - years / 100 + years / 400; + + int64_t days = years * 365 + yday + leap_days; + int64_t hours = days * 24 + hour; + int64_t mins = hours * 60 + min; + int64_t secs = mins * 60 + sec; + return secs; +} + +static int64_t upb_mktime(const struct tm *tp) { + int sec = tp->tm_sec; + int min = tp->tm_min; + int hour = tp->tm_hour; + int mday = tp->tm_mday; + int mon = tp->tm_mon; + int year = tp->tm_year + TM_YEAR_BASE; + + /* Calculate day of year from year, month, and day of month. */ + int mon_yday = ((__mon_yday[isleap(year)][mon]) - 1); + int yday = mon_yday + mday; + + return epoch(year, yday, hour, min, sec); +} + static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) { size_t len; const char *buf; @@ -14325,7 +14366,7 @@ static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) { } /* Normalize tm */ - seconds = mktime(&p->tm) - timezone; + seconds = upb_mktime(&p->tm); seconds += 3600 * hours; /* Check timestamp boundary */ diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 86a37141c..75db88ffe 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.7.1" + s.version = "3.8.0" s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" s.description = "Protocol Buffers are Google's data interchange format." @@ -20,6 +20,7 @@ Gem::Specification.new do |s| s.test_files = ["tests/basic.rb", "tests/stress.rb", "tests/generated_code_test.rb"] + s.required_ruby_version = '>= 2.3' s.add_development_dependency "rake-compiler", "~> 0.9.5" s.add_development_dependency "test-unit", '~> 3.0', '>= 3.0.9' s.add_development_dependency "rubygems-tasks", "~> 0.2.4" diff --git a/src/Makefile.am b/src/Makefile.am index 0627861a9..31307044d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 18:1:0 +PROTOBUF_VERSION = 19:0:0 if GCC # Turn on all warnings except for sign comparison (we ignore sign comparison diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 5383adf68..d9a125d30 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/api.pb.h b/src/google/protobuf/api.pb.h index 83beaa12e..729c3f9b0 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 2a1d14b87..c47ea33f7 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -655,27 +655,58 @@ void GenerateOneofField(const OneofDescriptor* oneof, io::Printer* printer) { void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, io::Printer* printer) { + bool need_other_name_for_accessor = false; + bool need_other_name_for_wrapper_accessor = false; + const Descriptor* desc = field->containing_type(); + + if (!field->is_repeated() && + field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + IsWrapperType(field)) { + // Check if there is any field called xxx_value + const FieldDescriptor* other = + desc->FindFieldByName(StrCat(field->name(), "_value")); + if (other != NULL) { + need_other_name_for_wrapper_accessor = true; + } + } + + if (strings::EndsWith(field->name(), "_value")) { + std::size_t pos = (field->name()).find("_value"); + string name = (field->name()).substr(0, pos); + const FieldDescriptor* other = desc->FindFieldByName(name); + if (other != NULL && + !other->is_repeated() && + other->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + IsWrapperType(other)) { + need_other_name_for_accessor = true; + } + } + const OneofDescriptor* oneof = field->containing_oneof(); // Generate getter. if (oneof != NULL) { GenerateFieldDocComment(printer, field, is_descriptor, kFieldGetter); printer->Print( - "public function get^camel_name^()\n" + "public function get^camel_name^^field_number^()\n" "{\n" " return $this->readOneof(^number^);\n" "}\n\n", "camel_name", UnderscoresToCamelCase(field->name(), true), - "number", IntToString(field->number())); + "number", IntToString(field->number()), + "field_number", need_other_name_for_accessor ? + StrCat(field->number()) : ""); } else { GenerateFieldDocComment(printer, field, is_descriptor, kFieldGetter); printer->Print( - "public function get^camel_name^()\n" + "public function get^camel_name^^field_number^()\n" "{\n" " return $this->^name^;\n" "}\n\n", - "camel_name", UnderscoresToCamelCase(field->name(), true), "name", - field->name()); + "camel_name", UnderscoresToCamelCase(field->name(), true), + "name", field->name(), + "field_number", need_other_name_for_accessor ? + StrCat(field->number()) : ""); } // For wrapper types, generate an additional getXXXValue getter @@ -684,21 +715,28 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && IsWrapperType(field)) { GenerateWrapperFieldGetterDocComment(printer, field); + printer->Print( - "public function get^camel_name^Value()\n" + "public function get^camel_name^Value^field_number1^()\n" "{\n" - " $wrapper = $this->get^camel_name^();\n" + " $wrapper = $this->get^camel_name^^field_number2^();\n" " return is_null($wrapper) ? null : $wrapper->getValue();\n" "}\n\n", - "camel_name", UnderscoresToCamelCase(field->name(), true)); + "camel_name", UnderscoresToCamelCase(field->name(), true), + "field_number1", need_other_name_for_wrapper_accessor ? + StrCat(field->number()) : "", + "field_number2", need_other_name_for_accessor ? + StrCat(field->number()) : ""); } // Generate setter. GenerateFieldDocComment(printer, field, is_descriptor, kFieldSetter); printer->Print( - "public function set^camel_name^($var)\n" + "public function set^camel_name^^field_number^($var)\n" "{\n", - "camel_name", UnderscoresToCamelCase(field->name(), true)); + "camel_name", UnderscoresToCamelCase(field->name(), true), + "field_number", need_other_name_for_accessor ? + StrCat(field->number()) : ""); Indent(printer); @@ -798,13 +836,17 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, IsWrapperType(field)) { GenerateWrapperFieldSetterDocComment(printer, field); printer->Print( - "public function set^camel_name^Value($var)\n" + "public function set^camel_name^Value^field_number1^($var)\n" "{\n" " $wrappedVar = is_null($var) ? null : new \\^wrapper_type^(['value' => $var]);\n" - " return $this->set^camel_name^($wrappedVar);\n" + " return $this->set^camel_name^^field_number2^($wrappedVar);\n" "}\n\n", "camel_name", UnderscoresToCamelCase(field->name(), true), - "wrapper_type", LegacyFullClassName(field->message_type(), is_descriptor)); + "wrapper_type", LegacyFullClassName(field->message_type(), is_descriptor), + "field_number1", need_other_name_for_wrapper_accessor ? + StrCat(field->number()) : "", + "field_number2", need_other_name_for_accessor ? + StrCat(field->number()) : ""); } // Generate has method for proto2 only. diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 7e46231ab..9226d4309 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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 228866622..66f5c1cee 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/duration.pb.h b/src/google/protobuf/duration.pb.h index 774b1ebd6..beed27900 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/empty.pb.h b/src/google/protobuf/empty.pb.h index 5ac03a69a..3556bd9cc 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 5bdcd7eb9..22a23db1e 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/port_def.inc b/src/google/protobuf/port_def.inc index 39aaf05f3..c1dc73919 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -285,14 +285,14 @@ // Shared google3/opensource definitions. ////////////////////////////////////// -#define PROTOBUF_VERSION 3007001 -#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3007000 -#define PROTOBUF_MIN_PROTOC_VERSION 3007000 +#define PROTOBUF_VERSION 3008000 +#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3008000 +#define PROTOBUF_MIN_PROTOC_VERSION 3008000 #define PROTOBUF_VERSION_SUFFIX "" // The minimum library version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3007000 +#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3008000 #if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI #define PROTOBUF_RTTI 0 diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 01e356bb0..d46bbc5fd 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/struct.pb.h b/src/google/protobuf/struct.pb.h index 519b3e7e0..2a639f675 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/stubs/common.h b/src/google/protobuf/stubs/common.h index 38331ac0a..29efde1dd 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -81,7 +81,7 @@ 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 3007001 +#define GOOGLE_PROTOBUF_VERSION 3008000 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" @@ -89,15 +89,15 @@ namespace internal { // 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 = 3007000; +static const int kMinHeaderVersionForLibrary = 3008000; // The minimum protoc version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3007000 +#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3008000 // The minimum header version which works with the current version of // protoc. This constant should only be used in VerifyVersion(). -static const int kMinHeaderVersionForProtoc = 3007000; +static const int kMinHeaderVersionForProtoc = 3008000; // Verifies that the headers and libraries are compatible. Use the macro // below to call this. diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index b35ad10aa..76d33296e 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/type.pb.h b/src/google/protobuf/type.pb.h index 6da3d3256..3aad0fa8a 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 5deb4ecc4..c8f09f2bc 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3007000 +#if PROTOBUF_VERSION < 3008000 #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 3007001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3008000 < 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/update_version.py b/update_version.py index 187e7e6d8..38078c1a7 100755 --- a/update_version.py +++ b/update_version.py @@ -177,13 +177,13 @@ def UpdateCsharp(): RewriteXml('csharp/src/Google.Protobuf/Google.Protobuf.csproj', lambda document : ReplaceText( Find(Find(document.documentElement, 'PropertyGroup'), 'VersionPrefix'), - GetFullVersion(rc_suffix = '-rc.')), + GetFullVersion(rc_suffix = '-rc')), add_xml_prefix=False) RewriteXml('csharp/Google.Protobuf.Tools.nuspec', lambda document : ReplaceText( Find(Find(document.documentElement, 'metadata'), 'version'), - GetFullVersion(rc_suffix = '-rc.'))) + GetFullVersion(rc_suffix = '-rc'))) def UpdateJava(): @@ -247,7 +247,7 @@ def UpdateObjectiveC(): RewriteTextFile('Protobuf.podspec', lambda line : re.sub( r"^ s.version = '.*'$", - " s.version = '%s'" % GetFullVersion(rc_suffix = '-rc.'), + " s.version = '%s'" % GetFullVersion(rc_suffix = '-rc'), line)) |