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", 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++ 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. - diff --git a/Makefile.am b/Makefile.am index f87e74d0ac..8396f6e0c7 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= \ @@ -1231,6 +1235,7 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ python/release/wheel/protobuf_optimized_pip.sh \ python/release/wheel/README.md \ six.BUILD \ + third_party/zlib.BUILD \ util/python/BUILD diff --git a/Protobuf.podspec b/Protobuf.podspec index 1a6699bac9..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.7.1' + s.version = '3.8.0' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/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") diff --git a/configure.ac b/configure.ac index f99817ee61..a8f7b303e7 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # In the SVN trunk, the version should always be the next anticipated release # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.7.1],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.8.0],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) @@ -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@:>@])], 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})", 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/conformance/failure_list_ruby_mac.txt b/conformance/failure_list_ruby_mac.txt index 0abc41247d..19be38a309 100644 --- a/conformance/failure_list_ruby_mac.txt +++ b/conformance/failure_list_ruby_mac.txt @@ -51,11 +51,6 @@ Required.Proto3.JsonInput.RepeatedUint32Wrapper.JsonOutput Required.Proto3.JsonInput.RepeatedUint64Wrapper.JsonOutput Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput -Required.Proto3.JsonInput.TimestampJsonInputTooSmall -Required.Proto3.JsonInput.TimestampMinValue.JsonOutput -Required.Proto3.JsonInput.TimestampMinValue.ProtobufOutput -Required.Proto3.JsonInput.TimestampRepeatedValue.JsonOutput -Required.Proto3.JsonInput.TimestampRepeatedValue.ProtobufOutput Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 7e7a3fd437..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.7.1 + 3.8.0 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf.Test/testprotos.pb b/csharp/src/Google.Protobuf.Test/testprotos.pb index bc3979e965..71256aea77 100644 Binary files a/csharp/src/Google.Protobuf.Test/testprotos.pb and b/csharp/src/Google.Protobuf.Test/testprotos.pb differ diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 57901d8ccf..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.7.1 + 3.8.0 6 Google Inc. netstandard1.0;netstandard2.0;net45 @@ -32,11 +32,11 @@ - + - + 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])); diff --git a/docs/options.md b/docs/options.md index ee88ef96c3..f240f0c8bc 100644 --- a/docs/options.md +++ b/docs/options.md @@ -197,7 +197,11 @@ 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 + 1. Protoc-gen-validate * Website: https://github.com/envoyproxy/protoc-gen-validate - * Extensions: 1070 - + * Extensions: 1071 + 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++ diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 90fc53366e..9f09b91ab5 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 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index c9161b69ac..5a355b69bc 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 protobuf-java 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/java/lite/pom.xml b/java/lite/pom.xml index 800cdded9a..0e360a7080 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 diff --git a/java/pom.xml b/java/pom.xml index 5291f9c113..e3a7224f80 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.7.1 + 3.8.0 pom Protocol Buffers [Parent] @@ -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..5bb4bafae8 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -1,134 +1,139 @@ - - - 4.0.0 - - com.google.protobuf - protobuf-parent - 3.7.1 - - - 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 - - - - - - ../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 - - - - - - + + + 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 + + + + + + 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/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/js/package.json b/js/package.json index dfa1d1f1e9..5043963d20 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.7.1", + "version": "3.8.0", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/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 diff --git a/objectivec/GPBDescriptor.h b/objectivec/GPBDescriptor.h index 292bce1371..331d4444ab 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; @@ -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. */ 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, diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 6f5659ff46..bf0389de7f 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-opensource@google.com yes - 2019-03-25 - + 2019-05-21 + - 3.7.1 - 3.7.1 + 3.8.0 + 3.8.0 stable @@ -26,6 +26,7 @@

+ @@ -318,5 +319,33 @@ 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. + + + + 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 cc5c1943a1..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.7.1" +#define PHP_PROTOBUF_VERSION "3.8.0" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c index 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/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); 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/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/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/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) { 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/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/protobuf.bzl b/protobuf.bzl index e764859b4a..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, @@ -158,10 +160,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 = tools, use_default_shell_env = True, ) diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index a3f610b2b0..68f12f5033 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 pom Protobuf Compiler 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. diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 36213d1434..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.7.1' +__version__ = '3.8.0' if __name__ != '__main__': try: 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/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/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/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/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/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/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/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/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 */ diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 86a37141cf..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.7.1" + s.version = "3.8.0" s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" s.description = "Protocol Buffers are Google's data interchange format." @@ -20,6 +20,7 @@ Gem::Specification.new do |s| s.test_files = ["tests/basic.rb", "tests/stress.rb", "tests/generated_code_test.rb"] + s.required_ruby_version = '>= 2.3' s.add_development_dependency "rake-compiler", "~> 0.9.5" s.add_development_dependency "test-unit", '~> 3.0', '>= 3.0.9' s.add_development_dependency "rubygems-tasks", "~> 0.2.4" diff --git a/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); 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 { diff --git a/src/Makefile.am b/src/Makefile.am index 0627861a99..31307044dd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 18:1:0 +PROTOBUF_VERSION = 19:0:0 if GCC # Turn on all warnings except for sign comparison (we ignore sign comparison diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 778773b8d4..a7d9fbe826 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -111,15 +111,10 @@ bool Any::ParseAnyTypeUrl(const string& type_url, full_type_name); } -class Any::HasBitSetters { +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(); @@ -131,11 +126,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) @@ -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 214d521c4d..e3118e0848 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. @@ -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); @@ -217,7 +222,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..26bd56d6af 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() { @@ -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(); @@ -219,11 +209,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 +532,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 +605,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; @@ -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_); @@ -804,23 +790,13 @@ void Api::InternalSwap(Api* other) { void Method::InitAsDefaultInstance() { } -class Method::HasBitSetters { +class Method::_Internal { public: }; 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(); @@ -832,15 +808,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_, @@ -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_); @@ -1402,15 +1374,10 @@ void Method::InternalSwap(Method* other) { void Mixin::InitAsDefaultInstance() { } -class Mixin::HasBitSetters { +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(); @@ -1421,11 +1388,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) @@ -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 4853593bae..ae02cd461c 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. @@ -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,13 +262,12 @@ 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); // @@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_; @@ -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,25 +449,22 @@ 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); // @@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_; @@ -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); @@ -604,7 +619,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/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_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..624bbd37a2 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() @@ -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), @@ -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..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" @@ -1392,7 +1421,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 +2019,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) { @@ -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/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/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/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/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 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/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 2a1d14b87c..60d7d8b73b 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. @@ -1265,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); diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index 7b0d9e65e7..23ac4f2f38 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) { @@ -225,13 +225,6 @@ class Version::HasBitSetters { } }; -#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(); @@ -300,7 +293,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 +302,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 +310,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 +318,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 +364,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 +377,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 +390,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_))); @@ -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_); @@ -657,7 +646,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,19 +659,12 @@ 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() { 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(); @@ -757,7 +739,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 +918,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 +969,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; @@ -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_); @@ -1139,7 +1117,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) { @@ -1153,12 +1131,6 @@ class CodeGeneratorResponse_File::HasBitSetters { } }; -#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(); @@ -1236,7 +1208,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); @@ -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_); @@ -1576,7 +1544,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) { @@ -1584,11 +1552,6 @@ class CodeGeneratorResponse::HasBitSetters { } }; -#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(); @@ -1648,7 +1611,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); @@ -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 9ebd29e13a..46704e5f2b 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. @@ -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,27 +228,24 @@ 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); // @@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_; @@ -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(); @@ -423,7 +433,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_; @@ -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); @@ -593,7 +608,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_; @@ -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); @@ -750,7 +770,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/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 892b9c93e0..420320d245 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -1381,15 +1381,11 @@ constexpr int MethodOptions::IdempotencyLevel_ARRAYSIZE; void FileDescriptorSet::InitAsDefaultInstance() { } -class FileDescriptorSet::HasBitSetters { +class FileDescriptorSet::_Internal { public: 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_); @@ -1690,7 +1667,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 +1690,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( @@ -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(); @@ -1899,7 +1861,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 +2280,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 +2393,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; @@ -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_); @@ -2719,7 +2662,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 +2678,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( @@ -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(); @@ -2840,7 +2777,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 +2787,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 +2795,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 +2841,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 +2854,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 +2916,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 +2947,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()) { @@ -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_); @@ -3158,7 +3076,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) { @@ -3169,11 +3087,6 @@ class DescriptorProto_ReservedRange::HasBitSetters { } }; -#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(); @@ -3246,7 +3159,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 +3169,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 +3177,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 +3216,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 +3229,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_))); @@ -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_); @@ -3521,7 +3415,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 +3428,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( @@ -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(); @@ -3672,7 +3553,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 +3906,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 +4006,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; @@ -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_); @@ -4395,15 +4257,11 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) { void ExtensionRangeOptions::InitAsDefaultInstance() { } -class ExtensionRangeOptions::HasBitSetters { +class ExtensionRangeOptions::_Internal { public: 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_); @@ -4732,7 +4571,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 +4608,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( @@ -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(); @@ -4939,7 +4765,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 +4789,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 +4842,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 +4918,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 +5010,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 +5123,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 +5220,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; @@ -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_); @@ -5645,7 +5452,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 +5465,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( @@ -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(); @@ -5764,7 +5566,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 +5685,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 +5717,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()) { @@ -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_); @@ -6052,7 +5835,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) { @@ -6063,11 +5846,6 @@ class EnumDescriptorProto_EnumReservedRange::HasBitSetters { } }; -#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(); @@ -6140,7 +5918,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 +5928,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 +5936,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 +5975,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 +5988,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_))); @@ -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_); @@ -6415,7 +6174,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 +6187,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( @@ -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(); @@ -6546,7 +6297,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 +6499,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 +6558,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; @@ -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_); @@ -7001,7 +6733,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 +6749,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( @@ -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(); @@ -7128,7 +6854,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 +6871,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 +6932,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 +6999,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 +7036,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()) { @@ -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_); @@ -7461,7 +7168,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 +7181,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( @@ -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(); @@ -7584,7 +7285,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 +7436,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 +7476,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()) { @@ -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_); @@ -7928,7 +7610,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 +7635,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( @@ -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(); @@ -8091,7 +7764,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 +7802,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 +7810,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 +7905,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 +7918,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 +7989,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 +8053,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]; @@ -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_); @@ -8570,7 +8224,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) { @@ -8635,30 +8289,6 @@ class FileOptions::HasBitSetters { } }; -#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(); @@ -8849,7 +8479,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 +8515,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 +8530,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 +8538,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 +8546,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 +8554,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 +8562,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 +8570,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 +8578,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 +8621,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 +8741,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 +8769,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 +8782,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 +8795,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 +8808,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 +8821,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 +8834,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 +8847,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 +8935,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_))); @@ -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_); @@ -10091,7 +9702,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) { @@ -10108,14 +9719,6 @@ class MessageOptions::HasBitSetters { } }; -#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(); @@ -10192,7 +9795,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 +9805,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 +9813,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 +9821,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 +9829,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 +9886,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 +9899,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 +9912,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 +9925,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_))); @@ -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_); @@ -10622,7 +10206,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) { @@ -10645,16 +10229,6 @@ class FieldOptions::HasBitSetters { } }; -#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(); @@ -10734,7 +10308,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 +10330,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 +10338,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 +10346,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 +10366,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 +10442,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 +10455,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 +10468,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 +10500,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_))); @@ -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_); @@ -11270,15 +10825,11 @@ void FieldOptions::InternalSwap(FieldOptions* other) { void OneofOptions::InitAsDefaultInstance() { } -class OneofOptions::HasBitSetters { +class OneofOptions::_Internal { public: 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_); @@ -11605,7 +11137,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) { @@ -11616,12 +11148,6 @@ class EnumOptions::HasBitSetters { } }; -#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(); @@ -11698,7 +11224,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 +11234,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 +11242,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 +11299,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 +11312,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_))); @@ -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_); @@ -12048,7 +11555,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) { @@ -12056,11 +11563,6 @@ class EnumValueOptions::HasBitSetters { } }; -#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(); @@ -12131,7 +11633,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 +11643,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 +11700,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_))); @@ -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_); @@ -12435,7 +11918,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) { @@ -12443,11 +11926,6 @@ class ServiceOptions::HasBitSetters { } }; -#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(); @@ -12518,7 +11996,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 +12006,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 +12063,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_))); @@ -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_); @@ -12822,7 +12281,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) { @@ -12833,12 +12292,6 @@ class MethodOptions::HasBitSetters { } }; -#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(); @@ -12918,7 +12371,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 +12381,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 +12450,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_))); @@ -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_); @@ -13281,7 +12715,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) { @@ -13292,11 +12726,6 @@ class UninterpretedOption_NamePart::HasBitSetters { } }; -#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(); @@ -13372,7 +12801,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 +12818,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 +12872,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_))); @@ -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_); @@ -13672,7 +13082,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) { @@ -13695,16 +13105,6 @@ class UninterpretedOption::HasBitSetters { } }; -#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(); @@ -13813,7 +13213,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 +13242,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 +13250,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 +13258,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 +13337,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 +13350,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 +13363,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_))); @@ -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_); @@ -14333,7 +13714,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) { @@ -14344,14 +13725,6 @@ class SourceCodeInfo_Location::HasBitSetters { } }; -#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(); @@ -14445,7 +13818,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; @@ -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_); @@ -14935,15 +14289,11 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { void SourceCodeInfo::InitAsDefaultInstance() { } -class SourceCodeInfo::HasBitSetters { +class SourceCodeInfo::_Internal { public: 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_); @@ -15239,7 +14570,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) { @@ -15253,13 +14584,6 @@ class GeneratedCodeInfo_Annotation::HasBitSetters { } }; -#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(); @@ -15346,7 +14670,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 +14697,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 +14705,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 +14775,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 +14788,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_))); @@ -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_); @@ -15741,15 +15046,11 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot void GeneratedCodeInfo::InitAsDefaultInstance() { } -class GeneratedCodeInfo::HasBitSetters { +class GeneratedCodeInfo::_Internal { public: 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 0920d4196b..f8a7159a4e 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. @@ -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(); @@ -472,7 +485,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; @@ -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(); @@ -795,7 +821,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; @@ -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,20 +1003,18 @@ 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); // @@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; @@ -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,23 +1168,25 @@ 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); // @@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; @@ -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(); @@ -1417,7 +1482,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; @@ -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(); @@ -1582,7 +1660,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_; @@ -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,34 +2039,30 @@ 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); // @@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; @@ -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(); @@ -2157,7 +2261,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; @@ -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,23 +2414,25 @@ 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); // @@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; @@ -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(); @@ -2537,7 +2667,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; @@ -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,13 +2863,12 @@ 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); // @@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; @@ -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(); @@ -2916,7 +3072,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; @@ -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,20 +3311,18 @@ 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); // @@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; @@ -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,77 +3758,67 @@ 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); GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FileOptions) // @@protoc_insertion_point(class_scope:google.protobuf.FileOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -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,35 +4013,31 @@ 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); GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MessageOptions) // @@protoc_insertion_point(class_scope:google.protobuf.MessageOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -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,49 +4282,43 @@ 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); GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FieldOptions) // @@protoc_insertion_point(class_scope:google.protobuf.FieldOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -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(); @@ -4274,7 +4495,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_; @@ -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,21 +4668,19 @@ 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); GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumOptions) // @@protoc_insertion_point(class_scope:google.protobuf.EnumOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -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,14 +4854,13 @@ 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); GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumValueOptions) // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -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,14 +5033,13 @@ 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); GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(ServiceOptions) // @@protoc_insertion_point(class_scope:google.protobuf.ServiceOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -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,21 +5245,19 @@ 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); GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MethodOptions) // @@protoc_insertion_point(class_scope:google.protobuf.MethodOptions) private: - class HasBitSetters; + class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; @@ -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,13 +5441,12 @@ 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); // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption.NamePart) private: - class HasBitSetters; + class _Internal; // helper for ByteSizeLong() size_t RequiredFieldsByteSizeFallback() const; @@ -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,27 +5690,24 @@ 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); // @@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; @@ -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); @@ -5643,7 +5955,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; @@ -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(); @@ -5806,7 +6131,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; @@ -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,20 +6324,18 @@ 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); // @@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; @@ -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(); @@ -6158,7 +6509,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..6aea3636cc 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -86,15 +86,10 @@ PROTOBUF_NAMESPACE_OPEN void Duration::InitAsDefaultInstance() { } -class Duration::HasBitSetters { +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 91ac1e18d1..0a43178af4 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. @@ -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,21 +198,23 @@ 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); // @@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..412d6f792f 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -83,13 +83,10 @@ PROTOBUF_NAMESPACE_OPEN void Empty::InitAsDefaultInstance() { } -class Empty::HasBitSetters { +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 d65060da80..0f4b9f8278 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. @@ -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 ---------------------------------------------- @@ -189,7 +200,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/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 034b44f49c..ca88d38ef7 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -85,14 +85,10 @@ PROTOBUF_NAMESPACE_OPEN void FieldMask::InitAsDefaultInstance() { } -class FieldMask::HasBitSetters { +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 57f400c4eb..ab7152959a 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. @@ -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); @@ -207,7 +220,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/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/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!"; // 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); 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/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/port_def.inc b/src/google/protobuf/port_def.inc index 39aaf05f38..c1dc739196 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/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 98add69e05..5263fc6152 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -86,14 +86,10 @@ PROTOBUF_NAMESPACE_OPEN void SourceContext::InitAsDefaultInstance() { } -class SourceContext::HasBitSetters { +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(); @@ -104,7 +100,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) @@ -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 943c936bf9..0383fb52e4 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. @@ -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); @@ -189,7 +194,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..124fdfa018 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -195,14 +195,10 @@ void Struct_FieldsEntry_DoNotUse::MergeFrom( void Struct::InitAsDefaultInstance() { } -class Struct::HasBitSetters { +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_); @@ -578,18 +555,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) { @@ -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(); @@ -979,13 +947,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 +1000,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()) { @@ -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_); @@ -1216,14 +1165,10 @@ void Value::InternalSwap(Value* other) { void ListValue::InitAsDefaultInstance() { } -class ListValue::HasBitSetters { +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 5dfd8fae16..63df3c976e 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. @@ -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 >* @@ -271,7 +284,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; @@ -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(); @@ -498,7 +524,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(); @@ -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(); @@ -664,7 +703,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/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. 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/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..c05fb1269b 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -86,15 +86,10 @@ PROTOBUF_NAMESPACE_OPEN void Timestamp::InitAsDefaultInstance() { } -class Timestamp::HasBitSetters { +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 f3ede5c1c8..3cd5fdf57d 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. @@ -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,21 +198,23 @@ 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); // @@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..e6c061f2fa 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( @@ -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(); @@ -420,7 +411,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 +719,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 +782,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; @@ -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_); @@ -970,23 +942,10 @@ void Type::InternalSwap(Type* other) { void Field::InitAsDefaultInstance() { } -class Field::HasBitSetters { +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(); @@ -1006,22 +965,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()); } @@ -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_); @@ -1751,13 +1691,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( @@ -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(); @@ -1808,7 +1740,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 +2009,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 +2062,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; @@ -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_); @@ -2299,16 +2212,10 @@ void Enum::InternalSwap(Enum* other) { void EnumValue::InitAsDefaultInstance() { } -class EnumValue::HasBitSetters { +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(); @@ -2328,7 +2235,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()); } @@ -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_); @@ -2710,13 +2598,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( @@ -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(); @@ -2760,7 +2643,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 +2820,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 +2851,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()) { @@ -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 0ded75db37..0dd0a2ae1f 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. @@ -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,13 +391,12 @@ 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); // @@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; @@ -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,37 +748,32 @@ 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); // @@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; @@ -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,13 +988,12 @@ 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); // @@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; @@ -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,13 +1179,12 @@ 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); // @@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; @@ -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(); @@ -1302,7 +1367,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/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/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/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/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, 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 c16cd27617..244edf1357 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. @@ -1429,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); @@ -1447,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; @@ -1593,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 e8100d9222..73d8c4227d 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -307,14 +307,10 @@ PROTOBUF_NAMESPACE_OPEN void DoubleValue::InitAsDefaultInstance() { } -class DoubleValue::HasBitSetters { +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_); @@ -592,14 +569,10 @@ void DoubleValue::InternalSwap(DoubleValue* other) { void FloatValue::InitAsDefaultInstance() { } -class FloatValue::HasBitSetters { +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_); @@ -877,14 +831,10 @@ void FloatValue::InternalSwap(FloatValue* other) { void Int64Value::InitAsDefaultInstance() { } -class Int64Value::HasBitSetters { +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_); @@ -1164,14 +1095,10 @@ void Int64Value::InternalSwap(Int64Value* other) { void UInt64Value::InitAsDefaultInstance() { } -class UInt64Value::HasBitSetters { +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_); @@ -1451,14 +1359,10 @@ void UInt64Value::InternalSwap(UInt64Value* other) { void Int32Value::InitAsDefaultInstance() { } -class Int32Value::HasBitSetters { +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_); @@ -1738,14 +1623,10 @@ void Int32Value::InternalSwap(Int32Value* other) { void UInt32Value::InitAsDefaultInstance() { } -class UInt32Value::HasBitSetters { +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_); @@ -2025,14 +1887,10 @@ void UInt32Value::InternalSwap(UInt32Value* other) { void BoolValue::InitAsDefaultInstance() { } -class BoolValue::HasBitSetters { +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_); @@ -2310,14 +2149,10 @@ void BoolValue::InternalSwap(BoolValue* other) { void StringValue::InitAsDefaultInstance() { } -class StringValue::HasBitSetters { +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(); @@ -2335,7 +2170,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()); } @@ -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_); @@ -2617,14 +2433,10 @@ void StringValue::InternalSwap(StringValue* other) { void BytesValue::InitAsDefaultInstance() { } -class BytesValue::HasBitSetters { +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(); @@ -2642,7 +2454,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()); } @@ -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 b5ded2a08c..8038d988d1 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. @@ -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,15 +230,17 @@ 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); // @@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; @@ -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,15 +384,17 @@ 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); // @@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; @@ -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,15 +538,17 @@ 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); // @@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; @@ -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,15 +692,17 @@ 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); // @@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; @@ -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,15 +846,17 @@ 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); // @@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; @@ -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,15 +1000,17 @@ 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); // @@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; @@ -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,15 +1154,17 @@ 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); // @@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; @@ -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); @@ -1229,7 +1333,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; @@ -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); @@ -1385,7 +1502,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; diff --git a/update_version.py b/update_version.py index 187e7e6d88..38078c1a75 100755 --- a/update_version.py +++ b/update_version.py @@ -177,13 +177,13 @@ def UpdateCsharp(): RewriteXml('csharp/src/Google.Protobuf/Google.Protobuf.csproj', lambda document : ReplaceText( Find(Find(document.documentElement, 'PropertyGroup'), 'VersionPrefix'), - GetFullVersion(rc_suffix = '-rc.')), + GetFullVersion(rc_suffix = '-rc')), add_xml_prefix=False) RewriteXml('csharp/Google.Protobuf.Tools.nuspec', lambda document : ReplaceText( Find(Find(document.documentElement, 'metadata'), 'version'), - GetFullVersion(rc_suffix = '-rc.'))) + GetFullVersion(rc_suffix = '-rc'))) def UpdateJava(): @@ -247,7 +247,7 @@ def UpdateObjectiveC(): RewriteTextFile('Protobuf.podspec', lambda line : re.sub( r"^ s.version = '.*'$", - " s.version = '%s'" % GetFullVersion(rc_suffix = '-rc.'), + " s.version = '%s'" % GetFullVersion(rc_suffix = '-rc'), line))