From 37a89f8e1a70d5736dc3e0b5ad4ccdb0eddec06c Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 23 Apr 2019 16:14:52 -0700 Subject: [PATCH 01/51] Update version to 3.8.0 --- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 6 ++--- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 26 ++++++++++++++----- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- src/Makefile.am | 2 +- src/google/protobuf/port_def.inc | 8 +++--- src/google/protobuf/stubs/common.h | 8 +++--- 17 files changed, 44 insertions(+), 30 deletions(-) diff --git a/Protobuf.podspec b/Protobuf.podspec index 1a6699bac9..bf66f4c3d4 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-rc.1' 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 f99817ee61..777a932dcb 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-rc-1],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 7e7a3fd437..3ff6eb6049 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.7.1 + 3.8.0-rc.1 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 57901d8ccf..51bca41b15 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.7.1 + 3.8.0-rc.1 6 Google Inc. netstandard1.0;netstandard2.0;net45 @@ -32,11 +32,11 @@ - + - + diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 90fc53366e..8c501bf19e 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.7.1 + 3.8.0-rc-1 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index c9161b69ac..f05c06cc6e 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.7.1 + 3.8.0-rc-1 protobuf-java diff --git a/java/pom.xml b/java/pom.xml index 5291f9c113..3822179acc 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.7.1 + 3.8.0-rc-1 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 010e522000..f446485e49 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.7.1 + 3.8.0-rc-1 protobuf-java-util diff --git a/js/package.json b/js/package.json index 01e49c34db..43228872ad 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.7.1", + "version": "3.8.0-rc.1", "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 6f5659ff46..ed4eaaaef6 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,15 +10,15 @@ protobuf-opensource@google.com yes - 2019-03-25 - + 2019-04-23 + - 3.7.1 - 3.7.1 + 3.8.0RC1 + 3.8.0 - stable - stable + beta + beta 3-Clause BSD License GA release. @@ -318,5 +318,19 @@ G A release. 3-Clause BSD License GA release. + + + 3.8.0RC1 + 3.8.0 + + + beta + beta + + 2019-04-23 + + 3-Clause BSD License + GA release. + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index cc5c1943a1..ca8d9872d2 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.0RC1" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index a3f610b2b0..e23280a99d 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.7.1 + 3.8.0-rc-1 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 36213d1434..1d3518471a 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.0rc1' if __name__ != '__main__': try: diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 86a37141cf..2b095f4975 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.rc.1" s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" s.description = "Protocol Buffers are Google's data interchange format." diff --git a/src/Makefile.am b/src/Makefile.am index 41bf7b4139..be18ba7614 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/port_def.inc b/src/google/protobuf/port_def.inc index 5694168b3b..15064fbf1c 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/stubs/common.h b/src/google/protobuf/stubs/common.h index 38331ac0a5..29efde1ddb 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. From 1b3c0e418e85b8d31473e6439eed1e4f66dbd0d4 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 23 Apr 2019 17:04:16 -0700 Subject: [PATCH 02/51] Update java lite version --- java/lite/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/lite/pom.xml b/java/lite/pom.xml index f63e275d91..681edbfd59 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -6,7 +6,7 @@ com.google.protobuf protobuf-parent - 3.7.0 + 3.8.0-rc-1 protobuf-javalite From fd3bd962f271eeaf375bc13687806eebba37f142 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Wed, 24 Apr 2019 15:42:23 -0700 Subject: [PATCH 03/51] Update generated files --- src/google/protobuf/any.pb.h | 4 ++-- src/google/protobuf/api.pb.h | 4 ++-- src/google/protobuf/compiler/plugin.pb.h | 4 ++-- src/google/protobuf/descriptor.pb.h | 4 ++-- src/google/protobuf/duration.pb.h | 4 ++-- src/google/protobuf/empty.pb.h | 4 ++-- src/google/protobuf/field_mask.pb.h | 4 ++-- src/google/protobuf/source_context.pb.h | 4 ++-- src/google/protobuf/struct.pb.h | 4 ++-- src/google/protobuf/timestamp.pb.h | 4 ++-- src/google/protobuf/type.pb.h | 4 ++-- src/google/protobuf/wrappers.pb.h | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 214d521c4d..800211b742 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -8,12 +8,12 @@ #include #include -#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 4853593bae..5d4f00077e 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -8,12 +8,12 @@ #include #include -#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/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 9ebd29e13a..9bcb138305 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -8,12 +8,12 @@ #include #include -#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 0920d4196b..43c20a8539 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -8,12 +8,12 @@ #include #include -#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 91ac1e18d1..b117a0a78b 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -8,12 +8,12 @@ #include #include -#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 d65060da80..8d48bb9e09 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -8,12 +8,12 @@ #include #include -#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 57f400c4eb..bc99ea79e1 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -8,12 +8,12 @@ #include #include -#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/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 943c936bf9..9ef68699b3 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -8,12 +8,12 @@ #include #include -#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 5dfd8fae16..b5c78bd0cb 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -8,12 +8,12 @@ #include #include -#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/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index f3ede5c1c8..d4dac2213f 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -8,12 +8,12 @@ #include #include -#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 0ded75db37..f1a8b3e288 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -8,12 +8,12 @@ #include #include -#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 b5ded2a08c..2d9a36695c 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -8,12 +8,12 @@ #include #include -#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. From a80431a0a012f7c72417b5687ad5ee201c0b6119 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Fri, 26 Apr 2019 16:12:22 -0700 Subject: [PATCH 04/51] Remove unused files from lite's pom.xml --- java/lite/pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 681edbfd59..0e360a7080 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -115,7 +115,6 @@ FieldSet.java FieldType.java FloatArrayList.java - GeneratedExtensionRegistryLoader.java GeneratedMessageInfoFactory.java GeneratedMessageLite.java IntArrayList.java @@ -150,12 +149,6 @@ OneofInfo.java Parser.java PrimitiveNonBoxingCollection.java - ProtoField.java - ProtoMessage.java - ProtoOneof.java - ProtoOneofCase.java - ProtoPresenceBits.java - ProtoPresenceCheckedField.java ProtoSyntax.java Protobuf.java ProtobufArrayList.java From 3a5fe3beeeb24e257fe896550f92110fc6390d08 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Mon, 29 Apr 2019 13:01:54 -0700 Subject: [PATCH 05/51] Update change log for 3.8.0 --- CHANGES.txt | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 5a74cd3c0c..72ee37175f 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 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++ From 65fed3f294ef9053f29d511714b1d4e0bcc2fe5f Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Wed, 8 May 2019 19:15:20 -0700 Subject: [PATCH 06/51] Update version for podspec to not include dot (#6111) --- Protobuf.podspec | 2 +- update_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Protobuf.podspec b/Protobuf.podspec index bf66f4c3d4..f657d3d331 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.8.0-rc.1' + s.version = '3.8.0-rc1' 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/update_version.py b/update_version.py index dd01d833c4..ab203d6ea5 100755 --- a/update_version.py +++ b/update_version.py @@ -220,7 +220,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)) From fdfe76102255fa06baf7946922751558bfb847dd Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Thu, 9 May 2019 06:14:32 -0700 Subject: [PATCH 07/51] Fix update version to use the appropriate rc style for C# --- update_version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update_version.py b/update_version.py index ab203d6ea5..dfa53f76b2 100755 --- a/update_version.py +++ b/update_version.py @@ -155,13 +155,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(): From 7597f8ad24980279cacf89eeea76f207da760a93 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Thu, 9 May 2019 20:51:35 -0700 Subject: [PATCH 08/51] Custom mktime to fix issue on mac (#6118) * Custom mktime to fix issue on mac * Remove succeeded tests from failure list --- conformance/failure_list_ruby_mac.txt | 5 --- php/ext/google/protobuf/upb.c | 44 ++++++++++++++++++++++++++- ruby/ext/google/protobuf_c/upb.c | 43 +++++++++++++++++++++++++- 3 files changed, 85 insertions(+), 7 deletions(-) diff --git a/conformance/failure_list_ruby_mac.txt b/conformance/failure_list_ruby_mac.txt index 3114cba878..876184deb6 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/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c index 233c2a2e61..1d977437f6 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/ruby/ext/google/protobuf_c/upb.c b/ruby/ext/google/protobuf_c/upb.c index 28bba7f99b..3d96c5ccc7 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 */ From 531505ca1374bf299c92a58676f1c1407dd81aa1 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Mon, 6 May 2019 17:07:46 -0700 Subject: [PATCH 09/51] Updated gemspec to require Ruby 2.3 or higher --- ruby/google-protobuf.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 2b095f4975..0f7cc0af7a 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -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" From 87f83cc1e8e51bc3181cff3f85fc1213a41c9025 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Mon, 13 May 2019 16:38:07 -0700 Subject: [PATCH 10/51] Make sure to include zlib.BUILD in our distribution --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 903eca7c01..33616c5854 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1223,6 +1223,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 From c40018e52dce3757a1f586ebe27755cb27aa3ba3 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 17 May 2019 15:19:46 -0700 Subject: [PATCH 11/51] Add new file to package.xml (#6116) --- php/ext/google/protobuf/package.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index ed4eaaaef6..6d0ff093b6 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -26,6 +26,7 @@ + From 6d96493b3147a0f253f7eef2447785e19361afe3 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 21 May 2019 13:31:01 -0700 Subject: [PATCH 12/51] Update protobuf version --- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 24 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- 14 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Protobuf.podspec b/Protobuf.podspec index f657d3d331..a05d4bb917 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.8.0-rc1' + 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 777a932dcb..2f025b7ee1 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.8.0-rc-1],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.8.0],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 3ff6eb6049..ccb2dd2c41 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.8.0-rc.1 + 3.8.0 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 51bca41b15..5b292b1dc6 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.8.0-rc.1 + 3.8.0 6 Google Inc. netstandard1.0;netstandard2.0;net45 diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 8c501bf19e..9f09b91ab5 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.8.0-rc-1 + 3.8.0 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index f05c06cc6e..5a355b69bc 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.8.0-rc-1 + 3.8.0 protobuf-java diff --git a/java/pom.xml b/java/pom.xml index 3822179acc..b9b019347f 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.8.0-rc-1 + 3.8.0 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index f446485e49..b2d457b410 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.8.0-rc-1 + 3.8.0 protobuf-java-util diff --git a/js/package.json b/js/package.json index 43228872ad..5b3ab59e69 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.8.0-rc.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 6d0ff093b6..c11be737d2 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,15 +10,15 @@ protobuf-opensource@google.com yes - 2019-04-23 - + 2019-05-21 + - 3.8.0RC1 + 3.8.0 3.8.0 - beta - beta + stable + stable 3-Clause BSD License GA release. @@ -333,5 +333,19 @@ G A release. 3-Clause BSD License GA release. + + + 3.8.0 + 3.8.0 + + + stable + stable + + 2019-05-21 + + 3-Clause BSD License + GA release. + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index ca8d9872d2..058337d97d 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.8.0RC1" +#define PHP_PROTOBUF_VERSION "3.8.0" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index e23280a99d..68f12f5033 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.8.0-rc-1 + 3.8.0 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 1d3518471a..92d2d81903 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.8.0rc1' +__version__ = '3.8.0' if __name__ != '__main__': try: diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 0f7cc0af7a..75db88ffeb 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.8.0.rc.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." From 783971e872c210140daaf15a6ce21628106dd210 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 21 May 2019 13:48:34 -0700 Subject: [PATCH 13/51] Revert "Add new file to package.xml (#6116)" This reverts commit c40018e52dce3757a1f586ebe27755cb27aa3ba3. --- php/ext/google/protobuf/package.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index c11be737d2..a6e232b6bd 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -26,7 +26,6 @@ - From 2352a30e66c0d18071e3120085d101b5ab776ae0 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 21 May 2019 13:49:06 -0700 Subject: [PATCH 14/51] Revert "Update protobuf version" This reverts commit 6d96493b3147a0f253f7eef2447785e19361afe3. --- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 24 ++++--------------- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- 14 files changed, 18 insertions(+), 32 deletions(-) diff --git a/Protobuf.podspec b/Protobuf.podspec index a05d4bb917..f657d3d331 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.8.0' + s.version = '3.8.0-rc1' 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 2f025b7ee1..777a932dcb 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.8.0],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.8.0-rc-1],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index ccb2dd2c41..3ff6eb6049 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.8.0 + 3.8.0-rc.1 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 5b292b1dc6..51bca41b15 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.8.0 + 3.8.0-rc.1 6 Google Inc. netstandard1.0;netstandard2.0;net45 diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 9f09b91ab5..8c501bf19e 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.8.0 + 3.8.0-rc-1 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index 5a355b69bc..f05c06cc6e 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.8.0 + 3.8.0-rc-1 protobuf-java diff --git a/java/pom.xml b/java/pom.xml index b9b019347f..3822179acc 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.8.0 + 3.8.0-rc-1 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index b2d457b410..f446485e49 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.8.0 + 3.8.0-rc-1 protobuf-java-util diff --git a/js/package.json b/js/package.json index 5b3ab59e69..43228872ad 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.8.0", + "version": "3.8.0-rc.1", "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 a6e232b6bd..ed4eaaaef6 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,15 +10,15 @@ protobuf-opensource@google.com yes - 2019-05-21 - + 2019-04-23 + - 3.8.0 + 3.8.0RC1 3.8.0 - stable - stable + beta + beta 3-Clause BSD License GA release. @@ -332,19 +332,5 @@ G A release. 3-Clause BSD License GA release. - - - 3.8.0 - 3.8.0 - - - stable - stable - - 2019-05-21 - - 3-Clause BSD License - GA release. - diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 058337d97d..ca8d9872d2 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.8.0" +#define PHP_PROTOBUF_VERSION "3.8.0RC1" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 68f12f5033..e23280a99d 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.8.0 + 3.8.0-rc-1 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 92d2d81903..1d3518471a 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.8.0' +__version__ = '3.8.0rc1' if __name__ != '__main__': try: diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 75db88ffeb..0f7cc0af7a 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.8.0" + s.version = "3.8.0.rc.1" s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" s.description = "Protocol Buffers are Google's data interchange format." From 46d5cc7de5519d896cb0c32eefe0548680b77ece Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 21 May 2019 13:50:54 -0700 Subject: [PATCH 15/51] Revert "Revert "Add new file to package.xml (#6116)"" This reverts commit 783971e872c210140daaf15a6ce21628106dd210. Revert an accidental revert! --- php/ext/google/protobuf/package.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index ed4eaaaef6..6d0ff093b6 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -26,6 +26,7 @@ + From b0d648664df2cb34fe5bcc6e8a2cff8c20096093 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 21 May 2019 14:07:13 -0700 Subject: [PATCH 16/51] Update protobuf version --- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 24 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- 14 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Protobuf.podspec b/Protobuf.podspec index f657d3d331..a05d4bb917 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.8.0-rc1' + 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 777a932dcb..2f025b7ee1 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.8.0-rc-1],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.8.0],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 3ff6eb6049..ccb2dd2c41 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.8.0-rc.1 + 3.8.0 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 51bca41b15..5b292b1dc6 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.8.0-rc.1 + 3.8.0 6 Google Inc. netstandard1.0;netstandard2.0;net45 diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 8c501bf19e..9f09b91ab5 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.8.0-rc-1 + 3.8.0 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index f05c06cc6e..5a355b69bc 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.8.0-rc-1 + 3.8.0 protobuf-java diff --git a/java/pom.xml b/java/pom.xml index 3822179acc..b9b019347f 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.8.0-rc-1 + 3.8.0 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index f446485e49..b2d457b410 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.8.0-rc-1 + 3.8.0 protobuf-java-util diff --git a/js/package.json b/js/package.json index 43228872ad..5b3ab59e69 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.8.0-rc.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 6d0ff093b6..bf0389de7f 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,15 +10,15 @@ protobuf-opensource@google.com yes - 2019-04-23 - + 2019-05-21 + - 3.8.0RC1 + 3.8.0 3.8.0 - beta - beta + stable + stable 3-Clause BSD License GA release. @@ -333,5 +333,19 @@ G A release. 3-Clause BSD License GA release. + + + 3.8.0 + 3.8.0 + + + stable + stable + + 2019-05-21 + + 3-Clause BSD License + GA release. + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index ca8d9872d2..058337d97d 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.8.0RC1" +#define PHP_PROTOBUF_VERSION "3.8.0" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index e23280a99d..68f12f5033 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.8.0-rc-1 + 3.8.0 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 1d3518471a..92d2d81903 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.8.0rc1' +__version__ = '3.8.0' if __name__ != '__main__': try: diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 0f7cc0af7a..75db88ffeb 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.8.0.rc.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." From 014872a962a85fe11cd5a1798a8a390b64493c48 Mon Sep 17 00:00:00 2001 From: Seth Girvan Date: Tue, 30 Apr 2019 17:35:36 -0700 Subject: [PATCH 17/51] Revert "protobuf.pc.in does not reflect CXXFLAGS" This reverts commit a7180caf19ae150d9a3f9724600b0eed4b5da830. --- protobuf.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobuf.pc.in b/protobuf.pc.in index 282fef35b2..4e88b514a2 100644 --- a/protobuf.pc.in +++ b/protobuf.pc.in @@ -8,5 +8,5 @@ Description: Google's Data Interchange Format Version: @VERSION@ Libs: -L${libdir} -lprotobuf @PTHREAD_LIBS@ Libs.private: @LIBS@ -Cflags: -I${includedir} @PTHREAD_CFLAGS@ @CXXFLAGS@ +Cflags: -I${includedir} @PTHREAD_CFLAGS@ Conflicts: protobuf-lite From 565154af78c01c0424833022179dbfbe43fb081c Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Wed, 22 May 2019 13:21:51 -0600 Subject: [PATCH 18/51] Remove Ruby to_hash methods --- ruby/ext/google/protobuf_c/map.c | 1 - ruby/ext/google/protobuf_c/message.c | 1 - ruby/src/main/java/com/google/protobuf/jruby/RubyMap.java | 2 +- ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ruby/ext/google/protobuf_c/map.c b/ruby/ext/google/protobuf_c/map.c index 55b7be4c66..cf1d6e3771 100644 --- a/ruby/ext/google/protobuf_c/map.c +++ b/ruby/ext/google/protobuf_c/map.c @@ -847,7 +847,6 @@ void Map_register(VALUE module) { rb_define_method(klass, "dup", Map_dup, 0); rb_define_method(klass, "==", Map_eq, 1); rb_define_method(klass, "hash", Map_hash, 0); - rb_define_method(klass, "to_hash", Map_to_h, 0); rb_define_method(klass, "to_h", Map_to_h, 0); rb_define_method(klass, "inspect", Map_inspect, 0); rb_define_method(klass, "merge", Map_merge, 1); diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c index 850ab0eb5d..2f02c35445 100644 --- a/ruby/ext/google/protobuf_c/message.c +++ b/ruby/ext/google/protobuf_c/message.c @@ -737,7 +737,6 @@ VALUE build_class_from_descriptor(Descriptor* desc) { rb_define_method(klass, "eql?", Message_eq, 1); rb_define_method(klass, "hash", Message_hash, 0); rb_define_method(klass, "to_h", Message_to_h, 0); - rb_define_method(klass, "to_hash", Message_to_h, 0); rb_define_method(klass, "inspect", Message_inspect, 0); rb_define_method(klass, "to_s", Message_inspect, 0); rb_define_method(klass, "[]", Message_index, 1); diff --git a/ruby/src/main/java/com/google/protobuf/jruby/RubyMap.java b/ruby/src/main/java/com/google/protobuf/jruby/RubyMap.java index 3adaa2a8bd..89738624b8 100644 --- a/ruby/src/main/java/com/google/protobuf/jruby/RubyMap.java +++ b/ruby/src/main/java/com/google/protobuf/jruby/RubyMap.java @@ -338,7 +338,7 @@ public class RubyMap extends RubyObject { return newMap; } - @JRubyMethod(name = {"to_h", "to_hash"}) + @JRubyMethod(name = "to_h") public RubyHash toHash(ThreadContext context) { return RubyHash.newHash(context.runtime, table, context.runtime.getNil()); } diff --git a/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java b/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java index c3a0d81c14..774db65a12 100644 --- a/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java +++ b/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java @@ -368,7 +368,7 @@ public class RubyMessage extends RubyObject { return ret; } - @JRubyMethod(name = {"to_h", "to_hash"}) + @JRubyMethod(name = "to_h") public IRubyObject toHash(ThreadContext context) { Ruby runtime = context.runtime; RubyHash ret = RubyHash.newHash(runtime); From 6d83327a86d8540b3ef914389f7c6695413e3e3e Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Wed, 1 May 2019 13:22:07 -0700 Subject: [PATCH 19/51] Fix gulpfile to use gulp 4 API --- js/gulpfile.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/js/gulpfile.js b/js/gulpfile.js index b2366995e8..449ae502c2 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js @@ -144,7 +144,7 @@ function getClosureBuilderCommand(exportsFile, outputFile) { exportsFile + ' > ' + outputFile; } -gulp.task('dist', ['genproto_wellknowntypes'], function (cb) { +gulp.task('dist', gulp.series(['genproto_wellknowntypes'], function (cb) { // TODO(haberman): minify this more aggressively. // Will require proper externs/exports. exec(getClosureBuilderCommand('commonjs/export.js', 'google-protobuf.js'), @@ -153,7 +153,7 @@ gulp.task('dist', ['genproto_wellknowntypes'], function (cb) { console.log(stderr); cb(err); }); -}); +})); gulp.task('commonjs_asserts', function (cb) { exec('mkdir -p commonjs_out/test_node_modules && ' + @@ -179,7 +179,7 @@ gulp.task('commonjs_testdeps', function (cb) { }); }); -gulp.task('make_commonjs_out', ['dist', 'genproto_well_known_types_commonjs', 'genproto_group1_commonjs', 'genproto_group2_commonjs', 'genproto_commonjs_wellknowntypes', 'commonjs_asserts', 'commonjs_testdeps', 'genproto_group3_commonjs_strict'], function (cb) { +gulp.task('make_commonjs_out', gulp.series(['dist', 'genproto_well_known_types_commonjs', 'genproto_group1_commonjs', 'genproto_group2_commonjs', 'genproto_commonjs_wellknowntypes', 'commonjs_asserts', 'commonjs_testdeps', 'genproto_group3_commonjs_strict'], function (cb) { // TODO(haberman): minify this more aggressively. // Will require proper externs/exports. var cmd = "mkdir -p commonjs_out/binary && mkdir -p commonjs_out/test_node_modules && "; @@ -201,35 +201,35 @@ gulp.task('make_commonjs_out', ['dist', 'genproto_well_known_types_commonjs', 'g console.log(stderr); cb(err); }); -}); +})); -gulp.task('deps', ['genproto_well_known_types_closure', 'genproto_group1_closure', 'genproto_group2_closure'], function (cb) { +gulp.task('deps', gulp.series(['genproto_well_known_types_closure', 'genproto_group1_closure', 'genproto_group2_closure'], function (cb) { exec('./node_modules/google-closure-library/closure/bin/build/depswriter.py binary/arith.js binary/constants.js binary/decoder.js binary/encoder.js binary/reader.js binary/utils.js binary/writer.js debug.js map.js message.js node_loader.js test_bootstrap.js > deps.js', function (err, stdout, stderr) { console.log(stdout); console.log(stderr); cb(err); }); -}); +})); -gulp.task('test_closure', ['genproto_well_known_types_closure', 'genproto_group1_closure', 'genproto_group2_closure', 'deps'], function (cb) { +gulp.task('test_closure', gulp.series(['genproto_well_known_types_closure', 'genproto_group1_closure', 'genproto_group2_closure', 'deps'], function (cb) { exec('JASMINE_CONFIG_PATH=jasmine.json ./node_modules/.bin/jasmine', function (err, stdout, stderr) { console.log(stdout); console.log(stderr); cb(err); }); -}); +})); -gulp.task('test_commonjs', ['make_commonjs_out'], function (cb) { +gulp.task('test_commonjs', gulp.series(['make_commonjs_out'], function (cb) { exec('cd commonjs_out && JASMINE_CONFIG_PATH=jasmine.json NODE_PATH=test_node_modules ../node_modules/.bin/jasmine', function (err, stdout, stderr) { console.log(stdout); console.log(stderr); cb(err); }); -}); +})); -gulp.task('test', ['test_closure', 'test_commonjs'], function(cb) { +gulp.task('test', gulp.series(['test_closure', 'test_commonjs'], function(cb) { cb(); -}); +})); From f9cd7bd9b3a00e57dac1ea26d121c495e99f5baf Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Wed, 1 May 2019 12:42:52 -0700 Subject: [PATCH 20/51] Upgrade gulp version --- js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/package.json b/js/package.json index 43228872ad..310b555474 100644 --- a/js/package.json +++ b/js/package.json @@ -11,7 +11,7 @@ "glob": "~6.0.4", "google-closure-compiler": "~20190301.0.0", "google-closure-library": "~20190301.0.0", - "gulp": "~3.9.0", + "gulp": "~4.0.1", "jasmine": "~2.4.1" }, "scripts": { From 9a8ef05a34dab7583b6f253daca294d6b1bfb187 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 24 May 2019 10:00:09 -0700 Subject: [PATCH 21/51] Append field number to accessors if there is conflict (#6169) Previously, foo_value and foo (wrapper field) will both have get/setFooValue --- .../proto/test_wrapper_type_setters.proto | 11 +++ php/tests/wrapper_type_setters_test.php | 38 +++++++++++ .../protobuf/compiler/php/php_generator.cc | 68 +++++++++++++++---- 3 files changed, 104 insertions(+), 13 deletions(-) diff --git a/php/tests/proto/test_wrapper_type_setters.proto b/php/tests/proto/test_wrapper_type_setters.proto index 41ca7f3f31..119bd2547a 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 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 5509a175a1..35e3a7dec1 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/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index d7e33b2c06..8e405608a8 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. From 95c207f24e462028d3ffca49819f3a0fbc978707 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 24 May 2019 10:01:58 -0700 Subject: [PATCH 22/51] Add use_nested to internalAddGeneratedFile for php implementation (#6117) --- php/src/Google/Protobuf/Internal/DescriptorPool.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/src/Google/Protobuf/Internal/DescriptorPool.php b/php/src/Google/Protobuf/Internal/DescriptorPool.php index 9b4dcc0115..419bbf4dca 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); From ca3ead7745581b24d9e84471b5dee6921fcd369d Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Tue, 21 May 2019 17:31:34 -0700 Subject: [PATCH 23/51] Move tool out of inputs in bazel config This fixes compatibility with bazel when passing `--incompatible_no_support_tools_in_action_inputs` which will be flipped in an upcoming release. --- protobuf.bzl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protobuf.bzl b/protobuf.bzl index e764859b4a..2fd31d081c 100644 --- a/protobuf.bzl +++ b/protobuf.bzl @@ -158,10 +158,11 @@ def _proto_gen_impl(ctx): if generated_out != out.path: command += ";mv %s %s" % (generated_out, out.path) ctx.actions.run_shell( - inputs = inputs + [ctx.executable.protoc], + inputs = inputs, outputs = [out], command = command, mnemonic = "ProtoCompile", + tools = [ctx.executable.protoc], use_default_shell_env = True, ) From 37297b25f64885708039aa757e90fba513535aa5 Mon Sep 17 00:00:00 2001 From: Amit Portnoy <1131991+amitport@users.noreply.github.com> Date: Tue, 28 May 2019 17:47:17 +0300 Subject: [PATCH 24/51] avoid error when compiling with MSVC2010 I'm getting `src/google/protobuf/map_field.cc(284): error C2899: typename cannot be used outside a template declaration` removing `typename` fixes the issue --- src/google/protobuf/map_field.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/protobuf/map_field.cc b/src/google/protobuf/map_field.cc index dbce28eaa0..880f3e188f 100644 --- a/src/google/protobuf/map_field.cc +++ b/src/google/protobuf/map_field.cc @@ -281,7 +281,7 @@ void DynamicMapField::MergeFrom(const MapFieldBase& other) { Map* map = MutableMap(); const DynamicMapField& other_field = reinterpret_cast(other); - for (typename Map::const_iterator other_it = + for (Map::const_iterator other_it = other_field.map_.begin(); other_it != other_field.map_.end(); ++other_it) { Map::iterator iter = map->find(other_it->first); From beaeaeda34e97a6ff9735b33a66e011102ab506b Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Wed, 29 May 2019 15:03:24 -0400 Subject: [PATCH 25/51] Use runtime_error vs just exiting for some issues. release notes: no --- conformance/conformance_objc.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/conformance/conformance_objc.m b/conformance/conformance_objc.m index 60b2ac59ed..1d677034e6 100644 --- a/conformance/conformance_objc.m +++ b/conformance/conformance_objc.m @@ -68,7 +68,8 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) { switch (request.payloadOneOfCase) { case ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase: - Die(@"Request didn't have a payload: %@", request); + response.runtimeError = + [NSString stringWithFormat:@"Request didn't have a payload: %@", request]; break; case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: { @@ -78,7 +79,10 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) { } else if ([request.messageType isEqual:@"protobuf_test_messages.proto2.TestAllTypesProto2"]) { msgClass = [TestAllTypesProto2 class]; } else { - Die(@"Protobuf request had an unknown message_type: %@", request.messageType); + response.runtimeError = + [NSString stringWithFormat: + @"Protobuf request had an unknown message_type: %@", request.messageType]; + break; } NSError *error = nil; testMessage = [msgClass parseFromData:request.protobufPayload error:&error]; @@ -108,7 +112,8 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) { switch (request.requestedOutputFormat) { case WireFormat_GPBUnrecognizedEnumeratorValue: case WireFormat_Unspecified: - Die(@"Unrecognized/unspecified output format: %@", request); + response.runtimeError = + [NSString stringWithFormat:@"Unrecognized/unspecified output format: %@", request]; break; case WireFormat_Protobuf: From 044c766fd4777713fef2d1a9a095e4308d770c68 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Thu, 30 May 2019 13:31:15 -0700 Subject: [PATCH 26/51] Down integrate to GitHub --- conformance/conformance_objc.m | 11 +- .../com/google/protobuf/util/Structs.java | 65 ++++ .../java/com/google/protobuf/util/Values.java | 85 +++++ .../com/google/protobuf/util/StructsTest.java | 59 ++++ .../com/google/protobuf/util/ValuesTest.java | 102 ++++++ python/google/protobuf/descriptor_pool.py | 2 - .../google/protobuf/internal/message_test.py | 2 + python/google/protobuf/pyext/map_container.cc | 85 ++--- src/google/protobuf/any.pb.cc | 6 +- src/google/protobuf/any.pb.h | 2 +- src/google/protobuf/api.pb.cc | 26 +- src/google/protobuf/api.pb.h | 6 +- src/google/protobuf/compiler/cpp/cpp_field.cc | 2 +- .../protobuf/compiler/cpp/cpp_helpers.cc | 13 +- .../protobuf/compiler/cpp/cpp_message.cc | 4 +- .../compiler/cpp/cpp_message_field.cc | 20 +- .../protobuf/compiler/cpp/cpp_string_field.cc | 2 +- src/google/protobuf/compiler/parser.cc | 16 + .../protobuf/compiler/parser_unittest.cc | 43 +++ src/google/protobuf/compiler/plugin.pb.cc | 34 +- src/google/protobuf/compiler/plugin.pb.h | 8 +- src/google/protobuf/descriptor.pb.cc | 314 +++++++++--------- src/google/protobuf/descriptor.pb.h | 54 +-- src/google/protobuf/descriptor.proto | 1 + src/google/protobuf/duration.pb.cc | 2 +- src/google/protobuf/duration.pb.h | 2 +- src/google/protobuf/empty.pb.cc | 2 +- src/google/protobuf/empty.pb.h | 2 +- src/google/protobuf/field_mask.pb.cc | 2 +- src/google/protobuf/field_mask.pb.h | 2 +- src/google/protobuf/map_test.cc | 12 +- src/google/protobuf/source_context.pb.cc | 4 +- src/google/protobuf/source_context.pb.h | 2 +- src/google/protobuf/struct.pb.cc | 18 +- src/google/protobuf/struct.pb.h | 6 +- src/google/protobuf/text_format.cc | 16 +- src/google/protobuf/text_format.h | 5 + src/google/protobuf/timestamp.pb.cc | 2 +- src/google/protobuf/timestamp.pb.h | 2 +- src/google/protobuf/type.pb.cc | 44 +-- src/google/protobuf/type.pb.h | 10 +- .../util/internal/json_objectwriter_test.cc | 52 ++- src/google/protobuf/wrappers.pb.cc | 22 +- src/google/protobuf/wrappers.pb.h | 18 +- 44 files changed, 785 insertions(+), 402 deletions(-) create mode 100755 java/util/src/main/java/com/google/protobuf/util/Structs.java create mode 100755 java/util/src/main/java/com/google/protobuf/util/Values.java create mode 100755 java/util/src/test/java/com/google/protobuf/util/StructsTest.java create mode 100755 java/util/src/test/java/com/google/protobuf/util/ValuesTest.java diff --git a/conformance/conformance_objc.m b/conformance/conformance_objc.m index 1d677034e6..60b2ac59ed 100644 --- a/conformance/conformance_objc.m +++ b/conformance/conformance_objc.m @@ -68,8 +68,7 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) { switch (request.payloadOneOfCase) { case ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase: - response.runtimeError = - [NSString stringWithFormat:@"Request didn't have a payload: %@", request]; + Die(@"Request didn't have a payload: %@", request); break; case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: { @@ -79,10 +78,7 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) { } else if ([request.messageType isEqual:@"protobuf_test_messages.proto2.TestAllTypesProto2"]) { msgClass = [TestAllTypesProto2 class]; } else { - response.runtimeError = - [NSString stringWithFormat: - @"Protobuf request had an unknown message_type: %@", request.messageType]; - break; + Die(@"Protobuf request had an unknown message_type: %@", request.messageType); } NSError *error = nil; testMessage = [msgClass parseFromData:request.protobufPayload error:&error]; @@ -112,8 +108,7 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) { switch (request.requestedOutputFormat) { case WireFormat_GPBUnrecognizedEnumeratorValue: case WireFormat_Unspecified: - response.runtimeError = - [NSString stringWithFormat:@"Unrecognized/unspecified output format: %@", request]; + Die(@"Unrecognized/unspecified output format: %@", request); break; case WireFormat_Protobuf: diff --git a/java/util/src/main/java/com/google/protobuf/util/Structs.java b/java/util/src/main/java/com/google/protobuf/util/Structs.java new file mode 100755 index 0000000000..b1696ecdbc --- /dev/null +++ b/java/util/src/main/java/com/google/protobuf/util/Structs.java @@ -0,0 +1,65 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package com.google.protobuf.util; + +import com.google.protobuf.Struct; +import com.google.protobuf.Value; + +/** Utilities to help create {@code google.protobuf.Struct} messages. */ +public final class Structs { + + /** + * Returns a struct containing the key-value pair. + */ + public static Struct of(String k1, Value v1) { + return Struct.newBuilder().putFields(k1, v1).build(); + } + + /** + * Returns a struct containing each of the key-value pairs. + * + *

Providing duplicate keys is undefined behavior. + */ + public static Struct of(String k1, Value v1, String k2, Value v2) { + return Struct.newBuilder().putFields(k1, v1).putFields(k2, v2).build(); + } + + /** + * Returns a struct containing each of the key-value pairs. + * + *

Providing duplicate keys is undefined behavior. + */ + public static Struct of(String k1, Value v1, String k2, Value v2, String k3, Value v3) { + return Struct.newBuilder().putFields(k1, v1).putFields(k2, v2).putFields(k3, v3).build(); + } + + private Structs() {} +} diff --git a/java/util/src/main/java/com/google/protobuf/util/Values.java b/java/util/src/main/java/com/google/protobuf/util/Values.java new file mode 100755 index 0000000000..b3ade2ddfb --- /dev/null +++ b/java/util/src/main/java/com/google/protobuf/util/Values.java @@ -0,0 +1,85 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package com.google.protobuf.util; + +import com.google.protobuf.ListValue; +import com.google.protobuf.NullValue; +import com.google.protobuf.Struct; +import com.google.protobuf.Value; + +/** Utilities to help create {@code google.protobuf.Value} messages. */ +public final class Values { + + private static final Value NULL_VALUE = + Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build(); + + public static Value ofNull() { + return NULL_VALUE; + } + + /** Returns a Value object with number set to value. */ + public static Value of(boolean value) { + return Value.newBuilder().setBoolValue(value).build(); + } + + /** Returns a Value object with number set to value. */ + public static Value of(double value) { + return Value.newBuilder().setNumberValue(value).build(); + } + + /** Returns a Value object with string set to value. */ + public static Value of(String value) { + return Value.newBuilder().setStringValue(value).build(); + } + + /** Returns a Value object with struct set to value. */ + public static Value of(Struct value) { + return Value.newBuilder().setStructValue(value).build(); + } + + /** Returns a Value with ListValue set to value. */ + public static Value of(ListValue value) { + return Value.newBuilder().setListValue(value).build(); + } + + /** + * Returns a Value with ListValue set to the appending the result of calling {@link #of(Object)} + * on each element in the iterable. + */ + public static Value of(Iterable values) { + Value.Builder valueBuilder = Value.newBuilder(); + ListValue.Builder listValue = valueBuilder.getListValueBuilder(); + listValue.addAllValues(values); + return valueBuilder.build(); + } + + private Values() {} +} diff --git a/java/util/src/test/java/com/google/protobuf/util/StructsTest.java b/java/util/src/test/java/com/google/protobuf/util/StructsTest.java new file mode 100755 index 0000000000..265aff5776 --- /dev/null +++ b/java/util/src/test/java/com/google/protobuf/util/StructsTest.java @@ -0,0 +1,59 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package com.google.protobuf.util; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.protobuf.Struct; +import junit.framework.TestCase; + +public final class StructsTest extends TestCase { + + public void test1pair_constructsObject() throws Exception { + Struct.Builder expected = Struct.newBuilder(); + JsonFormat.parser().merge("{\"k1\": 1}", expected); + assertThat(Structs.of("k1", Values.of(1))).isEqualTo(expected.build()); + } + + public void test2pair_constructsObject() throws Exception { + Struct.Builder expected = Struct.newBuilder(); + JsonFormat.parser().merge("{\"k1\": 1, \"k2\": 2}", expected); + assertThat(Structs.of("k1", Values.of(1), "k2", Values.of(2))).isEqualTo(expected.build()); + } + + public void test3pair_constructsObject() throws Exception { + Struct.Builder expected = Struct.newBuilder(); + JsonFormat.parser().merge("{\"k1\": 1, \"k2\": 2, \"k3\": 3}", expected); + assertThat(Structs.of("k1", Values.of(1), "k2", Values.of(2), "k3", Values.of(3))) + .isEqualTo(expected.build()); + } + +} diff --git a/java/util/src/test/java/com/google/protobuf/util/ValuesTest.java b/java/util/src/test/java/com/google/protobuf/util/ValuesTest.java new file mode 100755 index 0000000000..d646e97282 --- /dev/null +++ b/java/util/src/test/java/com/google/protobuf/util/ValuesTest.java @@ -0,0 +1,102 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package com.google.protobuf.util; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.protobuf.ListValue; +import com.google.protobuf.NullValue; +import com.google.protobuf.Struct; +import com.google.protobuf.Value; +import java.util.ArrayList; +import java.util.List; +import junit.framework.TestCase; + +public final class ValuesTest extends TestCase { + public void testOfNull_IsNullValue() throws Exception { + assertThat(Values.ofNull()) + .isEqualTo(Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()); + } + + public void testOfBoolean_ConstructsValue() { + assertThat(Values.of(true)).isEqualTo(Value.newBuilder().setBoolValue(true).build()); + assertThat(Values.of(false)).isEqualTo(Value.newBuilder().setBoolValue(false).build()); + } + + public void testOfNumeric_ConstructsValue() { + assertThat(Values.of(100)).isEqualTo(Value.newBuilder().setNumberValue(100).build()); + assertThat(Values.of(1000L)).isEqualTo(Value.newBuilder().setNumberValue(1000).build()); + assertThat(Values.of(1000.23f)).isEqualTo(Value.newBuilder().setNumberValue(1000.23f).build()); + assertThat(Values.of(10000.23)).isEqualTo(Value.newBuilder().setNumberValue(10000.23).build()); + } + + public void testOfString_ConstructsValue() { + assertThat(Values.of("")).isEqualTo(Value.newBuilder().setStringValue("").build()); + assertThat(Values.of("foo")).isEqualTo(Value.newBuilder().setStringValue("foo").build()); + } + + public void testOfStruct_ConstructsValue() { + Struct.Builder builder = Struct.newBuilder(); + builder.putFields("a", Values.of("a")); + builder.putFields("b", Values.of("b")); + + assertThat(Values.of(builder.build())) + .isEqualTo(Value.newBuilder().setStructValue(builder.build()).build()); + } + + public void testOfListValue_ConstructsInstance() { + ListValue.Builder builder = ListValue.newBuilder(); + builder.addValues(Values.of(1)); + builder.addValues(Values.of(2)); + + assertThat(Values.of(builder.build())) + .isEqualTo(Value.newBuilder().setListValue(builder.build()).build()); + } + + public void testOfIterable_ReturnsTheValue() { + ListValue.Builder builder = ListValue.newBuilder(); + builder.addValues(Values.of(1)); + builder.addValues(Values.of(2)); + builder.addValues(Values.of(true)); + builder.addValues(Value.newBuilder().setListValue(builder.build()).build()); + + List list = new ArrayList<>(); + list.add(Values.of(1)); + list.add(Values.of(2)); + list.add(Values.of(true)); + List copyList = new ArrayList<>(list); + list.add(Values.of(copyList)); + + assertThat(Values.of(list)).isEqualTo(Value.newBuilder().setListValue(builder).build()); + assertThat(Values.of(new ArrayList())) + .isEqualTo(Value.newBuilder().setListValue(ListValue.getDefaultInstance()).build()); + } +} diff --git a/python/google/protobuf/descriptor_pool.py b/python/google/protobuf/descriptor_pool.py index bc5029a557..f41dc522c6 100644 --- a/python/google/protobuf/descriptor_pool.py +++ b/python/google/protobuf/descriptor_pool.py @@ -99,8 +99,6 @@ def _IsMessageSetExtension(field): field.label == descriptor.FieldDescriptor.LABEL_OPTIONAL) - - class DescriptorPool(object): """A collection of protobufs dynamically constructed by descriptor protos.""" diff --git a/python/google/protobuf/internal/message_test.py b/python/google/protobuf/internal/message_test.py index 3927ce1cdf..9de3e7a016 100755 --- a/python/google/protobuf/internal/message_test.py +++ b/python/google/protobuf/internal/message_test.py @@ -1725,6 +1725,7 @@ class Proto3Test(unittest.TestCase): self.assertIsNone(msg.map_int32_int32.get(5)) self.assertEqual(10, msg.map_int32_int32.get(5, 10)) + self.assertEqual(10, msg.map_int32_int32.get(key=5, default=10)) self.assertIsNone(msg.map_int32_int32.get(5)) msg.map_int32_int32[5] = 15 @@ -1735,6 +1736,7 @@ class Proto3Test(unittest.TestCase): self.assertIsNone(msg.map_int32_foreign_message.get(5)) self.assertEqual(10, msg.map_int32_foreign_message.get(5, 10)) + self.assertEqual(10, msg.map_int32_foreign_message.get(key=5, default=10)) submsg = msg.map_int32_foreign_message[5] self.assertIs(submsg, msg.map_int32_foreign_message.get(5)) diff --git a/python/google/protobuf/pyext/map_container.cc b/python/google/protobuf/pyext/map_container.cc index 07c94c779c..9c8727efab 100644 --- a/python/google/protobuf/pyext/map_container.cc +++ b/python/google/protobuf/pyext/map_container.cc @@ -464,10 +464,13 @@ int MapReflectionFriend::ScalarMapSetItem(PyObject* _self, PyObject* key, } } -static PyObject* ScalarMapGet(PyObject* self, PyObject* args) { +static PyObject* ScalarMapGet(PyObject* self, PyObject* args, + PyObject* kwargs) { + static char* kwlist[] = {"key", "default", nullptr}; PyObject* key; PyObject* default_value = NULL; - if (PyArg_ParseTuple(args, "O|O", &key, &default_value) < 0) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist, &key, + &default_value)) { return NULL; } @@ -532,23 +535,23 @@ static void ScalarMapDealloc(PyObject* _self) { } static PyMethodDef ScalarMapMethods[] = { - { "__contains__", MapReflectionFriend::Contains, METH_O, - "Tests whether a key is a member of the map." }, - { "clear", (PyCFunction)Clear, METH_NOARGS, - "Removes all elements from the map." }, - { "get", ScalarMapGet, METH_VARARGS, - "Gets the value for the given key if present, or otherwise a default" }, - { "GetEntryClass", (PyCFunction)GetEntryClass, METH_NOARGS, - "Return the class used to build Entries of (key, value) pairs." }, - { "MergeFrom", (PyCFunction)MapReflectionFriend::MergeFrom, METH_O, - "Merges a map into the current map." }, - /* - { "__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS, - "Makes a deep copy of the class." }, - { "__reduce__", (PyCFunction)Reduce, METH_NOARGS, - "Outputs picklable representation of the repeated field." }, - */ - {NULL, NULL}, + {"__contains__", MapReflectionFriend::Contains, METH_O, + "Tests whether a key is a member of the map."}, + {"clear", (PyCFunction)Clear, METH_NOARGS, + "Removes all elements from the map."}, + {"get", (PyCFunction)ScalarMapGet, METH_VARARGS | METH_KEYWORDS, + "Gets the value for the given key if present, or otherwise a default"}, + {"GetEntryClass", (PyCFunction)GetEntryClass, METH_NOARGS, + "Return the class used to build Entries of (key, value) pairs."}, + {"MergeFrom", (PyCFunction)MapReflectionFriend::MergeFrom, METH_O, + "Merges a map into the current map."}, + /* + { "__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS, + "Makes a deep copy of the class." }, + { "__reduce__", (PyCFunction)Reduce, METH_NOARGS, + "Outputs picklable representation of the repeated field." }, + */ + {NULL, NULL}, }; PyTypeObject *ScalarMapContainer_Type; @@ -773,10 +776,12 @@ PyObject* MapReflectionFriend::MessageMapToStr(PyObject* _self) { return PyObject_Repr(dict.get()); } -PyObject* MessageMapGet(PyObject* self, PyObject* args) { +PyObject* MessageMapGet(PyObject* self, PyObject* args, PyObject* kwargs) { + static char* kwlist[] = {"key", "default", nullptr}; PyObject* key; PyObject* default_value = NULL; - if (PyArg_ParseTuple(args, "O|O", &key, &default_value) < 0) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist, &key, + &default_value)) { return NULL; } @@ -810,25 +815,25 @@ static void MessageMapDealloc(PyObject* _self) { } static PyMethodDef MessageMapMethods[] = { - { "__contains__", (PyCFunction)MapReflectionFriend::Contains, METH_O, - "Tests whether the map contains this element."}, - { "clear", (PyCFunction)Clear, METH_NOARGS, - "Removes all elements from the map."}, - { "get", MessageMapGet, METH_VARARGS, - "Gets the value for the given key if present, or otherwise a default" }, - { "get_or_create", MapReflectionFriend::MessageMapGetItem, METH_O, - "Alias for getitem, useful to make explicit that the map is mutated." }, - { "GetEntryClass", (PyCFunction)GetEntryClass, METH_NOARGS, - "Return the class used to build Entries of (key, value) pairs." }, - { "MergeFrom", (PyCFunction)MapReflectionFriend::MergeFrom, METH_O, - "Merges a map into the current map." }, - /* - { "__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS, - "Makes a deep copy of the class." }, - { "__reduce__", (PyCFunction)Reduce, METH_NOARGS, - "Outputs picklable representation of the repeated field." }, - */ - {NULL, NULL}, + {"__contains__", (PyCFunction)MapReflectionFriend::Contains, METH_O, + "Tests whether the map contains this element."}, + {"clear", (PyCFunction)Clear, METH_NOARGS, + "Removes all elements from the map."}, + {"get", (PyCFunction)MessageMapGet, METH_VARARGS | METH_KEYWORDS, + "Gets the value for the given key if present, or otherwise a default"}, + {"get_or_create", MapReflectionFriend::MessageMapGetItem, METH_O, + "Alias for getitem, useful to make explicit that the map is mutated."}, + {"GetEntryClass", (PyCFunction)GetEntryClass, METH_NOARGS, + "Return the class used to build Entries of (key, value) pairs."}, + {"MergeFrom", (PyCFunction)MapReflectionFriend::MergeFrom, METH_O, + "Merges a map into the current map."}, + /* + { "__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS, + "Makes a deep copy of the class." }, + { "__reduce__", (PyCFunction)Reduce, METH_NOARGS, + "Outputs picklable representation of the repeated field." }, + */ + {NULL, NULL}, }; PyTypeObject *MessageMapContainer_Type; diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 778773b8d4..879db89725 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -111,7 +111,7 @@ bool Any::ParseAnyTypeUrl(const string& type_url, full_type_name); } -class Any::HasBitSetters { +class Any::_Internal { public: }; @@ -131,11 +131,11 @@ Any::Any(const Any& from) _any_metadata_(&type_url_, &value_) { _internal_metadata_.MergeFrom(from._internal_metadata_); type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.type_url().size() > 0) { + if (!from.type_url().empty()) { type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.type_url_); } value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.value().size() > 0) { + if (!from.value().empty()) { value_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.value_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Any) diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 214d521c4d..5383adf68b 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -217,7 +217,7 @@ class PROTOBUF_EXPORT Any : // @@protoc_insertion_point(class_scope:google.protobuf.Any) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_url_; diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index bc07c60fbe..29060c09b0 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -178,13 +178,13 @@ void Api::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_Api_default_instance_._instance.get_mutable()->source_context_ = const_cast< PROTOBUF_NAMESPACE_ID::SourceContext*>( PROTOBUF_NAMESPACE_ID::SourceContext::internal_default_instance()); } -class Api::HasBitSetters { +class Api::_Internal { public: static const PROTOBUF_NAMESPACE_ID::SourceContext& source_context(const Api* msg); }; const PROTOBUF_NAMESPACE_ID::SourceContext& -Api::HasBitSetters::source_context(const Api* msg) { +Api::_Internal::source_context(const Api* msg) { return *msg->source_context_; } void Api::clear_options() { @@ -219,11 +219,11 @@ Api::Api(const Api& from) mixins_(from.mixins_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.name().size() > 0) { + if (!from.name().empty()) { name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); } version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.version().size() > 0) { + if (!from.version().empty()) { version_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.version_); } if (from.has_source_context()) { @@ -542,7 +542,7 @@ void Api::SerializeWithCachedSizes( // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, HasBitSetters::source_context(this), output); + 5, _Internal::source_context(this), output); } // repeated .google.protobuf.Mixin mixins = 6; @@ -615,7 +615,7 @@ void Api::SerializeWithCachedSizes( if (this->has_source_context()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 5, HasBitSetters::source_context(this), target); + 5, _Internal::source_context(this), target); } // repeated .google.protobuf.Mixin mixins = 6; @@ -804,7 +804,7 @@ void Api::InternalSwap(Api* other) { void Method::InitAsDefaultInstance() { } -class Method::HasBitSetters { +class Method::_Internal { public: }; @@ -832,15 +832,15 @@ Method::Method(const Method& from) options_(from.options_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.name().size() > 0) { + if (!from.name().empty()) { name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); } request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.request_type_url().size() > 0) { + if (!from.request_type_url().empty()) { request_type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.request_type_url_); } response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.response_type_url().size() > 0) { + if (!from.response_type_url().empty()) { response_type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.response_type_url_); } ::memcpy(&request_streaming_, &from.request_streaming_, @@ -1402,7 +1402,7 @@ void Method::InternalSwap(Method* other) { void Mixin::InitAsDefaultInstance() { } -class Mixin::HasBitSetters { +class Mixin::_Internal { public: }; @@ -1421,11 +1421,11 @@ Mixin::Mixin(const Mixin& from) _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.name().size() > 0) { + if (!from.name().empty()) { name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); } root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.root().size() > 0) { + if (!from.root().empty()) { root_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.root_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 4853593bae..83beaa12e7 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -262,7 +262,7 @@ class PROTOBUF_EXPORT Api : // @@protoc_insertion_point(class_scope:google.protobuf.Api) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Method > methods_; @@ -454,7 +454,7 @@ class PROTOBUF_EXPORT Method : // @@protoc_insertion_point(class_scope:google.protobuf.Method) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Option > options_; @@ -604,7 +604,7 @@ class PROTOBUF_EXPORT Mixin : // @@protoc_insertion_point(class_scope:google.protobuf.Mixin) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; diff --git a/src/google/protobuf/compiler/cpp/cpp_field.cc b/src/google/protobuf/compiler/cpp/cpp_field.cc index 411136f3b9..137e133a2b 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_field.cc @@ -77,7 +77,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, (*variables)["clear_hasbit"] = ""; if (HasFieldPresence(descriptor->file())) { (*variables)["set_hasbit_io"] = - "HasBitSetters::set_has_" + FieldName(descriptor) + "(&_has_bits_);"; + "_Internal::set_has_" + FieldName(descriptor) + "(&_has_bits_);"; } else { (*variables)["set_hasbit_io"] = ""; } diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 6a32c56474..4cec899b83 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -1381,7 +1381,7 @@ class ParseLoopGenerator { // For now only optimize small hasbits. if (hasbits_size != 1) hasbits_size = 0; if (hasbits_size) { - format_("HasBitSetters::HasBits has_bits{};\n"); + format_("_Internal::HasBits has_bits{};\n"); format_.Set("has_bits", "has_bits"); } else { format_.Set("has_bits", "_has_bits_"); @@ -1420,7 +1420,7 @@ class ParseLoopGenerator { field_name = ", kFieldName"; } if (HasFieldPresence(field->file())) { - format_("HasBitSetters::set_has_$1$(&$has_bits$);\n", FieldName(field)); + format_("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field)); } string default_string = field->default_value_string().empty() @@ -1536,7 +1536,7 @@ class ParseLoopGenerator { FieldName(field), field->containing_oneof()->name()); } else if (HasFieldPresence(field->file())) { format_( - "HasBitSetters::set_has_$1$(&$has_bits$);\n" + "_Internal::set_has_$1$(&$has_bits$);\n" "ptr = ctx->ParseMessage(&$1$_, ptr);\n", FieldName(field)); } else { @@ -1546,7 +1546,7 @@ class ParseLoopGenerator { } else if (IsImplicitWeakField(field, options_, scc_analyzer_)) { if (!field->is_repeated()) { format_( - "ptr = ctx->ParseMessage(HasBitSetters::mutable_$1$(this), " + "ptr = ctx->ParseMessage(_Internal::mutable_$1$(this), " "ptr);\n", FieldName(field)); } else { @@ -1633,7 +1633,7 @@ class ParseLoopGenerator { prefix, FieldName(field), zigzag); } else { if (HasFieldPresence(field->file())) { - format_("HasBitSetters::set_has_$1$(&$has_bits$);\n", + format_("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field)); } format_( @@ -1655,8 +1655,7 @@ class ParseLoopGenerator { prefix, FieldName(field), type); } else { if (HasFieldPresence(field->file())) { - format_("HasBitSetters::set_has_$1$(&$has_bits$);\n", - FieldName(field)); + format_("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field)); } format_( "$1$_ = $pi_ns$::UnalignedLoad<$2$>(ptr);\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 1a01922cef..43dc0f57d0 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -1392,7 +1392,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format(" private:\n"); format.Indent(); // TODO(seongkim): Remove hack to track field access and remove this class. - format("class HasBitSetters;\n"); + format("class _Internal;\n"); for (auto field : FieldRange(descriptor_)) { @@ -1990,7 +1990,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { } format( - "class $classname$::HasBitSetters {\n" + "class $classname$::_Internal {\n" " public:\n"); format.Indent(); if (HasFieldPresence(descriptor_->file()) && HasBitsSize() != 0) { diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index 659e3faeb8..3007cc2a3b 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -269,7 +269,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDeclarations( void MessageFieldGenerator::GenerateInternalAccessorDefinitions( io::Printer* printer) const { - // In theory, these accessors could be inline in HasBitSetters. However, in + // In theory, these accessors could be inline in _Internal. However, in // practice, the linker is then not able to throw them out making implicit // weak dependencies not work at all. Formatter format(printer, variables_); @@ -278,7 +278,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( // MergePartialFromCodedStream, and their purpose is to provide access to // the field without creating a strong dependency on the message type. format( - "const ::$proto_ns$::MessageLite& $classname$::HasBitSetters::$name$(\n" + "const ::$proto_ns$::MessageLite& $classname$::_Internal::$name$(\n" " const $classname$* msg) {\n" " if (msg->$name$_ != nullptr) {\n" " return *msg->$name$_;\n" @@ -293,7 +293,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( if (SupportsArenas(descriptor_)) { format( "::$proto_ns$::MessageLite*\n" - "$classname$::HasBitSetters::mutable_$name$($classname$* msg) {\n"); + "$classname$::_Internal::mutable_$name$($classname$* msg) {\n"); if (HasFieldPresence(descriptor_->file())) { format(" msg->$set_hasbit$\n"); } @@ -315,7 +315,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( } else { format( "::$proto_ns$::MessageLite*\n" - "$classname$::HasBitSetters::mutable_$name$($classname$* msg) {\n"); + "$classname$::_Internal::mutable_$name$($classname$* msg) {\n"); if (HasFieldPresence(descriptor_->file())) { format(" msg->$set_hasbit$\n"); } @@ -339,7 +339,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( // message fields under serialize. format( "const $type$&\n" - "$classname$::HasBitSetters::$name$(const $classname$* msg) {\n" + "$classname$::_Internal::$name$(const $classname$* msg) {\n" " return *msg->$field_member$;\n" "}\n"); } @@ -382,8 +382,8 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const { Formatter format(printer, variables_); if (implicit_weak_field_) { format( - "HasBitSetters::mutable_$name$(this)->CheckTypeAndMergeFrom(\n" - " HasBitSetters::$name$(&from));\n"); + "_Internal::mutable_$name$(this)->CheckTypeAndMergeFrom(\n" + " _Internal::$name$(&from));\n"); } else { format("mutable_$name$()->$type$::MergeFrom(from.$name$());\n"); } @@ -430,7 +430,7 @@ void MessageFieldGenerator::GenerateMergeFromCodedStream( if (implicit_weak_field_) { format( "DO_(::$proto_ns$::internal::WireFormatLite::ReadMessage(\n" - " input, HasBitSetters::mutable_$name$(this)));\n"); + " input, _Internal::mutable_$name$(this)));\n"); } else if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { format( "DO_(::$proto_ns$::internal::WireFormatLite::ReadMessage(\n" @@ -447,7 +447,7 @@ void MessageFieldGenerator::GenerateSerializeWithCachedSizes( Formatter format(printer, variables_); format( "::$proto_ns$::internal::WireFormatLite::Write$stream_writer$(\n" - " $number$, HasBitSetters::$name$(this), output);\n"); + " $number$, _Internal::$name$(this), output);\n"); } void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( @@ -456,7 +456,7 @@ void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( format( "target = ::$proto_ns$::internal::WireFormatLite::\n" " InternalWrite$declared_type$ToArray(\n" - " $number$, HasBitSetters::$name$(this), target);\n"); + " $number$, _Internal::$name$(this), target);\n"); } void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const { diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index bd25d7a84e..1f14b16dc1 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -519,7 +519,7 @@ void StringFieldGenerator::GenerateCopyConstructorCode( if (HasFieldPresence(descriptor_->file())) { format("if (from.has_$name$()) {\n"); } else { - format("if (from.$name$().size() > 0) {\n"); + format("if (!from.$name$().empty()) {\n"); } format.Indent(); diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index 235c10249b..1c0efda18d 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -157,6 +157,16 @@ bool IsLowerUnderscore(const string& name) { return true; } +bool IsNumberFollowUnderscore(const string& name) { + for (int i = 1; i < name.length(); i++) { + const char c = name[i]; + if (IsNumber(c) && name[i - 1] == '_') { + return true; + } + } + return false; +} + } // anonymous namespace // Makes code slightly more readable. The meaning of "DO(foo)" is @@ -1004,6 +1014,12 @@ bool Parser::ParseMessageFieldNoLabel( "Field name should be lowercase. Found: " + field->name() + ". See: https://developers.google.com/protocol-buffers/docs/style"); } + if (IsNumberFollowUnderscore(field->name())) { + AddWarning( + "Number should not come right after an underscore. Found: " + + field->name() + + ". See: https://developers.google.com/protocol-buffers/docs/style"); + } } DO(Consume("=", "Missing field number.")); diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc index 80e01a50cf..43784cb321 100644 --- a/src/google/protobuf/compiler/parser_unittest.cc +++ b/src/google/protobuf/compiler/parser_unittest.cc @@ -65,9 +65,15 @@ class MockErrorCollector : public io::ErrorCollector { MockErrorCollector() = default; ~MockErrorCollector() override = default; + std::string warning_; std::string text_; // implements ErrorCollector --------------------------------------- + void AddWarning(int line, int column, const std::string& message) override { + strings::SubstituteAndAppend(&warning_, "$0:$1: $2\n", line, column, + message); + } + void AddError(int line, int column, const std::string& message) override { strings::SubstituteAndAppend(&text_, "$0:$1: $2\n", line, column, message); } @@ -223,6 +229,43 @@ TEST_F(ParserTest, WarnIfSyntaxIdentifierOmmitted) { string::npos); } +TEST_F(ParserTest, WarnIfFieldNameIsNotUpperCamel) { + SetupParser( + "syntax = \"proto2\";" + "message abc {}"); + FileDescriptorProto file; + EXPECT_TRUE(parser_->Parse(input_.get(), &file)); + EXPECT_TRUE(error_collector_.warning_.find( + "Message name should be in UpperCamelCase. Found: abc.") != + string::npos); +} + +TEST_F(ParserTest, WarnIfFieldNameIsNotLowerUnderscore) { + SetupParser( + "syntax = \"proto2\";" + "message A {" + " optional string SongName = 1;" + "}"); + FileDescriptorProto file; + EXPECT_TRUE(parser_->Parse(input_.get(), &file)); + EXPECT_TRUE(error_collector_.warning_.find( + "Field name should be lowercase. Found: SongName") != + string::npos); +} + +TEST_F(ParserTest, WarnIfFieldNameContainsNumberImmediatelyFollowUnderscore) { + SetupParser( + "syntax = \"proto2\";" + "message A {" + " optional string song_name_1 = 1;" + "}"); + FileDescriptorProto file; + EXPECT_TRUE(parser_->Parse(input_.get(), &file)); + EXPECT_TRUE(error_collector_.warning_.find( + "Number should not come right after an underscore. Found: " + "song_name_1.") != string::npos); +} + // =================================================================== typedef ParserTest ParseMessageTest; diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index 7b0d9e65e7..e027234585 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -208,7 +208,7 @@ namespace compiler { void Version::InitAsDefaultInstance() { } -class Version::HasBitSetters { +class Version::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_major(HasBits* has_bits) { @@ -300,7 +300,7 @@ void Version::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -309,7 +309,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in // optional int32 major = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - HasBitSetters::set_has_major(&has_bits); + _Internal::set_has_major(&has_bits); major_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -317,7 +317,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in // optional int32 minor = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - HasBitSetters::set_has_minor(&has_bits); + _Internal::set_has_minor(&has_bits); minor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -325,7 +325,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in // optional int32 patch = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { - HasBitSetters::set_has_patch(&has_bits); + _Internal::set_has_patch(&has_bits); patch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -371,7 +371,7 @@ bool Version::MergePartialFromCodedStream( // optional int32 major = 1; case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (8 & 0xFF)) { - HasBitSetters::set_has_major(&_has_bits_); + _Internal::set_has_major(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &major_))); @@ -384,7 +384,7 @@ bool Version::MergePartialFromCodedStream( // optional int32 minor = 2; case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (16 & 0xFF)) { - HasBitSetters::set_has_minor(&_has_bits_); + _Internal::set_has_minor(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &minor_))); @@ -397,7 +397,7 @@ bool Version::MergePartialFromCodedStream( // optional int32 patch = 3; case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (24 & 0xFF)) { - HasBitSetters::set_has_patch(&_has_bits_); + _Internal::set_has_patch(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &patch_))); @@ -657,7 +657,7 @@ void CodeGeneratorRequest::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_._instance.get_mutable()->compiler_version_ = const_cast< PROTOBUF_NAMESPACE_ID::compiler::Version*>( PROTOBUF_NAMESPACE_ID::compiler::Version::internal_default_instance()); } -class CodeGeneratorRequest::HasBitSetters { +class CodeGeneratorRequest::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_parameter(HasBits* has_bits) { @@ -670,7 +670,7 @@ class CodeGeneratorRequest::HasBitSetters { }; const PROTOBUF_NAMESPACE_ID::compiler::Version& -CodeGeneratorRequest::HasBitSetters::compiler_version(const CodeGeneratorRequest* msg) { +CodeGeneratorRequest::_Internal::compiler_version(const CodeGeneratorRequest* msg) { return *msg->compiler_version_; } void CodeGeneratorRequest::clear_proto_file() { @@ -757,7 +757,7 @@ void CodeGeneratorRequest::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -936,7 +936,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( // optional .google.protobuf.compiler.Version compiler_version = 3; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, HasBitSetters::compiler_version(this), output); + 3, _Internal::compiler_version(this), output); } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; @@ -987,7 +987,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( if (cached_has_bits & 0x00000002u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 3, HasBitSetters::compiler_version(this), target); + 3, _Internal::compiler_version(this), target); } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; @@ -1139,7 +1139,7 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { void CodeGeneratorResponse_File::InitAsDefaultInstance() { } -class CodeGeneratorResponse_File::HasBitSetters { +class CodeGeneratorResponse_File::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_name(HasBits* has_bits) { @@ -1236,7 +1236,7 @@ void CodeGeneratorResponse_File::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); @@ -1576,7 +1576,7 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) void CodeGeneratorResponse::InitAsDefaultInstance() { } -class CodeGeneratorResponse::HasBitSetters { +class CodeGeneratorResponse::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_error(HasBits* has_bits) { @@ -1648,7 +1648,7 @@ void CodeGeneratorResponse::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 9ebd29e13a..7e46231ab5 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -240,7 +240,7 @@ class PROTOC_EXPORT Version : // @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; @@ -423,7 +423,7 @@ class PROTOC_EXPORT CodeGeneratorRequest : // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; @@ -593,7 +593,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; @@ -750,7 +750,7 @@ class PROTOC_EXPORT CodeGeneratorResponse : // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 892b9c93e0..be3a706219 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -1381,7 +1381,7 @@ constexpr int MethodOptions::IdempotencyLevel_ARRAYSIZE; void FileDescriptorSet::InitAsDefaultInstance() { } -class FileDescriptorSet::HasBitSetters { +class FileDescriptorSet::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); }; @@ -1690,7 +1690,7 @@ void FileDescriptorProto::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_._instance.get_mutable()->source_code_info_ = const_cast< PROTOBUF_NAMESPACE_ID::SourceCodeInfo*>( PROTOBUF_NAMESPACE_ID::SourceCodeInfo::internal_default_instance()); } -class FileDescriptorProto::HasBitSetters { +class FileDescriptorProto::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_name(HasBits* has_bits) { @@ -1713,11 +1713,11 @@ class FileDescriptorProto::HasBitSetters { }; const PROTOBUF_NAMESPACE_ID::FileOptions& -FileDescriptorProto::HasBitSetters::options(const FileDescriptorProto* msg) { +FileDescriptorProto::_Internal::options(const FileDescriptorProto* msg) { return *msg->options_; } const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& -FileDescriptorProto::HasBitSetters::source_code_info(const FileDescriptorProto* msg) { +FileDescriptorProto::_Internal::source_code_info(const FileDescriptorProto* msg) { return *msg->source_code_info_; } void FileDescriptorProto::unsafe_arena_set_allocated_options( @@ -1899,7 +1899,7 @@ void FileDescriptorProto::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -2318,13 +2318,13 @@ void FileDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.FileOptions options = 8; if (cached_has_bits & 0x00000008u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 8, HasBitSetters::options(this), output); + 8, _Internal::options(this), output); } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; if (cached_has_bits & 0x00000010u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 9, HasBitSetters::source_code_info(this), output); + 9, _Internal::source_code_info(this), output); } // repeated int32 public_dependency = 10; @@ -2431,14 +2431,14 @@ void FileDescriptorProto::SerializeWithCachedSizes( if (cached_has_bits & 0x00000008u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 8, HasBitSetters::options(this), target); + 8, _Internal::options(this), target); } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; if (cached_has_bits & 0x00000010u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 9, HasBitSetters::source_code_info(this), target); + 9, _Internal::source_code_info(this), target); } // repeated int32 public_dependency = 10; @@ -2719,7 +2719,7 @@ void DescriptorProto_ExtensionRange::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions*>( PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions::internal_default_instance()); } -class DescriptorProto_ExtensionRange::HasBitSetters { +class DescriptorProto_ExtensionRange::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_start(HasBits* has_bits) { @@ -2735,7 +2735,7 @@ class DescriptorProto_ExtensionRange::HasBitSetters { }; const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& -DescriptorProto_ExtensionRange::HasBitSetters::options(const DescriptorProto_ExtensionRange* msg) { +DescriptorProto_ExtensionRange::_Internal::options(const DescriptorProto_ExtensionRange* msg) { return *msg->options_; } void DescriptorProto_ExtensionRange::unsafe_arena_set_allocated_options( @@ -2840,7 +2840,7 @@ void DescriptorProto_ExtensionRange::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -2850,7 +2850,7 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PR // optional int32 start = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - HasBitSetters::set_has_start(&has_bits); + _Internal::set_has_start(&has_bits); start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -2858,7 +2858,7 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PR // optional int32 end = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - HasBitSetters::set_has_end(&has_bits); + _Internal::set_has_end(&has_bits); end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -2904,7 +2904,7 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( // optional int32 start = 1; case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (8 & 0xFF)) { - HasBitSetters::set_has_start(&_has_bits_); + _Internal::set_has_start(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &start_))); @@ -2917,7 +2917,7 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( // optional int32 end = 2; case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (16 & 0xFF)) { - HasBitSetters::set_has_end(&_has_bits_); + _Internal::set_has_end(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &end_))); @@ -2979,7 +2979,7 @@ void DescriptorProto_ExtensionRange::SerializeWithCachedSizes( // optional .google.protobuf.ExtensionRangeOptions options = 3; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, HasBitSetters::options(this), output); + 3, _Internal::options(this), output); } if (_internal_metadata_.have_unknown_fields()) { @@ -3010,7 +3010,7 @@ void DescriptorProto_ExtensionRange::SerializeWithCachedSizes( if (cached_has_bits & 0x00000001u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 3, HasBitSetters::options(this), target); + 3, _Internal::options(this), target); } if (_internal_metadata_.have_unknown_fields()) { @@ -3158,7 +3158,7 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange void DescriptorProto_ReservedRange::InitAsDefaultInstance() { } -class DescriptorProto_ReservedRange::HasBitSetters { +class DescriptorProto_ReservedRange::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_start(HasBits* has_bits) { @@ -3246,7 +3246,7 @@ void DescriptorProto_ReservedRange::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -3256,7 +3256,7 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PRO // optional int32 start = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - HasBitSetters::set_has_start(&has_bits); + _Internal::set_has_start(&has_bits); start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -3264,7 +3264,7 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PRO // optional int32 end = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - HasBitSetters::set_has_end(&has_bits); + _Internal::set_has_end(&has_bits); end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -3303,7 +3303,7 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( // optional int32 start = 1; case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (8 & 0xFF)) { - HasBitSetters::set_has_start(&_has_bits_); + _Internal::set_has_start(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &start_))); @@ -3316,7 +3316,7 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( // optional int32 end = 2; case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (16 & 0xFF)) { - HasBitSetters::set_has_end(&_has_bits_); + _Internal::set_has_end(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &end_))); @@ -3521,7 +3521,7 @@ void DescriptorProto::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::MessageOptions*>( PROTOBUF_NAMESPACE_ID::MessageOptions::internal_default_instance()); } -class DescriptorProto::HasBitSetters { +class DescriptorProto::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_name(HasBits* has_bits) { @@ -3534,7 +3534,7 @@ class DescriptorProto::HasBitSetters { }; const PROTOBUF_NAMESPACE_ID::MessageOptions& -DescriptorProto::HasBitSetters::options(const DescriptorProto* msg) { +DescriptorProto::_Internal::options(const DescriptorProto* msg) { return *msg->options_; } void DescriptorProto::unsafe_arena_set_allocated_options( @@ -3672,7 +3672,7 @@ void DescriptorProto::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -4025,7 +4025,7 @@ void DescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.MessageOptions options = 7; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 7, HasBitSetters::options(this), output); + 7, _Internal::options(this), output); } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; @@ -4125,7 +4125,7 @@ void DescriptorProto::SerializeWithCachedSizes( if (cached_has_bits & 0x00000002u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 7, HasBitSetters::options(this), target); + 7, _Internal::options(this), target); } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; @@ -4395,7 +4395,7 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) { void ExtensionRangeOptions::InitAsDefaultInstance() { } -class ExtensionRangeOptions::HasBitSetters { +class ExtensionRangeOptions::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); }; @@ -4732,7 +4732,7 @@ void FieldDescriptorProto::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::FieldOptions*>( PROTOBUF_NAMESPACE_ID::FieldOptions::internal_default_instance()); } -class FieldDescriptorProto::HasBitSetters { +class FieldDescriptorProto::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_name(HasBits* has_bits) { @@ -4769,7 +4769,7 @@ class FieldDescriptorProto::HasBitSetters { }; const PROTOBUF_NAMESPACE_ID::FieldOptions& -FieldDescriptorProto::HasBitSetters::options(const FieldDescriptorProto* msg) { +FieldDescriptorProto::_Internal::options(const FieldDescriptorProto* msg) { return *msg->options_; } void FieldDescriptorProto::unsafe_arena_set_allocated_options( @@ -4939,7 +4939,7 @@ void FieldDescriptorProto::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -4963,7 +4963,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM // optional int32 number = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { - HasBitSetters::set_has_number(&has_bits); + _Internal::set_has_number(&has_bits); number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -5016,7 +5016,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM // optional int32 oneof_index = 9; case 9: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 72)) { - HasBitSetters::set_has_oneof_index(&has_bits); + _Internal::set_has_oneof_index(&has_bits); oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -5092,7 +5092,7 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional int32 number = 3; case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (24 & 0xFF)) { - HasBitSetters::set_has_number(&_has_bits_); + _Internal::set_has_number(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &number_))); @@ -5184,7 +5184,7 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( // optional int32 oneof_index = 9; case 9: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (72 & 0xFF)) { - HasBitSetters::set_has_oneof_index(&_has_bits_); + _Internal::set_has_oneof_index(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &oneof_index_))); @@ -5297,7 +5297,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.FieldOptions options = 8; if (cached_has_bits & 0x00000020u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 8, HasBitSetters::options(this), output); + 8, _Internal::options(this), output); } // optional int32 oneof_index = 9; @@ -5394,7 +5394,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( if (cached_has_bits & 0x00000020u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 8, HasBitSetters::options(this), target); + 8, _Internal::options(this), target); } // optional int32 oneof_index = 9; @@ -5645,7 +5645,7 @@ void OneofDescriptorProto::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::OneofOptions*>( PROTOBUF_NAMESPACE_ID::OneofOptions::internal_default_instance()); } -class OneofDescriptorProto::HasBitSetters { +class OneofDescriptorProto::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_name(HasBits* has_bits) { @@ -5658,7 +5658,7 @@ class OneofDescriptorProto::HasBitSetters { }; const PROTOBUF_NAMESPACE_ID::OneofOptions& -OneofDescriptorProto::HasBitSetters::options(const OneofDescriptorProto* msg) { +OneofDescriptorProto::_Internal::options(const OneofDescriptorProto* msg) { return *msg->options_; } void OneofDescriptorProto::unsafe_arena_set_allocated_options( @@ -5764,7 +5764,7 @@ void OneofDescriptorProto::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -5883,7 +5883,7 @@ void OneofDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.OneofOptions options = 2; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, HasBitSetters::options(this), output); + 2, _Internal::options(this), output); } if (_internal_metadata_.have_unknown_fields()) { @@ -5915,7 +5915,7 @@ void OneofDescriptorProto::SerializeWithCachedSizes( if (cached_has_bits & 0x00000002u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 2, HasBitSetters::options(this), target); + 2, _Internal::options(this), target); } if (_internal_metadata_.have_unknown_fields()) { @@ -6052,7 +6052,7 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) { void EnumDescriptorProto_EnumReservedRange::InitAsDefaultInstance() { } -class EnumDescriptorProto_EnumReservedRange::HasBitSetters { +class EnumDescriptorProto_EnumReservedRange::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_start(HasBits* has_bits) { @@ -6140,7 +6140,7 @@ void EnumDescriptorProto_EnumReservedRange::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -6150,7 +6150,7 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* pt // optional int32 start = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - HasBitSetters::set_has_start(&has_bits); + _Internal::set_has_start(&has_bits); start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6158,7 +6158,7 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* pt // optional int32 end = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - HasBitSetters::set_has_end(&has_bits); + _Internal::set_has_end(&has_bits); end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6197,7 +6197,7 @@ bool EnumDescriptorProto_EnumReservedRange::MergePartialFromCodedStream( // optional int32 start = 1; case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (8 & 0xFF)) { - HasBitSetters::set_has_start(&_has_bits_); + _Internal::set_has_start(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &start_))); @@ -6210,7 +6210,7 @@ bool EnumDescriptorProto_EnumReservedRange::MergePartialFromCodedStream( // optional int32 end = 2; case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (16 & 0xFF)) { - HasBitSetters::set_has_end(&_has_bits_); + _Internal::set_has_end(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &end_))); @@ -6415,7 +6415,7 @@ void EnumDescriptorProto::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::EnumOptions*>( PROTOBUF_NAMESPACE_ID::EnumOptions::internal_default_instance()); } -class EnumDescriptorProto::HasBitSetters { +class EnumDescriptorProto::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_name(HasBits* has_bits) { @@ -6428,7 +6428,7 @@ class EnumDescriptorProto::HasBitSetters { }; const PROTOBUF_NAMESPACE_ID::EnumOptions& -EnumDescriptorProto::HasBitSetters::options(const EnumDescriptorProto* msg) { +EnumDescriptorProto::_Internal::options(const EnumDescriptorProto* msg) { return *msg->options_; } void EnumDescriptorProto::unsafe_arena_set_allocated_options( @@ -6546,7 +6546,7 @@ void EnumDescriptorProto::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -6748,7 +6748,7 @@ void EnumDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.EnumOptions options = 3; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, HasBitSetters::options(this), output); + 3, _Internal::options(this), output); } // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; @@ -6807,7 +6807,7 @@ void EnumDescriptorProto::SerializeWithCachedSizes( if (cached_has_bits & 0x00000002u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 3, HasBitSetters::options(this), target); + 3, _Internal::options(this), target); } // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; @@ -7001,7 +7001,7 @@ void EnumValueDescriptorProto::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::EnumValueOptions*>( PROTOBUF_NAMESPACE_ID::EnumValueOptions::internal_default_instance()); } -class EnumValueDescriptorProto::HasBitSetters { +class EnumValueDescriptorProto::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_name(HasBits* has_bits) { @@ -7017,7 +7017,7 @@ class EnumValueDescriptorProto::HasBitSetters { }; const PROTOBUF_NAMESPACE_ID::EnumValueOptions& -EnumValueDescriptorProto::HasBitSetters::options(const EnumValueDescriptorProto* msg) { +EnumValueDescriptorProto::_Internal::options(const EnumValueDescriptorProto* msg) { return *msg->options_; } void EnumValueDescriptorProto::unsafe_arena_set_allocated_options( @@ -7128,7 +7128,7 @@ void EnumValueDescriptorProto::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -7145,7 +7145,7 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF // optional int32 number = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - HasBitSetters::set_has_number(&has_bits); + _Internal::set_has_number(&has_bits); number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -7206,7 +7206,7 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( // optional int32 number = 2; case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (16 & 0xFF)) { - HasBitSetters::set_has_number(&_has_bits_); + _Internal::set_has_number(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &number_))); @@ -7273,7 +7273,7 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.EnumValueOptions options = 3; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, HasBitSetters::options(this), output); + 3, _Internal::options(this), output); } if (_internal_metadata_.have_unknown_fields()) { @@ -7310,7 +7310,7 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes( if (cached_has_bits & 0x00000002u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 3, HasBitSetters::options(this), target); + 3, _Internal::options(this), target); } if (_internal_metadata_.have_unknown_fields()) { @@ -7461,7 +7461,7 @@ void ServiceDescriptorProto::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::ServiceOptions*>( PROTOBUF_NAMESPACE_ID::ServiceOptions::internal_default_instance()); } -class ServiceDescriptorProto::HasBitSetters { +class ServiceDescriptorProto::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_name(HasBits* has_bits) { @@ -7474,7 +7474,7 @@ class ServiceDescriptorProto::HasBitSetters { }; const PROTOBUF_NAMESPACE_ID::ServiceOptions& -ServiceDescriptorProto::HasBitSetters::options(const ServiceDescriptorProto* msg) { +ServiceDescriptorProto::_Internal::options(const ServiceDescriptorProto* msg) { return *msg->options_; } void ServiceDescriptorProto::unsafe_arena_set_allocated_options( @@ -7584,7 +7584,7 @@ void ServiceDescriptorProto::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -7735,7 +7735,7 @@ void ServiceDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.ServiceOptions options = 3; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, HasBitSetters::options(this), output); + 3, _Internal::options(this), output); } if (_internal_metadata_.have_unknown_fields()) { @@ -7775,7 +7775,7 @@ void ServiceDescriptorProto::SerializeWithCachedSizes( if (cached_has_bits & 0x00000002u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 3, HasBitSetters::options(this), target); + 3, _Internal::options(this), target); } if (_internal_metadata_.have_unknown_fields()) { @@ -7928,7 +7928,7 @@ void MethodDescriptorProto::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< PROTOBUF_NAMESPACE_ID::MethodOptions*>( PROTOBUF_NAMESPACE_ID::MethodOptions::internal_default_instance()); } -class MethodDescriptorProto::HasBitSetters { +class MethodDescriptorProto::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_name(HasBits* has_bits) { @@ -7953,7 +7953,7 @@ class MethodDescriptorProto::HasBitSetters { }; const PROTOBUF_NAMESPACE_ID::MethodOptions& -MethodDescriptorProto::HasBitSetters::options(const MethodDescriptorProto* msg) { +MethodDescriptorProto::_Internal::options(const MethodDescriptorProto* msg) { return *msg->options_; } void MethodDescriptorProto::unsafe_arena_set_allocated_options( @@ -8091,7 +8091,7 @@ void MethodDescriptorProto::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -8129,7 +8129,7 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA // optional bool client_streaming = 5 [default = false]; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { - HasBitSetters::set_has_client_streaming(&has_bits); + _Internal::set_has_client_streaming(&has_bits); client_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8137,7 +8137,7 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA // optional bool server_streaming = 6 [default = false]; case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) { - HasBitSetters::set_has_server_streaming(&has_bits); + _Internal::set_has_server_streaming(&has_bits); server_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8232,7 +8232,7 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional bool client_streaming = 5 [default = false]; case 5: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (40 & 0xFF)) { - HasBitSetters::set_has_client_streaming(&_has_bits_); + _Internal::set_has_client_streaming(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &client_streaming_))); @@ -8245,7 +8245,7 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( // optional bool server_streaming = 6 [default = false]; case 6: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (48 & 0xFF)) { - HasBitSetters::set_has_server_streaming(&_has_bits_); + _Internal::set_has_server_streaming(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &server_streaming_))); @@ -8316,7 +8316,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( // optional .google.protobuf.MethodOptions options = 4; if (cached_has_bits & 0x00000008u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, HasBitSetters::options(this), output); + 4, _Internal::options(this), output); } // optional bool client_streaming = 5 [default = false]; @@ -8380,7 +8380,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( if (cached_has_bits & 0x00000008u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 4, HasBitSetters::options(this), target); + 4, _Internal::options(this), target); } // optional bool client_streaming = 5 [default = false]; @@ -8570,7 +8570,7 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) { void FileOptions::InitAsDefaultInstance() { } -class FileOptions::HasBitSetters { +class FileOptions::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_java_package(HasBits* has_bits) { @@ -8849,7 +8849,7 @@ void FileOptions::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -8885,7 +8885,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool java_multiple_files = 10 [default = false]; case 10: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) { - HasBitSetters::set_has_java_multiple_files(&has_bits); + _Internal::set_has_java_multiple_files(&has_bits); java_multiple_files_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8900,7 +8900,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool cc_generic_services = 16 [default = false]; case 16: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 128)) { - HasBitSetters::set_has_cc_generic_services(&has_bits); + _Internal::set_has_cc_generic_services(&has_bits); cc_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8908,7 +8908,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool java_generic_services = 17 [default = false]; case 17: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 136)) { - HasBitSetters::set_has_java_generic_services(&has_bits); + _Internal::set_has_java_generic_services(&has_bits); java_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8916,7 +8916,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool py_generic_services = 18 [default = false]; case 18: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 144)) { - HasBitSetters::set_has_py_generic_services(&has_bits); + _Internal::set_has_py_generic_services(&has_bits); py_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8924,7 +8924,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; case 20: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 160)) { - HasBitSetters::set_has_java_generate_equals_and_hash(&has_bits); + _Internal::set_has_java_generate_equals_and_hash(&has_bits); java_generate_equals_and_hash_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8932,7 +8932,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool deprecated = 23 [default = false]; case 23: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 184)) { - HasBitSetters::set_has_deprecated(&has_bits); + _Internal::set_has_deprecated(&has_bits); deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8940,7 +8940,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool java_string_check_utf8 = 27 [default = false]; case 27: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 216)) { - HasBitSetters::set_has_java_string_check_utf8(&has_bits); + _Internal::set_has_java_string_check_utf8(&has_bits); java_string_check_utf8_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8948,7 +8948,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool cc_enable_arenas = 31 [default = false]; case 31: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 248)) { - HasBitSetters::set_has_cc_enable_arenas(&has_bits); + _Internal::set_has_cc_enable_arenas(&has_bits); cc_enable_arenas_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8991,7 +8991,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool php_generic_services = 42 [default = false]; case 42: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) { - HasBitSetters::set_has_php_generic_services(&has_bits); + _Internal::set_has_php_generic_services(&has_bits); php_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -9111,7 +9111,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_multiple_files = 10 [default = false]; case 10: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (80 & 0xFF)) { - HasBitSetters::set_has_java_multiple_files(&_has_bits_); + _Internal::set_has_java_multiple_files(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &java_multiple_files_))); @@ -9139,7 +9139,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool cc_generic_services = 16 [default = false]; case 16: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (128 & 0xFF)) { - HasBitSetters::set_has_cc_generic_services(&_has_bits_); + _Internal::set_has_cc_generic_services(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &cc_generic_services_))); @@ -9152,7 +9152,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_generic_services = 17 [default = false]; case 17: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (136 & 0xFF)) { - HasBitSetters::set_has_java_generic_services(&_has_bits_); + _Internal::set_has_java_generic_services(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &java_generic_services_))); @@ -9165,7 +9165,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool py_generic_services = 18 [default = false]; case 18: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (144 & 0xFF)) { - HasBitSetters::set_has_py_generic_services(&_has_bits_); + _Internal::set_has_py_generic_services(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &py_generic_services_))); @@ -9178,7 +9178,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; case 20: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (160 & 0xFF)) { - HasBitSetters::set_has_java_generate_equals_and_hash(&_has_bits_); + _Internal::set_has_java_generate_equals_and_hash(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &java_generate_equals_and_hash_))); @@ -9191,7 +9191,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool deprecated = 23 [default = false]; case 23: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (184 & 0xFF)) { - HasBitSetters::set_has_deprecated(&_has_bits_); + _Internal::set_has_deprecated(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); @@ -9204,7 +9204,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool java_string_check_utf8 = 27 [default = false]; case 27: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (216 & 0xFF)) { - HasBitSetters::set_has_java_string_check_utf8(&_has_bits_); + _Internal::set_has_java_string_check_utf8(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &java_string_check_utf8_))); @@ -9217,7 +9217,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool cc_enable_arenas = 31 [default = false]; case 31: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (248 & 0xFF)) { - HasBitSetters::set_has_cc_enable_arenas(&_has_bits_); + _Internal::set_has_cc_enable_arenas(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &cc_enable_arenas_))); @@ -9305,7 +9305,7 @@ bool FileOptions::MergePartialFromCodedStream( // optional bool php_generic_services = 42 [default = false]; case 42: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (336 & 0xFF)) { - HasBitSetters::set_has_php_generic_services(&_has_bits_); + _Internal::set_has_php_generic_services(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &php_generic_services_))); @@ -10091,7 +10091,7 @@ void FileOptions::InternalSwap(FileOptions* other) { void MessageOptions::InitAsDefaultInstance() { } -class MessageOptions::HasBitSetters { +class MessageOptions::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_message_set_wire_format(HasBits* has_bits) { @@ -10192,7 +10192,7 @@ void MessageOptions::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -10202,7 +10202,7 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE // optional bool message_set_wire_format = 1 [default = false]; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - HasBitSetters::set_has_message_set_wire_format(&has_bits); + _Internal::set_has_message_set_wire_format(&has_bits); message_set_wire_format_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10210,7 +10210,7 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE // optional bool no_standard_descriptor_accessor = 2 [default = false]; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - HasBitSetters::set_has_no_standard_descriptor_accessor(&has_bits); + _Internal::set_has_no_standard_descriptor_accessor(&has_bits); no_standard_descriptor_accessor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10218,7 +10218,7 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE // optional bool deprecated = 3 [default = false]; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { - HasBitSetters::set_has_deprecated(&has_bits); + _Internal::set_has_deprecated(&has_bits); deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10226,7 +10226,7 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE // optional bool map_entry = 7; case 7: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) { - HasBitSetters::set_has_map_entry(&has_bits); + _Internal::set_has_map_entry(&has_bits); map_entry_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10283,7 +10283,7 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool message_set_wire_format = 1 [default = false]; case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (8 & 0xFF)) { - HasBitSetters::set_has_message_set_wire_format(&_has_bits_); + _Internal::set_has_message_set_wire_format(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &message_set_wire_format_))); @@ -10296,7 +10296,7 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool no_standard_descriptor_accessor = 2 [default = false]; case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (16 & 0xFF)) { - HasBitSetters::set_has_no_standard_descriptor_accessor(&_has_bits_); + _Internal::set_has_no_standard_descriptor_accessor(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &no_standard_descriptor_accessor_))); @@ -10309,7 +10309,7 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool deprecated = 3 [default = false]; case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (24 & 0xFF)) { - HasBitSetters::set_has_deprecated(&_has_bits_); + _Internal::set_has_deprecated(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); @@ -10322,7 +10322,7 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool map_entry = 7; case 7: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (56 & 0xFF)) { - HasBitSetters::set_has_map_entry(&_has_bits_); + _Internal::set_has_map_entry(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &map_entry_))); @@ -10622,7 +10622,7 @@ void MessageOptions::InternalSwap(MessageOptions* other) { void FieldOptions::InitAsDefaultInstance() { } -class FieldOptions::HasBitSetters { +class FieldOptions::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_ctype(HasBits* has_bits) { @@ -10734,7 +10734,7 @@ void FieldOptions::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -10756,7 +10756,7 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I // optional bool packed = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - HasBitSetters::set_has_packed(&has_bits); + _Internal::set_has_packed(&has_bits); packed_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10764,7 +10764,7 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I // optional bool deprecated = 3 [default = false]; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { - HasBitSetters::set_has_deprecated(&has_bits); + _Internal::set_has_deprecated(&has_bits); deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10772,7 +10772,7 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I // optional bool lazy = 5 [default = false]; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { - HasBitSetters::set_has_lazy(&has_bits); + _Internal::set_has_lazy(&has_bits); lazy_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10792,7 +10792,7 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I // optional bool weak = 10 [default = false]; case 10: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) { - HasBitSetters::set_has_weak(&has_bits); + _Internal::set_has_weak(&has_bits); weak_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10868,7 +10868,7 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool packed = 2; case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (16 & 0xFF)) { - HasBitSetters::set_has_packed(&_has_bits_); + _Internal::set_has_packed(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &packed_))); @@ -10881,7 +10881,7 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool deprecated = 3 [default = false]; case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (24 & 0xFF)) { - HasBitSetters::set_has_deprecated(&_has_bits_); + _Internal::set_has_deprecated(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); @@ -10894,7 +10894,7 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool lazy = 5 [default = false]; case 5: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (40 & 0xFF)) { - HasBitSetters::set_has_lazy(&_has_bits_); + _Internal::set_has_lazy(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &lazy_))); @@ -10926,7 +10926,7 @@ bool FieldOptions::MergePartialFromCodedStream( // optional bool weak = 10 [default = false]; case 10: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (80 & 0xFF)) { - HasBitSetters::set_has_weak(&_has_bits_); + _Internal::set_has_weak(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &weak_))); @@ -11270,7 +11270,7 @@ void FieldOptions::InternalSwap(FieldOptions* other) { void OneofOptions::InitAsDefaultInstance() { } -class OneofOptions::HasBitSetters { +class OneofOptions::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); }; @@ -11605,7 +11605,7 @@ void OneofOptions::InternalSwap(OneofOptions* other) { void EnumOptions::InitAsDefaultInstance() { } -class EnumOptions::HasBitSetters { +class EnumOptions::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_allow_alias(HasBits* has_bits) { @@ -11698,7 +11698,7 @@ void EnumOptions::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -11708,7 +11708,7 @@ const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool allow_alias = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - HasBitSetters::set_has_allow_alias(&has_bits); + _Internal::set_has_allow_alias(&has_bits); allow_alias_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -11716,7 +11716,7 @@ const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional bool deprecated = 3 [default = false]; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { - HasBitSetters::set_has_deprecated(&has_bits); + _Internal::set_has_deprecated(&has_bits); deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -11773,7 +11773,7 @@ bool EnumOptions::MergePartialFromCodedStream( // optional bool allow_alias = 2; case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (16 & 0xFF)) { - HasBitSetters::set_has_allow_alias(&_has_bits_); + _Internal::set_has_allow_alias(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &allow_alias_))); @@ -11786,7 +11786,7 @@ bool EnumOptions::MergePartialFromCodedStream( // optional bool deprecated = 3 [default = false]; case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (24 & 0xFF)) { - HasBitSetters::set_has_deprecated(&_has_bits_); + _Internal::set_has_deprecated(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); @@ -12048,7 +12048,7 @@ void EnumOptions::InternalSwap(EnumOptions* other) { void EnumValueOptions::InitAsDefaultInstance() { } -class EnumValueOptions::HasBitSetters { +class EnumValueOptions::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_deprecated(HasBits* has_bits) { @@ -12131,7 +12131,7 @@ void EnumValueOptions::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* EnumValueOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -12141,7 +12141,7 @@ const char* EnumValueOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPA // optional bool deprecated = 1 [default = false]; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - HasBitSetters::set_has_deprecated(&has_bits); + _Internal::set_has_deprecated(&has_bits); deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -12198,7 +12198,7 @@ bool EnumValueOptions::MergePartialFromCodedStream( // optional bool deprecated = 1 [default = false]; case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (8 & 0xFF)) { - HasBitSetters::set_has_deprecated(&_has_bits_); + _Internal::set_has_deprecated(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); @@ -12435,7 +12435,7 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) { void ServiceOptions::InitAsDefaultInstance() { } -class ServiceOptions::HasBitSetters { +class ServiceOptions::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_deprecated(HasBits* has_bits) { @@ -12518,7 +12518,7 @@ void ServiceOptions::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* ServiceOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -12528,7 +12528,7 @@ const char* ServiceOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE // optional bool deprecated = 33 [default = false]; case 33: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - HasBitSetters::set_has_deprecated(&has_bits); + _Internal::set_has_deprecated(&has_bits); deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -12585,7 +12585,7 @@ bool ServiceOptions::MergePartialFromCodedStream( // optional bool deprecated = 33 [default = false]; case 33: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (264 & 0xFF)) { - HasBitSetters::set_has_deprecated(&_has_bits_); + _Internal::set_has_deprecated(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); @@ -12822,7 +12822,7 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) { void MethodOptions::InitAsDefaultInstance() { } -class MethodOptions::HasBitSetters { +class MethodOptions::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_deprecated(HasBits* has_bits) { @@ -12918,7 +12918,7 @@ void MethodOptions::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* MethodOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -12928,7 +12928,7 @@ const char* MethodOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ // optional bool deprecated = 33 [default = false]; case 33: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - HasBitSetters::set_has_deprecated(&has_bits); + _Internal::set_has_deprecated(&has_bits); deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -12997,7 +12997,7 @@ bool MethodOptions::MergePartialFromCodedStream( // optional bool deprecated = 33 [default = false]; case 33: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (264 & 0xFF)) { - HasBitSetters::set_has_deprecated(&_has_bits_); + _Internal::set_has_deprecated(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); @@ -13281,7 +13281,7 @@ void MethodOptions::InternalSwap(MethodOptions* other) { void UninterpretedOption_NamePart::InitAsDefaultInstance() { } -class UninterpretedOption_NamePart::HasBitSetters { +class UninterpretedOption_NamePart::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_name_part(HasBits* has_bits) { @@ -13372,7 +13372,7 @@ void UninterpretedOption_NamePart::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -13389,7 +13389,7 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::PROT // required bool is_extension = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - HasBitSetters::set_has_is_extension(&has_bits); + _Internal::set_has_is_extension(&has_bits); is_extension_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -13443,7 +13443,7 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( // required bool is_extension = 2; case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (16 & 0xFF)) { - HasBitSetters::set_has_is_extension(&_has_bits_); + _Internal::set_has_is_extension(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< bool, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_BOOL>( input, &is_extension_))); @@ -13672,7 +13672,7 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot void UninterpretedOption::InitAsDefaultInstance() { } -class UninterpretedOption::HasBitSetters { +class UninterpretedOption::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_identifier_value(HasBits* has_bits) { @@ -13813,7 +13813,7 @@ void UninterpretedOption::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -13842,7 +13842,7 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME // optional uint64 positive_int_value = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { - HasBitSetters::set_has_positive_int_value(&has_bits); + _Internal::set_has_positive_int_value(&has_bits); positive_int_value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -13850,7 +13850,7 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME // optional int64 negative_int_value = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { - HasBitSetters::set_has_negative_int_value(&has_bits); + _Internal::set_has_negative_int_value(&has_bits); negative_int_value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -13858,7 +13858,7 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME // optional double double_value = 6; case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 49)) { - HasBitSetters::set_has_double_value(&has_bits); + _Internal::set_has_double_value(&has_bits); double_value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); ptr += sizeof(double); } else goto handle_unusual; @@ -13937,7 +13937,7 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional uint64 positive_int_value = 4; case 4: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (32 & 0xFF)) { - HasBitSetters::set_has_positive_int_value(&_has_bits_); + _Internal::set_has_positive_int_value(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::uint64, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_UINT64>( input, &positive_int_value_))); @@ -13950,7 +13950,7 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional int64 negative_int_value = 5; case 5: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (40 & 0xFF)) { - HasBitSetters::set_has_negative_int_value(&_has_bits_); + _Internal::set_has_negative_int_value(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int64, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT64>( input, &negative_int_value_))); @@ -13963,7 +13963,7 @@ bool UninterpretedOption::MergePartialFromCodedStream( // optional double double_value = 6; case 6: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (49 & 0xFF)) { - HasBitSetters::set_has_double_value(&_has_bits_); + _Internal::set_has_double_value(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< double, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_DOUBLE>( input, &double_value_))); @@ -14333,7 +14333,7 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) { void SourceCodeInfo_Location::InitAsDefaultInstance() { } -class SourceCodeInfo_Location::HasBitSetters { +class SourceCodeInfo_Location::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_leading_comments(HasBits* has_bits) { @@ -14445,7 +14445,7 @@ void SourceCodeInfo_Location::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -14935,7 +14935,7 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { void SourceCodeInfo::InitAsDefaultInstance() { } -class SourceCodeInfo::HasBitSetters { +class SourceCodeInfo::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); }; @@ -15239,7 +15239,7 @@ void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { void GeneratedCodeInfo_Annotation::InitAsDefaultInstance() { } -class GeneratedCodeInfo_Annotation::HasBitSetters { +class GeneratedCodeInfo_Annotation::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); static void set_has_source_file(HasBits* has_bits) { @@ -15346,7 +15346,7 @@ void GeneratedCodeInfo_Annotation::Clear() { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - HasBitSetters::HasBits has_bits{}; + _Internal::HasBits has_bits{}; ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; @@ -15373,7 +15373,7 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT // optional int32 begin = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { - HasBitSetters::set_has_begin(&has_bits); + _Internal::set_has_begin(&has_bits); begin_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -15381,7 +15381,7 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT // optional int32 end = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { - HasBitSetters::set_has_end(&has_bits); + _Internal::set_has_end(&has_bits); end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -15451,7 +15451,7 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( // optional int32 begin = 3; case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (24 & 0xFF)) { - HasBitSetters::set_has_begin(&_has_bits_); + _Internal::set_has_begin(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &begin_))); @@ -15464,7 +15464,7 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( // optional int32 end = 4; case 4: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (32 & 0xFF)) { - HasBitSetters::set_has_end(&_has_bits_); + _Internal::set_has_end(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32>( input, &end_))); @@ -15741,7 +15741,7 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot void GeneratedCodeInfo::InitAsDefaultInstance() { } -class GeneratedCodeInfo::HasBitSetters { +class GeneratedCodeInfo::_Internal { public: using HasBits = decltype(std::declval()._has_bits_); }; diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 0920d4196b..2288666220 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -472,7 +472,7 @@ class PROTOBUF_EXPORT FileDescriptorSet : // @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorSet) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -795,7 +795,7 @@ class PROTOBUF_EXPORT FileDescriptorProto : // @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorProto) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -975,7 +975,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ExtensionRange) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -1134,7 +1134,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ReservedRange) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -1417,7 +1417,7 @@ class PROTOBUF_EXPORT DescriptorProto : // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -1582,7 +1582,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions : GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(ExtensionRangeOptions) // @@protoc_insertion_point(class_scope:google.protobuf.ExtensionRangeOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -1971,7 +1971,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto : // @@protoc_insertion_point(class_scope:google.protobuf.FieldDescriptorProto) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -2157,7 +2157,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto : // @@protoc_insertion_point(class_scope:google.protobuf.OneofDescriptorProto) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -2315,7 +2315,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : // @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto.EnumReservedRange) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -2537,7 +2537,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto : // @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -2725,7 +2725,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueDescriptorProto) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -2916,7 +2916,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : // @@protoc_insertion_point(class_scope:google.protobuf.ServiceDescriptorProto) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -3153,7 +3153,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto : // @@protoc_insertion_point(class_scope:google.protobuf.MethodDescriptorProto) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -3636,7 +3636,7 @@ class PROTOBUF_EXPORT FileOptions : GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FileOptions) // @@protoc_insertion_point(class_scope:google.protobuf.FileOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -3842,7 +3842,7 @@ class PROTOBUF_EXPORT MessageOptions : GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MessageOptions) // @@protoc_insertion_point(class_scope:google.protobuf.MessageOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -4110,7 +4110,7 @@ class PROTOBUF_EXPORT FieldOptions : GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FieldOptions) // @@protoc_insertion_point(class_scope:google.protobuf.FieldOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -4274,7 +4274,7 @@ class PROTOBUF_EXPORT OneofOptions : GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(OneofOptions) // @@protoc_insertion_point(class_scope:google.protobuf.OneofOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -4446,7 +4446,7 @@ class PROTOBUF_EXPORT EnumOptions : GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumOptions) // @@protoc_insertion_point(class_scope:google.protobuf.EnumOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -4613,7 +4613,7 @@ class PROTOBUF_EXPORT EnumValueOptions : GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumValueOptions) // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -4779,7 +4779,7 @@ class PROTOBUF_EXPORT ServiceOptions : GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(ServiceOptions) // @@protoc_insertion_point(class_scope:google.protobuf.ServiceOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -4984,7 +4984,7 @@ class PROTOBUF_EXPORT MethodOptions : GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MethodOptions) // @@protoc_insertion_point(class_scope:google.protobuf.MethodOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -5160,7 +5160,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption.NamePart) private: - class HasBitSetters; + class _Internal; // helper for ByteSizeLong() size_t RequiredFieldsByteSizeFallback() const; @@ -5408,7 +5408,7 @@ class PROTOBUF_EXPORT UninterpretedOption : // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -5643,7 +5643,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : // @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo.Location) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -5806,7 +5806,7 @@ class PROTOBUF_EXPORT SourceCodeInfo : // @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -5997,7 +5997,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : // @@protoc_insertion_point(class_scope:google.protobuf.GeneratedCodeInfo.Annotation) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -6158,7 +6158,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo : // @@protoc_insertion_point(class_scope:google.protobuf.GeneratedCodeInfo) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index a7d070ad11..a2102d7aa9 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -428,6 +428,7 @@ message FileOptions { // determining the ruby package. optional string ruby_package = 45; + // The parser stores options it doesn't recognize here. // See the documentation for the "Options" section above. repeated UninterpretedOption uninterpreted_option = 999; diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 4190f9710d..864a4407e8 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -86,7 +86,7 @@ PROTOBUF_NAMESPACE_OPEN void Duration::InitAsDefaultInstance() { } -class Duration::HasBitSetters { +class Duration::_Internal { public: }; diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 91ac1e18d1..774b1ebd6c 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -201,7 +201,7 @@ class PROTOBUF_EXPORT Duration : // @@protoc_insertion_point(class_scope:google.protobuf.Duration) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 481cb57abb..835fd5fc12 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -83,7 +83,7 @@ PROTOBUF_NAMESPACE_OPEN void Empty::InitAsDefaultInstance() { } -class Empty::HasBitSetters { +class Empty::_Internal { public: }; diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index d65060da80..5ac03a69a5 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -189,7 +189,7 @@ class PROTOBUF_EXPORT Empty : // @@protoc_insertion_point(class_scope:google.protobuf.Empty) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index 034b44f49c..4f75e4a6a7 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -85,7 +85,7 @@ PROTOBUF_NAMESPACE_OPEN void FieldMask::InitAsDefaultInstance() { } -class FieldMask::HasBitSetters { +class FieldMask::_Internal { public: }; diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 57f400c4eb..5bdcd7eb95 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -207,7 +207,7 @@ class PROTOBUF_EXPORT FieldMask : // @@protoc_insertion_point(class_scope:google.protobuf.FieldMask) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc index 4f069cd4c0..99a7f67411 100644 --- a/src/google/protobuf/map_test.cc +++ b/src/google/protobuf/map_test.cc @@ -3083,11 +3083,13 @@ static std::string DeterministicSerialization(const T& t) { const int size = t.ByteSize(); std::string result(size, '\0'); io::ArrayOutputStream array_stream(::google::protobuf::string_as_array(&result), size); - io::CodedOutputStream output_stream(&array_stream); - output_stream.SetSerializationDeterministic(true); - t.SerializeWithCachedSizes(&output_stream); - EXPECT_FALSE(output_stream.HadError()); - EXPECT_EQ(size, output_stream.ByteCount()); + { + io::CodedOutputStream output_stream(&array_stream); + output_stream.SetSerializationDeterministic(true); + t.SerializeWithCachedSizes(&output_stream); + EXPECT_FALSE(output_stream.HadError()); + EXPECT_EQ(size, output_stream.ByteCount()); + } EXPECT_EQ(result, DeterministicSerializationWithSerializeToCodedStream(t)); EXPECT_EQ(result, DeterministicSerializationWithSerializePartialToCodedStream(t)); diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 98add69e05..e7e66aa1e7 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -86,7 +86,7 @@ PROTOBUF_NAMESPACE_OPEN void SourceContext::InitAsDefaultInstance() { } -class SourceContext::HasBitSetters { +class SourceContext::_Internal { public: }; @@ -104,7 +104,7 @@ SourceContext::SourceContext(const SourceContext& from) _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.file_name().size() > 0) { + if (!from.file_name().empty()) { file_name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.file_name_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 943c936bf9..01e356bb0e 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -189,7 +189,7 @@ class PROTOBUF_EXPORT SourceContext : // @@protoc_insertion_point(class_scope:google.protobuf.SourceContext) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr file_name_; diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index c4ff59b399..a3de868d53 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -195,7 +195,7 @@ void Struct_FieldsEntry_DoNotUse::MergeFrom( void Struct::InitAsDefaultInstance() { } -class Struct::HasBitSetters { +class Struct::_Internal { public: }; @@ -578,18 +578,18 @@ void Value::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_Value_default_instance_.list_value_ = const_cast< PROTOBUF_NAMESPACE_ID::ListValue*>( PROTOBUF_NAMESPACE_ID::ListValue::internal_default_instance()); } -class Value::HasBitSetters { +class Value::_Internal { public: static const PROTOBUF_NAMESPACE_ID::Struct& struct_value(const Value* msg); static const PROTOBUF_NAMESPACE_ID::ListValue& list_value(const Value* msg); }; const PROTOBUF_NAMESPACE_ID::Struct& -Value::HasBitSetters::struct_value(const Value* msg) { +Value::_Internal::struct_value(const Value* msg) { return *msg->kind_.struct_value_; } const PROTOBUF_NAMESPACE_ID::ListValue& -Value::HasBitSetters::list_value(const Value* msg) { +Value::_Internal::list_value(const Value* msg) { return *msg->kind_.list_value_; } void Value::set_allocated_struct_value(PROTOBUF_NAMESPACE_ID::Struct* struct_value) { @@ -979,13 +979,13 @@ void Value::SerializeWithCachedSizes( // .google.protobuf.Struct struct_value = 5; if (has_struct_value()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, HasBitSetters::struct_value(this), output); + 5, _Internal::struct_value(this), output); } // .google.protobuf.ListValue list_value = 6; if (has_list_value()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, HasBitSetters::list_value(this), output); + 6, _Internal::list_value(this), output); } if (_internal_metadata_.have_unknown_fields()) { @@ -1032,14 +1032,14 @@ void Value::SerializeWithCachedSizes( if (has_struct_value()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 5, HasBitSetters::struct_value(this), target); + 5, _Internal::struct_value(this), target); } // .google.protobuf.ListValue list_value = 6; if (has_list_value()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 6, HasBitSetters::list_value(this), target); + 6, _Internal::list_value(this), target); } if (_internal_metadata_.have_unknown_fields()) { @@ -1216,7 +1216,7 @@ void Value::InternalSwap(Value* other) { void ListValue::InitAsDefaultInstance() { } -class ListValue::HasBitSetters { +class ListValue::_Internal { public: }; diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 5dfd8fae16..519b3e7e07 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -271,7 +271,7 @@ class PROTOBUF_EXPORT Struct : // @@protoc_insertion_point(class_scope:google.protobuf.Struct) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -498,7 +498,7 @@ class PROTOBUF_EXPORT Value : KindCase kind_case() const; // @@protoc_insertion_point(class_scope:google.protobuf.Value) private: - class HasBitSetters; + class _Internal; void set_has_null_value(); void set_has_number_value(); void set_has_string_value(); @@ -664,7 +664,7 @@ class PROTOBUF_EXPORT ListValue : // @@protoc_insertion_point(class_scope:google.protobuf.ListValue) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 562f4528e8..e04ae3df24 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -208,6 +208,11 @@ const FieldDescriptor* DefaultFinderFindExtension(Message* message, name); } +const FieldDescriptor* DefaultFinderFindExtensionByNumber( + const Descriptor* descriptor, int number) { + return descriptor->file()->pool()->FindExtensionByNumber(descriptor, number); +} + const Descriptor* DefaultFinderFindAnyType(const Message& message, const std::string& prefix, const std::string& name) { @@ -459,8 +464,10 @@ class TextFormat::Parser::ParserImpl { if (allow_field_number_ && safe_strto32(field_name, &field_number)) { if (descriptor->IsExtensionNumber(field_number)) { - field = descriptor->file()->pool()->FindExtensionByNumber( - descriptor, field_number); + field = finder_ + ? finder_->FindExtensionByNumber(descriptor, field_number) + : DefaultFinderFindExtensionByNumber(descriptor, + field_number); } else if (descriptor->IsReservedNumber(field_number)) { reserved_field = true; } else { @@ -1354,6 +1361,11 @@ const FieldDescriptor* TextFormat::Finder::FindExtension( return DefaultFinderFindExtension(message, name); } +const FieldDescriptor* TextFormat::Finder::FindExtensionByNumber( + const Descriptor* descriptor, int number) const { + return DefaultFinderFindExtensionByNumber(descriptor, number); +} + const Descriptor* TextFormat::Finder::FindAnyType( const Message& message, const std::string& prefix, const std::string& name) const { diff --git a/src/google/protobuf/text_format.h b/src/google/protobuf/text_format.h index f999f4727e..4ebab0e4de 100644 --- a/src/google/protobuf/text_format.h +++ b/src/google/protobuf/text_format.h @@ -208,6 +208,11 @@ class PROTOBUF_EXPORT TextFormat { virtual const FieldDescriptor* FindExtension(Message* message, const std::string& name) const; + // Similar to FindExtension, but uses a Descriptor and the extension number + // instead of using a Message and the name when doing the look up. + virtual const FieldDescriptor* FindExtensionByNumber( + const Descriptor* descriptor, int number) const; + // Find the message type for an Any proto. // Returns NULL if no message is known for this name. // The base implementation only accepts prefixes of type.googleprod.com/ or diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index 3d56e3a28e..4c26287297 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -86,7 +86,7 @@ PROTOBUF_NAMESPACE_OPEN void Timestamp::InitAsDefaultInstance() { } -class Timestamp::HasBitSetters { +class Timestamp::_Internal { public: }; diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index f3ede5c1c8..b35ad10aa0 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -201,7 +201,7 @@ class PROTOBUF_EXPORT Timestamp : // @@protoc_insertion_point(class_scope:google.protobuf.Timestamp) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index 0631fdd664..28f42d9183 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -360,13 +360,13 @@ void Type::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_Type_default_instance_._instance.get_mutable()->source_context_ = const_cast< PROTOBUF_NAMESPACE_ID::SourceContext*>( PROTOBUF_NAMESPACE_ID::SourceContext::internal_default_instance()); } -class Type::HasBitSetters { +class Type::_Internal { public: static const PROTOBUF_NAMESPACE_ID::SourceContext& source_context(const Type* msg); }; const PROTOBUF_NAMESPACE_ID::SourceContext& -Type::HasBitSetters::source_context(const Type* msg) { +Type::_Internal::source_context(const Type* msg) { return *msg->source_context_; } void Type::unsafe_arena_set_allocated_source_context( @@ -420,7 +420,7 @@ Type::Type(const Type& from) options_(from.options_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.name().size() > 0) { + if (!from.name().empty()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), GetArenaNoVirtual()); } @@ -728,7 +728,7 @@ void Type::SerializeWithCachedSizes( // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, HasBitSetters::source_context(this), output); + 5, _Internal::source_context(this), output); } // .google.protobuf.Syntax syntax = 6; @@ -791,7 +791,7 @@ void Type::SerializeWithCachedSizes( if (this->has_source_context()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 5, HasBitSetters::source_context(this), target); + 5, _Internal::source_context(this), target); } // .google.protobuf.Syntax syntax = 6; @@ -970,7 +970,7 @@ void Type::InternalSwap(Type* other) { void Field::InitAsDefaultInstance() { } -class Field::HasBitSetters { +class Field::_Internal { public: }; @@ -1006,22 +1006,22 @@ Field::Field(const Field& from) options_(from.options_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.name().size() > 0) { + if (!from.name().empty()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), GetArenaNoVirtual()); } type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.type_url().size() > 0) { + if (!from.type_url().empty()) { type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.type_url(), GetArenaNoVirtual()); } json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.json_name().size() > 0) { + if (!from.json_name().empty()) { json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.json_name(), GetArenaNoVirtual()); } default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.default_value().size() > 0) { + if (!from.default_value().empty()) { default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.default_value(), GetArenaNoVirtual()); } @@ -1751,13 +1751,13 @@ void Enum::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_Enum_default_instance_._instance.get_mutable()->source_context_ = const_cast< PROTOBUF_NAMESPACE_ID::SourceContext*>( PROTOBUF_NAMESPACE_ID::SourceContext::internal_default_instance()); } -class Enum::HasBitSetters { +class Enum::_Internal { public: static const PROTOBUF_NAMESPACE_ID::SourceContext& source_context(const Enum* msg); }; const PROTOBUF_NAMESPACE_ID::SourceContext& -Enum::HasBitSetters::source_context(const Enum* msg) { +Enum::_Internal::source_context(const Enum* msg) { return *msg->source_context_; } void Enum::unsafe_arena_set_allocated_source_context( @@ -1808,7 +1808,7 @@ Enum::Enum(const Enum& from) options_(from.options_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.name().size() > 0) { + if (!from.name().empty()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), GetArenaNoVirtual()); } @@ -2077,7 +2077,7 @@ void Enum::SerializeWithCachedSizes( // .google.protobuf.SourceContext source_context = 4; if (this->has_source_context()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, HasBitSetters::source_context(this), output); + 4, _Internal::source_context(this), output); } // .google.protobuf.Syntax syntax = 5; @@ -2130,7 +2130,7 @@ void Enum::SerializeWithCachedSizes( if (this->has_source_context()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 4, HasBitSetters::source_context(this), target); + 4, _Internal::source_context(this), target); } // .google.protobuf.Syntax syntax = 5; @@ -2299,7 +2299,7 @@ void Enum::InternalSwap(Enum* other) { void EnumValue::InitAsDefaultInstance() { } -class EnumValue::HasBitSetters { +class EnumValue::_Internal { public: }; @@ -2328,7 +2328,7 @@ EnumValue::EnumValue(const EnumValue& from) options_(from.options_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.name().size() > 0) { + if (!from.name().empty()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), GetArenaNoVirtual()); } @@ -2710,13 +2710,13 @@ void Option::InitAsDefaultInstance() { PROTOBUF_NAMESPACE_ID::_Option_default_instance_._instance.get_mutable()->value_ = const_cast< PROTOBUF_NAMESPACE_ID::Any*>( PROTOBUF_NAMESPACE_ID::Any::internal_default_instance()); } -class Option::HasBitSetters { +class Option::_Internal { public: static const PROTOBUF_NAMESPACE_ID::Any& value(const Option* msg); }; const PROTOBUF_NAMESPACE_ID::Any& -Option::HasBitSetters::value(const Option* msg) { +Option::_Internal::value(const Option* msg) { return *msg->value_; } void Option::unsafe_arena_set_allocated_value( @@ -2760,7 +2760,7 @@ Option::Option(const Option& from) _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.name().size() > 0) { + if (!from.name().empty()) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), GetArenaNoVirtual()); } @@ -2937,7 +2937,7 @@ void Option::SerializeWithCachedSizes( // .google.protobuf.Any value = 2; if (this->has_value()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, HasBitSetters::value(this), output); + 2, _Internal::value(this), output); } if (_internal_metadata_.have_unknown_fields()) { @@ -2968,7 +2968,7 @@ void Option::SerializeWithCachedSizes( if (this->has_value()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( - 2, HasBitSetters::value(this), target); + 2, _Internal::value(this), target); } if (_internal_metadata_.have_unknown_fields()) { diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 0ded75db37..6da3d32569 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -383,7 +383,7 @@ class PROTOBUF_EXPORT Type : // @@protoc_insertion_point(class_scope:google.protobuf.Type) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -747,7 +747,7 @@ class PROTOBUF_EXPORT Field : // @@protoc_insertion_point(class_scope:google.protobuf.Field) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -954,7 +954,7 @@ class PROTOBUF_EXPORT Enum : // @@protoc_insertion_point(class_scope:google.protobuf.Enum) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -1132,7 +1132,7 @@ class PROTOBUF_EXPORT EnumValue : // @@protoc_insertion_point(class_scope:google.protobuf.EnumValue) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -1302,7 +1302,7 @@ class PROTOBUF_EXPORT Option : // @@protoc_insertion_point(class_scope:google.protobuf.Option) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; diff --git a/src/google/protobuf/util/internal/json_objectwriter_test.cc b/src/google/protobuf/util/internal/json_objectwriter_test.cc index 032977feae..4d190b8708 100644 --- a/src/google/protobuf/util/internal/json_objectwriter_test.cc +++ b/src/google/protobuf/util/internal/json_objectwriter_test.cc @@ -49,10 +49,12 @@ class JsonObjectWriterTest : public ::testing::Test { out_stream_(new CodedOutputStream(str_stream_)), ow_(nullptr) {} - virtual ~JsonObjectWriterTest() { - delete ow_; + ~JsonObjectWriterTest() override { delete ow_; } + + std::string CloseStreamAndGetString() { delete out_stream_; delete str_stream_; + return output_; } std::string output_; @@ -64,7 +66,7 @@ class JsonObjectWriterTest : public ::testing::Test { TEST_F(JsonObjectWriterTest, EmptyRootObject) { ow_ = new JsonObjectWriter("", out_stream_); ow_->StartObject("")->EndObject(); - EXPECT_EQ("{}", output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("{}", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, EmptyObject) { @@ -74,14 +76,13 @@ TEST_F(JsonObjectWriterTest, EmptyObject) { ->StartObject("empty") ->EndObject() ->EndObject(); - EXPECT_EQ("{\"test\":\"value\",\"empty\":{}}", - output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("{\"test\":\"value\",\"empty\":{}}", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, EmptyRootList) { ow_ = new JsonObjectWriter("", out_stream_); ow_->StartList("")->EndList(); - EXPECT_EQ("[]", output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("[]", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, EmptyList) { @@ -91,14 +92,13 @@ TEST_F(JsonObjectWriterTest, EmptyList) { ->StartList("empty") ->EndList() ->EndObject(); - EXPECT_EQ("{\"test\":\"value\",\"empty\":[]}", - output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("{\"test\":\"value\",\"empty\":[]}", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, EmptyObjectKey) { ow_ = new JsonObjectWriter("", out_stream_); ow_->StartObject("")->RenderString("", "value")->EndObject(); - EXPECT_EQ("{\"\":\"value\"}", output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("{\"\":\"value\"}", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, ObjectInObject) { @@ -108,8 +108,7 @@ TEST_F(JsonObjectWriterTest, ObjectInObject) { ->RenderString("field", "value") ->EndObject() ->EndObject(); - EXPECT_EQ("{\"nested\":{\"field\":\"value\"}}", - output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("{\"nested\":{\"field\":\"value\"}}", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, ListInObject) { @@ -119,8 +118,7 @@ TEST_F(JsonObjectWriterTest, ListInObject) { ->RenderString("", "value") ->EndList() ->EndObject(); - EXPECT_EQ("{\"nested\":[\"value\"]}", - output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("{\"nested\":[\"value\"]}", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, ObjectInList) { @@ -130,8 +128,7 @@ TEST_F(JsonObjectWriterTest, ObjectInList) { ->RenderString("field", "value") ->EndObject() ->EndList(); - EXPECT_EQ("[{\"field\":\"value\"}]", - output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("[{\"field\":\"value\"}]", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, ListInList) { @@ -141,7 +138,7 @@ TEST_F(JsonObjectWriterTest, ListInList) { ->RenderString("", "value") ->EndList() ->EndList(); - EXPECT_EQ("[[\"value\"]]", output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("[[\"value\"]]", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, RenderPrimitives) { @@ -171,7 +168,7 @@ TEST_F(JsonObjectWriterTest, RenderPrimitives) { "\"string\":\"string\"," "\"emptybytes\":\"\"," "\"emptystring\":\"\"}", - output_.substr(0, out_stream_->ByteCount())); + CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, BytesEncodesAsNonWebSafeBase64) { @@ -181,8 +178,7 @@ TEST_F(JsonObjectWriterTest, BytesEncodesAsNonWebSafeBase64) { ow_ = new JsonObjectWriter("", out_stream_); ow_->StartObject("")->RenderBytes("bytes", s)->EndObject(); // Non-web-safe would encode this as "/+8=" - EXPECT_EQ("{\"bytes\":\"/+8=\"}", - output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("{\"bytes\":\"/+8=\"}", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, PrettyPrintList) { @@ -205,7 +201,7 @@ TEST_F(JsonObjectWriterTest, PrettyPrintList) { " ],\n" " \"empty\": []\n" "}\n", - output_.substr(0, out_stream_->ByteCount())); + CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, PrettyPrintObject) { @@ -228,7 +224,7 @@ TEST_F(JsonObjectWriterTest, PrettyPrintObject) { " },\n" " \"empty\": {}\n" "}\n", - output_.substr(0, out_stream_->ByteCount())); + CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, PrettyPrintEmptyObjectInEmptyList) { @@ -245,7 +241,7 @@ TEST_F(JsonObjectWriterTest, PrettyPrintEmptyObjectInEmptyList) { " {}\n" " ]\n" "}\n", - output_.substr(0, out_stream_->ByteCount())); + CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, PrettyPrintDoubleIndent) { @@ -259,14 +255,14 @@ TEST_F(JsonObjectWriterTest, PrettyPrintDoubleIndent) { " \"bool\": true,\n" " \"int\": 42\n" "}\n", - output_.substr(0, out_stream_->ByteCount())); + CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, StringsEscapedAndEnclosedInDoubleQuotes) { ow_ = new JsonObjectWriter("", out_stream_); ow_->StartObject("")->RenderString("string", "'<>&\\\"\r\n")->EndObject(); EXPECT_EQ("{\"string\":\"'\\u003c\\u003e&\\\\\\\"\\r\\n\"}", - output_.substr(0, out_stream_->ByteCount())); + CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, Stringification) { @@ -286,7 +282,7 @@ TEST_F(JsonObjectWriterTest, Stringification) { "\"float_pos\":\"Infinity\"," "\"double_neg\":\"-Infinity\"," "\"float_neg\":\"-Infinity\"}", - output_.substr(0, out_stream_->ByteCount())); + CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, TestRegularByteEncoding) { @@ -297,8 +293,7 @@ TEST_F(JsonObjectWriterTest, TestRegularByteEncoding) { // Test that we get regular (non websafe) base64 encoding on byte fields by // default. - EXPECT_EQ("{\"bytes\":\"A+/A\"}", - output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("{\"bytes\":\"A+/A\"}", CloseStreamAndGetString()); } TEST_F(JsonObjectWriterTest, TestWebsafeByteEncoding) { @@ -309,8 +304,7 @@ TEST_F(JsonObjectWriterTest, TestWebsafeByteEncoding) { ->EndObject(); // Test that we get websafe base64 encoding when explicitly asked. - EXPECT_EQ("{\"bytes\":\"A-_AEA==\"}", - output_.substr(0, out_stream_->ByteCount())); + EXPECT_EQ("{\"bytes\":\"A-_AEA==\"}", CloseStreamAndGetString()); } } // namespace converter diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index e8100d9222..a4846613e7 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -307,7 +307,7 @@ PROTOBUF_NAMESPACE_OPEN void DoubleValue::InitAsDefaultInstance() { } -class DoubleValue::HasBitSetters { +class DoubleValue::_Internal { public: }; @@ -592,7 +592,7 @@ void DoubleValue::InternalSwap(DoubleValue* other) { void FloatValue::InitAsDefaultInstance() { } -class FloatValue::HasBitSetters { +class FloatValue::_Internal { public: }; @@ -877,7 +877,7 @@ void FloatValue::InternalSwap(FloatValue* other) { void Int64Value::InitAsDefaultInstance() { } -class Int64Value::HasBitSetters { +class Int64Value::_Internal { public: }; @@ -1164,7 +1164,7 @@ void Int64Value::InternalSwap(Int64Value* other) { void UInt64Value::InitAsDefaultInstance() { } -class UInt64Value::HasBitSetters { +class UInt64Value::_Internal { public: }; @@ -1451,7 +1451,7 @@ void UInt64Value::InternalSwap(UInt64Value* other) { void Int32Value::InitAsDefaultInstance() { } -class Int32Value::HasBitSetters { +class Int32Value::_Internal { public: }; @@ -1738,7 +1738,7 @@ void Int32Value::InternalSwap(Int32Value* other) { void UInt32Value::InitAsDefaultInstance() { } -class UInt32Value::HasBitSetters { +class UInt32Value::_Internal { public: }; @@ -2025,7 +2025,7 @@ void UInt32Value::InternalSwap(UInt32Value* other) { void BoolValue::InitAsDefaultInstance() { } -class BoolValue::HasBitSetters { +class BoolValue::_Internal { public: }; @@ -2310,7 +2310,7 @@ void BoolValue::InternalSwap(BoolValue* other) { void StringValue::InitAsDefaultInstance() { } -class StringValue::HasBitSetters { +class StringValue::_Internal { public: }; @@ -2335,7 +2335,7 @@ StringValue::StringValue(const StringValue& from) _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.value().size() > 0) { + if (!from.value().empty()) { value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.value(), GetArenaNoVirtual()); } @@ -2617,7 +2617,7 @@ void StringValue::InternalSwap(StringValue* other) { void BytesValue::InitAsDefaultInstance() { } -class BytesValue::HasBitSetters { +class BytesValue::_Internal { public: }; @@ -2642,7 +2642,7 @@ BytesValue::BytesValue(const BytesValue& from) _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.value().size() > 0) { + if (!from.value().empty()) { value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.value(), GetArenaNoVirtual()); } diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index b5ded2a08c..5deb4ecc47 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -227,7 +227,7 @@ class PROTOBUF_EXPORT DoubleValue : // @@protoc_insertion_point(class_scope:google.protobuf.DoubleValue) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -368,7 +368,7 @@ class PROTOBUF_EXPORT FloatValue : // @@protoc_insertion_point(class_scope:google.protobuf.FloatValue) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -509,7 +509,7 @@ class PROTOBUF_EXPORT Int64Value : // @@protoc_insertion_point(class_scope:google.protobuf.Int64Value) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -650,7 +650,7 @@ class PROTOBUF_EXPORT UInt64Value : // @@protoc_insertion_point(class_scope:google.protobuf.UInt64Value) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -791,7 +791,7 @@ class PROTOBUF_EXPORT Int32Value : // @@protoc_insertion_point(class_scope:google.protobuf.Int32Value) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -932,7 +932,7 @@ class PROTOBUF_EXPORT UInt32Value : // @@protoc_insertion_point(class_scope:google.protobuf.UInt32Value) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -1073,7 +1073,7 @@ class PROTOBUF_EXPORT BoolValue : // @@protoc_insertion_point(class_scope:google.protobuf.BoolValue) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -1229,7 +1229,7 @@ class PROTOBUF_EXPORT StringValue : // @@protoc_insertion_point(class_scope:google.protobuf.StringValue) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; @@ -1385,7 +1385,7 @@ class PROTOBUF_EXPORT BytesValue : // @@protoc_insertion_point(class_scope:google.protobuf.BytesValue) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; From 0a67788a4655b1071dd2609485053db7dcd4b649 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Fri, 31 May 2019 06:26:08 -0700 Subject: [PATCH 27/51] Include the new Java util files in Makefile.am --- Makefile.am | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile.am b/Makefile.am index f87e74d0ac..57b1032c23 100644 --- a/Makefile.am +++ b/Makefile.am @@ -493,11 +493,15 @@ java_EXTRA_DIST= java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java \ java/util/src/main/java/com/google/protobuf/util/JsonFormat.java \ java/util/src/main/java/com/google/protobuf/util/TimeUtil.java \ + java/util/src/main/java/com/google/protobuf/util/Structs.java \ java/util/src/main/java/com/google/protobuf/util/Timestamps.java \ + java/util/src/main/java/com/google/protobuf/util/Values.java \ java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java \ java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java \ java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java \ + java/util/src/test/java/com/google/protobuf/util/StructsTest.java \ java/util/src/test/java/com/google/protobuf/util/TimeUtilTest.java \ + java/util/src/test/java/com/google/protobuf/util/ValuesTest.java \ java/util/src/test/proto/com/google/protobuf/util/json_test.proto objectivec_EXTRA_DIST= \ From 010320f780c5a85218da1bc73bb2eb2670b58950 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Fri, 31 May 2019 07:54:53 -0700 Subject: [PATCH 28/51] Add dependency to truth in test --- java/pom.xml | 6 ++++++ java/util/pom.xml | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/java/pom.xml b/java/pom.xml index 5291f9c113..79456cb26c 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -101,6 +101,12 @@ 26.0-jre test + + com.google.truth + truth + 0.45 + test + diff --git a/java/util/pom.xml b/java/util/pom.xml index 010e522000..17ecacf111 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -49,6 +49,11 @@ org.easymock easymockclassextension + + com.google.truth + truth + test + From 74f4f594cf79eca344cb23ed5bc2db9694580403 Mon Sep 17 00:00:00 2001 From: Wang Kirin Date: Thu, 30 May 2019 14:27:16 +0800 Subject: [PATCH 29/51] fix typos in examples/README.md --- examples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 examples/README.md diff --git a/examples/README.md b/examples/README.md old mode 100644 new mode 100755 index 3eb63527b7..2378ff6ae8 --- a/examples/README.md +++ b/examples/README.md @@ -38,7 +38,7 @@ and the protobuf runtime for the language you want to build. You can simply run "make" to build the example for all languages (except for Go). However, since different language has different installation requirement, -it will likely fail. It's better to follow individual instrutions below to +it will likely fail. It's better to follow individual instructions below to build only the language you are interested in. ### C++ From e06c5ff780a418ba7814d670b08663cb4a9474e7 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Fri, 31 May 2019 15:32:02 -0700 Subject: [PATCH 30/51] Update CONTRIBUTING.md --- CONTRIBUTING.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8b28471b94..db1ff31cac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -83,6 +83,10 @@ the final release. Ultimately, the green signal will be provided by our testing infrastructure. The reviewer will help you if there are test failures that seem not related to the change you are making. + +## Reviewer Guidelines + +* Make sure that all tests are passing before approval. * Apply the "release notes: yes" label if the pull request's description should be included in the next release (e.g., any new feature / bug fix). Apply the "release notes: no" label if the pull request's description should @@ -92,4 +96,3 @@ the final release. pull request. This will make it easier to identify which languages the pull request affects, allowing us to better identify appropriate reviewer, create a better release note, and make it easier to identify issues in the future. - From 232d06174381bfd4ca2ea7979607113320b76ad6 Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Thu, 30 May 2019 15:03:51 -0700 Subject: [PATCH 31/51] remove comment about wire_format_lite_inl.h The wire_format_lite_inl.h header file was made unnecessary in #5839 and deleted in #5921, so remove the comment about it. --- src/google/protobuf/wire_format_lite.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index c16cd27617..c25b59a198 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -244,9 +244,7 @@ class PROTOBUF_EXPORT WireFormatLite { static int64 ZigZagDecode64(uint64 n); // ================================================================= - // Methods for reading/writing individual field. The implementations - // of these methods are defined in wire_format_lite_inl.h; you must #include - // that file to use these. + // Methods for reading/writing individual field. // Read fields, not including tags. The assumption is that you already // read the tag to determine what field to read. From e08f01ce6a78a6cf2834dfa37281eb366eb0c5c3 Mon Sep 17 00:00:00 2001 From: Wang Kirin Date: Tue, 4 Jun 2019 20:20:45 +0800 Subject: [PATCH 32/51] compelete fix issue 5060: change CodedOutputStream to CodedOutputStream* --- src/google/protobuf/io/coded_stream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 src/google/protobuf/io/coded_stream.h diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h old mode 100644 new mode 100755 index 5d065fc25e..89ae74d075 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -664,7 +664,7 @@ class PROTOBUF_EXPORT CodedInputStream { // individual value. // i.e., in the example above: // -// CodedOutputStream coded_output = new CodedOutputStream(raw_output); +// CodedOutputStream* coded_output = new CodedOutputStream(raw_output); // int magic_number = 1234; // char text[] = "Hello world!"; // From b10d490efd6052a02a90277e3325adbec6ce62eb Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Sun, 2 Jun 2019 21:39:23 -0400 Subject: [PATCH 33/51] Fix RPATH when CMAKE_INSTALL_LIBDIR != lib. In some platforms ${CMAKE_INSTALL_LIBDIR} expands to `lib64`. The libraries are correctly installed in that directory, but the RPATH is set to point to `$ORIGIN/../lib`, where it should be `$ORIGIN/../lib64`. --- cmake/install.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/install.cmake b/cmake/install.cmake index 9b2ae93cf6..be47c54a1e 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -33,7 +33,7 @@ if (protobuf_BUILD_PROTOC_BINARIES) RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc) if (UNIX AND NOT APPLE) set_property(TARGET protoc - PROPERTY INSTALL_RPATH "$ORIGIN/../lib") + PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") elseif (APPLE) set_property(TARGET protoc PROPERTY INSTALL_RPATH "@loader_path/../lib") From 4e740a724fd5b9bf0810992d1b6071b770b59a1c Mon Sep 17 00:00:00 2001 From: Andrzej Hunt Date: Wed, 5 Jun 2019 16:24:05 +0200 Subject: [PATCH 34/51] ObjC: avoid assign for object properties This avoids hitting the following warning when including GPBDescriptor.h in ARC projects with stricter warning settings: error: 'assign' property of object type may become a dangling reference; consider using 'unsafe_unretained' [-Werror,-Wobjc-property-assign-on-object-type We first hit this in XCode 11, it's unclear whether it simply got stricter about enforcing this warning or whether the flags enabled with -Wall or -Weverything have been expanded. --- objectivec/GPBDescriptor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/objectivec/GPBDescriptor.h b/objectivec/GPBDescriptor.h index 292bce1371..b6a85c12dc 100644 --- a/objectivec/GPBDescriptor.h +++ b/objectivec/GPBDescriptor.h @@ -75,7 +75,7 @@ typedef NS_ENUM(uint8_t, GPBFieldType) { /** Number of extension ranges declared for the message. */ @property(nonatomic, readonly) uint32_t extensionRangesCount; /** Descriptor for the file where the message was defined. */ -@property(nonatomic, readonly, assign) GPBFileDescriptor *file; +@property(nonatomic, readonly) GPBFileDescriptor *file; /** Whether the message is in wire format or not. */ @property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat; @@ -188,10 +188,10 @@ typedef NS_ENUM(uint8_t, GPBFieldType) { @property(nonatomic, readonly, getter=isPackable) BOOL packable; /** The containing oneof if this field is part of one, nil otherwise. */ -@property(nonatomic, readonly, assign, nullable) GPBOneofDescriptor *containingOneof; +@property(nonatomic, readonly, nullable) GPBOneofDescriptor *containingOneof; /** Class of the message if the field is of message type. */ -@property(nonatomic, readonly, assign, nullable) Class msgClass; +@property(nonatomic, readonly, nullable) Class msgClass; /** Descriptor for the enum if this field is an enum. */ @property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor; From 1c95097dd385fca8cbfb94c10f414669e57ca87c Mon Sep 17 00:00:00 2001 From: Julien Poumailloux Date: Thu, 6 Jun 2019 09:54:04 -0700 Subject: [PATCH 35/51] ObjC: avoid assign for object properties (part 2) Follow up on https://github.com/protocolbuffers/protobuf/pull/6221 --- objectivec/GPBDescriptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objectivec/GPBDescriptor.h b/objectivec/GPBDescriptor.h index b6a85c12dc..331d4444ab 100644 --- a/objectivec/GPBDescriptor.h +++ b/objectivec/GPBDescriptor.h @@ -305,7 +305,7 @@ typedef NS_ENUM(uint8_t, GPBFieldType) { /** Whether the extension is packable. */ @property(nonatomic, readonly, getter=isPackable) BOOL packable; /** The class of the message if the extension is of message type. */ -@property(nonatomic, readonly, assign) Class msgClass; +@property(nonatomic, readonly) Class msgClass; /** The singleton name for the extension. */ @property(nonatomic, readonly) NSString *singletonName; /** The enum descriptor if the extension is of enum type. */ From 1c8a7a10f82dc7a5a2aca026f4b49450d76673bd Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 6 Jun 2019 14:25:22 -0400 Subject: [PATCH 36/51] Update some tests for newer clang error messages. --- objectivec/Tests/GPBMessageTests+Runtime.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/objectivec/Tests/GPBMessageTests+Runtime.m b/objectivec/Tests/GPBMessageTests+Runtime.m index b0d58c9c55..9d98f91ca7 100644 --- a/objectivec/Tests/GPBMessageTests+Runtime.m +++ b/objectivec/Tests/GPBMessageTests+Runtime.m @@ -1482,7 +1482,7 @@ [msg release]; msg = [[Message2 alloc] init]; - uint32_t values[] = { + int32_t values[] = { Message2_O_OneOfCase_OneofInt32, Message2_O_OneOfCase_OneofInt64, Message2_O_OneOfCase_OneofUint32, @@ -1992,7 +1992,7 @@ [msg release]; msg = [[Message3 alloc] init]; - uint32_t values[] = { + int32_t values[] = { Message3_O_OneOfCase_OneofInt32, Message3_O_OneOfCase_OneofInt64, Message3_O_OneOfCase_OneofUint32, @@ -2113,7 +2113,7 @@ Message2 *msg = [[Message2 alloc] init]; - uint32_t values[] = { + int32_t values[] = { Message2_O_OneOfCase_OneofInt32, Message2_O_OneOfCase_OneofInt64, Message2_O_OneOfCase_OneofUint32, @@ -2242,7 +2242,7 @@ Message3 *msg = [[Message3 alloc] init]; - uint32_t values[] = { + int32_t values[] = { Message3_O_OneOfCase_OneofInt32, Message3_O_OneOfCase_OneofInt64, Message3_O_OneOfCase_OneofUint32, From a8b8c037fca174b8514cfd1184172523f6b7dc7a Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 6 Jun 2019 13:43:42 -0400 Subject: [PATCH 37/51] Add Xcode 11 support to the script. --- objectivec/DevTools/full_mac_build.sh | 38 ++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/objectivec/DevTools/full_mac_build.sh b/objectivec/DevTools/full_mac_build.sh index 7543fdf029..1f87407358 100755 --- a/objectivec/DevTools/full_mac_build.sh +++ b/objectivec/DevTools/full_mac_build.sh @@ -41,7 +41,7 @@ OPTIONS: Skip the Xcode Debug configuration. --skip-xcode-release Skip the Xcode Release configuration. - --skip-xcode-osx + --skip-xcode-osx | --skip-xcode-macos Skip the invoke of Xcode to test the runtime on OS X. --skip-xcode-tvos Skip the invoke of Xcode to test the runtime on tvOS. @@ -119,7 +119,7 @@ while [[ $# != 0 ]]; do --skip-xcode-ios ) DO_XCODE_IOS_TESTS=no ;; - --skip-xcode-osx ) + --skip-xcode-osx | --skip-xcode-macos) DO_XCODE_OSX_TESTS=no ;; --skip-xcode-tvos ) @@ -280,7 +280,16 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then -disable-concurrent-testing ) ;; - 10.[0-1]* ) + 10.*) + XCODEBUILD_TEST_BASE_IOS+=( + -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit + -destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit + # 10.x also seems to often fail running destinations in parallel (with + # 32bit one include atleast) + -disable-concurrent-destination-testing + ) + ;; + 11.0* ) XCODEBUILD_TEST_BASE_IOS+=( -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit -destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit @@ -340,10 +349,27 @@ if [[ "${DO_XCODE_TVOS_TESTS}" == "yes" ]] ; then xcodebuild -project objectivec/ProtocolBuffers_tvOS.xcodeproj -scheme ProtocolBuffers - # Test on the oldest and current. - -destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=9.0" - -destination "platform=tvOS Simulator,name=Apple TV,OS=latest" ) + case "${XCODE_VERSION}" in + [6-9].* ) + echo "ERROR: Xcode 10.0 or higher is required to build the test suite." 1>&2 + exit 11 + ;; + 10.* | 11.* ) + XCODEBUILD_TEST_BASE_TVOS+=( + # Test on the oldest and current. + -destination "platform=tvOS Simulator,name=Apple TV,OS=11.0" + -destination "platform=tvOS Simulator,name=Apple TV 4K,OS=latest" + ) + ;; + * ) + echo "" + echo "ATTENTION: Time to update the simulator targets for Xcode ${XCODE_VERSION}" + echo "" + echo "ERROR: Build aborted!" + exit 2 + ;; + esac if [[ "${XCODE_QUIET}" == "yes" ]] ; then XCODEBUILD_TEST_BASE_TVOS+=( -quiet ) fi From 6153f80876b61fcd6c48a4f0c89dc51ac144a4f6 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 3 Jun 2019 08:56:33 -0700 Subject: [PATCH 38/51] Treat plugins as host tools. As a followup to ca3ead7745581b24d9e84471b5dee6921fcd369d, treat plugin executables as well as protoc as host tools. --- protobuf.bzl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/protobuf.bzl b/protobuf.bzl index 2fd31d081c..e0653321f8 100644 --- a/protobuf.bzl +++ b/protobuf.bzl @@ -117,6 +117,7 @@ def _proto_gen_impl(ctx): outs = [ctx.actions.declare_file(out, sibling = src) for out in outs] inputs = [src] + deps + tools = [ctx.executable.protoc] if ctx.executable.plugin: plugin = ctx.executable.plugin lang = ctx.attr.plugin_language @@ -131,11 +132,12 @@ def _proto_gen_impl(ctx): outdir = ",".join(ctx.attr.plugin_options) + ":" + outdir args += [("--plugin=protoc-gen-%s=" + path_tpl) % (lang, plugin.path)] args += ["--%s_out=%s" % (lang, outdir)] - inputs += [plugin] + tools.append(plugin) if not in_gen_dir: ctx.actions.run( inputs = inputs, + tools = tools, outputs = outs, arguments = args + import_flags + [src.path], executable = ctx.executable.protoc, @@ -162,7 +164,7 @@ def _proto_gen_impl(ctx): outputs = [out], command = command, mnemonic = "ProtoCompile", - tools = [ctx.executable.protoc], + tools = tools, use_default_shell_env = True, ) From 3cbe45a4b55952609dff0b3a9e2e7043679af93f Mon Sep 17 00:00:00 2001 From: boscosiu Date: Fri, 31 May 2019 16:01:05 -0700 Subject: [PATCH 39/51] JSON string output funtions should clear() the destination first Make the JSON util string output functions match the Message::SerializeToString() behavior. This is helpful when packing the output into string fields of reused protobuf messages. --- src/google/protobuf/util/json_util.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index 52ce331005..c12c50cf53 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc @@ -115,6 +115,7 @@ util::Status BinaryToJsonString(TypeResolver* resolver, const std::string& binary_input, std::string* json_output, const JsonPrintOptions& options) { + json_output->clear(); io::ArrayInputStream input_stream(binary_input.data(), binary_input.size()); io::StringOutputStream output_stream(json_output); return BinaryToJsonStream(resolver, type_url, &input_stream, &output_stream, @@ -209,6 +210,7 @@ util::Status JsonToBinaryString(TypeResolver* resolver, StringPiece json_input, std::string* binary_output, const JsonParseOptions& options) { + binary_output->clear(); io::ArrayInputStream input_stream(json_input.data(), json_input.size()); io::StringOutputStream output_stream(binary_output); return JsonToBinaryStream(resolver, type_url, &input_stream, &output_stream, From a1b3d5e1b9747fed5ecef2fb57088b6aaa47034d Mon Sep 17 00:00:00 2001 From: Lily Li Date: Thu, 6 Jun 2019 17:30:50 -0700 Subject: [PATCH 40/51] add compatibility check badges to README --- python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/README.md b/python/README.md index 3eb78e5629..8f7e031314 100644 --- a/python/README.md +++ b/python/README.md @@ -1,7 +1,7 @@ Protocol Buffers - Google's data interchange format =================================================== -[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python_compatibility.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython_compatibility%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython_cpp%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-python.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fpython%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-python_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fpython_cpp%2Fcontinuous) +[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python_compatibility.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython_compatibility%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython_cpp%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-python.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fpython%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-python_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fpython_cpp%2Fcontinuous) [![Compat check PyPI](https://python-compatibility-tools.appspot.com/one_badge_image?package=protobuf)](https://python-compatibility-tools.appspot.com/one_badge_target?package=protobuf) Copyright 2008 Google Inc. From f158dfe3a9086aa298924de88b33d871ac27fdd3 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Mon, 10 Jun 2019 16:49:58 -0700 Subject: [PATCH 41/51] Add AM_SILENT_RULES([yes]) to configure.ac --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 2f025b7ee1..a8f7b303e7 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,11 @@ AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects]) +# Silent rules enabled: the output is minimal but informative. +# In particular, the warnings from the compiler stick out very clearly. +# To see all logs, use the --disable-silent-rules on configure or via make V=1 +AM_SILENT_RULES([yes]) + AC_ARG_WITH([zlib], [AS_HELP_STRING([--with-zlib], [include classes for streaming compressed data in and out @<:@default=check@:>@])], From 21e4b1c3366fe6831ed5c62ca974166e6e4d98c2 Mon Sep 17 00:00:00 2001 From: "John W. Bruce" Date: Wed, 5 Jun 2019 18:28:16 -0700 Subject: [PATCH 42/51] Fix Alphabetization of BUILD --- BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD b/BUILD index d681994fec..1f1a047467 100644 --- a/BUILD +++ b/BUILD @@ -115,8 +115,8 @@ cc_library( "src/google/protobuf/generated_message_util.cc", "src/google/protobuf/implicit_weak_message.cc", "src/google/protobuf/io/coded_stream.cc", - "src/google/protobuf/io/strtod.cc", "src/google/protobuf/io/io_win32.cc", + "src/google/protobuf/io/strtod.cc", "src/google/protobuf/io/zero_copy_stream.cc", "src/google/protobuf/io/zero_copy_stream_impl.cc", "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", From 36cd11a2bf3593427a54ccca3254351dd577be48 Mon Sep 17 00:00:00 2001 From: marwan-at-work Date: Tue, 11 Jun 2019 09:26:25 -0400 Subject: [PATCH 43/51] Add twirpql ID to global registry --- docs/options.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/options.md b/docs/options.md index c1775d17b6..72e265634b 100644 --- a/docs/options.md +++ b/docs/options.md @@ -197,3 +197,7 @@ with info about your project (name and website) so we can add an entry for you. * Website: https://github.com/container-storage-interface/spec * Extensions: 1059-1069 +1. TwirpQL Plugin + * Website: https://twirpql.dev + * Extensions: 1070 + From 09cab821a96c52b7b3482bd993177a33098012a8 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 11 Jun 2019 16:00:16 -0700 Subject: [PATCH 44/51] Down integrate to GitHub --- .../com/google/protobuf/AbstractMessage.java | 4 +- .../protobuf/ExtensionRegistryLite.java | 16 +- .../java/com/google/protobuf/Message.java | 2 +- .../java/com/google/protobuf/TextFormat.java | 408 +++++++--- .../com/google/protobuf/UnknownFieldSet.java | 4 +- .../com/google/protobuf/MapForProto2Test.java | 2 +- .../java/com/google/protobuf/MapTest.java | 2 +- .../com/google/protobuf/TextFormatTest.java | 101 ++- .../google/protobuf/UnknownEnumValueTest.java | 2 +- js/message.js | 22 +- protobuf.pc.in | 1 + .../protobuf/internal/descriptor_pool_test.py | 84 +- .../protobuf/internal/json_format_test.py | 17 + python/google/protobuf/json_format.py | 16 +- .../google/protobuf/pyext/descriptor_pool.cc | 130 ++-- .../google/protobuf/pyext/descriptor_pool.h | 4 + python/setup.py | 1 + src/google/protobuf/any.pb.cc | 9 - src/google/protobuf/any.pb.h | 11 +- src/google/protobuf/api.pb.cc | 37 - src/google/protobuf/api.pb.h | 53 +- src/google/protobuf/arena.h | 2 +- .../command_line_interface_unittest.cc | 4 + .../protobuf/compiler/cpp/cpp_helpers.cc | 6 +- .../protobuf/compiler/cpp/cpp_message.cc | 91 +-- .../protobuf/compiler/js/js_generator.cc | 18 +- .../protobuf/compiler/js/js_generator.h | 2 +- src/google/protobuf/compiler/plugin.pb.cc | 41 - src/google/protobuf/compiler/plugin.pb.h | 54 +- src/google/protobuf/compiler/subprocess.cc | 5 +- src/google/protobuf/descriptor.pb.cc | 718 ------------------ src/google/protobuf/descriptor.pb.h | 707 ++++++++++++----- src/google/protobuf/duration.pb.cc | 24 - src/google/protobuf/duration.pb.h | 21 +- src/google/protobuf/empty.pb.cc | 22 - src/google/protobuf/empty.pb.h | 15 +- src/google/protobuf/extension_set_inl.h | 3 +- src/google/protobuf/field_mask.pb.cc | 23 - src/google/protobuf/field_mask.pb.h | 19 +- src/google/protobuf/generated_message_util.cc | 9 + src/google/protobuf/generated_message_util.h | 1 + src/google/protobuf/message.cc | 9 +- src/google/protobuf/message.h | 2 +- src/google/protobuf/parse_context.cc | 14 +- src/google/protobuf/parse_context.h | 6 +- src/google/protobuf/repeated_field.h | 84 +- src/google/protobuf/source_context.pb.cc | 8 - src/google/protobuf/source_context.pb.h | 9 +- src/google/protobuf/struct.pb.cc | 74 -- src/google/protobuf/struct.pb.h | 67 +- src/google/protobuf/stubs/mathutil.h | 3 +- src/google/protobuf/timestamp.pb.cc | 24 - src/google/protobuf/timestamp.pb.h | 21 +- src/google/protobuf/type.pb.cc | 136 ---- src/google/protobuf/type.pb.h | 137 +++- src/google/protobuf/unknown_field_set.cc | 14 +- src/google/protobuf/unknown_field_set.h | 7 +- .../protobuf/util/field_comparator_test.cc | 14 + src/google/protobuf/util/json_format.proto | 11 + .../protobuf/util/message_differencer.cc | 12 +- .../util/message_differencer_unittest.cc | 59 ++ src/google/protobuf/wire_format_lite.h | 6 +- src/google/protobuf/wrappers.pb.cc | 207 ----- src/google/protobuf/wrappers.pb.h | 171 ++++- 64 files changed, 1794 insertions(+), 2012 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/AbstractMessage.java b/java/core/src/main/java/com/google/protobuf/AbstractMessage.java index fe1bebc77b..15ee53a426 100644 --- a/java/core/src/main/java/com/google/protobuf/AbstractMessage.java +++ b/java/core/src/main/java/com/google/protobuf/AbstractMessage.java @@ -108,7 +108,7 @@ public abstract class AbstractMessage @Override public final String toString() { - return TextFormat.printToString(this); + return TextFormat.printer().printToString(this); } @Override @@ -468,7 +468,7 @@ public abstract class AbstractMessage @Override public String toString() { - return TextFormat.printToString(this); + return TextFormat.printer().printToString(this); } /** Construct an UninitializedMessageException reporting missing fields in the given message. */ diff --git a/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java b/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java index 11843b6c39..f07d607212 100644 --- a/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java +++ b/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java @@ -76,6 +76,10 @@ public class ExtensionRegistryLite { // applications. Need to support this feature on smaller granularity. private static volatile boolean eagerlyParseMessageSets = false; + // short circuit the ExtensionRegistryFactory via assumevalues trickery + @SuppressWarnings("JavaOptionalSuggestions") + private static boolean doFullRuntimeInheritanceCheck = true; + // Visible for testing. static final String EXTENSION_CLASS_NAME = "com.google.protobuf.Extension"; @@ -107,7 +111,9 @@ public class ExtensionRegistryLite { * available. */ public static ExtensionRegistryLite newInstance() { - return ExtensionRegistryFactory.create(); + return doFullRuntimeInheritanceCheck + ? ExtensionRegistryFactory.create() + : new ExtensionRegistryLite(); } private static volatile ExtensionRegistryLite emptyRegistry; @@ -122,7 +128,11 @@ public class ExtensionRegistryLite { synchronized (ExtensionRegistryLite.class) { result = emptyRegistry; if (result == null) { - result = emptyRegistry = ExtensionRegistryFactory.createEmpty(); + result = + emptyRegistry = + doFullRuntimeInheritanceCheck + ? ExtensionRegistryFactory.createEmpty() + : EMPTY_REGISTRY_LITE; } } } @@ -163,7 +173,7 @@ public class ExtensionRegistryLite { if (GeneratedMessageLite.GeneratedExtension.class.isAssignableFrom(extension.getClass())) { add((GeneratedMessageLite.GeneratedExtension) extension); } - if (ExtensionRegistryFactory.isFullRegistry(this)) { + if (doFullRuntimeInheritanceCheck && ExtensionRegistryFactory.isFullRegistry(this)) { try { this.getClass().getMethod("add", extensionClass).invoke(this, extension); } catch (Exception e) { diff --git a/java/core/src/main/java/com/google/protobuf/Message.java b/java/core/src/main/java/com/google/protobuf/Message.java index 40dcaf026e..9b3a015ba9 100644 --- a/java/core/src/main/java/com/google/protobuf/Message.java +++ b/java/core/src/main/java/com/google/protobuf/Message.java @@ -85,7 +85,7 @@ public interface Message extends MessageLite, MessageOrBuilder { /** * Converts the message to a string in protocol buffer text format. This is just a trivial wrapper - * around {@link TextFormat#printToString(MessageOrBuilder)}. + * around {@link TextFormat.Printer#printToString(MessageOrBuilder)}. */ @Override String toString(); diff --git a/java/core/src/main/java/com/google/protobuf/TextFormat.java b/java/core/src/main/java/com/google/protobuf/TextFormat.java index 2326a05ffb..0385b2425a 100644 --- a/java/core/src/main/java/com/google/protobuf/TextFormat.java +++ b/java/core/src/main/java/com/google/protobuf/TextFormat.java @@ -61,135 +61,132 @@ public final class TextFormat { * Outputs a textual representation of the Protocol Message supplied into the parameter output. * (This representation is the new version of the classic "ProtocolPrinter" output from the * original Protocol Buffer system) + * + * @deprecated Use {@code printer().print(MessageOrBuilder, Appendable)} */ + @Deprecated public static void print(final MessageOrBuilder message, final Appendable output) throws IOException { - Printer.DEFAULT.print(message, multiLineOutput(output)); + printer().print(message, output); } - /** Outputs a textual representation of {@code fields} to {@code output}. */ + /** + * Outputs a textual representation of {@code fields} to {@code output}. + * + * @deprecated Use {@code printer().print(UnknownFieldSet, Appendable)} + */ + @Deprecated public static void print(final UnknownFieldSet fields, final Appendable output) throws IOException { - Printer.DEFAULT.printUnknownFields(fields, multiLineOutput(output)); + printer().print(fields, output); } - /** Same as {@code print()}, except that non-ASCII characters are not escaped. */ + /** + * Same as {@code print()}, except that non-ASCII characters are not escaped. + * + * @deprecated Use {@code printer().escapingNonAscii(false).print(MessageOrBuilder, Appendable)} + */ + @Deprecated public static void printUnicode(final MessageOrBuilder message, final Appendable output) throws IOException { - Printer.UNICODE.print(message, multiLineOutput(output)); + printer().escapingNonAscii(false).print(message, output); } - /** Same as {@code print()}, except that non-ASCII characters are not escaped. */ + /** + * Same as {@code print()}, except that non-ASCII characters are not escaped. + * + * @deprecated Use {@code printer().escapingNonAscii(false).print(UnknownFieldSet, Appendable)} + */ + @Deprecated public static void printUnicode(final UnknownFieldSet fields, final Appendable output) throws IOException { - Printer.UNICODE.printUnknownFields(fields, multiLineOutput(output)); + printer().escapingNonAscii(false).print(fields, output); } /** * Generates a human readable form of this message, useful for debugging and other purposes, with - * no newline characters. + * no newline characters. This is just a trivial wrapper around + * {@link TextFormat.Printer#shortDebugString(MessageOrBuilder)}. */ public static String shortDebugString(final MessageOrBuilder message) { - try { - final StringBuilder text = new StringBuilder(); - Printer.DEFAULT.print(message, singleLineOutput(text)); - return text.toString(); - } catch (IOException e) { - throw new IllegalStateException(e); - } + return printer().shortDebugString(message); } /** * Generates a human readable form of the field, useful for debugging and other purposes, with no * newline characters. + * + * @deprecated Use {@code printer().shortDebugString(FieldDescriptor, Object)} */ + @Deprecated public static String shortDebugString(final FieldDescriptor field, final Object value) { - try { - final StringBuilder text = new StringBuilder(); - Printer.DEFAULT.printField(field, value, singleLineOutput(text)); - return text.toString(); - } catch (IOException e) { - throw new IllegalStateException(e); - } + return printer().shortDebugString(field, value); } /** * Generates a human readable form of the unknown fields, useful for debugging and other purposes, * with no newline characters. + * + * @deprecated Use {@code printer().shortDebugString(UnknownFieldSet)} */ + @Deprecated public static String shortDebugString(final UnknownFieldSet fields) { - try { - final StringBuilder text = new StringBuilder(); - Printer.DEFAULT.printUnknownFields(fields, singleLineOutput(text)); - return text.toString(); - } catch (IOException e) { - throw new IllegalStateException(e); - } + return printer().shortDebugString(fields); } - /** Like {@code print()}, but writes directly to a {@code String} and returns it. */ + /** + * Like {@code print()}, but writes directly to a {@code String} and returns it. + * + * @deprecated Use {@link MessageOrBuilder#toString()} + */ + @Deprecated public static String printToString(final MessageOrBuilder message) { - try { - final StringBuilder text = new StringBuilder(); - print(message, text); - return text.toString(); - } catch (IOException e) { - throw new IllegalStateException(e); - } + return printer().printToString(message); } - /** Like {@code print()}, but writes directly to a {@code String} and returns it. */ + /** + * Like {@code print()}, but writes directly to a {@code String} and returns it. + * + * @deprecated Use {@link UnknownFieldSet#toString()} + */ + @Deprecated public static String printToString(final UnknownFieldSet fields) { - try { - final StringBuilder text = new StringBuilder(); - print(fields, text); - return text.toString(); - } catch (IOException e) { - throw new IllegalStateException(e); - } + return printer().printToString(fields); } /** * Same as {@code printToString()}, except that non-ASCII characters in string type fields are not * escaped in backslash+octals. + * + * @deprecated Use {@code printer().escapingNonAscii(false).printToString(MessageOrBuilder)} */ + @Deprecated public static String printToUnicodeString(final MessageOrBuilder message) { - try { - final StringBuilder text = new StringBuilder(); - Printer.UNICODE.print(message, multiLineOutput(text)); - return text.toString(); - } catch (IOException e) { - throw new IllegalStateException(e); - } + return printer().escapingNonAscii(false).printToString(message); } /** * Same as {@code printToString()}, except that non-ASCII characters in string type fields are not * escaped in backslash+octals. + * + * @deprecated Use {@code printer().escapingNonAscii(false).printToString(UnknownFieldSet)} */ + @Deprecated public static String printToUnicodeString(final UnknownFieldSet fields) { - try { - final StringBuilder text = new StringBuilder(); - Printer.UNICODE.printUnknownFields(fields, multiLineOutput(text)); - return text.toString(); - } catch (IOException e) { - throw new IllegalStateException(e); - } + return printer().escapingNonAscii(false).printToString(fields); } + /** @deprecated Use {@code printer().printField(FieldDescriptor, Object, Appendable)} */ + @Deprecated public static void printField( final FieldDescriptor field, final Object value, final Appendable output) throws IOException { - Printer.DEFAULT.printField(field, value, multiLineOutput(output)); + printer().printField(field, value, output); } + /** @deprecated Use {@code printer().printFieldToString(FieldDescriptor, Object)} */ + @Deprecated public static String printFieldToString(final FieldDescriptor field, final Object value) { - try { - final StringBuilder text = new StringBuilder(); - printField(field, value, text); - return text.toString(); - } catch (IOException e) { - throw new IllegalStateException(e); - } + return printer().printFieldToString(field, value); } /** @@ -198,29 +195,34 @@ public final class TextFormat { *

Same as {@code printFieldValue()}, except that non-ASCII characters in string type fields * are not escaped in backslash+octals. * + * @deprecated Use {@code printer().escapingNonAscii(false).printFieldValue(FieldDescriptor, + * Object, Appendable)} * @param field the descriptor of the field * @param value the value of the field * @param output the output to which to append the formatted value * @throws ClassCastException if the value is not appropriate for the given field descriptor * @throws IOException if there is an exception writing to the output */ + @Deprecated public static void printUnicodeFieldValue( final FieldDescriptor field, final Object value, final Appendable output) throws IOException { - Printer.UNICODE.printFieldValue(field, value, multiLineOutput(output)); + printer().escapingNonAscii(false).printFieldValue(field, value, output); } /** * Outputs a textual representation of the value of given field value. * + * @deprecated Use {@code printer().printFieldValue(FieldDescriptor, Object, Appendable)} * @param field the descriptor of the field * @param value the value of the field * @param output the output to which to append the formatted value * @throws ClassCastException if the value is not appropriate for the given field descriptor * @throws IOException if there is an exception writing to the output */ + @Deprecated public static void printFieldValue( final FieldDescriptor field, final Object value, final Appendable output) throws IOException { - Printer.DEFAULT.printFieldValue(field, value, multiLineOutput(output)); + printer().printFieldValue(field, value, output); } /** @@ -256,7 +258,7 @@ public final class TextFormat { generator.print("{"); generator.eol(); generator.indent(); - Printer.DEFAULT.printUnknownFields(message, generator); + Printer.printUnknownFields(message, generator); generator.outdent(); generator.print("}"); } catch (InvalidProtocolBufferException e) { @@ -267,19 +269,23 @@ public final class TextFormat { } break; case WireFormat.WIRETYPE_START_GROUP: - Printer.DEFAULT.printUnknownFields((UnknownFieldSet) value, generator); + Printer.printUnknownFields((UnknownFieldSet) value, generator); break; default: throw new IllegalArgumentException("Bad tag: " + tag); } } + /** Printer instance which escapes non-ASCII characters. */ + public static Printer printer() { + return Printer.DEFAULT; + } + /** Helper class for converting protobufs to text. */ - private static final class Printer { + public static final class Printer { + // Printer instance which escapes non-ASCII characters. - static final Printer DEFAULT = new Printer(true); - // Printer instance which emits Unicode (it still escapes newlines and quotes in strings). - static final Printer UNICODE = new Printer(false); + private static final Printer DEFAULT = new Printer(true); /** Whether to escape non ASCII characters with backslash and octal. */ private final boolean escapeNonAscii; @@ -288,12 +294,51 @@ public final class TextFormat { this.escapeNonAscii = escapeNonAscii; } + /** + * Return a new Printer instance with the specified escape mode. + * + * @param escapeNonAscii If true, the new Printer will escape non-ASCII characters (this is the + * default behavior. If false, the new Printer will print non-ASCII characters as is. In + * either case, the new Printer still escapes newlines and quotes in strings. + * @return a new Printer that clones all other configurations from the current {@link Printer}, + * with the escape mode set to the given parameter. + */ + public Printer escapingNonAscii(boolean escapeNonAscii) { + return new Printer(escapeNonAscii); + } + + /** + * Outputs a textual representation of the Protocol Message supplied into the parameter output. + * (This representation is the new version of the classic "ProtocolPrinter" output from the + * original Protocol Buffer system) + */ + public void print(final MessageOrBuilder message, final Appendable output) throws IOException { + print(message, multiLineOutput(output)); + } + + /** Outputs a textual representation of {@code fields} to {@code output}. */ + public void print(final UnknownFieldSet fields, final Appendable output) throws IOException { + printUnknownFields(fields, multiLineOutput(output)); + } + private void print(final MessageOrBuilder message, final TextGenerator generator) throws IOException { - for (Map.Entry field : message.getAllFields().entrySet()) { - printField(field.getKey(), field.getValue(), generator); + printMessage(message, generator); + } + + public String printFieldToString(final FieldDescriptor field, final Object value) { + try { + final StringBuilder text = new StringBuilder(); + printField(field, value, text); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); } - printUnknownFields(message.getUnknownFields(), generator); + } + + public void printField(final FieldDescriptor field, final Object value, final Appendable output) + throws IOException { + printField(field, value, multiLineOutput(output)); } private void printField( @@ -309,46 +354,19 @@ public final class TextFormat { } } - private void printSingleField( - final FieldDescriptor field, final Object value, final TextGenerator generator) + /** + * Outputs a textual representation of the value of given field value. + * + * @param field the descriptor of the field + * @param value the value of the field + * @param output the output to which to append the formatted value + * @throws ClassCastException if the value is not appropriate for the given field descriptor + * @throws IOException if there is an exception writing to the output + */ + public void printFieldValue( + final FieldDescriptor field, final Object value, final Appendable output) throws IOException { - if (field.isExtension()) { - generator.print("["); - // We special-case MessageSet elements for compatibility with proto1. - if (field.getContainingType().getOptions().getMessageSetWireFormat() - && (field.getType() == FieldDescriptor.Type.MESSAGE) - && (field.isOptional()) - // object equality - && (field.getExtensionScope() == field.getMessageType())) { - generator.print(field.getMessageType().getFullName()); - } else { - generator.print(field.getFullName()); - } - generator.print("]"); - } else { - if (field.getType() == FieldDescriptor.Type.GROUP) { - // Groups must be serialized with their original capitalization. - generator.print(field.getMessageType().getName()); - } else { - generator.print(field.getName()); - } - } - - if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { - generator.print(" {"); - generator.eol(); - generator.indent(); - } else { - generator.print(": "); - } - - printFieldValue(field, value, generator); - - if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { - generator.outdent(); - generator.print("}"); - } - generator.eol(); + printFieldValue(field, value, multiLineOutput(output)); } private void printFieldValue( @@ -419,7 +437,157 @@ public final class TextFormat { } } - private void printUnknownFields( + /** Like {@code print()}, but writes directly to a {@code String} and returns it. */ + public String printToString(final MessageOrBuilder message) { + try { + final StringBuilder text = new StringBuilder(); + print(message, text); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + /** Like {@code print()}, but writes directly to a {@code String} and returns it. */ + public String printToString(final UnknownFieldSet fields) { + try { + final StringBuilder text = new StringBuilder(); + print(fields, text); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + /** + * Generates a human readable form of this message, useful for debugging and other purposes, + * with no newline characters. + */ + public String shortDebugString(final MessageOrBuilder message) { + try { + final StringBuilder text = new StringBuilder(); + print(message, singleLineOutput(text)); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + /** + * Generates a human readable form of the field, useful for debugging and other purposes, with + * no newline characters. + */ + public String shortDebugString(final FieldDescriptor field, final Object value) { + try { + final StringBuilder text = new StringBuilder(); + printField(field, value, singleLineOutput(text)); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + /** + * Generates a human readable form of the unknown fields, useful for debugging and other + * purposes, with no newline characters. + */ + public String shortDebugString(final UnknownFieldSet fields) { + try { + final StringBuilder text = new StringBuilder(); + printUnknownFields(fields, singleLineOutput(text)); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + private static void printUnknownFieldValue( + final int tag, final Object value, final TextGenerator generator) throws IOException { + switch (WireFormat.getTagWireType(tag)) { + case WireFormat.WIRETYPE_VARINT: + generator.print(unsignedToString((Long) value)); + break; + case WireFormat.WIRETYPE_FIXED32: + generator.print(String.format((Locale) null, "0x%08x", (Integer) value)); + break; + case WireFormat.WIRETYPE_FIXED64: + generator.print(String.format((Locale) null, "0x%016x", (Long) value)); + break; + case WireFormat.WIRETYPE_LENGTH_DELIMITED: + try { + // Try to parse and print the field as an embedded message + UnknownFieldSet message = UnknownFieldSet.parseFrom((ByteString) value); + generator.print("{"); + generator.eol(); + generator.indent(); + printUnknownFields(message, generator); + generator.outdent(); + generator.print("}"); + } catch (InvalidProtocolBufferException e) { + // If not parseable as a message, print as a String + generator.print("\""); + generator.print(escapeBytes((ByteString) value)); + generator.print("\""); + } + break; + case WireFormat.WIRETYPE_START_GROUP: + printUnknownFields((UnknownFieldSet) value, generator); + break; + default: + throw new IllegalArgumentException("Bad tag: " + tag); + } + } + + private void printMessage(final MessageOrBuilder message, final TextGenerator generator) + throws IOException { + for (Map.Entry field : message.getAllFields().entrySet()) { + printField(field.getKey(), field.getValue(), generator); + } + printUnknownFields(message.getUnknownFields(), generator); + } + + private void printSingleField( + final FieldDescriptor field, final Object value, final TextGenerator generator) + throws IOException { + if (field.isExtension()) { + generator.print("["); + // We special-case MessageSet elements for compatibility with proto1. + if (field.getContainingType().getOptions().getMessageSetWireFormat() + && (field.getType() == FieldDescriptor.Type.MESSAGE) + && (field.isOptional()) + // object equality + && (field.getExtensionScope() == field.getMessageType())) { + generator.print(field.getMessageType().getFullName()); + } else { + generator.print(field.getFullName()); + } + generator.print("]"); + } else { + if (field.getType() == FieldDescriptor.Type.GROUP) { + // Groups must be serialized with their original capitalization. + generator.print(field.getMessageType().getName()); + } else { + generator.print(field.getName()); + } + } + + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + generator.print(" {"); + generator.eol(); + generator.indent(); + } else { + generator.print(": "); + } + + printFieldValue(field, value, generator); + + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + generator.outdent(); + generator.print("}"); + } + generator.eol(); + } + + private static void printUnknownFields( final UnknownFieldSet unknownFields, final TextGenerator generator) throws IOException { for (Map.Entry entry : unknownFields.asMap().entrySet()) { final int number = entry.getKey(); @@ -445,7 +613,7 @@ public final class TextFormat { } } - private void printUnknownField( + private static void printUnknownField( final int number, final int wireType, final List values, final TextGenerator generator) throws IOException { for (final Object value : values) { @@ -1994,7 +2162,7 @@ public final class TextFormat { return escapeBytes(ByteString.copyFromUtf8(input)); } - /** Escape double quotes and backslashes in a String for unicode output of a message. */ + /** Escape double quotes and backslashes in a String for emittingUnicode output of a message. */ public static String escapeDoubleQuotesAndBackslashes(final String input) { return TextFormatEscaper.escapeDoubleQuotesAndBackslashes(input); } diff --git a/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java b/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java index bde1303db7..ba2f9df08e 100644 --- a/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java +++ b/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java @@ -140,11 +140,11 @@ public final class UnknownFieldSet implements MessageLite { /** * Converts the set to a string in protocol buffer text format. This is just a trivial wrapper - * around {@link TextFormat#printToString(UnknownFieldSet)}. + * around {@link TextFormat.Printer#printToString(UnknownFieldSet)}. */ @Override public String toString() { - return TextFormat.printToString(this); + return TextFormat.printer().printToString(this); } /** diff --git a/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java b/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java index 4961042f5f..bb706326c4 100644 --- a/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java +++ b/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java @@ -766,7 +766,7 @@ public class MapForProto2Test extends TestCase { setMapValuesUsingAccessors(builder); TestMap message = builder.build(); - String textData = TextFormat.printToString(message); + String textData = TextFormat.printer().printToString(message); builder = TestMap.newBuilder(); TextFormat.merge(textData, builder); diff --git a/java/core/src/test/java/com/google/protobuf/MapTest.java b/java/core/src/test/java/com/google/protobuf/MapTest.java index 6007d8e7de..9f1ebaed69 100644 --- a/java/core/src/test/java/com/google/protobuf/MapTest.java +++ b/java/core/src/test/java/com/google/protobuf/MapTest.java @@ -857,7 +857,7 @@ public class MapTest extends TestCase { setMapValuesUsingAccessors(builder); TestMap message = builder.build(); - String textData = TextFormat.printToString(message); + String textData = TextFormat.printer().printToString(message); builder = TestMap.newBuilder(); TextFormat.merge(textData, builder); diff --git a/java/core/src/test/java/com/google/protobuf/TextFormatTest.java b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java index f68a45e28e..4421c0cc4b 100644 --- a/java/core/src/test/java/com/google/protobuf/TextFormatTest.java +++ b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java @@ -147,7 +147,7 @@ public class TextFormatTest extends TestCase { /** Print TestAllTypes and compare with golden file. */ public void testPrintMessage() throws Exception { - String javaText = TextFormat.printToString(TestUtil.getAllSet()); + String javaText = TextFormat.printer().printToString(TestUtil.getAllSet()); // Java likes to add a trailing ".0" to floats and doubles. C printf // (with %g format) does not. Our golden files are used for both @@ -159,7 +159,7 @@ public class TextFormatTest extends TestCase { /** Print TestAllTypes as Builder and compare with golden file. */ public void testPrintMessageBuilder() throws Exception { - String javaText = TextFormat.printToString(TestUtil.getAllSetBuilder()); + String javaText = TextFormat.printer().printToString(TestUtil.getAllSetBuilder()); // Java likes to add a trailing ".0" to floats and doubles. C printf // (with %g format) does not. Our golden files are used for both @@ -171,7 +171,7 @@ public class TextFormatTest extends TestCase { /** Print TestAllExtensions and compare with golden file. */ public void testPrintExtensions() throws Exception { - String javaText = TextFormat.printToString(TestUtil.getAllExtensionsSet()); + String javaText = TextFormat.printer().printToString(TestUtil.getAllExtensionsSet()); // Java likes to add a trailing ".0" to floats and doubles. C printf // (with %g format) does not. Our golden files are used for both @@ -237,12 +237,13 @@ public class TextFormatTest extends TestCase { + "15: 12379813812177893520\n" + "15: 0xabcd1234\n" + "15: 0xabcdef1234567890\n", - TextFormat.printToString(message)); + TextFormat.printer().printToString(message)); } public void testPrintField() throws Exception { final FieldDescriptor dataField = OneString.getDescriptor().findFieldByName("data"); - assertEquals("data: \"test data\"\n", TextFormat.printFieldToString(dataField, "test data")); + assertEquals( + "data: \"test data\"\n", TextFormat.printer().printFieldToString(dataField, "test data")); final FieldDescriptor optionalField = TestAllTypes.getDescriptor().findFieldByName("optional_nested_message"); @@ -250,7 +251,7 @@ public class TextFormatTest extends TestCase { assertEquals( "optional_nested_message {\n bb: 42\n}\n", - TextFormat.printFieldToString(optionalField, value)); + TextFormat.printer().printFieldToString(optionalField, value)); } /** @@ -885,7 +886,8 @@ public class TextFormatTest extends TestCase { private void assertPrintFieldValue(String expect, Object value, String fieldName) throws Exception { StringBuilder sb = new StringBuilder(); - TextFormat.printFieldValue(TestAllTypes.getDescriptor().findFieldByName(fieldName), value, sb); + TextFormat.printer() + .printFieldValue(TestAllTypes.getDescriptor().findFieldByName(fieldName), value, sb); assertEquals(expect, sb.toString()); } @@ -902,14 +904,17 @@ public class TextFormatTest extends TestCase { public void testShortDebugString_field() { final FieldDescriptor dataField = OneString.getDescriptor().findFieldByName("data"); - assertEquals("data: \"test data\"", TextFormat.shortDebugString(dataField, "test data")); + assertEquals( + "data: \"test data\"", + TextFormat.printer().shortDebugString(dataField, "test data")); final FieldDescriptor optionalField = TestAllTypes.getDescriptor().findFieldByName("optional_nested_message"); final Object value = NestedMessage.newBuilder().setBb(42).build(); assertEquals( - "optional_nested_message { bb: 42 }", TextFormat.shortDebugString(optionalField, value)); + "optional_nested_message { bb: 42 }", + TextFormat.printer().shortDebugString(optionalField, value)); } public void testShortDebugString_unknown() { @@ -917,7 +922,7 @@ public class TextFormatTest extends TestCase { "5: 1 5: 0x00000002 5: 0x0000000000000003 5: \"4\" 5: { 12: 6 } 5 { 10: 5 }" + " 8: 1 8: 2 8: 3 15: 12379813812177893520 15: 0xabcd1234 15:" + " 0xabcdef1234567890", - TextFormat.shortDebugString(makeUnknownFieldSet())); + TextFormat.printer().shortDebugString(makeUnknownFieldSet())); } public void testPrintToUnicodeString() throws Exception { @@ -925,23 +930,26 @@ public class TextFormatTest extends TestCase { "optional_string: \"abc\u3042efg\"\n" + "optional_bytes: \"\\343\\201\\202\"\n" + "repeated_string: \"\u3093XYZ\"\n", - TextFormat.printToUnicodeString( - TestAllTypes.newBuilder() - .setOptionalString("abc\u3042efg") - .setOptionalBytes(bytes(0xe3, 0x81, 0x82)) - .addRepeatedString("\u3093XYZ") - .build())); + TextFormat.printer() + .escapingNonAscii(false) + .printToString( + TestAllTypes.newBuilder() + .setOptionalString("abc\u3042efg") + .setOptionalBytes(bytes(0xe3, 0x81, 0x82)) + .addRepeatedString("\u3093XYZ") + .build())); // Double quotes and backslashes should be escaped assertEquals( "optional_string: \"a\\\\bc\\\"ef\\\"g\"\n", - TextFormat.printToUnicodeString( - TestAllTypes.newBuilder().setOptionalString("a\\bc\"ef\"g").build())); + TextFormat.printer() + .escapingNonAscii(false) + .printToString(TestAllTypes.newBuilder().setOptionalString("a\\bc\"ef\"g").build())); // Test escaping roundtrip TestAllTypes message = TestAllTypes.newBuilder().setOptionalString("a\\bc\\\"ef\"g").build(); TestAllTypes.Builder builder = TestAllTypes.newBuilder(); - TextFormat.merge(TextFormat.printToUnicodeString(message), builder); + TextFormat.merge(TextFormat.printer().escapingNonAscii(false).printToString(message), builder); assertEquals(message.getOptionalString(), builder.getOptionalString()); } @@ -949,48 +957,61 @@ public class TextFormatTest extends TestCase { // No newlines at start and end assertEquals( "optional_string: \"test newlines\\n\\nin\\nstring\"\n", - TextFormat.printToUnicodeString( - TestAllTypes.newBuilder().setOptionalString("test newlines\n\nin\nstring").build())); + TextFormat.printer() + .escapingNonAscii(false) + .printToString( + TestAllTypes.newBuilder() + .setOptionalString("test newlines\n\nin\nstring") + .build())); // Newlines at start and end assertEquals( "optional_string: \"\\ntest\\nnewlines\\n\\nin\\nstring\\n\"\n", - TextFormat.printToUnicodeString( - TestAllTypes.newBuilder() - .setOptionalString("\ntest\nnewlines\n\nin\nstring\n") - .build())); + TextFormat.printer() + .escapingNonAscii(false) + .printToString( + TestAllTypes.newBuilder() + .setOptionalString("\ntest\nnewlines\n\nin\nstring\n") + .build())); // Strings with 0, 1 and 2 newlines. assertEquals( "optional_string: \"\"\n", - TextFormat.printToUnicodeString(TestAllTypes.newBuilder().setOptionalString("").build())); + TextFormat.printer() + .escapingNonAscii(false) + .printToString(TestAllTypes.newBuilder().setOptionalString("").build())); assertEquals( "optional_string: \"\\n\"\n", - TextFormat.printToUnicodeString(TestAllTypes.newBuilder().setOptionalString("\n").build())); + TextFormat.printer() + .escapingNonAscii(false) + .printToString(TestAllTypes.newBuilder().setOptionalString("\n").build())); assertEquals( "optional_string: \"\\n\\n\"\n", - TextFormat.printToUnicodeString( - TestAllTypes.newBuilder().setOptionalString("\n\n").build())); + TextFormat.printer() + .escapingNonAscii(false) + .printToString(TestAllTypes.newBuilder().setOptionalString("\n\n").build())); // Test escaping roundtrip TestAllTypes message = TestAllTypes.newBuilder().setOptionalString("\ntest\nnewlines\n\nin\nstring\n").build(); TestAllTypes.Builder builder = TestAllTypes.newBuilder(); - TextFormat.merge(TextFormat.printToUnicodeString(message), builder); + TextFormat.merge(TextFormat.printer().escapingNonAscii(false).printToString(message), builder); assertEquals(message.getOptionalString(), builder.getOptionalString()); } public void testPrintToUnicodeString_unknown() { assertEquals( "1: \"\\343\\201\\202\"\n", - TextFormat.printToUnicodeString( - UnknownFieldSet.newBuilder() - .addField( - 1, - UnknownFieldSet.Field.newBuilder() - .addLengthDelimited(bytes(0xe3, 0x81, 0x82)) - .build()) - .build())); + TextFormat.printer() + .escapingNonAscii(false) + .printToString( + UnknownFieldSet.newBuilder() + .addField( + 1, + UnknownFieldSet.Field.newBuilder() + .addLengthDelimited(bytes(0xe3, 0x81, 0x82)) + .build()) + .build())); } @@ -1120,7 +1141,7 @@ public class TextFormatTest extends TestCase { TestUtil.setOneof(builder); TestOneof2 message = builder.build(); TestOneof2.Builder dest = TestOneof2.newBuilder(); - TextFormat.merge(TextFormat.printToUnicodeString(message), dest); + TextFormat.merge(TextFormat.printer().escapingNonAscii(false).printToString(message), dest); TestUtil.assertOneofSet(dest.build()); } @@ -1159,7 +1180,7 @@ public class TextFormatTest extends TestCase { .putInt32ToStringField(20, "banana") .putInt32ToStringField(30, "cherry") .build(); - String text = TextFormat.printToUnicodeString(message); + String text = TextFormat.printer().escapingNonAscii(false).printToString(message); { TestMap.Builder dest = TestMap.newBuilder(); TextFormat.merge(text, dest); diff --git a/java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java b/java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java index ae4e086ee1..7daef026dc 100644 --- a/java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java +++ b/java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java @@ -234,7 +234,7 @@ public class UnknownEnumValueTest extends TestCase { TestAllTypes message = builder.build(); // We can print a message with unknown enum values. - String textData = TextFormat.printToString(message); + String textData = TextFormat.printer().printToString(message); assertEquals( "optional_nested_enum: UNKNOWN_ENUM_VALUE_NestedEnum_4321\n" + "repeated_nested_enum: UNKNOWN_ENUM_VALUE_NestedEnum_5432\n" diff --git a/js/message.js b/js/message.js index aff8db1408..23e5af0d4b 100644 --- a/js/message.js +++ b/js/message.js @@ -958,19 +958,19 @@ jspb.Message.getMapField = function(msg, fieldNumber, noLazyCreate, // If we already have a map in the map wrappers, return that. if (fieldNumber in msg.wrappers_) { return msg.wrappers_[fieldNumber]; - } else if (noLazyCreate) { - return undefined; - } else { - // Wrap the underlying elements array with a Map. - var arr = jspb.Message.getField(msg, fieldNumber); - if (!arr) { - arr = []; - jspb.Message.setField(msg, fieldNumber, arr); + } + var arr = jspb.Message.getField(msg, fieldNumber); + // Wrap the underlying elements array with a Map. + if (!arr) { + if (noLazyCreate) { + return undefined; } - return msg.wrappers_[fieldNumber] = - new jspb.Map( - /** @type {!Array>} */ (arr), opt_valueCtor); + arr = []; + jspb.Message.setField(msg, fieldNumber, arr); } + return msg.wrappers_[fieldNumber] = + new jspb.Map( + /** @type {!Array>} */ (arr), opt_valueCtor); }; diff --git a/protobuf.pc.in b/protobuf.pc.in index 4e88b514a2..055a9d0563 100644 --- a/protobuf.pc.in +++ b/protobuf.pc.in @@ -8,5 +8,6 @@ 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/python/google/protobuf/internal/descriptor_pool_test.py b/python/google/protobuf/internal/descriptor_pool_test.py index 9414f6f5af..ad1eb653fd 100644 --- a/python/google/protobuf/internal/descriptor_pool_test.py +++ b/python/google/protobuf/internal/descriptor_pool_test.py @@ -615,18 +615,86 @@ class SecondaryDescriptorFromDescriptorDB(DescriptorPoolTestBase, factory_test1_pb2.DESCRIPTOR.serialized_pb) self.factory_test2_fd = descriptor_pb2.FileDescriptorProto.FromString( factory_test2_pb2.DESCRIPTOR.serialized_pb) - db = descriptor_database.DescriptorDatabase() - db.Add(self.factory_test1_fd) - db.Add(self.factory_test2_fd) - db.Add(descriptor_pb2.FileDescriptorProto.FromString( + self.db = descriptor_database.DescriptorDatabase() + self.db.Add(self.factory_test1_fd) + self.db.Add(self.factory_test2_fd) + self.db.Add(descriptor_pb2.FileDescriptorProto.FromString( unittest_import_public_pb2.DESCRIPTOR.serialized_pb)) - db.Add(descriptor_pb2.FileDescriptorProto.FromString( + self.db.Add(descriptor_pb2.FileDescriptorProto.FromString( unittest_import_pb2.DESCRIPTOR.serialized_pb)) - db.Add(descriptor_pb2.FileDescriptorProto.FromString( + self.db.Add(descriptor_pb2.FileDescriptorProto.FromString( unittest_pb2.DESCRIPTOR.serialized_pb)) - db.Add(descriptor_pb2.FileDescriptorProto.FromString( + self.db.Add(descriptor_pb2.FileDescriptorProto.FromString( no_package_pb2.DESCRIPTOR.serialized_pb)) - self.pool = descriptor_pool.DescriptorPool(descriptor_db=db) + self.pool = descriptor_pool.DescriptorPool(descriptor_db=self.db) + + def testErrorCollector(self): + file_proto = descriptor_pb2.FileDescriptorProto() + file_proto.package = 'collector' + file_proto.name = 'error_file' + message_type = file_proto.message_type.add() + message_type.name = 'ErrorMessage' + field = message_type.field.add() + field.number = 1 + field.name = 'nested_message_field' + field.label = descriptor.FieldDescriptor.LABEL_OPTIONAL + field.type = descriptor.FieldDescriptor.TYPE_MESSAGE + field.type_name = 'SubMessage' + oneof = message_type.oneof_decl.add() + oneof.name = 'MyOneof' + enum_type = file_proto.enum_type.add() + enum_type.name = 'MyEnum' + enum_value = enum_type.value.add() + enum_value.name = 'MyEnumValue' + enum_value.number = 0 + self.db.Add(file_proto) + + self.assertRaisesRegexp(KeyError, 'SubMessage', + self.pool.FindMessageTypeByName, + 'collector.ErrorMessage') + self.assertRaisesRegexp(KeyError, 'SubMessage', + self.pool.FindFileByName, 'error_file') + with self.assertRaises(KeyError) as exc: + self.pool.FindFileByName('none_file') + self.assertIn(str(exc.exception), ('\'none_file\'', + '\"Couldn\'t find file none_file\"')) + + # Pure python _ConvertFileProtoToFileDescriptor() method has side effect + # that all the symbols found in the file will load into the pool even the + # file can not build. So when FindMessageTypeByName('ErrorMessage') was + # called the first time, a KeyError will be raised but call the find + # method later will return a descriptor which is not build. + # TODO(jieluo): fix pure python to revert the load if file can not be build + if api_implementation.Type() == 'cpp': + error_msg = ('Invalid proto descriptor for file "error_file":\\n ' + 'collector.ErrorMessage.nested_message_field: "SubMessage" ' + 'is not defined.\\n collector.ErrorMessage.MyOneof: Oneof ' + 'must have at least one field.\\n\'') + with self.assertRaises(KeyError) as exc: + self.pool.FindMessageTypeByName('collector.ErrorMessage') + self.assertEqual(str(exc.exception), '\'Couldn\\\'t build file for ' + 'message collector.ErrorMessage\\n' + error_msg) + + with self.assertRaises(KeyError) as exc: + self.pool.FindFieldByName('collector.ErrorMessage.nested_message_field') + self.assertEqual(str(exc.exception), '\'Couldn\\\'t build file for field' + ' collector.ErrorMessage.nested_message_field\\n' + + error_msg) + + with self.assertRaises(KeyError) as exc: + self.pool.FindEnumTypeByName('collector.MyEnum') + self.assertEqual(str(exc.exception), '\'Couldn\\\'t build file for enum' + ' collector.MyEnum\\n' + error_msg) + + with self.assertRaises(KeyError) as exc: + self.pool.FindFileContainingSymbol('collector.MyEnumValue') + self.assertEqual(str(exc.exception), '\'Couldn\\\'t build file for symbol' + ' collector.MyEnumValue\\n' + error_msg) + + with self.assertRaises(KeyError) as exc: + self.pool.FindOneofByName('collector.ErrorMessage.MyOneof') + self.assertEqual(str(exc.exception), '\'Couldn\\\'t build file for oneof' + ' collector.ErrorMessage.MyOneof\\n' + error_msg) class ProtoFile(object): diff --git a/python/google/protobuf/internal/json_format_test.py b/python/google/protobuf/internal/json_format_test.py index f4271b9dfd..939d4961e7 100644 --- a/python/google/protobuf/internal/json_format_test.py +++ b/python/google/protobuf/internal/json_format_test.py @@ -54,6 +54,7 @@ from google.protobuf import unittest_mset_pb2 from google.protobuf import unittest_pb2 from google.protobuf import descriptor_pool from google.protobuf import json_format +from google.protobuf.util import json_format_pb2 from google.protobuf.util import json_format_proto3_pb2 @@ -247,6 +248,22 @@ class JsonFormatTest(JsonFormatBase): } self.assertEqual(golden_dict, message_dict) + def testExtensionSerializationDictMatchesProto3SpecMore(self): + """See go/proto3-json-spec for spec. + """ + message = json_format_pb2.TestMessageWithExtension() + ext = json_format_pb2.TestExtension.ext + message.Extensions[ext].value = 'stuff' + message_dict = json_format.MessageToDict( + message + ) + expected_dict = { + '[protobuf_unittest.TestExtension.ext]': { + 'value': u'stuff', + }, + } + self.assertEqual(expected_dict, message_dict) + def testExtensionSerializationJsonMatchesProto3Spec(self): """See go/proto3-json-spec for spec. diff --git a/python/google/protobuf/json_format.py b/python/google/protobuf/json_format.py index 80f010371a..6c3b1cb8cb 100644 --- a/python/google/protobuf/json_format.py +++ b/python/google/protobuf/json_format.py @@ -233,12 +233,8 @@ class _Printer(object): js[name] = [self._FieldToJsonObject(field, k) for k in value] elif field.is_extension: - f = field - if (f.containing_type.GetOptions().message_set_wire_format and - f.type == descriptor.FieldDescriptor.TYPE_MESSAGE and - f.label == descriptor.FieldDescriptor.LABEL_OPTIONAL): - f = f.message_type - name = '[%s.%s]' % (f.full_name, name) + full_qualifier = field.full_name[:-len(field.name)] + name = '[%s%s]' % (full_qualifier, name) js[name] = self._FieldToJsonObject(field, value) else: js[name] = self._FieldToJsonObject(field, value) @@ -493,10 +489,16 @@ class _Parser(object): raise ParseError('Message type {0} does not have extensions'.format( message_descriptor.full_name)) identifier = name[1:-1] # strip [] brackets - identifier = '.'.join(identifier.split('.')[:-1]) # pylint: disable=protected-access field = message.Extensions._FindExtensionByName(identifier) # pylint: enable=protected-access + if not field: + # Try looking for extension by the message type name, dropping the + # field name following the final . separator in full_name. + identifier = '.'.join(identifier.split('.')[:-1]) + # pylint: disable=protected-access + field = message.Extensions._FindExtensionByName(identifier) + # pylint: enable=protected-access if not field: if self.ignore_unknown_fields: continue diff --git a/python/google/protobuf/pyext/descriptor_pool.cc b/python/google/protobuf/pyext/descriptor_pool.cc index 50b290db0a..767659204f 100644 --- a/python/google/protobuf/pyext/descriptor_pool.cc +++ b/python/google/protobuf/pyext/descriptor_pool.cc @@ -67,6 +67,38 @@ static std::unordered_map* namespace cdescriptor_pool { +// Collects errors that occur during proto file building to allow them to be +// propagated in the python exception instead of only living in ERROR logs. +class BuildFileErrorCollector : public DescriptorPool::ErrorCollector { + public: + BuildFileErrorCollector() : error_message(""), had_errors_(false) {} + + void AddError(const string& filename, const string& element_name, + const Message* descriptor, ErrorLocation location, + const string& message) override { + // Replicates the logging behavior that happens in the C++ implementation + // when an error collector is not passed in. + if (!had_errors_) { + error_message += + ("Invalid proto descriptor for file \"" + filename + "\":\n"); + had_errors_ = true; + } + // As this only happens on failure and will result in the program not + // running at all, no effort is made to optimize this string manipulation. + error_message += (" " + element_name + ": " + message + "\n"); + } + + void Clear() { + had_errors_ = false; + error_message = ""; + } + + string error_message; + + private: + bool had_errors_; +}; + // Create a Python DescriptorPool object, but does not fill the "pool" // attribute. static PyDescriptorPool* _CreateDescriptorPool() { @@ -76,6 +108,7 @@ static PyDescriptorPool* _CreateDescriptorPool() { return NULL; } + cpool->error_collector = nullptr; cpool->underlay = NULL; cpool->database = NULL; @@ -124,7 +157,8 @@ static PyDescriptorPool* PyDescriptorPool_NewWithDatabase( return NULL; } if (database != NULL) { - cpool->pool = new DescriptorPool(database); + cpool->error_collector = new BuildFileErrorCollector(); + cpool->pool = new DescriptorPool(database, cpool->error_collector); cpool->database = database; } else { cpool->pool = new DescriptorPool(); @@ -167,6 +201,7 @@ static void Dealloc(PyObject* pself) { delete self->descriptor_options; delete self->database; delete self->pool; + delete self->error_collector; Py_TYPE(self)->tp_free(pself); } @@ -182,6 +217,20 @@ static int GcClear(PyObject* pself) { return 0; } +PyObject* SetErrorFromCollector(DescriptorPool::ErrorCollector* self, + char* name, char* error_type) { + BuildFileErrorCollector* error_collector = + reinterpret_cast(self); + if (error_collector && !error_collector->error_message.empty()) { + PyErr_Format(PyExc_KeyError, "Couldn't build file for %s %.200s\n%s", + error_type, name, error_collector->error_message.c_str()); + error_collector->Clear(); + return NULL; + } + PyErr_Format(PyExc_KeyError, "Couldn't find %s %.200s", error_type, name); + return NULL; +} + static PyObject* FindMessageByName(PyObject* self, PyObject* arg) { Py_ssize_t name_size; char* name; @@ -194,8 +243,9 @@ static PyObject* FindMessageByName(PyObject* self, PyObject* arg) { string(name, name_size)); if (message_descriptor == NULL) { - PyErr_Format(PyExc_KeyError, "Couldn't find message %.200s", name); - return NULL; + return SetErrorFromCollector( + reinterpret_cast(self)->error_collector, name, + "message"); } @@ -212,12 +262,12 @@ static PyObject* FindFileByName(PyObject* self, PyObject* arg) { return NULL; } + PyDescriptorPool* py_pool = reinterpret_cast(self); const FileDescriptor* file_descriptor = - reinterpret_cast(self)->pool->FindFileByName( - string(name, name_size)); + py_pool->pool->FindFileByName(string(name, name_size)); + if (file_descriptor == NULL) { - PyErr_Format(PyExc_KeyError, "Couldn't find file %.200s", name); - return NULL; + return SetErrorFromCollector(py_pool->error_collector, name, "file"); } return PyFileDescriptor_FromDescriptor(file_descriptor); } @@ -232,9 +282,7 @@ PyObject* FindFieldByName(PyDescriptorPool* self, PyObject* arg) { const FieldDescriptor* field_descriptor = self->pool->FindFieldByName(string(name, name_size)); if (field_descriptor == NULL) { - PyErr_Format(PyExc_KeyError, "Couldn't find field %.200s", - name); - return NULL; + return SetErrorFromCollector(self->error_collector, name, "field"); } @@ -255,8 +303,8 @@ PyObject* FindExtensionByName(PyDescriptorPool* self, PyObject* arg) { const FieldDescriptor* field_descriptor = self->pool->FindExtensionByName(string(name, name_size)); if (field_descriptor == NULL) { - PyErr_Format(PyExc_KeyError, "Couldn't find extension field %.200s", name); - return NULL; + return SetErrorFromCollector(self->error_collector, name, + "extension field"); } @@ -277,8 +325,7 @@ PyObject* FindEnumTypeByName(PyDescriptorPool* self, PyObject* arg) { const EnumDescriptor* enum_descriptor = self->pool->FindEnumTypeByName(string(name, name_size)); if (enum_descriptor == NULL) { - PyErr_Format(PyExc_KeyError, "Couldn't find enum %.200s", name); - return NULL; + return SetErrorFromCollector(self->error_collector, name, "enum"); } @@ -299,8 +346,7 @@ PyObject* FindOneofByName(PyDescriptorPool* self, PyObject* arg) { const OneofDescriptor* oneof_descriptor = self->pool->FindOneofByName(string(name, name_size)); if (oneof_descriptor == NULL) { - PyErr_Format(PyExc_KeyError, "Couldn't find oneof %.200s", name); - return NULL; + return SetErrorFromCollector(self->error_collector, name, "oneof"); } @@ -322,8 +368,9 @@ static PyObject* FindServiceByName(PyObject* self, PyObject* arg) { reinterpret_cast(self)->pool->FindServiceByName( string(name, name_size)); if (service_descriptor == NULL) { - PyErr_Format(PyExc_KeyError, "Couldn't find service %.200s", name); - return NULL; + return SetErrorFromCollector( + reinterpret_cast(self)->error_collector, name, + "service"); } @@ -341,8 +388,9 @@ static PyObject* FindMethodByName(PyObject* self, PyObject* arg) { reinterpret_cast(self)->pool->FindMethodByName( string(name, name_size)); if (method_descriptor == NULL) { - PyErr_Format(PyExc_KeyError, "Couldn't find method %.200s", name); - return NULL; + return SetErrorFromCollector( + reinterpret_cast(self)->error_collector, name, + "method"); } @@ -360,8 +408,9 @@ static PyObject* FindFileContainingSymbol(PyObject* self, PyObject* arg) { reinterpret_cast(self)->pool->FindFileContainingSymbol( string(name, name_size)); if (file_descriptor == NULL) { - PyErr_Format(PyExc_KeyError, "Couldn't find symbol %.200s", name); - return NULL; + return SetErrorFromCollector( + reinterpret_cast(self)->error_collector, name, + "symbol"); } @@ -384,7 +433,16 @@ static PyObject* FindExtensionByNumber(PyObject* self, PyObject* args) { reinterpret_cast(self)->pool->FindExtensionByNumber( descriptor, number); if (extension_descriptor == NULL) { - PyErr_Format(PyExc_KeyError, "Couldn't find extension %d", number); + BuildFileErrorCollector* error_collector = + reinterpret_cast( + reinterpret_cast(self)->error_collector); + if (error_collector && !error_collector->error_message.empty()) { + PyErr_Format(PyExc_KeyError, "Couldn't build file for Extension %.d\n%s", + number, error_collector->error_message.c_str()); + error_collector->Clear(); + return NULL; + } + PyErr_Format(PyExc_KeyError, "Couldn't find Extension %d", number); return NULL; } @@ -511,32 +569,6 @@ static PyObject* AddServiceDescriptor(PyObject* self, PyObject* descriptor) { } // The code below loads new Descriptors from a serialized FileDescriptorProto. - -// Collects errors that occur during proto file building to allow them to be -// propagated in the python exception instead of only living in ERROR logs. -class BuildFileErrorCollector : public DescriptorPool::ErrorCollector { - public: - BuildFileErrorCollector() : error_message(""), had_errors(false) {} - - void AddError(const string& filename, const string& element_name, - const Message* descriptor, ErrorLocation location, - const string& message) { - // Replicates the logging behavior that happens in the C++ implementation - // when an error collector is not passed in. - if (!had_errors) { - error_message += - ("Invalid proto descriptor for file \"" + filename + "\":\n"); - had_errors = true; - } - // As this only happens on failure and will result in the program not - // running at all, no effort is made to optimize this string manipulation. - error_message += (" " + element_name + ": " + message + "\n"); - } - - string error_message; - bool had_errors; -}; - static PyObject* AddSerializedFile(PyObject* pself, PyObject* serialized_pb) { PyDescriptorPool* self = reinterpret_cast(pself); char* message_type; diff --git a/python/google/protobuf/pyext/descriptor_pool.h b/python/google/protobuf/pyext/descriptor_pool.h index 541fda0380..2d456f9088 100644 --- a/python/google/protobuf/pyext/descriptor_pool.h +++ b/python/google/protobuf/pyext/descriptor_pool.h @@ -59,6 +59,10 @@ typedef struct PyDescriptorPool { // The C++ pool containing Descriptors. DescriptorPool* pool; + // The error collector to store error info. Can be NULL. This pointer is + // owned. + DescriptorPool::ErrorCollector* error_collector; + // The C++ pool acting as an underlay. Can be NULL. // This pointer is not owned and must stay alive. const DescriptorPool* underlay; diff --git a/python/setup.py b/python/setup.py index ba74443b3a..9aabbf7aaa 100755 --- a/python/setup.py +++ b/python/setup.py @@ -92,6 +92,7 @@ def GenerateUnittestProtos(): generate_proto("../src/google/protobuf/unittest_mset_wire_format.proto", False) generate_proto("../src/google/protobuf/unittest_no_generic_services.proto", False) generate_proto("../src/google/protobuf/unittest_proto3_arena.proto", False) + generate_proto("../src/google/protobuf/util/json_format.proto", False) generate_proto("../src/google/protobuf/util/json_format_proto3.proto", False) generate_proto("google/protobuf/internal/any_test.proto", False) generate_proto("google/protobuf/internal/descriptor_pool_test1.proto", False) diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 879db89725..a7d9fbe826 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -115,11 +115,6 @@ class Any::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Any::kTypeUrlFieldNumber; -const int Any::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Any::Any() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr), _any_metadata_(&type_url_, &value_) { SharedCtor(); @@ -419,10 +414,6 @@ bool Any::IsInitialized() const { return true; } -void Any::Swap(Any* other) { - if (other == this) return; - InternalSwap(other); -} void Any::InternalSwap(Any* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index d9a125d301..e3118e0848 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -126,10 +126,13 @@ class PROTOBUF_EXPORT Any : } static bool ParseAnyTypeUrl(const string& type_url, std::string* full_type_name); - void Swap(Any* other); friend void swap(Any& a, Any& b) { a.Swap(&b); } + inline void Swap(Any* other) { + if (other == this) return; + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -191,9 +194,12 @@ class PROTOBUF_EXPORT Any : // accessors ------------------------------------------------------- + enum : int { + kTypeUrlFieldNumber = 1, + kValueFieldNumber = 2, + }; // string type_url = 1; void clear_type_url(); - static const int kTypeUrlFieldNumber = 1; const std::string& type_url() const; void set_type_url(const std::string& value); void set_type_url(std::string&& value); @@ -205,7 +211,6 @@ class PROTOBUF_EXPORT Any : // bytes value = 2; void clear_value(); - static const int kValueFieldNumber = 2; const std::string& value() const; void set_value(const std::string& value); void set_value(std::string&& value); diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 29060c09b0..26bd56d6af 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -196,16 +196,6 @@ void Api::clear_source_context() { } source_context_ = nullptr; } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Api::kNameFieldNumber; -const int Api::kMethodsFieldNumber; -const int Api::kOptionsFieldNumber; -const int Api::kVersionFieldNumber; -const int Api::kSourceContextFieldNumber; -const int Api::kMixinsFieldNumber; -const int Api::kSyntaxFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Api::Api() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -777,10 +767,6 @@ bool Api::IsInitialized() const { return true; } -void Api::Swap(Api* other) { - if (other == this) return; - InternalSwap(other); -} void Api::InternalSwap(Api* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -811,16 +797,6 @@ class Method::_Internal { void Method::clear_options() { options_.Clear(); } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Method::kNameFieldNumber; -const int Method::kRequestTypeUrlFieldNumber; -const int Method::kRequestStreamingFieldNumber; -const int Method::kResponseTypeUrlFieldNumber; -const int Method::kResponseStreamingFieldNumber; -const int Method::kOptionsFieldNumber; -const int Method::kSyntaxFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Method::Method() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1374,10 +1350,6 @@ bool Method::IsInitialized() const { return true; } -void Method::Swap(Method* other) { - if (other == this) return; - InternalSwap(other); -} void Method::InternalSwap(Method* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -1406,11 +1378,6 @@ class Mixin::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Mixin::kNameFieldNumber; -const int Mixin::kRootFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Mixin::Mixin() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1721,10 +1688,6 @@ bool Mixin::IsInitialized() const { return true; } -void Mixin::Swap(Mixin* other) { - if (other == this) return; - InternalSwap(other); -} void Mixin::InternalSwap(Mixin* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 729c3f9b0f..ae02cd461c 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -120,10 +120,13 @@ class PROTOBUF_EXPORT Api : static constexpr int kIndexInFileMessages = 0; - void Swap(Api* other); friend void swap(Api& a, Api& b) { a.Swap(&b); } + inline void Swap(Api* other) { + if (other == this) return; + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -185,10 +188,18 @@ class PROTOBUF_EXPORT Api : // accessors ------------------------------------------------------- + enum : int { + kMethodsFieldNumber = 2, + kOptionsFieldNumber = 3, + kMixinsFieldNumber = 6, + kNameFieldNumber = 1, + kVersionFieldNumber = 4, + kSourceContextFieldNumber = 5, + kSyntaxFieldNumber = 7, + }; // repeated .google.protobuf.Method methods = 2; int methods_size() const; void clear_methods(); - static const int kMethodsFieldNumber = 2; PROTOBUF_NAMESPACE_ID::Method* mutable_methods(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Method >* mutable_methods(); @@ -200,7 +211,6 @@ class PROTOBUF_EXPORT Api : // repeated .google.protobuf.Option options = 3; int options_size() const; void clear_options(); - static const int kOptionsFieldNumber = 3; PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Option >* mutable_options(); @@ -212,7 +222,6 @@ class PROTOBUF_EXPORT Api : // repeated .google.protobuf.Mixin mixins = 6; int mixins_size() const; void clear_mixins(); - static const int kMixinsFieldNumber = 6; PROTOBUF_NAMESPACE_ID::Mixin* mutable_mixins(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Mixin >* mutable_mixins(); @@ -223,7 +232,6 @@ class PROTOBUF_EXPORT Api : // string name = 1; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -235,7 +243,6 @@ class PROTOBUF_EXPORT Api : // string version = 4; void clear_version(); - static const int kVersionFieldNumber = 4; const std::string& version() const; void set_version(const std::string& value); void set_version(std::string&& value); @@ -248,7 +255,6 @@ class PROTOBUF_EXPORT Api : // .google.protobuf.SourceContext source_context = 5; bool has_source_context() const; void clear_source_context(); - static const int kSourceContextFieldNumber = 5; const PROTOBUF_NAMESPACE_ID::SourceContext& source_context() const; PROTOBUF_NAMESPACE_ID::SourceContext* release_source_context(); PROTOBUF_NAMESPACE_ID::SourceContext* mutable_source_context(); @@ -256,7 +262,6 @@ class PROTOBUF_EXPORT Api : // .google.protobuf.Syntax syntax = 7; void clear_syntax(); - static const int kSyntaxFieldNumber = 7; PROTOBUF_NAMESPACE_ID::Syntax syntax() const; void set_syntax(PROTOBUF_NAMESPACE_ID::Syntax value); @@ -321,10 +326,13 @@ class PROTOBUF_EXPORT Method : static constexpr int kIndexInFileMessages = 1; - void Swap(Method* other); friend void swap(Method& a, Method& b) { a.Swap(&b); } + inline void Swap(Method* other) { + if (other == this) return; + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -386,10 +394,18 @@ class PROTOBUF_EXPORT Method : // accessors ------------------------------------------------------- + enum : int { + kOptionsFieldNumber = 6, + kNameFieldNumber = 1, + kRequestTypeUrlFieldNumber = 2, + kResponseTypeUrlFieldNumber = 4, + kRequestStreamingFieldNumber = 3, + kResponseStreamingFieldNumber = 5, + kSyntaxFieldNumber = 7, + }; // repeated .google.protobuf.Option options = 6; int options_size() const; void clear_options(); - static const int kOptionsFieldNumber = 6; PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Option >* mutable_options(); @@ -400,7 +416,6 @@ class PROTOBUF_EXPORT Method : // string name = 1; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -412,7 +427,6 @@ class PROTOBUF_EXPORT Method : // string request_type_url = 2; void clear_request_type_url(); - static const int kRequestTypeUrlFieldNumber = 2; const std::string& request_type_url() const; void set_request_type_url(const std::string& value); void set_request_type_url(std::string&& value); @@ -424,7 +438,6 @@ class PROTOBUF_EXPORT Method : // string response_type_url = 4; void clear_response_type_url(); - static const int kResponseTypeUrlFieldNumber = 4; const std::string& response_type_url() const; void set_response_type_url(const std::string& value); void set_response_type_url(std::string&& value); @@ -436,19 +449,16 @@ class PROTOBUF_EXPORT Method : // bool request_streaming = 3; void clear_request_streaming(); - static const int kRequestStreamingFieldNumber = 3; bool request_streaming() const; void set_request_streaming(bool value); // bool response_streaming = 5; void clear_response_streaming(); - static const int kResponseStreamingFieldNumber = 5; bool response_streaming() const; void set_response_streaming(bool value); // .google.protobuf.Syntax syntax = 7; void clear_syntax(); - static const int kSyntaxFieldNumber = 7; PROTOBUF_NAMESPACE_ID::Syntax syntax() const; void set_syntax(PROTOBUF_NAMESPACE_ID::Syntax value); @@ -513,10 +523,13 @@ class PROTOBUF_EXPORT Mixin : static constexpr int kIndexInFileMessages = 2; - void Swap(Mixin* other); friend void swap(Mixin& a, Mixin& b) { a.Swap(&b); } + inline void Swap(Mixin* other) { + if (other == this) return; + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -578,9 +591,12 @@ class PROTOBUF_EXPORT Mixin : // accessors ------------------------------------------------------- + enum : int { + kNameFieldNumber = 1, + kRootFieldNumber = 2, + }; // string name = 1; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -592,7 +608,6 @@ class PROTOBUF_EXPORT Mixin : // string root = 2; void clear_root(); - static const int kRootFieldNumber = 2; const std::string& root() const; void set_root(const std::string& value); void set_root(std::string&& value); diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 52f3fb9505..dedc22122e 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -245,7 +245,7 @@ struct ArenaOptions { // well as protobuf container types like RepeatedPtrField and Map. The protocol // is internal to protobuf and is not guaranteed to be stable. Non-proto types // should not rely on this protocol. -class PROTOBUF_EXPORT Arena final { +class PROTOBUF_EXPORT alignas(8) Arena final { public: // Arena constructor taking custom options. See ArenaOptions below for // descriptions of the options available. diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 6ab5aff2f2..6ea25652d5 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -2023,6 +2023,10 @@ TEST_F(CommandLineInterfaceTest, GeneratorPluginNotFound) { // Error written to stdout by child process after exec() fails. ExpectErrorSubstring("no_such_file: program not found or is not executable"); + ExpectErrorSubstring( + "Please specify a program using absolute path or make sure " + "the program is available in your PATH system variable"); + // Error written by parent process when child fails. ExpectErrorSubstring( "--badplug_out: prefix-gen-badplug: Plugin failed with status code 1."); diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 4cec899b83..624bbd37a2 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -1489,9 +1489,9 @@ class ParseLoopGenerator { std::string enum_validator; if (field->type() == FieldDescriptor::TYPE_ENUM && !HasPreservingUnknownEnumSemantics(field)) { - enum_validator = StrCat( - ", ", QualifiedClassName(field->enum_type(), options_), - "_IsValid, mutable_unknown_fields(), ", field->number()); + enum_validator = + StrCat(", ", QualifiedClassName(field->enum_type(), options_), + "_IsValid, &_internal_metadata_, ", field->number()); } format_("ptr = $pi_ns$::Packed$1$Parser(mutable_$2$(), ptr, ctx$3$);\n", DeclaredTypeMethodName(field->type()), FieldName(field), diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 43dc0f57d0..3ef4665d17 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -714,6 +714,18 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) { ordered_fields.push_back(field); } + if (!ordered_fields.empty()) { + format("enum : int {\n"); + for (auto field : ordered_fields) { + Formatter::SaveState save(&format); + + std::map vars; + SetCommonFieldVariables(field, &vars, options_); + format.AddMap(vars); + format(" ${1$$2$$}$ = $number$,\n", field, FieldConstantName(field)); + } + format("};\n"); + } for (auto field : ordered_fields) { PrintFieldComment(format, field); @@ -735,10 +747,7 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) { field); } - format( - "$deprecated_attr$void ${1$clear_$name$$}$();\n" - "$deprecated_attr$static const int ${1$$2$$}$ = $number$;\n", - field, FieldConstantName(field)); + format("$deprecated_attr$void ${1$clear_$name$$}$();\n", field); // Generate type-specific accessor declarations. field_generators_.get(field).GenerateAccessorDeclarations(printer); @@ -1159,10 +1168,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "\n", index_in_file_messages_); - if (SupportsArenas(descriptor_)) { - format("void UnsafeArenaSwap($classname$* other);\n"); - } - if (IsAnyMessage(descriptor_, options_)) { format( "// implements Any -----------------------------------------------\n" @@ -1205,10 +1210,34 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { ShouldMarkNewAsFinal(descriptor_, options_) ? "final" : ""); format( - "void Swap($classname$* other);\n" "friend void swap($classname$& a, $classname$& b) {\n" " a.Swap(&b);\n" - "}\n" + "}\n"); + + if (SupportsArenas(descriptor_)) { + format( + "inline void Swap($classname$* other) {\n" + " if (other == this) return;\n" + " if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n" + " InternalSwap(other);\n" + " } else {\n" + " ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);\n" + " }\n" + "}\n" + "void UnsafeArenaSwap($classname$* other) {\n" + " if (other == this) return;\n" + " $DCHK$(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n" + " InternalSwap(other);\n" + "}\n"); + } else { + format( + "inline void Swap($classname$* other) {\n" + " if (other == this) return;\n" + " InternalSwap(other);\n" + "}\n"); + } + + format( "\n" "// implements Message ----------------------------------------------\n" "\n" @@ -2031,15 +2060,6 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { } } - // Generate field number constants. - format("#if !defined(_MSC_VER) || _MSC_VER >= 1900\n"); - for (auto field : FieldRange(descriptor_)) { - format("const int $classname$::$1$;\n", FieldConstantName(field)); - } - format( - "#endif // !defined(_MSC_VER) || _MSC_VER >= 1900\n" - "\n"); - GenerateStructors(printer); format("\n"); @@ -3003,40 +3023,7 @@ void MessageGenerator::GenerateOneofClear(io::Printer* printer) { void MessageGenerator::GenerateSwap(io::Printer* printer) { Formatter format(printer, variables_); - if (SupportsArenas(descriptor_)) { - // Generate the Swap member function. This is a lightweight wrapper around - // UnsafeArenaSwap() / MergeFrom() with temporaries, depending on the memory - // ownership situation: swapping across arenas or between an arena and a - // heap requires copying. - format( - "void $classname$::Swap($classname$* other) {\n" - " if (other == this) return;\n" - " if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n" - " InternalSwap(other);\n" - " } else {\n" - " $classname$* temp = New(GetArenaNoVirtual());\n" - " temp->MergeFrom(*other);\n" - " other->CopyFrom(*this);\n" - " InternalSwap(temp);\n" - " if (GetArenaNoVirtual() == nullptr) {\n" - " delete temp;\n" - " }\n" - " }\n" - "}\n" - "void $classname$::UnsafeArenaSwap($classname$* other) {\n" - " if (other == this) return;\n" - " $DCHK$(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n" - " InternalSwap(other);\n" - "}\n"); - } else { - format( - "void $classname$::Swap($classname$* other) {\n" - " if (other == this) return;\n" - " InternalSwap(other);\n" - "}\n"); - } - // Generate the UnsafeArenaSwap member function. format("void $classname$::InternalSwap($classname$* other) {\n"); format.Indent(); format("using std::swap;\n"); diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index 556284f2ab..fa7e98ef5c 100644 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -1651,7 +1651,11 @@ bool IsWellKnownTypeFile(const FileDescriptor* file) { } // anonymous namespace void Generator::GenerateHeader(const GeneratorOptions& options, + const FileDescriptor* file, io::Printer* printer) const { + if (file != nullptr) { + printer->Print("// source: $filename$\n", "filename", file->name()); + } printer->Print( "/**\n" " * @fileoverview\n" @@ -3637,7 +3641,7 @@ bool Generator::GenerateFile(const FileDescriptor* file, void Generator::GenerateFile(const GeneratorOptions& options, io::Printer* printer, const FileDescriptor* file) const { - GenerateHeader(options, printer); + GenerateHeader(options, file, printer); // Generate "require" statements. if ((options.import_style == GeneratorOptions::kImportCommonJs || @@ -3748,7 +3752,11 @@ bool Generator::GenerateAll(const std::vector& files, } } - GenerateHeader(options, &printer); + if (files.size() == 1) { + GenerateHeader(options, files[0], &printer); + } else { + GenerateHeader(options, nullptr, &printer); + } std::set provided; FindProvides(options, &printer, files, &provided); @@ -3811,7 +3819,7 @@ bool Generator::GenerateAll(const std::vector& files, output.get(), '$', options.annotate_code ? &annotation_collector : nullptr); - GenerateHeader(options, &printer); + GenerateHeader(options, file, &printer); std::set provided; for (auto one_desc : scc->descriptors) { @@ -3864,7 +3872,7 @@ bool Generator::GenerateAll(const std::vector& files, output.get(), '$', options.annotate_code ? &annotation_collector : nullptr); - GenerateHeader(options, &printer); + GenerateHeader(options, file, &printer); std::set provided; FindProvidesForEnum(options, &printer, enumdesc, &provided); @@ -3896,7 +3904,7 @@ bool Generator::GenerateAll(const std::vector& files, output.get(), '$', options.annotate_code ? &annotation_collector : nullptr); - GenerateHeader(options, &printer); + GenerateHeader(options, file, &printer); std::set provided; std::vector fields; diff --git a/src/google/protobuf/compiler/js/js_generator.h b/src/google/protobuf/compiler/js/js_generator.h index 7895b0b063..49f19f6eb6 100644 --- a/src/google/protobuf/compiler/js/js_generator.h +++ b/src/google/protobuf/compiler/js/js_generator.h @@ -157,7 +157,7 @@ class PROTOC_EXPORT Generator : public CodeGenerator { private: void GenerateHeader(const GeneratorOptions& options, - io::Printer* printer) const; + const FileDescriptor* file, io::Printer* printer) const; // Generate goog.provides() calls. void FindProvides(const GeneratorOptions& options, io::Printer* printer, diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index e027234585..23ac4f2f38 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -225,13 +225,6 @@ class Version::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Version::kMajorFieldNumber; -const int Version::kMinorFieldNumber; -const int Version::kPatchFieldNumber; -const int Version::kSuffixFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Version::Version() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -631,10 +624,6 @@ bool Version::IsInitialized() const { return true; } -void Version::Swap(Version* other) { - if (other == this) return; - InternalSwap(other); -} void Version::InternalSwap(Version* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -676,13 +665,6 @@ CodeGeneratorRequest::_Internal::compiler_version(const CodeGeneratorRequest* ms void CodeGeneratorRequest::clear_proto_file() { proto_file_.Clear(); } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int CodeGeneratorRequest::kFileToGenerateFieldNumber; -const int CodeGeneratorRequest::kParameterFieldNumber; -const int CodeGeneratorRequest::kProtoFileFieldNumber; -const int CodeGeneratorRequest::kCompilerVersionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - CodeGeneratorRequest::CodeGeneratorRequest() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1115,10 +1097,6 @@ bool CodeGeneratorRequest::IsInitialized() const { return true; } -void CodeGeneratorRequest::Swap(CodeGeneratorRequest* other) { - if (other == this) return; - InternalSwap(other); -} void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -1153,12 +1131,6 @@ class CodeGeneratorResponse_File::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int CodeGeneratorResponse_File::kNameFieldNumber; -const int CodeGeneratorResponse_File::kInsertionPointFieldNumber; -const int CodeGeneratorResponse_File::kContentFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - CodeGeneratorResponse_File::CodeGeneratorResponse_File() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1551,10 +1523,6 @@ bool CodeGeneratorResponse_File::IsInitialized() const { return true; } -void CodeGeneratorResponse_File::Swap(CodeGeneratorResponse_File* other) { - if (other == this) return; - InternalSwap(other); -} void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -1584,11 +1552,6 @@ class CodeGeneratorResponse::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int CodeGeneratorResponse::kErrorFieldNumber; -const int CodeGeneratorResponse::kFileFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - CodeGeneratorResponse::CodeGeneratorResponse() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1902,10 +1865,6 @@ bool CodeGeneratorResponse::IsInitialized() const { return true; } -void CodeGeneratorResponse::Swap(CodeGeneratorResponse* other) { - if (other == this) return; - InternalSwap(other); -} void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 9226d43098..46704e5f2b 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -139,10 +139,13 @@ class PROTOC_EXPORT Version : static constexpr int kIndexInFileMessages = 0; - void Swap(Version* other); friend void swap(Version& a, Version& b) { a.Swap(&b); } + inline void Swap(Version* other) { + if (other == this) return; + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -204,10 +207,15 @@ class PROTOC_EXPORT Version : // accessors ------------------------------------------------------- + enum : int { + kSuffixFieldNumber = 4, + kMajorFieldNumber = 1, + kMinorFieldNumber = 2, + kPatchFieldNumber = 3, + }; // optional string suffix = 4; bool has_suffix() const; void clear_suffix(); - static const int kSuffixFieldNumber = 4; const std::string& suffix() const; void set_suffix(const std::string& value); void set_suffix(std::string&& value); @@ -220,21 +228,18 @@ class PROTOC_EXPORT Version : // optional int32 major = 1; bool has_major() const; void clear_major(); - static const int kMajorFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::int32 major() const; void set_major(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 minor = 2; bool has_minor() const; void clear_minor(); - static const int kMinorFieldNumber = 2; ::PROTOBUF_NAMESPACE_ID::int32 minor() const; void set_minor(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 patch = 3; bool has_patch() const; void clear_patch(); - static const int kPatchFieldNumber = 3; ::PROTOBUF_NAMESPACE_ID::int32 patch() const; void set_patch(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -304,10 +309,13 @@ class PROTOC_EXPORT CodeGeneratorRequest : static constexpr int kIndexInFileMessages = 1; - void Swap(CodeGeneratorRequest* other); friend void swap(CodeGeneratorRequest& a, CodeGeneratorRequest& b) { a.Swap(&b); } + inline void Swap(CodeGeneratorRequest* other) { + if (other == this) return; + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -369,10 +377,15 @@ class PROTOC_EXPORT CodeGeneratorRequest : // accessors ------------------------------------------------------- + enum : int { + kFileToGenerateFieldNumber = 1, + kProtoFileFieldNumber = 15, + kParameterFieldNumber = 2, + kCompilerVersionFieldNumber = 3, + }; // repeated string file_to_generate = 1; int file_to_generate_size() const; void clear_file_to_generate(); - static const int kFileToGenerateFieldNumber = 1; const std::string& file_to_generate(int index) const; std::string* mutable_file_to_generate(int index); void set_file_to_generate(int index, const std::string& value); @@ -390,7 +403,6 @@ class PROTOC_EXPORT CodeGeneratorRequest : // repeated .google.protobuf.FileDescriptorProto proto_file = 15; int proto_file_size() const; void clear_proto_file(); - static const int kProtoFileFieldNumber = 15; PROTOBUF_NAMESPACE_ID::FileDescriptorProto* mutable_proto_file(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::FileDescriptorProto >* mutable_proto_file(); @@ -402,7 +414,6 @@ class PROTOC_EXPORT CodeGeneratorRequest : // optional string parameter = 2; bool has_parameter() const; void clear_parameter(); - static const int kParameterFieldNumber = 2; const std::string& parameter() const; void set_parameter(const std::string& value); void set_parameter(std::string&& value); @@ -415,7 +426,6 @@ class PROTOC_EXPORT CodeGeneratorRequest : // optional .google.protobuf.compiler.Version compiler_version = 3; bool has_compiler_version() const; void clear_compiler_version(); - static const int kCompilerVersionFieldNumber = 3; const PROTOBUF_NAMESPACE_ID::compiler::Version& compiler_version() const; PROTOBUF_NAMESPACE_ID::compiler::Version* release_compiler_version(); PROTOBUF_NAMESPACE_ID::compiler::Version* mutable_compiler_version(); @@ -487,10 +497,13 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : static constexpr int kIndexInFileMessages = 2; - void Swap(CodeGeneratorResponse_File* other); friend void swap(CodeGeneratorResponse_File& a, CodeGeneratorResponse_File& b) { a.Swap(&b); } + inline void Swap(CodeGeneratorResponse_File* other) { + if (other == this) return; + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -552,10 +565,14 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : // accessors ------------------------------------------------------- + enum : int { + kNameFieldNumber = 1, + kInsertionPointFieldNumber = 2, + kContentFieldNumber = 15, + }; // optional string name = 1; bool has_name() const; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -568,7 +585,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : // optional string insertion_point = 2; bool has_insertion_point() const; void clear_insertion_point(); - static const int kInsertionPointFieldNumber = 2; const std::string& insertion_point() const; void set_insertion_point(const std::string& value); void set_insertion_point(std::string&& value); @@ -581,7 +597,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : // optional string content = 15; bool has_content() const; void clear_content(); - static const int kContentFieldNumber = 15; const std::string& content() const; void set_content(const std::string& value); void set_content(std::string&& value); @@ -656,10 +671,13 @@ class PROTOC_EXPORT CodeGeneratorResponse : static constexpr int kIndexInFileMessages = 3; - void Swap(CodeGeneratorResponse* other); friend void swap(CodeGeneratorResponse& a, CodeGeneratorResponse& b) { a.Swap(&b); } + inline void Swap(CodeGeneratorResponse* other) { + if (other == this) return; + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -723,10 +741,13 @@ class PROTOC_EXPORT CodeGeneratorResponse : // accessors ------------------------------------------------------- + enum : int { + kFileFieldNumber = 15, + kErrorFieldNumber = 1, + }; // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; int file_size() const; void clear_file(); - static const int kFileFieldNumber = 15; PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* mutable_file(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >* mutable_file(); @@ -738,7 +759,6 @@ class PROTOC_EXPORT CodeGeneratorResponse : // optional string error = 1; bool has_error() const; void clear_error(); - static const int kErrorFieldNumber = 1; const std::string& error() const; void set_error(const std::string& value); void set_error(std::string&& value); diff --git a/src/google/protobuf/compiler/subprocess.cc b/src/google/protobuf/compiler/subprocess.cc index b920b2ddd4..bd6be2b09b 100644 --- a/src/google/protobuf/compiler/subprocess.cc +++ b/src/google/protobuf/compiler/subprocess.cc @@ -338,7 +338,10 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { // stuff that is unsafe here. int ignored; ignored = write(STDERR_FILENO, argv[0], strlen(argv[0])); - const char* message = ": program not found or is not executable\n"; + const char* message = + ": program not found or is not executable\n" + "Please specify a program using absolute path or make sure " + "the program is available in your PATH system variable\n"; ignored = write(STDERR_FILENO, message, strlen(message)); (void)ignored; diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index be3a706219..420320d245 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -1386,10 +1386,6 @@ class FileDescriptorSet::_Internal { using HasBits = decltype(std::declval()._has_bits_); }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int FileDescriptorSet::kFileFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - FileDescriptorSet::FileDescriptorSet() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1651,25 +1647,6 @@ bool FileDescriptorSet::IsInitialized() const { return true; } -void FileDescriptorSet::Swap(FileDescriptorSet* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - FileDescriptorSet* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void FileDescriptorSet::UnsafeArenaSwap(FileDescriptorSet* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -1746,21 +1723,6 @@ void FileDescriptorProto::unsafe_arena_set_allocated_source_code_info( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.source_code_info) } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int FileDescriptorProto::kNameFieldNumber; -const int FileDescriptorProto::kPackageFieldNumber; -const int FileDescriptorProto::kDependencyFieldNumber; -const int FileDescriptorProto::kPublicDependencyFieldNumber; -const int FileDescriptorProto::kWeakDependencyFieldNumber; -const int FileDescriptorProto::kMessageTypeFieldNumber; -const int FileDescriptorProto::kEnumTypeFieldNumber; -const int FileDescriptorProto::kServiceFieldNumber; -const int FileDescriptorProto::kExtensionFieldNumber; -const int FileDescriptorProto::kOptionsFieldNumber; -const int FileDescriptorProto::kSourceCodeInfoFieldNumber; -const int FileDescriptorProto::kSyntaxFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - FileDescriptorProto::FileDescriptorProto() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -2668,25 +2630,6 @@ bool FileDescriptorProto::IsInitialized() const { return true; } -void FileDescriptorProto::Swap(FileDescriptorProto* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - FileDescriptorProto* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void FileDescriptorProto::UnsafeArenaSwap(FileDescriptorProto* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -2751,12 +2694,6 @@ void DescriptorProto_ExtensionRange::unsafe_arena_set_allocated_options( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.ExtensionRange.options) } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int DescriptorProto_ExtensionRange::kStartFieldNumber; -const int DescriptorProto_ExtensionRange::kEndFieldNumber; -const int DescriptorProto_ExtensionRange::kOptionsFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -3121,25 +3058,6 @@ bool DescriptorProto_ExtensionRange::IsInitialized() const { return true; } -void DescriptorProto_ExtensionRange::Swap(DescriptorProto_ExtensionRange* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - DescriptorProto_ExtensionRange* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void DescriptorProto_ExtensionRange::UnsafeArenaSwap(DescriptorProto_ExtensionRange* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -3169,11 +3087,6 @@ class DescriptorProto_ReservedRange::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int DescriptorProto_ReservedRange::kStartFieldNumber; -const int DescriptorProto_ReservedRange::kEndFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - DescriptorProto_ReservedRange::DescriptorProto_ReservedRange() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -3483,25 +3396,6 @@ bool DescriptorProto_ReservedRange::IsInitialized() const { return true; } -void DescriptorProto_ReservedRange::Swap(DescriptorProto_ReservedRange* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - DescriptorProto_ReservedRange* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void DescriptorProto_ReservedRange::UnsafeArenaSwap(DescriptorProto_ReservedRange* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -3550,19 +3444,6 @@ void DescriptorProto::unsafe_arena_set_allocated_options( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.options) } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int DescriptorProto::kNameFieldNumber; -const int DescriptorProto::kFieldFieldNumber; -const int DescriptorProto::kExtensionFieldNumber; -const int DescriptorProto::kNestedTypeFieldNumber; -const int DescriptorProto::kEnumTypeFieldNumber; -const int DescriptorProto::kExtensionRangeFieldNumber; -const int DescriptorProto::kOneofDeclFieldNumber; -const int DescriptorProto::kOptionsFieldNumber; -const int DescriptorProto::kReservedRangeFieldNumber; -const int DescriptorProto::kReservedNameFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - DescriptorProto::DescriptorProto() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -4350,25 +4231,6 @@ bool DescriptorProto::IsInitialized() const { return true; } -void DescriptorProto::Swap(DescriptorProto* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - DescriptorProto* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void DescriptorProto::UnsafeArenaSwap(DescriptorProto* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void DescriptorProto::InternalSwap(DescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -4400,10 +4262,6 @@ class ExtensionRangeOptions::_Internal { using HasBits = decltype(std::declval()._has_bits_); }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int ExtensionRangeOptions::kUninterpretedOptionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - ExtensionRangeOptions::ExtensionRangeOptions() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -4694,25 +4552,6 @@ bool ExtensionRangeOptions::IsInitialized() const { return true; } -void ExtensionRangeOptions::Swap(ExtensionRangeOptions* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - ExtensionRangeOptions* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void ExtensionRangeOptions::UnsafeArenaSwap(ExtensionRangeOptions* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); @@ -4785,19 +4624,6 @@ void FieldDescriptorProto::unsafe_arena_set_allocated_options( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.options) } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int FieldDescriptorProto::kNameFieldNumber; -const int FieldDescriptorProto::kNumberFieldNumber; -const int FieldDescriptorProto::kLabelFieldNumber; -const int FieldDescriptorProto::kTypeFieldNumber; -const int FieldDescriptorProto::kTypeNameFieldNumber; -const int FieldDescriptorProto::kExtendeeFieldNumber; -const int FieldDescriptorProto::kDefaultValueFieldNumber; -const int FieldDescriptorProto::kOneofIndexFieldNumber; -const int FieldDescriptorProto::kJsonNameFieldNumber; -const int FieldDescriptorProto::kOptionsFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - FieldDescriptorProto::FieldDescriptorProto() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -5594,25 +5420,6 @@ bool FieldDescriptorProto::IsInitialized() const { return true; } -void FieldDescriptorProto::Swap(FieldDescriptorProto* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - FieldDescriptorProto* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void FieldDescriptorProto::UnsafeArenaSwap(FieldDescriptorProto* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -5674,11 +5481,6 @@ void OneofDescriptorProto::unsafe_arena_set_allocated_options( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.OneofDescriptorProto.options) } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int OneofDescriptorProto::kNameFieldNumber; -const int OneofDescriptorProto::kOptionsFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - OneofDescriptorProto::OneofDescriptorProto() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -6015,25 +5817,6 @@ bool OneofDescriptorProto::IsInitialized() const { return true; } -void OneofDescriptorProto::Swap(OneofDescriptorProto* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - OneofDescriptorProto* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void OneofDescriptorProto::UnsafeArenaSwap(OneofDescriptorProto* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -6063,11 +5846,6 @@ class EnumDescriptorProto_EnumReservedRange::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int EnumDescriptorProto_EnumReservedRange::kStartFieldNumber; -const int EnumDescriptorProto_EnumReservedRange::kEndFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -6377,25 +6155,6 @@ bool EnumDescriptorProto_EnumReservedRange::IsInitialized() const { return true; } -void EnumDescriptorProto_EnumReservedRange::Swap(EnumDescriptorProto_EnumReservedRange* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - EnumDescriptorProto_EnumReservedRange* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void EnumDescriptorProto_EnumReservedRange::UnsafeArenaSwap(EnumDescriptorProto_EnumReservedRange* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_EnumReservedRange* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -6444,14 +6203,6 @@ void EnumDescriptorProto::unsafe_arena_set_allocated_options( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumDescriptorProto.options) } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int EnumDescriptorProto::kNameFieldNumber; -const int EnumDescriptorProto::kValueFieldNumber; -const int EnumDescriptorProto::kOptionsFieldNumber; -const int EnumDescriptorProto::kReservedRangeFieldNumber; -const int EnumDescriptorProto::kReservedNameFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - EnumDescriptorProto::EnumDescriptorProto() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -6959,25 +6710,6 @@ bool EnumDescriptorProto::IsInitialized() const { return true; } -void EnumDescriptorProto::Swap(EnumDescriptorProto* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - EnumDescriptorProto* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void EnumDescriptorProto::UnsafeArenaSwap(EnumDescriptorProto* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -7033,12 +6765,6 @@ void EnumValueDescriptorProto::unsafe_arena_set_allocated_options( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValueDescriptorProto.options) } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int EnumValueDescriptorProto::kNameFieldNumber; -const int EnumValueDescriptorProto::kNumberFieldNumber; -const int EnumValueDescriptorProto::kOptionsFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - EnumValueDescriptorProto::EnumValueDescriptorProto() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -7421,25 +7147,6 @@ bool EnumValueDescriptorProto::IsInitialized() const { return true; } -void EnumValueDescriptorProto::Swap(EnumValueDescriptorProto* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - EnumValueDescriptorProto* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void EnumValueDescriptorProto::UnsafeArenaSwap(EnumValueDescriptorProto* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -7490,12 +7197,6 @@ void ServiceDescriptorProto::unsafe_arena_set_allocated_options( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.ServiceDescriptorProto.options) } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int ServiceDescriptorProto::kNameFieldNumber; -const int ServiceDescriptorProto::kMethodFieldNumber; -const int ServiceDescriptorProto::kOptionsFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - ServiceDescriptorProto::ServiceDescriptorProto() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -7888,25 +7589,6 @@ bool ServiceDescriptorProto::IsInitialized() const { return true; } -void ServiceDescriptorProto::Swap(ServiceDescriptorProto* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - ServiceDescriptorProto* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void ServiceDescriptorProto::UnsafeArenaSwap(ServiceDescriptorProto* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -7969,15 +7651,6 @@ void MethodDescriptorProto::unsafe_arena_set_allocated_options( } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.options) } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int MethodDescriptorProto::kNameFieldNumber; -const int MethodDescriptorProto::kInputTypeFieldNumber; -const int MethodDescriptorProto::kOutputTypeFieldNumber; -const int MethodDescriptorProto::kOptionsFieldNumber; -const int MethodDescriptorProto::kClientStreamingFieldNumber; -const int MethodDescriptorProto::kServerStreamingFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - MethodDescriptorProto::MethodDescriptorProto() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -8527,25 +8200,6 @@ bool MethodDescriptorProto::IsInitialized() const { return true; } -void MethodDescriptorProto::Swap(MethodDescriptorProto* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - MethodDescriptorProto* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void MethodDescriptorProto::UnsafeArenaSwap(MethodDescriptorProto* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -8635,30 +8289,6 @@ class FileOptions::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int FileOptions::kJavaPackageFieldNumber; -const int FileOptions::kJavaOuterClassnameFieldNumber; -const int FileOptions::kJavaMultipleFilesFieldNumber; -const int FileOptions::kJavaGenerateEqualsAndHashFieldNumber; -const int FileOptions::kJavaStringCheckUtf8FieldNumber; -const int FileOptions::kOptimizeForFieldNumber; -const int FileOptions::kGoPackageFieldNumber; -const int FileOptions::kCcGenericServicesFieldNumber; -const int FileOptions::kJavaGenericServicesFieldNumber; -const int FileOptions::kPyGenericServicesFieldNumber; -const int FileOptions::kPhpGenericServicesFieldNumber; -const int FileOptions::kDeprecatedFieldNumber; -const int FileOptions::kCcEnableArenasFieldNumber; -const int FileOptions::kObjcClassPrefixFieldNumber; -const int FileOptions::kCsharpNamespaceFieldNumber; -const int FileOptions::kSwiftPrefixFieldNumber; -const int FileOptions::kPhpClassPrefixFieldNumber; -const int FileOptions::kPhpNamespaceFieldNumber; -const int FileOptions::kPhpMetadataNamespaceFieldNumber; -const int FileOptions::kRubyPackageFieldNumber; -const int FileOptions::kUninterpretedOptionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - FileOptions::FileOptions() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -10025,25 +9655,6 @@ bool FileOptions::IsInitialized() const { return true; } -void FileOptions::Swap(FileOptions* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - FileOptions* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void FileOptions::UnsafeArenaSwap(FileOptions* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void FileOptions::InternalSwap(FileOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); @@ -10108,14 +9719,6 @@ class MessageOptions::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int MessageOptions::kMessageSetWireFormatFieldNumber; -const int MessageOptions::kNoStandardDescriptorAccessorFieldNumber; -const int MessageOptions::kDeprecatedFieldNumber; -const int MessageOptions::kMapEntryFieldNumber; -const int MessageOptions::kUninterpretedOptionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - MessageOptions::MessageOptions() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -10582,25 +10185,6 @@ bool MessageOptions::IsInitialized() const { return true; } -void MessageOptions::Swap(MessageOptions* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - MessageOptions* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void MessageOptions::UnsafeArenaSwap(MessageOptions* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void MessageOptions::InternalSwap(MessageOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); @@ -10645,16 +10229,6 @@ class FieldOptions::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int FieldOptions::kCtypeFieldNumber; -const int FieldOptions::kPackedFieldNumber; -const int FieldOptions::kJstypeFieldNumber; -const int FieldOptions::kLazyFieldNumber; -const int FieldOptions::kDeprecatedFieldNumber; -const int FieldOptions::kWeakFieldNumber; -const int FieldOptions::kUninterpretedOptionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - FieldOptions::FieldOptions() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -11228,25 +10802,6 @@ bool FieldOptions::IsInitialized() const { return true; } -void FieldOptions::Swap(FieldOptions* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - FieldOptions* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void FieldOptions::UnsafeArenaSwap(FieldOptions* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void FieldOptions::InternalSwap(FieldOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); @@ -11275,10 +10830,6 @@ class OneofOptions::_Internal { using HasBits = decltype(std::declval()._has_bits_); }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int OneofOptions::kUninterpretedOptionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - OneofOptions::OneofOptions() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -11569,25 +11120,6 @@ bool OneofOptions::IsInitialized() const { return true; } -void OneofOptions::Swap(OneofOptions* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - OneofOptions* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void OneofOptions::UnsafeArenaSwap(OneofOptions* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void OneofOptions::InternalSwap(OneofOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); @@ -11616,12 +11148,6 @@ class EnumOptions::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int EnumOptions::kAllowAliasFieldNumber; -const int EnumOptions::kDeprecatedFieldNumber; -const int EnumOptions::kUninterpretedOptionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - EnumOptions::EnumOptions() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -12010,25 +11536,6 @@ bool EnumOptions::IsInitialized() const { return true; } -void EnumOptions::Swap(EnumOptions* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - EnumOptions* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void EnumOptions::UnsafeArenaSwap(EnumOptions* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void EnumOptions::InternalSwap(EnumOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); @@ -12056,11 +11563,6 @@ class EnumValueOptions::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int EnumValueOptions::kDeprecatedFieldNumber; -const int EnumValueOptions::kUninterpretedOptionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - EnumValueOptions::EnumValueOptions() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -12398,25 +11900,6 @@ bool EnumValueOptions::IsInitialized() const { return true; } -void EnumValueOptions::Swap(EnumValueOptions* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - EnumValueOptions* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void EnumValueOptions::UnsafeArenaSwap(EnumValueOptions* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void EnumValueOptions::InternalSwap(EnumValueOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); @@ -12443,11 +11926,6 @@ class ServiceOptions::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int ServiceOptions::kDeprecatedFieldNumber; -const int ServiceOptions::kUninterpretedOptionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - ServiceOptions::ServiceOptions() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -12785,25 +12263,6 @@ bool ServiceOptions::IsInitialized() const { return true; } -void ServiceOptions::Swap(ServiceOptions* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - ServiceOptions* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void ServiceOptions::UnsafeArenaSwap(ServiceOptions* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void ServiceOptions::InternalSwap(ServiceOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); @@ -12833,12 +12292,6 @@ class MethodOptions::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int MethodOptions::kDeprecatedFieldNumber; -const int MethodOptions::kIdempotencyLevelFieldNumber; -const int MethodOptions::kUninterpretedOptionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - MethodOptions::MethodOptions() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -13243,25 +12696,6 @@ bool MethodOptions::IsInitialized() const { return true; } -void MethodOptions::Swap(MethodOptions* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - MethodOptions* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void MethodOptions::UnsafeArenaSwap(MethodOptions* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void MethodOptions::InternalSwap(MethodOptions* other) { using std::swap; _extensions_.Swap(&other->_extensions_); @@ -13292,11 +12726,6 @@ class UninterpretedOption_NamePart::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int UninterpretedOption_NamePart::kNamePartFieldNumber; -const int UninterpretedOption_NamePart::kIsExtensionFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - UninterpretedOption_NamePart::UninterpretedOption_NamePart() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -13635,25 +13064,6 @@ bool UninterpretedOption_NamePart::IsInitialized() const { return true; } -void UninterpretedOption_NamePart::Swap(UninterpretedOption_NamePart* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - UninterpretedOption_NamePart* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void UninterpretedOption_NamePart::UnsafeArenaSwap(UninterpretedOption_NamePart* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -13695,16 +13105,6 @@ class UninterpretedOption::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int UninterpretedOption::kNameFieldNumber; -const int UninterpretedOption::kIdentifierValueFieldNumber; -const int UninterpretedOption::kPositiveIntValueFieldNumber; -const int UninterpretedOption::kNegativeIntValueFieldNumber; -const int UninterpretedOption::kDoubleValueFieldNumber; -const int UninterpretedOption::kStringValueFieldNumber; -const int UninterpretedOption::kAggregateValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - UninterpretedOption::UninterpretedOption() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -14289,25 +13689,6 @@ bool UninterpretedOption::IsInitialized() const { return true; } -void UninterpretedOption::Swap(UninterpretedOption* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - UninterpretedOption* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void UninterpretedOption::UnsafeArenaSwap(UninterpretedOption* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void UninterpretedOption::InternalSwap(UninterpretedOption* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -14344,14 +13725,6 @@ class SourceCodeInfo_Location::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int SourceCodeInfo_Location::kPathFieldNumber; -const int SourceCodeInfo_Location::kSpanFieldNumber; -const int SourceCodeInfo_Location::kLeadingCommentsFieldNumber; -const int SourceCodeInfo_Location::kTrailingCommentsFieldNumber; -const int SourceCodeInfo_Location::kLeadingDetachedCommentsFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - SourceCodeInfo_Location::SourceCodeInfo_Location() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -14894,25 +14267,6 @@ bool SourceCodeInfo_Location::IsInitialized() const { return true; } -void SourceCodeInfo_Location::Swap(SourceCodeInfo_Location* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - SourceCodeInfo_Location* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void SourceCodeInfo_Location::UnsafeArenaSwap(SourceCodeInfo_Location* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -14940,10 +14294,6 @@ class SourceCodeInfo::_Internal { using HasBits = decltype(std::declval()._has_bits_); }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int SourceCodeInfo::kLocationFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - SourceCodeInfo::SourceCodeInfo() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -15204,25 +14554,6 @@ bool SourceCodeInfo::IsInitialized() const { return true; } -void SourceCodeInfo::Swap(SourceCodeInfo* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - SourceCodeInfo* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void SourceCodeInfo::UnsafeArenaSwap(SourceCodeInfo* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -15253,13 +14584,6 @@ class GeneratedCodeInfo_Annotation::_Internal { } }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int GeneratedCodeInfo_Annotation::kPathFieldNumber; -const int GeneratedCodeInfo_Annotation::kSourceFileFieldNumber; -const int GeneratedCodeInfo_Annotation::kBeginFieldNumber; -const int GeneratedCodeInfo_Annotation::kEndFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -15702,25 +15026,6 @@ bool GeneratedCodeInfo_Annotation::IsInitialized() const { return true; } -void GeneratedCodeInfo_Annotation::Swap(GeneratedCodeInfo_Annotation* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - GeneratedCodeInfo_Annotation* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void GeneratedCodeInfo_Annotation::UnsafeArenaSwap(GeneratedCodeInfo_Annotation* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -15746,10 +15051,6 @@ class GeneratedCodeInfo::_Internal { using HasBits = decltype(std::declval()._has_bits_); }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int GeneratedCodeInfo::kAnnotationFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - GeneratedCodeInfo::GeneratedCodeInfo() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -16010,25 +15311,6 @@ bool GeneratedCodeInfo::IsInitialized() const { return true; } -void GeneratedCodeInfo::Swap(GeneratedCodeInfo* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - GeneratedCodeInfo* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void GeneratedCodeInfo::UnsafeArenaSwap(GeneratedCodeInfo* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 66f5c1cee4..f8a7159a4e 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -387,11 +387,22 @@ class PROTOBUF_EXPORT FileDescriptorSet : static constexpr int kIndexInFileMessages = 0; - void UnsafeArenaSwap(FileDescriptorSet* other); - void Swap(FileDescriptorSet* other); friend void swap(FileDescriptorSet& a, FileDescriptorSet& b) { a.Swap(&b); } + inline void Swap(FileDescriptorSet* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FileDescriptorSet* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -458,10 +469,12 @@ class PROTOBUF_EXPORT FileDescriptorSet : // accessors ------------------------------------------------------- + enum : int { + kFileFieldNumber = 1, + }; // repeated .google.protobuf.FileDescriptorProto file = 1; int file_size() const; void clear_file(); - static const int kFileFieldNumber = 1; PROTOBUF_NAMESPACE_ID::FileDescriptorProto* mutable_file(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::FileDescriptorProto >* mutable_file(); @@ -542,11 +555,22 @@ class PROTOBUF_EXPORT FileDescriptorProto : static constexpr int kIndexInFileMessages = 1; - void UnsafeArenaSwap(FileDescriptorProto* other); - void Swap(FileDescriptorProto* other); friend void swap(FileDescriptorProto& a, FileDescriptorProto& b) { a.Swap(&b); } + inline void Swap(FileDescriptorProto* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FileDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -613,10 +637,23 @@ class PROTOBUF_EXPORT FileDescriptorProto : // accessors ------------------------------------------------------- + enum : int { + kDependencyFieldNumber = 3, + kMessageTypeFieldNumber = 4, + kEnumTypeFieldNumber = 5, + kServiceFieldNumber = 6, + kExtensionFieldNumber = 7, + kPublicDependencyFieldNumber = 10, + kWeakDependencyFieldNumber = 11, + kNameFieldNumber = 1, + kPackageFieldNumber = 2, + kSyntaxFieldNumber = 12, + kOptionsFieldNumber = 8, + kSourceCodeInfoFieldNumber = 9, + }; // repeated string dependency = 3; int dependency_size() const; void clear_dependency(); - static const int kDependencyFieldNumber = 3; const std::string& dependency(int index) const; std::string* mutable_dependency(int index); void set_dependency(int index, const std::string& value); @@ -634,7 +671,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // repeated .google.protobuf.DescriptorProto message_type = 4; int message_type_size() const; void clear_message_type(); - static const int kMessageTypeFieldNumber = 4; PROTOBUF_NAMESPACE_ID::DescriptorProto* mutable_message_type(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::DescriptorProto >* mutable_message_type(); @@ -646,7 +682,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; int enum_type_size() const; void clear_enum_type(); - static const int kEnumTypeFieldNumber = 5; PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* mutable_enum_type(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >* mutable_enum_type(); @@ -658,7 +693,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // repeated .google.protobuf.ServiceDescriptorProto service = 6; int service_size() const; void clear_service(); - static const int kServiceFieldNumber = 6; PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* mutable_service(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >* mutable_service(); @@ -670,7 +704,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // repeated .google.protobuf.FieldDescriptorProto extension = 7; int extension_size() const; void clear_extension(); - static const int kExtensionFieldNumber = 7; PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* mutable_extension(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >* mutable_extension(); @@ -682,7 +715,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // repeated int32 public_dependency = 10; int public_dependency_size() const; void clear_public_dependency(); - static const int kPublicDependencyFieldNumber = 10; ::PROTOBUF_NAMESPACE_ID::int32 public_dependency(int index) const; void set_public_dependency(int index, ::PROTOBUF_NAMESPACE_ID::int32 value); void add_public_dependency(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -694,7 +726,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // repeated int32 weak_dependency = 11; int weak_dependency_size() const; void clear_weak_dependency(); - static const int kWeakDependencyFieldNumber = 11; ::PROTOBUF_NAMESPACE_ID::int32 weak_dependency(int index) const; void set_weak_dependency(int index, ::PROTOBUF_NAMESPACE_ID::int32 value); void add_weak_dependency(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -706,7 +737,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // optional string name = 1; bool has_name() const; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -728,7 +758,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // optional string package = 2; bool has_package() const; void clear_package(); - static const int kPackageFieldNumber = 2; const std::string& package() const; void set_package(const std::string& value); void set_package(std::string&& value); @@ -750,7 +779,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // optional string syntax = 12; bool has_syntax() const; void clear_syntax(); - static const int kSyntaxFieldNumber = 12; const std::string& syntax() const; void set_syntax(const std::string& value); void set_syntax(std::string&& value); @@ -772,7 +800,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // optional .google.protobuf.FileOptions options = 8; bool has_options() const; void clear_options(); - static const int kOptionsFieldNumber = 8; const PROTOBUF_NAMESPACE_ID::FileOptions& options() const; PROTOBUF_NAMESPACE_ID::FileOptions* release_options(); PROTOBUF_NAMESPACE_ID::FileOptions* mutable_options(); @@ -784,7 +811,6 @@ class PROTOBUF_EXPORT FileDescriptorProto : // optional .google.protobuf.SourceCodeInfo source_code_info = 9; bool has_source_code_info() const; void clear_source_code_info(); - static const int kSourceCodeInfoFieldNumber = 9; const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& source_code_info() const; PROTOBUF_NAMESPACE_ID::SourceCodeInfo* release_source_code_info(); PROTOBUF_NAMESPACE_ID::SourceCodeInfo* mutable_source_code_info(); @@ -876,11 +902,22 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : static constexpr int kIndexInFileMessages = 2; - void UnsafeArenaSwap(DescriptorProto_ExtensionRange* other); - void Swap(DescriptorProto_ExtensionRange* other); friend void swap(DescriptorProto_ExtensionRange& a, DescriptorProto_ExtensionRange& b) { a.Swap(&b); } + inline void Swap(DescriptorProto_ExtensionRange* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(DescriptorProto_ExtensionRange* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -947,10 +984,14 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : // accessors ------------------------------------------------------- + enum : int { + kOptionsFieldNumber = 3, + kStartFieldNumber = 1, + kEndFieldNumber = 2, + }; // optional .google.protobuf.ExtensionRangeOptions options = 3; bool has_options() const; void clear_options(); - static const int kOptionsFieldNumber = 3; const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& options() const; PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* release_options(); PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* mutable_options(); @@ -962,14 +1003,12 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : // optional int32 start = 1; bool has_start() const; void clear_start(); - static const int kStartFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::int32 start() const; void set_start(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 end = 2; bool has_end() const; void clear_end(); - static const int kEndFieldNumber = 2; ::PROTOBUF_NAMESPACE_ID::int32 end() const; void set_end(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -1047,11 +1086,22 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : static constexpr int kIndexInFileMessages = 3; - void UnsafeArenaSwap(DescriptorProto_ReservedRange* other); - void Swap(DescriptorProto_ReservedRange* other); friend void swap(DescriptorProto_ReservedRange& a, DescriptorProto_ReservedRange& b) { a.Swap(&b); } + inline void Swap(DescriptorProto_ReservedRange* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(DescriptorProto_ReservedRange* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -1118,17 +1168,19 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : // accessors ------------------------------------------------------- + enum : int { + kStartFieldNumber = 1, + kEndFieldNumber = 2, + }; // optional int32 start = 1; bool has_start() const; void clear_start(); - static const int kStartFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::int32 start() const; void set_start(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 end = 2; bool has_end() const; void clear_end(); - static const int kEndFieldNumber = 2; ::PROTOBUF_NAMESPACE_ID::int32 end() const; void set_end(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -1205,11 +1257,22 @@ class PROTOBUF_EXPORT DescriptorProto : static constexpr int kIndexInFileMessages = 4; - void UnsafeArenaSwap(DescriptorProto* other); - void Swap(DescriptorProto* other); friend void swap(DescriptorProto& a, DescriptorProto& b) { a.Swap(&b); } + inline void Swap(DescriptorProto* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(DescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -1279,10 +1342,21 @@ class PROTOBUF_EXPORT DescriptorProto : // accessors ------------------------------------------------------- + enum : int { + kFieldFieldNumber = 2, + kNestedTypeFieldNumber = 3, + kEnumTypeFieldNumber = 4, + kExtensionRangeFieldNumber = 5, + kExtensionFieldNumber = 6, + kOneofDeclFieldNumber = 8, + kReservedRangeFieldNumber = 9, + kReservedNameFieldNumber = 10, + kNameFieldNumber = 1, + kOptionsFieldNumber = 7, + }; // repeated .google.protobuf.FieldDescriptorProto field = 2; int field_size() const; void clear_field(); - static const int kFieldFieldNumber = 2; PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* mutable_field(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >* mutable_field(); @@ -1294,7 +1368,6 @@ class PROTOBUF_EXPORT DescriptorProto : // repeated .google.protobuf.DescriptorProto nested_type = 3; int nested_type_size() const; void clear_nested_type(); - static const int kNestedTypeFieldNumber = 3; PROTOBUF_NAMESPACE_ID::DescriptorProto* mutable_nested_type(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::DescriptorProto >* mutable_nested_type(); @@ -1306,7 +1379,6 @@ class PROTOBUF_EXPORT DescriptorProto : // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; int enum_type_size() const; void clear_enum_type(); - static const int kEnumTypeFieldNumber = 4; PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* mutable_enum_type(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >* mutable_enum_type(); @@ -1318,7 +1390,6 @@ class PROTOBUF_EXPORT DescriptorProto : // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; int extension_range_size() const; void clear_extension_range(); - static const int kExtensionRangeFieldNumber = 5; PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* mutable_extension_range(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >* mutable_extension_range(); @@ -1330,7 +1401,6 @@ class PROTOBUF_EXPORT DescriptorProto : // repeated .google.protobuf.FieldDescriptorProto extension = 6; int extension_size() const; void clear_extension(); - static const int kExtensionFieldNumber = 6; PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* mutable_extension(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >* mutable_extension(); @@ -1342,7 +1412,6 @@ class PROTOBUF_EXPORT DescriptorProto : // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; int oneof_decl_size() const; void clear_oneof_decl(); - static const int kOneofDeclFieldNumber = 8; PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* mutable_oneof_decl(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >* mutable_oneof_decl(); @@ -1354,7 +1423,6 @@ class PROTOBUF_EXPORT DescriptorProto : // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; int reserved_range_size() const; void clear_reserved_range(); - static const int kReservedRangeFieldNumber = 9; PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* mutable_reserved_range(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >* mutable_reserved_range(); @@ -1366,7 +1434,6 @@ class PROTOBUF_EXPORT DescriptorProto : // repeated string reserved_name = 10; int reserved_name_size() const; void clear_reserved_name(); - static const int kReservedNameFieldNumber = 10; const std::string& reserved_name(int index) const; std::string* mutable_reserved_name(int index); void set_reserved_name(int index, const std::string& value); @@ -1384,7 +1451,6 @@ class PROTOBUF_EXPORT DescriptorProto : // optional string name = 1; bool has_name() const; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -1406,7 +1472,6 @@ class PROTOBUF_EXPORT DescriptorProto : // optional .google.protobuf.MessageOptions options = 7; bool has_options() const; void clear_options(); - static const int kOptionsFieldNumber = 7; const PROTOBUF_NAMESPACE_ID::MessageOptions& options() const; PROTOBUF_NAMESPACE_ID::MessageOptions* release_options(); PROTOBUF_NAMESPACE_ID::MessageOptions* mutable_options(); @@ -1496,11 +1561,22 @@ class PROTOBUF_EXPORT ExtensionRangeOptions : static constexpr int kIndexInFileMessages = 5; - void UnsafeArenaSwap(ExtensionRangeOptions* other); - void Swap(ExtensionRangeOptions* other); friend void swap(ExtensionRangeOptions& a, ExtensionRangeOptions& b) { a.Swap(&b); } + inline void Swap(ExtensionRangeOptions* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ExtensionRangeOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -1567,10 +1643,12 @@ class PROTOBUF_EXPORT ExtensionRangeOptions : // accessors ------------------------------------------------------- + enum : int { + kUninterpretedOptionFieldNumber = 999, + }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::UninterpretedOption >* mutable_uninterpreted_option(); @@ -1654,11 +1732,22 @@ class PROTOBUF_EXPORT FieldDescriptorProto : static constexpr int kIndexInFileMessages = 6; - void UnsafeArenaSwap(FieldDescriptorProto* other); - void Swap(FieldDescriptorProto* other); friend void swap(FieldDescriptorProto& a, FieldDescriptorProto& b) { a.Swap(&b); } + inline void Swap(FieldDescriptorProto* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FieldDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -1819,10 +1908,21 @@ class PROTOBUF_EXPORT FieldDescriptorProto : // accessors ------------------------------------------------------- + enum : int { + kNameFieldNumber = 1, + kExtendeeFieldNumber = 2, + kTypeNameFieldNumber = 6, + kDefaultValueFieldNumber = 7, + kJsonNameFieldNumber = 10, + kOptionsFieldNumber = 8, + kNumberFieldNumber = 3, + kOneofIndexFieldNumber = 9, + kLabelFieldNumber = 4, + kTypeFieldNumber = 5, + }; // optional string name = 1; bool has_name() const; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -1844,7 +1944,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto : // optional string extendee = 2; bool has_extendee() const; void clear_extendee(); - static const int kExtendeeFieldNumber = 2; const std::string& extendee() const; void set_extendee(const std::string& value); void set_extendee(std::string&& value); @@ -1866,7 +1965,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto : // optional string type_name = 6; bool has_type_name() const; void clear_type_name(); - static const int kTypeNameFieldNumber = 6; const std::string& type_name() const; void set_type_name(const std::string& value); void set_type_name(std::string&& value); @@ -1888,7 +1986,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto : // optional string default_value = 7; bool has_default_value() const; void clear_default_value(); - static const int kDefaultValueFieldNumber = 7; const std::string& default_value() const; void set_default_value(const std::string& value); void set_default_value(std::string&& value); @@ -1910,7 +2007,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto : // optional string json_name = 10; bool has_json_name() const; void clear_json_name(); - static const int kJsonNameFieldNumber = 10; const std::string& json_name() const; void set_json_name(const std::string& value); void set_json_name(std::string&& value); @@ -1932,7 +2028,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto : // optional .google.protobuf.FieldOptions options = 8; bool has_options() const; void clear_options(); - static const int kOptionsFieldNumber = 8; const PROTOBUF_NAMESPACE_ID::FieldOptions& options() const; PROTOBUF_NAMESPACE_ID::FieldOptions* release_options(); PROTOBUF_NAMESPACE_ID::FieldOptions* mutable_options(); @@ -1944,28 +2039,24 @@ class PROTOBUF_EXPORT FieldDescriptorProto : // optional int32 number = 3; bool has_number() const; void clear_number(); - static const int kNumberFieldNumber = 3; ::PROTOBUF_NAMESPACE_ID::int32 number() const; void set_number(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 oneof_index = 9; bool has_oneof_index() const; void clear_oneof_index(); - static const int kOneofIndexFieldNumber = 9; ::PROTOBUF_NAMESPACE_ID::int32 oneof_index() const; void set_oneof_index(::PROTOBUF_NAMESPACE_ID::int32 value); // optional .google.protobuf.FieldDescriptorProto.Label label = 4; bool has_label() const; void clear_label(); - static const int kLabelFieldNumber = 4; PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label label() const; void set_label(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value); // optional .google.protobuf.FieldDescriptorProto.Type type = 5; bool has_type() const; void clear_type(); - static const int kTypeFieldNumber = 5; PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type type() const; void set_type(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value); @@ -2050,11 +2141,22 @@ class PROTOBUF_EXPORT OneofDescriptorProto : static constexpr int kIndexInFileMessages = 7; - void UnsafeArenaSwap(OneofDescriptorProto* other); - void Swap(OneofDescriptorProto* other); friend void swap(OneofDescriptorProto& a, OneofDescriptorProto& b) { a.Swap(&b); } + inline void Swap(OneofDescriptorProto* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OneofDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -2121,10 +2223,13 @@ class PROTOBUF_EXPORT OneofDescriptorProto : // accessors ------------------------------------------------------- + enum : int { + kNameFieldNumber = 1, + kOptionsFieldNumber = 2, + }; // optional string name = 1; bool has_name() const; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -2146,7 +2251,6 @@ class PROTOBUF_EXPORT OneofDescriptorProto : // optional .google.protobuf.OneofOptions options = 2; bool has_options() const; void clear_options(); - static const int kOptionsFieldNumber = 2; const PROTOBUF_NAMESPACE_ID::OneofOptions& options() const; PROTOBUF_NAMESPACE_ID::OneofOptions* release_options(); PROTOBUF_NAMESPACE_ID::OneofOptions* mutable_options(); @@ -2228,11 +2332,22 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : static constexpr int kIndexInFileMessages = 8; - void UnsafeArenaSwap(EnumDescriptorProto_EnumReservedRange* other); - void Swap(EnumDescriptorProto_EnumReservedRange* other); friend void swap(EnumDescriptorProto_EnumReservedRange& a, EnumDescriptorProto_EnumReservedRange& b) { a.Swap(&b); } + inline void Swap(EnumDescriptorProto_EnumReservedRange* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(EnumDescriptorProto_EnumReservedRange* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -2299,17 +2414,19 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : // accessors ------------------------------------------------------- + enum : int { + kStartFieldNumber = 1, + kEndFieldNumber = 2, + }; // optional int32 start = 1; bool has_start() const; void clear_start(); - static const int kStartFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::int32 start() const; void set_start(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 end = 2; bool has_end() const; void clear_end(); - static const int kEndFieldNumber = 2; ::PROTOBUF_NAMESPACE_ID::int32 end() const; void set_end(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -2386,11 +2503,22 @@ class PROTOBUF_EXPORT EnumDescriptorProto : static constexpr int kIndexInFileMessages = 9; - void UnsafeArenaSwap(EnumDescriptorProto* other); - void Swap(EnumDescriptorProto* other); friend void swap(EnumDescriptorProto& a, EnumDescriptorProto& b) { a.Swap(&b); } + inline void Swap(EnumDescriptorProto* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(EnumDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -2459,10 +2587,16 @@ class PROTOBUF_EXPORT EnumDescriptorProto : // accessors ------------------------------------------------------- + enum : int { + kValueFieldNumber = 2, + kReservedRangeFieldNumber = 4, + kReservedNameFieldNumber = 5, + kNameFieldNumber = 1, + kOptionsFieldNumber = 3, + }; // repeated .google.protobuf.EnumValueDescriptorProto value = 2; int value_size() const; void clear_value(); - static const int kValueFieldNumber = 2; PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* mutable_value(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >* mutable_value(); @@ -2474,7 +2608,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto : // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; int reserved_range_size() const; void clear_reserved_range(); - static const int kReservedRangeFieldNumber = 4; PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* mutable_reserved_range(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >* mutable_reserved_range(); @@ -2486,7 +2619,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto : // repeated string reserved_name = 5; int reserved_name_size() const; void clear_reserved_name(); - static const int kReservedNameFieldNumber = 5; const std::string& reserved_name(int index) const; std::string* mutable_reserved_name(int index); void set_reserved_name(int index, const std::string& value); @@ -2504,7 +2636,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto : // optional string name = 1; bool has_name() const; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -2526,7 +2657,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto : // optional .google.protobuf.EnumOptions options = 3; bool has_options() const; void clear_options(); - static const int kOptionsFieldNumber = 3; const PROTOBUF_NAMESPACE_ID::EnumOptions& options() const; PROTOBUF_NAMESPACE_ID::EnumOptions* release_options(); PROTOBUF_NAMESPACE_ID::EnumOptions* mutable_options(); @@ -2611,11 +2741,22 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : static constexpr int kIndexInFileMessages = 10; - void UnsafeArenaSwap(EnumValueDescriptorProto* other); - void Swap(EnumValueDescriptorProto* other); friend void swap(EnumValueDescriptorProto& a, EnumValueDescriptorProto& b) { a.Swap(&b); } + inline void Swap(EnumValueDescriptorProto* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(EnumValueDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -2682,10 +2823,14 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : // accessors ------------------------------------------------------- + enum : int { + kNameFieldNumber = 1, + kOptionsFieldNumber = 3, + kNumberFieldNumber = 2, + }; // optional string name = 1; bool has_name() const; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -2707,7 +2852,6 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : // optional .google.protobuf.EnumValueOptions options = 3; bool has_options() const; void clear_options(); - static const int kOptionsFieldNumber = 3; const PROTOBUF_NAMESPACE_ID::EnumValueOptions& options() const; PROTOBUF_NAMESPACE_ID::EnumValueOptions* release_options(); PROTOBUF_NAMESPACE_ID::EnumValueOptions* mutable_options(); @@ -2719,7 +2863,6 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : // optional int32 number = 2; bool has_number() const; void clear_number(); - static const int kNumberFieldNumber = 2; ::PROTOBUF_NAMESPACE_ID::int32 number() const; void set_number(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -2797,11 +2940,22 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : static constexpr int kIndexInFileMessages = 11; - void UnsafeArenaSwap(ServiceDescriptorProto* other); - void Swap(ServiceDescriptorProto* other); friend void swap(ServiceDescriptorProto& a, ServiceDescriptorProto& b) { a.Swap(&b); } + inline void Swap(ServiceDescriptorProto* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ServiceDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -2868,10 +3022,14 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : // accessors ------------------------------------------------------- + enum : int { + kMethodFieldNumber = 2, + kNameFieldNumber = 1, + kOptionsFieldNumber = 3, + }; // repeated .google.protobuf.MethodDescriptorProto method = 2; int method_size() const; void clear_method(); - static const int kMethodFieldNumber = 2; PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* mutable_method(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >* mutable_method(); @@ -2883,7 +3041,6 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : // optional string name = 1; bool has_name() const; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -2905,7 +3062,6 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : // optional .google.protobuf.ServiceOptions options = 3; bool has_options() const; void clear_options(); - static const int kOptionsFieldNumber = 3; const PROTOBUF_NAMESPACE_ID::ServiceOptions& options() const; PROTOBUF_NAMESPACE_ID::ServiceOptions* release_options(); PROTOBUF_NAMESPACE_ID::ServiceOptions* mutable_options(); @@ -2988,11 +3144,22 @@ class PROTOBUF_EXPORT MethodDescriptorProto : static constexpr int kIndexInFileMessages = 12; - void UnsafeArenaSwap(MethodDescriptorProto* other); - void Swap(MethodDescriptorProto* other); friend void swap(MethodDescriptorProto& a, MethodDescriptorProto& b) { a.Swap(&b); } + inline void Swap(MethodDescriptorProto* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(MethodDescriptorProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -3059,10 +3226,17 @@ class PROTOBUF_EXPORT MethodDescriptorProto : // accessors ------------------------------------------------------- + enum : int { + kNameFieldNumber = 1, + kInputTypeFieldNumber = 2, + kOutputTypeFieldNumber = 3, + kOptionsFieldNumber = 4, + kClientStreamingFieldNumber = 5, + kServerStreamingFieldNumber = 6, + }; // optional string name = 1; bool has_name() const; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -3084,7 +3258,6 @@ class PROTOBUF_EXPORT MethodDescriptorProto : // optional string input_type = 2; bool has_input_type() const; void clear_input_type(); - static const int kInputTypeFieldNumber = 2; const std::string& input_type() const; void set_input_type(const std::string& value); void set_input_type(std::string&& value); @@ -3106,7 +3279,6 @@ class PROTOBUF_EXPORT MethodDescriptorProto : // optional string output_type = 3; bool has_output_type() const; void clear_output_type(); - static const int kOutputTypeFieldNumber = 3; const std::string& output_type() const; void set_output_type(const std::string& value); void set_output_type(std::string&& value); @@ -3128,7 +3300,6 @@ class PROTOBUF_EXPORT MethodDescriptorProto : // optional .google.protobuf.MethodOptions options = 4; bool has_options() const; void clear_options(); - static const int kOptionsFieldNumber = 4; const PROTOBUF_NAMESPACE_ID::MethodOptions& options() const; PROTOBUF_NAMESPACE_ID::MethodOptions* release_options(); PROTOBUF_NAMESPACE_ID::MethodOptions* mutable_options(); @@ -3140,14 +3311,12 @@ class PROTOBUF_EXPORT MethodDescriptorProto : // optional bool client_streaming = 5 [default = false]; bool has_client_streaming() const; void clear_client_streaming(); - static const int kClientStreamingFieldNumber = 5; bool client_streaming() const; void set_client_streaming(bool value); // optional bool server_streaming = 6 [default = false]; bool has_server_streaming() const; void clear_server_streaming(); - static const int kServerStreamingFieldNumber = 6; bool server_streaming() const; void set_server_streaming(bool value); @@ -3228,11 +3397,22 @@ class PROTOBUF_EXPORT FileOptions : static constexpr int kIndexInFileMessages = 13; - void UnsafeArenaSwap(FileOptions* other); - void Swap(FileOptions* other); friend void swap(FileOptions& a, FileOptions& b) { a.Swap(&b); } + inline void Swap(FileOptions* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FileOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -3331,10 +3511,32 @@ class PROTOBUF_EXPORT FileOptions : // accessors ------------------------------------------------------- + enum : int { + kUninterpretedOptionFieldNumber = 999, + kJavaPackageFieldNumber = 1, + kJavaOuterClassnameFieldNumber = 8, + kGoPackageFieldNumber = 11, + kObjcClassPrefixFieldNumber = 36, + kCsharpNamespaceFieldNumber = 37, + kSwiftPrefixFieldNumber = 39, + kPhpClassPrefixFieldNumber = 40, + kPhpNamespaceFieldNumber = 41, + kPhpMetadataNamespaceFieldNumber = 44, + kRubyPackageFieldNumber = 45, + kJavaMultipleFilesFieldNumber = 10, + kJavaGenerateEqualsAndHashFieldNumber = 20, + kJavaStringCheckUtf8FieldNumber = 27, + kCcGenericServicesFieldNumber = 16, + kJavaGenericServicesFieldNumber = 17, + kPyGenericServicesFieldNumber = 18, + kPhpGenericServicesFieldNumber = 42, + kDeprecatedFieldNumber = 23, + kCcEnableArenasFieldNumber = 31, + kOptimizeForFieldNumber = 9, + }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::UninterpretedOption >* mutable_uninterpreted_option(); @@ -3346,7 +3548,6 @@ class PROTOBUF_EXPORT FileOptions : // optional string java_package = 1; bool has_java_package() const; void clear_java_package(); - static const int kJavaPackageFieldNumber = 1; const std::string& java_package() const; void set_java_package(const std::string& value); void set_java_package(std::string&& value); @@ -3368,7 +3569,6 @@ class PROTOBUF_EXPORT FileOptions : // optional string java_outer_classname = 8; bool has_java_outer_classname() const; void clear_java_outer_classname(); - static const int kJavaOuterClassnameFieldNumber = 8; const std::string& java_outer_classname() const; void set_java_outer_classname(const std::string& value); void set_java_outer_classname(std::string&& value); @@ -3390,7 +3590,6 @@ class PROTOBUF_EXPORT FileOptions : // optional string go_package = 11; bool has_go_package() const; void clear_go_package(); - static const int kGoPackageFieldNumber = 11; const std::string& go_package() const; void set_go_package(const std::string& value); void set_go_package(std::string&& value); @@ -3412,7 +3611,6 @@ class PROTOBUF_EXPORT FileOptions : // optional string objc_class_prefix = 36; bool has_objc_class_prefix() const; void clear_objc_class_prefix(); - static const int kObjcClassPrefixFieldNumber = 36; const std::string& objc_class_prefix() const; void set_objc_class_prefix(const std::string& value); void set_objc_class_prefix(std::string&& value); @@ -3434,7 +3632,6 @@ class PROTOBUF_EXPORT FileOptions : // optional string csharp_namespace = 37; bool has_csharp_namespace() const; void clear_csharp_namespace(); - static const int kCsharpNamespaceFieldNumber = 37; const std::string& csharp_namespace() const; void set_csharp_namespace(const std::string& value); void set_csharp_namespace(std::string&& value); @@ -3456,7 +3653,6 @@ class PROTOBUF_EXPORT FileOptions : // optional string swift_prefix = 39; bool has_swift_prefix() const; void clear_swift_prefix(); - static const int kSwiftPrefixFieldNumber = 39; const std::string& swift_prefix() const; void set_swift_prefix(const std::string& value); void set_swift_prefix(std::string&& value); @@ -3478,7 +3674,6 @@ class PROTOBUF_EXPORT FileOptions : // optional string php_class_prefix = 40; bool has_php_class_prefix() const; void clear_php_class_prefix(); - static const int kPhpClassPrefixFieldNumber = 40; const std::string& php_class_prefix() const; void set_php_class_prefix(const std::string& value); void set_php_class_prefix(std::string&& value); @@ -3500,7 +3695,6 @@ class PROTOBUF_EXPORT FileOptions : // optional string php_namespace = 41; bool has_php_namespace() const; void clear_php_namespace(); - static const int kPhpNamespaceFieldNumber = 41; const std::string& php_namespace() const; void set_php_namespace(const std::string& value); void set_php_namespace(std::string&& value); @@ -3522,7 +3716,6 @@ class PROTOBUF_EXPORT FileOptions : // optional string php_metadata_namespace = 44; bool has_php_metadata_namespace() const; void clear_php_metadata_namespace(); - static const int kPhpMetadataNamespaceFieldNumber = 44; const std::string& php_metadata_namespace() const; void set_php_metadata_namespace(const std::string& value); void set_php_metadata_namespace(std::string&& value); @@ -3544,7 +3737,6 @@ class PROTOBUF_EXPORT FileOptions : // optional string ruby_package = 45; bool has_ruby_package() const; void clear_ruby_package(); - static const int kRubyPackageFieldNumber = 45; const std::string& ruby_package() const; void set_ruby_package(const std::string& value); void set_ruby_package(std::string&& value); @@ -3566,70 +3758,60 @@ class PROTOBUF_EXPORT FileOptions : // optional bool java_multiple_files = 10 [default = false]; bool has_java_multiple_files() const; void clear_java_multiple_files(); - static const int kJavaMultipleFilesFieldNumber = 10; bool java_multiple_files() const; void set_java_multiple_files(bool value); // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; PROTOBUF_DEPRECATED bool has_java_generate_equals_and_hash() const; PROTOBUF_DEPRECATED void clear_java_generate_equals_and_hash(); - PROTOBUF_DEPRECATED static const int kJavaGenerateEqualsAndHashFieldNumber = 20; PROTOBUF_DEPRECATED bool java_generate_equals_and_hash() const; PROTOBUF_DEPRECATED void set_java_generate_equals_and_hash(bool value); // optional bool java_string_check_utf8 = 27 [default = false]; bool has_java_string_check_utf8() const; void clear_java_string_check_utf8(); - static const int kJavaStringCheckUtf8FieldNumber = 27; bool java_string_check_utf8() const; void set_java_string_check_utf8(bool value); // optional bool cc_generic_services = 16 [default = false]; bool has_cc_generic_services() const; void clear_cc_generic_services(); - static const int kCcGenericServicesFieldNumber = 16; bool cc_generic_services() const; void set_cc_generic_services(bool value); // optional bool java_generic_services = 17 [default = false]; bool has_java_generic_services() const; void clear_java_generic_services(); - static const int kJavaGenericServicesFieldNumber = 17; bool java_generic_services() const; void set_java_generic_services(bool value); // optional bool py_generic_services = 18 [default = false]; bool has_py_generic_services() const; void clear_py_generic_services(); - static const int kPyGenericServicesFieldNumber = 18; bool py_generic_services() const; void set_py_generic_services(bool value); // optional bool php_generic_services = 42 [default = false]; bool has_php_generic_services() const; void clear_php_generic_services(); - static const int kPhpGenericServicesFieldNumber = 42; bool php_generic_services() const; void set_php_generic_services(bool value); // optional bool deprecated = 23 [default = false]; bool has_deprecated() const; void clear_deprecated(); - static const int kDeprecatedFieldNumber = 23; bool deprecated() const; void set_deprecated(bool value); // optional bool cc_enable_arenas = 31 [default = false]; bool has_cc_enable_arenas() const; void clear_cc_enable_arenas(); - static const int kCcEnableArenasFieldNumber = 31; bool cc_enable_arenas() const; void set_cc_enable_arenas(bool value); // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; bool has_optimize_for() const; void clear_optimize_for(); - static const int kOptimizeForFieldNumber = 9; PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode optimize_for() const; void set_optimize_for(PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value); @@ -3728,11 +3910,22 @@ class PROTOBUF_EXPORT MessageOptions : static constexpr int kIndexInFileMessages = 14; - void UnsafeArenaSwap(MessageOptions* other); - void Swap(MessageOptions* other); friend void swap(MessageOptions& a, MessageOptions& b) { a.Swap(&b); } + inline void Swap(MessageOptions* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(MessageOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -3799,10 +3992,16 @@ class PROTOBUF_EXPORT MessageOptions : // accessors ------------------------------------------------------- + enum : int { + kUninterpretedOptionFieldNumber = 999, + kMessageSetWireFormatFieldNumber = 1, + kNoStandardDescriptorAccessorFieldNumber = 2, + kDeprecatedFieldNumber = 3, + kMapEntryFieldNumber = 7, + }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::UninterpretedOption >* mutable_uninterpreted_option(); @@ -3814,28 +4013,24 @@ class PROTOBUF_EXPORT MessageOptions : // optional bool message_set_wire_format = 1 [default = false]; bool has_message_set_wire_format() const; void clear_message_set_wire_format(); - static const int kMessageSetWireFormatFieldNumber = 1; bool message_set_wire_format() const; void set_message_set_wire_format(bool value); // optional bool no_standard_descriptor_accessor = 2 [default = false]; bool has_no_standard_descriptor_accessor() const; void clear_no_standard_descriptor_accessor(); - static const int kNoStandardDescriptorAccessorFieldNumber = 2; bool no_standard_descriptor_accessor() const; void set_no_standard_descriptor_accessor(bool value); // optional bool deprecated = 3 [default = false]; bool has_deprecated() const; void clear_deprecated(); - static const int kDeprecatedFieldNumber = 3; bool deprecated() const; void set_deprecated(bool value); // optional bool map_entry = 7; bool has_map_entry() const; void clear_map_entry(); - static const int kMapEntryFieldNumber = 7; bool map_entry() const; void set_map_entry(bool value); @@ -3918,11 +4113,22 @@ class PROTOBUF_EXPORT FieldOptions : static constexpr int kIndexInFileMessages = 15; - void UnsafeArenaSwap(FieldOptions* other); - void Swap(FieldOptions* other); friend void swap(FieldOptions& a, FieldOptions& b) { a.Swap(&b); } + inline void Swap(FieldOptions* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FieldOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -4053,10 +4259,18 @@ class PROTOBUF_EXPORT FieldOptions : // accessors ------------------------------------------------------- + enum : int { + kUninterpretedOptionFieldNumber = 999, + kCtypeFieldNumber = 1, + kPackedFieldNumber = 2, + kLazyFieldNumber = 5, + kDeprecatedFieldNumber = 3, + kWeakFieldNumber = 10, + kJstypeFieldNumber = 6, + }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::UninterpretedOption >* mutable_uninterpreted_option(); @@ -4068,42 +4282,36 @@ class PROTOBUF_EXPORT FieldOptions : // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; bool has_ctype() const; void clear_ctype(); - static const int kCtypeFieldNumber = 1; PROTOBUF_NAMESPACE_ID::FieldOptions_CType ctype() const; void set_ctype(PROTOBUF_NAMESPACE_ID::FieldOptions_CType value); // optional bool packed = 2; bool has_packed() const; void clear_packed(); - static const int kPackedFieldNumber = 2; bool packed() const; void set_packed(bool value); // optional bool lazy = 5 [default = false]; bool has_lazy() const; void clear_lazy(); - static const int kLazyFieldNumber = 5; bool lazy() const; void set_lazy(bool value); // optional bool deprecated = 3 [default = false]; bool has_deprecated() const; void clear_deprecated(); - static const int kDeprecatedFieldNumber = 3; bool deprecated() const; void set_deprecated(bool value); // optional bool weak = 10 [default = false]; bool has_weak() const; void clear_weak(); - static const int kWeakFieldNumber = 10; bool weak() const; void set_weak(bool value); // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; bool has_jstype() const; void clear_jstype(); - static const int kJstypeFieldNumber = 6; PROTOBUF_NAMESPACE_ID::FieldOptions_JSType jstype() const; void set_jstype(PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value); @@ -4188,11 +4396,22 @@ class PROTOBUF_EXPORT OneofOptions : static constexpr int kIndexInFileMessages = 16; - void UnsafeArenaSwap(OneofOptions* other); - void Swap(OneofOptions* other); friend void swap(OneofOptions& a, OneofOptions& b) { a.Swap(&b); } + inline void Swap(OneofOptions* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OneofOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -4259,10 +4478,12 @@ class PROTOBUF_EXPORT OneofOptions : // accessors ------------------------------------------------------- + enum : int { + kUninterpretedOptionFieldNumber = 999, + }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::UninterpretedOption >* mutable_uninterpreted_option(); @@ -4346,11 +4567,22 @@ class PROTOBUF_EXPORT EnumOptions : static constexpr int kIndexInFileMessages = 17; - void UnsafeArenaSwap(EnumOptions* other); - void Swap(EnumOptions* other); friend void swap(EnumOptions& a, EnumOptions& b) { a.Swap(&b); } + inline void Swap(EnumOptions* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(EnumOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -4417,10 +4649,14 @@ class PROTOBUF_EXPORT EnumOptions : // accessors ------------------------------------------------------- + enum : int { + kUninterpretedOptionFieldNumber = 999, + kAllowAliasFieldNumber = 2, + kDeprecatedFieldNumber = 3, + }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::UninterpretedOption >* mutable_uninterpreted_option(); @@ -4432,14 +4668,12 @@ class PROTOBUF_EXPORT EnumOptions : // optional bool allow_alias = 2; bool has_allow_alias() const; void clear_allow_alias(); - static const int kAllowAliasFieldNumber = 2; bool allow_alias() const; void set_allow_alias(bool value); // optional bool deprecated = 3 [default = false]; bool has_deprecated() const; void clear_deprecated(); - static const int kDeprecatedFieldNumber = 3; bool deprecated() const; void set_deprecated(bool value); @@ -4520,11 +4754,22 @@ class PROTOBUF_EXPORT EnumValueOptions : static constexpr int kIndexInFileMessages = 18; - void UnsafeArenaSwap(EnumValueOptions* other); - void Swap(EnumValueOptions* other); friend void swap(EnumValueOptions& a, EnumValueOptions& b) { a.Swap(&b); } + inline void Swap(EnumValueOptions* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(EnumValueOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -4591,10 +4836,13 @@ class PROTOBUF_EXPORT EnumValueOptions : // accessors ------------------------------------------------------- + enum : int { + kUninterpretedOptionFieldNumber = 999, + kDeprecatedFieldNumber = 1, + }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::UninterpretedOption >* mutable_uninterpreted_option(); @@ -4606,7 +4854,6 @@ class PROTOBUF_EXPORT EnumValueOptions : // optional bool deprecated = 1 [default = false]; bool has_deprecated() const; void clear_deprecated(); - static const int kDeprecatedFieldNumber = 1; bool deprecated() const; void set_deprecated(bool value); @@ -4686,11 +4933,22 @@ class PROTOBUF_EXPORT ServiceOptions : static constexpr int kIndexInFileMessages = 19; - void UnsafeArenaSwap(ServiceOptions* other); - void Swap(ServiceOptions* other); friend void swap(ServiceOptions& a, ServiceOptions& b) { a.Swap(&b); } + inline void Swap(ServiceOptions* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ServiceOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -4757,10 +5015,13 @@ class PROTOBUF_EXPORT ServiceOptions : // accessors ------------------------------------------------------- + enum : int { + kUninterpretedOptionFieldNumber = 999, + kDeprecatedFieldNumber = 33, + }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::UninterpretedOption >* mutable_uninterpreted_option(); @@ -4772,7 +5033,6 @@ class PROTOBUF_EXPORT ServiceOptions : // optional bool deprecated = 33 [default = false]; bool has_deprecated() const; void clear_deprecated(); - static const int kDeprecatedFieldNumber = 33; bool deprecated() const; void set_deprecated(bool value); @@ -4852,11 +5112,22 @@ class PROTOBUF_EXPORT MethodOptions : static constexpr int kIndexInFileMessages = 20; - void UnsafeArenaSwap(MethodOptions* other); - void Swap(MethodOptions* other); friend void swap(MethodOptions& a, MethodOptions& b) { a.Swap(&b); } + inline void Swap(MethodOptions* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(MethodOptions* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -4955,10 +5226,14 @@ class PROTOBUF_EXPORT MethodOptions : // accessors ------------------------------------------------------- + enum : int { + kUninterpretedOptionFieldNumber = 999, + kDeprecatedFieldNumber = 33, + kIdempotencyLevelFieldNumber = 34, + }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::UninterpretedOption >* mutable_uninterpreted_option(); @@ -4970,14 +5245,12 @@ class PROTOBUF_EXPORT MethodOptions : // optional bool deprecated = 33 [default = false]; bool has_deprecated() const; void clear_deprecated(); - static const int kDeprecatedFieldNumber = 33; bool deprecated() const; void set_deprecated(bool value); // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; bool has_idempotency_level() const; void clear_idempotency_level(); - static const int kIdempotencyLevelFieldNumber = 34; PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel idempotency_level() const; void set_idempotency_level(PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel value); @@ -5058,11 +5331,22 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : static constexpr int kIndexInFileMessages = 21; - void UnsafeArenaSwap(UninterpretedOption_NamePart* other); - void Swap(UninterpretedOption_NamePart* other); friend void swap(UninterpretedOption_NamePart& a, UninterpretedOption_NamePart& b) { a.Swap(&b); } + inline void Swap(UninterpretedOption_NamePart* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(UninterpretedOption_NamePart* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -5129,10 +5413,13 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : // accessors ------------------------------------------------------- + enum : int { + kNamePartFieldNumber = 1, + kIsExtensionFieldNumber = 2, + }; // required string name_part = 1; bool has_name_part() const; void clear_name_part(); - static const int kNamePartFieldNumber = 1; const std::string& name_part() const; void set_name_part(const std::string& value); void set_name_part(std::string&& value); @@ -5154,7 +5441,6 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : // required bool is_extension = 2; bool has_is_extension() const; void clear_is_extension(); - static const int kIsExtensionFieldNumber = 2; bool is_extension() const; void set_is_extension(bool value); @@ -5234,11 +5520,22 @@ class PROTOBUF_EXPORT UninterpretedOption : static constexpr int kIndexInFileMessages = 22; - void UnsafeArenaSwap(UninterpretedOption* other); - void Swap(UninterpretedOption* other); friend void swap(UninterpretedOption& a, UninterpretedOption& b) { a.Swap(&b); } + inline void Swap(UninterpretedOption* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(UninterpretedOption* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -5307,10 +5604,18 @@ class PROTOBUF_EXPORT UninterpretedOption : // accessors ------------------------------------------------------- + enum : int { + kNameFieldNumber = 2, + kIdentifierValueFieldNumber = 3, + kStringValueFieldNumber = 7, + kAggregateValueFieldNumber = 8, + kPositiveIntValueFieldNumber = 4, + kNegativeIntValueFieldNumber = 5, + kDoubleValueFieldNumber = 6, + }; // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; int name_size() const; void clear_name(); - static const int kNameFieldNumber = 2; PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* mutable_name(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >* mutable_name(); @@ -5322,7 +5627,6 @@ class PROTOBUF_EXPORT UninterpretedOption : // optional string identifier_value = 3; bool has_identifier_value() const; void clear_identifier_value(); - static const int kIdentifierValueFieldNumber = 3; const std::string& identifier_value() const; void set_identifier_value(const std::string& value); void set_identifier_value(std::string&& value); @@ -5344,7 +5648,6 @@ class PROTOBUF_EXPORT UninterpretedOption : // optional bytes string_value = 7; bool has_string_value() const; void clear_string_value(); - static const int kStringValueFieldNumber = 7; const std::string& string_value() const; void set_string_value(const std::string& value); void set_string_value(std::string&& value); @@ -5366,7 +5669,6 @@ class PROTOBUF_EXPORT UninterpretedOption : // optional string aggregate_value = 8; bool has_aggregate_value() const; void clear_aggregate_value(); - static const int kAggregateValueFieldNumber = 8; const std::string& aggregate_value() const; void set_aggregate_value(const std::string& value); void set_aggregate_value(std::string&& value); @@ -5388,21 +5690,18 @@ class PROTOBUF_EXPORT UninterpretedOption : // optional uint64 positive_int_value = 4; bool has_positive_int_value() const; void clear_positive_int_value(); - static const int kPositiveIntValueFieldNumber = 4; ::PROTOBUF_NAMESPACE_ID::uint64 positive_int_value() const; void set_positive_int_value(::PROTOBUF_NAMESPACE_ID::uint64 value); // optional int64 negative_int_value = 5; bool has_negative_int_value() const; void clear_negative_int_value(); - static const int kNegativeIntValueFieldNumber = 5; ::PROTOBUF_NAMESPACE_ID::int64 negative_int_value() const; void set_negative_int_value(::PROTOBUF_NAMESPACE_ID::int64 value); // optional double double_value = 6; bool has_double_value() const; void clear_double_value(); - static const int kDoubleValueFieldNumber = 6; double double_value() const; void set_double_value(double value); @@ -5484,11 +5783,22 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : static constexpr int kIndexInFileMessages = 23; - void UnsafeArenaSwap(SourceCodeInfo_Location* other); - void Swap(SourceCodeInfo_Location* other); friend void swap(SourceCodeInfo_Location& a, SourceCodeInfo_Location& b) { a.Swap(&b); } + inline void Swap(SourceCodeInfo_Location* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(SourceCodeInfo_Location* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -5555,10 +5865,16 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : // accessors ------------------------------------------------------- + enum : int { + kPathFieldNumber = 1, + kSpanFieldNumber = 2, + kLeadingDetachedCommentsFieldNumber = 6, + kLeadingCommentsFieldNumber = 3, + kTrailingCommentsFieldNumber = 4, + }; // repeated int32 path = 1 [packed = true]; int path_size() const; void clear_path(); - static const int kPathFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::int32 path(int index) const; void set_path(int index, ::PROTOBUF_NAMESPACE_ID::int32 value); void add_path(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -5570,7 +5886,6 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : // repeated int32 span = 2 [packed = true]; int span_size() const; void clear_span(); - static const int kSpanFieldNumber = 2; ::PROTOBUF_NAMESPACE_ID::int32 span(int index) const; void set_span(int index, ::PROTOBUF_NAMESPACE_ID::int32 value); void add_span(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -5582,7 +5897,6 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : // repeated string leading_detached_comments = 6; int leading_detached_comments_size() const; void clear_leading_detached_comments(); - static const int kLeadingDetachedCommentsFieldNumber = 6; const std::string& leading_detached_comments(int index) const; std::string* mutable_leading_detached_comments(int index); void set_leading_detached_comments(int index, const std::string& value); @@ -5600,7 +5914,6 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : // optional string leading_comments = 3; bool has_leading_comments() const; void clear_leading_comments(); - static const int kLeadingCommentsFieldNumber = 3; const std::string& leading_comments() const; void set_leading_comments(const std::string& value); void set_leading_comments(std::string&& value); @@ -5622,7 +5935,6 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : // optional string trailing_comments = 4; bool has_trailing_comments() const; void clear_trailing_comments(); - static const int kTrailingCommentsFieldNumber = 4; const std::string& trailing_comments() const; void set_trailing_comments(const std::string& value); void set_trailing_comments(std::string&& value); @@ -5719,11 +6031,22 @@ class PROTOBUF_EXPORT SourceCodeInfo : static constexpr int kIndexInFileMessages = 24; - void UnsafeArenaSwap(SourceCodeInfo* other); - void Swap(SourceCodeInfo* other); friend void swap(SourceCodeInfo& a, SourceCodeInfo& b) { a.Swap(&b); } + inline void Swap(SourceCodeInfo* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(SourceCodeInfo* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -5792,10 +6115,12 @@ class PROTOBUF_EXPORT SourceCodeInfo : // accessors ------------------------------------------------------- + enum : int { + kLocationFieldNumber = 1, + }; // repeated .google.protobuf.SourceCodeInfo.Location location = 1; int location_size() const; void clear_location(); - static const int kLocationFieldNumber = 1; PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* mutable_location(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >* mutable_location(); @@ -5876,11 +6201,22 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : static constexpr int kIndexInFileMessages = 25; - void UnsafeArenaSwap(GeneratedCodeInfo_Annotation* other); - void Swap(GeneratedCodeInfo_Annotation* other); friend void swap(GeneratedCodeInfo_Annotation& a, GeneratedCodeInfo_Annotation& b) { a.Swap(&b); } + inline void Swap(GeneratedCodeInfo_Annotation* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(GeneratedCodeInfo_Annotation* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -5947,10 +6283,15 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : // accessors ------------------------------------------------------- + enum : int { + kPathFieldNumber = 1, + kSourceFileFieldNumber = 2, + kBeginFieldNumber = 3, + kEndFieldNumber = 4, + }; // repeated int32 path = 1 [packed = true]; int path_size() const; void clear_path(); - static const int kPathFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::int32 path(int index) const; void set_path(int index, ::PROTOBUF_NAMESPACE_ID::int32 value); void add_path(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -5962,7 +6303,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : // optional string source_file = 2; bool has_source_file() const; void clear_source_file(); - static const int kSourceFileFieldNumber = 2; const std::string& source_file() const; void set_source_file(const std::string& value); void set_source_file(std::string&& value); @@ -5984,14 +6324,12 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : // optional int32 begin = 3; bool has_begin() const; void clear_begin(); - static const int kBeginFieldNumber = 3; ::PROTOBUF_NAMESPACE_ID::int32 begin() const; void set_begin(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 end = 4; bool has_end() const; void clear_end(); - static const int kEndFieldNumber = 4; ::PROTOBUF_NAMESPACE_ID::int32 end() const; void set_end(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -6071,11 +6409,22 @@ class PROTOBUF_EXPORT GeneratedCodeInfo : static constexpr int kIndexInFileMessages = 26; - void UnsafeArenaSwap(GeneratedCodeInfo* other); - void Swap(GeneratedCodeInfo* other); friend void swap(GeneratedCodeInfo& a, GeneratedCodeInfo& b) { a.Swap(&b); } + inline void Swap(GeneratedCodeInfo* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(GeneratedCodeInfo* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -6144,10 +6493,12 @@ class PROTOBUF_EXPORT GeneratedCodeInfo : // accessors ------------------------------------------------------- + enum : int { + kAnnotationFieldNumber = 1, + }; // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; int annotation_size() const; void clear_annotation(); - static const int kAnnotationFieldNumber = 1; PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* mutable_annotation(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >* mutable_annotation(); diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 864a4407e8..6aea3636cc 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -90,11 +90,6 @@ class Duration::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Duration::kSecondsFieldNumber; -const int Duration::kNanosFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Duration::Duration() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -386,25 +381,6 @@ bool Duration::IsInitialized() const { return true; } -void Duration::Swap(Duration* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Duration* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Duration::UnsafeArenaSwap(Duration* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Duration::InternalSwap(Duration* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index beed27900a..0a43178af4 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -116,11 +116,22 @@ class PROTOBUF_EXPORT Duration : static constexpr int kIndexInFileMessages = 0; - void UnsafeArenaSwap(Duration* other); - void Swap(Duration* other); friend void swap(Duration& a, Duration& b) { a.Swap(&b); } + inline void Swap(Duration* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Duration* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -187,15 +198,17 @@ class PROTOBUF_EXPORT Duration : // accessors ------------------------------------------------------- + enum : int { + kSecondsFieldNumber = 1, + kNanosFieldNumber = 2, + }; // int64 seconds = 1; void clear_seconds(); - static const int kSecondsFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::int64 seconds() const; void set_seconds(::PROTOBUF_NAMESPACE_ID::int64 value); // int32 nanos = 2; void clear_nanos(); - static const int kNanosFieldNumber = 2; ::PROTOBUF_NAMESPACE_ID::int32 nanos() const; void set_nanos(::PROTOBUF_NAMESPACE_ID::int32 value); diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 835fd5fc12..412d6f792f 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -87,9 +87,6 @@ class Empty::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Empty::Empty() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -286,25 +283,6 @@ bool Empty::IsInitialized() const { return true; } -void Empty::Swap(Empty* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Empty* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Empty::UnsafeArenaSwap(Empty* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Empty::InternalSwap(Empty* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 3556bd9cc3..0f4b9f8278 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -116,11 +116,22 @@ class PROTOBUF_EXPORT Empty : static constexpr int kIndexInFileMessages = 0; - void UnsafeArenaSwap(Empty* other); - void Swap(Empty* other); friend void swap(Empty& a, Empty& b) { a.Swap(&b); } + inline void Swap(Empty* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Empty* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- diff --git a/src/google/protobuf/extension_set_inl.h b/src/google/protobuf/extension_set_inl.h index 4e6995ef1e..9e15a17c4a 100644 --- a/src/google/protobuf/extension_set_inl.h +++ b/src/google/protobuf/extension_set_inl.h @@ -71,8 +71,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( MutableRawRepeatedField(number, extension.type, extension.is_packed, extension.descriptor), ptr, ctx, extension.enum_validity_check.func, - extension.enum_validity_check.arg, - metadata->mutable_unknown_fields(), number); + extension.enum_validity_check.arg, metadata, number); case WireFormatLite::TYPE_STRING: case WireFormatLite::TYPE_BYTES: case WireFormatLite::TYPE_GROUP: diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index 4f75e4a6a7..ca88d38ef7 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -89,10 +89,6 @@ class FieldMask::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int FieldMask::kPathsFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - FieldMask::FieldMask() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -356,25 +352,6 @@ bool FieldMask::IsInitialized() const { return true; } -void FieldMask::Swap(FieldMask* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - FieldMask* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void FieldMask::UnsafeArenaSwap(FieldMask* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void FieldMask::InternalSwap(FieldMask* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 22a23db1e9..ab7152959a 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -116,11 +116,22 @@ class PROTOBUF_EXPORT FieldMask : static constexpr int kIndexInFileMessages = 0; - void UnsafeArenaSwap(FieldMask* other); - void Swap(FieldMask* other); friend void swap(FieldMask& a, FieldMask& b) { a.Swap(&b); } + inline void Swap(FieldMask* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FieldMask* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -187,10 +198,12 @@ class PROTOBUF_EXPORT FieldMask : // accessors ------------------------------------------------------- + enum : int { + kPathsFieldNumber = 1, + }; // repeated string paths = 1; int paths_size() const; void clear_paths(); - static const int kPathsFieldNumber = 1; const std::string& paths(int index) const; std::string* mutable_paths(int index); void set_paths(int index, const std::string& value); diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 363eca42bc..36d7307a50 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -747,6 +747,15 @@ MessageLite* DuplicateIfNonNullInternal(MessageLite* message) { } } +void GenericSwap(MessageLite* m1, MessageLite* m2) { + std::unique_ptr tmp(m1->New()); + tmp->CheckTypeAndMergeFrom(*m1); + m1->Clear(); + m1->CheckTypeAndMergeFrom(*m2); + m2->Clear(); + m2->CheckTypeAndMergeFrom(*tmp); +} + // Returns a message owned by this Arena. This may require Own()ing or // duplicating the message. MessageLite* GetOwnedMessageInternal(Arena* message_arena, diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index bf0e5b9b0f..4e8ad9142f 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -145,6 +145,7 @@ PROTOBUF_EXPORT MessageLite* DuplicateIfNonNullInternal(MessageLite* message); PROTOBUF_EXPORT MessageLite* GetOwnedMessageInternal(Arena* message_arena, MessageLite* submessage, Arena* submessage_arena); +PROTOBUF_EXPORT void GenericSwap(MessageLite* m1, MessageLite* m2); template T* DuplicateIfNonNull(T* message) { diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index 56259bb5cf..804c2ce018 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -158,6 +158,11 @@ class ReflectionAccessor { return reflection->MutableRawRepeatedField( msg, field, FieldDescriptor::CPPTYPE_ENUM, 0, nullptr); } + + static InternalMetadataWithArena* MutableInternalMetadataWithArena( + const Reflection* reflection, Message* msg) { + return reflection->MutableInternalMetadataWithArena(msg); + } }; } // namespace internal @@ -263,7 +268,9 @@ const char* ParsePackedField(const FieldDescriptor* field, Message* msg, } else { return internal::PackedEnumParserArg( object, ptr, ctx, ReflectiveValidator, field->enum_type(), - reflection->MutableUnknownFields(msg), field->number()); + internal::ReflectionAccessor::MutableInternalMetadataWithArena( + reflection, msg), + field->number()); } } HANDLE_PACKED_TYPE(FIXED32, uint32, Fixed32); diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index b6e966d341..da44a363a5 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -982,7 +982,7 @@ class PROTOBUF_EXPORT Reflection final { inline const internal::InternalMetadataWithArena& GetInternalMetadataWithArena(const Message& message) const; - inline internal::InternalMetadataWithArena* MutableInternalMetadataWithArena( + internal::InternalMetadataWithArena* MutableInternalMetadataWithArena( Message* message) const; inline bool IsInlined(const FieldDescriptor* field) const; diff --git a/src/google/protobuf/parse_context.cc b/src/google/protobuf/parse_context.cc index 9efa521e19..d514079e9f 100644 --- a/src/google/protobuf/parse_context.cc +++ b/src/google/protobuf/parse_context.cc @@ -421,14 +421,15 @@ const char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx) { } const char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(int), std::string* unknown, + bool (*is_valid)(int), + InternalMetadataWithArenaLite* metadata, int field_num) { return ctx->ReadPackedVarint( - ptr, [object, is_valid, unknown, field_num](uint64 val) { + ptr, [object, is_valid, metadata, field_num](uint64 val) { if (is_valid(val)) { static_cast*>(object)->Add(val); } else { - WriteVarint(field_num, val, unknown); + WriteVarint(field_num, val, metadata->mutable_unknown_fields()); } }); } @@ -436,14 +437,15 @@ const char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx, const char* PackedEnumParserArg(void* object, const char* ptr, ParseContext* ctx, bool (*is_valid)(const void*, int), - const void* data, std::string* unknown, + const void* data, + InternalMetadataWithArenaLite* metadata, int field_num) { return ctx->ReadPackedVarint( - ptr, [object, is_valid, data, unknown, field_num](uint64 val) { + ptr, [object, is_valid, data, metadata, field_num](uint64 val) { if (is_valid(data, val)) { static_cast*>(object)->Add(val); } else { - WriteVarint(field_num, val, unknown); + WriteVarint(field_num, val, metadata->mutable_unknown_fields()); } }); } diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 04db357227..72355f81cf 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -718,11 +718,11 @@ PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParser( void* object, const char* ptr, ParseContext* ctx, bool (*is_valid)(int), - std::string* unknown, int field_num); + InternalMetadataWithArenaLite* metadata, int field_num); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParserArg( void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(const void*, int), const void* data, std::string* unknown, - int field_num); + bool (*is_valid)(const void*, int), const void* data, + InternalMetadataWithArenaLite* metadata, int field_num); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedBoolParser( void* object, const char* ptr, ParseContext* ctx); diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index e4a7b62a4c..47c9987041 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -118,6 +118,10 @@ inline int CalculateReserve(Iter begin, Iter end) { // set-by-index, and add accessors that are generated for all repeated fields. template class RepeatedField final { + static_assert( + alignof(Arena) >= alignof(Element), + "We only support types that have an alignment smaller than Arena"); + public: RepeatedField(); explicit RepeatedField(Arena* arena); @@ -289,23 +293,30 @@ class RepeatedField final { // Element is double and pointer is 32bit). static const size_t kRepHeaderSize; - // We reuse the Rep* for an Arena* when total_size == 0, to avoid having to do - // an allocation in the constructor when we have an Arena. - union Pointer { - Pointer(Arena* a) : arena(a) {} - Arena* arena; // When total_size_ == 0. - Element* elements; // When total_size_ != 0, this is Rep->elements of Rep. - } ptr_; + // If total_size_ == 0 this points to an Arena otherwise it points to the + // elements member of a Rep struct. Using this invariant allows the storage of + // the arena pointer without an extra allocation in the constructor. + void* arena_or_elements_; + // Return pointer to elements array. + // pre-condition: the array must have been allocated. Element* elements() const { GOOGLE_DCHECK_GT(total_size_, 0); - return ptr_.elements; + // Because of above pre-condition this cast is safe. + return unsafe_elements(); + } + + // Return pointer to elements array if it exists otherwise either null or + // a invalid pointer is returned. This only happens for empty repeated fields, + // where you can't dereference this pointer anyway (it's empty). + Element* unsafe_elements() const { + return static_cast(arena_or_elements_); } + // Return pointer to the Rep struct. + // pre-condition: the Rep must have been allocated, ie elements() is safe. Rep* rep() const { - GOOGLE_DCHECK_GT(total_size_, 0); - char* addr = - reinterpret_cast(ptr_.elements) - offsetof(Rep, elements); + char* addr = reinterpret_cast(elements()) - offsetof(Rep, elements); return reinterpret_cast(addr); } @@ -323,7 +334,8 @@ class RepeatedField final { // Internal helper expected by Arena methods. inline Arena* GetArenaNoVirtual() const { - return (total_size_ == 0) ? ptr_.arena : rep()->arena; + return (total_size_ == 0) ? static_cast(arena_or_elements_) + : rep()->arena; } // Internal helper to delete all elements and deallocate the storage. @@ -346,9 +358,6 @@ class RepeatedField final { } } } - - friend class internal::WireFormatLite; - const Element* unsafe_data() const; }; template @@ -1057,15 +1066,15 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { template inline RepeatedField::RepeatedField() - : current_size_(0), total_size_(0), ptr_(NULL) {} + : current_size_(0), total_size_(0), arena_or_elements_(nullptr) {} template inline RepeatedField::RepeatedField(Arena* arena) - : current_size_(0), total_size_(0), ptr_(arena) {} + : current_size_(0), total_size_(0), arena_or_elements_(arena) {} template inline RepeatedField::RepeatedField(const RepeatedField& other) - : current_size_(0), total_size_(0), ptr_(NULL) { + : current_size_(0), total_size_(0), arena_or_elements_(nullptr) { if (other.current_size_ != 0) { Reserve(other.size()); AddNAlreadyReserved(other.size()); @@ -1076,7 +1085,7 @@ inline RepeatedField::RepeatedField(const RepeatedField& other) template template RepeatedField::RepeatedField(Iter begin, const Iter& end) - : current_size_(0), total_size_(0), ptr_(NULL) { + : current_size_(0), total_size_(0), arena_or_elements_(nullptr) { Add(begin, end); } @@ -1153,13 +1162,11 @@ template inline Element* RepeatedField::AddNAlreadyReserved(int n) { GOOGLE_DCHECK_GE(total_size_ - current_size_, n) << total_size_ << ", " << current_size_; - // Warning: sometimes people call this when n==0 and total_size_==0. This - // forces us to add this branch, to avoid reading the non-active union member - // (which is UB). Luckily the compiler is smart enough to optimize the branch - // away. - Element* ret = - total_size_ == 0 ? reinterpret_cast(ptr_.arena) : ptr_.elements; - ret += current_size_; + // Warning: sometimes people call this when n == 0 and total_size_ == 0. In + // this case the return pointer points to a zero size array (n == 0). Hence + // we can just use unsafe_elements(), because the user cannot dereference the + // pointer anyway. + Element* ret = unsafe_elements() + current_size_; current_size_ += n; return ret; } @@ -1313,17 +1320,12 @@ inline typename RepeatedField::iterator RepeatedField::erase( template inline Element* RepeatedField::mutable_data() { - return total_size_ > 0 ? elements() : NULL; + return unsafe_elements(); } template inline const Element* RepeatedField::data() const { - return total_size_ > 0 ? elements() : NULL; -} - -template -inline const Element* RepeatedField::unsafe_data() const { - return elements(); + return unsafe_elements(); } template @@ -1331,7 +1333,7 @@ inline void RepeatedField::InternalSwap(RepeatedField* other) { GOOGLE_DCHECK(this != other); GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - std::swap(ptr_, other->ptr_); + std::swap(arena_or_elements_, other->arena_or_elements_); std::swap(current_size_, other->current_size_); std::swap(total_size_, other->total_size_); } @@ -1364,31 +1366,31 @@ void RepeatedField::SwapElements(int index1, int index2) { template inline typename RepeatedField::iterator RepeatedField::begin() { - return total_size_ > 0 ? elements() : NULL; + return unsafe_elements(); } template inline typename RepeatedField::const_iterator RepeatedField::begin() const { - return total_size_ > 0 ? elements() : NULL; + return unsafe_elements(); } template inline typename RepeatedField::const_iterator RepeatedField::cbegin() const { - return total_size_ > 0 ? elements() : NULL; + return unsafe_elements(); } template inline typename RepeatedField::iterator RepeatedField::end() { - return total_size_ > 0 ? elements() + current_size_ : NULL; + return unsafe_elements() + current_size_; } template inline typename RepeatedField::const_iterator RepeatedField::end() const { - return total_size_ > 0 ? elements() + current_size_ : NULL; + return unsafe_elements() + current_size_; } template inline typename RepeatedField::const_iterator RepeatedField::cend() const { - return total_size_ > 0 ? elements() + current_size_ : NULL; + return unsafe_elements() + current_size_; } template @@ -1420,7 +1422,7 @@ void RepeatedField::Reserve(int new_size) { new_rep->arena = arena; int old_total_size = total_size_; total_size_ = new_size; - ptr_.elements = new_rep->elements; + arena_or_elements_ = new_rep->elements; // Invoke placement-new on newly allocated elements. We shouldn't have to do // this, since Element is supposed to be POD, but a previous version of this // code allocated storage with "new Element[size]" and some code uses diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index e7e66aa1e7..5263fc6152 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -90,10 +90,6 @@ class SourceContext::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int SourceContext::kFileNameFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - SourceContext::SourceContext() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -343,10 +339,6 @@ bool SourceContext::IsInitialized() const { return true; } -void SourceContext::Swap(SourceContext* other) { - if (other == this) return; - InternalSwap(other); -} void SourceContext::InternalSwap(SourceContext* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index d46bbc5fd8..0383fb52e4 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -110,10 +110,13 @@ class PROTOBUF_EXPORT SourceContext : static constexpr int kIndexInFileMessages = 0; - void Swap(SourceContext* other); friend void swap(SourceContext& a, SourceContext& b) { a.Swap(&b); } + inline void Swap(SourceContext* other) { + if (other == this) return; + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -175,9 +178,11 @@ class PROTOBUF_EXPORT SourceContext : // accessors ------------------------------------------------------- + enum : int { + kFileNameFieldNumber = 1, + }; // string file_name = 1; void clear_file_name(); - static const int kFileNameFieldNumber = 1; const std::string& file_name() const; void set_file_name(const std::string& value); void set_file_name(std::string&& value); diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index a3de868d53..124fdfa018 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -199,10 +199,6 @@ class Struct::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Struct::kFieldsFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Struct::Struct() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -535,25 +531,6 @@ bool Struct::IsInitialized() const { return true; } -void Struct::Swap(Struct* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Struct* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Struct::UnsafeArenaSwap(Struct* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Struct::InternalSwap(Struct* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -622,15 +599,6 @@ void Value::set_allocated_list_value(PROTOBUF_NAMESPACE_ID::ListValue* list_valu } // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value) } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Value::kNullValueFieldNumber; -const int Value::kNumberValueFieldNumber; -const int Value::kStringValueFieldNumber; -const int Value::kBoolValueFieldNumber; -const int Value::kStructValueFieldNumber; -const int Value::kListValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Value::Value() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1181,25 +1149,6 @@ bool Value::IsInitialized() const { return true; } -void Value::Swap(Value* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Value* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Value::UnsafeArenaSwap(Value* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Value::InternalSwap(Value* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -1220,10 +1169,6 @@ class ListValue::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int ListValue::kValuesFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - ListValue::ListValue() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1482,25 +1427,6 @@ bool ListValue::IsInitialized() const { return true; } -void ListValue::Swap(ListValue* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - ListValue* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void ListValue::UnsafeArenaSwap(ListValue* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void ListValue::InternalSwap(ListValue* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 2a639f675a..63df3c976e 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -188,11 +188,22 @@ class PROTOBUF_EXPORT Struct : static constexpr int kIndexInFileMessages = 1; - void UnsafeArenaSwap(Struct* other); - void Swap(Struct* other); friend void swap(Struct& a, Struct& b) { a.Swap(&b); } + inline void Swap(Struct* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Struct* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -260,10 +271,12 @@ class PROTOBUF_EXPORT Struct : // accessors ------------------------------------------------------- + enum : int { + kFieldsFieldNumber = 1, + }; // map fields = 1; int fields_size() const; void clear_fields(); - static const int kFieldsFieldNumber = 1; const ::PROTOBUF_NAMESPACE_ID::Map< std::string, PROTOBUF_NAMESPACE_ID::Value >& fields() const; ::PROTOBUF_NAMESPACE_ID::Map< std::string, PROTOBUF_NAMESPACE_ID::Value >* @@ -348,11 +361,22 @@ class PROTOBUF_EXPORT Value : static constexpr int kIndexInFileMessages = 2; - void UnsafeArenaSwap(Value* other); - void Swap(Value* other); friend void swap(Value& a, Value& b) { a.Swap(&b); } + inline void Swap(Value* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Value* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -419,12 +443,19 @@ class PROTOBUF_EXPORT Value : // accessors ------------------------------------------------------- + enum : int { + kNullValueFieldNumber = 1, + kNumberValueFieldNumber = 2, + kStringValueFieldNumber = 3, + kBoolValueFieldNumber = 4, + kStructValueFieldNumber = 5, + kListValueFieldNumber = 6, + }; // .google.protobuf.NullValue null_value = 1; private: bool has_null_value() const; public: void clear_null_value(); - static const int kNullValueFieldNumber = 1; PROTOBUF_NAMESPACE_ID::NullValue null_value() const; void set_null_value(PROTOBUF_NAMESPACE_ID::NullValue value); @@ -433,7 +464,6 @@ class PROTOBUF_EXPORT Value : bool has_number_value() const; public: void clear_number_value(); - static const int kNumberValueFieldNumber = 2; double number_value() const; void set_number_value(double value); @@ -442,7 +472,6 @@ class PROTOBUF_EXPORT Value : bool has_string_value() const; public: void clear_string_value(); - static const int kStringValueFieldNumber = 3; const std::string& string_value() const; void set_string_value(const std::string& value); void set_string_value(std::string&& value); @@ -466,14 +495,12 @@ class PROTOBUF_EXPORT Value : bool has_bool_value() const; public: void clear_bool_value(); - static const int kBoolValueFieldNumber = 4; bool bool_value() const; void set_bool_value(bool value); // .google.protobuf.Struct struct_value = 5; bool has_struct_value() const; void clear_struct_value(); - static const int kStructValueFieldNumber = 5; const PROTOBUF_NAMESPACE_ID::Struct& struct_value() const; PROTOBUF_NAMESPACE_ID::Struct* release_struct_value(); PROTOBUF_NAMESPACE_ID::Struct* mutable_struct_value(); @@ -485,7 +512,6 @@ class PROTOBUF_EXPORT Value : // .google.protobuf.ListValue list_value = 6; bool has_list_value() const; void clear_list_value(); - static const int kListValueFieldNumber = 6; const PROTOBUF_NAMESPACE_ID::ListValue& list_value() const; PROTOBUF_NAMESPACE_ID::ListValue* release_list_value(); PROTOBUF_NAMESPACE_ID::ListValue* mutable_list_value(); @@ -579,11 +605,22 @@ class PROTOBUF_EXPORT ListValue : static constexpr int kIndexInFileMessages = 3; - void UnsafeArenaSwap(ListValue* other); - void Swap(ListValue* other); friend void swap(ListValue& a, ListValue& b) { a.Swap(&b); } + inline void Swap(ListValue* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ListValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -650,10 +687,12 @@ class PROTOBUF_EXPORT ListValue : // accessors ------------------------------------------------------- + enum : int { + kValuesFieldNumber = 1, + }; // repeated .google.protobuf.Value values = 1; int values_size() const; void clear_values(); - static const int kValuesFieldNumber = 1; PROTOBUF_NAMESPACE_ID::Value* mutable_values(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Value >* mutable_values(); diff --git a/src/google/protobuf/stubs/mathutil.h b/src/google/protobuf/stubs/mathutil.h index b87b286980..479032d064 100644 --- a/src/google/protobuf/stubs/mathutil.h +++ b/src/google/protobuf/stubs/mathutil.h @@ -126,8 +126,7 @@ bool MathUtil::WithinFractionOrMargin(const T x, const T y, if (MathLimits::kIsInteger) { return x == y; } else { - // IsFinite checks are to make kPosInf and kNegInf not within fraction - if (!MathLimits::IsFinite(x) && !MathLimits::IsFinite(y)) { + if (!MathLimits::IsFinite(x) || !MathLimits::IsFinite(y)) { return false; } T relative_margin = static_cast(fraction * Max(Abs(x), Abs(y))); diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index 4c26287297..c05fb1269b 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -90,11 +90,6 @@ class Timestamp::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Timestamp::kSecondsFieldNumber; -const int Timestamp::kNanosFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Timestamp::Timestamp() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -386,25 +381,6 @@ bool Timestamp::IsInitialized() const { return true; } -void Timestamp::Swap(Timestamp* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Timestamp* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Timestamp::UnsafeArenaSwap(Timestamp* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Timestamp::InternalSwap(Timestamp* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 76d33296ec..3cd5fdf57d 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -116,11 +116,22 @@ class PROTOBUF_EXPORT Timestamp : static constexpr int kIndexInFileMessages = 0; - void UnsafeArenaSwap(Timestamp* other); - void Swap(Timestamp* other); friend void swap(Timestamp& a, Timestamp& b) { a.Swap(&b); } + inline void Swap(Timestamp* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Timestamp* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -187,15 +198,17 @@ class PROTOBUF_EXPORT Timestamp : // accessors ------------------------------------------------------- + enum : int { + kSecondsFieldNumber = 1, + kNanosFieldNumber = 2, + }; // int64 seconds = 1; void clear_seconds(); - static const int kSecondsFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::int64 seconds() const; void set_seconds(::PROTOBUF_NAMESPACE_ID::int64 value); // int32 nanos = 2; void clear_nanos(); - static const int kNanosFieldNumber = 2; ::PROTOBUF_NAMESPACE_ID::int32 nanos() const; void set_nanos(::PROTOBUF_NAMESPACE_ID::int32 value); diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index 28f42d9183..e6c061f2fa 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -388,15 +388,6 @@ void Type::clear_source_context() { } source_context_ = nullptr; } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Type::kNameFieldNumber; -const int Type::kFieldsFieldNumber; -const int Type::kOneofsFieldNumber; -const int Type::kOptionsFieldNumber; -const int Type::kSourceContextFieldNumber; -const int Type::kSyntaxFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Type::Type() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -930,25 +921,6 @@ bool Type::IsInitialized() const { return true; } -void Type::Swap(Type* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Type* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Type::UnsafeArenaSwap(Type* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Type::InternalSwap(Type* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -974,19 +946,6 @@ class Field::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Field::kKindFieldNumber; -const int Field::kCardinalityFieldNumber; -const int Field::kNumberFieldNumber; -const int Field::kNameFieldNumber; -const int Field::kTypeUrlFieldNumber; -const int Field::kOneofIndexFieldNumber; -const int Field::kPackedFieldNumber; -const int Field::kOptionsFieldNumber; -const int Field::kJsonNameFieldNumber; -const int Field::kDefaultValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Field::Field() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1702,25 +1661,6 @@ bool Field::IsInitialized() const { return true; } -void Field::Swap(Field* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Field* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Field::UnsafeArenaSwap(Field* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Field::InternalSwap(Field* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -1779,14 +1719,6 @@ void Enum::clear_source_context() { } source_context_ = nullptr; } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Enum::kNameFieldNumber; -const int Enum::kEnumvalueFieldNumber; -const int Enum::kOptionsFieldNumber; -const int Enum::kSourceContextFieldNumber; -const int Enum::kSyntaxFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Enum::Enum() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -2260,25 +2192,6 @@ bool Enum::IsInitialized() const { return true; } -void Enum::Swap(Enum* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Enum* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Enum::UnsafeArenaSwap(Enum* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Enum::InternalSwap(Enum* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -2303,12 +2216,6 @@ class EnumValue::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int EnumValue::kNameFieldNumber; -const int EnumValue::kNumberFieldNumber; -const int EnumValue::kOptionsFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - EnumValue::EnumValue() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -2671,25 +2578,6 @@ bool EnumValue::IsInitialized() const { return true; } -void EnumValue::Swap(EnumValue* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - EnumValue* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void EnumValue::UnsafeArenaSwap(EnumValue* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void EnumValue::InternalSwap(EnumValue* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -2738,11 +2626,6 @@ void Option::clear_value() { } value_ = nullptr; } -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Option::kNameFieldNumber; -const int Option::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Option::Option() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -3059,25 +2942,6 @@ bool Option::IsInitialized() const { return true; } -void Option::Swap(Option* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Option* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Option::UnsafeArenaSwap(Option* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Option::InternalSwap(Option* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 3aad0fa8af..0dd0a2ae1f 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -229,11 +229,22 @@ class PROTOBUF_EXPORT Type : static constexpr int kIndexInFileMessages = 0; - void UnsafeArenaSwap(Type* other); - void Swap(Type* other); friend void swap(Type& a, Type& b) { a.Swap(&b); } + inline void Swap(Type* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Type* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -300,10 +311,17 @@ class PROTOBUF_EXPORT Type : // accessors ------------------------------------------------------- + enum : int { + kFieldsFieldNumber = 2, + kOneofsFieldNumber = 3, + kOptionsFieldNumber = 4, + kNameFieldNumber = 1, + kSourceContextFieldNumber = 5, + kSyntaxFieldNumber = 6, + }; // repeated .google.protobuf.Field fields = 2; int fields_size() const; void clear_fields(); - static const int kFieldsFieldNumber = 2; PROTOBUF_NAMESPACE_ID::Field* mutable_fields(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Field >* mutable_fields(); @@ -315,7 +333,6 @@ class PROTOBUF_EXPORT Type : // repeated string oneofs = 3; int oneofs_size() const; void clear_oneofs(); - static const int kOneofsFieldNumber = 3; const std::string& oneofs(int index) const; std::string* mutable_oneofs(int index); void set_oneofs(int index, const std::string& value); @@ -333,7 +350,6 @@ class PROTOBUF_EXPORT Type : // repeated .google.protobuf.Option options = 4; int options_size() const; void clear_options(); - static const int kOptionsFieldNumber = 4; PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Option >* mutable_options(); @@ -344,7 +360,6 @@ class PROTOBUF_EXPORT Type : // string name = 1; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -366,7 +381,6 @@ class PROTOBUF_EXPORT Type : // .google.protobuf.SourceContext source_context = 5; bool has_source_context() const; void clear_source_context(); - static const int kSourceContextFieldNumber = 5; const PROTOBUF_NAMESPACE_ID::SourceContext& source_context() const; PROTOBUF_NAMESPACE_ID::SourceContext* release_source_context(); PROTOBUF_NAMESPACE_ID::SourceContext* mutable_source_context(); @@ -377,7 +391,6 @@ class PROTOBUF_EXPORT Type : // .google.protobuf.Syntax syntax = 6; void clear_syntax(); - static const int kSyntaxFieldNumber = 6; PROTOBUF_NAMESPACE_ID::Syntax syntax() const; void set_syntax(PROTOBUF_NAMESPACE_ID::Syntax value); @@ -450,11 +463,22 @@ class PROTOBUF_EXPORT Field : static constexpr int kIndexInFileMessages = 1; - void UnsafeArenaSwap(Field* other); - void Swap(Field* other); friend void swap(Field& a, Field& b) { a.Swap(&b); } + inline void Swap(Field* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Field* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -619,10 +643,21 @@ class PROTOBUF_EXPORT Field : // accessors ------------------------------------------------------- + enum : int { + kOptionsFieldNumber = 9, + kNameFieldNumber = 4, + kTypeUrlFieldNumber = 6, + kJsonNameFieldNumber = 10, + kDefaultValueFieldNumber = 11, + kKindFieldNumber = 1, + kCardinalityFieldNumber = 2, + kNumberFieldNumber = 3, + kOneofIndexFieldNumber = 7, + kPackedFieldNumber = 8, + }; // repeated .google.protobuf.Option options = 9; int options_size() const; void clear_options(); - static const int kOptionsFieldNumber = 9; PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Option >* mutable_options(); @@ -633,7 +668,6 @@ class PROTOBUF_EXPORT Field : // string name = 4; void clear_name(); - static const int kNameFieldNumber = 4; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -654,7 +688,6 @@ class PROTOBUF_EXPORT Field : // string type_url = 6; void clear_type_url(); - static const int kTypeUrlFieldNumber = 6; const std::string& type_url() const; void set_type_url(const std::string& value); void set_type_url(std::string&& value); @@ -675,7 +708,6 @@ class PROTOBUF_EXPORT Field : // string json_name = 10; void clear_json_name(); - static const int kJsonNameFieldNumber = 10; const std::string& json_name() const; void set_json_name(const std::string& value); void set_json_name(std::string&& value); @@ -696,7 +728,6 @@ class PROTOBUF_EXPORT Field : // string default_value = 11; void clear_default_value(); - static const int kDefaultValueFieldNumber = 11; const std::string& default_value() const; void set_default_value(const std::string& value); void set_default_value(std::string&& value); @@ -717,31 +748,26 @@ class PROTOBUF_EXPORT Field : // .google.protobuf.Field.Kind kind = 1; void clear_kind(); - static const int kKindFieldNumber = 1; PROTOBUF_NAMESPACE_ID::Field_Kind kind() const; void set_kind(PROTOBUF_NAMESPACE_ID::Field_Kind value); // .google.protobuf.Field.Cardinality cardinality = 2; void clear_cardinality(); - static const int kCardinalityFieldNumber = 2; PROTOBUF_NAMESPACE_ID::Field_Cardinality cardinality() const; void set_cardinality(PROTOBUF_NAMESPACE_ID::Field_Cardinality value); // int32 number = 3; void clear_number(); - static const int kNumberFieldNumber = 3; ::PROTOBUF_NAMESPACE_ID::int32 number() const; void set_number(::PROTOBUF_NAMESPACE_ID::int32 value); // int32 oneof_index = 7; void clear_oneof_index(); - static const int kOneofIndexFieldNumber = 7; ::PROTOBUF_NAMESPACE_ID::int32 oneof_index() const; void set_oneof_index(::PROTOBUF_NAMESPACE_ID::int32 value); // bool packed = 8; void clear_packed(); - static const int kPackedFieldNumber = 8; bool packed() const; void set_packed(bool value); @@ -818,11 +844,22 @@ class PROTOBUF_EXPORT Enum : static constexpr int kIndexInFileMessages = 2; - void UnsafeArenaSwap(Enum* other); - void Swap(Enum* other); friend void swap(Enum& a, Enum& b) { a.Swap(&b); } + inline void Swap(Enum* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Enum* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -889,10 +926,16 @@ class PROTOBUF_EXPORT Enum : // accessors ------------------------------------------------------- + enum : int { + kEnumvalueFieldNumber = 2, + kOptionsFieldNumber = 3, + kNameFieldNumber = 1, + kSourceContextFieldNumber = 4, + kSyntaxFieldNumber = 5, + }; // repeated .google.protobuf.EnumValue enumvalue = 2; int enumvalue_size() const; void clear_enumvalue(); - static const int kEnumvalueFieldNumber = 2; PROTOBUF_NAMESPACE_ID::EnumValue* mutable_enumvalue(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::EnumValue >* mutable_enumvalue(); @@ -904,7 +947,6 @@ class PROTOBUF_EXPORT Enum : // repeated .google.protobuf.Option options = 3; int options_size() const; void clear_options(); - static const int kOptionsFieldNumber = 3; PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Option >* mutable_options(); @@ -915,7 +957,6 @@ class PROTOBUF_EXPORT Enum : // string name = 1; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -937,7 +978,6 @@ class PROTOBUF_EXPORT Enum : // .google.protobuf.SourceContext source_context = 4; bool has_source_context() const; void clear_source_context(); - static const int kSourceContextFieldNumber = 4; const PROTOBUF_NAMESPACE_ID::SourceContext& source_context() const; PROTOBUF_NAMESPACE_ID::SourceContext* release_source_context(); PROTOBUF_NAMESPACE_ID::SourceContext* mutable_source_context(); @@ -948,7 +988,6 @@ class PROTOBUF_EXPORT Enum : // .google.protobuf.Syntax syntax = 5; void clear_syntax(); - static const int kSyntaxFieldNumber = 5; PROTOBUF_NAMESPACE_ID::Syntax syntax() const; void set_syntax(PROTOBUF_NAMESPACE_ID::Syntax value); @@ -1020,11 +1059,22 @@ class PROTOBUF_EXPORT EnumValue : static constexpr int kIndexInFileMessages = 3; - void UnsafeArenaSwap(EnumValue* other); - void Swap(EnumValue* other); friend void swap(EnumValue& a, EnumValue& b) { a.Swap(&b); } + inline void Swap(EnumValue* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(EnumValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -1091,10 +1141,14 @@ class PROTOBUF_EXPORT EnumValue : // accessors ------------------------------------------------------- + enum : int { + kOptionsFieldNumber = 3, + kNameFieldNumber = 1, + kNumberFieldNumber = 2, + }; // repeated .google.protobuf.Option options = 3; int options_size() const; void clear_options(); - static const int kOptionsFieldNumber = 3; PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Option >* mutable_options(); @@ -1105,7 +1159,6 @@ class PROTOBUF_EXPORT EnumValue : // string name = 1; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -1126,7 +1179,6 @@ class PROTOBUF_EXPORT EnumValue : // int32 number = 2; void clear_number(); - static const int kNumberFieldNumber = 2; ::PROTOBUF_NAMESPACE_ID::int32 number() const; void set_number(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -1196,11 +1248,22 @@ class PROTOBUF_EXPORT Option : static constexpr int kIndexInFileMessages = 4; - void UnsafeArenaSwap(Option* other); - void Swap(Option* other); friend void swap(Option& a, Option& b) { a.Swap(&b); } + inline void Swap(Option* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Option* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -1267,9 +1330,12 @@ class PROTOBUF_EXPORT Option : // accessors ------------------------------------------------------- + enum : int { + kNameFieldNumber = 1, + kValueFieldNumber = 2, + }; // string name = 1; void clear_name(); - static const int kNameFieldNumber = 1; const std::string& name() const; void set_name(const std::string& value); void set_name(std::string&& value); @@ -1291,7 +1357,6 @@ class PROTOBUF_EXPORT Option : // .google.protobuf.Any value = 2; bool has_value() const; void clear_value(); - static const int kValueFieldNumber = 2; const PROTOBUF_NAMESPACE_ID::Any& value() const; PROTOBUF_NAMESPACE_ID::Any* release_value(); PROTOBUF_NAMESPACE_ID::Any* mutable_value(); diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc index 2f8b763681..92e1cfea49 100644 --- a/src/google/protobuf/unknown_field_set.cc +++ b/src/google/protobuf/unknown_field_set.cc @@ -287,28 +287,30 @@ uint8* UnknownField::SerializeLengthDelimitedNoTagToArray(uint8* target) const { #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER namespace internal { const char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(int), UnknownFieldSet* unknown, + bool (*is_valid)(int), + InternalMetadataWithArena* metadata, int field_num) { return ctx->ReadPackedVarint( - ptr, [object, is_valid, unknown, field_num](uint64 val) { + ptr, [object, is_valid, metadata, field_num](uint64 val) { if (is_valid(val)) { static_cast*>(object)->Add(val); } else { - WriteVarint(field_num, val, unknown); + WriteVarint(field_num, val, metadata->mutable_unknown_fields()); } }); } const char* PackedEnumParserArg(void* object, const char* ptr, ParseContext* ctx, bool (*is_valid)(const void*, int), - const void* data, UnknownFieldSet* unknown, + const void* data, + InternalMetadataWithArena* metadata, int field_num) { return ctx->ReadPackedVarint( - ptr, [object, is_valid, data, unknown, field_num](uint64 val) { + ptr, [object, is_valid, data, metadata, field_num](uint64 val) { if (is_valid(data, val)) { static_cast*>(object)->Add(val); } else { - WriteVarint(field_num, val, unknown); + WriteVarint(field_num, val, metadata->mutable_unknown_fields()); } }); } diff --git a/src/google/protobuf/unknown_field_set.h b/src/google/protobuf/unknown_field_set.h index 4d5cc060e5..9f4a4741b4 100644 --- a/src/google/protobuf/unknown_field_set.h +++ b/src/google/protobuf/unknown_field_set.h @@ -196,13 +196,14 @@ inline void WriteLengthDelimited(uint32 num, StringPiece val, PROTOBUF_EXPORT const char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(int), UnknownFieldSet* unknown, - int field_num); + bool (*is_valid)(int), + InternalMetadataWithArena* unknown, int field_num); PROTOBUF_EXPORT const char* PackedEnumParserArg(void* object, const char* ptr, ParseContext* ctx, bool (*is_valid)(const void*, int), - const void* data, UnknownFieldSet* unknown, + const void* data, + InternalMetadataWithArena* unknown, int field_num); PROTOBUF_EXPORT diff --git a/src/google/protobuf/util/field_comparator_test.cc b/src/google/protobuf/util/field_comparator_test.cc index 6b7ee49a19..7e538f8951 100644 --- a/src/google/protobuf/util/field_comparator_test.cc +++ b/src/google/protobuf/util/field_comparator_test.cc @@ -388,6 +388,20 @@ TEST_F(DefaultFieldComparatorTest, EXPECT_EQ( FieldComparator::SAME, comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + + // Finite values and inf should not be equal, even for a positive fraction. + message_1_.set_optional_float(std::numeric_limits::infinity()); + message_2_.set_optional_float(0.0f); + message_1_.set_optional_double(std::numeric_limits::infinity()); + message_2_.set_optional_double(0.0); + comparator_.SetFractionAndMargin(field_float, 0.1, 0.0); + comparator_.SetFractionAndMargin(field_double, 0.1, 0.0); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); } TEST_F(DefaultFieldComparatorTest, diff --git a/src/google/protobuf/util/json_format.proto b/src/google/protobuf/util/json_format.proto index d773267216..7434fc3e81 100644 --- a/src/google/protobuf/util/json_format.proto +++ b/src/google/protobuf/util/json_format.proto @@ -117,3 +117,14 @@ message TestStringSerializer { repeated string repeated_string = 2; map string_map = 3; } + +message TestMessageWithExtension { + extensions 100 to max; +} + +message TestExtension { + extend TestMessageWithExtension { + optional TestExtension ext = 100; + } + optional string value = 1; +} diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index 3e2b346932..421db45fbf 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc @@ -1640,7 +1640,8 @@ bool MessageDifferencer::MatchRepeatedFieldIndices( for (int j = start_offset; j < count2; j++) { if (match_list2->at(j) != -1) { - if (!is_treated_as_smart_set || num_diffs_list1[i] == 0) { + if (!is_treated_as_smart_set || num_diffs_list1[i] == 0 || + num_diffs_list1[match_list2->at(j)] == 0) { continue; } } @@ -1662,8 +1663,13 @@ bool MessageDifferencer::MatchRepeatedFieldIndices( // Replace with the one with fewer diffs. const int32 num_diffs = num_diffs_reporter.GetNumDiffs(); if (num_diffs < num_diffs_list1[i]) { - num_diffs_list1[i] = num_diffs; - match = true; + // If j has been already matched to some element, ensure the + // current num_diffs is smaller. + if (match_list2->at(j) == -1 || + num_diffs < num_diffs_list1[match_list2->at(j)]) { + num_diffs_list1[i] = num_diffs; + match = true; + } } } } diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc index 702f99fbd6..afb99fa1bf 100644 --- a/src/google/protobuf/util/message_differencer_unittest.cc +++ b/src/google/protobuf/util/message_differencer_unittest.cc @@ -1158,6 +1158,65 @@ TEST(MessageDifferencerTest, RepeatedFieldSmartSetTest) { diff_report); } +TEST(MessageDifferencerTest, RepeatedFieldSmartSetTest_IdenticalElements) { + // Create the testing protos + protobuf_unittest::TestDiffMessage msg1; + protobuf_unittest::TestDiffMessage msg2; + protobuf_unittest::TestField elem; + + elem.set_a(1); + elem.set_b(1); + elem.set_c(1); + + *msg1.add_rm() = elem; + *msg1.add_rm() = elem; + *msg2.add_rm() = elem; + *msg2.add_rm() = elem; + + util::MessageDifferencer differencer; + differencer.set_repeated_field_comparison( + util::MessageDifferencer::AS_SMART_SET); + EXPECT_TRUE(differencer.Compare(msg1, msg2)); +} + +TEST(MessageDifferencerTest, RepeatedFieldSmartSetTest_PreviouslyMatch) { + // Create the testing protos + protobuf_unittest::TestDiffMessage msg1; + protobuf_unittest::TestDiffMessage msg2; + protobuf_unittest::TestField elem1_1, elem1_2; + protobuf_unittest::TestField elem2_1, elem2_2; + + elem1_1.set_a(1); + elem1_1.set_b(1); + elem1_1.set_c(1); + elem1_2.set_a(1); + elem1_2.set_b(1); + elem1_2.set_c(0); + + elem2_1.set_a(1); + elem2_1.set_b(1); + elem2_1.set_c(1); + elem2_2.set_a(1); + elem2_2.set_b(0); + elem2_2.set_c(1); + + *msg1.add_rm() = elem1_1; + *msg1.add_rm() = elem2_1; + *msg2.add_rm() = elem1_2; + *msg2.add_rm() = elem2_2; + + string diff_report; + util::MessageDifferencer differencer; + differencer.ReportDifferencesToString(&diff_report); + differencer.set_repeated_field_comparison( + util::MessageDifferencer::AS_SMART_SET); + EXPECT_FALSE(differencer.Compare(msg1, msg2)); + EXPECT_EQ( + "modified: rm[0].c: 1 -> 0\n" + "modified: rm[1].b: 1 -> 0\n", + diff_report); +} + TEST(MessageDifferencerTest, RepeatedFieldSmartSet_MultipleMatches) { // Create the testing protos protobuf_unittest::TestDiffMessage msg1; diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index c25b59a198..244edf1357 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -1427,7 +1427,7 @@ inline uint8* WireFormatLite::WritePrimitiveNoTagToArray( const int n = value.size(); GOOGLE_DCHECK_GT(n, 0); - const T* ii = value.unsafe_data(); + const T* ii = value.data(); int i = 0; do { target = Writer(ii[i], target); @@ -1445,7 +1445,7 @@ inline uint8* WireFormatLite::WriteFixedNoTagToArray( const int n = value.size(); GOOGLE_DCHECK_GT(n, 0); - const T* ii = value.unsafe_data(); + const T* ii = value.data(); const int bytes = n * static_cast(sizeof(ii[0])); memcpy(target, ii, static_cast(bytes)); return target + bytes; @@ -1591,7 +1591,7 @@ inline uint8* WireFormatLite::WritePrimitiveToArray( return target; } - const T* ii = value.unsafe_data(); + const T* ii = value.data(); int i = 0; do { target = Writer(field_number, ii[i], target); diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index a4846613e7..73d8c4227d 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -311,10 +311,6 @@ class DoubleValue::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int DoubleValue::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - DoubleValue::DoubleValue() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -558,25 +554,6 @@ bool DoubleValue::IsInitialized() const { return true; } -void DoubleValue::Swap(DoubleValue* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - DoubleValue* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void DoubleValue::UnsafeArenaSwap(DoubleValue* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void DoubleValue::InternalSwap(DoubleValue* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -596,10 +573,6 @@ class FloatValue::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int FloatValue::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - FloatValue::FloatValue() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -843,25 +816,6 @@ bool FloatValue::IsInitialized() const { return true; } -void FloatValue::Swap(FloatValue* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - FloatValue* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void FloatValue::UnsafeArenaSwap(FloatValue* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void FloatValue::InternalSwap(FloatValue* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -881,10 +835,6 @@ class Int64Value::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Int64Value::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Int64Value::Int64Value() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1130,25 +1080,6 @@ bool Int64Value::IsInitialized() const { return true; } -void Int64Value::Swap(Int64Value* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Int64Value* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Int64Value::UnsafeArenaSwap(Int64Value* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Int64Value::InternalSwap(Int64Value* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -1168,10 +1099,6 @@ class UInt64Value::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int UInt64Value::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - UInt64Value::UInt64Value() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1417,25 +1344,6 @@ bool UInt64Value::IsInitialized() const { return true; } -void UInt64Value::Swap(UInt64Value* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - UInt64Value* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void UInt64Value::UnsafeArenaSwap(UInt64Value* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void UInt64Value::InternalSwap(UInt64Value* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -1455,10 +1363,6 @@ class Int32Value::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int Int32Value::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - Int32Value::Int32Value() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1704,25 +1608,6 @@ bool Int32Value::IsInitialized() const { return true; } -void Int32Value::Swap(Int32Value* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - Int32Value* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void Int32Value::UnsafeArenaSwap(Int32Value* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void Int32Value::InternalSwap(Int32Value* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -1742,10 +1627,6 @@ class UInt32Value::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int UInt32Value::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - UInt32Value::UInt32Value() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -1991,25 +1872,6 @@ bool UInt32Value::IsInitialized() const { return true; } -void UInt32Value::Swap(UInt32Value* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - UInt32Value* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void UInt32Value::UnsafeArenaSwap(UInt32Value* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void UInt32Value::InternalSwap(UInt32Value* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -2029,10 +1891,6 @@ class BoolValue::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int BoolValue::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - BoolValue::BoolValue() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -2276,25 +2134,6 @@ bool BoolValue::IsInitialized() const { return true; } -void BoolValue::Swap(BoolValue* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - BoolValue* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void BoolValue::UnsafeArenaSwap(BoolValue* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void BoolValue::InternalSwap(BoolValue* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -2314,10 +2153,6 @@ class StringValue::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int StringValue::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - StringValue::StringValue() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -2582,25 +2417,6 @@ bool StringValue::IsInitialized() const { return true; } -void StringValue::Swap(StringValue* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - StringValue* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void StringValue::UnsafeArenaSwap(StringValue* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void StringValue::InternalSwap(StringValue* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); @@ -2621,10 +2437,6 @@ class BytesValue::_Internal { public: }; -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int BytesValue::kValueFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - BytesValue::BytesValue() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); @@ -2877,25 +2689,6 @@ bool BytesValue::IsInitialized() const { return true; } -void BytesValue::Swap(BytesValue* other) { - if (other == this) return; - if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { - InternalSwap(other); - } else { - BytesValue* temp = New(GetArenaNoVirtual()); - temp->MergeFrom(*other); - other->CopyFrom(*this); - InternalSwap(temp); - if (GetArenaNoVirtual() == nullptr) { - delete temp; - } - } -} -void BytesValue::UnsafeArenaSwap(BytesValue* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); - InternalSwap(other); -} void BytesValue::InternalSwap(BytesValue* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index c8f09f2bcb..8038d988d1 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -148,11 +148,22 @@ class PROTOBUF_EXPORT DoubleValue : static constexpr int kIndexInFileMessages = 0; - void UnsafeArenaSwap(DoubleValue* other); - void Swap(DoubleValue* other); friend void swap(DoubleValue& a, DoubleValue& b) { a.Swap(&b); } + inline void Swap(DoubleValue* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(DoubleValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -219,9 +230,11 @@ class PROTOBUF_EXPORT DoubleValue : // accessors ------------------------------------------------------- + enum : int { + kValueFieldNumber = 1, + }; // double value = 1; void clear_value(); - static const int kValueFieldNumber = 1; double value() const; void set_value(double value); @@ -289,11 +302,22 @@ class PROTOBUF_EXPORT FloatValue : static constexpr int kIndexInFileMessages = 1; - void UnsafeArenaSwap(FloatValue* other); - void Swap(FloatValue* other); friend void swap(FloatValue& a, FloatValue& b) { a.Swap(&b); } + inline void Swap(FloatValue* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FloatValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -360,9 +384,11 @@ class PROTOBUF_EXPORT FloatValue : // accessors ------------------------------------------------------- + enum : int { + kValueFieldNumber = 1, + }; // float value = 1; void clear_value(); - static const int kValueFieldNumber = 1; float value() const; void set_value(float value); @@ -430,11 +456,22 @@ class PROTOBUF_EXPORT Int64Value : static constexpr int kIndexInFileMessages = 2; - void UnsafeArenaSwap(Int64Value* other); - void Swap(Int64Value* other); friend void swap(Int64Value& a, Int64Value& b) { a.Swap(&b); } + inline void Swap(Int64Value* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Int64Value* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -501,9 +538,11 @@ class PROTOBUF_EXPORT Int64Value : // accessors ------------------------------------------------------- + enum : int { + kValueFieldNumber = 1, + }; // int64 value = 1; void clear_value(); - static const int kValueFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::int64 value() const; void set_value(::PROTOBUF_NAMESPACE_ID::int64 value); @@ -571,11 +610,22 @@ class PROTOBUF_EXPORT UInt64Value : static constexpr int kIndexInFileMessages = 3; - void UnsafeArenaSwap(UInt64Value* other); - void Swap(UInt64Value* other); friend void swap(UInt64Value& a, UInt64Value& b) { a.Swap(&b); } + inline void Swap(UInt64Value* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(UInt64Value* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -642,9 +692,11 @@ class PROTOBUF_EXPORT UInt64Value : // accessors ------------------------------------------------------- + enum : int { + kValueFieldNumber = 1, + }; // uint64 value = 1; void clear_value(); - static const int kValueFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::uint64 value() const; void set_value(::PROTOBUF_NAMESPACE_ID::uint64 value); @@ -712,11 +764,22 @@ class PROTOBUF_EXPORT Int32Value : static constexpr int kIndexInFileMessages = 4; - void UnsafeArenaSwap(Int32Value* other); - void Swap(Int32Value* other); friend void swap(Int32Value& a, Int32Value& b) { a.Swap(&b); } + inline void Swap(Int32Value* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Int32Value* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -783,9 +846,11 @@ class PROTOBUF_EXPORT Int32Value : // accessors ------------------------------------------------------- + enum : int { + kValueFieldNumber = 1, + }; // int32 value = 1; void clear_value(); - static const int kValueFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::int32 value() const; void set_value(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -853,11 +918,22 @@ class PROTOBUF_EXPORT UInt32Value : static constexpr int kIndexInFileMessages = 5; - void UnsafeArenaSwap(UInt32Value* other); - void Swap(UInt32Value* other); friend void swap(UInt32Value& a, UInt32Value& b) { a.Swap(&b); } + inline void Swap(UInt32Value* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(UInt32Value* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -924,9 +1000,11 @@ class PROTOBUF_EXPORT UInt32Value : // accessors ------------------------------------------------------- + enum : int { + kValueFieldNumber = 1, + }; // uint32 value = 1; void clear_value(); - static const int kValueFieldNumber = 1; ::PROTOBUF_NAMESPACE_ID::uint32 value() const; void set_value(::PROTOBUF_NAMESPACE_ID::uint32 value); @@ -994,11 +1072,22 @@ class PROTOBUF_EXPORT BoolValue : static constexpr int kIndexInFileMessages = 6; - void UnsafeArenaSwap(BoolValue* other); - void Swap(BoolValue* other); friend void swap(BoolValue& a, BoolValue& b) { a.Swap(&b); } + inline void Swap(BoolValue* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(BoolValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -1065,9 +1154,11 @@ class PROTOBUF_EXPORT BoolValue : // accessors ------------------------------------------------------- + enum : int { + kValueFieldNumber = 1, + }; // bool value = 1; void clear_value(); - static const int kValueFieldNumber = 1; bool value() const; void set_value(bool value); @@ -1135,11 +1226,22 @@ class PROTOBUF_EXPORT StringValue : static constexpr int kIndexInFileMessages = 7; - void UnsafeArenaSwap(StringValue* other); - void Swap(StringValue* other); friend void swap(StringValue& a, StringValue& b) { a.Swap(&b); } + inline void Swap(StringValue* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(StringValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -1206,9 +1308,11 @@ class PROTOBUF_EXPORT StringValue : // accessors ------------------------------------------------------- + enum : int { + kValueFieldNumber = 1, + }; // string value = 1; void clear_value(); - static const int kValueFieldNumber = 1; const std::string& value() const; void set_value(const std::string& value); void set_value(std::string&& value); @@ -1291,11 +1395,22 @@ class PROTOBUF_EXPORT BytesValue : static constexpr int kIndexInFileMessages = 8; - void UnsafeArenaSwap(BytesValue* other); - void Swap(BytesValue* other); friend void swap(BytesValue& a, BytesValue& b) { a.Swap(&b); } + inline void Swap(BytesValue* other) { + if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(BytesValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); + InternalSwap(other); + } // implements Message ---------------------------------------------- @@ -1362,9 +1477,11 @@ class PROTOBUF_EXPORT BytesValue : // accessors ------------------------------------------------------- + enum : int { + kValueFieldNumber = 1, + }; // bytes value = 1; void clear_value(); - static const int kValueFieldNumber = 1; const std::string& value() const; void set_value(const std::string& value); void set_value(std::string&& value); From bb1c0adedf28643cada5689d4bf49be9c819b137 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Wed, 12 Jun 2019 12:32:51 -0700 Subject: [PATCH 45/51] Remove unused fields --- csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs b/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs index 5ed4b53164..9cb6abaf9a 100644 --- a/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs +++ b/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs @@ -41,15 +41,11 @@ namespace Google.Protobuf.Reflection /// public class ExtensionCollection { - private readonly FileDescriptor file; - private readonly MessageDescriptor message; - private IDictionary> extensionsByTypeInDeclarationOrder; private IDictionary> extensionsByTypeInNumberOrder; internal ExtensionCollection(FileDescriptor file, Extension[] extensions) { - this.file = file; UnorderedExtensions = DescriptorUtil.ConvertAndMakeReadOnly( file.Proto.Extension, (extension, i) => new FieldDescriptor(extension, file, null, i, null, extensions?[i])); @@ -57,7 +53,6 @@ namespace Google.Protobuf.Reflection internal ExtensionCollection(MessageDescriptor message, Extension[] extensions) { - this.message = message; UnorderedExtensions = DescriptorUtil.ConvertAndMakeReadOnly( message.Proto.Extension, (extension, i) => new FieldDescriptor(extension, message.File, message, i, null, extensions?[i])); From 997bd354d55de6a8462ac3db0b002aa73b240cff Mon Sep 17 00:00:00 2001 From: Sorah Fukumori Date: Mon, 17 Jun 2019 07:20:18 +0900 Subject: [PATCH 46/51] Fix TypeError on decoding enum map values in Ruby (#6262) value_field_typeclass should be a enum module, not EnumDescriptor object. Also expanding tests for enum valued maps. Fixes #4580 Signed-off-by: Sorah Fukumori --- ruby/ext/google/protobuf_c/encode_decode.c | 3 ++ ruby/tests/basic.rb | 32 +++++++++++++--------- ruby/tests/basic_test.proto | 1 + 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ruby/ext/google/protobuf_c/encode_decode.c b/ruby/ext/google/protobuf_c/encode_decode.c index 4b79368552..40952c6b1b 100644 --- a/ruby/ext/google/protobuf_c/encode_decode.c +++ b/ruby/ext/google/protobuf_c/encode_decode.c @@ -389,6 +389,9 @@ static bool endmap_handler(void *closure, const void *hd, upb_status* s) { if (mapdata->value_field_type == UPB_TYPE_MESSAGE || mapdata->value_field_type == UPB_TYPE_ENUM) { value_field_typeclass = get_def_obj(mapdata->value_field_subdef); + if (mapdata->value_field_type == UPB_TYPE_ENUM) { + value_field_typeclass = EnumDescriptor_enummodule(value_field_typeclass); + } } value = native_slot_get( diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index 591a1c3a6c..9ec738ba61 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -170,10 +170,12 @@ module BasicTest m = MapMessage.new( :map_string_int32 => {"a" => 1, "b" => 2}, :map_string_msg => {"a" => TestMessage2.new(:foo => 1), - "b" => TestMessage2.new(:foo => 2)}) + "b" => TestMessage2.new(:foo => 2)}, + :map_string_enum => {"a" => :A, "b" => :B}) assert m.map_string_int32.keys.sort == ["a", "b"] assert m.map_string_int32["a"] == 1 assert m.map_string_msg["b"].foo == 2 + assert m.map_string_enum["a"] == :A m.map_string_int32["c"] = 3 assert m.map_string_int32["c"] == 3 @@ -206,8 +208,9 @@ module BasicTest m = MapMessage.new( :map_string_int32 => {"a" => 1, "b" => 2}, :map_string_msg => {"a" => TestMessage2.new(:foo => 1), - "b" => TestMessage2.new(:foo => 2)}) - expected = "2, \"a\"=>1}, map_string_msg: {\"b\"=>, \"a\"=>}>" + "b" => TestMessage2.new(:foo => 2)}, + :map_string_enum => {"a" => :A, "b" => :B}) + expected = "2, \"a\"=>1}, map_string_msg: {\"b\"=>, \"a\"=>}, map_string_enum: {\"b\"=>:B, \"a\"=>:A}>" assert_equal expected, m.inspect end @@ -237,7 +240,8 @@ module BasicTest m = MapMessage.new( :map_string_int32 => {"a" => 1, "b" => 2}, :map_string_msg => {"a" => TestMessage2.new(:foo => 1), - "b" => TestMessage2.new(:foo => 2)}) + "b" => TestMessage2.new(:foo => 2)}, + :map_string_enum => {"a" => :A, "b" => :B}) m2 = MapMessage.decode(MapMessage.encode(m)) assert m == m2 @@ -298,10 +302,12 @@ module BasicTest m = MapMessage.new( :map_string_int32 => {"a" => 1, "b" => 2}, :map_string_msg => {"a" => TestMessage2.new(:foo => 1), - "b" => TestMessage2.new(:foo => 2)}) + "b" => TestMessage2.new(:foo => 2)}, + :map_string_enum => {"a" => :A, "b" => :B}) expected_result = { :map_string_int32 => {"a" => 1, "b" => 2}, - :map_string_msg => {"a" => {:foo => 1}, "b" => {:foo => 2}} + :map_string_msg => {"a" => {:foo => 1}, "b" => {:foo => 2}}, + :map_string_enum => {"a" => :A, "b" => :B} } assert_equal expected_result, m.to_h end @@ -311,26 +317,26 @@ module BasicTest # TODO: Fix JSON in JRuby version. return if RUBY_PLATFORM == "java" m = MapMessage.new(:map_string_int32 => {"a" => 1}) - expected = {mapStringInt32: {a: 1}, mapStringMsg: {}} - expected_preserve = {map_string_int32: {a: 1}, map_string_msg: {}} - assert JSON.parse(MapMessage.encode_json(m), :symbolize_names => true) == expected + expected = {mapStringInt32: {a: 1}, mapStringMsg: {}, mapStringEnum: {}} + expected_preserve = {map_string_int32: {a: 1}, map_string_msg: {}, map_string_enum: {}} + assert_equal JSON.parse(MapMessage.encode_json(m), :symbolize_names => true), expected json = MapMessage.encode_json(m, :preserve_proto_fieldnames => true) - assert JSON.parse(json, :symbolize_names => true) == expected_preserve + assert_equal JSON.parse(json, :symbolize_names => true), expected_preserve m2 = MapMessage.decode_json(MapMessage.encode_json(m)) - assert m == m2 + assert_equal m, m2 end def test_json_maps_emit_defaults_submsg # TODO: Fix JSON in JRuby version. return if RUBY_PLATFORM == "java" m = MapMessage.new(:map_string_msg => {"a" => TestMessage2.new}) - expected = {mapStringInt32: {}, mapStringMsg: {a: {foo: 0}}} + expected = {mapStringInt32: {}, mapStringMsg: {a: {foo: 0}}, mapStringEnum: {}} actual = MapMessage.encode_json(m, :emit_defaults => true) - assert JSON.parse(actual, :symbolize_names => true) == expected + assert_equal JSON.parse(actual, :symbolize_names => true), expected end def test_respond_to diff --git a/ruby/tests/basic_test.proto b/ruby/tests/basic_test.proto index 3a5a53284c..e5811dc881 100644 --- a/ruby/tests/basic_test.proto +++ b/ruby/tests/basic_test.proto @@ -80,6 +80,7 @@ message Recursive2 { message MapMessage { map map_string_int32 = 1; map map_string_msg = 2; + map map_string_enum = 3; } message MapMessageWireEquiv { From abb4fb00408eff18c92bef388d963ad163f94e7f Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 17 Jun 2019 13:13:54 -0700 Subject: [PATCH 47/51] Change offset of Timestamp conformance test to distinguish from the default (#6263) Fixes #4079 --- conformance/binary_json_conformance_suite.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc index 0995d3563a..5ddb3a90bd 100644 --- a/conformance/binary_json_conformance_suite.cc +++ b/conformance/binary_json_conformance_suite.cc @@ -1980,12 +1980,12 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() { "repeated_timestamp: {seconds: 253402300799 nanos: 999999999}"); RunValidJsonTest( "TimestampWithPositiveOffset", REQUIRED, - R"({"optionalTimestamp": "1970-01-01T08:00:00+08:00"})", - "optional_timestamp: {seconds: 0}"); + R"({"optionalTimestamp": "1970-01-01T08:00:01+08:00"})", + "optional_timestamp: {seconds: 1}"); RunValidJsonTest( "TimestampWithNegativeOffset", REQUIRED, - R"({"optionalTimestamp": "1969-12-31T16:00:00-08:00"})", - "optional_timestamp: {seconds: 0}"); + R"({"optionalTimestamp": "1969-12-31T16:00:01-08:00"})", + "optional_timestamp: {seconds: 1}"); RunValidJsonTest( "TimestampNull", REQUIRED, R"({"optionalTimestamp": null})", From 8ccdc44dde33eed7f02fc40f2d2b51576cdd7d71 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Mon, 17 Jun 2019 13:20:44 -0700 Subject: [PATCH 48/51] Update GSON version --- java/util/pom.xml | 268 +++++++++++++++++++++++----------------------- 1 file changed, 134 insertions(+), 134 deletions(-) diff --git a/java/util/pom.xml b/java/util/pom.xml index 657f9fe91f..5bb4bafae8 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -1,139 +1,139 @@ - - - 4.0.0 - - com.google.protobuf - protobuf-parent - 3.8.0 - - - protobuf-java-util - bundle - - Protocol Buffers [Util] - Utilities for Protocol Buffers - - - - ${project.groupId} - protobuf-java - - - com.google.guava - guava - - - com.google.errorprone - error_prone_annotations - 2.3.2 - - - com.google.guava - guava-testlib - test - - - com.google.code.gson - gson - 2.7 - - - junit - junit - - - org.easymock - easymock - - - org.easymock - easymockclassextension - + + + 4.0.0 + + com.google.protobuf + protobuf-parent + 3.8.0 + + + protobuf-java-util + bundle + + Protocol Buffers [Util] + Utilities for Protocol Buffers + + + + ${project.groupId} + protobuf-java + + + com.google.guava + guava + + + com.google.errorprone + error_prone_annotations + 2.3.2 + + + com.google.guava + guava-testlib + test + + + com.google.code.gson + gson + 2.8.5 + + + junit + junit + + + org.easymock + easymock + + + org.easymock + easymockclassextension + com.google.truth truth test - - - - - ../core/src/test/proto - - - - - - maven-antrun-plugin - - - - generate-test-sources - generate-test-sources - - - - - - - - - - - - - - - - run - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-generated-test-sources - generate-test-sources - - add-test-source - - - - ${generated.testsources.dir} - - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - https://developers.google.com/protocol-buffers/ - com.google.protobuf.util - com.google.protobuf.util;version=${project.version} - - - - - - - maven-assembly-plugin - - - jar-with-dependencies - - - - - - + + + + + ../core/src/test/proto + + + + + + maven-antrun-plugin + + + + generate-test-sources + generate-test-sources + + + + + + + + + + + + + + + + run + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-generated-test-sources + generate-test-sources + + add-test-source + + + + ${generated.testsources.dir} + + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + https://developers.google.com/protocol-buffers/ + com.google.protobuf.util + com.google.protobuf.util;version=${project.version} + + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + + + + + From f98b3401bf731786d8e990d203b060186ff1f634 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 18 Jun 2019 00:45:53 -0700 Subject: [PATCH 49/51] Removed all use of STLDelete*() in ObjC and C# Generators. Other languages will have this removed inside Google first. These functions are subject to ADL and cause problems. --- .../csharp/csharp_bootstrap_unittest.cc | 22 ++- .../compiler/objectivec/objectivec_file.cc | 67 ++++----- .../compiler/objectivec/objectivec_file.h | 6 +- .../compiler/objectivec/objectivec_message.cc | 127 ++++++------------ .../compiler/objectivec/objectivec_message.h | 8 +- 5 files changed, 83 insertions(+), 147 deletions(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc b/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc index 33c5619843..978fdf02b6 100644 --- a/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc +++ b/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc @@ -77,23 +77,19 @@ class MockErrorCollector : public MultiFileErrorCollector { class MockGeneratorContext : public GeneratorContext { public: - MockGeneratorContext() {} - ~MockGeneratorContext() { - STLDeleteValues(&files_); - } - void ExpectFileMatches(const string& virtual_filename, const string& physical_filename) { - string* expected_contents = FindPtrOrNull(files_, virtual_filename); - ASSERT_TRUE(expected_contents != NULL) + auto it = files_.find(virtual_filename); + ASSERT_TRUE(it != files_.end()) << "Generator failed to generate file: " << virtual_filename; + string expected_contents = *it->second; string actual_contents; GOOGLE_CHECK_OK( File::GetContentsAsText(TestSourceDir() + "/" + physical_filename, &actual_contents, true)) << "Unable to get " << physical_filename; - EXPECT_TRUE(actual_contents == *expected_contents) + EXPECT_TRUE(actual_contents == expected_contents) << physical_filename << " needs to be regenerated. Please run " "generate_descriptor_proto.sh. Then add this file " "to your CL."; @@ -102,15 +98,13 @@ class MockGeneratorContext : public GeneratorContext { // implements GeneratorContext -------------------------------------- virtual io::ZeroCopyOutputStream* Open(const string& filename) { - string** map_slot = &files_[filename]; - delete *map_slot; - *map_slot = new string; - - return new io::StringOutputStream(*map_slot); + auto& map_slot = files_[filename]; + map_slot.reset(new std::string); + return new io::StringOutputStream(map_slot.get()); } private: - std::map files_; + std::map> files_; }; class GenerateAndTest { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc index d4a4d708f1..7bc585e9ba 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc @@ -192,27 +192,21 @@ FileGenerator::FileGenerator(const FileDescriptor *file, const Options& options) options_(options) { for (int i = 0; i < file_->enum_type_count(); i++) { EnumGenerator *generator = new EnumGenerator(file_->enum_type(i)); - enum_generators_.push_back(generator); + enum_generators_.emplace_back(generator); } for (int i = 0; i < file_->message_type_count(); i++) { MessageGenerator *generator = new MessageGenerator(root_class_name_, file_->message_type(i), options_); - message_generators_.push_back(generator); + message_generators_.emplace_back(generator); } for (int i = 0; i < file_->extension_count(); i++) { ExtensionGenerator *generator = new ExtensionGenerator(root_class_name_, file_->extension(i)); - extension_generators_.push_back(generator); + extension_generators_.emplace_back(generator); } } -FileGenerator::~FileGenerator() { - STLDeleteContainerPointers(enum_generators_.begin(), enum_generators_.end()); - STLDeleteContainerPointers(message_generators_.begin(), - message_generators_.end()); - STLDeleteContainerPointers(extension_generators_.begin(), - extension_generators_.end()); -} +FileGenerator::~FileGenerator() {} void FileGenerator::GenerateHeader(io::Printer *printer) { std::set headers; @@ -270,9 +264,8 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { "\n"); std::set fwd_decls; - for (std::vector::iterator iter = message_generators_.begin(); - iter != message_generators_.end(); ++iter) { - (*iter)->DetermineForwardDeclarations(&fwd_decls); + for (const auto& generator : message_generators_) { + generator->DetermineForwardDeclarations(&fwd_decls); } for (std::set::const_iterator i(fwd_decls.begin()); i != fwd_decls.end(); ++i) { @@ -287,14 +280,12 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { "\n"); // need to write out all enums first - for (std::vector::iterator iter = enum_generators_.begin(); - iter != enum_generators_.end(); ++iter) { - (*iter)->GenerateHeader(printer); + for (const auto& generator : enum_generators_) { + generator->GenerateHeader(printer); } - for (std::vector::iterator iter = message_generators_.begin(); - iter != message_generators_.end(); ++iter) { - (*iter)->GenerateEnumHeader(printer); + for (const auto& generator : message_generators_) { + generator->GenerateEnumHeader(printer); } // For extensions to chain together, the Root gets created even if there @@ -323,18 +314,15 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { "@interface $root_class_name$ (DynamicMethods)\n", "root_class_name", root_class_name_); - for (std::vector::iterator iter = - extension_generators_.begin(); - iter != extension_generators_.end(); ++iter) { - (*iter)->GenerateMembersHeader(printer); + for (const auto& generator : extension_generators_) { + generator->GenerateMembersHeader(printer); } printer->Print("@end\n\n"); } // extension_generators_.size() > 0 - for (std::vector::iterator iter = message_generators_.begin(); - iter != message_generators_.end(); ++iter) { - (*iter)->GenerateMessageHeader(printer); + for (const auto& generator : message_generators_) { + generator->GenerateMessageHeader(printer); } printer->Print( @@ -403,9 +391,8 @@ void FileGenerator::GenerateSource(io::Printer *printer) { } bool includes_oneof = false; - for (std::vector::iterator iter = message_generators_.begin(); - iter != message_generators_.end(); ++iter) { - if ((*iter)->IncludesOneOfDefinition()) { + for (const auto& generator : message_generators_) { + if (generator->IncludesOneOfDefinition()) { includes_oneof = true; break; } @@ -456,15 +443,11 @@ void FileGenerator::GenerateSource(io::Printer *printer) { printer->Print( "static GPBExtensionDescription descriptions[] = {\n"); printer->Indent(); - for (std::vector::iterator iter = - extension_generators_.begin(); - iter != extension_generators_.end(); ++iter) { - (*iter)->GenerateStaticVariablesInitialization(printer); + for (const auto& generator : extension_generators_) { + generator->GenerateStaticVariablesInitialization(printer); } - for (std::vector::iterator iter = - message_generators_.begin(); - iter != message_generators_.end(); ++iter) { - (*iter)->GenerateStaticVariablesInitialization(printer); + for (const auto& generator : message_generators_) { + generator->GenerateStaticVariablesInitialization(printer); } printer->Outdent(); printer->Print( @@ -561,13 +544,11 @@ void FileGenerator::GenerateSource(io::Printer *printer) { "\n"); } - for (std::vector::iterator iter = enum_generators_.begin(); - iter != enum_generators_.end(); ++iter) { - (*iter)->GenerateSource(printer); + for (const auto& generator : enum_generators_) { + generator->GenerateSource(printer); } - for (std::vector::iterator iter = message_generators_.begin(); - iter != message_generators_.end(); ++iter) { - (*iter)->GenerateSource(printer); + for (const auto& generator : message_generators_) { + generator->GenerateSource(printer); } printer->Print( diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.h b/src/google/protobuf/compiler/objectivec/objectivec_file.h index ed7fad80a5..fd57263484 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.h @@ -65,9 +65,9 @@ class FileGenerator { string root_class_name_; bool is_bundled_proto_; - std::vector enum_generators_; - std::vector message_generators_; - std::vector extension_generators_; + std::vector> enum_generators_; + std::vector> message_generators_; + std::vector> extension_generators_; const Options options_; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc index a9e845397b..6731e37a77 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc @@ -184,18 +184,18 @@ MessageGenerator::MessageGenerator(const string& root_classname, GetOptionalDeprecatedAttribute(descriptor, descriptor->file(), false, true)) { for (int i = 0; i < descriptor_->extension_count(); i++) { - extension_generators_.push_back( + extension_generators_.emplace_back( new ExtensionGenerator(class_name_, descriptor_->extension(i))); } for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { OneofGenerator* generator = new OneofGenerator(descriptor_->oneof_decl(i)); - oneof_generators_.push_back(generator); + oneof_generators_.emplace_back(generator); } for (int i = 0; i < descriptor_->enum_type_count(); i++) { EnumGenerator* generator = new EnumGenerator(descriptor_->enum_type(i)); - enum_generators_.push_back(generator); + enum_generators_.emplace_back(generator); } for (int i = 0; i < descriptor_->nested_type_count(); i++) { @@ -203,32 +203,20 @@ MessageGenerator::MessageGenerator(const string& root_classname, new MessageGenerator(root_classname_, descriptor_->nested_type(i), options); - nested_message_generators_.push_back(generator); + nested_message_generators_.emplace_back(generator); } } -MessageGenerator::~MessageGenerator() { - STLDeleteContainerPointers(extension_generators_.begin(), - extension_generators_.end()); - STLDeleteContainerPointers(enum_generators_.begin(), enum_generators_.end()); - STLDeleteContainerPointers(nested_message_generators_.begin(), - nested_message_generators_.end()); - STLDeleteContainerPointers(oneof_generators_.begin(), - oneof_generators_.end()); -} +MessageGenerator::~MessageGenerator() {} void MessageGenerator::GenerateStaticVariablesInitialization( io::Printer* printer) { - for (std::vector::iterator iter = - extension_generators_.begin(); - iter != extension_generators_.end(); ++iter) { - (*iter)->GenerateStaticVariablesInitialization(printer); + for (const auto& generator : extension_generators_) { + generator->GenerateStaticVariablesInitialization(printer); } - for (std::vector::iterator iter = - nested_message_generators_.begin(); - iter != nested_message_generators_.end(); ++iter) { - (*iter)->GenerateStaticVariablesInitialization(printer); + for (const auto& generator : nested_message_generators_) { + generator->GenerateStaticVariablesInitialization(printer); } } @@ -241,10 +229,8 @@ void MessageGenerator::DetermineForwardDeclarations(std::set* fwd_decls) } } - for (std::vector::iterator iter = - nested_message_generators_.begin(); - iter != nested_message_generators_.end(); ++iter) { - (*iter)->DetermineForwardDeclarations(fwd_decls); + for (const auto& generator : nested_message_generators_) { + generator->DetermineForwardDeclarations(fwd_decls); } } @@ -253,10 +239,8 @@ bool MessageGenerator::IncludesOneOfDefinition() const { return true; } - for (std::vector::const_iterator iter = - nested_message_generators_.begin(); - iter != nested_message_generators_.end(); ++iter) { - if ((*iter)->IncludesOneOfDefinition()) { + for (const auto& generator : nested_message_generators_) { + if (generator->IncludesOneOfDefinition()) { return true; } } @@ -265,40 +249,31 @@ bool MessageGenerator::IncludesOneOfDefinition() const { } void MessageGenerator::GenerateEnumHeader(io::Printer* printer) { - for (std::vector::iterator iter = enum_generators_.begin(); - iter != enum_generators_.end(); ++iter) { - (*iter)->GenerateHeader(printer); + for (const auto& generator : enum_generators_) { + generator->GenerateHeader(printer); } - for (std::vector::iterator iter = - nested_message_generators_.begin(); - iter != nested_message_generators_.end(); ++iter) { - (*iter)->GenerateEnumHeader(printer); + for (const auto& generator : nested_message_generators_) { + generator->GenerateEnumHeader(printer); } } void MessageGenerator::GenerateExtensionRegistrationSource( io::Printer* printer) { - for (std::vector::iterator iter = - extension_generators_.begin(); - iter != extension_generators_.end(); ++iter) { - (*iter)->GenerateRegistrationSource(printer); + for (const auto& generator : extension_generators_) { + generator->GenerateRegistrationSource(printer); } - for (std::vector::iterator iter = - nested_message_generators_.begin(); - iter != nested_message_generators_.end(); ++iter) { - (*iter)->GenerateExtensionRegistrationSource(printer); + for (const auto& generator : nested_message_generators_) { + generator->GenerateExtensionRegistrationSource(printer); } } void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { // This a a map entry message, just recurse and do nothing directly. if (IsMapEntryMessage(descriptor_)) { - for (std::vector::iterator iter = - nested_message_generators_.begin(); - iter != nested_message_generators_.end(); ++iter) { - (*iter)->GenerateMessageHeader(printer); + for (const auto& generator : nested_message_generators_) { + generator->GenerateMessageHeader(printer); } return; } @@ -325,9 +300,8 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { printer->Print("};\n\n"); } - for (std::vector::iterator iter = oneof_generators_.begin(); - iter != oneof_generators_.end(); ++iter) { - (*iter)->GenerateCaseEnum(printer); + for (const auto& generator : oneof_generators_) { + generator->GenerateCaseEnum(printer); } string message_comments; @@ -366,9 +340,8 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { } if (!oneof_generators_.empty()) { - for (std::vector::iterator iter = oneof_generators_.begin(); - iter != oneof_generators_.end(); ++iter) { - (*iter)->GenerateClearFunctionDeclaration(printer); + for (const auto& generator : oneof_generators_) { + generator->GenerateClearFunctionDeclaration(printer); } printer->Print("\n"); } @@ -376,18 +349,14 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { if (descriptor_->extension_count() > 0) { printer->Print("@interface $classname$ (DynamicMethods)\n\n", "classname", class_name_); - for (std::vector::iterator iter = - extension_generators_.begin(); - iter != extension_generators_.end(); ++iter) { - (*iter)->GenerateMembersHeader(printer); + for (const auto& generator : extension_generators_) { + generator->GenerateMembersHeader(printer); } printer->Print("@end\n\n"); } - for (std::vector::iterator iter = - nested_message_generators_.begin(); - iter != nested_message_generators_.end(); ++iter) { - (*iter)->GenerateMessageHeader(printer); + for (const auto& generator : nested_message_generators_) { + generator->GenerateMessageHeader(printer); } } @@ -409,9 +378,8 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { printer->Print("@implementation $classname$\n\n", "classname", class_name_); - for (std::vector::iterator iter = oneof_generators_.begin(); - iter != oneof_generators_.end(); ++iter) { - (*iter)->GeneratePropertyImplementation(printer); + for (const auto& generator : oneof_generators_) { + generator->GeneratePropertyImplementation(printer); } for (int i = 0; i < descriptor_->field_count(); i++) { @@ -447,9 +415,8 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { sizeof_has_storage = 1; } // Tell all the fields the oneof base. - for (std::vector::iterator iter = oneof_generators_.begin(); - iter != oneof_generators_.end(); ++iter) { - (*iter)->SetOneofIndexBase(sizeof_has_storage); + for (const auto& generator : oneof_generators_) { + generator->SetOneofIndexBase(sizeof_has_storage); } field_generators_.SetOneofIndexBase(sizeof_has_storage); // sizeof_has_storage needs enough bits for the single fields that aren't in @@ -547,11 +514,9 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { if (oneof_generators_.size() != 0) { printer->Print( " static const char *oneofs[] = {\n"); - for (std::vector::iterator iter = oneof_generators_.begin(); - iter != oneof_generators_.end(); ++iter) { - printer->Print( - " \"$name$\",\n", - "name", (*iter)->DescriptorName()); + for (const auto& generator : oneof_generators_) { + printer->Print(" \"$name$\",\n", "name", + generator->DescriptorName()); } printer->Print( " };\n" @@ -624,21 +589,17 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { .GenerateCFunctionImplementations(printer); } - for (std::vector::iterator iter = oneof_generators_.begin(); - iter != oneof_generators_.end(); ++iter) { - (*iter)->GenerateClearFunctionImplementation(printer); + for (const auto& generator : oneof_generators_) { + generator->GenerateClearFunctionImplementation(printer); } } - for (std::vector::iterator iter = enum_generators_.begin(); - iter != enum_generators_.end(); ++iter) { - (*iter)->GenerateSource(printer); + for (const auto& generator : enum_generators_) { + generator->GenerateSource(printer); } - for (std::vector::iterator iter = - nested_message_generators_.begin(); - iter != nested_message_generators_.end(); ++iter) { - (*iter)->GenerateSource(printer); + for (const auto& generator : nested_message_generators_) { + generator->GenerateSource(printer); } } diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.h b/src/google/protobuf/compiler/objectivec/objectivec_message.h index 1d41628f68..55eda0b8ef 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.h @@ -85,10 +85,10 @@ class MessageGenerator { FieldGeneratorMap field_generators_; const string class_name_; const string deprecated_attribute_; - std::vector extension_generators_; - std::vector enum_generators_; - std::vector nested_message_generators_; - std::vector oneof_generators_; + std::vector> extension_generators_; + std::vector> enum_generators_; + std::vector> nested_message_generators_; + std::vector> oneof_generators_; }; } // namespace objectivec From 43307d4da09e1a27b132cd3a2c29824efaafef25 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Tue, 18 Jun 2019 19:31:50 +0200 Subject: [PATCH 50/51] php: Fix formatting of Duration (#6155) * php: Fixed php notices for unknown enum indices * php: Fixed formatting of Duration This fixes: * Missing nanoseconds. The nanoseconds where divided as a float and implicitly converted to a string before being passed to bcadd. This can result in a float formatted in scientific/exponential notation, which bcmath doesn't understand. * Durations are supposed to be formatted without trailing zeroes. --- conformance/failure_list_php.txt | 4 --- .../Protobuf/Internal/EnumDescriptor.php | 15 ++++++++--- php/src/Google/Protobuf/Internal/GPBUtil.php | 26 ++++++++++++++----- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/conformance/failure_list_php.txt b/conformance/failure_list_php.txt index f76e9d731f..28ca461d47 100644 --- a/conformance/failure_list_php.txt +++ b/conformance/failure_list_php.txt @@ -3,10 +3,6 @@ Recommended.FieldMaskPathsDontRoundTrip.JsonOutput Recommended.FieldMaskTooManyUnderscore.JsonOutput Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput -Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator -Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator -Recommended.Proto3.JsonInput.DurationHas9FractionalDigits.Validator -Recommended.Proto3.JsonInput.DurationHasZeroFractionalDigit.Validator Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter Required.Proto3.JsonInput.FloatFieldTooLarge Required.Proto3.JsonInput.FloatFieldTooSmall diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptor.php b/php/src/Google/Protobuf/Internal/EnumDescriptor.php index 82a427670c..7af4f84012 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptor.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptor.php @@ -39,17 +39,26 @@ class EnumDescriptor public function getValueByNumber($number) { - return $this->value[$number]; + if (isset($this->value[$number])) { + return $this->value[$number]; + } + return null; } public function getValueByName($name) { - return $this->name_to_value[$name]; + if (isset($this->name_to_value[$name])) { + return $this->name_to_value[$name]; + } + return null; } public function getValueDescriptorByIndex($index) { - return $this->value_descriptor[$index]; + if (isset($this->value_descriptor[$index])) { + return $this->value_descriptor[$index]; + } + return null; } public function getValueCount() diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php index 0beedba333..7ec3ca2294 100644 --- a/php/src/Google/Protobuf/Internal/GPBUtil.php +++ b/php/src/Google/Protobuf/Internal/GPBUtil.php @@ -504,17 +504,29 @@ class GPBUtil public static function formatDuration($value) { - if (bccomp($value->getSeconds(), "315576000001") != -1) { - throw new GPBDecodeException("Duration number too large."); + if (bccomp($value->getSeconds(), '315576000001') != -1) { + throw new GPBDecodeException('Duration number too large.'); } - if (bccomp($value->getSeconds(), "-315576000001") != 1) { - throw new GPBDecodeException("Duration number too small."); + if (bccomp($value->getSeconds(), '-315576000001') != 1) { + throw new GPBDecodeException('Duration number too small.'); + } + + $nanos = $value->getNanos(); + if ($nanos === 0) { + return (string) $value->getSeconds(); } - return strval(bcadd($value->getSeconds(), - $value->getNanos() / 1000000000.0, 9)); - } + if ($nanos % 1000000 === 0) { + $digits = 3; + } elseif ($nanos % 1000 === 0) { + $digits = 6; + } else { + $digits = 9; + } + $nanos = bcdiv($nanos, '1000000000', $digits); + return bcadd($value->getSeconds(), $nanos, $digits); + } public static function parseFieldMask($paths_string) { From 7f84a943667358a53bd5d255ee9769ca83e75cd9 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Tue, 18 Jun 2019 17:12:55 -0700 Subject: [PATCH 51/51] Make php message class final to avoid mocking (#6277) * Make php message class final Because proto messages are just data object, they should not be mocked. Explicitly make them final to avoid accidental usage. * Update generated descriptors --- csharp/src/Google.Protobuf.Test/testprotos.pb | Bin 205207 -> 205207 bytes .../Protobuf/Internal/DescriptorProto.php | 2 +- .../DescriptorProto/ExtensionRange.php | 2 +- .../DescriptorProto/ReservedRange.php | 2 +- .../Protobuf/Internal/EnumDescriptorProto.php | 2 +- .../EnumDescriptorProto/EnumReservedRange.php | 2 +- .../Google/Protobuf/Internal/EnumOptions.php | 2 +- .../Internal/EnumValueDescriptorProto.php | 2 +- .../Protobuf/Internal/EnumValueOptions.php | 2 +- .../Internal/ExtensionRangeOptions.php | 2 +- .../Internal/FieldDescriptorProto.php | 2 +- .../Google/Protobuf/Internal/FieldOptions.php | 2 +- .../Protobuf/Internal/FileDescriptorProto.php | 2 +- .../Protobuf/Internal/FileDescriptorSet.php | 2 +- .../Google/Protobuf/Internal/FileOptions.php | 2 +- .../Protobuf/Internal/GeneratedCodeInfo.php | 2 +- .../Internal/GeneratedCodeInfo/Annotation.php | 2 +- .../Protobuf/Internal/MessageOptions.php | 2 +- .../Internal/MethodDescriptorProto.php | 2 +- .../Protobuf/Internal/MethodOptions.php | 2 +- .../Internal/OneofDescriptorProto.php | 2 +- .../Google/Protobuf/Internal/OneofOptions.php | 2 +- .../Internal/ServiceDescriptorProto.php | 2 +- .../Protobuf/Internal/ServiceOptions.php | 2 +- .../Protobuf/Internal/SourceCodeInfo.php | 2 +- .../Internal/SourceCodeInfo/Location.php | 2 +- .../Protobuf/Internal/UninterpretedOption.php | 2 +- .../Internal/UninterpretedOption/NamePart.php | 2 +- .../protobuf/compiler/php/php_generator.cc | 2 +- 29 files changed, 28 insertions(+), 28 deletions(-) diff --git a/csharp/src/Google.Protobuf.Test/testprotos.pb b/csharp/src/Google.Protobuf.Test/testprotos.pb index bc3979e965ef354b8491b637c3ca441bb1050365..71256aea778e8a7f1d74a709e2c84ab3acef5727 100644 GIT binary patch delta 5317 zcmYjVYiv}<72dgbX6)R3c=vjF`GFT>8?Z?+k2Xa>QwT_fD5Ponkn9LmA*P{fOTwdV zDm5z;OiKD=Ra$bR$T1O?s{jGjDrl?xNPfgn>RE@2|Otb`@zvtDm~ zJ$rp^uWdO_)DhgVlG5e9c6h#lj9|@518ss|TkX8b9Gg4B}p2sRd@_m$SoViXRZWa&~-?fwakPY%;Kv;L>#lmJobmtuw|{ z2<#p3)-!a{(&UG1M$*s>5HZ`U-NRRqY}jmw<(rK$kV6WL2k zS*^WhB8Xrk!bA|kMuZ7FK2LMlw8^fjcIt3=VI1CFuc?_eEWK-oBfg6|wPJ`m6s*xZ zro3M_vjtz73U*MNiXnC=_^e8kyL{UAKHJQ;YzSLiAuUcoh;!PA6A(nxMx201cACW5 zLZMOD1N-;4zWn~yuz=1U7=Z#|8=x;xK*WDQ0wtYAT=~!rUFW{eBJg}@mnNNV3%Nxs z@U&+iE@$;D-OhDZup+B=9*(Pq0Af=+Ps}zDS+(zT?Q{pe7jsrXz1C{TKy$3mu z796PWFq8%c>^R7Al4b|+Z#bV-a3Hqde){poYi@Ib^aMRJl>!)>M0}*pI>QSg{{)kM|b*7W5SRQMEnfH$fvXLUr_I2UoLKWouth zJl)E^pn-HN`*=L5%cEP_$LE+{*eJe_&ucWRD87%^Eph%qgC%0&3iW%(zRCXC(jNri z2+$t{pqtds^Nk9-5vUD0)eR*;*=GnnG$v75D(qr%>M>P;X1@IRH(ctX>XXydwK)@ z##s%UA^}n4uqhG{8;4DifGBd<6d6U4H&v0(M5)M|rbr-c1N4goL~1vwNJ=f{%FlV| zz8-fmcz(`H%bg!0vlwMI;x%nzFRmLgIl+iPBj#WMv1NqED^(i+k<$pDU*n9B_F{Bt z$GrYc?C&jO0R>Hmv4DbZN39qDb-G##tpnKVrYM0S&==`j>?Pc?mOjGBJW zG#v=r0R5%|BH%sK^fFgY^U!|be`CtvIn7JwI{&7Yl~LDcyhGn&4_anSQZORYjA

*7bo`Cd9|chuN`GWZ$11s+(g6|Wktw|l z3AGElRNg0BnAqGd^rb3Or33n<1ETbHq4gGb0xFH*<#i{g6Hu^Lh zW~~{aKd-PNR7U8J2_QCQgdSCZ$SNbMYm@*1QF}(DmK%uLGoqW-_r0sXoGQTGv3cfytLh|pPG zcLLn+h|*ckAl03qy1TP`wz53i)@>4k6;ZlP-GJECZR!R@LfxirK-ArB>IOvJ-BkA^ zi7G+wiVuYKp?Cb-Y~ra8M9CcW$%ma{9~Znzec=^G7#QXR2Gns}R8-;#D2a)hc)}Zg zjy2St5WKwLM<2iwV)h*83GD}b(p&f)wmN-M@L0i*?%qj}aMiat0XBI`Sf@pUIx%3J z3Jm_w5kQ>EDG~PP3m}4@5>@`|2@p*^-q5T z0OIrpap>0fn$yQB;`9oA`hbYjYfe9bb2+1=zbZku{)~|T5VisO5&%TRGbDlE+L*Pj zD?b*Yf$V>uXK%6ck40&v^EV5py=GmWS;q0dtt^tL2Y>ic=& z&JPSAJuep2s*j;dXw1VnEyh;X@C1=j_U^j|Mn1=9tAms}@F)m4xB zi{9uDSXcUDz(E;Z6#6yjs(daAw^mb<4lauN2AvJso)gv*y+|hwXtJT7RJnkOPC6&t zI^ztcoLID&n9|4w@RG0=>s1?6fQE`*X_th4_`?@emqcQraaMa97U`t0^|G+cBK@!d zG)(jyyBs7%&#}uQjegVX0zCoM<)GVez9KABJRArbDtdWc36i3h*AS~acdSnTAflf+2vP50IbAv(M<#^z|C|RzmL0MtrDjAq-H(IP8j}96B4BtQ zl(;2tl;D~GQ;@Fg|F*LZ`{geD_)#)dc2v+Mqi$fp)-GA@k2mFkP+bz^jijy&7$RM= zs>z8vrP=^Jb;;^RXTZ|oK+==_@<;5uEZtKaj#S!H9FFcyPjNU>YEN-Enpr)?;aDlc z^-#E;hz?cKR!rz*THwPWW`yrX;A>Wx_TJ4*y4#5<<5%Ag36 zHLA19fF$n7+J(+9bOb~k_p0`?*EWq8Gm)6ai_0M~jmz@61tt>DxWoV-Hl2ZC%Db_b leYR?{{gyel28Bu delta 5317 zcmYjVYiv}<72dgbX6)R3c=vjF`GFT>8?Z?+k2Xa>69`C!D5Ponkn9LmA*P{fOTwdV zDm80rBbrolgi3p*7}MZ7N_a_@KwafWlpls7*Nd@>{J;njBAg=QVhnOips4-M+?l=m z&)=Cd-+9b8=g!*eiFiGc?i0i8{+W}*YwBgjW-GR)ylKh4^``pH) z)^^*L<3t_79V;na-ff5H8^{P&tTfOj_>I-hLFU-p5iURLJ*sAJr_b8axxSAGVGCfw zK#Sn4xlWjNJmK=c+E&boI2<5EC>-@YpP-HT5E~VYI2I4P@?$&nmCY1Q7@i;7g|nSe z0iLiGLR#63T*St##;mCYX5^Q(!$pc85WBK=e35~)$*!$4u#n)=bp{p?d}^(8o2d}k zJLs*cW&dg%3<59&7z_e1aA zb?k2AND#n6fRP}8g#aUVyhKx22ry!o`)3ulECd*_E9%WE0*u(T%bfS6ssPS+GW|1(5Wz--J3#~+5$@RWd78tfO?FwiQ-#9|0LV<@m z?fs^nE%@4Wu!Gu^53xhR7gU_2=q`Gc)t0i8WC0tLc0KwqGMi2r~DN;-?U@{t`H=DyA%@O)$!CY`@n$Sq=l zr#bWA<*b^eo4L*kR%F%8!*SIRKx}H}iP;7st7bmWKQpZ2keYevlV%l%)XZy^Ixz~s zL$2J1CmU*^QMpBF@&3P;j1WzfQTQHl5dN>-l6pN>=H6!=T1qlHIfpz?jO_W!0R%@oFD=t; zBl>!R#$l}-;crXSiT={m-i0*7IfwNQMFysEF!GbLa(988;0Yrdat_KSs0`zhWmZudzn6loN>)HB-Y``zb8t@D7XM+L+ z__KVDKV>480DqR3_>&kA{8?UI>(D@mkPZgC{TtYeYX<^;Nmi~uQ}6-*0N0->K=2Q6 zJqaR6f05eZ`Tmr9r|nnfhiy2loh0z5_RP$4_)WX{{}|kI?6FrsJtj?Z;Z-&ZUg?t zS&f+@0a4_bDH0GH$4rrcD00jc8AXxTRFTg|smN=lNFZzj^os;UYS*YpN-gHf&w1#+ z9(OT#e$ESvogX2y7-e?TtJ}n0S$EUq1S107GzSZaEjM|*RJ8#RIo;&*E1YrCUW_j7 zg!lJN?4J!20R>HmiGYG`?Pc?mOjGBJW zG#v=r0R5%|BH%sK^deWz@X&tYe`AW^Il~L*I{%@T6;an8dT)Q5ebw;LBn2ZPJv1!? z#GZ$yWq>w8eO&?3vWKQ+fN0r6Y8jPYMD;xOOUK_R{c#Y5q4dY5bgYuADIE||9-GpO zkWjOrOXYpKg^A70LSL#PRXU(wIv`4K7Fus{SGI`IA9d+*1ZWX>#$BQ(J=s{N2qZ;SN+ zDE?3ohKfHV^hCj`^3@Xs5Md4pJyGJw=&;xSJbQWbVN-Wp)eY#^4T!oAo4OOO^hD^a zt~&v4PZZ8_hN;oaWQ+2^OW`jKH)9=E?b>GA$Tn3M|bapNVw|ToB*3VC9Kn;Mx7Wi zP6Y=4=LjH9<&+5f^92yWPl+=B^#q6}oD%i^XCDwvI4xwgp+XZ*i$qmKoqmD>cl)Qm z0RVBjgE(~SyUpoi6>++SK7ByM={BdIz`2}J(qEOJTYtt#00`RveF*>};u(^_?`_Ol z*Oi}$&|v2AOY9w1{D~+mb^7QP<=Qx%9%210^WOK_7MAW24mC&80v*pe!7Ekw6h_)G zL;?e{IVYn2IVcb0a84x40}mvBPNWv(IN@+!@P#=CYB>y=GmWS;q0dtt^tL2Y>ic=& z&JPSAJuenis*j;dXw1VnEyh;Xr41=j_U^j|Mn1=9tAm)sGOs;eIL zecqQpWJl9|0S9H&C-iI3Rr&M@w^CD*4*EoOjm`#b&kAdaUZj%-G}+Kks%*eSC!G~; zm2n1BRxDafOlf2Tcu`o3^{NdjKtn~Zw2MMN{NW3#iz2bmIIF!ii*!=h+Al1#NIz@< z4HG@b`h%qCIo2=I=r_GC&=XMg2i=DAC1IK3;Xu$((aY;nkQBYVE{TLW8hUwMA~DeG z(^YRPVfl9t2uuS3(@F`dfgmgO$P(@Xos@cHiK=R6j6vPSc;txC6>n7oyAmIzq5j(h zLKKrUS~KO1thI1ktJGP-3Qe?1tqDM6*(#I%a~=>`w#tf>ni0ixKMqK1RQkV)fZ=^W z;+C`&;FZUHRc?W_9I;xdipplDL~kkliAN+OL9 z$z)ZoMw0cAgvx2mkO%OvPH; z+0~-!vT&aBD~K*hdbr_b-eAApcEe~6MriJa49`;f1w^nLa(2oOTNpoLF z>z>veFucEzPSSaop=ZDpW88apH#?LbH$^EkiW)Z>PzLNAHyTg|L>f05PzGpV+-Sfz z;K;{G125=c;J77uRmsz-&9657eDBU3J5}LLsU16i>iu~STfGs>erJh*gm}wzRv8pQ zvO;xM8IZ&+S-H^prH+7zlU~_g_U5L^d?pgpWPUj$rb$^mH^)TcnUomdS50SNnD)l@ lvTLiR^QlNf)A>}Sp=nt>J4Z!7Y^M+2-p4Yx_gSY-{vX!_kkSAE diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php index 3b215d52ae..2d52831451 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php @@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.DescriptorProto */ -class DescriptorProto extends \Google\Protobuf\Internal\Message +final class DescriptorProto extends \Google\Protobuf\Internal\Message { /** * Generated from protobuf field optional string name = 1; diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php index a2057fd5d1..fb98f7d5a0 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.DescriptorProto.ExtensionRange */ -class ExtensionRange extends \Google\Protobuf\Internal\Message +final class ExtensionRange extends \Google\Protobuf\Internal\Message { /** * Inclusive. diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php index 73c964faa0..fa46419a53 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php @@ -17,7 +17,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.DescriptorProto.ReservedRange */ -class ReservedRange extends \Google\Protobuf\Internal\Message +final class ReservedRange extends \Google\Protobuf\Internal\Message { /** * Inclusive. diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php index da30fa9906..b7c3a208be 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php @@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.EnumDescriptorProto */ -class EnumDescriptorProto extends \Google\Protobuf\Internal\Message +final class EnumDescriptorProto extends \Google\Protobuf\Internal\Message { /** * Generated from protobuf field optional string name = 1; diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php index e1079585ec..0103a1b301 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php @@ -19,7 +19,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.EnumDescriptorProto.EnumReservedRange */ -class EnumReservedRange extends \Google\Protobuf\Internal\Message +final class EnumReservedRange extends \Google\Protobuf\Internal\Message { /** * Inclusive. diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php index 3d74c81c21..4c73d52740 100644 --- a/php/src/Google/Protobuf/Internal/EnumOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumOptions.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.EnumOptions */ -class EnumOptions extends \Google\Protobuf\Internal\Message +final class EnumOptions extends \Google\Protobuf\Internal\Message { /** * Set this option to true to allow mapping different tag names to the same diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php index 50bda008e8..d5a0a9afb5 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php @@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.EnumValueDescriptorProto */ -class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message +final class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message { /** * Generated from protobuf field optional string name = 1; diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php index a267c6d5e2..50ac904ff9 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.EnumValueOptions */ -class EnumValueOptions extends \Google\Protobuf\Internal\Message +final class EnumValueOptions extends \Google\Protobuf\Internal\Message { /** * Is this enum value deprecated? diff --git a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php index 00fbebecaf..97ad2c055f 100644 --- a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php +++ b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.ExtensionRangeOptions */ -class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message +final class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message { /** * The parser stores options it doesn't recognize here. See above. diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php index e578197515..6f8643c8d7 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php @@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.FieldDescriptorProto */ -class FieldDescriptorProto extends \Google\Protobuf\Internal\Message +final class FieldDescriptorProto extends \Google\Protobuf\Internal\Message { /** * Generated from protobuf field optional string name = 1; diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php index 751c278d78..47d1951d16 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.FieldOptions */ -class FieldOptions extends \Google\Protobuf\Internal\Message +final class FieldOptions extends \Google\Protobuf\Internal\Message { /** * The ctype option instructs the C++ code generator to use a different diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php index cb10aa7939..e95205476c 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php @@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.FileDescriptorProto */ -class FileDescriptorProto extends \Google\Protobuf\Internal\Message +final class FileDescriptorProto extends \Google\Protobuf\Internal\Message { /** * file name, relative to root of source tree diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php index 9907b17d73..c9a38808fb 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php @@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.FileDescriptorSet */ -class FileDescriptorSet extends \Google\Protobuf\Internal\Message +final class FileDescriptorSet extends \Google\Protobuf\Internal\Message { /** * Generated from protobuf field repeated .google.protobuf.FileDescriptorProto file = 1; diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php index 6fea195ec1..9110005016 100644 --- a/php/src/Google/Protobuf/Internal/FileOptions.php +++ b/php/src/Google/Protobuf/Internal/FileOptions.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.FileOptions */ -class FileOptions extends \Google\Protobuf\Internal\Message +final class FileOptions extends \Google\Protobuf\Internal\Message { /** * Sets the Java package where classes generated from this .proto will be diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php index f5a65bea46..c99d77afa3 100644 --- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php @@ -17,7 +17,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.GeneratedCodeInfo */ -class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message +final class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message { /** * An Annotation connects some span of text in generated code to an element diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php index 09f958d251..8cc3cdf457 100644 --- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.GeneratedCodeInfo.Annotation */ -class Annotation extends \Google\Protobuf\Internal\Message +final class Annotation extends \Google\Protobuf\Internal\Message { /** * Identifies the element in the original source .proto file. This field diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php index 4453942110..9032c97e9b 100644 --- a/php/src/Google/Protobuf/Internal/MessageOptions.php +++ b/php/src/Google/Protobuf/Internal/MessageOptions.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.MessageOptions */ -class MessageOptions extends \Google\Protobuf\Internal\Message +final class MessageOptions extends \Google\Protobuf\Internal\Message { /** * Set true to use the old proto1 MessageSet wire format for extensions. diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php index 1bd5dd3e1c..25a2c166fd 100644 --- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php @@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.MethodDescriptorProto */ -class MethodDescriptorProto extends \Google\Protobuf\Internal\Message +final class MethodDescriptorProto extends \Google\Protobuf\Internal\Message { /** * Generated from protobuf field optional string name = 1; diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php index a2c729a9bb..a9c093ad5d 100644 --- a/php/src/Google/Protobuf/Internal/MethodOptions.php +++ b/php/src/Google/Protobuf/Internal/MethodOptions.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.MethodOptions */ -class MethodOptions extends \Google\Protobuf\Internal\Message +final class MethodOptions extends \Google\Protobuf\Internal\Message { /** * Is this method deprecated? diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php index 9ecfe5cbfe..a703fcb702 100644 --- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php @@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.OneofDescriptorProto */ -class OneofDescriptorProto extends \Google\Protobuf\Internal\Message +final class OneofDescriptorProto extends \Google\Protobuf\Internal\Message { /** * Generated from protobuf field optional string name = 1; diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php index 46b516f301..749051f31f 100644 --- a/php/src/Google/Protobuf/Internal/OneofOptions.php +++ b/php/src/Google/Protobuf/Internal/OneofOptions.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.OneofOptions */ -class OneofOptions extends \Google\Protobuf\Internal\Message +final class OneofOptions extends \Google\Protobuf\Internal\Message { /** * The parser stores options it doesn't recognize here. See above. diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php index 8de7afd0bc..9534f0480e 100644 --- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php @@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.ServiceDescriptorProto */ -class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message +final class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message { /** * Generated from protobuf field optional string name = 1; diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php index 67162f3764..55bf7a7758 100644 --- a/php/src/Google/Protobuf/Internal/ServiceOptions.php +++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.ServiceOptions */ -class ServiceOptions extends \Google\Protobuf\Internal\Message +final class ServiceOptions extends \Google\Protobuf\Internal\Message { /** * Is this service deprecated? diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php index dfeb69ff69..3ddd892262 100644 --- a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php @@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.SourceCodeInfo */ -class SourceCodeInfo extends \Google\Protobuf\Internal\Message +final class SourceCodeInfo extends \Google\Protobuf\Internal\Message { /** * A Location identifies a piece of source code in a .proto file which diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php index bad247a11f..470d64c6e2 100644 --- a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php @@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil; /** * Generated from protobuf message google.protobuf.SourceCodeInfo.Location */ -class Location extends \Google\Protobuf\Internal\Message +final class Location extends \Google\Protobuf\Internal\Message { /** * Identifies which part of the FileDescriptorProto was defined at this diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php index 3b517ec552..39273d62fa 100644 --- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php @@ -20,7 +20,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.UninterpretedOption */ -class UninterpretedOption extends \Google\Protobuf\Internal\Message +final class UninterpretedOption extends \Google\Protobuf\Internal\Message { /** * Generated from protobuf field repeated .google.protobuf.UninterpretedOption.NamePart name = 2; diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php index 92ee4b44b9..a2f9250f93 100644 --- a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php @@ -19,7 +19,7 @@ use Google\Protobuf\Internal\GPBUtil; * * Generated from protobuf message google.protobuf.UninterpretedOption.NamePart */ -class NamePart extends \Google\Protobuf\Internal\Message +final class NamePart extends \Google\Protobuf\Internal\Message { /** * Generated from protobuf field required string name_part = 1; diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index c47ea33f79..60d7d8b73b 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -1307,7 +1307,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, } printer.Print( - "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n" + "final class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n" "{\n", "name", fullname); Indent(&printer);