aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cmake/libprotobuf-lite.cmake2
-rw-r--r--conformance/failure_list_cpp.txt1
-rw-r--r--conformance/failure_list_java.txt5
-rw-r--r--conformance/failure_list_python.txt3
-rw-r--r--conformance/failure_list_python_cpp.txt3
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Any.cs21
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs4
-rw-r--r--java/core/src/main/java/com/google/protobuf/Android.java57
-rw-r--r--java/core/src/main/java/com/google/protobuf/ByteString.java10
-rw-r--r--java/core/src/main/java/com/google/protobuf/FieldSet.java5
-rw-r--r--java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java42
-rw-r--r--java/core/src/main/java/com/google/protobuf/TextFormat.java35
-rw-r--r--java/core/src/main/java/com/google/protobuf/UnsafeUtil.java9
-rw-r--r--java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java12
-rw-r--r--java/core/src/test/java/com/google/protobuf/TestUtil.java6
-rw-r--r--java/core/src/test/java/com/google/protobuf/TextFormatTest.java88
-rw-r--r--java/util/src/main/java/com/google/protobuf/util/JsonFormat.java57
-rw-r--r--java/util/src/main/java/com/google/protobuf/util/Timestamps.java11
-rw-r--r--java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java15
-rw-r--r--js/binary/arith.js2
-rw-r--r--js/binary/decoder.js10
-rw-r--r--js/binary/encoder.js4
-rw-r--r--js/binary/reader.js50
-rw-r--r--js/binary/utils.js8
-rw-r--r--js/binary/utils_test.js2
-rw-r--r--js/binary/writer.js106
-rw-r--r--js/debug.js9
-rw-r--r--js/debug_test.js11
-rw-r--r--js/message.js64
-rw-r--r--js/message_test.js20
-rw-r--r--objectivec/google/protobuf/Any.pbobjc.h21
-rw-r--r--objectivec/google/protobuf/Timestamp.pbobjc.h4
-rwxr-xr-xpython/google/protobuf/descriptor.py4
-rw-r--r--python/google/protobuf/descriptor_database.py26
-rw-r--r--python/google/protobuf/descriptor_pool.py43
-rw-r--r--python/google/protobuf/internal/descriptor_database_test.py21
-rw-r--r--python/google/protobuf/internal/descriptor_pool_test.py56
-rwxr-xr-xpython/google/protobuf/internal/encoder.py3
-rwxr-xr-xpython/google/protobuf/internal/text_format_test.py7
-rw-r--r--python/google/protobuf/pyext/descriptor_containers.cc530
-rw-r--r--python/google/protobuf/pyext/message.cc90
-rw-r--r--python/google/protobuf/pyext/message.h12
-rwxr-xr-xpython/google/protobuf/text_format.py2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/google/protobuf/any.pb.cc14
-rw-r--r--src/google/protobuf/any.pb.h13
-rw-r--r--src/google/protobuf/any.proto21
-rw-r--r--src/google/protobuf/api.pb.cc76
-rw-r--r--src/google/protobuf/api.pb.h114
-rwxr-xr-xsrc/google/protobuf/arena.cc371
-rw-r--r--src/google/protobuf/arena.h83
-rw-r--r--src/google/protobuf/arena_impl.h158
-rw-r--r--src/google/protobuf/arena_unittest.cc32
-rwxr-xr-xsrc/google/protobuf/arenastring.h21
-rw-r--r--src/google/protobuf/compiler/annotation_test_util.cc26
-rw-r--r--src/google/protobuf/compiler/annotation_test_util.h17
-rw-r--r--src/google/protobuf/compiler/code_generator.h2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum_field.cc6
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_field.cc17
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_field.h4
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.cc95
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_generator.cc39
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_helpers.cc2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_helpers.h4
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.cc769
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.h3
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message_field.cc601
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message_field.h9
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_options.h2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_primitive_field.cc8
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_string_field.cc106
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_string_field.h2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_unittest.cc45
-rw-r--r--src/google/protobuf/compiler/cpp/metadata_test.cc4
-rw-r--r--src/google/protobuf/compiler/java/java_message.cc28
-rw-r--r--src/google/protobuf/compiler/java/java_message_lite.cc62
-rwxr-xr-xsrc/google/protobuf/compiler/js/js_generator.cc35
-rw-r--r--src/google/protobuf/compiler/mock_code_generator.cc2
-rw-r--r--src/google/protobuf/compiler/plugin.pb.cc82
-rw-r--r--src/google/protobuf/compiler/plugin.pb.h83
-rw-r--r--src/google/protobuf/descriptor.cc112
-rw-r--r--src/google/protobuf/descriptor.pb.cc517
-rw-r--r--src/google/protobuf/descriptor.pb.h847
-rw-r--r--src/google/protobuf/descriptor_unittest.cc3
-rw-r--r--src/google/protobuf/duration.pb.cc10
-rw-r--r--src/google/protobuf/duration.pb.h13
-rw-r--r--src/google/protobuf/dynamic_message.cc78
-rw-r--r--src/google/protobuf/dynamic_message_unittest.cc68
-rw-r--r--src/google/protobuf/empty.pb.cc10
-rw-r--r--src/google/protobuf/empty.pb.h13
-rw-r--r--src/google/protobuf/extension_set.cc16
-rw-r--r--src/google/protobuf/extension_set.h2
-rw-r--r--src/google/protobuf/extension_set_heavy.cc10
-rw-r--r--src/google/protobuf/extension_set_unittest.cc9
-rw-r--r--src/google/protobuf/field_mask.pb.cc16
-rw-r--r--src/google/protobuf/field_mask.pb.h13
-rw-r--r--src/google/protobuf/generated_enum_reflection.h1
-rw-r--r--src/google/protobuf/generated_enum_util.h2
-rw-r--r--src/google/protobuf/generated_message_reflection.cc12
-rw-r--r--src/google/protobuf/generated_message_reflection.h8
-rw-r--r--src/google/protobuf/generated_message_table_driven_lite.h54
-rw-r--r--src/google/protobuf/generated_message_util.h16
-rw-r--r--src/google/protobuf/implicit_weak_message.h51
-rw-r--r--src/google/protobuf/io/coded_stream.cc11
-rw-r--r--src/google/protobuf/io/coded_stream.h61
-rw-r--r--src/google/protobuf/map.h11
-rw-r--r--src/google/protobuf/map_entry_lite.h9
-rw-r--r--src/google/protobuf/map_field.cc7
-rw-r--r--src/google/protobuf/map_test.cc10
-rw-r--r--src/google/protobuf/message.h12
-rw-r--r--src/google/protobuf/message_lite.h19
-rw-r--r--src/google/protobuf/reflection_ops.cc29
-rw-r--r--src/google/protobuf/repeated_field.cc16
-rw-r--r--src/google/protobuf/repeated_field.h257
-rw-r--r--src/google/protobuf/source_context.pb.cc14
-rw-r--r--src/google/protobuf/source_context.pb.h13
-rw-r--r--src/google/protobuf/struct.pb.cc34
-rw-r--r--src/google/protobuf/struct.pb.h68
-rw-r--r--src/google/protobuf/timestamp.pb.cc10
-rw-r--r--src/google/protobuf/timestamp.pb.h13
-rw-r--r--src/google/protobuf/timestamp.proto4
-rw-r--r--src/google/protobuf/type.pb.cc120
-rw-r--r--src/google/protobuf/type.pb.h187
-rw-r--r--src/google/protobuf/unittest_lite_imports_nonlite.proto3
-rw-r--r--src/google/protobuf/util/field_comparator.cc10
-rw-r--r--src/google/protobuf/util/field_comparator.h11
-rw-r--r--src/google/protobuf/util/field_mask_util.h9
-rw-r--r--src/google/protobuf/util/field_mask_util_test.cc6
-rw-r--r--src/google/protobuf/util/internal/json_escaping.h8
-rw-r--r--src/google/protobuf/util/internal/json_objectwriter.cc13
-rw-r--r--src/google/protobuf/util/internal/json_objectwriter.h42
-rw-r--r--src/google/protobuf/util/internal/json_objectwriter_test.cc6
-rw-r--r--src/google/protobuf/util/internal/object_writer.h7
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource.cc2
-rw-r--r--src/google/protobuf/util/internal/utility.cc5
-rw-r--r--src/google/protobuf/util/message_differencer.cc10
-rw-r--r--src/google/protobuf/util/message_differencer.h14
-rw-r--r--src/google/protobuf/wire_format_lite.cc189
-rw-r--r--src/google/protobuf/wire_format_lite.h14
-rw-r--r--src/google/protobuf/wire_format_lite_inl.h27
-rw-r--r--src/google/protobuf/wire_format_unittest.cc1
-rw-r--r--src/google/protobuf/wrappers.pb.cc58
-rw-r--r--src/google/protobuf/wrappers.pb.h85
143 files changed, 4483 insertions, 3272 deletions
diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake
index 9e1fab0a..f5242d4f 100644
--- a/cmake/libprotobuf-lite.cmake
+++ b/cmake/libprotobuf-lite.cmake
@@ -4,6 +4,7 @@ set(libprotobuf_lite_files
${protobuf_source_dir}/src/google/protobuf/extension_set.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_util.cc
+ ${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.cc
${protobuf_source_dir}/src/google/protobuf/io/coded_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
@@ -31,6 +32,7 @@ set(libprotobuf_lite_includes
${protobuf_source_dir}/src/google/protobuf/arenastring.h
${protobuf_source_dir}/src/google/protobuf/extension_set.h
${protobuf_source_dir}/src/google/protobuf/generated_message_util.h
+ ${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.h
${protobuf_source_dir}/src/google/protobuf/io/coded_stream.h
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.h
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.h
diff --git a/conformance/failure_list_cpp.txt b/conformance/failure_list_cpp.txt
index 8c328890..752fbb5d 100644
--- a/conformance/failure_list_cpp.txt
+++ b/conformance/failure_list_cpp.txt
@@ -54,4 +54,3 @@ Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64
-
diff --git a/conformance/failure_list_java.txt b/conformance/failure_list_java.txt
index 5116c569..053bdaa4 100644
--- a/conformance/failure_list_java.txt
+++ b/conformance/failure_list_java.txt
@@ -44,4 +44,7 @@ Required.Proto3.JsonInput.StringFieldNotAString
Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
-Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE \ No newline at end of file
+Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
+# This test will be fixed as soon as we internally make the switch to
+# preserving unknowns in proto3.
+Required.Proto3.ProtobufInput.UnknownVarint.ProtobufOutput
diff --git a/conformance/failure_list_python.txt b/conformance/failure_list_python.txt
index e3ce7af7..b44c938d 100644
--- a/conformance/failure_list_python.txt
+++ b/conformance/failure_list_python.txt
@@ -19,3 +19,6 @@ Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_0
Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_1
Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_2
Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_3
+# This test will be fixed as soon as we internally make the switch to
+# preserving unknowns in proto3.
+Required.Proto3.ProtobufInput.UnknownVarint.ProtobufOutput
diff --git a/conformance/failure_list_python_cpp.txt b/conformance/failure_list_python_cpp.txt
index a498ad1a..7fada009 100644
--- a/conformance/failure_list_python_cpp.txt
+++ b/conformance/failure_list_python_cpp.txt
@@ -52,3 +52,6 @@ Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64
+# This test will be fixed as soon as we internally make the switch to
+# preserving unknowns in proto3.
+Required.Proto3.ProtobufInput.UnknownVarint.ProtobufOutput
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
index 5b39b809..d94feb1e 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
@@ -154,17 +154,18 @@ namespace Google.Protobuf.WellKnownTypes {
public const int TypeUrlFieldNumber = 1;
private string typeUrl_ = "";
/// <summary>
- /// A URL/resource name whose content describes the type of the
- /// serialized protocol buffer message.
+ /// A URL/resource name that uniquely identifies the type of the serialized
+ /// protocol buffer message. The last segment of the URL's path must represent
+ /// the fully qualified name of the type (as in
+ /// `path/google.protobuf.Duration`). The name should be in a canonical form
+ /// (e.g., leading "." is not accepted).
///
- /// For URLs which use the scheme `http`, `https`, or no scheme, the
- /// following restrictions and interpretations apply:
+ /// In practice, teams usually precompile into the binary all types that they
+ /// expect it to use in the context of Any. However, for URLs which use the
+ /// scheme `http`, `https`, or no scheme, one can optionally set up a type
+ /// server that maps type URLs to message definitions as follows:
///
/// * If no scheme is provided, `https` is assumed.
- /// * The last segment of the URL's path must represent the fully
- /// qualified name of the type (as in `path/google.protobuf.Duration`).
- /// The name should be in a canonical form (e.g., leading "." is
- /// not accepted).
/// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
/// value in binary format, or produce an error.
/// * Applications are allowed to cache lookup results based on the
@@ -173,6 +174,10 @@ namespace Google.Protobuf.WellKnownTypes {
/// on changes to types. (Use versioned type names to manage
/// breaking changes.)
///
+ /// Note: this functionality is not currently available in the official
+ /// protobuf release, and it is not used for type URLs beginning with
+ /// type.googleapis.com.
+ ///
/// Schemes other than `http`, `https` (or the empty scheme) might be
/// used with implementation specific semantics.
/// </summary>
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
index 9f7ad73a..036be63f 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
@@ -112,8 +112,8 @@ namespace Google.Protobuf.WellKnownTypes {
/// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
/// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
/// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
- /// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--)
- /// to obtain a formatter capable of generating timestamps in this format.
+ /// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--
+ /// ) to obtain a formatter capable of generating timestamps in this format.
/// </summary>
public sealed partial class Timestamp : pb::IMessage<Timestamp> {
private static readonly pb::MessageParser<Timestamp> _parser = new pb::MessageParser<Timestamp>(() => new Timestamp());
diff --git a/java/core/src/main/java/com/google/protobuf/Android.java b/java/core/src/main/java/com/google/protobuf/Android.java
new file mode 100644
index 00000000..cad54783
--- /dev/null
+++ b/java/core/src/main/java/com/google/protobuf/Android.java
@@ -0,0 +1,57 @@
+// 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;
+
+final class Android {
+
+ private static final Class<?> MEMORY_CLASS = getClassForName("libcore.io.Memory");
+ private static final boolean IS_ROBOLECTRIC =
+ getClassForName("org.robolectric.Robolectric") != null;
+
+ /** Returns {@code true} if running on an Android device. */
+ static boolean isOnAndroidDevice() {
+ return MEMORY_CLASS != null && !IS_ROBOLECTRIC;
+ }
+
+ /** Returns the memory class or {@code null} if not on Android device. */
+ static Class<?> getMemoryClass() {
+ return MEMORY_CLASS;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T> Class<T> getClassForName(String name) {
+ try {
+ return (Class<T>) Class.forName(name);
+ } catch (Throwable e) {
+ return null;
+ }
+ }
+}
diff --git a/java/core/src/main/java/com/google/protobuf/ByteString.java b/java/core/src/main/java/com/google/protobuf/ByteString.java
index 99a31209..d67bb54a 100644
--- a/java/core/src/main/java/com/google/protobuf/ByteString.java
+++ b/java/core/src/main/java/com/google/protobuf/ByteString.java
@@ -124,14 +124,8 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
private static final ByteArrayCopier byteArrayCopier;
static {
- boolean isAndroid = true;
- try {
- Class.forName("android.content.Context");
- } catch (ClassNotFoundException e) {
- isAndroid = false;
- }
-
- byteArrayCopier = isAndroid ? new SystemByteArrayCopier() : new ArraysByteArrayCopier();
+ byteArrayCopier =
+ Android.isOnAndroidDevice() ? new SystemByteArrayCopier() : new ArraysByteArrayCopier();
}
/**
diff --git a/java/core/src/main/java/com/google/protobuf/FieldSet.java b/java/core/src/main/java/com/google/protobuf/FieldSet.java
index 8a9239ed..c09daa32 100644
--- a/java/core/src/main/java/com/google/protobuf/FieldSet.java
+++ b/java/core/src/main/java/com/google/protobuf/FieldSet.java
@@ -102,6 +102,11 @@ final class FieldSet<FieldDescriptorType extends
@SuppressWarnings("rawtypes")
private static final FieldSet DEFAULT_INSTANCE = new FieldSet(true);
+ /** Returns {@code true} if empty, {@code false} otherwise. */
+ boolean isEmpty() {
+ return fields.isEmpty();
+ }
+
/** Make this FieldSet immutable from this point forward. */
@SuppressWarnings("unchecked")
public void makeImmutable() {
diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
index 09084646..8b8d9fc6 100644
--- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
+++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
@@ -504,11 +504,8 @@ public abstract class GeneratedMessageLite<
extends GeneratedMessageLite<MessageType, BuilderType>
implements ExtendableMessageOrBuilder<MessageType, BuilderType> {
- /**
- * Represents the set of extensions on this message. For use by generated
- * code only.
- */
- protected FieldSet<ExtensionDescriptor> extensions = FieldSet.newFieldSet();
+ /** Represents the set of extensions on this message. For use by generated code only. */
+ protected FieldSet<ExtensionDescriptor> extensions = FieldSet.emptySet();
@SuppressWarnings("unchecked")
protected final void mergeExtensionFields(final MessageType other) {
@@ -578,7 +575,11 @@ public abstract class GeneratedMessageLite<
if (unknown) { // Unknown field or wrong wire type. Skip.
return parseUnknownField(tag, input);
}
-
+
+ if (extensions.isImmutable()) {
+ extensions = extensions.clone();
+ }
+
if (packed) {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
@@ -942,12 +943,6 @@ public abstract class GeneratedMessageLite<
implements ExtendableMessageOrBuilder<MessageType, BuilderType> {
protected ExtendableBuilder(MessageType defaultInstance) {
super(defaultInstance);
-
- // TODO(dweis): This is kind of an unnecessary clone since we construct a
- // new instance in the parent constructor which makes the extensions
- // immutable. This extra allocation shouldn't matter in practice
- // though.
- instance.extensions = instance.extensions.clone();
}
// For immutable message conversion.
@@ -966,6 +961,15 @@ public abstract class GeneratedMessageLite<
instance.extensions = instance.extensions.clone();
}
+ private FieldSet<ExtensionDescriptor> ensureExtensionsAreMutable() {
+ FieldSet<ExtensionDescriptor> extensions = instance.extensions;
+ if (extensions.isImmutable()) {
+ extensions = extensions.clone();
+ instance.extensions = extensions;
+ }
+ return extensions;
+ }
+
@Override
public final MessageType buildPartial() {
if (isBuilt) {
@@ -1024,7 +1028,8 @@ public abstract class GeneratedMessageLite<
verifyExtensionContainingType(extensionLite);
copyOnWrite();
- instance.extensions.setField(extensionLite.descriptor, extensionLite.toFieldSetType(value));
+ ensureExtensionsAreMutable()
+ .setField(extensionLite.descriptor, extensionLite.toFieldSetType(value));
return (BuilderType) this;
}
@@ -1037,8 +1042,9 @@ public abstract class GeneratedMessageLite<
verifyExtensionContainingType(extensionLite);
copyOnWrite();
- instance.extensions.setRepeatedField(
- extensionLite.descriptor, index, extensionLite.singularToFieldSetType(value));
+ ensureExtensionsAreMutable()
+ .setRepeatedField(
+ extensionLite.descriptor, index, extensionLite.singularToFieldSetType(value));
return (BuilderType) this;
}
@@ -1051,8 +1057,8 @@ public abstract class GeneratedMessageLite<
verifyExtensionContainingType(extensionLite);
copyOnWrite();
- instance.extensions.addRepeatedField(
- extensionLite.descriptor, extensionLite.singularToFieldSetType(value));
+ ensureExtensionsAreMutable()
+ .addRepeatedField(extensionLite.descriptor, extensionLite.singularToFieldSetType(value));
return (BuilderType) this;
}
@@ -1063,7 +1069,7 @@ public abstract class GeneratedMessageLite<
verifyExtensionContainingType(extensionLite);
copyOnWrite();
- instance.extensions.clearField(extensionLite.descriptor);
+ ensureExtensionsAreMutable().clearField(extensionLite.descriptor);
return (BuilderType) this;
}
}
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 ab9acf2f..0c8b898c 100644
--- a/java/core/src/main/java/com/google/protobuf/TextFormat.java
+++ b/java/core/src/main/java/com/google/protobuf/TextFormat.java
@@ -1224,6 +1224,22 @@ public final class TextFormat {
}
/**
+ * Parse a text-format message from {@code input}.
+ *
+ * @return the parsed message, guaranteed initialized
+ */
+ public static <T extends Message> T parse(final CharSequence input,
+ final Class<T> protoClass)
+ throws ParseException {
+ Message.Builder builder =
+ Internal.getDefaultInstance(protoClass).newBuilderForType();
+ merge(input, builder);
+ @SuppressWarnings("unchecked")
+ T output = (T) builder.build();
+ return output;
+ }
+
+ /**
* Parse a text-format message from {@code input} and merge the contents
* into {@code builder}. Extensions will be recognized if they are
* registered in {@code extensionRegistry}.
@@ -1248,6 +1264,25 @@ public final class TextFormat {
PARSER.merge(input, extensionRegistry, builder);
}
+ /**
+ * Parse a text-format message from {@code input}. Extensions will be
+ * recognized if they are registered in {@code extensionRegistry}.
+ *
+ * @return the parsed message, guaranteed initialized
+ */
+ public static <T extends Message> T parse(
+ final CharSequence input,
+ final ExtensionRegistry extensionRegistry,
+ final Class<T> protoClass)
+ throws ParseException {
+ Message.Builder builder =
+ Internal.getDefaultInstance(protoClass).newBuilderForType();
+ merge(input, extensionRegistry, builder);
+ @SuppressWarnings("unchecked")
+ T output = (T) builder.build();
+ return output;
+ }
+
/**
* Parser for text-format proto2 instances. This class is thread-safe.
diff --git a/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java b/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java
index 88315cb6..98c93b90 100644
--- a/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java
+++ b/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java
@@ -364,15 +364,6 @@ final class UnsafeUtil {
}
- @SuppressWarnings("unchecked")
- private static <T> Class<T> getClassForName(String name) {
- try {
- return (Class<T>) Class.forName(name);
- } catch (Throwable e) {
- return null;
- }
- }
-
/** Finds the address field within a direct {@link Buffer}. */
private static Field bufferAddressField() {
return field(Buffer.class, "address");
diff --git a/java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java b/java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java
index 622e36a4..cb2d34eb 100644
--- a/java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java
+++ b/java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java
@@ -30,6 +30,9 @@
package com.google.protobuf;
+import static com.google.protobuf.TestUtil.TEST_REQUIRED_INITIALIZED;
+import static com.google.protobuf.TestUtil.TEST_REQUIRED_UNINITIALIZED;
+
import com.google.protobuf.Descriptors.FieldDescriptor;
import protobuf_unittest.UnittestOptimizeFor.TestOptimizedForSize;
import protobuf_unittest.UnittestProto;
@@ -346,11 +349,6 @@ public class AbstractMessageTest extends TestCase {
// -----------------------------------------------------------------
// Tests for isInitialized().
- private static final TestRequired TEST_REQUIRED_UNINITIALIZED =
- TestRequired.getDefaultInstance();
- private static final TestRequired TEST_REQUIRED_INITIALIZED =
- TestRequired.newBuilder().setA(1).setB(2).setC(3).build();
-
public void testIsInitialized() throws Exception {
TestRequired.Builder builder = TestRequired.newBuilder();
AbstractMessageWrapper.Builder abstractBuilder =
@@ -380,7 +378,7 @@ public class AbstractMessageTest extends TestCase {
builder.setOptionalMessage(TEST_REQUIRED_UNINITIALIZED);
assertFalse(abstractBuilder.isInitialized());
assertEquals(
- "optional_message.a, optional_message.b, optional_message.c",
+ "optional_message.b, optional_message.c",
abstractBuilder.getInitializationErrorString());
builder.setOptionalMessage(TEST_REQUIRED_INITIALIZED);
@@ -390,7 +388,7 @@ public class AbstractMessageTest extends TestCase {
builder.addRepeatedMessage(TEST_REQUIRED_UNINITIALIZED);
assertFalse(abstractBuilder.isInitialized());
assertEquals(
- "repeated_message[0].a, repeated_message[0].b, repeated_message[0].c",
+ "repeated_message[0].b, repeated_message[0].c",
abstractBuilder.getInitializationErrorString());
builder.setRepeatedMessage(0, TEST_REQUIRED_INITIALIZED);
diff --git a/java/core/src/test/java/com/google/protobuf/TestUtil.java b/java/core/src/test/java/com/google/protobuf/TestUtil.java
index e96adf07..b4bc3a3d 100644
--- a/java/core/src/test/java/com/google/protobuf/TestUtil.java
+++ b/java/core/src/test/java/com/google/protobuf/TestUtil.java
@@ -231,6 +231,7 @@ import protobuf_unittest.UnittestProto.TestAllTypesOrBuilder;
import protobuf_unittest.UnittestProto.TestOneof2;
import protobuf_unittest.UnittestProto.TestPackedExtensions;
import protobuf_unittest.UnittestProto.TestPackedTypes;
+import protobuf_unittest.UnittestProto.TestRequired;
import protobuf_unittest.UnittestProto.TestUnpackedTypes;
import java.io.File;
import java.io.IOException;
@@ -252,6 +253,11 @@ import junit.framework.Assert;
public final class TestUtil {
private TestUtil() {}
+ public static final TestRequired TEST_REQUIRED_UNINITIALIZED =
+ TestRequired.newBuilder().setA(1).buildPartial();
+ public static final TestRequired TEST_REQUIRED_INITIALIZED =
+ TestRequired.newBuilder().setA(1).setB(2).setC(3).build();
+
/** Helper to convert a String to ByteString. */
static ByteString toBytes(String str) {
return ByteString.copyFrom(str.getBytes(Internal.UTF_8));
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 28c4fdea..5d38ca51 100644
--- a/java/core/src/test/java/com/google/protobuf/TextFormatTest.java
+++ b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java
@@ -30,6 +30,9 @@
package com.google.protobuf;
+import static com.google.protobuf.TestUtil.TEST_REQUIRED_INITIALIZED;
+import static com.google.protobuf.TestUtil.TEST_REQUIRED_UNINITIALIZED;
+
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.TextFormat.Parser.SingularOverwritePolicy;
@@ -42,6 +45,7 @@ import protobuf_unittest.UnittestProto.TestAllTypes;
import protobuf_unittest.UnittestProto.TestAllTypes.NestedMessage;
import protobuf_unittest.UnittestProto.TestEmptyMessage;
import protobuf_unittest.UnittestProto.TestOneof2;
+import protobuf_unittest.UnittestProto.TestRequired;
import proto2_wireformat_unittest.UnittestMsetWireFormat.TestMessageSet;
import java.io.StringReader;
import java.util.List;
@@ -326,19 +330,58 @@ public class TextFormatTest extends TestCase {
// =================================================================
- public void testParse() throws Exception {
+ public void testMerge() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
TextFormat.merge(allFieldsSetText, builder);
TestUtil.assertAllFieldsSet(builder.build());
}
- public void testParseReader() throws Exception {
+ public void testParse() throws Exception {
+ TestUtil.assertAllFieldsSet(
+ TextFormat.parse(allFieldsSetText, TestAllTypes.class));
+ }
+
+ public void testMergeInitialized() throws Exception {
+ TestRequired.Builder builder = TestRequired.newBuilder();
+ TextFormat.merge(TEST_REQUIRED_INITIALIZED.toString(), builder);
+ assertEquals(TEST_REQUIRED_INITIALIZED.toString(),
+ builder.buildPartial().toString());
+ assertTrue(builder.isInitialized());
+ }
+
+ public void testParseInitialized() throws Exception {
+ TestRequired parsed =
+ TextFormat.parse(TEST_REQUIRED_INITIALIZED.toString(),
+ TestRequired.class);
+ assertEquals(TEST_REQUIRED_INITIALIZED.toString(), parsed.toString());
+ assertTrue(parsed.isInitialized());
+ }
+
+ public void testMergeUninitialized() throws Exception {
+ TestRequired.Builder builder = TestRequired.newBuilder();
+ TextFormat.merge(TEST_REQUIRED_UNINITIALIZED.toString(), builder);
+ assertEquals(TEST_REQUIRED_UNINITIALIZED.toString(),
+ builder.buildPartial().toString());
+ assertFalse(builder.isInitialized());
+ }
+
+ public void testParseUninitialized() throws Exception {
+ try {
+ TextFormat.parse(TEST_REQUIRED_UNINITIALIZED.toString(),
+ TestRequired.class);
+ fail("Expected UninitializedMessageException.");
+ } catch (UninitializedMessageException e) {
+ assertEquals("Message missing required fields: b, c", e.getMessage());
+ }
+ }
+
+ public void testMergeReader() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
TextFormat.merge(new StringReader(allFieldsSetText), builder);
TestUtil.assertAllFieldsSet(builder.build());
}
- public void testParseExtensions() throws Exception {
+ public void testMergeExtensions() throws Exception {
TestAllExtensions.Builder builder = TestAllExtensions.newBuilder();
TextFormat.merge(allExtensionsSetText,
TestUtil.getExtensionRegistry(),
@@ -346,7 +389,14 @@ public class TextFormatTest extends TestCase {
TestUtil.assertAllExtensionsSet(builder.build());
}
- public void testParseCompatibility() throws Exception {
+ public void testParseExtensions() throws Exception {
+ TestUtil.assertAllExtensionsSet(
+ TextFormat.parse(allExtensionsSetText,
+ TestUtil.getExtensionRegistry(),
+ TestAllExtensions.class));
+ }
+
+ public void testMergeAndParseCompatibility() throws Exception {
String original = "repeated_float: inf\n" +
"repeated_float: -inf\n" +
"repeated_float: nan\n" +
@@ -371,21 +421,29 @@ public class TextFormatTest extends TestCase {
"repeated_double: Infinity\n" +
"repeated_double: -Infinity\n" +
"repeated_double: NaN\n";
+
+ // Test merge().
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
TextFormat.merge(original, builder);
assertEquals(canonical, builder.build().toString());
+
+ // Test parse().
+ assertEquals(canonical,
+ TextFormat.parse(original, TestAllTypes.class).toString());
}
- public void testParseExotic() throws Exception {
+ public void testMergeAndParseExotic() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
TextFormat.merge(exoticText, builder);
// Too lazy to check things individually. Don't try to debug this
// if testPrintExotic() is failing.
assertEquals(canonicalExoticText, builder.build().toString());
+ assertEquals(canonicalExoticText,
+ TextFormat.parse(exoticText, TestAllTypes.class).toString());
}
- public void testParseMessageSet() throws Exception {
+ public void testMergeMessageSet() throws Exception {
ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();
extensionRegistry.add(TestMessageSetExtension1.messageSetExtension);
extensionRegistry.add(TestMessageSetExtension2.messageSetExtension);
@@ -411,7 +469,7 @@ public class TextFormatTest extends TestCase {
TestMessageSetExtension1.messageSetExtension).getI());
}
- public void testParseMessageSetWithOverwriteForbidden() throws Exception {
+ public void testMergeMessageSetWithOverwriteForbidden() throws Exception {
ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();
extensionRegistry.add(TestMessageSetExtension1.messageSetExtension);
extensionRegistry.add(TestMessageSetExtension2.messageSetExtension);
@@ -438,20 +496,20 @@ public class TextFormatTest extends TestCase {
}
}
- public void testParseNumericEnum() throws Exception {
+ public void testMergeNumericEnum() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
TextFormat.merge("optional_nested_enum: 2", builder);
assertEquals(TestAllTypes.NestedEnum.BAR, builder.getOptionalNestedEnum());
}
- public void testParseAngleBrackets() throws Exception {
+ public void testMergeAngleBrackets() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
TextFormat.merge("OptionalGroup: < a: 1 >", builder);
assertTrue(builder.hasOptionalGroup());
assertEquals(1, builder.getOptionalGroup().getA());
}
- public void testParseComment() throws Exception {
+ public void testMergeComment() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
TextFormat.merge(
"# this is a comment\n" +
@@ -463,6 +521,7 @@ public class TextFormatTest extends TestCase {
}
private void assertParseError(String error, String text) {
+ // Test merge().
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
try {
TextFormat.merge(text, TestUtil.getExtensionRegistry(), builder);
@@ -470,6 +529,15 @@ public class TextFormatTest extends TestCase {
} catch (TextFormat.ParseException e) {
assertEquals(error, e.getMessage());
}
+
+ // Test parse().
+ try {
+ TextFormat.parse(
+ text, TestUtil.getExtensionRegistry(), TestAllTypes.class);
+ fail("Expected parse exception.");
+ } catch (TextFormat.ParseException e) {
+ assertEquals(error, e.getMessage());
+ }
}
diff --git a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
index a26dbc2d..7f69ee68 100644
--- a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
+++ b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
@@ -105,7 +105,7 @@ public class JsonFormat {
public static Printer printer() {
return new Printer(
TypeRegistry.getEmptyTypeRegistry(), false, Collections.<FieldDescriptor>emptySet(),
- false, false);
+ false, false, false);
}
/**
@@ -125,18 +125,21 @@ public class JsonFormat {
private Set<FieldDescriptor> includingDefaultValueFields;
private final boolean preservingProtoFieldNames;
private final boolean omittingInsignificantWhitespace;
+ private final boolean printingEnumsAsInts;
private Printer(
TypeRegistry registry,
boolean alwaysOutputDefaultValueFields,
Set<FieldDescriptor> includingDefaultValueFields,
boolean preservingProtoFieldNames,
- boolean omittingInsignificantWhitespace) {
+ boolean omittingInsignificantWhitespace,
+ boolean printingEnumsAsInts) {
this.registry = registry;
this.alwaysOutputDefaultValueFields = alwaysOutputDefaultValueFields;
this.includingDefaultValueFields = includingDefaultValueFields;
this.preservingProtoFieldNames = preservingProtoFieldNames;
this.omittingInsignificantWhitespace = omittingInsignificantWhitespace;
+ this.printingEnumsAsInts = printingEnumsAsInts;
}
/**
@@ -154,7 +157,8 @@ public class JsonFormat {
alwaysOutputDefaultValueFields,
includingDefaultValueFields,
preservingProtoFieldNames,
- omittingInsignificantWhitespace);
+ omittingInsignificantWhitespace,
+ printingEnumsAsInts);
}
/**
@@ -170,7 +174,31 @@ public class JsonFormat {
true,
Collections.<FieldDescriptor>emptySet(),
preservingProtoFieldNames,
- omittingInsignificantWhitespace);
+ omittingInsignificantWhitespace,
+ printingEnumsAsInts);
+ }
+
+ /**
+ * Creates a new {@link Printer} that will print enum field values as integers instead of as
+ * string.
+ * The new Printer clones all other configurations from the current
+ * {@link Printer}.
+ */
+ public Printer printingEnumsAsInts() {
+ checkUnsetPrintingEnumsAsInts();
+ return new Printer(
+ registry,
+ alwaysOutputDefaultValueFields,
+ Collections.<FieldDescriptor>emptySet(),
+ preservingProtoFieldNames,
+ omittingInsignificantWhitespace,
+ true);
+ }
+
+ private void checkUnsetPrintingEnumsAsInts() {
+ if (printingEnumsAsInts) {
+ throw new IllegalStateException("JsonFormat printingEnumsAsInts has already been set.");
+ }
}
/**
@@ -191,7 +219,8 @@ public class JsonFormat {
false,
fieldsToAlwaysOutput,
preservingProtoFieldNames,
- omittingInsignificantWhitespace);
+ omittingInsignificantWhitespace,
+ printingEnumsAsInts);
}
private void checkUnsetIncludingDefaultValueFields() {
@@ -213,7 +242,8 @@ public class JsonFormat {
alwaysOutputDefaultValueFields,
includingDefaultValueFields,
true,
- omittingInsignificantWhitespace);
+ omittingInsignificantWhitespace,
+ printingEnumsAsInts);
}
@@ -240,7 +270,8 @@ public class JsonFormat {
alwaysOutputDefaultValueFields,
includingDefaultValueFields,
preservingProtoFieldNames,
- true);
+ true,
+ printingEnumsAsInts);
}
/**
@@ -259,7 +290,8 @@ public class JsonFormat {
includingDefaultValueFields,
preservingProtoFieldNames,
output,
- omittingInsignificantWhitespace)
+ omittingInsignificantWhitespace,
+ printingEnumsAsInts)
.print(message);
}
@@ -416,7 +448,7 @@ public class JsonFormat {
*/
public Builder add(Iterable<Descriptor> messageTypes) {
if (types == null) {
- throw new IllegalStateException("A TypeRegistry.Builer can only be used once.");
+ throw new IllegalStateException("A TypeRegistry.Builder can only be used once.");
}
for (Descriptor type : messageTypes) {
addFile(type.getFile());
@@ -570,6 +602,7 @@ public class JsonFormat {
private final boolean alwaysOutputDefaultValueFields;
private final Set<FieldDescriptor> includingDefaultValueFields;
private final boolean preservingProtoFieldNames;
+ private final boolean printingEnumsAsInts;
private final TextGenerator generator;
// We use Gson to help handle string escapes.
private final Gson gson;
@@ -586,11 +619,13 @@ public class JsonFormat {
Set<FieldDescriptor> includingDefaultValueFields,
boolean preservingProtoFieldNames,
Appendable jsonOutput,
- boolean omittingInsignificantWhitespace) {
+ boolean omittingInsignificantWhitespace,
+ boolean printingEnumsAsInts) {
this.registry = registry;
this.alwaysOutputDefaultValueFields = alwaysOutputDefaultValueFields;
this.includingDefaultValueFields = includingDefaultValueFields;
this.preservingProtoFieldNames = preservingProtoFieldNames;
+ this.printingEnumsAsInts = printingEnumsAsInts;
this.gson = GsonHolder.DEFAULT_GSON;
// json format related properties, determined by printerType
if (omittingInsignificantWhitespace) {
@@ -1069,7 +1104,7 @@ public class JsonFormat {
generator.print("\"");
}
} else {
- if (((EnumValueDescriptor) value).getIndex() == -1) {
+ if (printingEnumsAsInts || ((EnumValueDescriptor) value).getIndex() == -1) {
generator.print(String.valueOf(((EnumValueDescriptor) value).getNumber()));
} else {
generator.print("\"" + ((EnumValueDescriptor) value).getName() + "\"");
diff --git a/java/util/src/main/java/com/google/protobuf/util/Timestamps.java b/java/util/src/main/java/com/google/protobuf/util/Timestamps.java
index 7a1f2014..9e528d4a 100644
--- a/java/util/src/main/java/com/google/protobuf/util/Timestamps.java
+++ b/java/util/src/main/java/com/google/protobuf/util/Timestamps.java
@@ -74,6 +74,11 @@ public final class Timestamps {
public static final Timestamp MAX_VALUE =
Timestamp.newBuilder().setSeconds(TIMESTAMP_SECONDS_MAX).setNanos(999999999).build();
+ /**
+ * A constant holding the {@link Timestamp} of epoch time, {@code 1970-01-01T00:00:00.000000000Z}.
+ */
+ public static final Timestamp EPOCH = Timestamp.newBuilder().setSeconds(0).setNanos(0).build();
+
private static final ThreadLocal<SimpleDateFormat> timestampFormat =
new ThreadLocal<SimpleDateFormat>() {
@Override
@@ -358,10 +363,12 @@ public final class Timestamps {
static Timestamp normalizedTimestamp(long seconds, int nanos) {
if (nanos <= -NANOS_PER_SECOND || nanos >= NANOS_PER_SECOND) {
seconds = checkedAdd(seconds, nanos / NANOS_PER_SECOND);
- nanos %= NANOS_PER_SECOND;
+ nanos = (int) (nanos % NANOS_PER_SECOND);
}
if (nanos < 0) {
- nanos += NANOS_PER_SECOND; // no overflow since nanos is negative (and we're adding)
+ nanos =
+ (int)
+ (nanos + NANOS_PER_SECOND); // no overflow since nanos is negative (and we're adding)
seconds = checkedSubtract(seconds, 1);
}
Timestamp timestamp = Timestamp.newBuilder().setSeconds(seconds).setNanos(nanos).build();
diff --git a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
index e4c5387a..6ef08508 100644
--- a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
+++ b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
@@ -1174,6 +1174,14 @@ public class JsonFormatTest extends TestCase {
JsonFormat.parser().ignoringUnknownFields().merge(json, builder);
}
+ public void testParserIntegerEnumValue() throws Exception {
+ TestAllTypes.Builder actualBuilder = TestAllTypes.newBuilder();
+ mergeFromJson("{\n" + " \"optionalNestedEnum\": 2\n" + "}", actualBuilder);
+
+ TestAllTypes expected = TestAllTypes.newBuilder().setOptionalNestedEnum(NestedEnum.BAZ).build();
+ assertEquals(expected, actualBuilder.build());
+ }
+
public void testCustomJsonName() throws Exception {
TestCustomJsonName message = TestCustomJsonName.newBuilder().setValue(12345).build();
assertEquals("{\n" + " \"@value\": 12345\n" + "}", JsonFormat.printer().print(message));
@@ -1441,6 +1449,13 @@ public class JsonFormatTest extends TestCase {
assertEquals(54321, builder.getOptionalInt32());
}
+ public void testPrintingEnumsAsInts() throws Exception {
+ TestAllTypes message = TestAllTypes.newBuilder().setOptionalNestedEnum(NestedEnum.BAR).build();
+ assertEquals(
+ "{\n" + " \"optionalNestedEnum\": 1\n" + "}",
+ JsonFormat.printer().printingEnumsAsInts().print(message));
+ }
+
public void testOmittingInsignificantWhiteSpace() throws Exception {
TestAllTypes message = TestAllTypes.newBuilder().setOptionalInt32(12345).build();
assertEquals(
diff --git a/js/binary/arith.js b/js/binary/arith.js
index 70257de7..62528a26 100644
--- a/js/binary/arith.js
+++ b/js/binary/arith.js
@@ -221,7 +221,7 @@ jspb.arith.UInt64.prototype.mul = function(a) {
* Divide a 64-bit number by a 32-bit number to produce a
* 64-bit quotient and a 32-bit remainder.
* @param {number} _divisor
- * @return {Array.<jspb.arith.UInt64>} array of [quotient, remainder],
+ * @return {Array<jspb.arith.UInt64>} array of [quotient, remainder],
* unless divisor is 0, in which case an empty array is returned.
*/
jspb.arith.UInt64.prototype.div = function(_divisor) {
diff --git a/js/binary/decoder.js b/js/binary/decoder.js
index 4ec3cada..d0c0bc17 100644
--- a/js/binary/decoder.js
+++ b/js/binary/decoder.js
@@ -58,7 +58,7 @@ goog.require('jspb.utils');
* @param {?jspb.BinaryDecoder=} opt_decoder
* @param {?function(this:jspb.BinaryDecoder):(number|boolean|string)=}
* opt_next The decoder method to use for next().
- * @param {?Array.<number|boolean|string>=} opt_elements
+ * @param {?Array<number|boolean|string>=} opt_elements
* @constructor
* @struct
*/
@@ -92,7 +92,7 @@ jspb.BinaryIterator = function(opt_decoder, opt_next, opt_elements) {
* @param {?jspb.BinaryDecoder=} opt_decoder
* @param {?function(this:jspb.BinaryDecoder):(number|boolean|string)=}
* opt_next The decoder method to use for next().
- * @param {?Array.<number|boolean|string>=} opt_elements
+ * @param {?Array<number|boolean|string>=} opt_elements
* @private
*/
jspb.BinaryIterator.prototype.init_ =
@@ -112,7 +112,7 @@ jspb.BinaryIterator.prototype.init_ =
/**
* Global pool of BinaryIterator instances.
- * @private {!Array.<!jspb.BinaryIterator>}
+ * @private {!Array<!jspb.BinaryIterator>}
*/
jspb.BinaryIterator.instanceCache_ = [];
@@ -123,7 +123,7 @@ jspb.BinaryIterator.instanceCache_ = [];
* @param {?jspb.BinaryDecoder=} opt_decoder
* @param {?function(this:jspb.BinaryDecoder):(number|boolean|string)=}
* opt_next The decoder method to use for next().
- * @param {?Array.<number|boolean|string>=} opt_elements
+ * @param {?Array<number|boolean|string>=} opt_elements
* @return {!jspb.BinaryIterator}
*/
jspb.BinaryIterator.alloc = function(opt_decoder, opt_next, opt_elements) {
@@ -274,7 +274,7 @@ jspb.BinaryDecoder = function(opt_bytes, opt_start, opt_length) {
/**
* Global pool of BinaryDecoder instances.
- * @private {!Array.<!jspb.BinaryDecoder>}
+ * @private {!Array<!jspb.BinaryDecoder>}
*/
jspb.BinaryDecoder.instanceCache_ = [];
diff --git a/js/binary/encoder.js b/js/binary/encoder.js
index 8e9f5bbc..b2013f63 100644
--- a/js/binary/encoder.js
+++ b/js/binary/encoder.js
@@ -51,7 +51,7 @@ goog.require('jspb.utils');
* @struct
*/
jspb.BinaryEncoder = function() {
- /** @private {!Array.<number>} */
+ /** @private {!Array<number>} */
this.buffer_ = [];
};
@@ -65,7 +65,7 @@ jspb.BinaryEncoder.prototype.length = function() {
/**
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryEncoder.prototype.end = function() {
var buffer = this.buffer_;
diff --git a/js/binary/reader.js b/js/binary/reader.js
index d5d698f7..2dc3eb70 100644
--- a/js/binary/reader.js
+++ b/js/binary/reader.js
@@ -97,7 +97,7 @@ jspb.BinaryReader = function(opt_bytes, opt_start, opt_length) {
/**
* User-defined reader callbacks.
- * @private {Object.<string, function(!jspb.BinaryReader):*>}
+ * @private {Object<string, function(!jspb.BinaryReader):*>}
*/
this.readCallbacks_ = null;
};
@@ -105,7 +105,7 @@ jspb.BinaryReader = function(opt_bytes, opt_start, opt_length) {
/**
* Global pool of BinaryReader instances.
- * @private {!Array.<!jspb.BinaryReader>}
+ * @private {!Array<!jspb.BinaryReader>}
*/
jspb.BinaryReader.instanceCache_ = [];
@@ -992,7 +992,7 @@ jspb.BinaryReader.prototype.readPackedField_ = function(decodeMethod) {
/**
* Reads a packed int32 field, which consists of a length header and a list of
* signed varints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedInt32 = function() {
return this.readPackedField_(this.decoder_.readSignedVarint32);
@@ -1002,7 +1002,7 @@ jspb.BinaryReader.prototype.readPackedInt32 = function() {
/**
* Reads a packed int32 field, which consists of a length header and a list of
* signed varints. Returns a list of strings.
- * @return {!Array.<string>}
+ * @return {!Array<string>}
*/
jspb.BinaryReader.prototype.readPackedInt32String = function() {
return this.readPackedField_(this.decoder_.readSignedVarint32String);
@@ -1012,7 +1012,7 @@ jspb.BinaryReader.prototype.readPackedInt32String = function() {
/**
* Reads a packed int64 field, which consists of a length header and a list of
* signed varints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedInt64 = function() {
return this.readPackedField_(this.decoder_.readSignedVarint64);
@@ -1022,7 +1022,7 @@ jspb.BinaryReader.prototype.readPackedInt64 = function() {
/**
* Reads a packed int64 field, which consists of a length header and a list of
* signed varints. Returns a list of strings.
- * @return {!Array.<string>}
+ * @return {!Array<string>}
*/
jspb.BinaryReader.prototype.readPackedInt64String = function() {
return this.readPackedField_(this.decoder_.readSignedVarint64String);
@@ -1032,7 +1032,7 @@ jspb.BinaryReader.prototype.readPackedInt64String = function() {
/**
* Reads a packed uint32 field, which consists of a length header and a list of
* unsigned varints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedUint32 = function() {
return this.readPackedField_(this.decoder_.readUnsignedVarint32);
@@ -1042,7 +1042,7 @@ jspb.BinaryReader.prototype.readPackedUint32 = function() {
/**
* Reads a packed uint32 field, which consists of a length header and a list of
* unsigned varints. Returns a list of strings.
- * @return {!Array.<string>}
+ * @return {!Array<string>}
*/
jspb.BinaryReader.prototype.readPackedUint32String = function() {
return this.readPackedField_(this.decoder_.readUnsignedVarint32String);
@@ -1052,7 +1052,7 @@ jspb.BinaryReader.prototype.readPackedUint32String = function() {
/**
* Reads a packed uint64 field, which consists of a length header and a list of
* unsigned varints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedUint64 = function() {
return this.readPackedField_(this.decoder_.readUnsignedVarint64);
@@ -1062,7 +1062,7 @@ jspb.BinaryReader.prototype.readPackedUint64 = function() {
/**
* Reads a packed uint64 field, which consists of a length header and a list of
* unsigned varints. Returns a list of strings.
- * @return {!Array.<string>}
+ * @return {!Array<string>}
*/
jspb.BinaryReader.prototype.readPackedUint64String = function() {
return this.readPackedField_(this.decoder_.readUnsignedVarint64String);
@@ -1072,7 +1072,7 @@ jspb.BinaryReader.prototype.readPackedUint64String = function() {
/**
* Reads a packed sint32 field, which consists of a length header and a list of
* zigzag varints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedSint32 = function() {
return this.readPackedField_(this.decoder_.readZigzagVarint32);
@@ -1082,7 +1082,7 @@ jspb.BinaryReader.prototype.readPackedSint32 = function() {
/**
* Reads a packed sint64 field, which consists of a length header and a list of
* zigzag varints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedSint64 = function() {
return this.readPackedField_(this.decoder_.readZigzagVarint64);
@@ -1092,7 +1092,7 @@ jspb.BinaryReader.prototype.readPackedSint64 = function() {
/**
* Reads a packed sint64 field, which consists of a length header and a list of
* zigzag varints. Returns a list of strings.
- * @return {!Array.<string>}
+ * @return {!Array<string>}
*/
jspb.BinaryReader.prototype.readPackedSint64String = function() {
return this.readPackedField_(this.decoder_.readZigzagVarint64String);
@@ -1102,7 +1102,7 @@ jspb.BinaryReader.prototype.readPackedSint64String = function() {
/**
* Reads a packed fixed32 field, which consists of a length header and a list
* of unsigned 32-bit ints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedFixed32 = function() {
return this.readPackedField_(this.decoder_.readUint32);
@@ -1112,7 +1112,7 @@ jspb.BinaryReader.prototype.readPackedFixed32 = function() {
/**
* Reads a packed fixed64 field, which consists of a length header and a list
* of unsigned 64-bit ints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedFixed64 = function() {
return this.readPackedField_(this.decoder_.readUint64);
@@ -1122,7 +1122,7 @@ jspb.BinaryReader.prototype.readPackedFixed64 = function() {
/**
* Reads a packed fixed64 field, which consists of a length header and a list
* of unsigned 64-bit ints. Returns a list of strings.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedFixed64String = function() {
return this.readPackedField_(this.decoder_.readUint64String);
@@ -1132,7 +1132,7 @@ jspb.BinaryReader.prototype.readPackedFixed64String = function() {
/**
* Reads a packed sfixed32 field, which consists of a length header and a list
* of 32-bit ints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedSfixed32 = function() {
return this.readPackedField_(this.decoder_.readInt32);
@@ -1142,7 +1142,7 @@ jspb.BinaryReader.prototype.readPackedSfixed32 = function() {
/**
* Reads a packed sfixed64 field, which consists of a length header and a list
* of 64-bit ints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedSfixed64 = function() {
return this.readPackedField_(this.decoder_.readInt64);
@@ -1152,7 +1152,7 @@ jspb.BinaryReader.prototype.readPackedSfixed64 = function() {
/**
* Reads a packed sfixed64 field, which consists of a length header and a list
* of 64-bit ints. Returns a list of strings.
- * @return {!Array.<string>}
+ * @return {!Array<string>}
*/
jspb.BinaryReader.prototype.readPackedSfixed64String = function() {
return this.readPackedField_(this.decoder_.readInt64String);
@@ -1162,7 +1162,7 @@ jspb.BinaryReader.prototype.readPackedSfixed64String = function() {
/**
* Reads a packed float field, which consists of a length header and a list of
* floats.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedFloat = function() {
return this.readPackedField_(this.decoder_.readFloat);
@@ -1172,7 +1172,7 @@ jspb.BinaryReader.prototype.readPackedFloat = function() {
/**
* Reads a packed double field, which consists of a length header and a list of
* doubles.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedDouble = function() {
return this.readPackedField_(this.decoder_.readDouble);
@@ -1182,7 +1182,7 @@ jspb.BinaryReader.prototype.readPackedDouble = function() {
/**
* Reads a packed bool field, which consists of a length header and a list of
* unsigned varints.
- * @return {!Array.<boolean>}
+ * @return {!Array<boolean>}
*/
jspb.BinaryReader.prototype.readPackedBool = function() {
return this.readPackedField_(this.decoder_.readBool);
@@ -1192,7 +1192,7 @@ jspb.BinaryReader.prototype.readPackedBool = function() {
/**
* Reads a packed enum field, which consists of a length header and a list of
* unsigned varints.
- * @return {!Array.<number>}
+ * @return {!Array<number>}
*/
jspb.BinaryReader.prototype.readPackedEnum = function() {
return this.readPackedField_(this.decoder_.readEnum);
@@ -1202,7 +1202,7 @@ jspb.BinaryReader.prototype.readPackedEnum = function() {
/**
* Reads a packed varint hash64 field, which consists of a length header and a
* list of varint hash64s.
- * @return {!Array.<string>}
+ * @return {!Array<string>}
*/
jspb.BinaryReader.prototype.readPackedVarintHash64 = function() {
return this.readPackedField_(this.decoder_.readVarintHash64);
@@ -1212,7 +1212,7 @@ jspb.BinaryReader.prototype.readPackedVarintHash64 = function() {
/**
* Reads a packed fixed hash64 field, which consists of a length header and a
* list of fixed hash64s.
- * @return {!Array.<string>}
+ * @return {!Array<string>}
*/
jspb.BinaryReader.prototype.readPackedFixedHash64 = function() {
return this.readPackedField_(this.decoder_.readFixedHash64);
diff --git a/js/binary/utils.js b/js/binary/utils.js
index c706bff4..87570ff8 100644
--- a/js/binary/utils.js
+++ b/js/binary/utils.js
@@ -431,7 +431,7 @@ jspb.utils.joinHash64 = function(bitsLow, bitsHigh) {
/**
* Individual digits for number->string conversion.
- * @const {!Array.<string>}
+ * @const {!Array<string>}
*/
jspb.utils.DIGITS = [
'0', '1', '2', '3', '4', '5', '6', '7',
@@ -554,10 +554,10 @@ jspb.utils.hash64ToDecimalString = function(hash, signed) {
/**
* Converts an array of 8-character hash strings into their decimal
* representations.
- * @param {!Array.<string>} hashes The array of hash strings to convert.
+ * @param {!Array<string>} hashes The array of hash strings to convert.
* @param {boolean} signed True if we should treat the hash string as encoding
* a signed integer.
- * @return {!Array.<string>}
+ * @return {!Array<string>}
*/
jspb.utils.hash64ArrayToDecimalStrings = function(hashes, signed) {
var result = new Array(hashes.length);
@@ -972,7 +972,7 @@ jspb.utils.byteSourceToUint8Array = function(data) {
}
if (data.constructor === Array) {
- data = /** @type {!Array.<number>} */(data);
+ data = /** @type {!Array<number>} */(data);
return /** @type {!Uint8Array} */(new Uint8Array(data));
}
diff --git a/js/binary/utils_test.js b/js/binary/utils_test.js
index 6b481dce..13450644 100644
--- a/js/binary/utils_test.js
+++ b/js/binary/utils_test.js
@@ -657,7 +657,7 @@ describe('binaryUtilsTest', function() {
// Converting Uint8Arrays into Uint8Arrays should be a no-op.
assertEquals(sourceBytes, convert(sourceBytes));
- // Converting Array.<numbers> into Uint8Arrays should work.
+ // Converting Array<numbers> into Uint8Arrays should work.
check(convert(sourceData));
// Converting ArrayBuffers into Uint8Arrays should work.
diff --git a/js/binary/writer.js b/js/binary/writer.js
index 037e92b2..8a018058 100644
--- a/js/binary/writer.js
+++ b/js/binary/writer.js
@@ -102,7 +102,7 @@ jspb.BinaryWriter = function() {
* A stack of bookmarks containing the parent blocks for each message started
* via beginSubMessage(), needed as bookkeeping for endSubMessage().
* TODO(aappleby): Deprecated, users should be calling writeMessage().
- * @private {!Array.<!Array.<number>>}
+ * @private {!Array<!Array<number>>}
*/
this.bookmarks_ = [];
};
@@ -126,7 +126,7 @@ jspb.BinaryWriter.prototype.appendUint8Array_ = function(arr) {
* Begins a new message by writing the field header and returning a bookmark
* which we will use to patch in the message length to in endDelimited_ below.
* @param {number} field
- * @return {!Array.<number>}
+ * @return {!Array<number>}
* @private
*/
jspb.BinaryWriter.prototype.beginDelimited_ = function(field) {
@@ -143,7 +143,7 @@ jspb.BinaryWriter.prototype.beginDelimited_ = function(field) {
* Ends a message by encoding the _change_ in length of the buffer to the
* parent block and adds the number of bytes needed to encode that length to
* the total byte length.
- * @param {!Array.<number>} bookmark
+ * @param {!Array<number>} bookmark
* @private
*/
jspb.BinaryWriter.prototype.endDelimited_ = function(bookmark) {
@@ -855,7 +855,7 @@ jspb.BinaryWriter.prototype.writeVarintHash64 = function(field, value) {
/**
* Writes an array of numbers to the buffer as a repeated 32-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedInt32 = function(field, value) {
if (value == null) return;
@@ -869,7 +869,7 @@ jspb.BinaryWriter.prototype.writeRepeatedInt32 = function(field, value) {
* Writes an array of numbers formatted as strings to the buffer as a repeated
* 32-bit int field.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of ints to write.
+ * @param {?Array<string>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedInt32String = function(field, value) {
if (value == null) return;
@@ -882,7 +882,7 @@ jspb.BinaryWriter.prototype.writeRepeatedInt32String = function(field, value) {
/**
* Writes an array of numbers to the buffer as a repeated 64-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedInt64 = function(field, value) {
if (value == null) return;
@@ -896,7 +896,7 @@ jspb.BinaryWriter.prototype.writeRepeatedInt64 = function(field, value) {
* Writes an array of numbers formatted as strings to the buffer as a repeated
* 64-bit int field.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of ints to write.
+ * @param {?Array<string>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedInt64String = function(field, value) {
if (value == null) return;
@@ -910,7 +910,7 @@ jspb.BinaryWriter.prototype.writeRepeatedInt64String = function(field, value) {
* Writes an array numbers to the buffer as a repeated unsigned 32-bit int
* field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedUint32 = function(field, value) {
if (value == null) return;
@@ -924,7 +924,7 @@ jspb.BinaryWriter.prototype.writeRepeatedUint32 = function(field, value) {
* Writes an array of numbers formatted as strings to the buffer as a repeated
* unsigned 32-bit int field.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of ints to write.
+ * @param {?Array<string>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedUint32String = function(field, value) {
if (value == null) return;
@@ -938,7 +938,7 @@ jspb.BinaryWriter.prototype.writeRepeatedUint32String = function(field, value) {
* Writes an array numbers to the buffer as a repeated unsigned 64-bit int
* field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedUint64 = function(field, value) {
if (value == null) return;
@@ -952,7 +952,7 @@ jspb.BinaryWriter.prototype.writeRepeatedUint64 = function(field, value) {
* Writes an array of numbers formatted as strings to the buffer as a repeated
* unsigned 64-bit int field.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of ints to write.
+ * @param {?Array<string>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedUint64String = function(field, value) {
if (value == null) return;
@@ -965,7 +965,7 @@ jspb.BinaryWriter.prototype.writeRepeatedUint64String = function(field, value) {
/**
* Writes an array numbers to the buffer as a repeated signed 32-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedSint32 = function(field, value) {
if (value == null) return;
@@ -978,7 +978,7 @@ jspb.BinaryWriter.prototype.writeRepeatedSint32 = function(field, value) {
/**
* Writes an array numbers to the buffer as a repeated signed 64-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedSint64 = function(field, value) {
if (value == null) return;
@@ -991,7 +991,7 @@ jspb.BinaryWriter.prototype.writeRepeatedSint64 = function(field, value) {
/**
* Writes an array numbers to the buffer as a repeated signed 64-bit int field.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of ints to write.
+ * @param {?Array<string>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedSint64String = function(field, value) {
if (value == null) return;
@@ -1005,7 +1005,7 @@ jspb.BinaryWriter.prototype.writeRepeatedSint64String = function(field, value) {
* Writes an array of numbers to the buffer as a repeated fixed32 field. This
* works for both signed and unsigned fixed32s.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedFixed32 = function(field, value) {
if (value == null) return;
@@ -1019,7 +1019,7 @@ jspb.BinaryWriter.prototype.writeRepeatedFixed32 = function(field, value) {
* Writes an array of numbers to the buffer as a repeated fixed64 field. This
* works for both signed and unsigned fixed64s.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedFixed64 = function(field, value) {
if (value == null) return;
@@ -1033,7 +1033,7 @@ jspb.BinaryWriter.prototype.writeRepeatedFixed64 = function(field, value) {
* Writes an array of numbers to the buffer as a repeated fixed64 field. This
* works for both signed and unsigned fixed64s.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of decimal strings to write.
+ * @param {?Array<string>} value The array of decimal strings to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedFixed64String = function(
field, value) {
@@ -1047,7 +1047,7 @@ jspb.BinaryWriter.prototype.writeRepeatedFixed64String = function(
/**
* Writes an array of numbers to the buffer as a repeated sfixed32 field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedSfixed32 = function(field, value) {
if (value == null) return;
@@ -1060,7 +1060,7 @@ jspb.BinaryWriter.prototype.writeRepeatedSfixed32 = function(field, value) {
/**
* Writes an array of numbers to the buffer as a repeated sfixed64 field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedSfixed64 = function(field, value) {
if (value == null) return;
@@ -1074,7 +1074,7 @@ jspb.BinaryWriter.prototype.writeRepeatedSfixed64 = function(field, value) {
* Writes an array of decimal strings to the buffer as a repeated sfixed64
* field.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of decimal strings to write.
+ * @param {?Array<string>} value The array of decimal strings to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedSfixed64String = function(field, value) {
if (value == null) return;
@@ -1087,7 +1087,7 @@ jspb.BinaryWriter.prototype.writeRepeatedSfixed64String = function(field, value)
/**
* Writes an array of numbers to the buffer as a repeated float field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedFloat = function(field, value) {
if (value == null) return;
@@ -1100,7 +1100,7 @@ jspb.BinaryWriter.prototype.writeRepeatedFloat = function(field, value) {
/**
* Writes an array of numbers to the buffer as a repeated double field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedDouble = function(field, value) {
if (value == null) return;
@@ -1113,7 +1113,7 @@ jspb.BinaryWriter.prototype.writeRepeatedDouble = function(field, value) {
/**
* Writes an array of booleans to the buffer as a repeated bool field.
* @param {number} field The field number.
- * @param {?Array.<boolean>} value The array of ints to write.
+ * @param {?Array<boolean>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedBool = function(field, value) {
if (value == null) return;
@@ -1126,7 +1126,7 @@ jspb.BinaryWriter.prototype.writeRepeatedBool = function(field, value) {
/**
* Writes an array of enums to the buffer as a repeated enum field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedEnum = function(field, value) {
if (value == null) return;
@@ -1139,7 +1139,7 @@ jspb.BinaryWriter.prototype.writeRepeatedEnum = function(field, value) {
/**
* Writes an array of strings to the buffer as a repeated string field.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of strings to write.
+ * @param {?Array<string>} value The array of strings to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedString = function(field, value) {
if (value == null) return;
@@ -1152,7 +1152,7 @@ jspb.BinaryWriter.prototype.writeRepeatedString = function(field, value) {
/**
* Writes an array of arbitrary byte fields to the buffer.
* @param {number} field The field number.
- * @param {?Array.<!jspb.ByteSource>} value The arrays of arrays of bytes to
+ * @param {?Array<!jspb.ByteSource>} value The arrays of arrays of bytes to
* write.
*/
jspb.BinaryWriter.prototype.writeRepeatedBytes = function(field, value) {
@@ -1167,7 +1167,7 @@ jspb.BinaryWriter.prototype.writeRepeatedBytes = function(field, value) {
* Writes an array of messages to the buffer.
* @template MessageType
* @param {number} field The field number.
- * @param {?Array.<MessageType>} value The array of messages to
+ * @param {?Array<MessageType>} value The array of messages to
* write.
* @param {function(MessageType, !jspb.BinaryWriter)} writerCallback
* Will be invoked with the value to write and the writer to write it with.
@@ -1187,7 +1187,7 @@ jspb.BinaryWriter.prototype.writeRepeatedMessage = function(
* Writes an array of group messages to the buffer.
* @template MessageType
* @param {number} field The field number.
- * @param {?Array.<MessageType>} value The array of messages to
+ * @param {?Array<MessageType>} value The array of messages to
* write.
* @param {function(MessageType, !jspb.BinaryWriter)} writerCallback
* Will be invoked with the value to write and the writer to write it with.
@@ -1207,7 +1207,7 @@ jspb.BinaryWriter.prototype.writeRepeatedGroup = function(
* Writes a 64-bit hash string field (8 characters @ 8 bits of data each) to
* the buffer.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of hashes to write.
+ * @param {?Array<string>} value The array of hashes to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedFixedHash64 =
function(field, value) {
@@ -1222,7 +1222,7 @@ jspb.BinaryWriter.prototype.writeRepeatedFixedHash64 =
* Writes a repeated 64-bit hash string field (8 characters @ 8 bits of data
* each) to the buffer.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of hashes to write.
+ * @param {?Array<string>} value The array of hashes to write.
*/
jspb.BinaryWriter.prototype.writeRepeatedVarintHash64 =
function(field, value) {
@@ -1236,7 +1236,7 @@ jspb.BinaryWriter.prototype.writeRepeatedVarintHash64 =
/**
* Writes an array of numbers to the buffer as a packed 32-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedInt32 = function(field, value) {
if (value == null || !value.length) return;
@@ -1252,7 +1252,7 @@ jspb.BinaryWriter.prototype.writePackedInt32 = function(field, value) {
* Writes an array of numbers represented as strings to the buffer as a packed
* 32-bit int field.
* @param {number} field
- * @param {?Array.<string>} value
+ * @param {?Array<string>} value
*/
jspb.BinaryWriter.prototype.writePackedInt32String = function(field, value) {
if (value == null || !value.length) return;
@@ -1267,7 +1267,7 @@ jspb.BinaryWriter.prototype.writePackedInt32String = function(field, value) {
/**
* Writes an array of numbers to the buffer as a packed 64-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedInt64 = function(field, value) {
if (value == null || !value.length) return;
@@ -1283,7 +1283,7 @@ jspb.BinaryWriter.prototype.writePackedInt64 = function(field, value) {
* Writes an array of numbers represented as strings to the buffer as a packed
* 64-bit int field.
* @param {number} field
- * @param {?Array.<string>} value
+ * @param {?Array<string>} value
*/
jspb.BinaryWriter.prototype.writePackedInt64String = function(field, value) {
if (value == null || !value.length) return;
@@ -1299,7 +1299,7 @@ jspb.BinaryWriter.prototype.writePackedInt64String = function(field, value) {
/**
* Writes an array numbers to the buffer as a packed unsigned 32-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedUint32 = function(field, value) {
if (value == null || !value.length) return;
@@ -1315,7 +1315,7 @@ jspb.BinaryWriter.prototype.writePackedUint32 = function(field, value) {
* Writes an array of numbers represented as strings to the buffer as a packed
* unsigned 32-bit int field.
* @param {number} field
- * @param {?Array.<string>} value
+ * @param {?Array<string>} value
*/
jspb.BinaryWriter.prototype.writePackedUint32String =
function(field, value) {
@@ -1331,7 +1331,7 @@ jspb.BinaryWriter.prototype.writePackedUint32String =
/**
* Writes an array numbers to the buffer as a packed unsigned 64-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedUint64 = function(field, value) {
if (value == null || !value.length) return;
@@ -1347,7 +1347,7 @@ jspb.BinaryWriter.prototype.writePackedUint64 = function(field, value) {
* Writes an array of numbers represented as strings to the buffer as a packed
* unsigned 64-bit int field.
* @param {number} field
- * @param {?Array.<string>} value
+ * @param {?Array<string>} value
*/
jspb.BinaryWriter.prototype.writePackedUint64String =
function(field, value) {
@@ -1364,7 +1364,7 @@ jspb.BinaryWriter.prototype.writePackedUint64String =
/**
* Writes an array numbers to the buffer as a packed signed 32-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedSint32 = function(field, value) {
if (value == null || !value.length) return;
@@ -1379,7 +1379,7 @@ jspb.BinaryWriter.prototype.writePackedSint32 = function(field, value) {
/**
* Writes an array of numbers to the buffer as a packed signed 64-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedSint64 = function(field, value) {
if (value == null || !value.length) return;
@@ -1395,7 +1395,7 @@ jspb.BinaryWriter.prototype.writePackedSint64 = function(field, value) {
* Writes an array of decimal strings to the buffer as a packed signed 64-bit
* int field.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of decimal strings to write.
+ * @param {?Array<string>} value The array of decimal strings to write.
*/
jspb.BinaryWriter.prototype.writePackedSint64String = function(field, value) {
if (value == null || !value.length) return;
@@ -1411,7 +1411,7 @@ jspb.BinaryWriter.prototype.writePackedSint64String = function(field, value) {
/**
* Writes an array of numbers to the buffer as a packed fixed32 field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedFixed32 = function(field, value) {
if (value == null || !value.length) return;
@@ -1426,7 +1426,7 @@ jspb.BinaryWriter.prototype.writePackedFixed32 = function(field, value) {
/**
* Writes an array of numbers to the buffer as a packed fixed64 field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedFixed64 = function(field, value) {
if (value == null || !value.length) return;
@@ -1442,7 +1442,7 @@ jspb.BinaryWriter.prototype.writePackedFixed64 = function(field, value) {
* Writes an array of numbers represented as strings to the buffer as a packed
* fixed64 field.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of strings to write.
+ * @param {?Array<string>} value The array of strings to write.
*/
jspb.BinaryWriter.prototype.writePackedFixed64String = function(field, value) {
if (value == null || !value.length) return;
@@ -1458,7 +1458,7 @@ jspb.BinaryWriter.prototype.writePackedFixed64String = function(field, value) {
/**
* Writes an array of numbers to the buffer as a packed sfixed32 field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedSfixed32 = function(field, value) {
if (value == null || !value.length) return;
@@ -1473,7 +1473,7 @@ jspb.BinaryWriter.prototype.writePackedSfixed32 = function(field, value) {
/**
* Writes an array of numbers to the buffer as a packed sfixed64 field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedSfixed64 = function(field, value) {
if (value == null || !value.length) return;
@@ -1488,7 +1488,7 @@ jspb.BinaryWriter.prototype.writePackedSfixed64 = function(field, value) {
/**
* Writes an array of numbers to the buffer as a packed sfixed64 field.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of decimal strings to write.
+ * @param {?Array<string>} value The array of decimal strings to write.
*/
jspb.BinaryWriter.prototype.writePackedSfixed64String = function(field, value) {
if (value == null || !value.length) return;
@@ -1503,7 +1503,7 @@ jspb.BinaryWriter.prototype.writePackedSfixed64String = function(field, value) {
/**
* Writes an array of numbers to the buffer as a packed float field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedFloat = function(field, value) {
if (value == null || !value.length) return;
@@ -1518,7 +1518,7 @@ jspb.BinaryWriter.prototype.writePackedFloat = function(field, value) {
/**
* Writes an array of numbers to the buffer as a packed double field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedDouble = function(field, value) {
if (value == null || !value.length) return;
@@ -1533,7 +1533,7 @@ jspb.BinaryWriter.prototype.writePackedDouble = function(field, value) {
/**
* Writes an array of booleans to the buffer as a packed bool field.
* @param {number} field The field number.
- * @param {?Array.<boolean>} value The array of ints to write.
+ * @param {?Array<boolean>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedBool = function(field, value) {
if (value == null || !value.length) return;
@@ -1548,7 +1548,7 @@ jspb.BinaryWriter.prototype.writePackedBool = function(field, value) {
/**
* Writes an array of enums to the buffer as a packed enum field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array<number>} value The array of ints to write.
*/
jspb.BinaryWriter.prototype.writePackedEnum = function(field, value) {
if (value == null || !value.length) return;
@@ -1564,7 +1564,7 @@ jspb.BinaryWriter.prototype.writePackedEnum = function(field, value) {
* Writes a 64-bit hash string field (8 characters @ 8 bits of data each) to
* the buffer.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of hashes to write.
+ * @param {?Array<string>} value The array of hashes to write.
*/
jspb.BinaryWriter.prototype.writePackedFixedHash64 = function(field, value) {
if (value == null || !value.length) return;
@@ -1580,7 +1580,7 @@ jspb.BinaryWriter.prototype.writePackedFixedHash64 = function(field, value) {
* Writes a 64-bit hash string field (8 characters @ 8 bits of data each) to
* the buffer.
* @param {number} field The field number.
- * @param {?Array.<string>} value The array of hashes to write.
+ * @param {?Array<string>} value The array of hashes to write.
*/
jspb.BinaryWriter.prototype.writePackedVarintHash64 = function(field, value) {
if (value == null || !value.length) return;
diff --git a/js/debug.js b/js/debug.js
index 46b24853..0b2c5f6a 100644
--- a/js/debug.js
+++ b/js/debug.js
@@ -74,15 +74,22 @@ jspb.debug.dump = function(message) {
*/
jspb.debug.dump_ = function(thing) {
var type = goog.typeOf(thing);
+ var message = thing; // Copy because we don't want type inference on thing.
if (type == 'number' || type == 'string' || type == 'boolean' ||
type == 'null' || type == 'undefined') {
return thing;
}
+ if (window.Uint8Array) {
+ // Will fail on IE9, where Uint8Array doesn't exist.
+ if (message instanceof Uint8Array) {
+ return thing;
+ }
+ }
+
if (type == 'array') {
goog.asserts.assertArray(thing);
return goog.array.map(thing, jspb.debug.dump_);
}
- var message = thing; // Copy because we don't want type inference on thing.
goog.asserts.assert(message instanceof jspb.Message,
'Only messages expected: ' + thing);
var ctor = message.constructor;
diff --git a/js/debug_test.js b/js/debug_test.js
index 702cc76e..73810871 100644
--- a/js/debug_test.js
+++ b/js/debug_test.js
@@ -41,6 +41,8 @@ goog.require('proto.jspb.test.IsExtension');
goog.require('proto.jspb.test.Simple1');
+// CommonJS-LoadFromFile: testbinary_pb
+goog.require('proto.jspb.test.TestAllTypes');
describe('debugTest', function() {
it('testSimple1', function() {
@@ -74,6 +76,15 @@ describe('debugTest', function() {
}, jspb.debug.dump(message));
});
+ it('testBytes', function() {
+ if (COMPILED || !window['Uint8Array']) {
+ return;
+ }
+ var message = new proto.jspb.test.TestAllTypes();
+ var bytes = new Uint8Array(4);
+ message.setOptionalBytes(bytes);
+ assertEquals(jspb.debug.dump(message)['optionalBytes'], bytes);
+ });
it('testExtensions', function() {
if (COMPILED) {
diff --git a/js/message.js b/js/message.js
index 1484229d..8f68cbb4 100644
--- a/js/message.js
+++ b/js/message.js
@@ -205,6 +205,16 @@ goog.define('jspb.Message.GENERATE_TO_STRING', true);
goog.define('jspb.Message.ASSUME_LOCAL_ARRAYS', false);
+// TODO(jakubvrana): Turn this off by default.
+/**
+ * @define {boolean} Disabling the serialization of empty trailing fields
+ * reduces the size of serialized protos. The price is an extra iteration of
+ * the proto before serialization. This is enabled by default to be
+ * backwards compatible. Projects are advised to turn this flag always off.
+ */
+goog.define('jspb.Message.SERIALIZE_EMPTY_TRAILING_FIELDS', true);
+
+
/**
* @define {boolean} Turning on this flag does NOT change the behavior of JSPB
* and only affects private internal state. It may, however, break some
@@ -212,8 +222,8 @@ goog.define('jspb.Message.ASSUME_LOCAL_ARRAYS', false);
* mutates its internal state.
* Projects are advised to turn this flag always on.
*/
-goog.define('jspb.Message.MINIMIZE_MEMORY_ALLOCATIONS', COMPILED);
-// TODO(b/19419436) Turn this on by default.
+goog.define('jspb.Message.MINIMIZE_MEMORY_ALLOCATIONS', true);
+// TODO(b/19419436): Delete this flag.
/**
@@ -278,6 +288,13 @@ jspb.Message.prototype.convertedFloatingPointFields_;
/**
+ * Repeated fields numbers.
+ * @protected {?Array<number>|undefined}
+ */
+jspb.Message.prototype.repeatedFields;
+
+
+/**
* The xid of this proto type (The same for all instances of a proto). Provides
* a way to identify a proto by stable obfuscated name.
* @see {xid}.
@@ -324,6 +341,18 @@ jspb.Message.getIndex_ = function(msg, fieldNumber) {
/**
+ * Returns the tag number based on the index in msg.array.
+ * @param {!jspb.Message} msg Message for which we're calculating an index.
+ * @param {number} index The tag number.
+ * @return {number} The field number.
+ * @private
+ */
+jspb.Message.getFieldNumber_ = function(msg, index) {
+ return index - msg.arrayIndexOffset_;
+};
+
+
+/**
* Initializes a JsPb Message.
* @param {!jspb.Message} msg The JsPb proto to modify.
* @param {Array|undefined} data An initial data array.
@@ -353,6 +382,13 @@ jspb.Message.initialize = function(
jspb.Message.initPivotAndExtensionObject_(msg, suggestedPivot);
msg.convertedFloatingPointFields_ = {};
+ if (!jspb.Message.SERIALIZE_EMPTY_TRAILING_FIELDS) {
+ // TODO(jakubvrana): This is same for all instances, move to prototype.
+ // TODO(jakubvrana): There are indexOf calls on this in serializtion,
+ // consider switching to a set.
+ msg.repeatedFields = repeatedFields;
+ }
+
if (repeatedFields) {
for (var i = 0; i < repeatedFields.length; i++) {
var fieldNumber = repeatedFields[i];
@@ -376,8 +412,9 @@ jspb.Message.initialize = function(
if (opt_oneofFields && opt_oneofFields.length) {
// Compute the oneof case for each union. This ensures only one value is
// set in the union.
- goog.array.forEach(
- opt_oneofFields, goog.partial(jspb.Message.computeOneofCase, msg));
+ for (var i = 0; i < opt_oneofFields.length; i++) {
+ jspb.Message.computeOneofCase(msg, opt_oneofFields[i]);
+ }
}
};
@@ -428,7 +465,7 @@ jspb.Message.initPivotAndExtensionObject_ = function(msg, suggestedPivot) {
// in Safari on iOS 8. See the description of CL/86511464 for details.
if (obj && typeof obj == 'object' && !jspb.Message.isArray_(obj) &&
!(jspb.Message.SUPPORTS_UINT8ARRAY_ && obj instanceof Uint8Array)) {
- msg.pivot_ = foundIndex - msg.arrayIndexOffset_;
+ msg.pivot_ = jspb.Message.getFieldNumber_(msg, foundIndex);
msg.extensionObject_ = obj;
return;
}
@@ -1043,14 +1080,15 @@ jspb.Message.computeOneofCase = function(msg, oneof) {
var oneofField;
var oneofValue;
- goog.array.forEach(oneof, function(fieldNumber) {
+ for (var i = 0; i < oneof.length; i++) {
+ var fieldNumber = oneof[i];
var value = jspb.Message.getField(msg, fieldNumber);
- if (goog.isDefAndNotNull(value)) {
+ if (value != null) {
oneofField = fieldNumber;
oneofValue = value;
jspb.Message.setField(msg, fieldNumber, undefined);
}
- });
+ }
if (oneofField) {
// NB: We know the value is unique, so we can call jspb.Message.setField
@@ -1241,7 +1279,7 @@ jspb.Message.addToRepeatedWrapperField = function(
* dead code removal.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
- * @return {!Object.<string, Object>} A map of proto or Soy objects.
+ * @return {!Object<string, Object>} A map of proto or Soy objects.
* @template T
*/
jspb.Message.toMap = function(
@@ -1318,7 +1356,7 @@ jspb.Message.prototype.toString = function() {
/**
* Gets the value of the extension field from the extended object.
- * @param {jspb.ExtensionFieldInfo.<T>} fieldInfo Specifies the field to get.
+ * @param {jspb.ExtensionFieldInfo<T>} fieldInfo Specifies the field to get.
* @return {T} The value of the field.
* @template T
*/
@@ -1705,7 +1743,11 @@ jspb.Message.registry_ = {};
* non-MessageSet. We special case MessageSet so that we do not need
* to goog.require MessageSet from classes that extends MessageSet.
*
- * @type {!Object.<number, jspb.ExtensionFieldInfo>}
+ * @type {!Object<number, jspb.ExtensionFieldInfo>}
*/
jspb.Message.messageSetExtensions = {};
+
+/**
+ * @type {!Object<number, jspb.ExtensionFieldBinaryInfo>}
+ */
jspb.Message.messageSetExtensionsBinary = {};
diff --git a/js/message_test.js b/js/message_test.js
index 7d61dacb..9944c741 100644
--- a/js/message_test.js
+++ b/js/message_test.js
@@ -34,6 +34,7 @@ goog.setTestOnly();
goog.require('goog.json');
goog.require('goog.string');
+goog.require('goog.testing.PropertyReplacer');
goog.require('goog.testing.asserts');
goog.require('goog.userAgent');
@@ -85,6 +86,16 @@ goog.require('proto.jspb.test.TestExtensionsMessage');
describe('Message test suite', function() {
+ var stubs = new goog.testing.PropertyReplacer();
+
+ beforeEach(function() {
+ stubs.set(jspb.Message, 'SERIALIZE_EMPTY_TRAILING_FIELDS', false);
+ });
+
+ afterEach(function() {
+ stubs.reset();
+ });
+
it('testEmptyProto', function() {
var empty1 = new proto.jspb.test.Empty([]);
var empty2 = new proto.jspb.test.Empty([]);
@@ -1041,4 +1052,13 @@ describe('Message test suite', function() {
assertNan(message.getDefaultDoubleField());
});
+ it('testSerializePreservesEmptyNestedField', function() {
+ var message = new proto.jspb.test.OptionalFields();
+ message.setANestedMessage(new proto.jspb.test.OptionalFields.Nested());
+ message.addARepeatedMessage(new proto.jspb.test.OptionalFields.Nested());
+ message = proto.jspb.test.OptionalFields.deserialize(message.serialize());
+ assertNotNullNorUndefined(message.getANestedMessage());
+ assertEquals(1, message.getARepeatedMessageList().length);
+ });
+
});
diff --git a/objectivec/google/protobuf/Any.pbobjc.h b/objectivec/google/protobuf/Any.pbobjc.h
index b17e76f0..89c99bdb 100644
--- a/objectivec/google/protobuf/Any.pbobjc.h
+++ b/objectivec/google/protobuf/Any.pbobjc.h
@@ -135,17 +135,18 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
@interface GPBAny : GPBMessage
/**
- * A URL/resource name whose content describes the type of the
- * serialized protocol buffer message.
+ * A URL/resource name that uniquely identifies the type of the serialized
+ * protocol buffer message. The last segment of the URL's path must represent
+ * the fully qualified name of the type (as in
+ * `path/google.protobuf.Duration`). The name should be in a canonical form
+ * (e.g., leading "." is not accepted).
*
- * For URLs which use the scheme `http`, `https`, or no scheme, the
- * following restrictions and interpretations apply:
+ * In practice, teams usually precompile into the binary all types that they
+ * expect it to use in the context of Any. However, for URLs which use the
+ * scheme `http`, `https`, or no scheme, one can optionally set up a type
+ * server that maps type URLs to message definitions as follows:
*
* * If no scheme is provided, `https` is assumed.
- * * The last segment of the URL's path must represent the fully
- * qualified name of the type (as in `path/google.protobuf.Duration`).
- * The name should be in a canonical form (e.g., leading "." is
- * not accepted).
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
* value in binary format, or produce an error.
* * Applications are allowed to cache lookup results based on the
@@ -154,6 +155,10 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
* on changes to types. (Use versioned type names to manage
* breaking changes.)
*
+ * Note: this functionality is not currently available in the official
+ * protobuf release, and it is not used for type URLs beginning with
+ * type.googleapis.com.
+ *
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
**/
diff --git a/objectivec/google/protobuf/Timestamp.pbobjc.h b/objectivec/google/protobuf/Timestamp.pbobjc.h
index 0b670c35..998bc15d 100644
--- a/objectivec/google/protobuf/Timestamp.pbobjc.h
+++ b/objectivec/google/protobuf/Timestamp.pbobjc.h
@@ -126,8 +126,8 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
* to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
* with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
* can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
- * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--)
- * to obtain a formatter capable of generating timestamps in this format.
+ * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--
+ * ) to obtain a formatter capable of generating timestamps in this format.
**/
@interface GPBTimestamp : GPBMessage
diff --git a/python/google/protobuf/descriptor.py b/python/google/protobuf/descriptor.py
index b1f3ca38..0d35425f 100755
--- a/python/google/protobuf/descriptor.py
+++ b/python/google/protobuf/descriptor.py
@@ -41,8 +41,8 @@ from google.protobuf.internal import api_implementation
_USE_C_DESCRIPTORS = False
if api_implementation.Type() == 'cpp':
# Used by MakeDescriptor in cpp mode
+ import binascii
import os
- import uuid
from google.protobuf.pyext import _message
_USE_C_DESCRIPTORS = getattr(_message, '_USE_C_DESCRIPTORS', False)
@@ -952,7 +952,7 @@ def MakeDescriptor(desc_proto, package='', build_file_if_cpp=True,
# imported ones. We need to specify a file name so the descriptor pool
# accepts our FileDescriptorProto, but it is not important what that file
# name is actually set to.
- proto_name = str(uuid.uuid4())
+ proto_name = binascii.hexlify(os.urandom(16)).decode('ascii')
if package:
file_descriptor_proto.name = os.path.join(package.replace('.', '/'),
diff --git a/python/google/protobuf/descriptor_database.py b/python/google/protobuf/descriptor_database.py
index b8f5140b..8b7715cd 100644
--- a/python/google/protobuf/descriptor_database.py
+++ b/python/google/protobuf/descriptor_database.py
@@ -32,6 +32,8 @@
__author__ = 'matthewtoia@google.com (Matt Toia)'
+import warnings
+
class Error(Exception):
pass
@@ -64,21 +66,20 @@ class DescriptorDatabase(object):
elif self._file_desc_protos_by_file[proto_name] != file_desc_proto:
raise DescriptorDatabaseConflictingDefinitionError(
'%s already added, but with different descriptor.' % proto_name)
+ else:
+ return
# Add all the top-level descriptors to the index.
package = file_desc_proto.package
for message in file_desc_proto.message_type:
- self._file_desc_protos_by_symbol.update(
- (name, file_desc_proto) for name in _ExtractSymbols(message, package))
+ for name in _ExtractSymbols(message, package):
+ self._AddSymbol(name, file_desc_proto)
for enum in file_desc_proto.enum_type:
- self._file_desc_protos_by_symbol[
- '.'.join((package, enum.name))] = file_desc_proto
+ self._AddSymbol(('.'.join((package, enum.name))), file_desc_proto)
for extension in file_desc_proto.extension:
- self._file_desc_protos_by_symbol[
- '.'.join((package, extension.name))] = file_desc_proto
+ self._AddSymbol(('.'.join((package, extension.name))), file_desc_proto)
for service in file_desc_proto.service:
- self._file_desc_protos_by_symbol[
- '.'.join((package, service.name))] = file_desc_proto
+ self._AddSymbol(('.'.join((package, service.name))), file_desc_proto)
def FindFileByName(self, name):
"""Finds the file descriptor proto by file name.
@@ -132,6 +133,15 @@ class DescriptorDatabase(object):
top_level, _, _ = symbol.rpartition('.')
return self._file_desc_protos_by_symbol[top_level]
+ def _AddSymbol(self, name, file_desc_proto):
+ if name in self._file_desc_protos_by_symbol:
+ warn_msg = ('Conflict register for file "' + file_desc_proto.name +
+ '": ' + name +
+ ' is already defined in file "' +
+ self._file_desc_protos_by_symbol[name].name + '"')
+ warnings.warn(warn_msg, RuntimeWarning)
+ self._file_desc_protos_by_symbol[name] = file_desc_proto
+
def _ExtractSymbols(desc_proto, package):
"""Pulls out all the symbols from a descriptor proto.
diff --git a/python/google/protobuf/descriptor_pool.py b/python/google/protobuf/descriptor_pool.py
index cb7146b6..8983f76f 100644
--- a/python/google/protobuf/descriptor_pool.py
+++ b/python/google/protobuf/descriptor_pool.py
@@ -58,6 +58,7 @@ directly instead of this class.
__author__ = 'matthewtoia@google.com (Matt Toia)'
import collections
+import warnings
from google.protobuf import descriptor
from google.protobuf import descriptor_database
@@ -127,12 +128,38 @@ class DescriptorPool(object):
self._service_descriptors = {}
self._file_descriptors = {}
self._toplevel_extensions = {}
+ # TODO(jieluo): Remove _file_desc_by_toplevel_extension after
+ # maybe year 2020 for compatibility issue (with 3.4.1 only).
+ self._file_desc_by_toplevel_extension = {}
# We store extensions in two two-level mappings: The first key is the
# descriptor of the message being extended, the second key is the extension
# full name or its tag number.
self._extensions_by_name = collections.defaultdict(dict)
self._extensions_by_number = collections.defaultdict(dict)
+ def _CheckConflictRegister(self, desc):
+ """Check if the descriptor name conflicts with another of the same name.
+
+ Args:
+ desc: Descriptor of a message, enum, service or extension.
+ """
+ desc_name = desc.full_name
+ for register, descriptor_type in [
+ (self._descriptors, descriptor.Descriptor),
+ (self._enum_descriptors, descriptor.EnumDescriptor),
+ (self._service_descriptors, descriptor.ServiceDescriptor),
+ (self._toplevel_extensions, descriptor.FieldDescriptor)]:
+ if desc_name in register:
+ file_name = register[desc_name].file.name
+ if not isinstance(desc, descriptor_type) or (
+ file_name != desc.file.name):
+ warn_msg = ('Conflict register for file "' + desc.file.name +
+ '": ' + desc_name +
+ ' is already defined in file "' +
+ file_name + '"')
+ warnings.warn(warn_msg, RuntimeWarning)
+ return
+
def Add(self, file_desc_proto):
"""Adds the FileDescriptorProto and its types to this pool.
@@ -169,6 +196,8 @@ class DescriptorPool(object):
if not isinstance(desc, descriptor.Descriptor):
raise TypeError('Expected instance of descriptor.Descriptor.')
+ self._CheckConflictRegister(desc)
+
self._descriptors[desc.full_name] = desc
self._AddFileDescriptor(desc.file)
@@ -184,6 +213,7 @@ class DescriptorPool(object):
if not isinstance(enum_desc, descriptor.EnumDescriptor):
raise TypeError('Expected instance of descriptor.EnumDescriptor.')
+ self._CheckConflictRegister(enum_desc)
self._enum_descriptors[enum_desc.full_name] = enum_desc
self._AddFileDescriptor(enum_desc.file)
@@ -197,6 +227,7 @@ class DescriptorPool(object):
if not isinstance(service_desc, descriptor.ServiceDescriptor):
raise TypeError('Expected instance of descriptor.ServiceDescriptor.')
+ self._CheckConflictRegister(service_desc)
self._service_descriptors[service_desc.full_name] = service_desc
def AddExtensionDescriptor(self, extension):
@@ -216,6 +247,7 @@ class DescriptorPool(object):
raise TypeError('Expected an extension descriptor.')
if extension.extension_scope is None:
+ self._CheckConflictRegister(extension)
self._toplevel_extensions[extension.full_name] = extension
try:
@@ -252,6 +284,12 @@ class DescriptorPool(object):
"""
self._AddFileDescriptor(file_desc)
+ # TODO(jieluo): This is a temporary solution for FieldDescriptor.file.
+ # FieldDescriptor.file is added in code gen. Remove this solution after
+ # maybe 2020 for compatibility reason (with 3.4.1 only).
+ for extension in file_desc.extensions_by_name.values():
+ self._file_desc_by_toplevel_extension[
+ extension.full_name] = file_desc
def _AddFileDescriptor(self, file_desc):
"""Adds a FileDescriptor to the pool, non-recursively.
@@ -331,7 +369,7 @@ class DescriptorPool(object):
pass
try:
- return self._toplevel_extensions[symbol].file
+ return self._file_desc_by_toplevel_extension[symbol]
except KeyError:
pass
@@ -680,6 +718,7 @@ class DescriptorPool(object):
fields[field_index].containing_oneof = oneofs[oneof_index]
scope[_PrefixWithDot(desc_name)] = desc
+ self._CheckConflictRegister(desc)
self._descriptors[desc_name] = desc
return desc
@@ -718,6 +757,7 @@ class DescriptorPool(object):
containing_type=containing_type,
options=_OptionsOrNone(enum_proto))
scope['.%s' % enum_name] = desc
+ self._CheckConflictRegister(desc)
self._enum_descriptors[enum_name] = desc
return desc
@@ -914,6 +954,7 @@ class DescriptorPool(object):
methods=methods,
options=_OptionsOrNone(service_proto),
file=file_desc)
+ self._CheckConflictRegister(desc)
self._service_descriptors[service_name] = desc
return desc
diff --git a/python/google/protobuf/internal/descriptor_database_test.py b/python/google/protobuf/internal/descriptor_database_test.py
index 1f1a3db9..f97477b3 100644
--- a/python/google/protobuf/internal/descriptor_database_test.py
+++ b/python/google/protobuf/internal/descriptor_database_test.py
@@ -38,6 +38,7 @@ try:
import unittest2 as unittest #PY26
except ImportError:
import unittest
+import warnings
from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2
@@ -98,6 +99,26 @@ class DescriptorDatabaseTest(unittest.TestCase):
db.FindFileContainingSymbol,
'protobuf_unittest.NoneMessage')
+ def testConflictRegister(self):
+ db = descriptor_database.DescriptorDatabase()
+ unittest_fd = descriptor_pb2.FileDescriptorProto.FromString(
+ unittest_pb2.DESCRIPTOR.serialized_pb)
+ db.Add(unittest_fd)
+ conflict_fd = descriptor_pb2.FileDescriptorProto.FromString(
+ unittest_pb2.DESCRIPTOR.serialized_pb)
+ conflict_fd.name = 'other_file'
+ with warnings.catch_warnings(record=True) as w:
+ # Cause all warnings to always be triggered.
+ warnings.simplefilter('always')
+ db.Add(conflict_fd)
+ self.assertTrue(len(w))
+ self.assertIs(w[0].category, RuntimeWarning)
+ self.assertIn('Conflict register for file "other_file": ',
+ str(w[0].message))
+ self.assertIn('already defined in file '
+ '"google/protobuf/unittest.proto"',
+ str(w[0].message))
+
if __name__ == '__main__':
unittest.main()
diff --git a/python/google/protobuf/internal/descriptor_pool_test.py b/python/google/protobuf/internal/descriptor_pool_test.py
index 15c857bb..2cbf7813 100644
--- a/python/google/protobuf/internal/descriptor_pool_test.py
+++ b/python/google/protobuf/internal/descriptor_pool_test.py
@@ -34,8 +34,10 @@
__author__ = 'matthewtoia@google.com (Matt Toia)'
+import copy
import os
import sys
+import warnings
try:
import unittest2 as unittest #PY26
@@ -119,6 +121,14 @@ class DescriptorPoolTestBase(object):
self.assertEqual('google/protobuf/unittest.proto',
file_desc5.name)
+ # Tests the generated pool.
+ assert descriptor_pool.Default().FindFileContainingSymbol(
+ 'google.protobuf.python.internal.Factory2Message.one_more_field')
+ assert descriptor_pool.Default().FindFileContainingSymbol(
+ 'google.protobuf.python.internal.another_field')
+ assert descriptor_pool.Default().FindFileContainingSymbol(
+ 'protobuf_unittest.TestService')
+
def testFindFileContainingSymbolFailure(self):
with self.assertRaises(KeyError):
self.pool.FindFileContainingSymbol('Does not exist')
@@ -492,6 +502,52 @@ class DescriptorPoolTestBase(object):
TEST1_FILE.CheckFile(self, self.pool)
TEST2_FILE.CheckFile(self, self.pool)
+ def testConflictRegister(self):
+ if isinstance(self, SecondaryDescriptorFromDescriptorDB):
+ if api_implementation.Type() == 'cpp':
+ # Cpp extension cannot call Add on a DescriptorPool
+ # that uses a DescriptorDatabase.
+ # TODO(jieluo): Fix python and cpp extension diff.
+ return
+ unittest_fd = descriptor_pb2.FileDescriptorProto.FromString(
+ unittest_pb2.DESCRIPTOR.serialized_pb)
+ conflict_fd = copy.deepcopy(unittest_fd)
+ conflict_fd.name = 'other_file'
+ if api_implementation.Type() == 'cpp':
+ try:
+ self.pool.Add(unittest_fd)
+ self.pool.Add(conflict_fd)
+ except TypeError:
+ pass
+ else:
+ with warnings.catch_warnings(record=True) as w:
+ # Cause all warnings to always be triggered.
+ warnings.simplefilter('always')
+ pool = copy.deepcopy(self.pool)
+ # No warnings to add the same descriptors.
+ file_descriptor = unittest_pb2.DESCRIPTOR
+ pool.AddDescriptor(
+ file_descriptor.message_types_by_name['TestAllTypes'])
+ pool.AddEnumDescriptor(
+ file_descriptor.enum_types_by_name['ForeignEnum'])
+ pool.AddServiceDescriptor(
+ file_descriptor.services_by_name['TestService'])
+ pool.AddExtensionDescriptor(
+ file_descriptor.extensions_by_name['optional_int32_extension'])
+ self.assertEqual(len(w), 0)
+ # Check warnings for conflict descriptors with the same name.
+ pool.Add(unittest_fd)
+ pool.Add(conflict_fd)
+ pool.FindFileByName(unittest_fd.name)
+ pool.FindFileByName(conflict_fd.name)
+ self.assertTrue(len(w))
+ self.assertIs(w[0].category, RuntimeWarning)
+ self.assertIn('Conflict register for file "other_file": ',
+ str(w[0].message))
+ self.assertIn('already defined in file '
+ '"google/protobuf/unittest.proto"',
+ str(w[0].message))
+
class DefaultDescriptorPoolTest(DescriptorPoolTestBase, unittest.TestCase):
diff --git a/python/google/protobuf/internal/encoder.py b/python/google/protobuf/internal/encoder.py
index 40c62d67..dc7a8ce8 100755
--- a/python/google/protobuf/internal/encoder.py
+++ b/python/google/protobuf/internal/encoder.py
@@ -418,7 +418,8 @@ def _VarintBytes(value):
def TagBytes(field_number, wire_type):
"""Encode the given tag and return the bytes. Only called at startup."""
- return six.binary_type( _VarintBytes(wire_format.PackTag(field_number, wire_type)) )
+ return six.binary_type(
+ _VarintBytes(wire_format.PackTag(field_number, wire_type)))
# --------------------------------------------------------------------
# As with sizers (see above), we have a number of common encoder
diff --git a/python/google/protobuf/internal/text_format_test.py b/python/google/protobuf/internal/text_format_test.py
index a52f133f..ed3445f2 100755
--- a/python/google/protobuf/internal/text_format_test.py
+++ b/python/google/protobuf/internal/text_format_test.py
@@ -828,6 +828,10 @@ class Proto2Tests(TextFormatBase):
' }\n'
' }\n'
' [unknown_extension]: 5\n'
+ ' [unknown_extension_with_number_field] {\n'
+ ' 1: "some_field"\n'
+ ' 2: -0.451\n'
+ ' }\n'
'}\n')
text_format.Parse(text, message, allow_unknown_extension=True)
golden = 'message_set {\n}\n'
@@ -894,7 +898,6 @@ class Proto2Tests(TextFormatBase):
message = unittest_mset_pb2.TestMessageSetContainer()
malformed = ('message_set {\n'
' unknown_field: true\n'
- ' \n' # Missing '>' here.
'}\n')
six.assertRaisesRegex(self,
text_format.ParseError,
@@ -906,7 +909,7 @@ class Proto2Tests(TextFormatBase):
message,
allow_unknown_extension=True)
- # Parse known extension correcty.
+ # Parse known extension correctly.
message = unittest_mset_pb2.TestMessageSetContainer()
text = ('message_set {\n'
' [protobuf_unittest.TestMessageSetExtension1] {\n'
diff --git a/python/google/protobuf/pyext/descriptor_containers.cc b/python/google/protobuf/pyext/descriptor_containers.cc
index d0aae9c9..bc007f7e 100644
--- a/python/google/protobuf/pyext/descriptor_containers.cc
+++ b/python/google/protobuf/pyext/descriptor_containers.cc
@@ -957,55 +957,55 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->field_count();
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindFieldByName(name);
}
-static ItemDescriptor GetByCamelcaseName(PyContainer* self,
+static const void* GetByCamelcaseName(PyContainer* self,
const string& name) {
return GetDescriptor(self)->FindFieldByCamelcaseName(name);
}
-static ItemDescriptor GetByNumber(PyContainer* self, int number) {
+static const void* GetByNumber(PyContainer* self, int number) {
return GetDescriptor(self)->FindFieldByNumber(number);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->field(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyFieldDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyFieldDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static const string& GetItemCamelcaseName(ItemDescriptor item) {
- return item->camelcase_name();
+static const string& GetItemCamelcaseName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->camelcase_name();
}
-static int GetItemNumber(ItemDescriptor item) {
- return item->number();
+static int GetItemNumber(const void* item) {
+ return static_cast<ItemDescriptor>(item)->number();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"MessageFields",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)GetByCamelcaseName,
- (GetByNumberMethod)GetByNumber,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)GetItemCamelcaseName,
- (GetItemNumberMethod)GetItemNumber,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ GetByCamelcaseName,
+ GetByNumber,
+ NewObjectFromItem,
+ GetItemName,
+ GetItemCamelcaseName,
+ GetItemNumber,
+ GetItemIndex,
};
} // namespace fields
@@ -1035,38 +1035,38 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->nested_type_count();
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindNestedTypeByName(name);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->nested_type(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyMessageDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyMessageDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"MessageNestedTypes",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ NULL,
+ GetItemIndex,
};
} // namespace nested_types
@@ -1087,38 +1087,38 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->enum_type_count();
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindEnumTypeByName(name);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->enum_type(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyEnumDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyEnumDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"MessageNestedEnums",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ NULL,
+ GetItemIndex,
};
} // namespace enums
@@ -1150,11 +1150,11 @@ static int Count(PyContainer* self) {
return count;
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindEnumValueByName(name);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
// This is not optimal, but the number of enums *types* in a given message
// is small. This function is only used when iterating over the mapping.
const EnumDescriptor* enum_type = NULL;
@@ -1173,26 +1173,27 @@ static ItemDescriptor GetByIndex(PyContainer* self, int index) {
return enum_type->value(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyEnumValueDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyEnumValueDescriptor_FromDescriptor(
+ static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
static DescriptorContainerDef ContainerDef = {
"MessageEnumValues",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)NULL,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ NULL,
+ NULL,
};
} // namespace enumvalues
@@ -1209,38 +1210,38 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->extension_count();
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindExtensionByName(name);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->extension(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyFieldDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyFieldDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"MessageExtensions",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ NULL,
+ GetItemIndex,
};
} // namespace extensions
@@ -1261,38 +1262,38 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->oneof_decl_count();
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindOneofByName(name);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->oneof_decl(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyOneofDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyOneofDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"MessageOneofs",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ NULL,
+ GetItemIndex,
};
} // namespace oneofs
@@ -1323,46 +1324,47 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->value_count();
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->value(index);
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindValueByName(name);
}
-static ItemDescriptor GetByNumber(PyContainer* self, int number) {
+static const void* GetByNumber(PyContainer* self, int number) {
return GetDescriptor(self)->FindValueByNumber(number);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyEnumValueDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyEnumValueDescriptor_FromDescriptor(
+ static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static int GetItemNumber(ItemDescriptor item) {
- return item->number();
+static int GetItemNumber(const void* item) {
+ return static_cast<ItemDescriptor>(item)->number();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"EnumValues",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)GetByNumber,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)GetItemNumber,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ GetByNumber,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ GetItemNumber,
+ GetItemIndex,
};
} // namespace enumvalues
@@ -1397,30 +1399,30 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->field_count();
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->field(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyFieldDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyFieldDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index_in_oneof();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index_in_oneof();
}
static DescriptorContainerDef ContainerDef = {
"OneofFields",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)NULL,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)NULL,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ NULL,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ NULL,
+ NULL,
+ NULL,
+ GetItemIndex,
};
} // namespace fields
@@ -1447,38 +1449,38 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->method_count();
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindMethodByName(name);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->method(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyMethodDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyMethodDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"ServiceMethods",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ NULL,
+ GetItemIndex,
};
} // namespace methods
@@ -1509,38 +1511,38 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->message_type_count();
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindMessageTypeByName(name);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->message_type(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyMessageDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyMessageDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"FileMessages",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ NULL,
+ GetItemIndex,
};
} // namespace messages
@@ -1557,38 +1559,38 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->enum_type_count();
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindEnumTypeByName(name);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->enum_type(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyEnumDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyEnumDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"FileEnums",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ NULL,
+ GetItemIndex,
};
} // namespace enums
@@ -1605,38 +1607,38 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->extension_count();
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindExtensionByName(name);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->extension(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyFieldDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyFieldDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"FileExtensions",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ NULL,
+ GetItemIndex,
};
} // namespace extensions
@@ -1653,38 +1655,38 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->service_count();
}
-static ItemDescriptor GetByName(PyContainer* self, const string& name) {
+static const void* GetByName(PyContainer* self, const string& name) {
return GetDescriptor(self)->FindServiceByName(name);
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->service(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyServiceDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyServiceDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
-static const string& GetItemName(ItemDescriptor item) {
- return item->name();
+static const string& GetItemName(const void* item) {
+ return static_cast<ItemDescriptor>(item)->name();
}
-static int GetItemIndex(ItemDescriptor item) {
- return item->index();
+static int GetItemIndex(const void* item) {
+ return static_cast<ItemDescriptor>(item)->index();
}
static DescriptorContainerDef ContainerDef = {
"FileServices",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)GetByName,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)GetItemName,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)GetItemIndex,
+ Count,
+ GetByIndex,
+ GetByName,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ GetItemName,
+ NULL,
+ NULL,
+ GetItemIndex,
};
} // namespace services
@@ -1701,26 +1703,26 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->dependency_count();
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->dependency(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyFileDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyFileDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
static DescriptorContainerDef ContainerDef = {
"FileDependencies",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)NULL,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)NULL,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)NULL,
+ Count,
+ GetByIndex,
+ NULL,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
};
} // namespace dependencies
@@ -1737,26 +1739,26 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->public_dependency_count();
}
-static ItemDescriptor GetByIndex(PyContainer* self, int index) {
+static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->public_dependency(index);
}
-static PyObject* NewObjectFromItem(ItemDescriptor item) {
- return PyFileDescriptor_FromDescriptor(item);
+static PyObject* NewObjectFromItem(const void* item) {
+ return PyFileDescriptor_FromDescriptor(static_cast<ItemDescriptor>(item));
}
static DescriptorContainerDef ContainerDef = {
"FilePublicDependencies",
- (CountMethod)Count,
- (GetByIndexMethod)GetByIndex,
- (GetByNameMethod)NULL,
- (GetByCamelcaseNameMethod)NULL,
- (GetByNumberMethod)NULL,
- (NewObjectFromItemMethod)NewObjectFromItem,
- (GetItemNameMethod)NULL,
- (GetItemCamelcaseNameMethod)NULL,
- (GetItemNumberMethod)NULL,
- (GetItemIndexMethod)NULL,
+ Count,
+ GetByIndex,
+ NULL,
+ NULL,
+ NULL,
+ NewObjectFromItem,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
};
} // namespace public_dependencies
diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc
index ef75acab..f515b560 100644
--- a/python/google/protobuf/pyext/message.cc
+++ b/python/google/protobuf/pyext/message.cc
@@ -605,18 +605,16 @@ void OutOfRangeError(PyObject* arg) {
template<class RangeType, class ValueType>
bool VerifyIntegerCastAndRange(PyObject* arg, ValueType value) {
- if
- GOOGLE_PREDICT_FALSE(value == -1 && PyErr_Occurred()) {
- if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
- // Replace it with the same ValueError as pure python protos instead of
- // the default one.
- PyErr_Clear();
- OutOfRangeError(arg);
- } // Otherwise propagate existing error.
- return false;
+ if (GOOGLE_PREDICT_FALSE(value == -1 && PyErr_Occurred())) {
+ if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
+ // Replace it with the same ValueError as pure python protos instead of
+ // the default one.
+ PyErr_Clear();
+ OutOfRangeError(arg);
+ } // Otherwise propagate existing error.
+ return false;
}
- if
- GOOGLE_PREDICT_FALSE(!IsValidNumericCast<RangeType>(value)) {
+ if (GOOGLE_PREDICT_FALSE(!IsValidNumericCast<RangeType>(value))) {
OutOfRangeError(arg);
return false;
}
@@ -628,26 +626,22 @@ bool CheckAndGetInteger(PyObject* arg, T* value) {
// The fast path.
#if PY_MAJOR_VERSION < 3
// For the typical case, offer a fast path.
- if
- GOOGLE_PREDICT_TRUE(PyInt_Check(arg)) {
- long int_result = PyInt_AsLong(arg);
- if
- GOOGLE_PREDICT_TRUE(IsValidNumericCast<T>(int_result)) {
- *value = static_cast<T>(int_result);
- return true;
- }
- else {
- OutOfRangeError(arg);
- return false;
- }
+ if (GOOGLE_PREDICT_TRUE(PyInt_Check(arg))) {
+ long int_result = PyInt_AsLong(arg);
+ if (GOOGLE_PREDICT_TRUE(IsValidNumericCast<T>(int_result))) {
+ *value = static_cast<T>(int_result);
+ return true;
+ } else {
+ OutOfRangeError(arg);
+ return false;
+ }
}
#endif
// This effectively defines an integer as "an object that can be cast as
// an integer and can be used as an ordinal number".
// This definition includes everything that implements numbers.Integral
// and shouldn't cast the net too wide.
- if
- GOOGLE_PREDICT_FALSE(!PyIndex_Check(arg)) {
+ if (GOOGLE_PREDICT_FALSE(!PyIndex_Check(arg))) {
FormatTypeError(arg, "int, long");
return false;
}
@@ -664,10 +658,9 @@ bool CheckAndGetInteger(PyObject* arg, T* value) {
// Unlike PyLong_AsLongLong, PyLong_AsUnsignedLongLong is very
// picky about the exact type.
PyObject* casted = PyNumber_Long(arg);
- if
- GOOGLE_PREDICT_FALSE(casted == NULL) {
- // Propagate existing error.
- return false;
+ if (GOOGLE_PREDICT_FALSE(casted == NULL)) {
+ // Propagate existing error.
+ return false;
}
ulong_result = PyLong_AsUnsignedLongLong(casted);
Py_DECREF(casted);
@@ -690,10 +683,9 @@ bool CheckAndGetInteger(PyObject* arg, T* value) {
// Valid subclasses of numbers.Integral should have a __long__() method
// so fall back to that.
PyObject* casted = PyNumber_Long(arg);
- if
- GOOGLE_PREDICT_FALSE(casted == NULL) {
- // Propagate existing error.
- return false;
+ if (GOOGLE_PREDICT_FALSE(casted == NULL)) {
+ // Propagate existing error.
+ return false;
}
long_result = PyLong_AsLongLong(casted);
Py_DECREF(casted);
@@ -717,10 +709,9 @@ template bool CheckAndGetInteger<uint64>(PyObject*, uint64*);
bool CheckAndGetDouble(PyObject* arg, double* value) {
*value = PyFloat_AsDouble(arg);
- if
- GOOGLE_PREDICT_FALSE(*value == -1 && PyErr_Occurred()) {
- FormatTypeError(arg, "int, long, float");
- return false;
+ if (GOOGLE_PREDICT_FALSE(*value == -1 && PyErr_Occurred())) {
+ FormatTypeError(arg, "int, long, float");
+ return false;
}
return true;
}
@@ -1187,7 +1178,7 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
continue;
}
if (descriptor->is_map()) {
- ScopedPyObjectPtr map(GetAttr(self, name));
+ ScopedPyObjectPtr map(GetAttr(reinterpret_cast<PyObject*>(self), name));
const FieldDescriptor* value_descriptor =
descriptor->message_type()->FindFieldByName("value");
if (value_descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
@@ -1215,7 +1206,8 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
}
}
} else if (descriptor->label() == FieldDescriptor::LABEL_REPEATED) {
- ScopedPyObjectPtr container(GetAttr(self, name));
+ ScopedPyObjectPtr container(
+ GetAttr(reinterpret_cast<PyObject*>(self), name));
if (container == NULL) {
return -1;
}
@@ -1282,7 +1274,8 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
}
}
} else if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- ScopedPyObjectPtr message(GetAttr(self, name));
+ ScopedPyObjectPtr message(
+ GetAttr(reinterpret_cast<PyObject*>(self), name));
if (message == NULL) {
return -1;
}
@@ -1307,8 +1300,8 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
return -1;
}
}
- if (SetAttr(self, name, (new_val.get() == NULL) ? value : new_val.get()) <
- 0) {
+ if (SetAttr(reinterpret_cast<PyObject*>(self), name,
+ (new_val.get() == NULL) ? value : new_val.get()) < 0) {
return -1;
}
}
@@ -2211,7 +2204,8 @@ static PyObject* ListFields(CMessage* self) {
return NULL;
}
- PyObject* field_value = GetAttr(self, py_field_name.get());
+ PyObject* field_value =
+ GetAttr(reinterpret_cast<PyObject*>(self), py_field_name.get());
if (field_value == NULL) {
PyErr_SetObject(PyExc_ValueError, py_field_name.get());
return NULL;
@@ -2707,7 +2701,8 @@ static bool SetCompositeField(
return PyDict_SetItem(self->composite_fields, name, value) == 0;
}
-PyObject* GetAttr(CMessage* self, PyObject* name) {
+PyObject* GetAttr(PyObject* pself, PyObject* name) {
+ CMessage* self = reinterpret_cast<CMessage*>(pself);
PyObject* value = self->composite_fields ?
PyDict_GetItem(self->composite_fields, name) : NULL;
if (value != NULL) {
@@ -2785,7 +2780,8 @@ PyObject* GetAttr(CMessage* self, PyObject* name) {
return InternalGetScalar(self->message, field_descriptor);
}
-int SetAttr(CMessage* self, PyObject* name, PyObject* value) {
+int SetAttr(PyObject* pself, PyObject* name, PyObject* value) {
+ CMessage* self = reinterpret_cast<CMessage*>(pself);
if (self->composite_fields && PyDict_Contains(self->composite_fields, name)) {
PyErr_SetString(PyExc_TypeError, "Can't set composite field");
return -1;
@@ -2837,8 +2833,8 @@ PyTypeObject CMessage_Type = {
PyObject_HashNotImplemented, // tp_hash
0, // tp_call
(reprfunc)cmessage::ToStr, // tp_str
- (getattrofunc)cmessage::GetAttr, // tp_getattro
- (setattrofunc)cmessage::SetAttr, // tp_setattro
+ cmessage::GetAttr, // tp_getattro
+ cmessage::SetAttr, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags
"A ProtocolMessage", // tp_doc
diff --git a/python/google/protobuf/pyext/message.h b/python/google/protobuf/pyext/message.h
index ce80497e..576d098c 100644
--- a/python/google/protobuf/pyext/message.h
+++ b/python/google/protobuf/pyext/message.h
@@ -240,15 +240,15 @@ PyObject* MergeFrom(CMessage* self, PyObject* arg);
// has been registered with the same field number on this class.
PyObject* RegisterExtension(PyObject* cls, PyObject* extension_handle);
-// Retrieves an attribute named 'name' from CMessage 'self'. Returns
-// the attribute value on success, or NULL on failure.
+// Retrieves an attribute named 'name' from 'self', which is interpreted as a
+// CMessage. Returns the attribute value on success, or null on failure.
//
// Returns a new reference.
-PyObject* GetAttr(CMessage* self, PyObject* name);
+PyObject* GetAttr(PyObject* self, PyObject* name);
-// Set the value of the attribute named 'name', for CMessage 'self',
-// to the value 'value'. Returns -1 on failure.
-int SetAttr(CMessage* self, PyObject* name, PyObject* value);
+// Set the value of the attribute named 'name', for 'self', which is interpreted
+// as a CMessage, to the value 'value'. Returns -1 on failure.
+int SetAttr(PyObject* self, PyObject* name, PyObject* value);
PyObject* FindInitializationErrors(CMessage* self);
diff --git a/python/google/protobuf/text_format.py b/python/google/protobuf/text_format.py
index 6b12632e..36ddd1b7 100755
--- a/python/google/protobuf/text_format.py
+++ b/python/google/protobuf/text_format.py
@@ -938,7 +938,7 @@ def _SkipField(tokenizer):
tokenizer.ConsumeIdentifier()
tokenizer.Consume(']')
else:
- tokenizer.ConsumeIdentifier()
+ tokenizer.ConsumeIdentifierOrNumber()
_SkipFieldContents(tokenizer)
diff --git a/src/Makefile.am b/src/Makefile.am
index 73abb7f2..6fc4356f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -119,6 +119,7 @@ nobase_include_HEADERS = \
google/protobuf/generated_message_table_driven.h \
google/protobuf/generated_message_util.h \
google/protobuf/has_bits.h \
+ google/protobuf/implicit_weak_message.h \
google/protobuf/map_entry.h \
google/protobuf/map_entry_lite.h \
google/protobuf/map_field.h \
@@ -223,6 +224,7 @@ libprotobuf_lite_la_SOURCES = \
google/protobuf/generated_message_util.cc \
google/protobuf/generated_message_table_driven_lite.h \
google/protobuf/generated_message_table_driven_lite.cc \
+ google/protobuf/implicit_weak_message.cc \
google/protobuf/message_lite.cc \
google/protobuf/repeated_field.cc \
google/protobuf/wire_format_lite.cc \
diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc
index 29687477..4335e467 100644
--- a/src/google/protobuf/any.pb.cc
+++ b/src/google/protobuf/any.pb.cc
@@ -196,13 +196,6 @@ const Any& Any::default_instance() {
return *internal_default_instance();
}
-Any* Any::New(::google::protobuf::Arena* arena) const {
- Any* n = new Any;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
void Any::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Any)
@@ -436,5 +429,12 @@ void Any::InternalSwap(Any* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Any* Arena::Create< ::google::protobuf::Any >(Arena* arena) {
+ return Arena::CreateInternal< ::google::protobuf::Any >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h
index 20a1cbed..14134370 100644
--- a/src/google/protobuf/any.pb.h
+++ b/src/google/protobuf/any.pb.h
@@ -58,6 +58,11 @@ LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Any* Arena::Create< ::google::protobuf::Any>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
// ===================================================================
@@ -115,9 +120,13 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
// implements Message ----------------------------------------------
- inline Any* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Any* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<Any>(NULL);
+ }
- Any* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Any* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<Any>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Any& from);
diff --git a/src/google/protobuf/any.proto b/src/google/protobuf/any.proto
index c7486676..49329425 100644
--- a/src/google/protobuf/any.proto
+++ b/src/google/protobuf/any.proto
@@ -120,17 +120,18 @@ option objc_class_prefix = "GPB";
// }
//
message Any {
- // A URL/resource name whose content describes the type of the
- // serialized protocol buffer message.
+ // A URL/resource name that uniquely identifies the type of the serialized
+ // protocol buffer message. The last segment of the URL's path must represent
+ // the fully qualified name of the type (as in
+ // `path/google.protobuf.Duration`). The name should be in a canonical form
+ // (e.g., leading "." is not accepted).
//
- // For URLs which use the scheme `http`, `https`, or no scheme, the
- // following restrictions and interpretations apply:
+ // In practice, teams usually precompile into the binary all types that they
+ // expect it to use in the context of Any. However, for URLs which use the
+ // scheme `http`, `https`, or no scheme, one can optionally set up a type
+ // server that maps type URLs to message definitions as follows:
//
// * If no scheme is provided, `https` is assumed.
- // * The last segment of the URL's path must represent the fully
- // qualified name of the type (as in `path/google.protobuf.Duration`).
- // The name should be in a canonical form (e.g., leading "." is
- // not accepted).
// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
// value in binary format, or produce an error.
// * Applications are allowed to cache lookup results based on the
@@ -139,6 +140,10 @@ message Any {
// on changes to types. (Use versioned type names to manage
// breaking changes.)
//
+ // Note: this functionality is not currently available in the official
+ // protobuf release, and it is not used for type URLs beginning with
+ // type.googleapis.com.
+ //
// Schemes other than `http`, `https` (or the empty scheme) might be
// used with implementation specific semantics.
//
diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc
index 439a47c6..b0354551 100644
--- a/src/google/protobuf/api.pb.cc
+++ b/src/google/protobuf/api.pb.cc
@@ -311,13 +311,6 @@ const Api& Api::default_instance() {
return *internal_default_instance();
}
-Api* Api::New(::google::protobuf::Arena* arena) const {
- Api* n = new Api;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
void Api::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Api)
@@ -368,7 +361,8 @@ bool Api::MergePartialFromCodedStream(
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_methods()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_methods()));
} else {
goto handle_unusual;
}
@@ -379,7 +373,8 @@ bool Api::MergePartialFromCodedStream(
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_options()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_options()));
} else {
goto handle_unusual;
}
@@ -418,7 +413,8 @@ bool Api::MergePartialFromCodedStream(
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_mixins()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_mixins()));
} else {
goto handle_unusual;
}
@@ -480,14 +476,18 @@ void Api::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->methods_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, this->methods(static_cast<int>(i)), output);
+ 2,
+ this->methods(static_cast<int>(i)),
+ output);
}
// repeated .google.protobuf.Option options = 3;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->options_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, this->options(static_cast<int>(i)), output);
+ 3,
+ this->options(static_cast<int>(i)),
+ output);
}
// string version = 4;
@@ -503,14 +503,16 @@ void Api::SerializeWithCachedSizes(
// .google.protobuf.SourceContext source_context = 5;
if (this->has_source_context()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 5, *this->source_context_, output);
+ 5, *source_context_, output);
}
// repeated .google.protobuf.Mixin mixins = 6;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->mixins_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 6, this->mixins(static_cast<int>(i)), output);
+ 6,
+ this->mixins(static_cast<int>(i)),
+ output);
}
// .google.protobuf.Syntax syntax = 7;
@@ -575,7 +577,7 @@ void Api::SerializeWithCachedSizes(
if (this->has_source_context()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 5, *this->source_context_, deterministic, target);
+ 5, *source_context_, deterministic, target);
}
// repeated .google.protobuf.Mixin mixins = 6;
@@ -660,7 +662,7 @@ size_t Api::ByteSizeLong() const {
if (this->has_source_context()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->source_context_);
+ *source_context_);
}
// .google.protobuf.Syntax syntax = 7;
@@ -741,9 +743,9 @@ void Api::Swap(Api* other) {
}
void Api::InternalSwap(Api* other) {
using std::swap;
- methods_.InternalSwap(&other->methods_);
- options_.InternalSwap(&other->options_);
- mixins_.InternalSwap(&other->mixins_);
+ CastToBase(&methods_)->InternalSwap(CastToBase(&other->methods_));
+ CastToBase(&options_)->InternalSwap(CastToBase(&other->options_));
+ CastToBase(&mixins_)->InternalSwap(CastToBase(&other->mixins_));
name_.Swap(&other->name_);
version_.Swap(&other->version_);
swap(source_context_, other->source_context_);
@@ -843,13 +845,6 @@ const Method& Method::default_instance() {
return *internal_default_instance();
}
-Method* Method::New(::google::protobuf::Arena* arena) const {
- Method* n = new Method;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
void Method::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Method)
@@ -957,7 +952,8 @@ bool Method::MergePartialFromCodedStream(
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_options()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_options()));
} else {
goto handle_unusual;
}
@@ -1049,7 +1045,9 @@ void Method::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->options_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 6, this->options(static_cast<int>(i)), output);
+ 6,
+ this->options(static_cast<int>(i)),
+ output);
}
// .google.protobuf.Syntax syntax = 7;
@@ -1271,7 +1269,7 @@ void Method::Swap(Method* other) {
}
void Method::InternalSwap(Method* other) {
using std::swap;
- options_.InternalSwap(&other->options_);
+ CastToBase(&options_)->InternalSwap(CastToBase(&other->options_));
name_.Swap(&other->name_);
request_type_url_.Swap(&other->request_type_url_);
response_type_url_.Swap(&other->response_type_url_);
@@ -1352,13 +1350,6 @@ const Mixin& Mixin::default_instance() {
return *internal_default_instance();
}
-Mixin* Mixin::New(::google::protobuf::Arena* arena) const {
- Mixin* n = new Mixin;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
void Mixin::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Mixin)
@@ -1604,5 +1595,18 @@ void Mixin::InternalSwap(Mixin* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Api* Arena::Create< ::google::protobuf::Api >(Arena* arena) {
+ return Arena::CreateInternal< ::google::protobuf::Api >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Method* Arena::Create< ::google::protobuf::Method >(Arena* arena) {
+ return Arena::CreateInternal< ::google::protobuf::Method >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Mixin* Arena::Create< ::google::protobuf::Mixin >(Arena* arena) {
+ return Arena::CreateInternal< ::google::protobuf::Mixin >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h
index e74528e1..9e175e3e 100644
--- a/src/google/protobuf/api.pb.h
+++ b/src/google/protobuf/api.pb.h
@@ -71,6 +71,13 @@ LIBPROTOBUF_EXPORT extern MixinDefaultTypeInternal _Mixin_default_instance_;
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Api* Arena::Create< ::google::protobuf::Api>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Method* Arena::Create< ::google::protobuf::Method>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Mixin* Arena::Create< ::google::protobuf::Mixin>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
// ===================================================================
@@ -118,9 +125,13 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
// implements Message ----------------------------------------------
- inline Api* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Api* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<Api>(NULL);
+ }
- Api* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Api* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<Api>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Api& from);
@@ -160,11 +171,11 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
int methods_size() const;
void clear_methods();
static const int kMethodsFieldNumber = 2;
- const ::google::protobuf::Method& methods(int index) const;
::google::protobuf::Method* mutable_methods(int index);
- ::google::protobuf::Method* add_methods();
::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >*
mutable_methods();
+ const ::google::protobuf::Method& methods(int index) const;
+ ::google::protobuf::Method* add_methods();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >&
methods() const;
@@ -172,11 +183,11 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
int options_size() const;
void clear_options();
static const int kOptionsFieldNumber = 3;
- const ::google::protobuf::Option& options(int index) const;
::google::protobuf::Option* mutable_options(int index);
- ::google::protobuf::Option* add_options();
::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
mutable_options();
+ const ::google::protobuf::Option& options(int index) const;
+ ::google::protobuf::Option* add_options();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
options() const;
@@ -184,11 +195,11 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
int mixins_size() const;
void clear_mixins();
static const int kMixinsFieldNumber = 6;
- const ::google::protobuf::Mixin& mixins(int index) const;
::google::protobuf::Mixin* mutable_mixins(int index);
- ::google::protobuf::Mixin* add_mixins();
::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*
mutable_mixins();
+ const ::google::protobuf::Mixin& mixins(int index) const;
+ ::google::protobuf::Mixin* add_mixins();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&
mixins() const;
@@ -296,9 +307,13 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
// implements Message ----------------------------------------------
- inline Method* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Method* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<Method>(NULL);
+ }
- Method* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Method* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<Method>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Method& from);
@@ -338,11 +353,11 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
int options_size() const;
void clear_options();
static const int kOptionsFieldNumber = 6;
- const ::google::protobuf::Option& options(int index) const;
::google::protobuf::Option* mutable_options(int index);
- ::google::protobuf::Option* add_options();
::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
mutable_options();
+ const ::google::protobuf::Option& options(int index) const;
+ ::google::protobuf::Option* add_options();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
options() const;
@@ -467,9 +482,13 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
// implements Message ----------------------------------------------
- inline Mixin* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Mixin* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<Mixin>(NULL);
+ }
- Mixin* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Mixin* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<Mixin>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Mixin& from);
@@ -614,23 +633,23 @@ inline int Api::methods_size() const {
inline void Api::clear_methods() {
methods_.Clear();
}
-inline const ::google::protobuf::Method& Api::methods(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.Api.methods)
- return methods_.Get(index);
-}
inline ::google::protobuf::Method* Api::mutable_methods(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.Api.methods)
return methods_.Mutable(index);
}
-inline ::google::protobuf::Method* Api::add_methods() {
- // @@protoc_insertion_point(field_add:google.protobuf.Api.methods)
- return methods_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >*
Api::mutable_methods() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.methods)
return &methods_;
}
+inline const ::google::protobuf::Method& Api::methods(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Api.methods)
+ return methods_.Get(index);
+}
+inline ::google::protobuf::Method* Api::add_methods() {
+ // @@protoc_insertion_point(field_add:google.protobuf.Api.methods)
+ return methods_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >&
Api::methods() const {
// @@protoc_insertion_point(field_list:google.protobuf.Api.methods)
@@ -641,23 +660,23 @@ Api::methods() const {
inline int Api::options_size() const {
return options_.size();
}
-inline const ::google::protobuf::Option& Api::options(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.Api.options)
- return options_.Get(index);
-}
inline ::google::protobuf::Option* Api::mutable_options(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.Api.options)
return options_.Mutable(index);
}
-inline ::google::protobuf::Option* Api::add_options() {
- // @@protoc_insertion_point(field_add:google.protobuf.Api.options)
- return options_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
Api::mutable_options() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.options)
return &options_;
}
+inline const ::google::protobuf::Option& Api::options(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Api.options)
+ return options_.Get(index);
+}
+inline ::google::protobuf::Option* Api::add_options() {
+ // @@protoc_insertion_point(field_add:google.protobuf.Api.options)
+ return options_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
Api::options() const {
// @@protoc_insertion_point(field_list:google.protobuf.Api.options)
@@ -737,7 +756,8 @@ inline ::google::protobuf::SourceContext* Api::release_source_context() {
inline ::google::protobuf::SourceContext* Api::mutable_source_context() {
if (source_context_ == NULL) {
- source_context_ = new ::google::protobuf::SourceContext;
+ source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.Api.source_context)
return source_context_;
@@ -768,23 +788,23 @@ inline int Api::mixins_size() const {
inline void Api::clear_mixins() {
mixins_.Clear();
}
-inline const ::google::protobuf::Mixin& Api::mixins(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.Api.mixins)
- return mixins_.Get(index);
-}
inline ::google::protobuf::Mixin* Api::mutable_mixins(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.Api.mixins)
return mixins_.Mutable(index);
}
-inline ::google::protobuf::Mixin* Api::add_mixins() {
- // @@protoc_insertion_point(field_add:google.protobuf.Api.mixins)
- return mixins_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*
Api::mutable_mixins() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.mixins)
return &mixins_;
}
+inline const ::google::protobuf::Mixin& Api::mixins(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Api.mixins)
+ return mixins_.Get(index);
+}
+inline ::google::protobuf::Mixin* Api::add_mixins() {
+ // @@protoc_insertion_point(field_add:google.protobuf.Api.mixins)
+ return mixins_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&
Api::mixins() const {
// @@protoc_insertion_point(field_list:google.protobuf.Api.mixins)
@@ -1000,23 +1020,23 @@ inline void Method::set_response_streaming(bool value) {
inline int Method::options_size() const {
return options_.size();
}
-inline const ::google::protobuf::Option& Method::options(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.Method.options)
- return options_.Get(index);
-}
inline ::google::protobuf::Option* Method::mutable_options(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.Method.options)
return options_.Mutable(index);
}
-inline ::google::protobuf::Option* Method::add_options() {
- // @@protoc_insertion_point(field_add:google.protobuf.Method.options)
- return options_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
Method::mutable_options() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.Method.options)
return &options_;
}
+inline const ::google::protobuf::Option& Method::options(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Method.options)
+ return options_.Get(index);
+}
+inline ::google::protobuf::Option* Method::add_options() {
+ // @@protoc_insertion_point(field_add:google.protobuf.Method.options)
+ return options_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
Method::options() const {
// @@protoc_insertion_point(field_list:google.protobuf.Method.options)
diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc
index e9289988..e53d7219 100755
--- a/src/google/protobuf/arena.cc
+++ b/src/google/protobuf/arena.cc
@@ -73,14 +73,15 @@ void ArenaImpl::Init() {
// Thread which calls Init() owns the first block. This allows the
// single-threaded case to allocate on the first block without having to
// perform atomic operations.
- InitBlock(initial_block_, &thread_cache(), options_.initial_block_size);
- ThreadInfo* info = NewThreadInfo(initial_block_);
- info->next = NULL;
+ new (initial_block_) Block(options_.initial_block_size, NULL);
+ SerialArena* serial =
+ SerialArena::New(initial_block_, &thread_cache(), this);
+ serial->set_next(NULL);
google::protobuf::internal::NoBarrier_Store(&threads_,
- reinterpret_cast<google::protobuf::internal::AtomicWord>(info));
+ reinterpret_cast<google::protobuf::internal::AtomicWord>(serial));
google::protobuf::internal::NoBarrier_Store(&space_allocated_,
options_.initial_block_size);
- CacheBlock(initial_block_);
+ CacheSerialArena(serial);
} else {
google::protobuf::internal::NoBarrier_Store(&space_allocated_, 0);
}
@@ -103,145 +104,134 @@ uint64 ArenaImpl::Reset() {
return space_allocated;
}
-ArenaImpl::Block* ArenaImpl::NewBlock(void* me, Block* my_last_block,
- size_t min_bytes) {
+ArenaImpl::Block* ArenaImpl::NewBlock(Block* last_block, size_t min_bytes) {
size_t size;
- if (my_last_block != NULL) {
+ if (last_block) {
// Double the current block size, up to a limit.
- size = std::min(2 * my_last_block->size, options_.max_block_size);
+ size = std::min(2 * last_block->size(), options_.max_block_size);
} else {
size = options_.start_block_size;
}
- // Verify that min_bytes + kHeaderSize won't overflow.
- GOOGLE_CHECK_LE(min_bytes, std::numeric_limits<size_t>::max() - kHeaderSize);
- size = std::max(size, kHeaderSize + min_bytes);
+ // Verify that min_bytes + kBlockHeaderSize won't overflow.
+ GOOGLE_CHECK_LE(min_bytes, std::numeric_limits<size_t>::max() - kBlockHeaderSize);
+ size = std::max(size, kBlockHeaderSize + min_bytes);
- Block* b = reinterpret_cast<Block*>(options_.block_alloc(size));
- InitBlock(b, me, size);
+ void* mem = options_.block_alloc(size);
+ Block* b = new (mem) Block(size, last_block);
google::protobuf::internal::NoBarrier_AtomicIncrement(&space_allocated_, size);
return b;
}
-void ArenaImpl::InitBlock(Block* b, void *me, size_t size) {
- b->pos = kHeaderSize;
- b->size = size;
- b->owner = me;
- b->next = NULL;
-#ifdef ADDRESS_SANITIZER
- // Poison the rest of the block for ASAN. It was unpoisoned by the underlying
- // malloc but it's not yet usable until we return it as part of an allocation.
- ASAN_POISON_MEMORY_REGION(
- reinterpret_cast<char*>(b) + b->pos, b->size - b->pos);
-#endif // ADDRESS_SANITIZER
-}
+ArenaImpl::Block::Block(size_t size, Block* next)
+ : next_(next), pos_(kBlockHeaderSize), size_(size) {}
-ArenaImpl::CleanupChunk* ArenaImpl::ExpandCleanupList(CleanupChunk* cleanup,
- Block* b) {
- size_t size = cleanup ? cleanup->size * 2 : kMinCleanupListElements;
+GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+void ArenaImpl::SerialArena::AddCleanupFallback(void* elem,
+ void (*cleanup)(void*)) {
+ size_t size = cleanup_ ? cleanup_->size * 2 : kMinCleanupListElements;
size = std::min(size, kMaxCleanupListElements);
size_t bytes = internal::AlignUpTo8(CleanupChunk::SizeOf(size));
- if (b->avail() < bytes) {
- b = GetBlock(bytes);
- }
- CleanupChunk* list =
- reinterpret_cast<CleanupChunk*>(AllocFromBlock(b, bytes));
- list->next = b->thread_info->cleanup;
+ CleanupChunk* list = reinterpret_cast<CleanupChunk*>(AllocateAligned(bytes));
+ list->next = cleanup_;
list->size = size;
- list->len = 0;
- b->thread_info->cleanup = list;
- return list;
+
+ cleanup_ = list;
+ cleanup_ptr_ = &list->nodes[0];
+ cleanup_limit_ = &list->nodes[size];
+
+ AddCleanup(elem, cleanup);
}
-inline GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
-void ArenaImpl::AddCleanupInBlock(
- Block* b, void* elem, void (*func)(void*)) {
- CleanupChunk* cleanup = b->thread_info->cleanup;
- if (cleanup == NULL || cleanup->len == cleanup->size) {
- cleanup = ExpandCleanupList(cleanup, b);
+void* ArenaImpl::AllocateAligned(size_t n) {
+ SerialArena* arena;
+ if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ return arena->AllocateAligned(n);
+ } else {
+ return AllocateAlignedFallback(n);
}
+}
- CleanupNode* node = &cleanup->nodes[cleanup->len++];
-
- node->elem = elem;
- node->cleanup = func;
+void* ArenaImpl::AllocateAlignedAndAddCleanup(size_t n,
+ void (*cleanup)(void*)) {
+ SerialArena* arena;
+ if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ return arena->AllocateAlignedAndAddCleanup(n, cleanup);
+ } else {
+ return AllocateAlignedAndAddCleanupFallback(n, cleanup);
+ }
}
void ArenaImpl::AddCleanup(void* elem, void (*cleanup)(void*)) {
- return AddCleanupInBlock(GetBlock(0), elem, cleanup);
+ SerialArena* arena;
+ if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ arena->AddCleanup(elem, cleanup);
+ } else {
+ return AddCleanupFallback(elem, cleanup);
+ }
}
-void* ArenaImpl::AllocateAligned(size_t n) {
- GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
-
- return AllocFromBlock(GetBlock(n), n);
+GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+void* ArenaImpl::AllocateAlignedFallback(size_t n) {
+ return GetSerialArena()->AllocateAligned(n);
}
-void* ArenaImpl::AllocateAlignedAndAddCleanup(size_t n,
- void (*cleanup)(void*)) {
- GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
+GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+void* ArenaImpl::AllocateAlignedAndAddCleanupFallback(size_t n,
+ void (*cleanup)(void*)) {
+ return GetSerialArena()->AllocateAlignedAndAddCleanup(n, cleanup);
+}
- Block* b = GetBlock(n);
- void* mem = AllocFromBlock(b, n);
- AddCleanupInBlock(b, mem, cleanup);
- return mem;
+GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+void ArenaImpl::AddCleanupFallback(void* elem, void (*cleanup)(void*)) {
+ GetSerialArena()->AddCleanup(elem, cleanup);
}
inline GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
-ArenaImpl::Block* ArenaImpl::GetBlock(size_t n) {
- Block* my_block = NULL;
-
+bool ArenaImpl::GetSerialArenaFast(ArenaImpl::SerialArena** arena) {
// If this thread already owns a block in this arena then try to use that.
// This fast path optimizes the case where multiple threads allocate from the
// same arena.
ThreadCache* tc = &thread_cache();
- if (tc->last_lifecycle_id_seen == lifecycle_id_) {
- my_block = tc->last_block_used_;
- if (my_block->avail() >= n) {
- return my_block;
- }
+ if (GOOGLE_PREDICT_TRUE(tc->last_lifecycle_id_seen == lifecycle_id_)) {
+ *arena = tc->last_serial_arena;
+ return true;
}
- // Check whether we own the last accessed block on this arena.
- // This fast path optimizes the case where a single thread uses multiple
- // arenas.
- Block* b = reinterpret_cast<Block*>(google::protobuf::internal::Acquire_Load(&hint_));
- if (b != NULL && b->owner == tc) {
- my_block = b;
- if (my_block->avail() >= n) {
- return my_block;
- }
+ // Check whether we own the last accessed SerialArena on this arena. This
+ // fast path optimizes the case where a single thread uses multiple arenas.
+ SerialArena* serial =
+ reinterpret_cast<SerialArena*>(google::protobuf::internal::Acquire_Load(&hint_));
+ if (GOOGLE_PREDICT_TRUE(serial != NULL && serial->owner() == tc)) {
+ *arena = serial;
+ return true;
}
- return GetBlockSlow(tc, my_block, n);
+
+ return false;
}
-inline GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
-void* ArenaImpl::AllocFromBlock(Block* b, size_t n) {
- GOOGLE_DCHECK_EQ(internal::AlignUpTo8(b->pos), b->pos); // Must be already aligned.
- GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
- GOOGLE_DCHECK_GE(b->avail(), n);
- size_t p = b->pos;
- b->pos = p + n;
+ArenaImpl::SerialArena* ArenaImpl::GetSerialArena() {
+ SerialArena* arena;
+ if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ return arena;
+ } else {
+ return GetSerialArenaFallback(&thread_cache());
+ }
+}
+
+GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+void* ArenaImpl::SerialArena::AllocateAlignedFallback(size_t n) {
+ // Sync back to current's pos.
+ head_->set_pos(head_->size() - (limit_ - ptr_));
+
+ head_ = arena_->NewBlock(head_, n);
+ ptr_ = head_->Pointer(head_->pos());
+ limit_ = head_->Pointer(head_->size());
+
#ifdef ADDRESS_SANITIZER
- ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b) + p, n);
+ ASAN_POISON_MEMORY_REGION(ptr_, limit_ - ptr_);
#endif // ADDRESS_SANITIZER
- return reinterpret_cast<char*>(b) + p;
-}
-ArenaImpl::Block* ArenaImpl::GetBlockSlow(void* me, Block* my_full_block,
- size_t n) {
- ThreadInfo* info =
- my_full_block ? my_full_block->thread_info : GetThreadInfo(me, n);
- GOOGLE_DCHECK(info != NULL);
- Block* b = info->head;
- if (b->avail() < n) {
- Block* new_b = NewBlock(me, b, n);
- new_b->thread_info = info;
- new_b->next = b;
- info->head = new_b;
- b = new_b;
- }
- CacheBlock(b);
- return b;
+ return AllocateAligned(n);
}
uint64 ArenaImpl::SpaceAllocated() const {
@@ -249,18 +239,24 @@ uint64 ArenaImpl::SpaceAllocated() const {
}
uint64 ArenaImpl::SpaceUsed() const {
- ThreadInfo* info =
- reinterpret_cast<ThreadInfo*>(google::protobuf::internal::Acquire_Load(&threads_));
+ SerialArena* serial =
+ reinterpret_cast<SerialArena*>(google::protobuf::internal::Acquire_Load(&threads_));
uint64 space_used = 0;
-
- for ( ; info; info = info->next) {
- // Remove the overhead of the ThreadInfo itself.
- space_used -= sizeof(ThreadInfo);
- for (Block* b = info->head; b; b = b->next) {
- space_used += (b->pos - kHeaderSize);
- }
+ for ( ; serial; serial = serial->next()) {
+ space_used += serial->SpaceUsed();
}
+ return space_used;
+}
+uint64 ArenaImpl::SerialArena::SpaceUsed() const {
+ // Get current block's size from ptr_ (since we can't trust head_->pos().
+ uint64 space_used = ptr_ - head_->Pointer(kBlockHeaderSize);
+ // Get subsequent block size from b->pos().
+ for (Block* b = head_->next(); b; b = b->next()) {
+ space_used += (b->pos() - kBlockHeaderSize);
+ }
+ // Remove the overhead of the SerialArena itself.
+ space_used -= kSerialArenaSize;
return space_used;
}
@@ -268,30 +264,45 @@ uint64 ArenaImpl::FreeBlocks() {
uint64 space_allocated = 0;
// By omitting an Acquire barrier we ensure that any user code that doesn't
// properly synchronize Reset() or the destructor will throw a TSAN warning.
- ThreadInfo* info =
- reinterpret_cast<ThreadInfo*>(google::protobuf::internal::NoBarrier_Load(&threads_));
+ SerialArena* serial =
+ reinterpret_cast<SerialArena*>(google::protobuf::internal::NoBarrier_Load(&threads_));
+
+ while (serial) {
+ // This is inside a block we are freeing, so we need to read it now.
+ SerialArena* next = serial->next();
+ space_allocated += ArenaImpl::SerialArena::Free(serial, initial_block_,
+ options_.block_dealloc);
+ // serial is dead now.
+ serial = next;
+ }
- while (info) {
+ return space_allocated;
+}
+
+uint64 ArenaImpl::SerialArena::Free(ArenaImpl::SerialArena* serial,
+ Block* initial_block,
+ void (*block_dealloc)(void*, size_t)) {
+ uint64 space_allocated = 0;
+
+ // We have to be careful in this function, since we will be freeing the Block
+ // that contains this SerialArena. Be careful about accessing |serial|.
+
+ for (Block* b = serial->head_; b; ) {
// This is inside the block we are freeing, so we need to read it now.
- ThreadInfo* next_info = info->next;
- for (Block* b = info->head; b; ) {
- // This is inside the block we are freeing, so we need to read it now.
- Block* next_block = b->next;
- space_allocated += (b->size);
+ Block* next_block = b->next();
+ space_allocated += (b->size());
#ifdef ADDRESS_SANITIZER
- // This memory was provided by the underlying allocator as unpoisoned, so
- // return it in an unpoisoned state.
- ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b), b->size);
+ // This memory was provided by the underlying allocator as unpoisoned, so
+ // return it in an unpoisoned state.
+ ASAN_UNPOISON_MEMORY_REGION(b->Pointer(0), b->size());
#endif // ADDRESS_SANITIZER
- if (b != initial_block_) {
- options_.block_dealloc(b, b->size);
- }
-
- b = next_block;
+ if (b != initial_block) {
+ block_dealloc(b, b->size());
}
- info = next_info;
+
+ b = next_block;
}
return space_allocated;
@@ -300,63 +311,87 @@ uint64 ArenaImpl::FreeBlocks() {
void ArenaImpl::CleanupList() {
// By omitting an Acquire barrier we ensure that any user code that doesn't
// properly synchronize Reset() or the destructor will throw a TSAN warning.
- ThreadInfo* info =
- reinterpret_cast<ThreadInfo*>(google::protobuf::internal::NoBarrier_Load(&threads_));
-
- for ( ; info; info = info->next) {
- CleanupChunk* list = info->cleanup;
- while (list) {
- size_t n = list->len;
- CleanupNode* node = &list->nodes[list->len - 1];
- for (size_t i = 0; i < n; i++, node--) {
- node->cleanup(node->elem);
- }
- list = list->next;
- }
+ SerialArena* serial =
+ reinterpret_cast<SerialArena*>(google::protobuf::internal::NoBarrier_Load(&threads_));
+
+ for ( ; serial; serial = serial->next()) {
+ serial->CleanupList();
}
}
-ArenaImpl::ThreadInfo* ArenaImpl::NewThreadInfo(Block* b) {
- GOOGLE_DCHECK(FindThreadInfo(b->owner) == NULL);
- ThreadInfo* info =
- reinterpret_cast<ThreadInfo*>(AllocFromBlock(b, sizeof(ThreadInfo)));
- b->thread_info = info;
- info->owner = b->owner;
- info->head = b;
- info->cleanup = NULL;
- return info;
+void ArenaImpl::SerialArena::CleanupList() {
+ if (cleanup_ != NULL) {
+ CleanupListFallback();
+ }
}
-ArenaImpl::ThreadInfo* ArenaImpl::FindThreadInfo(void* me) {
- ThreadInfo* info =
- reinterpret_cast<ThreadInfo*>(google::protobuf::internal::Acquire_Load(&threads_));
- for ( ; info; info = info->next) {
- if (info->owner == me) {
- return info;
+void ArenaImpl::SerialArena::CleanupListFallback() {
+ // Cleanup newest chunk: ptrs give us length.
+ size_t n = cleanup_ptr_ - &cleanup_->nodes[0];
+ CleanupNode* node = cleanup_ptr_;
+ for (size_t i = 0; i < n; i++) {
+ --node;
+ node->cleanup(node->elem);
+ }
+
+ // Cleanup older chunks, which are known to be full.
+ CleanupChunk* list = cleanup_->next;
+ while (list) {
+ size_t n = list->size;
+ CleanupNode* node = &list->nodes[list->size];
+ for (size_t i = 0; i < n; i++) {
+ --node;
+ node->cleanup(node->elem);
}
+ list = list->next;
}
+}
- return NULL;
+ArenaImpl::SerialArena* ArenaImpl::SerialArena::New(Block* b, void* owner,
+ ArenaImpl* arena) {
+ GOOGLE_DCHECK_EQ(b->pos(), kBlockHeaderSize); // Should be a fresh block
+ GOOGLE_DCHECK_LE(kBlockHeaderSize + kSerialArenaSize, b->size());
+ SerialArena* serial =
+ reinterpret_cast<SerialArena*>(b->Pointer(kBlockHeaderSize));
+ b->set_pos(kBlockHeaderSize + kSerialArenaSize);
+ serial->arena_ = arena;
+ serial->owner_ = owner;
+ serial->head_ = b;
+ serial->ptr_ = b->Pointer(b->pos());
+ serial->limit_ = b->Pointer(b->size());
+ serial->cleanup_ = NULL;
+ serial->cleanup_ptr_ = NULL;
+ serial->cleanup_limit_ = NULL;
+ return serial;
}
-ArenaImpl::ThreadInfo* ArenaImpl::GetThreadInfo(void* me, size_t n) {
- ThreadInfo* info = FindThreadInfo(me);
+GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+ArenaImpl::SerialArena* ArenaImpl::GetSerialArenaFallback(void* me) {
+ // Look for this SerialArena in our linked list.
+ SerialArena* serial =
+ reinterpret_cast<SerialArena*>(google::protobuf::internal::Acquire_Load(&threads_));
+ for ( ; serial; serial = serial->next()) {
+ if (serial->owner() == me) {
+ break;
+ }
+ }
- if (!info) {
- // This thread doesn't have any ThreadInfo, which also means it doesn't have
- // any blocks yet. So we'll allocate its first block now.
- Block* b = NewBlock(me, NULL, sizeof(ThreadInfo) + n);
- info = NewThreadInfo(b);
+ if (!serial) {
+ // This thread doesn't have any SerialArena, which also means it doesn't
+ // have any blocks yet. So we'll allocate its first block now.
+ Block* b = NewBlock(NULL, kSerialArenaSize);
+ serial = SerialArena::New(b, me, this);
google::protobuf::internal::AtomicWord head;
do {
head = google::protobuf::internal::NoBarrier_Load(&threads_);
- info->next = reinterpret_cast<ThreadInfo*>(head);
+ serial->set_next(reinterpret_cast<SerialArena*>(head));
} while (google::protobuf::internal::Release_CompareAndSwap(
- &threads_, head, reinterpret_cast<google::protobuf::internal::AtomicWord>(info)) != head);
+ &threads_, head, reinterpret_cast<google::protobuf::internal::AtomicWord>(serial)) != head);
}
- return info;
+ CacheSerialArena(serial);
+ return serial;
}
} // namespace internal
diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h
index 32be9a17..f3cdedac 100644
--- a/src/google/protobuf/arena.h
+++ b/src/google/protobuf/arena.h
@@ -56,6 +56,21 @@ using type_info = ::type_info;
namespace google {
namespace protobuf {
+struct ArenaOptions;
+} // namespace protobuf
+
+namespace quality_webanswers {
+
+void TempPrivateWorkAround(::google::protobuf::ArenaOptions* arena_options);
+
+} // namespace quality_webanswers
+
+namespace protobuf {
+namespace arena_metrics {
+
+void EnableArenaMetrics(::google::protobuf::ArenaOptions* options);
+
+} // namespace arena_metrics
class Arena; // defined below
class Message; // message.h
@@ -117,6 +132,20 @@ struct ArenaOptions {
// from the arena. By default, it contains a ptr to a wrapper function that
// calls free.
void (*block_dealloc)(void*, size_t);
+
+ ArenaOptions()
+ : start_block_size(kDefaultStartBlockSize),
+ max_block_size(kDefaultMaxBlockSize),
+ initial_block(NULL),
+ initial_block_size(0),
+ block_alloc(&::operator new),
+ block_dealloc(&internal::arena_free),
+ on_arena_init(NULL),
+ on_arena_reset(NULL),
+ on_arena_destruction(NULL),
+ on_arena_allocation(NULL) {}
+
+ private:
// Hooks for adding external functionality such as user-specific metrics
// collection, specific debugging abilities, etc.
// Init hook may return a pointer to a cookie to be stored in the arena.
@@ -138,23 +167,15 @@ struct ArenaOptions {
void (*on_arena_allocation)(const std::type_info* allocated_type,
uint64 alloc_size, void* cookie);
- ArenaOptions()
- : start_block_size(kDefaultStartBlockSize),
- max_block_size(kDefaultMaxBlockSize),
- initial_block(NULL),
- initial_block_size(0),
- block_alloc(&::operator new),
- block_dealloc(&internal::arena_free),
- on_arena_init(NULL),
- on_arena_reset(NULL),
- on_arena_destruction(NULL),
- on_arena_allocation(NULL) {}
-
- private:
// Constants define default starting block size and max block size for
// arena allocator behavior -- see descriptions above.
static const size_t kDefaultStartBlockSize = 256;
static const size_t kDefaultMaxBlockSize = 8192;
+
+ friend void ::google::protobuf::arena_metrics::EnableArenaMetrics(ArenaOptions*);
+ friend void quality_webanswers::TempPrivateWorkAround(ArenaOptions*);
+ friend class Arena;
+ friend class ArenaOptionsTestFriend;
};
// Support for non-RTTI environments. (The metrics hooks API uses type
@@ -229,14 +250,15 @@ class LIBPROTOBUF_EXPORT Arena {
// WARNING: if you allocate multiple objects, it is difficult to guarantee
// that a series of allocations will fit in the initial block, especially if
// Arena changes its alignment guarantees in the future!
- static const size_t kBlockOverhead = internal::ArenaImpl::kHeaderSize;
+ static const size_t kBlockOverhead = internal::ArenaImpl::kBlockHeaderSize +
+ internal::ArenaImpl::kSerialArenaSize;
// Default constructor with sensible default options, tuned for average
// use-cases.
Arena() : impl_(ArenaOptions()) { Init(ArenaOptions()); }
~Arena() {
- if (on_arena_reset_ != NULL || on_arena_destruction_ != NULL) {
+ if (hooks_cookie_) {
CallDestructorHooks();
}
}
@@ -277,6 +299,7 @@ class LIBPROTOBUF_EXPORT Arena {
}
}
#endif
+
template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
static T* CreateMessage(::google::protobuf::Arena* arena) {
#if LANG_CXX11
@@ -355,6 +378,7 @@ class LIBPROTOBUF_EXPORT Arena {
}
}
#endif
+
template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
static T* Create(::google::protobuf::Arena* arena) {
if (arena == NULL) {
@@ -522,6 +546,7 @@ class LIBPROTOBUF_EXPORT Arena {
//
// Combines SpaceAllocated and SpaceUsed. Returns a pair of
// <space_allocated, space_used>.
+ PROTOBUF_RUNTIME_DEPRECATED("Please use SpaceAllocated() and SpaceUsed()")
std::pair<uint64, uint64> SpaceAllocatedAndUsed() const {
return std::make_pair(SpaceAllocated(), SpaceUsed());
}
@@ -637,6 +662,29 @@ class LIBPROTOBUF_EXPORT Arena {
struct is_arena_constructable : InternalHelper<T>::is_arena_constructable {};
private:
+ template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ static T* CreateMessageInternal(::google::protobuf::Arena* arena) {
+#if LANG_CXX11
+ static_assert(
+ InternalHelper<T>::is_arena_constructable::value,
+ "CreateMessage can only construct types that are ArenaConstructable");
+#endif
+ if (arena == NULL) {
+ return new T;
+ } else {
+ return arena->CreateMessageInternal<T>();
+ }
+ }
+
+ template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ static T* CreateInternal(::google::protobuf::Arena* arena) {
+ if (arena == NULL) {
+ return new T();
+ } else {
+ return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value);
+ }
+ }
+
void CallDestructorHooks();
void OnArenaAllocation(const std::type_info* allocated_type, size_t n) const;
inline void AllocHook(const std::type_info* allocated_type, size_t n) const {
@@ -668,12 +716,12 @@ class LIBPROTOBUF_EXPORT Arena {
// fields, since they are designed to work in all mode combinations.
template <typename Msg> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
static Msg* CreateMaybeMessage(Arena* arena, google::protobuf::internal::true_type) {
- return CreateMessage<Msg>(arena);
+ return CreateMessageInternal<Msg>(arena);
}
template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
static T* CreateMaybeMessage(Arena* arena, google::protobuf::internal::false_type) {
- return Create<T>(arena);
+ return CreateInternal<T>(arena);
}
template <typename T> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
@@ -907,7 +955,6 @@ class LIBPROTOBUF_EXPORT Arena {
internal::ArenaImpl impl_;
- void* (*on_arena_init_)(Arena* arena);
void (*on_arena_allocation_)(const std::type_info* allocated_type,
uint64 alloc_size, void* cookie);
void (*on_arena_reset_)(Arena* arena, void* cookie, uint64 space_used);
diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h
index 6cc7096b..439b0969 100644
--- a/src/google/protobuf/arena_impl.h
+++ b/src/google/protobuf/arena_impl.h
@@ -40,10 +40,13 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/mutex.h>
-#include <google/protobuf/stubs/type_traits.h>
#include <google/protobuf/stubs/port.h>
+#ifdef ADDRESS_SANITIZER
+#include <sanitizer/asan_interface.h>
+#endif // ADDRESS_SANITIZER
+
namespace google {
namespace protobuf {
@@ -112,6 +115,10 @@ class LIBPROTOBUF_EXPORT ArenaImpl {
void AddCleanup(void* elem, void (*cleanup)(void*));
private:
+ void* AllocateAlignedFallback(size_t n);
+ void* AllocateAlignedAndAddCleanupFallback(size_t n, void (*cleanup)(void*));
+ void AddCleanupFallback(void* elem, void (*cleanup)(void*));
+
// Node contains the ptr of the object to be cleaned up and the associated
// cleanup function ptr.
struct CleanupNode {
@@ -124,34 +131,107 @@ class LIBPROTOBUF_EXPORT ArenaImpl {
static size_t SizeOf(size_t i) {
return sizeof(CleanupChunk) + (sizeof(CleanupNode) * (i - 1));
}
- size_t len; // Number of elements currently present.
size_t size; // Total elements in the list.
CleanupChunk* next; // Next node in the list.
CleanupNode nodes[1]; // True length is |size|.
};
- struct Block;
+ class Block;
+
+ // A thread-unsafe Arena that can only be used within its owning thread.
+ class LIBPROTOBUF_EXPORT SerialArena {
+ public:
+ // The allocate/free methods here are a little strange, since SerialArena is
+ // allocated inside a Block which it also manages. This is to avoid doing
+ // an extra allocation for the SerialArena itself.
+
+ // Creates a new SerialArena inside Block* and returns it.
+ static SerialArena* New(Block* b, void* owner, ArenaImpl* arena);
+
+ // Destroys this SerialArena, freeing all blocks with the given dealloc
+ // function, except any block equal to |initial_block|.
+ static uint64 Free(SerialArena* serial, Block* initial_block,
+ void (*block_dealloc)(void*, size_t));
+
+ void CleanupList();
+ uint64 SpaceUsed() const;
+
+ void* AllocateAligned(size_t n) {
+ GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
+ GOOGLE_DCHECK_GE(limit_, ptr_);
+ if (GOOGLE_PREDICT_FALSE(static_cast<size_t>(limit_ - ptr_) < n)) {
+ return AllocateAlignedFallback(n);
+ }
+ void* ret = ptr_;
+ ptr_ += n;
+#ifdef ADDRESS_SANITIZER
+ ASAN_UNPOISON_MEMORY_REGION(ret, n);
+#endif // ADDRESS_SANITIZER
+ return ret;
+ }
+
+ void AddCleanup(void* elem, void (*cleanup)(void*)) {
+ if (GOOGLE_PREDICT_FALSE(cleanup_ptr_ == cleanup_limit_)) {
+ AddCleanupFallback(elem, cleanup);
+ return;
+ }
+ cleanup_ptr_->elem = elem;
+ cleanup_ptr_->cleanup = cleanup;
+ cleanup_ptr_++;
+ }
+
+ void* AllocateAlignedAndAddCleanup(size_t n, void (*cleanup)(void*)) {
+ void* ret = AllocateAligned(n);
+ AddCleanup(ret, cleanup);
+ return ret;
+ }
- // Tracks per-thread info. ThreadInfos are kept in a linked list.
- struct ThreadInfo {
- void *owner; // &ThreadCache of this thread;
- Block* head; // Head of linked list of blocks.
- CleanupChunk* cleanup; // Head of cleanup list.
- ThreadInfo* next; // Next ThreadInfo in this linked list.
+ void* owner() const { return owner_; }
+ SerialArena* next() const { return next_; }
+ void set_next(SerialArena* next) { next_ = next; }
+
+ private:
+ void* AllocateAlignedFallback(size_t n);
+ void AddCleanupFallback(void* elem, void (*cleanup)(void*));
+ void CleanupListFallback();
+
+ ArenaImpl* arena_; // Containing arena.
+ void* owner_; // &ThreadCache of this thread;
+ Block* head_; // Head of linked list of blocks.
+ CleanupChunk* cleanup_; // Head of cleanup list.
+ SerialArena* next_; // Next SerialArena in this linked list.
+
+ // Next pointer to allocate from. Always 8-byte aligned. Points inside
+ // head_ (and head_->pos will always be non-canonical). We keep these
+ // here to reduce indirection.
+ char* ptr_;
+ char* limit_;
+
+ // Next CleanupList members to append to. These point inside cleanup_.
+ CleanupNode* cleanup_ptr_;
+ CleanupNode* cleanup_limit_;
};
// Blocks are variable length malloc-ed objects. The following structure
// describes the common header for all blocks.
- struct Block {
- void* owner; // &ThreadCache of thread that owns this block.
- ThreadInfo* thread_info; // ThreadInfo of thread that owns this block.
- Block* next; // Next block in arena (may have different owner)
- // ((char*) &block) + pos is next available byte. It is always
- // aligned at a multiple of 8 bytes.
- size_t pos;
- size_t size; // total size of the block.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
- size_t avail() const { return size - pos; }
+ class LIBPROTOBUF_EXPORT Block {
+ public:
+ Block(size_t size, Block* next);
+
+ char* Pointer(size_t n) {
+ GOOGLE_DCHECK(n <= size_);
+ return reinterpret_cast<char*>(this) + n;
+ }
+
+ Block* next() const { return next_; }
+ size_t pos() const { return pos_; }
+ size_t size() const { return size_; }
+ void set_pos(size_t pos) { pos_ = pos; }
+
+ private:
+ Block* next_; // Next block for this thread.
+ size_t pos_;
+ size_t size_;
// data follows
};
@@ -160,13 +240,13 @@ class LIBPROTOBUF_EXPORT ArenaImpl {
// If we are using the ThreadLocalStorage class to store the ThreadCache,
// then the ThreadCache's default constructor has to be responsible for
// initializing it.
- ThreadCache() : last_lifecycle_id_seen(-1), last_block_used_(NULL) {}
+ ThreadCache() : last_lifecycle_id_seen(-1), last_serial_arena(NULL) {}
#endif
// The ThreadCache is considered valid as long as this matches the
// lifecycle_id of the arena being used.
int64 last_lifecycle_id_seen;
- Block* last_block_used_;
+ SerialArena* last_serial_arena;
};
static google::protobuf::internal::SequenceNumber lifecycle_id_generator_;
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
@@ -188,38 +268,30 @@ class LIBPROTOBUF_EXPORT ArenaImpl {
// Free all blocks and return the total space used which is the sums of sizes
// of the all the allocated blocks.
uint64 FreeBlocks();
-
- void AddCleanupInBlock(Block* b, void* elem, void (*func)(void*));
- CleanupChunk* ExpandCleanupList(CleanupChunk* cleanup, Block* b);
// Delete or Destruct all objects owned by the arena.
void CleanupList();
- inline void CacheBlock(Block* block) {
- thread_cache().last_block_used_ = block;
+ inline void CacheSerialArena(SerialArena* serial) {
+ thread_cache().last_serial_arena = serial;
thread_cache().last_lifecycle_id_seen = lifecycle_id_;
// TODO(haberman): evaluate whether we would gain efficiency by getting rid
// of hint_. It's the only write we do to ArenaImpl in the allocation path,
// which will dirty the cache line.
- google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(block));
+ google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(serial));
}
- google::protobuf::internal::AtomicWord threads_; // Pointer to a linked list of ThreadInfo.
+ google::protobuf::internal::AtomicWord threads_; // Pointer to a linked list of SerialArena.
google::protobuf::internal::AtomicWord hint_; // Fast thread-local block access
google::protobuf::internal::AtomicWord space_allocated_; // Sum of sizes of all allocated blocks.
Block *initial_block_; // If non-NULL, points to the block that came from
// user data.
- // Returns a block owned by this thread.
- Block* GetBlock(size_t n);
- Block* GetBlockSlow(void* me, Block* my_full_block, size_t n);
- Block* NewBlock(void* me, Block* my_last_block, size_t min_bytes);
- void InitBlock(Block* b, void *me, size_t size);
- static void* AllocFromBlock(Block* b, size_t n);
- ThreadInfo* NewThreadInfo(Block* b);
- ThreadInfo* FindThreadInfo(void* me);
- ThreadInfo* GetThreadInfo(void* me, size_t n);
+ Block* NewBlock(Block* last_block, size_t min_bytes);
+ SerialArena* GetSerialArena();
+ bool GetSerialArenaFast(SerialArena** arena);
+ SerialArena* GetSerialArenaFallback(void* me);
int64 lifecycle_id_; // Unique for each arena. Changes on Reset().
Options options_;
@@ -227,11 +299,15 @@ class LIBPROTOBUF_EXPORT ArenaImpl {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArenaImpl);
public:
- // kHeaderSize is sizeof(Block), aligned up to the nearest multiple of 8 to
- // protect the invariant that pos is always at a multiple of 8.
- static const size_t kHeaderSize = (sizeof(Block) + 7) & -8;
+ // kBlockHeaderSize is sizeof(Block), aligned up to the nearest multiple of 8
+ // to protect the invariant that pos is always at a multiple of 8.
+ static const size_t kBlockHeaderSize = (sizeof(Block) + 7) & -8;
+ static const size_t kSerialArenaSize = (sizeof(SerialArena) + 7) & -8;
#if LANG_CXX11
- static_assert(kHeaderSize % 8 == 0, "kHeaderSize must be a multiple of 8.");
+ static_assert(kBlockHeaderSize % 8 == 0,
+ "kBlockHeaderSize must be a multiple of 8.");
+ static_assert(kSerialArenaSize % 8 == 0,
+ "kSerialArenaSize must be a multiple of 8.");
#endif
};
diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc
index c6ff25e8..71e28b0c 100644
--- a/src/google/protobuf/arena_unittest.cc
+++ b/src/google/protobuf/arena_unittest.cc
@@ -67,7 +67,6 @@ using protobuf_unittest::TestOneof2;
using protobuf_unittest::TestEmptyMessage;
namespace protobuf {
-namespace {
class Notifier {
public:
@@ -270,7 +269,7 @@ TEST(ArenaTest, InitialBlockTooSmall) {
// Construct a small (64 byte) initial block of memory to be used by the
// arena allocator; then, allocate an object which will not fit in the
// initial block.
- std::vector<char> arena_block(72);
+ std::vector<char> arena_block(96);
ArenaOptions options;
options.initial_block = &arena_block[0];
options.initial_block_size = arena_block.size();
@@ -1299,12 +1298,12 @@ TEST(ArenaTest, SpaceAllocated_and_Used) {
options.initial_block_size = 0;
Arena arena_3(options);
EXPECT_EQ(0, arena_3.SpaceUsed());
- ::google::protobuf::Arena::CreateArray<char>(&arena_3, 182);
+ ::google::protobuf::Arena::CreateArray<char>(&arena_3, 160);
EXPECT_EQ(256, arena_3.SpaceAllocated());
- EXPECT_EQ(Align8(182), arena_3.SpaceUsed());
+ EXPECT_EQ(Align8(160), arena_3.SpaceUsed());
::google::protobuf::Arena::CreateArray<char>(&arena_3, 70);
EXPECT_EQ(256 + 512, arena_3.SpaceAllocated());
- EXPECT_EQ(Align8(182) + Align8(70), arena_3.SpaceUsed());
+ EXPECT_EQ(Align8(160) + Align8(70), arena_3.SpaceUsed());
EXPECT_EQ(256 + 512, arena_3.Reset());
}
@@ -1347,6 +1346,13 @@ TEST(ArenaTest, GetArenaShouldReturnNullForNonArenaAllocatedMessages) {
EXPECT_EQ(NULL, Arena::GetArena(const_pointer_to_message));
}
+TEST(ArenaTest, AddCleanup) {
+ ::google::protobuf::Arena arena;
+ for (int i = 0; i < 100; i++) {
+ arena.Own(new int);
+ }
+}
+
TEST(ArenaTest, UnsafeSetAllocatedOnArena) {
::google::protobuf::Arena arena;
TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);
@@ -1405,13 +1411,20 @@ uint32 ArenaHooksTestUtil::num_reset = 0;
uint32 ArenaHooksTestUtil::num_destruct = 0;
const int ArenaHooksTestUtil::kCookieValue;
+class ArenaOptionsTestFriend {
+ public:
+ static void Set(::google::protobuf::ArenaOptions* options) {
+ options->on_arena_init = ArenaHooksTestUtil::on_init;
+ options->on_arena_allocation = ArenaHooksTestUtil::on_allocation;
+ options->on_arena_reset = ArenaHooksTestUtil::on_reset;
+ options->on_arena_destruction = ArenaHooksTestUtil::on_destruction;
+ }
+};
+
// Test the hooks are correctly called and that the cookie is passed.
TEST(ArenaTest, ArenaHooksSanity) {
::google::protobuf::ArenaOptions options;
- options.on_arena_init = ArenaHooksTestUtil::on_init;
- options.on_arena_allocation = ArenaHooksTestUtil::on_allocation;
- options.on_arena_reset = ArenaHooksTestUtil::on_reset;
- options.on_arena_destruction = ArenaHooksTestUtil::on_destruction;
+ ArenaOptionsTestFriend::Set(&options);
// Scope for defining the arena
{
@@ -1433,6 +1446,5 @@ TEST(ArenaTest, ArenaHooksSanity) {
}
-} // namespace
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h
index c9d045a1..fb1b64a3 100755
--- a/src/google/protobuf/arenastring.h
+++ b/src/google/protobuf/arenastring.h
@@ -51,6 +51,18 @@ namespace google {
namespace protobuf {
namespace internal {
+template <typename T>
+class TaggedPtr {
+ public:
+ void Set(T* p) { ptr_ = reinterpret_cast<uintptr_t>(p); }
+ T* Get() const { return reinterpret_cast<T*>(ptr_); }
+
+ bool IsNull() { return ptr_ == 0; }
+
+ private:
+ uintptr_t ptr_;
+};
+
struct LIBPROTOBUF_EXPORT ArenaStringPtr {
inline void Set(const ::std::string* default_value,
const ::std::string& value, ::google::protobuf::Arena* arena) {
@@ -294,6 +306,15 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
return ptr_ == default_value;
}
+ // Internal accessors!!!!
+ void UnsafeSetTaggedPointer(TaggedPtr< ::std::string> value) {
+ ptr_ = value.Get();
+ }
+ // Generated code only! An optimization, in certain cases the generated
+ // code is certain we can obtain a string with no default checks and
+ // tag tests.
+ ::std::string* UnsafeMutablePointer() { return ptr_; }
+
private:
::std::string* ptr_;
diff --git a/src/google/protobuf/compiler/annotation_test_util.cc b/src/google/protobuf/compiler/annotation_test_util.cc
index aa14faf6..cc8534cc 100644
--- a/src/google/protobuf/compiler/annotation_test_util.cc
+++ b/src/google/protobuf/compiler/annotation_test_util.cc
@@ -76,10 +76,9 @@ void AddFile(const string& filename, const string& data) {
true));
}
-bool CaptureMetadata(const string& filename, const string& plugin_specific_args,
- const string& meta_file_suffix, CommandLineInterface* cli,
- FileDescriptorProto* file,
- std::vector<ExpectedOutput>* outputs) {
+bool RunProtoCompiler(const string& filename,
+ const string& plugin_specific_args,
+ CommandLineInterface* cli, FileDescriptorProto* file) {
cli->SetInputsAreProtoPathRelative(true);
DescriptorCapturingGenerator capturing_generator(file);
@@ -92,24 +91,7 @@ bool CaptureMetadata(const string& filename, const string& plugin_specific_args,
plugin_specific_args.c_str(), capture_out.c_str(),
filename.c_str()};
- if (cli->Run(5, argv) != 0) {
- return false;
- }
-
- if (outputs != NULL) {
- for (std::vector<ExpectedOutput>::iterator i = outputs->begin();
- i != outputs->end(); ++i) {
- GOOGLE_CHECK_OK(File::GetContents(TestTempDir() + "/" + i->file_path,
- &i->file_content, true));
- if (!DecodeMetadata(
- TestTempDir() + "/" + i->file_path + meta_file_suffix,
- &i->file_info)) {
- return false;
- }
- }
- }
-
- return true;
+ return cli->Run(5, argv) == 0;
}
bool DecodeMetadata(const string& path, GeneratedCodeInfo* info) {
diff --git a/src/google/protobuf/compiler/annotation_test_util.h b/src/google/protobuf/compiler/annotation_test_util.h
index 4598a45a..90bd88b3 100644
--- a/src/google/protobuf/compiler/annotation_test_util.h
+++ b/src/google/protobuf/compiler/annotation_test_util.h
@@ -59,25 +59,20 @@ struct ExpectedOutput {
// directory.
void AddFile(const string& filename, const string& data);
-// Tries to capture a FileDescriptorProto, GeneratedCodeInfo, and output
-// code from the previously added file with name `filename`.
+// Runs proto compiler. Captures proto file structrue in FileDescriptorProto.
+// Files will be generated in TestTempDir() folder. Callers of this
+// function must read generated files themselves.
//
// filename: source .proto file used to generate code.
// plugin_specific_args: command line arguments specific to current generator.
// For Java, this value might be "--java_out=annotate_code:test_temp_dir"
-// meta_file_suffix: suffix of meta files that contain annotations. For Java
-// it is ".pb.meta" because for file Foo.java meta file is Foo.java.pb.meta
// cli: instance of command line interface to run generator. See Java's
// annotation_unittest.cc for an example of how to initialize it.
// file: output parameter, will be set to the descriptor of the proto file
// specified in filename.
-// outputs: output parameter. If not NULL, each ExpectedOutput in the vector
-// should have its file_path set; CaptureMetadata will fill the rest of
-// the fields appropriately.
-bool CaptureMetadata(const string& filename, const string& plugin_specific_args,
- const string& meta_file_suffix, CommandLineInterface* cli,
- FileDescriptorProto* file,
- std::vector<ExpectedOutput>* outputs);
+bool RunProtoCompiler(const string& filename,
+ const string& plugin_specific_args,
+ CommandLineInterface* cli, FileDescriptorProto* file);
bool DecodeMetadata(const string& path, GeneratedCodeInfo* info);
diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h
index 4b1d90b8..4c2b3ee1 100644
--- a/src/google/protobuf/compiler/code_generator.h
+++ b/src/google/protobuf/compiler/code_generator.h
@@ -166,7 +166,7 @@ typedef GeneratorContext OutputDirectory;
// "foo=bar,baz,qux=corge"
// parses to the pairs:
// ("foo", "bar"), ("baz", ""), ("qux", "corge")
-void ParseGeneratorParameter(
+LIBPROTOC_EXPORT void ParseGeneratorParameter(
const string&, std::vector<std::pair<string, string> >*);
} // namespace compiler
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
index 3d5b5b8d..50c7b5f3 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -195,7 +195,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
"inline $type$ $classname$::$name$() const {\n"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
" if (has_$name$()) {\n"
- " return static_cast< $type$ >($oneof_prefix$$name$_);\n"
+ " return static_cast< $type$ >($field_member$);\n"
" }\n"
" return static_cast< $type$ >($default$);\n"
"}\n"
@@ -209,14 +209,14 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" }\n"
- " $oneof_prefix$$name$_ = value;\n"
+ " $field_member$ = value;\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n");
}
void EnumOneofFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
- printer->Print(variables_, "$oneof_prefix$$name$_ = $default$;\n");
+ printer->Print(variables_, "$field_member$ = $default$;\n");
}
void EnumOneofFieldGenerator::
diff --git a/src/google/protobuf/compiler/cpp/cpp_field.cc b/src/google/protobuf/compiler/cpp/cpp_field.cc
index f8e11855..0cf25b33 100644
--- a/src/google/protobuf/compiler/cpp/cpp_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_field.cc
@@ -67,12 +67,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["number"] = SimpleItoa(descriptor->number());
(*variables)["classname"] = ClassName(FieldScope(descriptor), false);
(*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type());
-
- // non_null_ptr_to_name is usable only if has_$name$ is true. It yields a
- // pointer that will not be NULL. Subclasses of FieldGenerator may set
- // (*variables)["non_null_ptr_to_name"] differently.
- (*variables)["non_null_ptr_to_name"] =
- StrCat("&this->", FieldName(descriptor), "()");
+ (*variables)["field_member"] = FieldName(descriptor) + "_";
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), descriptor->type()));
@@ -81,8 +76,6 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["deprecated_attr"] = descriptor->options().deprecated()
? "GOOGLE_PROTOBUF_DEPRECATED_ATTR " : "";
- (*variables)["cppget"] = "Get";
-
if (HasFieldPresence(descriptor->file())) {
(*variables)["set_hasbit"] =
"set_has_" + FieldName(descriptor) + "();";
@@ -93,10 +86,6 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["clear_hasbit"] = "";
}
- // By default, empty string, so that generic code used for both oneofs and
- // singular fields can be written.
- (*variables)["oneof_prefix"] = "";
-
// These variables are placeholders to pick out the beginning and ends of
// identifiers for annotations (when doing so with existing variables would
// be ambiguous or impossible). They should never be set to anything but the
@@ -108,10 +97,8 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor,
std::map<string, string>* variables) {
const string prefix = descriptor->containing_oneof()->name() + "_.";
- (*variables)["oneof_prefix"] = prefix;
(*variables)["oneof_name"] = descriptor->containing_oneof()->name();
- (*variables)["non_null_ptr_to_name"] =
- StrCat(prefix, (*variables)["name"], "_");
+ (*variables)["field_member"] = StrCat(prefix, (*variables)["name"], "_");
}
FieldGenerator::~FieldGenerator() {}
diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h
index 891e30f6..bccfcb9a 100644
--- a/src/google/protobuf/compiler/cpp/cpp_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_field.h
@@ -184,6 +184,10 @@ class FieldGenerator {
// message's MergeFromCodedStream() method.
virtual void GenerateMergeFromCodedStream(io::Printer* printer) const = 0;
+ // Returns true if this field's "MergeFromCodedStream" code needs the arena
+ // to be defined as a variable.
+ virtual bool MergeFromCodedStreamNeedsArena() const { return false; }
+
// Generate lines to decode this field from a packed value, which will be
// placed inside the message's MergeFromCodedStream() method.
virtual void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer)
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc
index 52a16835..1f90ae43 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -397,7 +397,7 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) {
// Define default instances
GenerateSourceDefaultInstance(idx, printer);
- if (UsingImplicitWeakFields(file_, options_)) {
+ if (options_.lite_implicit_weak_fields) {
printer->Print("void $classname$_ReferenceStrong() {}\n", "classname",
message_generators_[idx]->classname_);
}
@@ -416,6 +416,13 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) {
GenerateInitForSCC(GetSCC(message_generators_[idx]->descriptor_), printer);
}
+
+ printer->Print(
+ "namespace google {\nnamespace protobuf {\n");
+ message_generators_[idx]->GenerateSourceInProto2Namespace(printer);
+ printer->Print(
+ "} // namespace protobuf\n} // namespace google\n");
+
printer->Print(
"\n"
"// @@protoc_insertion_point(global_scope)\n");
@@ -467,7 +474,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
// Define default instances
for (int i = 0; i < message_generators_.size(); i++) {
GenerateSourceDefaultInstance(i, printer);
- if (UsingImplicitWeakFields(file_, options_)) {
+ if (options_.lite_implicit_weak_fields) {
printer->Print("void $classname$_ReferenceStrong() {}\n", "classname",
message_generators_[i]->classname_);
}
@@ -525,6 +532,15 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
"\n"
"// @@protoc_insertion_point(namespace_scope)\n");
}
+
+ printer->Print(
+ "namespace google {\nnamespace protobuf {\n");
+ for (int i = 0; i < message_generators_.size(); i++) {
+ message_generators_[i]->GenerateSourceInProto2Namespace(printer);
+ }
+ printer->Print(
+ "} // namespace protobuf\n} // namespace google\n");
+
printer->Print(
"\n"
"// @@protoc_insertion_point(global_scope)\n");
@@ -553,7 +569,42 @@ class FileGenerator::ForwardDeclarations {
std::map<string, const Descriptor*>& classes() { return classes_; }
std::map<string, const EnumDescriptor*>& enums() { return enums_; }
- void Print(io::Printer* printer, const Options& options) const {
+ void PrintForwardDeclarations(io::Printer* printer,
+ const Options& options) const {
+ PrintNestedDeclarations(printer, options);
+ PrintTopLevelDeclarations(printer, options);
+ }
+
+
+ private:
+ void PrintNestedDeclarations(io::Printer* printer,
+ const Options& options) const {
+ PrintDeclarationsInsideNamespace(printer, options);
+ for (std::map<string, ForwardDeclarations *>::const_iterator
+ it = namespaces_.begin(),
+ end = namespaces_.end();
+ it != end; ++it) {
+ printer->Print("namespace $nsname$ {\n",
+ "nsname", it->first);
+ it->second->PrintNestedDeclarations(printer, options);
+ printer->Print("} // namespace $nsname$\n",
+ "nsname", it->first);
+ }
+ }
+
+ void PrintTopLevelDeclarations(io::Printer* printer,
+ const Options& options) const {
+ PrintDeclarationsOutsideNamespace(printer, options);
+ for (std::map<string, ForwardDeclarations *>::const_iterator
+ it = namespaces_.begin(),
+ end = namespaces_.end();
+ it != end; ++it) {
+ it->second->PrintTopLevelDeclarations(printer, options);
+ }
+ }
+
+ void PrintDeclarationsInsideNamespace(io::Printer* printer,
+ const Options& options) const {
for (std::map<string, const EnumDescriptor *>::const_iterator
it = enums_.begin(),
end = enums_.end();
@@ -584,20 +635,36 @@ class FileGenerator::ForwardDeclarations {
"classname", it->first);
}
}
- for (std::map<string, ForwardDeclarations *>::const_iterator
- it = namespaces_.begin(),
- end = namespaces_.end();
+ }
+
+ void PrintDeclarationsOutsideNamespace(io::Printer* printer,
+ const Options& options) const {
+ if (classes_.size() == 0) return;
+
+ printer->Print(
+ "namespace google {\nnamespace protobuf {\n");
+ for (std::map<string, const Descriptor*>::const_iterator
+ it = classes_.begin(),
+ end = classes_.end();
it != end; ++it) {
- printer->Print("namespace $nsname$ {\n",
- "nsname", it->first);
- it->second->Print(printer, options);
- printer->Print("} // namespace $nsname$\n",
- "nsname", it->first);
+ const Descriptor* d = it->second;
+ string extra_class_qualifier;
+ // "class" is to disambiguate in case there is also a function with this
+ // name. There is code out there that does this!
+ printer->Print(
+ "template<> "
+ "$dllexport_decl$"
+ "$class$$classname$* Arena::$func$< $class$$classname$>(Arena*);\n",
+ "classname", QualifiedClassName(d),
+ "func", MessageCreateFunction(d),
+ "class", extra_class_qualifier,
+ "dllexport_decl",
+ options.dllexport_decl.empty() ? "" : options.dllexport_decl + " ");
}
+ printer->Print(
+ "} // namespace protobuf\n} // namespace google\n");
}
-
- private:
std::map<string, ForwardDeclarations*> namespaces_;
std::map<string, const Descriptor*> classes_;
std::map<string, const EnumDescriptor*> enums_;
@@ -1053,7 +1120,7 @@ void FileGenerator::GenerateInitializationCode(io::Printer* printer) {
void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) {
ForwardDeclarations decls;
FillForwardDeclarations(&decls);
- decls.Print(printer, options_);
+ decls.PrintForwardDeclarations(printer, options_);
}
void FileGenerator::FillForwardDeclarations(ForwardDeclarations* decls) {
diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc
index e01e5dca..5d8ea300 100644
--- a/src/google/protobuf/compiler/cpp/cpp_generator.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc
@@ -41,12 +41,12 @@
#endif
#include <utility>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/cpp/cpp_file.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -85,7 +85,6 @@ bool CppGenerator::Generate(const FileDescriptor* file,
// __declspec(dllimport) depending on what is being compiled.
//
Options file_options;
- bool split_source = false;
for (int i = 0; i < options.size(); i++) {
if (options[i].first == "dllexport_decl") {
file_options.dllexport_decl = options[i].second;
@@ -101,18 +100,28 @@ bool CppGenerator::Generate(const FileDescriptor* file,
file_options.enforce_lite = true;
} else if (options[i].first == "lite_implicit_weak_fields") {
file_options.lite_implicit_weak_fields = true;
+ if (!options[i].second.empty()) {
+ file_options.num_cc_files = strto32(options[i].second.c_str(),
+ NULL, 10);
+ }
} else if (options[i].first == "table_driven_parsing") {
file_options.table_driven_parsing = true;
} else if (options[i].first == "table_driven_serialization") {
file_options.table_driven_serialization = true;
- } else if (options[i].first == "split_source") {
- split_source = true;
} else {
*error = "Unknown generator option: " + options[i].first;
return false;
}
}
+ // The safe_boundary_check option controls behavior for Google-internal
+ // protobuf APIs.
+ if (file_options.safe_boundary_check) {
+ *error =
+ "The safe_boundary_check option is not supported outside of Google.";
+ return false;
+ }
+
// -----------------------------------------------------------------
@@ -159,8 +168,8 @@ bool CppGenerator::Generate(const FileDescriptor* file,
}
}
- // Generate cc file.
- if (split_source) {
+ // Generate cc file(s).
+ if (UsingImplicitWeakFields(file, file_options)) {
{
// This is the global .cc file, containing enum/services/tables/reflection
google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(
@@ -168,12 +177,26 @@ bool CppGenerator::Generate(const FileDescriptor* file,
io::Printer printer(output.get(), '$');
file_generator.GenerateGlobalSource(&printer);
}
- for (int i = 0; i < file_generator.NumMessages(); i++) {
+
+ int num_cc_files = file_generator.NumMessages();
+
+ // If we're using implicit weak fields then we allow the user to optionally
+ // specify how many files to generate, not counting the global pb.cc file.
+ // If we have more files than messages, then some files will be generated as
+ // empty placeholders.
+ if (file_options.num_cc_files > 0) {
+ GOOGLE_CHECK_LE(file_generator.NumMessages(), file_options.num_cc_files)
+ << "There must be at least as many numbered .cc files as messages.";
+ num_cc_files = file_options.num_cc_files;
+ }
+ for (int i = 0; i < num_cc_files; i++) {
// TODO(gerbens) Agree on naming scheme.
google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(
generator_context->Open(basename + "." + SimpleItoa(i) + ".cc"));
io::Printer printer(output.get(), '$');
- file_generator.GenerateSourceForMessage(i, &printer);
+ if (i < file_generator.NumMessages()) {
+ file_generator.GenerateSourceForMessage(i, &printer);
+ }
}
} else {
google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc
index 96950e52..172acedd 100644
--- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc
@@ -752,7 +752,7 @@ bool UsingImplicitWeakFields(const FileDescriptor* file,
bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options) {
return UsingImplicitWeakFields(field->file(), options) &&
field->type() == FieldDescriptor::TYPE_MESSAGE &&
- !field->is_required() && !field->is_repeated() && !field->is_map() &&
+ !field->is_required() && !field->is_map() &&
field->containing_oneof() == NULL;
}
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h
index e0f809c9..4026d0ed 100644
--- a/src/google/protobuf/compiler/cpp/cpp_helpers.h
+++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h
@@ -310,6 +310,10 @@ inline bool IsCrossFileMessage(const FieldDescriptor* field) {
field->message_type()->file() != field->file();
}
+inline string MessageCreateFunction(const Descriptor* d) {
+ return SupportsArenas(d) ? "CreateMessage" : "Create";
+}
+
bool IsAnyMessage(const FileDescriptor* descriptor);
bool IsAnyMessage(const Descriptor* descriptor);
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc
index 60467598..8636f089 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -325,6 +325,109 @@ bool IsCrossFileMaybeMap(const FieldDescriptor* field) {
return IsCrossFileMessage(field);
}
+bool IsRequired(const std::vector<const FieldDescriptor*>& v) {
+ return v.front()->is_required();
+}
+
+// Allows chunking repeated fields together and non-repeated fields if the
+// fields share the same has_byte index.
+// TODO(seongkim): use lambda with capture instead of functor.
+class MatchRepeatedAndHasByte {
+ public:
+ MatchRepeatedAndHasByte(const std::vector<int>* has_bit_indices,
+ bool has_field_presence)
+ : has_bit_indices_(*has_bit_indices),
+ has_field_presence_(has_field_presence) {}
+
+ // Returns true if the following conditions are met:
+ // --both fields are repeated fields
+ // --both fields are non-repeated fields with either has_field_presence is
+ // false or have the same has_byte index.
+ bool operator()(const FieldDescriptor* a, const FieldDescriptor* b) const {
+ return a->is_repeated() == b->is_repeated() &&
+ (!has_field_presence_ || a->is_repeated() ||
+ has_bit_indices_[a->index()] / 8 ==
+ has_bit_indices_[b->index()] / 8);
+ }
+
+ private:
+ const std::vector<int>& has_bit_indices_;
+ const bool has_field_presence_;
+};
+
+// Allows chunking required fields separately after chunking with
+// MatchRepeatedAndHasByte.
+class MatchRepeatedAndHasByteAndRequired : public MatchRepeatedAndHasByte {
+ public:
+ MatchRepeatedAndHasByteAndRequired(const std::vector<int>* has_bit_indices,
+ bool has_field_presence)
+ : MatchRepeatedAndHasByte(has_bit_indices, has_field_presence) {}
+
+ bool operator()(const FieldDescriptor* a, const FieldDescriptor* b) const {
+ return MatchRepeatedAndHasByte::operator()(a, b) &&
+ a->is_required() == b->is_required();
+ }
+};
+
+// Allows chunking zero-initializable fields separately after chunking with
+// MatchRepeatedAndHasByte.
+class MatchRepeatedAndHasByteAndZeroInits : public MatchRepeatedAndHasByte {
+ public:
+ MatchRepeatedAndHasByteAndZeroInits(const std::vector<int>* has_bit_indices,
+ bool has_field_presence)
+ : MatchRepeatedAndHasByte(has_bit_indices, has_field_presence) {}
+
+ bool operator()(const FieldDescriptor* a, const FieldDescriptor* b) const {
+ return MatchRepeatedAndHasByte::operator()(a, b) &&
+ CanInitializeByZeroing(a) == CanInitializeByZeroing(b);
+ }
+};
+
+// Collects neighboring fields based on a given criteria (equivalent predicate).
+template <typename Predicate>
+std::vector<std::vector<const FieldDescriptor*> > CollectFields(
+ const std::vector<const FieldDescriptor*>& fields,
+ const Predicate& equivalent) {
+ std::vector<std::vector<const FieldDescriptor*> > chunks;
+ if (fields.empty()) {
+ return chunks;
+ }
+
+ const FieldDescriptor* last_field = fields.front();
+ std::vector<const FieldDescriptor*> chunk;
+ for (int i = 0; i < fields.size(); i++) {
+ if (!equivalent(last_field, fields[i]) && !chunk.empty()) {
+ chunks.push_back(chunk);
+ chunk.clear();
+ }
+ chunk.push_back(fields[i]);
+ last_field = fields[i];
+ }
+ if (!chunk.empty()) {
+ chunks.push_back(chunk);
+ }
+ return chunks;
+}
+
+// Returns a bit mask based on has_bit index of "fields" that are typically on
+// the same chunk. It is used in a group presence check where _has_bits_ is
+// masked to tell if any thing in "fields" is present.
+uint32 GenChunkMask(const std::vector<const FieldDescriptor*>& fields,
+ const std::vector<int>& has_bit_indices) {
+ GOOGLE_CHECK(!fields.empty());
+ int first_index_offset = has_bit_indices[fields.front()->index()] / 32;
+ uint32 chunk_mask = 0;
+ for (int i = 0; i < fields.size(); i++) {
+ const FieldDescriptor* field = fields[i];
+ // "index" defines where in the _has_bits_ the field appears.
+ int index = has_bit_indices[field->index()];
+ GOOGLE_CHECK_EQ(first_index_offset, index / 32);
+ chunk_mask |= static_cast<uint32>(1) << (index % 32);
+ }
+ GOOGLE_CHECK_NE(0, chunk_mask);
+ return chunk_mask;
+}
+
} // anonymous namespace
// ===================================================================
@@ -993,6 +1096,7 @@ GenerateClassDefinition(io::Printer* printer) {
vars["new_final"] = " PROTOBUF_FINAL";
+ vars["create_func"] = MessageCreateFunction(descriptor_);
printer->Print(vars,
"void Swap($classname$* other);\n"
"friend void swap($classname$& a, $classname$& b) {\n"
@@ -1001,9 +1105,13 @@ GenerateClassDefinition(io::Printer* printer) {
"\n"
"// implements Message ----------------------------------------------\n"
"\n"
- "inline $classname$* New() const$new_final$ { return New(NULL); }\n"
+ "inline $classname$* New() const$new_final$ {\n"
+ " return ::google::protobuf::Arena::$create_func$<$classname$>(NULL);\n"
+ "}\n"
"\n"
- "$classname$* New(::google::protobuf::Arena* arena) const$new_final$;\n");
+ "$classname$* New(::google::protobuf::Arena* arena) const$new_final$ {\n"
+ " return ::google::protobuf::Arena::$create_func$<$classname$>(arena);\n"
+ "}\n");
// For instances that derive from Message (rather than MessageLite), some
// methods are virtual and should be marked as final.
@@ -2452,112 +2560,125 @@ GenerateStructors(io::Printer* printer) {
}
// Generate the copy constructor.
- printer->Print(
- "$classname$::$classname$(const $classname$& from)\n"
- " : $superclass$()",
- "classname", classname_,
- "superclass", superclass,
- "full_name", descriptor_->full_name());
- printer->Indent();
- printer->Indent();
- printer->Indent();
+ if (UsingImplicitWeakFields(descriptor_->file(), options_)) {
+ // If we are in lite mode and using implicit weak fields, we generate a
+ // one-liner copy constructor that delegates to MergeFrom. This saves some
+ // code size and also cuts down on the complexity of implicit weak fields.
+ // We might eventually want to do this for all lite protos.
+ printer->Print(
+ "$classname$::$classname$(const $classname$& from)\n"
+ " : $classname$() {\n"
+ " MergeFrom(from);\n"
+ "}\n",
+ "classname", classname_);
+ } else {
+ printer->Print(
+ "$classname$::$classname$(const $classname$& from)\n"
+ " : $superclass$()",
+ "classname", classname_,
+ "superclass", superclass,
+ "full_name", descriptor_->full_name());
+ printer->Indent();
+ printer->Indent();
+ printer->Indent();
- printer->Print(
- ",\n_internal_metadata_(NULL)");
+ printer->Print(
+ ",\n_internal_metadata_(NULL)");
- if (HasFieldPresence(descriptor_->file())) {
- printer->Print(",\n_has_bits_(from._has_bits_)");
- }
+ if (HasFieldPresence(descriptor_->file())) {
+ printer->Print(",\n_has_bits_(from._has_bits_)");
+ }
- bool need_to_emit_cached_size = true;
- const string cached_size_decl = ",\n_cached_size_(0)";
- // We reproduce the logic used for laying out _cached_sized_ in the class
- // definition, as to initialize it in-order.
- if (HasFieldPresence(descriptor_->file()) &&
- (HasBitsSize() % 8) != 0) {
- printer->Print(cached_size_decl.c_str());
- need_to_emit_cached_size = false;
- }
+ bool need_to_emit_cached_size = true;
+ const string cached_size_decl = ",\n_cached_size_(0)";
+ // We reproduce the logic used for laying out _cached_sized_ in the class
+ // definition, as to initialize it in-order.
+ if (HasFieldPresence(descriptor_->file()) &&
+ (HasBitsSize() % 8) != 0) {
+ printer->Print(cached_size_decl.c_str());
+ need_to_emit_cached_size = false;
+ }
- std::vector<bool> processed(optimized_order_.size(), false);
- for (int i = 0; i < optimized_order_.size(); ++i) {
- const FieldDescriptor* field = optimized_order_[i];
+ std::vector<bool> processed(optimized_order_.size(), false);
+ for (int i = 0; i < optimized_order_.size(); ++i) {
+ const FieldDescriptor* field = optimized_order_[i];
- if (!(field->is_repeated() && !(field->is_map()))
- ) {
- continue;
- }
+ if (!(field->is_repeated() && !(field->is_map()))
+ ) {
+ continue;
+ }
- processed[i] = true;
- printer->Print(",\n$name$_(from.$name$_)",
- "name", FieldName(field));
- }
+ processed[i] = true;
+ printer->Print(",\n$name$_(from.$name$_)",
+ "name", FieldName(field));
+ }
- if (need_to_emit_cached_size) {
- printer->Print(cached_size_decl.c_str());
- need_to_emit_cached_size = false;
- }
+ if (need_to_emit_cached_size) {
+ printer->Print(cached_size_decl.c_str());
+ need_to_emit_cached_size = false;
+ }
- if (IsAnyMessage(descriptor_)) {
- printer->Print(",\n_any_metadata_(&type_url_, &value_)");
- }
- if (num_weak_fields_ > 0) {
- printer->Print(",\n_weak_field_map_(from._weak_field_map_)");
- }
+ if (IsAnyMessage(descriptor_)) {
+ printer->Print(",\n_any_metadata_(&type_url_, &value_)");
+ }
+ if (num_weak_fields_ > 0) {
+ printer->Print(",\n_weak_field_map_(from._weak_field_map_)");
+ }
- printer->Outdent();
- printer->Outdent();
- printer->Print(" {\n");
+ printer->Outdent();
+ printer->Outdent();
+ printer->Print(" {\n");
- printer->Print(
- "_internal_metadata_.MergeFrom(from._internal_metadata_);\n");
+ printer->Print(
+ "_internal_metadata_.MergeFrom(from._internal_metadata_);\n");
- if (descriptor_->extension_range_count() > 0) {
- printer->Print("_extensions_.MergeFrom(from._extensions_);\n");
- }
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print("_extensions_.MergeFrom(from._extensions_);\n");
+ }
- GenerateConstructorBody(printer, processed, true);
+ GenerateConstructorBody(printer, processed, true);
- // Copy oneof fields. Oneof field requires oneof case check.
- for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) {
- printer->Print(
- "clear_has_$oneofname$();\n"
- "switch (from.$oneofname$_case()) {\n",
- "oneofname", descriptor_->oneof_decl(i)->name());
- printer->Indent();
- for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
- const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
+ // Copy oneof fields. Oneof field requires oneof case check.
+ for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) {
printer->Print(
- "case k$field_name$: {\n",
- "field_name", UnderscoresToCamelCase(field->name(), true));
+ "clear_has_$oneofname$();\n"
+ "switch (from.$oneofname$_case()) {\n",
+ "oneofname", descriptor_->oneof_decl(i)->name());
printer->Indent();
- field_generators_.get(field).GenerateMergingCode(printer);
+ for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
+ const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
+ printer->Print(
+ "case k$field_name$: {\n",
+ "field_name", UnderscoresToCamelCase(field->name(), true));
+ printer->Indent();
+ field_generators_.get(field).GenerateMergingCode(printer);
+ printer->Print(
+ "break;\n");
+ printer->Outdent();
+ printer->Print(
+ "}\n");
+ }
printer->Print(
- "break;\n");
+ "case $cap_oneof_name$_NOT_SET: {\n"
+ " break;\n"
+ "}\n",
+ "oneof_index",
+ SimpleItoa(descriptor_->oneof_decl(i)->index()),
+ "cap_oneof_name",
+ ToUpper(descriptor_->oneof_decl(i)->name()));
printer->Outdent();
printer->Print(
"}\n");
}
- printer->Print(
- "case $cap_oneof_name$_NOT_SET: {\n"
- " break;\n"
- "}\n",
- "oneof_index",
- SimpleItoa(descriptor_->oneof_decl(i)->index()),
- "cap_oneof_name",
- ToUpper(descriptor_->oneof_decl(i)->name()));
+
printer->Outdent();
printer->Print(
- "}\n");
+ " // @@protoc_insertion_point(copy_constructor:$full_name$)\n"
+ "}\n"
+ "\n",
+ "full_name", descriptor_->full_name());
}
- printer->Outdent();
- printer->Print(
- " // @@protoc_insertion_point(copy_constructor:$full_name$)\n"
- "}\n"
- "\n",
- "full_name", descriptor_->full_name());
-
// Generate the shared constructor code.
GenerateSharedConstructorCode(printer);
@@ -2610,24 +2731,17 @@ GenerateStructors(io::Printer* printer) {
"}\n\n",
"classname", classname_, "scc_name", scc_name_, "file_namespace",
FileLevelNamespace(descriptor_));
+}
- if (SupportsArenas(descriptor_)) {
- printer->Print(
- "$classname$* $classname$::New(::google::protobuf::Arena* arena) const {\n"
- " return ::google::protobuf::Arena::CreateMessage<$classname$>(arena);\n"
- "}\n",
- "classname", classname_);
- } else {
- printer->Print(
- "$classname$* $classname$::New(::google::protobuf::Arena* arena) const {\n"
- " $classname$* n = new $classname$;\n"
- " if (arena != NULL) {\n"
- " arena->Own(n);\n"
- " }\n"
- " return n;\n"
+void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) {
+ printer->Print(
+ "template<> "
+ "GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE "
+ "$classname$* Arena::$create_func$< $classname$ >(Arena* arena) {\n"
+ " return Arena::$create_func$Internal< $classname$ >(arena);\n"
"}\n",
- "classname", classname_);
- }
+ "classname", QualifiedClassName(descriptor_),
+ "create_func", MessageCreateFunction(descriptor_));
}
// Return the number of bits set in n, a non-negative integer.
@@ -2681,7 +2795,6 @@ GenerateClear(io::Printer* printer) {
printer->Print("_extensions_.Clear();\n");
}
- int last_i = -1;
int unconditional_budget = kMaxUnconditionalPrimitiveBytesClear;
for (int i = 0; i < optimized_order_.size(); i++) {
const FieldDescriptor* field = optimized_order_[i];
@@ -2693,197 +2806,162 @@ GenerateClear(io::Printer* printer) {
unconditional_budget -= EstimateAlignmentSize(field);
}
- for (int i = 0; i < optimized_order_.size(); ) {
- // Detect infinite loops.
- GOOGLE_CHECK_NE(i, last_i);
- last_i = i;
+ std::vector<std::vector<const FieldDescriptor*> > chunks_frag = CollectFields(
+ optimized_order_,
+ MatchRepeatedAndHasByteAndZeroInits(
+ &has_bit_indices_, HasFieldPresence(descriptor_->file())));
+
+ // Merge next non-zero initializable chunk if it has the same has_byte index
+ // and not meeting unconditional clear condition.
+ std::vector<std::vector<const FieldDescriptor*> > chunks;
+ if (!HasFieldPresence(descriptor_->file())) {
+ // Don't bother with merging without has_bit field.
+ chunks = chunks_frag;
+ } else {
+ // Note that only the next chunk is considered for merging.
+ for (int i = 0; i < chunks_frag.size(); i++) {
+ chunks.push_back(chunks_frag[i]);
+ const FieldDescriptor* field = chunks_frag[i].front();
+ const FieldDescriptor* next_field =
+ (i + 1) < chunks_frag.size() ? chunks_frag[i + 1].front() : NULL;
+ if (CanInitializeByZeroing(field) &&
+ (chunks_frag[i].size() == 1 || unconditional_budget < 0) &&
+ next_field != NULL &&
+ has_bit_indices_[field->index()] / 8 ==
+ has_bit_indices_[next_field->index()] / 8) {
+ GOOGLE_CHECK(!CanInitializeByZeroing(next_field));
+ // Insert next chunk to the current one and skip next chunk.
+ chunks.back().insert(chunks.back().end(), chunks_frag[i + 1].begin(),
+ chunks_frag[i + 1].end());
+ i++;
+ }
+ }
+ }
+
+ for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) {
+ std::vector<const FieldDescriptor*>& chunk = chunks[chunk_index];
+ GOOGLE_CHECK(!chunk.empty());
// Step 2: Repeated fields don't use _has_bits_; emit code to clear them
// here.
- for (; i < optimized_order_.size(); i++) {
- const FieldDescriptor* field = optimized_order_[i];
- const FieldGenerator& generator = field_generators_.get(field);
+ if (chunk.front()->is_repeated()) {
+ for (int i = 0; i < chunk.size(); i++) {
+ const FieldDescriptor* field = chunk[i];
+ const FieldGenerator& generator = field_generators_.get(field);
- if (!field->is_repeated()) {
- break;
+ generator.GenerateMessageClearingCode(printer);
}
-
- generator.GenerateMessageClearingCode(printer);
+ continue;
}
- // Step 3: Greedily seek runs of fields that can be cleared by
- // memset-to-0.
- int last_chunk = -1;
- int last_chunk_start = -1;
- int last_chunk_end = -1;
- uint32 last_chunk_mask = 0;
-
+ // Step 3: Non-repeated fields that can be cleared by memset-to-0, then
+ // non-repeated, non-zero initializable fields.
+ int last_chunk = HasFieldPresence(descriptor_->file())
+ ? has_bit_indices_[chunk.front()->index()] / 8
+ : 0;
+ int last_chunk_start = 0;
int memset_run_start = -1;
int memset_run_end = -1;
- for (; i < optimized_order_.size(); i++) {
- const FieldDescriptor* field = optimized_order_[i];
-
- if (!CanInitializeByZeroing(field)) {
- break;
- }
-
- // "index" defines where in the _has_bits_ the field appears.
- // "i" is our loop counter within optimized_order_.
- int index = HasFieldPresence(descriptor_->file()) ?
- has_bit_indices_[field->index()] : 0;
- int chunk = index / 8;
-
- if (last_chunk == -1) {
- last_chunk = chunk;
- last_chunk_start = i;
- } else if (chunk != last_chunk) {
- // Emit the fields for this chunk so far.
- break;
- }
- if (memset_run_start == -1) {
- memset_run_start = i;
+ for (int i = 0; i < chunk.size(); i++) {
+ const FieldDescriptor* field = chunk[i];
+ if (CanInitializeByZeroing(field)) {
+ if (memset_run_start == -1) {
+ memset_run_start = i;
+ }
+ memset_run_end = i;
}
-
- memset_run_end = i;
- last_chunk_end = i;
- last_chunk_mask |= static_cast<uint32>(1) << (index % 32);
}
- if (memset_run_start != memset_run_end && unconditional_budget >= 0) {
- // Flush the memset fields.
- goto flush;
- }
+ const bool have_outer_if =
+ HasFieldPresence(descriptor_->file()) && chunk.size() > 1 &&
+ (memset_run_end != chunk.size() - 1 || unconditional_budget < 0);
- // Step 4: Non-repeated, non-zero initializable fields.
- for (; i < optimized_order_.size(); i++) {
- const FieldDescriptor* field = optimized_order_[i];
- if (field->is_repeated() || CanInitializeByZeroing(field)) {
- break;
- }
+ if (have_outer_if) {
+ uint32 last_chunk_mask = GenChunkMask(chunk, has_bit_indices_);
+ const int count = popcnt(last_chunk_mask);
- // "index" defines where in the _has_bits_ the field appears.
- // "i" is our loop counter within optimized_order_.
- int index = HasFieldPresence(descriptor_->file()) ?
- has_bit_indices_[field->index()] : 0;
- int chunk = index / 8;
+ // Check (up to) 8 has_bits at a time if we have more than one field in
+ // this chunk. Due to field layout ordering, we may check
+ // _has_bits_[last_chunk * 8 / 32] multiple times.
+ GOOGLE_DCHECK_LE(2, count);
+ GOOGLE_DCHECK_GE(8, count);
- if (last_chunk == -1) {
- last_chunk = chunk;
- last_chunk_start = i;
- } else if (chunk != last_chunk) {
- // Emit the fields for this chunk so far.
- break;
+ if (cached_has_bit_index != last_chunk / 4) {
+ cached_has_bit_index = last_chunk / 4;
+ printer->Print("cached_has_bits = _has_bits_[$idx$];\n", "idx",
+ SimpleItoa(cached_has_bit_index));
}
-
- last_chunk_end = i;
- last_chunk_mask |= static_cast<uint32>(1) << (index % 32);
+ printer->Print("if (cached_has_bits & $mask$u) {\n", "mask",
+ SimpleItoa(last_chunk_mask));
+ printer->Indent();
}
-flush:
-
- if (last_chunk != -1) {
- GOOGLE_DCHECK_NE(-1, last_chunk_start);
- GOOGLE_DCHECK_NE(-1, last_chunk_end);
- GOOGLE_DCHECK_NE(0, last_chunk_mask);
-
- const int count = popcnt(last_chunk_mask);
- const bool have_outer_if = HasFieldPresence(descriptor_->file()) &&
- (last_chunk_start != last_chunk_end) &&
- (memset_run_start != last_chunk_start ||
- memset_run_end != last_chunk_end ||
- unconditional_budget < 0);
-
- if (have_outer_if) {
- // Check (up to) 8 has_bits at a time if we have more than one field in
- // this chunk. Due to field layout ordering, we may check
- // _has_bits_[last_chunk * 8 / 32] multiple times.
- GOOGLE_DCHECK_LE(2, count);
- GOOGLE_DCHECK_GE(8, count);
+ if (memset_run_start != -1) {
+ if (memset_run_start == memset_run_end) {
+ // For clarity, do not memset a single field.
+ const FieldGenerator& generator =
+ field_generators_.get(chunk[memset_run_start]);
+ generator.GenerateMessageClearingCode(printer);
+ } else {
+ const string first_field_name = FieldName(chunk[memset_run_start]);
+ const string last_field_name = FieldName(chunk[memset_run_end]);
- if (cached_has_bit_index != last_chunk / 4) {
- cached_has_bit_index = last_chunk / 4;
- printer->Print(
- "cached_has_bits = _has_bits_[$idx$];\n",
- "idx", SimpleItoa(cached_has_bit_index));
- }
printer->Print(
- "if (cached_has_bits & $mask$u) {\n",
- "mask", SimpleItoa(last_chunk_mask));
- printer->Indent();
- }
-
- if (memset_run_start != -1) {
- if (memset_run_start == memset_run_end) {
- // For clarity, do not memset a single field.
- const FieldGenerator& generator =
- field_generators_.get(optimized_order_[memset_run_start]);
- generator.GenerateMessageClearingCode(printer);
- } else {
- const string first_field_name =
- FieldName(optimized_order_[memset_run_start]);
- const string last_field_name =
- FieldName(optimized_order_[memset_run_end]);
-
- printer->Print(
"::memset(&$first$_, 0, static_cast<size_t>(\n"
" reinterpret_cast<char*>(&$last$_) -\n"
" reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n",
- "first", first_field_name,
- "last", last_field_name);
- }
-
- // Advance last_chunk_start to skip over the fields we zeroed/memset.
- last_chunk_start = memset_run_end + 1;
+ "first", first_field_name, "last", last_field_name);
}
- // Go back and emit clears for each of the fields we processed.
- for (int j = last_chunk_start; j <= last_chunk_end; j++) {
- const FieldDescriptor* field = optimized_order_[j];
- const string fieldname = FieldName(field);
- const FieldGenerator& generator = field_generators_.get(field);
+ // Advance last_chunk_start to skip over the fields we zeroed/memset.
+ last_chunk_start = memset_run_end + 1;
+ }
+
+ // Go back and emit clears for each of the fields we processed.
+ for (int j = last_chunk_start; j < chunk.size(); j++) {
+ const FieldDescriptor* field = chunk[j];
+ const string fieldname = FieldName(field);
+ const FieldGenerator& generator = field_generators_.get(field);
- // It's faster to just overwrite primitive types, but we should only
- // clear strings and messages if they were set.
- //
- // TODO(kenton): Let the CppFieldGenerator decide this somehow.
- bool should_check_bit =
+ // It's faster to just overwrite primitive types, but we should only
+ // clear strings and messages if they were set.
+ //
+ // TODO(kenton): Let the CppFieldGenerator decide this somehow.
+ bool should_check_bit =
field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||
field->cpp_type() == FieldDescriptor::CPPTYPE_STRING;
- bool have_enclosing_if = false;
- if (should_check_bit &&
- // If no field presence, then always clear strings/messages as well.
- HasFieldPresence(descriptor_->file())) {
- if (!field->options().weak() &&
- cached_has_bit_index != (has_bit_indices_[field->index()] / 32)) {
- cached_has_bit_index = (has_bit_indices_[field->index()] / 32);
- printer->Print("cached_has_bits = _has_bits_[$new_index$];\n",
- "new_index", SimpleItoa(cached_has_bit_index));
- }
- if (!MaybeGenerateOptionalFieldCondition(printer, field,
- cached_has_bit_index)) {
- printer->Print(
- "if (has_$name$()) {\n",
- "name", fieldname);
- }
- printer->Indent();
- have_enclosing_if = true;
+ bool have_enclosing_if = false;
+ if (should_check_bit &&
+ // If no field presence, then always clear strings/messages as well.
+ HasFieldPresence(descriptor_->file())) {
+ if (!field->options().weak() &&
+ cached_has_bit_index != (has_bit_indices_[field->index()] / 32)) {
+ cached_has_bit_index = (has_bit_indices_[field->index()] / 32);
+ printer->Print("cached_has_bits = _has_bits_[$new_index$];\n",
+ "new_index", SimpleItoa(cached_has_bit_index));
}
-
- generator.GenerateMessageClearingCode(printer);
-
- if (have_enclosing_if) {
- printer->Outdent();
- printer->Print("}\n");
+ if (!MaybeGenerateOptionalFieldCondition(printer, field,
+ cached_has_bit_index)) {
+ printer->Print("if (has_$name$()) {\n", "name", fieldname);
}
+ printer->Indent();
+ have_enclosing_if = true;
}
- if (have_outer_if) {
+ generator.GenerateMessageClearingCode(printer);
+
+ if (have_enclosing_if) {
printer->Outdent();
printer->Print("}\n");
}
}
+
+ if (have_outer_if) {
+ printer->Outdent();
+ printer->Print("}\n");
+ }
}
// Step 4: Unions.
@@ -3349,7 +3427,6 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
"}\n");
return;
}
-
std::vector<const FieldDescriptor*> ordered_fields =
SortFieldsByNumber(descriptor_);
@@ -3379,9 +3456,22 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
return;
}
+ if (SupportsArenas(descriptor_)) {
+ for (int i = 0; i < ordered_fields.size(); i++) {
+ const FieldDescriptor* field = ordered_fields[i];
+ const FieldGenerator& field_generator = field_generators_.get(field);
+ if (field_generator.MergeFromCodedStreamNeedsArena()) {
+ printer->Print(
+ " ::google::protobuf::Arena* arena = GetArenaNoVirtual();\n");
+ break;
+ }
+ }
+ }
+
printer->Print(
- "#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n"
- " ::google::protobuf::uint32 tag;\n");
+ "#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto "
+ "failure\n"
+ " ::google::protobuf::uint32 tag;\n");
if (!UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(
@@ -4141,28 +4231,30 @@ GenerateByteSize(io::Printer* printer) {
}
}
- int last_i = -1;
- for (int i = 0; i < optimized_order_.size(); ) {
- // Detect infinite loops.
- GOOGLE_CHECK_NE(i, last_i);
- last_i = i;
+ std::vector<std::vector<const FieldDescriptor*> > chunks = CollectFields(
+ optimized_order_,
+ MatchRepeatedAndHasByteAndRequired(
+ &has_bit_indices_, HasFieldPresence(descriptor_->file())));
- // Skip required fields.
- for (; i < optimized_order_.size() &&
- optimized_order_[i]->is_required(); i++) {
- }
+ // Remove chunks with required fields.
+ chunks.erase(std::remove_if(chunks.begin(), chunks.end(), IsRequired),
+ chunks.end());
+
+ for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) {
+ const std::vector<const FieldDescriptor*>& chunk = chunks[chunk_index];
+ GOOGLE_CHECK(!chunk.empty());
// Handle repeated fields.
- for (; i < optimized_order_.size(); i++) {
- const FieldDescriptor* field = optimized_order_[i];
- if (!field->is_repeated()) {
- break;
- }
+ if (chunk.front()->is_repeated()) {
+ for (int i = 0; i < chunk.size(); i++) {
+ const FieldDescriptor* field = chunk[i];
- PrintFieldComment(printer, field);
- const FieldGenerator& generator = field_generators_.get(field);
- generator.GenerateByteSize(printer);
- printer->Print("\n");
+ PrintFieldComment(printer, field);
+ const FieldGenerator& generator = field_generators_.get(field);
+ generator.GenerateByteSize(printer);
+ printer->Print("\n");
+ }
+ continue;
}
// Handle optional (non-repeated/oneof) fields.
@@ -4174,92 +4266,62 @@ GenerateByteSize(io::Printer* printer) {
// descriptor_->field(8), descriptor_->field(9), ...
// descriptor_->field(15),
// etc.
- int last_chunk = -1;
- int last_chunk_start = -1;
- int last_chunk_end = -1;
- uint32 last_chunk_mask = 0;
- for (; i < optimized_order_.size(); i++) {
- const FieldDescriptor* field = optimized_order_[i];
- if (field->is_repeated() || field->is_required()) {
- break;
- }
+ int last_chunk = HasFieldPresence(descriptor_->file())
+ ? has_bit_indices_[chunk.front()->index()] / 8
+ : 0;
+ GOOGLE_DCHECK_NE(-1, last_chunk);
- // "index" defines where in the _has_bits_ the field appears.
- // "i" is our loop counter within optimized_order_.
- int index = HasFieldPresence(descriptor_->file()) ?
- has_bit_indices_[field->index()] : 0;
- int chunk = index / 8;
+ const bool have_outer_if =
+ HasFieldPresence(descriptor_->file()) && chunk.size() > 1;
- if (last_chunk == -1) {
- last_chunk = chunk;
- last_chunk_start = i;
- } else if (chunk != last_chunk) {
- // Emit the fields for this chunk so far.
- break;
- }
+ if (have_outer_if) {
+ uint32 last_chunk_mask = GenChunkMask(chunk, has_bit_indices_);
+ const int count = popcnt(last_chunk_mask);
- last_chunk_end = i;
- last_chunk_mask |= static_cast<uint32>(1) << (index % 32);
- }
+ // Check (up to) 8 has_bits at a time if we have more than one field in
+ // this chunk. Due to field layout ordering, we may check
+ // _has_bits_[last_chunk * 8 / 32] multiple times.
+ GOOGLE_DCHECK_LE(2, count);
+ GOOGLE_DCHECK_GE(8, count);
- if (last_chunk != -1) {
- GOOGLE_DCHECK_NE(-1, last_chunk_start);
- GOOGLE_DCHECK_NE(-1, last_chunk_end);
- GOOGLE_DCHECK_NE(0, last_chunk_mask);
+ printer->Print("if (_has_bits_[$index$ / 32] & $mask$u) {\n", "index",
+ SimpleItoa(last_chunk * 8), "mask",
+ SimpleItoa(last_chunk_mask));
+ printer->Indent();
+ }
- const int count = popcnt(last_chunk_mask);
- const bool have_outer_if = HasFieldPresence(descriptor_->file()) &&
- (last_chunk_start != last_chunk_end);
+ // Go back and emit checks for each of the fields we processed.
+ for (int j = 0; j < chunk.size(); j++) {
+ const FieldDescriptor* field = chunk[j];
+ const FieldGenerator& generator = field_generators_.get(field);
- if (have_outer_if) {
- // Check (up to) 8 has_bits at a time if we have more than one field in
- // this chunk. Due to field layout ordering, we may check
- // _has_bits_[last_chunk * 8 / 32] multiple times.
- GOOGLE_DCHECK_LE(2, count);
- GOOGLE_DCHECK_GE(8, count);
+ PrintFieldComment(printer, field);
- printer->Print(
- "if (_has_bits_[$index$ / 32] & $mask$u) {\n",
- "index", SimpleItoa(last_chunk * 8),
- "mask", SimpleItoa(last_chunk_mask));
+ bool have_enclosing_if = false;
+ if (HasFieldPresence(descriptor_->file())) {
+ printer->Print("if (has_$name$()) {\n", "name", FieldName(field));
printer->Indent();
+ have_enclosing_if = true;
+ } else {
+ // Without field presence: field is serialized only if it has a
+ // non-default value.
+ have_enclosing_if =
+ EmitFieldNonDefaultCondition(printer, "this->", field);
}
- // Go back and emit checks for each of the fields we processed.
- for (int j = last_chunk_start; j <= last_chunk_end; j++) {
- const FieldDescriptor* field = optimized_order_[j];
- const FieldGenerator& generator = field_generators_.get(field);
-
- PrintFieldComment(printer, field);
-
- bool have_enclosing_if = false;
- if (HasFieldPresence(descriptor_->file())) {
- printer->Print(
- "if (has_$name$()) {\n",
- "name", FieldName(field));
- printer->Indent();
- have_enclosing_if = true;
- } else {
- // Without field presence: field is serialized only if it has a
- // non-default value.
- have_enclosing_if = EmitFieldNonDefaultCondition(
- printer, "this->", field);
- }
-
- generator.GenerateByteSize(printer);
+ generator.GenerateByteSize(printer);
- if (have_enclosing_if) {
- printer->Outdent();
- printer->Print(
+ if (have_enclosing_if) {
+ printer->Outdent();
+ printer->Print(
"}\n"
"\n");
- }
}
+ }
- if (have_outer_if) {
- printer->Outdent();
- printer->Print("}\n");
- }
+ if (have_outer_if) {
+ printer->Outdent();
+ printer->Print("}\n");
}
}
@@ -4359,10 +4421,17 @@ GenerateIsInitialized(io::Printer* printer) {
!ShouldIgnoreRequiredFieldCheck(field, options_) &&
scc_analyzer_->HasRequiredFields(field->message_type())) {
if (field->is_repeated()) {
- printer->Print(
- "if (!::google::protobuf::internal::AllAreInitialized(this->$name$()))"
- " return false;\n",
- "name", FieldName(field));
+ if (IsImplicitWeakField(field, options_)) {
+ printer->Print(
+ "if (!::google::protobuf::internal::AllAreInitializedWeak(this->$name$_))"
+ " return false;\n",
+ "name", FieldName(field));
+ } else {
+ printer->Print(
+ "if (!::google::protobuf::internal::AllAreInitialized(this->$name$()))"
+ " return false;\n",
+ "name", FieldName(field));
+ }
} else if (field->options().weak()) {
continue;
} else {
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h
index 0387f0ca..06e2030b 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.h
+++ b/src/google/protobuf/compiler/cpp/cpp_message.h
@@ -106,6 +106,9 @@ class MessageGenerator {
// Generate all non-inline methods for this class.
void GenerateClassMethods(io::Printer* printer);
+ // Generate source file code that should go outside any namespace.
+ void GenerateSourceInProto2Namespace(io::Printer* printer);
+
private:
// Generate declarations and definitions of accessors for fields.
void GenerateDependentBaseClassDefinition(io::Printer* printer);
diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc
index fe60a283..530a6392 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc
@@ -80,11 +80,9 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
(*variables)["type_default_instance"] =
DefaultInstanceName(descriptor->message_type());
(*variables)["type_reference_function"] =
- ReferenceFunctionName(descriptor->message_type());
- if (descriptor->options().weak() || !descriptor->containing_oneof()) {
- (*variables)["non_null_ptr_to_name"] =
- StrCat("this->", (*variables)["name"], "_");
- }
+ IsImplicitWeakField(descriptor, options)
+ ? (" " + ReferenceFunctionName(descriptor->message_type()) + "();\n")
+ : "";
(*variables)["stream_writer"] =
(*variables)["declared_type"] +
(HasFastArraySerialization(descriptor->message_type()->file(), options)
@@ -96,14 +94,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
SafeFunctionName(descriptor->containing_type(),
descriptor, "release_");
(*variables)["full_name"] = descriptor->full_name();
- if (options.proto_h && IsFieldDependent(descriptor)) {
- (*variables)["dependent_type"] = "T::" + DependentTypeName(descriptor);
- (*variables)["dependent_typename"] =
- "typename T::" + DependentTypeName(descriptor);
- } else {
- (*variables)["dependent_type"] = FieldMessageTypeName(descriptor);
- (*variables)["dependent_typename"] = FieldMessageTypeName(descriptor);
- }
+ (*variables)["create_func"] =
+ MessageCreateFunction(descriptor->message_type());
}
} // namespace
@@ -114,7 +106,6 @@ MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor,
const Options& options)
: FieldGenerator(options),
descriptor_(descriptor),
- dependent_field_(options.proto_h && IsFieldDependent(descriptor)),
implicit_weak_field_(IsImplicitWeakField(descriptor, options)) {
SetMessageVariables(descriptor, &variables_, options);
}
@@ -131,23 +122,7 @@ GeneratePrivateMembers(io::Printer* printer) const {
}
void MessageFieldGenerator::
-GenerateDependentAccessorDeclarations(io::Printer* printer) const {
- if (!dependent_field_) {
- return;
- }
- printer->Print(variables_,
- "$deprecated_attr$$type$* ${$mutable_$name$$}$();\n");
- printer->Annotate("{", "}", descriptor_);
-}
-
-void MessageFieldGenerator::
GenerateAccessorDeclarations(io::Printer* printer) const {
- if (SupportsArenas(descriptor_) && !implicit_weak_field_) {
- printer->Print(variables_,
- "private:\n"
- "void _slow_mutable_$name$();\n"
- "public:\n");
- }
if (implicit_weak_field_) {
// These private accessors are used by MergeFrom and
// MergePartialFromCodedStream, and their purpose is to provide access to
@@ -163,11 +138,9 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
printer->Annotate("name", descriptor_);
printer->Print(variables_, "$deprecated_attr$$type$* $release_name$();\n");
printer->Annotate("release_name", descriptor_);
- if (!dependent_field_) {
- printer->Print(variables_,
- "$deprecated_attr$$type$* ${$mutable_$name$$}$();\n");
- printer->Annotate("{", "}", descriptor_);
- }
+ printer->Print(variables_,
+ "$deprecated_attr$$type$* ${$mutable_$name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
printer->Print(variables_,
"$deprecated_attr$void ${$set_allocated_$name$$}$"
"($type$* $name$);\n");
@@ -216,22 +189,9 @@ void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions(
" &$type_default_instance$)->New(GetArenaNoVirtual());\n"
" }\n"
" }\n"
- " return $name$_;\n");
- } else {
- printer->Print(variables_,
- "void $classname$::_slow_mutable_$name$() {\n");
- if (SupportsArenas(descriptor_->message_type())) {
- printer->Print(variables_,
- " $name$_ = ::google::protobuf::Arena::CreateMessage< $type$ >(\n"
- " GetArenaNoVirtual());\n");
- } else {
- printer->Print(variables_,
- " $name$_ = ::google::protobuf::Arena::Create< $type$ >(\n"
- " GetArenaNoVirtual());\n");
- }
+ " return $name$_;\n"
+ "}\n");
}
- printer->Print(variables_,
- "}\n");
printer->Print(variables_,
"void $classname$::unsafe_arena_set_allocated_$name$(\n"
@@ -268,118 +228,38 @@ void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions(
}
void MessageFieldGenerator::
-GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {
- if (!dependent_field_) {
- return;
- }
-
- std::map<string, string> variables(variables_);
- // For the CRTP base class, all mutation methods are dependent, and so
- // they must be in the header.
- variables["dependent_classname"] =
- DependentBaseClassTemplateName(descriptor_->containing_type()) + "<T>";
- variables["this_message"] = DependentBaseDownCast();
- variables["casted_reference"] =
- ReinterpretCast(variables["dependent_typename"] + "*&",
- variables["this_message"] + variables["name"] + "_",
- implicit_weak_field_);
- if (!variables["set_hasbit"].empty()) {
- variables["set_hasbit"] =
- variables["this_message"] + variables["set_hasbit"];
- }
- if (!variables["clear_hasbit"].empty()) {
- variables["clear_hasbit"] =
- variables["this_message"] + variables["clear_hasbit"];
- }
-
- if (SupportsArenas(descriptor_)) {
- printer->Print(variables,
- "template <class T>\n"
- "inline $type$* $dependent_classname$::mutable_$name$() {\n");
- if (implicit_weak_field_) {
- printer->Print(variables, " $type_reference_function$();\n");
- }
- printer->Print(variables,
- " $set_hasbit$\n"
- " $dependent_typename$*& $name$_ = $casted_reference$;\n"
- " if ($name$_ == NULL) {\n");
- if (implicit_weak_field_) {
- printer->Print(variables,
- " $name$_ = reinterpret_cast<$dependent_typename$*>(\n"
- " reinterpret_cast<const google::protobuf::MessageLite*>(\n"
- " &$type_default_instance$)->New(\n"
- " $this_message$GetArenaNoVirtual()));\n");
- } else {
- printer->Print(variables,
- " $this_message$_slow_mutable_$name$();\n");
- }
- printer->Print(variables,
- " }\n"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $name$_;\n"
- "}\n");
- } else {
- printer->Print(variables,
- "template <class T>\n"
- "inline $type$* $dependent_classname$::mutable_$name$() {\n"
- " $set_hasbit$\n"
- " $dependent_typename$*& $name$_ = $casted_reference$;\n"
- " if ($name$_ == NULL) {\n"
- " $name$_ = new $dependent_typename$;\n"
- " }\n"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $name$_;\n"
- "}\n");
- }
-}
-
-void MessageFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
- std::map<string, string> variables(variables_);
- variables["const_member"] = ReinterpretCast(
- "const " + variables["type"] + "*", variables["name"] + "_",
- implicit_weak_field_);
- printer->Print(variables,
- "inline const $type$& $classname$::$name$() const {\n");
- if (implicit_weak_field_) {
- printer->Print(variables, " $type_reference_function$();\n");
- }
- printer->Print(variables,
- " const $type$* p = $const_member$;\n"
+ printer->Print(variables_,
+ "inline const $type$& $classname$::$name$() const {\n"
+ "$type_reference_function$"
+ " const $type$* p = $casted_member$;\n"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
" return p != NULL ? *p : *reinterpret_cast<const $type$*>(\n"
" &$type_default_instance$);\n"
"}\n");
- printer->Print(variables,
+ printer->Print(variables_,
"inline $type$* $classname$::$release_name$() {\n"
- " // @@protoc_insertion_point(field_release:$full_name$)\n");
- if (implicit_weak_field_) {
- printer->Print(variables, " $type_reference_function$();\n");
- }
- printer->Print(variables,
+ " // @@protoc_insertion_point(field_release:$full_name$)\n"
+ "$type_reference_function$"
" $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n");
if (SupportsArenas(descriptor_)) {
- printer->Print(variables,
+ printer->Print(variables_,
" if (GetArenaNoVirtual() != NULL) {\n"
" temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL);\n"
" }\n");
}
- printer->Print(variables,
+ printer->Print(variables_,
" $name$_ = NULL;\n"
" return temp;\n"
"}\n");
if (SupportsArenas(descriptor_)) {
- printer->Print(variables,
+ printer->Print(variables_,
"inline $type$* $classname$::unsafe_arena_release_$name$() {\n"
- " // @@protoc_insertion_point("
- "field_unsafe_arena_release:$full_name$)\n");
- if (implicit_weak_field_) {
- printer->Print(variables, " $type_reference_function$();\n");
- }
- printer->Print(variables,
+ " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n"
+ "$type_reference_function$"
" $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n"
" $name$_ = NULL;\n"
@@ -387,71 +267,58 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
"}\n");
}
- if (!dependent_field_) {
- if (SupportsArenas(descriptor_)) {
- printer->Print(variables,
- "inline $type$* $classname$::mutable_$name$() {\n"
- " $set_hasbit$\n"
- " if ($name$_ == NULL) {\n");
- if (implicit_weak_field_) {
- printer->Print(variables,
- " _internal_mutable_$name$();\n");
- } else {
- printer->Print(variables,
- " _slow_mutable_$name$();\n");
- }
- printer->Print(variables,
- " }\n"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $casted_member$;\n"
- "}\n");
- } else {
- printer->Print(variables,
- "inline $type$* $classname$::mutable_$name$() {\n"
- " $set_hasbit$\n"
- " if ($name$_ == NULL) {\n"
- " $name$_ = new $type$;\n"
- " }\n"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $casted_member$;\n"
- "}\n");
- }
+ printer->Print(variables_,
+ "inline $type$* $classname$::mutable_$name$() {\n"
+ "$type_reference_function$"
+ " $set_hasbit$\n"
+ " if ($name$_ == NULL) {\n");
+ if (implicit_weak_field_) {
+ printer->Print(variables_,
+ " _internal_mutable_$name$();\n");
+ } else {
+ printer->Print(variables_,
+ " $name$_ = ::google::protobuf::Arena::$create_func$< $type$ >(\n"
+ " GetArenaNoVirtual());\n");
}
-
+ printer->Print(variables_,
+ " }\n"
+ " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
+ " return $casted_member$;\n"
+ "}\n");
// We handle the most common case inline, and delegate less common cases to
// the slow fallback function.
- printer->Print(variables,
+ printer->Print(variables_,
"inline void $classname$::set_allocated_$name$($type$* $name$) {\n"
" ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();\n");
- printer->Print(variables,
+ printer->Print(variables_,
" if (message_arena == NULL) {\n");
if (IsCrossFileMessage(descriptor_)) {
- printer->Print(variables,
+ printer->Print(variables_,
" delete reinterpret_cast< ::google::protobuf::MessageLite*>($name$_);\n");
} else {
- printer->Print(variables,
+ printer->Print(variables_,
" delete $name$_;\n");
}
- printer->Print(variables,
+ printer->Print(variables_,
" }\n"
" if ($name$) {\n");
if (SupportsArenas(descriptor_->message_type()) &&
IsCrossFileMessage(descriptor_)) {
// We have to read the arena through the virtual method, because the type
// isn't defined in this file.
- printer->Print(variables,
+ printer->Print(variables_,
" ::google::protobuf::Arena* submessage_arena =\n"
" reinterpret_cast< ::google::protobuf::MessageLite*>($name$)->GetArena();\n");
} else if (!SupportsArenas(descriptor_->message_type())) {
- printer->Print(variables,
+ printer->Print(variables_,
" ::google::protobuf::Arena* submessage_arena = NULL;\n");
} else {
- printer->Print(variables,
+ printer->Print(variables_,
" ::google::protobuf::Arena* submessage_arena =\n"
" ::google::protobuf::Arena::GetArena($name$);\n");
}
- printer->Print(variables,
+ printer->Print(variables_,
" if (message_arena != submessage_arena) {\n"
" $name$ = ::google::protobuf::internal::GetOwnedMessage(\n"
" message_arena, $name$, submessage_arena);\n"
@@ -461,13 +328,13 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" $clear_hasbit$\n"
" }\n");
if (implicit_weak_field_) {
- printer->Print(variables,
+ printer->Print(variables_,
" $name$_ = reinterpret_cast<MessageLite*>($name$);\n");
} else {
- printer->Print(variables,
+ printer->Print(variables_,
" $name$_ = $name$;\n");
}
- printer->Print(variables,
+ printer->Print(variables_,
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
}
@@ -540,34 +407,12 @@ GenerateConstructorCode(io::Printer* printer) const {
void MessageFieldGenerator::
GenerateCopyConstructorCode(io::Printer* printer) const {
- // For non-Arena enabled messages, everything always goes on the heap.
- //
- // For Arena enabled messages, the logic is a bit more convoluted.
- //
- // In the copy constructor, we call InternalMetadataWithArena::MergeFrom,
- // which does *not* copy the Arena pointer. In the generated MergeFrom
- // (see MessageFieldGenerator::GenerateMergingCode), we:
- // -> copy the has bits (but this is done in bulk by a memcpy in the copy
- // constructor)
- // -> check whether the destination field pointer is NULL (it will be, since
- // we're initializing it and would have called SharedCtor) and if so:
- // -> call _slow_mutable_$name$(), which calls either
- // ::google::protobuf::Arena::CreateMessage<>(GetArenaNoVirtual()), or
- // ::google::protobuf::Arena::Create<>(GetArenaNoVirtual())
- //
- // At this point, GetArenaNoVirtual returns NULL since the Arena pointer
- // wasn't copied, so both of these methods allocate the submessage on the
- // heap.
-
- string new_expression = (implicit_weak_field_ ? "from.$name$_->New()"
- : "new $type$(*from.$name$_)");
- string output =
- "if (from.has_$name$()) {\n"
- " $name$_ = " + new_expression + ";\n"
- "} else {\n"
- " $name$_ = NULL;\n"
- "}\n";
- printer->Print(variables_, output.c_str());
+ printer->Print(variables_,
+ "if (from.has_$name$()) {\n"
+ " $name$_ = new $type$(*from.$name$_);\n"
+ "} else {\n"
+ " $name$_ = NULL;\n"
+ "}\n");
}
void MessageFieldGenerator::
@@ -591,7 +436,7 @@ void MessageFieldGenerator::
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
printer->Print(variables_,
"::google::protobuf::internal::WireFormatLite::Write$stream_writer$(\n"
- " $number$, *$non_null_ptr_to_name$, output);\n");
+ " $number$, *$field_member$, output);\n");
}
void MessageFieldGenerator::
@@ -599,7 +444,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
printer->Print(variables_,
"target = ::google::protobuf::internal::WireFormatLite::\n"
" InternalWrite$declared_type$ToArray(\n"
- " $number$, *$non_null_ptr_to_name$, deterministic, target);\n");
+ " $number$, *$field_member$, deterministic, target);\n");
}
void MessageFieldGenerator::
@@ -607,7 +452,7 @@ GenerateByteSize(io::Printer* printer) const {
printer->Print(variables_,
"total_size += $tag_size$ +\n"
" ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n"
- " *$non_null_ptr_to_name$);\n");
+ " *$field_member$);\n");
}
// ===================================================================
@@ -650,57 +495,27 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
" message_arena, $name$, submessage_arena);\n"
" }\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_ = $name$;\n"
+ " $field_member$ = $name$;\n"
" }\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
}
void MessageOneofFieldGenerator::
-GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {
- // For the CRTP base class, all mutation methods are dependent, and so
- // they must be in the header.
- if (!dependent_base_) {
- return;
- }
- std::map<string, string> variables(variables_);
- variables["dependent_classname"] =
- DependentBaseClassTemplateName(descriptor_->containing_type()) + "<T>";
- variables["this_message"] = "reinterpret_cast<T*>(this)->";
- // Const message access is needed for the dependent getter.
- variables["this_const_message"] = "reinterpret_cast<const T*>(this)->";
- variables["tmpl"] = "template <class T>\n";
- variables["field_member"] = variables["this_message"] +
- variables["oneof_prefix"] + variables["name"] +
- "_";
- InternalGenerateInlineAccessorDefinitions(variables, printer);
-}
-
-void MessageOneofFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
-
- std::map<string, string> variables(variables_);
- variables["dependent_classname"] = variables["classname"];
- variables["this_message"] = "";
- variables["this_const_message"] = "";
- variables["tmpl"] = "";
- variables["field_member"] =
- variables["oneof_prefix"] + variables["name"] + "_";
- variables["dependent_type"] = variables["type"];
-
- printer->Print(variables,
+ printer->Print(variables_,
"inline $type$* $classname$::$release_name$() {\n"
" // @@protoc_insertion_point(field_release:$full_name$)\n"
- " if ($this_message$has_$name$()) {\n"
- " $this_message$clear_has_$oneof_name$();\n"
+ " if (has_$name$()) {\n"
+ " clear_has_$oneof_name$();\n"
" $type$* temp = $field_member$;\n");
if (SupportsArenas(descriptor_)) {
- printer->Print(variables,
- " if ($this_message$GetArenaNoVirtual() != NULL) {\n"
+ printer->Print(variables_,
+ " if (GetArenaNoVirtual() != NULL) {\n"
" temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL);\n"
" }\n");
}
- printer->Print(variables,
+ printer->Print(variables_,
" $field_member$ = NULL;\n"
" return temp;\n"
" } else {\n"
@@ -708,23 +523,23 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" }\n"
"}\n");
- printer->Print(variables,
+ printer->Print(variables_,
"inline const $type$& $classname$::$name$() const {\n"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return $this_const_message$has_$name$()\n"
- " ? *$this_const_message$$oneof_prefix$$name$_\n"
+ " return has_$name$()\n"
+ " ? *$field_member$\n"
" : *reinterpret_cast< $type$*>(&$type_default_instance$);\n"
"}\n");
if (SupportsArenas(descriptor_)) {
- printer->Print(variables,
- "inline $type$* $dependent_classname$::unsafe_arena_release_$name$() {\n"
+ printer->Print(variables_,
+ "inline $type$* $classname$::unsafe_arena_release_$name$() {\n"
" // @@protoc_insertion_point(field_unsafe_arena_release"
":$full_name$)\n"
- " if ($this_message$has_$name$()) {\n"
- " $this_message$clear_has_$oneof_name$();\n"
- " $type$* temp = $this_message$$oneof_prefix$$name$_;\n"
- " $this_message$$oneof_prefix$$name$_ = NULL;\n"
+ " if (has_$name$()) {\n"
+ " clear_has_$oneof_name$();\n"
+ " $type$* temp = $field_member$;\n"
+ " $field_member$ = NULL;\n"
" return temp;\n"
" } else {\n"
" return NULL;\n"
@@ -738,58 +553,24 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" clear_$oneof_name$();\n"
" if ($name$) {\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_ = $name$;\n"
+ " $field_member$ = $name$;\n"
" }\n"
" // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
"$full_name$)\n"
"}\n");
}
- if (dependent_base_) {
- return;
- }
-
- InternalGenerateInlineAccessorDefinitions(variables, printer);
-}
-
-void MessageOneofFieldGenerator::InternalGenerateInlineAccessorDefinitions(
- const std::map<string, string>& variables, io::Printer* printer) const {
- if (SupportsArenas(descriptor_)) {
- printer->Print(variables,
- "$tmpl$"
- "inline $type$* $dependent_classname$::mutable_$name$() {\n"
- " if (!$this_message$has_$name$()) {\n"
- " $this_message$clear_$oneof_name$();\n"
- " $this_message$set_has_$name$();\n");
- if (SupportsArenas(descriptor_->message_type())) {
- printer->Print(variables,
- " $field_member$ = \n"
- " ::google::protobuf::Arena::CreateMessage< $dependent_typename$ >(\n"
- " $this_message$GetArenaNoVirtual());\n");
- } else {
- printer->Print(variables,
- " $this_message$$oneof_prefix$$name$_ = \n"
- " ::google::protobuf::Arena::Create< $dependent_typename$ >(\n"
- " $this_message$GetArenaNoVirtual());\n");
- }
- printer->Print(variables,
- " }\n"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $field_member$;\n"
- "}\n");
- } else {
- printer->Print(variables,
- "$tmpl$"
- "inline $type$* $dependent_classname$::mutable_$name$() {\n"
- " if (!$this_message$has_$name$()) {\n"
- " $this_message$clear_$oneof_name$();\n"
- " $this_message$set_has_$name$();\n"
- " $field_member$ = new $dependent_typename$;\n"
- " }\n"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $field_member$;\n"
- "}\n");
- }
+ printer->Print(variables_,
+ "inline $type$* $classname$::mutable_$name$() {\n"
+ " if (!has_$name$()) {\n"
+ " clear_$oneof_name$();\n"
+ " set_has_$name$();\n"
+ " $field_member$ = ::google::protobuf::Arena::$create_func$< $type$ >(\n"
+ " GetArenaNoVirtual());\n"
+ " }\n"
+ " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
+ " return $field_member$;\n"
+ "}\n");
}
void MessageOneofFieldGenerator::
@@ -797,11 +578,11 @@ GenerateClearingCode(io::Printer* printer) const {
if (SupportsArenas(descriptor_)) {
printer->Print(variables_,
"if (GetArenaNoVirtual() == NULL) {\n"
- " delete $oneof_prefix$$name$_;\n"
+ " delete $field_member$;\n"
"}\n");
} else {
printer->Print(variables_,
- "delete $oneof_prefix$$name$_;\n");
+ "delete $field_member$;\n");
}
}
@@ -834,7 +615,7 @@ RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
: FieldGenerator(options),
descriptor_(descriptor),
dependent_field_(options.proto_h && IsFieldDependent(descriptor)),
- dependent_getter_(dependent_field_ && options.safe_boundary_check) {
+ implicit_weak_field_(IsImplicitWeakField(descriptor, options)) {
SetMessageVariables(descriptor, &variables_, options);
}
@@ -848,30 +629,12 @@ GeneratePrivateMembers(io::Printer* printer) const {
void RepeatedMessageFieldGenerator::
InternalGenerateTypeDependentAccessorDeclarations(io::Printer* printer) const {
- printer->Print(variables_,
- "$deprecated_attr$$type$* ${$mutable_$name$$}$(int index);\n");
- printer->Annotate("{", "}", descriptor_);
printer->Print(variables_, "$deprecated_attr$$type$* ${$add_$name$$}$();\n");
printer->Annotate("{", "}", descriptor_);
- if (dependent_getter_) {
- printer->Print(variables_,
- "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< $type$ >&\n"
- " $name$() const;\n");
- printer->Annotate("name", descriptor_);
- }
- printer->Print(variables_,
- "$deprecated_attr$::google::protobuf::RepeatedPtrField< $type$ >*\n"
- " ${$mutable_$name$$}$();\n");
- printer->Annotate("{", "}", descriptor_);
}
void RepeatedMessageFieldGenerator::
GenerateDependentAccessorDeclarations(io::Printer* printer) const {
- if (dependent_getter_) {
- printer->Print(variables_,
- "$deprecated_attr$const $type$& $name$(int index) const;\n");
- printer->Annotate("name", descriptor_);
- }
if (dependent_field_) {
InternalGenerateTypeDependentAccessorDeclarations(printer);
}
@@ -879,20 +642,24 @@ GenerateDependentAccessorDeclarations(io::Printer* printer) const {
void RepeatedMessageFieldGenerator::
GenerateAccessorDeclarations(io::Printer* printer) const {
- if (!dependent_getter_) {
- printer->Print(variables_,
- "$deprecated_attr$const $type$& $name$(int index) const;\n");
- printer->Annotate("name", descriptor_);
- }
+ printer->Print(variables_,
+ "$deprecated_attr$$type$* ${$mutable_$name$$}$(int index);\n");
+ printer->Annotate("{", "}", descriptor_);
+ printer->Print(variables_,
+ "$deprecated_attr$::google::protobuf::RepeatedPtrField< $type$ >*\n"
+ " ${$mutable_$name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
+
+ printer->Print(variables_,
+ "$deprecated_attr$const $type$& $name$(int index) const;\n");
+ printer->Annotate("name", descriptor_);
if (!dependent_field_) {
InternalGenerateTypeDependentAccessorDeclarations(printer);
}
- if (!dependent_getter_) {
- printer->Print(variables_,
- "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< $type$ >&\n"
- " $name$() const;\n");
- printer->Annotate("name", descriptor_);
- }
+ printer->Print(variables_,
+ "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< $type$ >&\n"
+ " $name$() const;\n");
+ printer->Annotate("name", descriptor_);
}
void RepeatedMessageFieldGenerator::
@@ -908,103 +675,97 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {
variables["this_message"] = DependentBaseDownCast();
variables["this_const_message"] = DependentBaseConstDownCast();
- if (dependent_getter_) {
- printer->Print(variables,
- "template <class T>\n"
- "inline const $type$& $dependent_classname$::$name$(int index) const {\n"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return $this_const_message$$name$_.$cppget$(index);\n"
- "}\n");
- }
-
// Generate per-element accessors:
printer->Print(variables,
"template <class T>\n"
- "inline $type$* $dependent_classname$::mutable_$name$(int index) {\n"
- // TODO(dlj): move insertion points
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $this_message$$name$_.Mutable(index);\n"
- "}\n"
- "template <class T>\n"
"inline $type$* $dependent_classname$::add_$name$() {\n"
" // @@protoc_insertion_point(field_add:$full_name$)\n"
+ "$type_reference_function$"
" return $this_message$$name$_.Add();\n"
"}\n");
+}
- if (dependent_getter_) {
- printer->Print(variables,
- "template <class T>\n"
- "inline const ::google::protobuf::RepeatedPtrField< $type$ >&\n"
- "$dependent_classname$::$name$() const {\n"
- " // @@protoc_insertion_point(field_list:$full_name$)\n"
- " return $this_const_message$$name$_;\n"
- "}\n");
- }
-
- // Generate mutable access to the entire list:
- printer->Print(variables,
- "template <class T>\n"
+void RepeatedMessageFieldGenerator::
+GenerateInlineAccessorDefinitions(io::Printer* printer) const {
+ printer->Print(variables_,
+ "inline $type$* $classname$::mutable_$name$(int index) {\n"
+ // TODO(dlj): move insertion points
+ " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
+ "$type_reference_function$"
+ " return $name$_.Mutable(index);\n"
+ "}\n"
"inline ::google::protobuf::RepeatedPtrField< $type$ >*\n"
- "$dependent_classname$::mutable_$name$() {\n"
+ "$classname$::mutable_$name$() {\n"
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
- " return &$this_message$$name$_;\n"
+ "$type_reference_function$"
+ " return &$name$_;\n"
"}\n");
-}
-void RepeatedMessageFieldGenerator::
-GenerateInlineAccessorDefinitions(io::Printer* printer) const {
- if (!dependent_getter_) {
+ if (options_.safe_boundary_check) {
+ printer->Print(variables_,
+ "inline const $type$& $classname$::$name$(int index) const {\n"
+ " // @@protoc_insertion_point(field_get:$full_name$)\n"
+ "$type_reference_function$"
+ " return $name$_.InternalCheckedGet(index,\n"
+ " *reinterpret_cast<const $type$*>(&$type_default_instance$));\n"
+ "}\n");
+ } else {
printer->Print(variables_,
"inline const $type$& $classname$::$name$(int index) const {\n"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return $name$_.$cppget$(index);\n"
+ "$type_reference_function$"
+ " return $name$_.Get(index);\n"
"}\n");
}
if (!dependent_field_) {
printer->Print(variables_,
- "inline $type$* $classname$::mutable_$name$(int index) {\n"
- // TODO(dlj): move insertion points
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $name$_.Mutable(index);\n"
- "}\n"
"inline $type$* $classname$::add_$name$() {\n"
" // @@protoc_insertion_point(field_add:$full_name$)\n"
+ "$type_reference_function$"
" return $name$_.Add();\n"
"}\n");
}
- if (!dependent_field_) {
- printer->Print(variables_,
- "inline ::google::protobuf::RepeatedPtrField< $type$ >*\n"
- "$classname$::mutable_$name$() {\n"
- " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
- " return &$name$_;\n"
- "}\n");
- }
- if (!dependent_getter_) {
- printer->Print(variables_,
- "inline const ::google::protobuf::RepeatedPtrField< $type$ >&\n"
- "$classname$::$name$() const {\n"
- " // @@protoc_insertion_point(field_list:$full_name$)\n"
- " return $name$_;\n"
- "}\n");
- }
+ printer->Print(variables_,
+ "inline const ::google::protobuf::RepeatedPtrField< $type$ >&\n"
+ "$classname$::$name$() const {\n"
+ " // @@protoc_insertion_point(field_list:$full_name$)\n"
+ "$type_reference_function$"
+ " return $name$_;\n"
+ "}\n");
}
void RepeatedMessageFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.Clear();\n");
+ if (implicit_weak_field_) {
+ printer->Print(
+ variables_,
+ "CastToBase(&$name$_)->Clear<"
+ "::google::protobuf::internal::ImplicitWeakTypeHandler<$type$>>();\n");
+ } else {
+ printer->Print(variables_, "$name$_.Clear();\n");
+ }
}
void RepeatedMessageFieldGenerator::
GenerateMergingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n");
+ if (implicit_weak_field_) {
+ printer->Print(
+ variables_,
+ "CastToBase(&$name$_)->MergeFrom<"
+ "::google::protobuf::internal::ImplicitWeakTypeHandler<$type$>>(CastToBase("
+ "from.$name$_));\n");
+ } else {
+ printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n");
+ }
}
void RepeatedMessageFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.InternalSwap(&other->$name$_);\n");
+ printer->Print(
+ variables_,
+ "CastToBase(&$name$_)->InternalSwap(CastToBase(&other->$name$_));\n");
}
void RepeatedMessageFieldGenerator::
@@ -1015,9 +776,18 @@ GenerateConstructorCode(io::Printer* printer) const {
void RepeatedMessageFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {
- printer->Print(variables_,
- "DO_(::google::protobuf::internal::WireFormatLite::"
- "ReadMessage(input, add_$name$()));\n");
+ if (implicit_weak_field_) {
+ printer->Print(variables_,
+ "DO_(::google::protobuf::internal::WireFormatLite::"
+ "ReadMessage(input, CastToBase(&$name$_)->AddWeak(\n"
+ " reinterpret_cast<const ::google::protobuf::MessageLite*>(\n"
+ " &$type_default_instance$))));\n");
+ } else {
+ printer->Print(variables_,
+ "DO_(::google::protobuf::internal::WireFormatLite::"
+ "ReadMessage(\n"
+ " input, add_$name$()));\n");
+ }
} else {
printer->Print(variables_,
"DO_(::google::protobuf::internal::WireFormatLite::"
@@ -1031,7 +801,19 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
"for (unsigned int i = 0,\n"
" n = static_cast<unsigned int>(this->$name$_size()); i < n; i++) {\n"
" ::google::protobuf::internal::WireFormatLite::Write$stream_writer$(\n"
- " $number$, this->$name$(static_cast<int>(i)), output);\n"
+ " $number$,\n");
+ if (implicit_weak_field_) {
+ printer->Print(
+ variables_,
+ " CastToBase($name$_).Get<"
+ "::google::protobuf::internal::ImplicitWeakTypeHandler<$type$>>("
+ "static_cast<int>(i)),\n");
+ } else {
+ printer->Print(variables_,
+ " this->$name$(static_cast<int>(i)),\n");
+ }
+ printer->Print(variables_,
+ " output);\n"
"}\n");
}
@@ -1056,9 +838,18 @@ GenerateByteSize(io::Printer* printer) const {
"total_size += $tag_size$UL * count;\n"
"for (unsigned int i = 0; i < count; i++) {\n"
" total_size +=\n"
- " ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n"
- " this->$name$(static_cast<int>(i)));\n"
- "}\n");
+ " ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n");
+ if (implicit_weak_field_) {
+ printer->Print(
+ variables_,
+ " CastToBase($name$_).Get<"
+ "::google::protobuf::internal::ImplicitWeakTypeHandler<$type$>>("
+ "static_cast<int>(i)));\n");
+ } else {
+ printer->Print(variables_,
+ " this->$name$(static_cast<int>(i)));\n");
+ }
+ printer->Print(variables_, "}\n");
printer->Outdent();
printer->Print("}\n");
}
diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.h b/src/google/protobuf/compiler/cpp/cpp_message_field.h
index 3be505e3..e165404f 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_message_field.h
@@ -54,9 +54,7 @@ class MessageFieldGenerator : public FieldGenerator {
// implements FieldGenerator ---------------------------------------
void GeneratePrivateMembers(io::Printer* printer) const;
- void GenerateDependentAccessorDeclarations(io::Printer* printer) const;
void GenerateAccessorDeclarations(io::Printer* printer) const;
- void GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateClearingCode(io::Printer* printer) const;
@@ -73,7 +71,6 @@ class MessageFieldGenerator : public FieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- const bool dependent_field_;
const bool implicit_weak_field_;
std::map<string, string> variables_;
@@ -88,7 +85,6 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator {
~MessageOneofFieldGenerator();
// implements FieldGenerator ---------------------------------------
- void GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateClearingCode(io::Printer* printer) const;
@@ -101,9 +97,6 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator {
void GenerateConstructorCode(io::Printer* printer) const;
private:
- void InternalGenerateInlineAccessorDefinitions(
- const std::map<string, string>& variables, io::Printer* printer) const;
-
const bool dependent_base_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);
};
@@ -136,7 +129,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator {
const FieldDescriptor* descriptor_;
const bool dependent_field_;
- const bool dependent_getter_;
+ const bool implicit_weak_field_;
std::map<string, string> variables_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);
diff --git a/src/google/protobuf/compiler/cpp/cpp_options.h b/src/google/protobuf/compiler/cpp/cpp_options.h
index 4a29ad0e..b0dd8836 100644
--- a/src/google/protobuf/compiler/cpp/cpp_options.h
+++ b/src/google/protobuf/compiler/cpp/cpp_options.h
@@ -54,6 +54,7 @@ struct Options {
table_driven_parsing(false),
table_driven_serialization(false),
lite_implicit_weak_fields(false),
+ num_cc_files(0),
access_info_map(NULL) {}
string dllexport_decl;
@@ -65,6 +66,7 @@ struct Options {
bool table_driven_parsing;
bool table_driven_serialization;
bool lite_implicit_weak_fields;
+ int num_cc_files;
string annotation_pragma_name;
string annotation_guard_name;
const AccessInfoMap* access_info_map;
diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
index bc2d02ea..701f9d2d 100644
--- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
@@ -215,7 +215,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
"inline $type$ $classname$::$name$() const {\n"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
" if (has_$name$()) {\n"
- " return $oneof_prefix$$name$_;\n"
+ " return $field_member$;\n"
" }\n"
" return $default$;\n"
"}\n"
@@ -224,14 +224,14 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" }\n"
- " $oneof_prefix$$name$_ = value;\n"
+ " $field_member$ = value;\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n");
}
void PrimitiveOneofFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
- printer->Print(variables_, "$oneof_prefix$$name$_ = $default$;\n");
+ printer->Print(variables_, "$field_member$ = $default$;\n");
}
void PrimitiveOneofFieldGenerator::
@@ -251,7 +251,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
"clear_$oneof_name$();\n"
"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
" $type$, $wire_format_field_type$>(\n"
- " input, &$oneof_prefix$$name$_)));\n"
+ " input, &$field_member$)));\n"
"set_has_$name$();\n");
}
diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
index 264f6124..c9901e84 100644
--- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
@@ -402,11 +402,11 @@ GenerateMessageClearingCode(io::Printer* printer) const {
// When Arenas are disabled and field presence has been checked, we can
// safely treat the ArenaStringPtr as a string*.
if (descriptor_->default_value_string().empty()) {
- printer->Print(variables_,
- "(*$name$_.UnsafeRawStringPointer())->clear();\n");
+ printer->Print(variables_, "$name$_.UnsafeMutablePointer()->clear();\n");
} else {
- printer->Print(variables_,
- "(*$name$_.UnsafeRawStringPointer())->assign(*$default_variable$);\n");
+ printer->Print(
+ variables_,
+ "$name$_.UnsafeMutablePointer()->assign(*$default_variable$);\n");
}
} else {
if (descriptor_->default_value_string().empty()) {
@@ -504,6 +504,11 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
}
}
+bool StringFieldGenerator::
+MergeFromCodedStreamNeedsArena() const {
+ return false;
+}
+
void StringFieldGenerator::
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
@@ -559,7 +564,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
"inline const ::std::string& $classname$::$name$() const {\n"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
" if (has_$name$()) {\n"
- " return $oneof_prefix$$name$_.Get();\n"
+ " return $field_member$.Get();\n"
" }\n"
" return *$default_variable$;\n"
"}\n"
@@ -567,9 +572,9 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
- " $oneof_prefix$$name$_.Set$lite$($default_variable$, value,\n"
+ " $field_member$.Set$lite$($default_variable$, value,\n"
" GetArenaNoVirtual());\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n"
@@ -579,9 +584,9 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
- " $oneof_prefix$$name$_.Set$lite$(\n"
+ " $field_member$.Set$lite$(\n"
" $default_variable$, ::std::move(value), GetArenaNoVirtual());\n"
" // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
"}\n"
@@ -591,9 +596,9 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
- " $oneof_prefix$$name$_.Set$lite$($default_variable$,\n"
+ " $field_member$.Set$lite$($default_variable$,\n"
" $string_piece$(value), GetArenaNoVirtual());\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n"
@@ -603,9 +608,9 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
- " $oneof_prefix$$name$_.Set$lite$(\n"
+ " $field_member$.Set$lite$(\n"
" $default_variable$, $string_piece$(\n"
" reinterpret_cast<const char*>(value), size),\n"
" GetArenaNoVirtual());\n"
@@ -615,9 +620,9 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
- " return $oneof_prefix$$name$_.Mutable($default_variable$,\n"
+ " return $field_member$.Mutable($default_variable$,\n"
" GetArenaNoVirtual());\n"
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
"}\n"
@@ -625,7 +630,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" // @@protoc_insertion_point(field_release:$full_name$)\n"
" if (has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
- " return $oneof_prefix$$name$_.Release($default_variable$,\n"
+ " return $field_member$.Release($default_variable$,\n"
" GetArenaNoVirtual());\n"
" } else {\n"
" return NULL;\n"
@@ -633,12 +638,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
"}\n"
"inline void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
" if (!has_$name$()) {\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" clear_$oneof_name$();\n"
" if ($name$ != NULL) {\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.SetAllocated($default_variable$, $name$,\n"
+ " $field_member$.SetAllocated($default_variable$, $name$,\n"
" GetArenaNoVirtual());\n"
" }\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
@@ -649,7 +654,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n"
" if (has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
- " return $oneof_prefix$$name$_.UnsafeArenaRelease(\n"
+ " return $field_member$.UnsafeArenaRelease(\n"
" $default_variable$, GetArenaNoVirtual());\n"
" } else {\n"
" return NULL;\n"
@@ -659,12 +664,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
"::std::string* $name$) {\n"
" GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n"
" if (!has_$name$()) {\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" clear_$oneof_name$();\n"
" if ($name$) {\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeArenaSetAllocated($default_variable$, "
+ " $field_member$.UnsafeArenaSetAllocated($default_variable$, "
"$name$, GetArenaNoVirtual());\n"
" }\n"
" // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
@@ -677,7 +682,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
"inline const ::std::string& $classname$::$name$() const {\n"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
" if (has_$name$()) {\n"
- " return $oneof_prefix$$name$_.GetNoArena();\n"
+ " return $field_member$.GetNoArena();\n"
" }\n"
" return *$default_variable$;\n"
"}\n"
@@ -686,9 +691,9 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
- " $oneof_prefix$$name$_.SetNoArena($default_variable$, value);\n"
+ " $field_member$.SetNoArena($default_variable$, value);\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n"
"#if LANG_CXX11\n"
@@ -697,10 +702,9 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
- " $oneof_prefix$$name$_.SetNoArena(\n"
- " $default_variable$, ::std::move(value));\n"
+ " $field_member$.SetNoArena($default_variable$, ::std::move(value));\n"
" // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
"}\n"
"#endif\n"
@@ -709,9 +713,9 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
- " $oneof_prefix$$name$_.SetNoArena($default_variable$,\n"
+ " $field_member$.SetNoArena($default_variable$,\n"
" $string_piece$(value));\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n"
@@ -721,10 +725,9 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
- " $oneof_prefix$$name$_.SetNoArena($default_variable$, "
- "$string_piece$(\n"
+ " $field_member$.SetNoArena($default_variable$, $string_piece$(\n"
" reinterpret_cast<const char*>(value), size));\n"
" // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
"}\n"
@@ -732,29 +735,28 @@ GenerateInlineAccessorDefinitions(io::Printer* printer) const {
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $oneof_prefix$$name$_.MutableNoArena($default_variable$);\n"
+ " return $field_member$.MutableNoArena($default_variable$);\n"
"}\n"
"inline ::std::string* $classname$::$release_name$() {\n"
" // @@protoc_insertion_point(field_release:$full_name$)\n"
" if (has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
- " return $oneof_prefix$$name$_.ReleaseNoArena($default_variable$);\n"
+ " return $field_member$.ReleaseNoArena($default_variable$);\n"
" } else {\n"
" return NULL;\n"
" }\n"
"}\n"
"inline void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
" if (!has_$name$()) {\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" clear_$oneof_name$();\n"
" if ($name$ != NULL) {\n"
" set_has_$name$();\n"
- " $oneof_prefix$$name$_.SetAllocatedNoArena($default_variable$,\n"
- " $name$);\n"
+ " $field_member$.SetAllocatedNoArena($default_variable$, $name$);\n"
" }\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
@@ -765,12 +767,11 @@ void StringOneofFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
if (SupportsArenas(descriptor_)) {
printer->Print(variables_,
- "$oneof_prefix$$name$_.Destroy($default_variable$,\n"
+ "$field_member$.Destroy($default_variable$,\n"
" GetArenaNoVirtual());\n");
} else {
printer->Print(variables_,
- "$oneof_prefix$$name$_."
- "DestroyNoArena($default_variable$);\n");
+ "$field_member$.DestroyNoArena($default_variable$);\n");
}
}
@@ -796,7 +797,7 @@ void StringOneofFieldGenerator::
GenerateDestructorCode(io::Printer* printer) const {
printer->Print(variables_,
"if (has_$name$()) {\n"
- " $oneof_prefix$$name$_.DestroyNoArena($default_variable$);\n"
+ " $field_member$.DestroyNoArena($default_variable$);\n"
"}\n");
}
@@ -912,11 +913,21 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
void RepeatedStringFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
+ if (options_.safe_boundary_check) {
+ printer->Print(variables_,
+ "inline const ::std::string& $classname$::$name$(int index) const {\n"
+ " // @@protoc_insertion_point(field_get:$full_name$)\n"
+ " return $name$_.InternalCheckedGet(\n"
+ " index, ::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"
+ "}\n");
+ } else {
+ printer->Print(variables_,
+ "inline const ::std::string& $classname$::$name$(int index) const {\n"
+ " // @@protoc_insertion_point(field_get:$full_name$)\n"
+ " return $name$_.Get(index);\n"
+ "}\n");
+ }
printer->Print(variables_,
- "inline const ::std::string& $classname$::$name$(int index) const {\n"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return $name$_.$cppget$(index);\n"
- "}\n"
"inline ::std::string* $classname$::mutable_$name$(int index) {\n"
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
" return $name$_.Mutable(index);\n"
@@ -991,7 +1002,8 @@ GenerateMergingCode(io::Printer* printer) const {
void RepeatedStringFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.InternalSwap(&other->$name$_);\n");
+ printer->Print(variables_,
+ "$name$_.InternalSwap(CastToBase(&other->$name$_));\n");
}
void RepeatedStringFieldGenerator::
diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.h b/src/google/protobuf/compiler/cpp/cpp_string_field.h
index f56f0721..0c6e9ced 100644
--- a/src/google/protobuf/compiler/cpp/cpp_string_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_string_field.h
@@ -69,6 +69,8 @@ class StringFieldGenerator : public FieldGenerator {
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
void GenerateByteSize(io::Printer* printer) const;
+ bool MergeFromCodedStreamNeedsArena() const;
+
protected:
const FieldDescriptor* descriptor_;
std::map<string, string> variables_;
diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc
index 61cc32a4..2ad7ea4e 100644
--- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc
@@ -995,75 +995,76 @@ TEST(GeneratedMessageTest, TestEmbedOptimizedForSize) {
TEST(GeneratedMessageTest, TestSpaceUsed) {
unittest::TestAllTypes message1;
- // sizeof provides a lower bound on SpaceUsed().
- EXPECT_LE(sizeof(unittest::TestAllTypes), message1.SpaceUsed());
- const int empty_message_size = message1.SpaceUsed();
+ // sizeof provides a lower bound on SpaceUsedLong().
+ EXPECT_LE(sizeof(unittest::TestAllTypes), message1.SpaceUsedLong());
+ const size_t empty_message_size = message1.SpaceUsedLong();
// Setting primitive types shouldn't affect the space used.
message1.set_optional_int32(123);
message1.set_optional_int64(12345);
message1.set_optional_uint32(123);
message1.set_optional_uint64(12345);
- EXPECT_EQ(empty_message_size, message1.SpaceUsed());
+ EXPECT_EQ(empty_message_size, message1.SpaceUsedLong());
// On some STL implementations, setting the string to a small value should
- // only increase SpaceUsed() by the size of a string object, though this is
- // not true everywhere.
+ // only increase SpaceUsedLong() by the size of a string object, though this
+ // is not true everywhere.
message1.set_optional_string("abc");
- EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsed());
+ EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsedLong());
// Setting a string to a value larger than the string object itself should
- // increase SpaceUsed(), because it cannot store the value internally.
+ // increase SpaceUsedLong(), because it cannot store the value internally.
message1.set_optional_string(string(sizeof(string) + 1, 'x'));
int min_expected_increase = message1.optional_string().capacity() +
sizeof(string);
EXPECT_LE(empty_message_size + min_expected_increase,
- message1.SpaceUsed());
+ message1.SpaceUsedLong());
- int previous_size = message1.SpaceUsed();
+ size_t previous_size = message1.SpaceUsedLong();
// Adding an optional message should increase the size by the size of the
// nested message type. NestedMessage is simple enough (1 int field) that it
// is equal to sizeof(NestedMessage)
message1.mutable_optional_nested_message();
ASSERT_EQ(sizeof(unittest::TestAllTypes::NestedMessage),
- message1.optional_nested_message().SpaceUsed());
+ message1.optional_nested_message().SpaceUsedLong());
EXPECT_EQ(previous_size +
sizeof(unittest::TestAllTypes::NestedMessage),
- message1.SpaceUsed());
+ message1.SpaceUsedLong());
}
TEST(GeneratedMessageTest, TestOneofSpaceUsed) {
unittest::TestOneof2 message1;
- EXPECT_LE(sizeof(unittest::TestOneof2), message1.SpaceUsed());
+ EXPECT_LE(sizeof(unittest::TestOneof2), message1.SpaceUsedLong());
- const int empty_message_size = message1.SpaceUsed();
+ const size_t empty_message_size = message1.SpaceUsedLong();
// Setting primitive types shouldn't affect the space used.
message1.set_foo_int(123);
message1.set_bar_int(12345);
- EXPECT_EQ(empty_message_size, message1.SpaceUsed());
+ EXPECT_EQ(empty_message_size, message1.SpaceUsedLong());
- // Setting a string in oneof to a small value should only increase SpaceUsed()
- // by the size of a string object.
+ // Setting a string in oneof to a small value should only increase
+ // SpaceUsedLong() by the size of a string object.
message1.set_foo_string("abc");
- EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsed());
+ EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsedLong());
// Setting a string in oneof to a value larger than the string object itself
- // should increase SpaceUsed(), because it cannot store the value internally.
+ // should increase SpaceUsedLong(), because it cannot store the value
+ // internally.
message1.set_foo_string(string(sizeof(string) + 1, 'x'));
int min_expected_increase = message1.foo_string().capacity() +
sizeof(string);
EXPECT_LE(empty_message_size + min_expected_increase,
- message1.SpaceUsed());
+ message1.SpaceUsedLong());
// Setting a message in oneof should delete the other fields and increase the
// size by the size of the nested message type. NestedMessage is simple enough
// that it is equal to sizeof(NestedMessage)
message1.mutable_foo_message();
ASSERT_EQ(sizeof(unittest::TestOneof2::NestedMessage),
- message1.foo_message().SpaceUsed());
+ message1.foo_message().SpaceUsedLong());
EXPECT_EQ(empty_message_size +
sizeof(unittest::TestOneof2::NestedMessage),
- message1.SpaceUsed());
+ message1.SpaceUsedLong());
}
#endif // !PROTOBUF_TEST_NO_DESCRIPTORS
diff --git a/src/google/protobuf/compiler/cpp/metadata_test.cc b/src/google/protobuf/compiler/cpp/metadata_test.cc
index d1bb3194..456784c6 100644
--- a/src/google/protobuf/compiler/cpp/metadata_test.cc
+++ b/src/google/protobuf/compiler/cpp/metadata_test.cc
@@ -72,9 +72,7 @@ class CppMetadataTest : public ::testing::Test {
TestTempDir();
const bool result =
- atu::CaptureMetadata(filename, cpp_out,
- /* meta_file_suffix */ "", &cli, file,
- /* outputs */ NULL);
+ atu::RunProtoCompiler(filename, cpp_out, &cli, file);
if (!result) {
return result;
diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc
index 2486b739..f2ff2800 100644
--- a/src/google/protobuf/compiler/java/java_message.cc
+++ b/src/google/protobuf/compiler/java/java_message.cc
@@ -1259,19 +1259,9 @@ GenerateParsingConstructor(io::Printer* printer) {
printer->Indent();
printer->Print(
- "case 0:\n" // zero signals EOF / limit reached
- " done = true;\n"
- " break;\n"
- "default: {\n"
- " if (!parseUnknownField$suffix$(\n"
- " input, unknownFields, extensionRegistry, tag)) {\n"
- " done = true;\n" // it's an endgroup tag
- " }\n"
- " break;\n"
- "}\n",
- "suffix",
- descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ? "Proto3"
- : "");
+ "case 0:\n" // zero signals EOF / limit reached
+ " done = true;\n"
+ " break;\n");
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = sorted_fields[i];
@@ -1309,6 +1299,18 @@ GenerateParsingConstructor(io::Printer* printer) {
}
}
+ printer->Print(
+ "default: {\n"
+ " if (!parseUnknownField$suffix$(\n"
+ " input, unknownFields, extensionRegistry, tag)) {\n"
+ " done = true;\n" // it's an endgroup tag
+ " }\n"
+ " break;\n"
+ "}\n",
+ "suffix",
+ descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ? "Proto3"
+ : "");
+
printer->Outdent();
printer->Outdent();
printer->Print(
diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc
index d828be43..108504c7 100644
--- a/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_lite.cc
@@ -1005,37 +1005,6 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
" done = true;\n"
" break;\n");
- if (descriptor_->extension_range_count() > 0) {
- if (descriptor_->options().message_set_wire_format()) {
- printer->Print(
- "default: {\n"
- " if (!parseUnknownFieldAsMessageSet(\n"
- " getDefaultInstanceForType(), input, extensionRegistry,\n"
- " tag)) {\n"
- " done = true;\n" // it's an endgroup tag
- " }\n"
- " break;\n"
- "}\n");
- } else {
- printer->Print(
- "default: {\n"
- " if (!parseUnknownField(getDefaultInstanceForType(),\n"
- " input, extensionRegistry, tag)) {\n"
- " done = true;\n" // it's an endgroup tag
- " }\n"
- " break;\n"
- "}\n");
- }
- } else {
- printer->Print(
- "default: {\n"
- " if (!parseUnknownField(tag, input)) {\n"
- " done = true;\n" // it's an endgroup tag
- " }\n"
- " break;\n"
- "}\n");
- }
-
google::protobuf::scoped_array<const FieldDescriptor* > sorted_fields(
SortFieldsByNumber(descriptor_));
for (int i = 0; i < descriptor_->field_count(); i++) {
@@ -1073,6 +1042,37 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
}
}
+ if (descriptor_->extension_range_count() > 0) {
+ if (descriptor_->options().message_set_wire_format()) {
+ printer->Print(
+ "default: {\n"
+ " if (!parseUnknownFieldAsMessageSet(\n"
+ " getDefaultInstanceForType(), input, extensionRegistry,\n"
+ " tag)) {\n"
+ " done = true;\n" // it's an endgroup tag
+ " }\n"
+ " break;\n"
+ "}\n");
+ } else {
+ printer->Print(
+ "default: {\n"
+ " if (!parseUnknownField(getDefaultInstanceForType(),\n"
+ " input, extensionRegistry, tag)) {\n"
+ " done = true;\n" // it's an endgroup tag
+ " }\n"
+ " break;\n"
+ "}\n");
+ }
+ } else {
+ printer->Print(
+ "default: {\n"
+ " if (!parseUnknownField(tag, input)) {\n"
+ " done = true;\n" // it's an endgroup tag
+ " }\n"
+ " break;\n"
+ "}\n");
+ }
+
printer->Outdent();
printer->Outdent();
printer->Print(
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc
index 16fe19ad..fd2d3dfd 100755
--- a/src/google/protobuf/compiler/js/js_generator.cc
+++ b/src/google/protobuf/compiler/js/js_generator.cc
@@ -195,9 +195,9 @@ string ModuleAlias(const string& filename) {
// We'll worry about this problem if/when we actually see it. This name isn't
// exposed to users so we can change it later if we need to.
string basename = StripProto(filename);
- StripString(&basename, "-", '$');
- StripString(&basename, "/", '_');
- StripString(&basename, ".", '_');
+ ReplaceCharacters(&basename, "-", '$');
+ ReplaceCharacters(&basename, "/", '_');
+ ReplaceCharacters(&basename, ".", '_');
return basename + "_pb";
}
@@ -1028,7 +1028,7 @@ string JSFieldTypeAnnotation(const GeneratorOptions& options,
if (!IsPrimitive(jstype)) {
jstype = "!" + jstype;
}
- jstype = "Array.<" + jstype + ">";
+ jstype = "Array<" + jstype + ">";
}
}
@@ -1558,6 +1558,22 @@ bool GenerateJspbAllowedSet(const GeneratorOptions& options,
return true;
}
+// Embeds base64 encoded GeneratedCodeInfo proto in a comment at the end of
+// file.
+void EmbedCodeAnnotations(const GeneratedCodeInfo& annotations,
+ io::Printer* printer) {
+ // Serialize annotations proto into base64 string.
+ string meta_content;
+ annotations.SerializeToString(&meta_content);
+ string meta_64;
+ Base64Escape(meta_content, &meta_64);
+
+ // Print base64 encoded annotations at the end of output file in
+ // a comment.
+ printer->Print("\n// Below is base64 encoded GeneratedCodeInfo proto");
+ printer->Print("\n// $encoded_proto$\n", "encoded_proto", meta_64);
+}
+
} // anonymous namespace
void Generator::GenerateHeader(const GeneratorOptions& options,
@@ -2822,7 +2838,7 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,
"so that it\n"
" * works in OPTIMIZED mode.\n"
" *\n"
- " * @type {!Object.<number, jspb.ExtensionFieldInfo>}\n"
+ " * @type {!Object<number, jspb.ExtensionFieldInfo>}\n"
" */\n"
"$class$.extensions = {};\n"
"\n",
@@ -2843,7 +2859,7 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,
"so that it\n"
" * works in OPTIMIZED mode.\n"
" *\n"
- " * @type {!Object.<number, jspb.ExtensionFieldBinaryInfo>}\n"
+ " * @type {!Object<number, jspb.ExtensionFieldBinaryInfo>}\n"
" */\n"
"$class$.extensionsBinary = {};\n"
"\n",
@@ -3195,7 +3211,7 @@ void Generator::GenerateExtension(const GeneratorOptions& options,
"/**\n"
" * A tuple of {field number, class constructor} for the extension\n"
" * field named `$name$`.\n"
- " * @type {!jspb.ExtensionFieldInfo.<$extensionType$>}\n"
+ " * @type {!jspb.ExtensionFieldInfo<$extensionType$>}\n"
" */\n"
"$class$.$name$ = new jspb.ExtensionFieldInfo(\n",
"name", JSObjectFieldName(options, field),
@@ -3634,10 +3650,7 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files,
}
if (options.annotate_code) {
- const string meta_file = filename + ".meta";
- google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> info_output(
- context->Open(meta_file));
- annotations.SerializeToZeroCopyStream(info_output.get());
+ EmbedCodeAnnotations(annotations, &printer);
}
}
}
diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc
index bfcb83df..7719ec3d 100644
--- a/src/google/protobuf/compiler/mock_code_generator.cc
+++ b/src/google/protobuf/compiler/mock_code_generator.cc
@@ -70,7 +70,7 @@ namespace compiler {
// Returns the list of the names of files in all_files in the form of a
// comma-separated string.
-string CommaSeparatedList(const std::vector<const FileDescriptor*> all_files) {
+string CommaSeparatedList(const std::vector<const FileDescriptor*>& all_files) {
std::vector<string> names;
for (size_t i = 0; i < all_files.size(); i++) {
names.push_back(all_files[i]->name());
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc
index 80c8c625..d13ad2b3 100644
--- a/src/google/protobuf/compiler/plugin.pb.cc
+++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -325,13 +325,6 @@ const Version& Version::default_instance() {
return *internal_default_instance();
}
-Version* Version::New(::google::protobuf::Arena* arena) const {
- Version* n = new Version;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
void Version::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.Version)
@@ -342,7 +335,7 @@ void Version::Clear() {
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(!suffix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
- (*suffix_.UnsafeRawStringPointer())->clear();
+ suffix_.UnsafeMutablePointer()->clear();
}
if (cached_has_bits & 14u) {
::memset(&major_, 0, static_cast<size_t>(
@@ -723,13 +716,6 @@ const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() {
return *internal_default_instance();
}
-CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena) const {
- CodeGeneratorRequest* n = new CodeGeneratorRequest;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
void CodeGeneratorRequest::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest)
@@ -743,7 +729,7 @@ void CodeGeneratorRequest::Clear() {
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(!parameter_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
- (*parameter_.UnsafeRawStringPointer())->clear();
+ parameter_.UnsafeMutablePointer()->clear();
}
if (cached_has_bits & 0x00000002u) {
GOOGLE_DCHECK(compiler_version_ != NULL);
@@ -813,7 +799,8 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream(
case 15: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(122u /* 122 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_proto_file()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_proto_file()));
} else {
goto handle_unusual;
}
@@ -870,14 +857,16 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
// optional .google.protobuf.compiler.Version compiler_version = 3;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, *this->compiler_version_, output);
+ 3, *compiler_version_, output);
}
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->proto_file_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 15, this->proto_file(static_cast<int>(i)), output);
+ 15,
+ this->proto_file(static_cast<int>(i)),
+ output);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -920,7 +909,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 3, *this->compiler_version_, deterministic, target);
+ 3, *compiler_version_, deterministic, target);
}
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
@@ -979,7 +968,7 @@ size_t CodeGeneratorRequest::ByteSizeLong() const {
if (has_compiler_version()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->compiler_version_);
+ *compiler_version_);
}
}
@@ -1051,8 +1040,8 @@ void CodeGeneratorRequest::Swap(CodeGeneratorRequest* other) {
}
void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
using std::swap;
- file_to_generate_.InternalSwap(&other->file_to_generate_);
- proto_file_.InternalSwap(&other->proto_file_);
+ file_to_generate_.InternalSwap(CastToBase(&other->file_to_generate_));
+ CastToBase(&proto_file_)->InternalSwap(CastToBase(&other->proto_file_));
parameter_.Swap(&other->parameter_);
swap(compiler_version_, other->compiler_version_);
swap(_has_bits_[0], other->_has_bits_[0]);
@@ -1138,13 +1127,6 @@ const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance()
return *internal_default_instance();
}
-CodeGeneratorResponse_File* CodeGeneratorResponse_File::New(::google::protobuf::Arena* arena) const {
- CodeGeneratorResponse_File* n = new CodeGeneratorResponse_File;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
void CodeGeneratorResponse_File::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File)
@@ -1156,15 +1138,15 @@ void CodeGeneratorResponse_File::Clear() {
if (cached_has_bits & 7u) {
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
- (*name_.UnsafeRawStringPointer())->clear();
+ name_.UnsafeMutablePointer()->clear();
}
if (cached_has_bits & 0x00000002u) {
GOOGLE_DCHECK(!insertion_point_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
- (*insertion_point_.UnsafeRawStringPointer())->clear();
+ insertion_point_.UnsafeMutablePointer()->clear();
}
if (cached_has_bits & 0x00000004u) {
GOOGLE_DCHECK(!content_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
- (*content_.UnsafeRawStringPointer())->clear();
+ content_.UnsafeMutablePointer()->clear();
}
}
_has_bits_.Clear();
@@ -1518,13 +1500,6 @@ const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() {
return *internal_default_instance();
}
-CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* arena) const {
- CodeGeneratorResponse* n = new CodeGeneratorResponse;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
void CodeGeneratorResponse::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse)
@@ -1536,7 +1511,7 @@ void CodeGeneratorResponse::Clear() {
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(!error_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
- (*error_.UnsafeRawStringPointer())->clear();
+ error_.UnsafeMutablePointer()->clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear();
@@ -1572,7 +1547,8 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream(
case 15: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(122u /* 122 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_file()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_file()));
} else {
goto handle_unusual;
}
@@ -1620,7 +1596,9 @@ void CodeGeneratorResponse::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->file_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 15, this->file(static_cast<int>(i)), output);
+ 15,
+ this->file(static_cast<int>(i)),
+ output);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -1752,7 +1730,7 @@ void CodeGeneratorResponse::Swap(CodeGeneratorResponse* other) {
}
void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
using std::swap;
- file_.InternalSwap(&other->file_);
+ CastToBase(&file_)->InternalSwap(CastToBase(&other->file_));
error_.Swap(&other->error_);
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
@@ -1769,5 +1747,21 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
} // namespace compiler
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::Version* Arena::Create< ::google::protobuf::compiler::Version >(Arena* arena) {
+ return Arena::CreateInternal< ::google::protobuf::compiler::Version >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::CodeGeneratorRequest* Arena::Create< ::google::protobuf::compiler::CodeGeneratorRequest >(Arena* arena) {
+ return Arena::CreateInternal< ::google::protobuf::compiler::CodeGeneratorRequest >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::CodeGeneratorResponse_File* Arena::Create< ::google::protobuf::compiler::CodeGeneratorResponse_File >(Arena* arena) {
+ return Arena::CreateInternal< ::google::protobuf::compiler::CodeGeneratorResponse_File >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::CodeGeneratorResponse* Arena::Create< ::google::protobuf::compiler::CodeGeneratorResponse >(Arena* arena) {
+ return Arena::CreateInternal< ::google::protobuf::compiler::CodeGeneratorResponse >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h
index 8f92b6ae..617fd799 100644
--- a/src/google/protobuf/compiler/plugin.pb.h
+++ b/src/google/protobuf/compiler/plugin.pb.h
@@ -84,6 +84,14 @@ LIBPROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_;
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorRequest* Arena::Create< ::google::protobuf::compiler::CodeGeneratorRequest>(Arena*);
+template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorResponse* Arena::Create< ::google::protobuf::compiler::CodeGeneratorResponse>(Arena*);
+template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorResponse_File* Arena::Create< ::google::protobuf::compiler::CodeGeneratorResponse_File>(Arena*);
+template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::Version* Arena::Create< ::google::protobuf::compiler::Version>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
namespace compiler {
// ===================================================================
@@ -139,9 +147,13 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_
// implements Message ----------------------------------------------
- inline Version* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Version* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<Version>(NULL);
+ }
- Version* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Version* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<Version>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Version& from);
@@ -287,9 +299,13 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
// implements Message ----------------------------------------------
- inline CodeGeneratorRequest* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline CodeGeneratorRequest* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<CodeGeneratorRequest>(NULL);
+ }
- CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<CodeGeneratorRequest>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const CodeGeneratorRequest& from);
@@ -351,11 +367,11 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
int proto_file_size() const;
void clear_proto_file();
static const int kProtoFileFieldNumber = 15;
- const ::google::protobuf::FileDescriptorProto& proto_file(int index) const;
::google::protobuf::FileDescriptorProto* mutable_proto_file(int index);
- ::google::protobuf::FileDescriptorProto* add_proto_file();
::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*
mutable_proto_file();
+ const ::google::protobuf::FileDescriptorProto& proto_file(int index) const;
+ ::google::protobuf::FileDescriptorProto* add_proto_file();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&
proto_file() const;
@@ -453,9 +469,13 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
// implements Message ----------------------------------------------
- inline CodeGeneratorResponse_File* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline CodeGeneratorResponse_File* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<CodeGeneratorResponse_File>(NULL);
+ }
- CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<CodeGeneratorResponse_File>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const CodeGeneratorResponse_File& from);
@@ -607,9 +627,13 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
// implements Message ----------------------------------------------
- inline CodeGeneratorResponse* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline CodeGeneratorResponse* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<CodeGeneratorResponse>(NULL);
+ }
- CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<CodeGeneratorResponse>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const CodeGeneratorResponse& from);
@@ -651,11 +675,11 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
int file_size() const;
void clear_file();
static const int kFileFieldNumber = 15;
- const ::google::protobuf::compiler::CodeGeneratorResponse_File& file(int index) const;
::google::protobuf::compiler::CodeGeneratorResponse_File* mutable_file(int index);
- ::google::protobuf::compiler::CodeGeneratorResponse_File* add_file();
::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >*
mutable_file();
+ const ::google::protobuf::compiler::CodeGeneratorResponse_File& file(int index) const;
+ ::google::protobuf::compiler::CodeGeneratorResponse_File* add_file();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >&
file() const;
@@ -973,23 +997,23 @@ inline void CodeGeneratorRequest::set_allocated_parameter(::std::string* paramet
inline int CodeGeneratorRequest::proto_file_size() const {
return proto_file_.size();
}
-inline const ::google::protobuf::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
- return proto_file_.Get(index);
-}
inline ::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::mutable_proto_file(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
return proto_file_.Mutable(index);
}
-inline ::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() {
- // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
- return proto_file_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*
CodeGeneratorRequest::mutable_proto_file() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
return &proto_file_;
}
+inline const ::google::protobuf::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
+ return proto_file_.Get(index);
+}
+inline ::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() {
+ // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
+ return proto_file_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&
CodeGeneratorRequest::proto_file() const {
// @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
@@ -1026,7 +1050,8 @@ inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::release_comp
inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() {
set_has_compiler_version();
if (compiler_version_ == NULL) {
- compiler_version_ = new ::google::protobuf::compiler::Version;
+ compiler_version_ = ::google::protobuf::Arena::Create< ::google::protobuf::compiler::Version >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
return compiler_version_;
@@ -1317,23 +1342,23 @@ inline int CodeGeneratorResponse::file_size() const {
inline void CodeGeneratorResponse::clear_file() {
file_.Clear();
}
-inline const ::google::protobuf::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.file)
- return file_.Get(index);
-}
inline ::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::mutable_file(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.file)
return file_.Mutable(index);
}
-inline ::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() {
- // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorResponse.file)
- return file_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >*
CodeGeneratorResponse::mutable_file() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorResponse.file)
return &file_;
}
+inline const ::google::protobuf::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.file)
+ return file_.Get(index);
+}
+inline ::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() {
+ // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorResponse.file)
+ return file_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >&
CodeGeneratorResponse::file() const {
// @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorResponse.file)
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index 3f54b848..9d48bfba 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -32,7 +32,10 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#include <algorithm>
+#include <functional>
#include <google/protobuf/stubs/hash.h>
+#include <limits>
#include <map>
#include <memory>
#ifndef _SHARED_PTR_H
@@ -41,8 +44,6 @@
#include <set>
#include <string>
#include <vector>
-#include <algorithm>
-#include <limits>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
@@ -375,15 +376,13 @@ class PrefixRemover {
string prefix_;
};
-// A DescriptorPool contains a bunch of hash_maps to implement the
+// A DescriptorPool contains a bunch of hash-maps to implement the
// various Find*By*() methods. Since hashtable lookups are O(1), it's
-// most efficient to construct a fixed set of large hash_maps used by
+// most efficient to construct a fixed set of large hash-maps used by
// all objects in the pool rather than construct one or more small
-// hash_maps for each object.
+// hash-maps for each object.
//
-// The keys to these hash_maps are (parent, name) or (parent, number)
-// pairs. Unfortunately STL doesn't provide hash functions for pair<>,
-// so we must invent our own.
+// The keys to these hash-maps are (parent, name) or (parent, number) pairs.
//
// TODO(kenton): Use StringPiece rather than const char* in keys? It would
// be a lot cleaner but we'd just have to convert it back to const char*
@@ -398,6 +397,13 @@ struct PointerStringPairEqual {
}
};
+typedef std::pair<const Descriptor*, int> DescriptorIntPair;
+typedef std::pair<const EnumDescriptor*, int> EnumIntPair;
+
+#define HASH_MAP hash_map
+#define HASH_SET hash_set
+#define HASH_FXN hash
+
template<typename PairType>
struct PointerIntegerPairHash {
size_t operator()(const PairType& p) const {
@@ -417,9 +423,6 @@ struct PointerIntegerPairHash {
}
};
-typedef std::pair<const Descriptor*, int> DescriptorIntPair;
-typedef std::pair<const EnumDescriptor*, int> EnumIntPair;
-
struct PointerStringPairHash {
size_t operator()(const PointerStringPair& p) const {
// FIXME(kenton): What is the best way to compute this hash? I have
@@ -445,31 +448,37 @@ struct PointerStringPairHash {
const Symbol kNullSymbol;
-typedef hash_map<const char*, Symbol,
- hash<const char*>, streq>
- SymbolsByNameMap;
-typedef hash_map<PointerStringPair, Symbol,
- PointerStringPairHash, PointerStringPairEqual>
- SymbolsByParentMap;
-typedef hash_map<const char*, const FileDescriptor*,
- hash<const char*>, streq>
- FilesByNameMap;
-typedef hash_map<PointerStringPair, const FieldDescriptor*,
+typedef HASH_MAP<const char*, Symbol, HASH_FXN<const char*>, streq>
+ SymbolsByNameMap;
+
+typedef HASH_MAP<PointerStringPair, Symbol, PointerStringPairHash,
+ PointerStringPairEqual>
+ SymbolsByParentMap;
+
+typedef HASH_MAP<const char*, const FileDescriptor*, HASH_FXN<const char*>,
+ streq>
+ FilesByNameMap;
+
+typedef HASH_MAP<PointerStringPair, const FieldDescriptor*,
PointerStringPairHash, PointerStringPairEqual>
- FieldsByNameMap;
-typedef hash_map<DescriptorIntPair, const FieldDescriptor*,
- PointerIntegerPairHash<DescriptorIntPair> >
- FieldsByNumberMap;
-typedef hash_map<EnumIntPair, const EnumValueDescriptor*,
- PointerIntegerPairHash<EnumIntPair> >
- EnumValuesByNumberMap;
-// This is a map rather than a hash_map, since we use it to iterate
+ FieldsByNameMap;
+
+typedef HASH_MAP<DescriptorIntPair, const FieldDescriptor*,
+ PointerIntegerPairHash<DescriptorIntPair>,
+ std::equal_to<DescriptorIntPair> >
+ FieldsByNumberMap;
+
+typedef HASH_MAP<EnumIntPair, const EnumValueDescriptor*,
+ PointerIntegerPairHash<EnumIntPair>,
+ std::equal_to<EnumIntPair> >
+ EnumValuesByNumberMap;
+// This is a map rather than a hash-map, since we use it to iterate
// through all the extensions that extend a given Descriptor, and an
// ordered data structure that implements lower_bound is convenient
// for that.
typedef std::map<DescriptorIntPair, const FieldDescriptor*>
ExtensionsGroupedByDescriptorMap;
-typedef hash_map<string, const SourceCodeInfo_Location*> LocationsByPathMap;
+typedef HASH_MAP<string, const SourceCodeInfo_Location*> LocationsByPathMap;
std::set<string>* allowed_proto3_extendees_ = NULL;
GOOGLE_PROTOBUF_DECLARE_ONCE(allowed_proto3_extendees_init_);
@@ -564,17 +573,17 @@ class DescriptorPool::Tables {
// execution of the current public API call, but for compatibility with
// legacy clients, this is cleared at the beginning of each public API call.
// Not used when fallback_database_ == NULL.
- hash_set<string> known_bad_files_;
+ HASH_SET<string> known_bad_files_;
// A set of symbols which we have tried to load from the fallback database
// and encountered errors. We will not attempt to load them again during
// execution of the current public API call, but for compatibility with
// legacy clients, this is cleared at the beginning of each public API call.
- hash_set<string> known_bad_symbols_;
+ HASH_SET<string> known_bad_symbols_;
// The set of descriptors for which we've already loaded the full
// set of extensions numbers from fallback_database_.
- hash_set<const Descriptor*> extensions_loaded_from_db_;
+ HASH_SET<const Descriptor*> extensions_loaded_from_db_;
// -----------------------------------------------------------------
// Finding items.
@@ -787,14 +796,13 @@ class FileDescriptorTables {
};
DescriptorPool::Tables::Tables()
- // Start some hash_map and hash_set objects with a small # of buckets
+ // Start some hash-map and hash-set objects with a small # of buckets
: known_bad_files_(3),
known_bad_symbols_(3),
extensions_loaded_from_db_(3),
symbols_by_name_(3),
files_by_name_(3) {}
-
DescriptorPool::Tables::~Tables() {
GOOGLE_DCHECK(checkpoints_.empty());
// Note that the deletion order is important, since the destructors of some
@@ -948,8 +956,10 @@ inline Symbol FileDescriptorTables::FindNestedSymbolOfType(
Symbol DescriptorPool::Tables::FindByNameHelper(
const DescriptorPool* pool, const string& name) {
MutexLockMaybe lock(pool->mutex_);
- known_bad_symbols_.clear();
- known_bad_files_.clear();
+ if (pool->fallback_database_ != NULL) {
+ known_bad_symbols_.clear();
+ known_bad_files_.clear();
+ }
Symbol result = FindSymbol(name);
if (result.IsNull() && pool->underlay_ != NULL) {
@@ -1403,8 +1413,10 @@ void DescriptorPool::InternalAddGeneratedFile(
const FileDescriptor* DescriptorPool::FindFileByName(const string& name) const {
MutexLockMaybe lock(mutex_);
- tables_->known_bad_symbols_.clear();
- tables_->known_bad_files_.clear();
+ if (fallback_database_ != NULL) {
+ tables_->known_bad_symbols_.clear();
+ tables_->known_bad_files_.clear();
+ }
const FileDescriptor* result = tables_->FindFile(name);
if (result != NULL) return result;
if (underlay_ != NULL) {
@@ -1421,8 +1433,10 @@ const FileDescriptor* DescriptorPool::FindFileByName(const string& name) const {
const FileDescriptor* DescriptorPool::FindFileContainingSymbol(
const string& symbol_name) const {
MutexLockMaybe lock(mutex_);
- tables_->known_bad_symbols_.clear();
- tables_->known_bad_files_.clear();
+ if (fallback_database_ != NULL) {
+ tables_->known_bad_symbols_.clear();
+ tables_->known_bad_files_.clear();
+ }
Symbol result = tables_->FindSymbol(symbol_name);
if (!result.IsNull()) return result.GetFile();
if (underlay_ != NULL) {
@@ -1508,8 +1522,10 @@ const FieldDescriptor* DescriptorPool::FindExtensionByNumber(
}
}
MutexLockMaybe lock(mutex_);
- tables_->known_bad_symbols_.clear();
- tables_->known_bad_files_.clear();
+ if (fallback_database_ != NULL) {
+ tables_->known_bad_symbols_.clear();
+ tables_->known_bad_files_.clear();
+ }
const FieldDescriptor* result = tables_->FindExtension(extendee, number);
if (result != NULL) {
return result;
@@ -1531,8 +1547,10 @@ void DescriptorPool::FindAllExtensions(
const Descriptor* extendee,
std::vector<const FieldDescriptor*>* out) const {
MutexLockMaybe lock(mutex_);
- tables_->known_bad_symbols_.clear();
- tables_->known_bad_files_.clear();
+ if (fallback_database_ != NULL) {
+ tables_->known_bad_symbols_.clear();
+ tables_->known_bad_files_.clear();
+ }
// Initialize tables_->extensions_ from the fallback database first
// (but do this only once per descriptor).
@@ -4539,7 +4557,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
}
}
- hash_set<string> reserved_name_set;
+ HASH_SET<string> reserved_name_set;
for (int i = 0; i < proto.reserved_name_size(); i++) {
const string& name = proto.reserved_name(i);
if (reserved_name_set.find(name) == reserved_name_set.end()) {
@@ -5125,7 +5143,7 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
}
}
- hash_set<string> reserved_name_set;
+ HASH_SET<string> reserved_name_set;
for (int i = 0; i < proto.reserved_name_size(); i++) {
const string& name = proto.reserved_name(i);
if (reserved_name_set.find(name) == reserved_name_set.end()) {
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc
index ab1b4992..c8362376 100644
--- a/src/google/protobuf/descriptor.pb.cc
+++ b/src/google/protobuf/descriptor.pb.cc
@@ -1635,9 +1635,6 @@ const FileDescriptorSet& FileDescriptorSet::default_instance() {
return *internal_default_instance();
}
-FileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<FileDescriptorSet>(arena);
-}
void FileDescriptorSet::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet)
@@ -1664,7 +1661,8 @@ bool FileDescriptorSet::MergePartialFromCodedStream(
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_file()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_file()));
} else {
goto handle_unusual;
}
@@ -1701,7 +1699,9 @@ void FileDescriptorSet::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->file_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1, this->file(static_cast<int>(i)), output);
+ 1,
+ this->file(static_cast<int>(i)),
+ output);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -1826,7 +1826,7 @@ void FileDescriptorSet::UnsafeArenaSwap(FileDescriptorSet* other) {
}
void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) {
using std::swap;
- file_.InternalSwap(&other->file_);
+ CastToBase(&file_)->InternalSwap(CastToBase(&other->file_));
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
@@ -1846,10 +1846,6 @@ void FileDescriptorProto::InitAsDefaultInstance() {
::google::protobuf::_FileDescriptorProto_default_instance_._instance.get_mutable()->source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>(
::google::protobuf::SourceCodeInfo::internal_default_instance());
}
-void FileDescriptorProto::_slow_mutable_options() {
- options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::FileOptions >(
- GetArenaNoVirtual());
-}
void FileDescriptorProto::unsafe_arena_set_allocated_options(
::google::protobuf::FileOptions* options) {
if (GetArenaNoVirtual() == NULL) {
@@ -1863,10 +1859,6 @@ void FileDescriptorProto::unsafe_arena_set_allocated_options(
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.options)
}
-void FileDescriptorProto::_slow_mutable_source_code_info() {
- source_code_info_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::SourceCodeInfo >(
- GetArenaNoVirtual());
-}
void FileDescriptorProto::unsafe_arena_set_allocated_source_code_info(
::google::protobuf::SourceCodeInfo* source_code_info) {
if (GetArenaNoVirtual() == NULL) {
@@ -2004,9 +1996,6 @@ const FileDescriptorProto& FileDescriptorProto::default_instance() {
return *internal_default_instance();
}
-FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<FileDescriptorProto>(arena);
-}
void FileDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorProto)
@@ -2111,7 +2100,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream(
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_message_type()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_message_type()));
} else {
goto handle_unusual;
}
@@ -2122,7 +2112,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream(
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_enum_type()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_enum_type()));
} else {
goto handle_unusual;
}
@@ -2133,7 +2124,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream(
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_service()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_service()));
} else {
goto handle_unusual;
}
@@ -2144,7 +2136,8 @@ bool FileDescriptorProto::MergePartialFromCodedStream(
case 7: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u /* 58 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_extension()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_extension()));
} else {
goto handle_unusual;
}
@@ -2290,40 +2283,48 @@ void FileDescriptorProto::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->message_type_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 4, this->message_type(static_cast<int>(i)), output);
+ 4,
+ this->message_type(static_cast<int>(i)),
+ output);
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->enum_type_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 5, this->enum_type(static_cast<int>(i)), output);
+ 5,
+ this->enum_type(static_cast<int>(i)),
+ output);
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->service_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 6, this->service(static_cast<int>(i)), output);
+ 6,
+ this->service(static_cast<int>(i)),
+ output);
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->extension_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 7, this->extension(static_cast<int>(i)), output);
+ 7,
+ this->extension(static_cast<int>(i)),
+ output);
}
// optional .google.protobuf.FileOptions options = 8;
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 8, *this->options_, output);
+ 8, *options_, output);
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
if (cached_has_bits & 0x00000010u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 9, *this->source_code_info_, output);
+ 9, *source_code_info_, output);
}
// repeated int32 public_dependency = 10;
@@ -2431,14 +2432,14 @@ void FileDescriptorProto::SerializeWithCachedSizes(
if (cached_has_bits & 0x00000008u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 8, *this->options_, deterministic, target);
+ 8, *options_, deterministic, target);
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
if (cached_has_bits & 0x00000010u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 9, *this->source_code_info_, deterministic, target);
+ 9, *source_code_info_, deterministic, target);
}
// repeated int32 public_dependency = 10;
@@ -2573,14 +2574,14 @@ size_t FileDescriptorProto::ByteSizeLong() const {
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->options_);
+ *options_);
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
if (has_source_code_info()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->source_code_info_);
+ *source_code_info_);
}
}
@@ -2686,11 +2687,11 @@ void FileDescriptorProto::UnsafeArenaSwap(FileDescriptorProto* other) {
}
void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
using std::swap;
- dependency_.InternalSwap(&other->dependency_);
- message_type_.InternalSwap(&other->message_type_);
- enum_type_.InternalSwap(&other->enum_type_);
- service_.InternalSwap(&other->service_);
- extension_.InternalSwap(&other->extension_);
+ dependency_.InternalSwap(CastToBase(&other->dependency_));
+ CastToBase(&message_type_)->InternalSwap(CastToBase(&other->message_type_));
+ CastToBase(&enum_type_)->InternalSwap(CastToBase(&other->enum_type_));
+ CastToBase(&service_)->InternalSwap(CastToBase(&other->service_));
+ CastToBase(&extension_)->InternalSwap(CastToBase(&other->extension_));
public_dependency_.InternalSwap(&other->public_dependency_);
weak_dependency_.InternalSwap(&other->weak_dependency_);
name_.Swap(&other->name_);
@@ -2715,10 +2716,6 @@ void DescriptorProto_ExtensionRange::InitAsDefaultInstance() {
::google::protobuf::_DescriptorProto_ExtensionRange_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::ExtensionRangeOptions*>(
::google::protobuf::ExtensionRangeOptions::internal_default_instance());
}
-void DescriptorProto_ExtensionRange::_slow_mutable_options() {
- options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ExtensionRangeOptions >(
- GetArenaNoVirtual());
-}
void DescriptorProto_ExtensionRange::unsafe_arena_set_allocated_options(
::google::protobuf::ExtensionRangeOptions* options) {
if (GetArenaNoVirtual() == NULL) {
@@ -2809,9 +2806,6 @@ const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_in
return *internal_default_instance();
}
-DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<DescriptorProto_ExtensionRange>(arena);
-}
void DescriptorProto_ExtensionRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange)
@@ -2923,7 +2917,7 @@ void DescriptorProto_ExtensionRange::SerializeWithCachedSizes(
// optional .google.protobuf.ExtensionRangeOptions options = 3;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, *this->options_, output);
+ 3, *options_, output);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -2955,7 +2949,7 @@ void DescriptorProto_ExtensionRange::SerializeWithCachedSizes(
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 3, *this->options_, deterministic, target);
+ 3, *options_, deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -2980,7 +2974,7 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const {
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->options_);
+ *options_);
}
// optional int32 start = 1;
@@ -3172,9 +3166,6 @@ const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_inst
return *internal_default_instance();
}
-DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<DescriptorProto_ReservedRange>(arena);
-}
void DescriptorProto_ReservedRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange)
@@ -3424,10 +3415,6 @@ void DescriptorProto::InitAsDefaultInstance() {
::google::protobuf::_DescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::MessageOptions*>(
::google::protobuf::MessageOptions::internal_default_instance());
}
-void DescriptorProto::_slow_mutable_options() {
- options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::MessageOptions >(
- GetArenaNoVirtual());
-}
void DescriptorProto::unsafe_arena_set_allocated_options(
::google::protobuf::MessageOptions* options) {
if (GetArenaNoVirtual() == NULL) {
@@ -3543,9 +3530,6 @@ const DescriptorProto& DescriptorProto::default_instance() {
return *internal_default_instance();
}
-DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<DescriptorProto>(arena);
-}
void DescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto)
@@ -3606,7 +3590,8 @@ bool DescriptorProto::MergePartialFromCodedStream(
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_field()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_field()));
} else {
goto handle_unusual;
}
@@ -3617,7 +3602,8 @@ bool DescriptorProto::MergePartialFromCodedStream(
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_nested_type()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_nested_type()));
} else {
goto handle_unusual;
}
@@ -3628,7 +3614,8 @@ bool DescriptorProto::MergePartialFromCodedStream(
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_enum_type()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_enum_type()));
} else {
goto handle_unusual;
}
@@ -3639,7 +3626,8 @@ bool DescriptorProto::MergePartialFromCodedStream(
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_extension_range()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_extension_range()));
} else {
goto handle_unusual;
}
@@ -3650,7 +3638,8 @@ bool DescriptorProto::MergePartialFromCodedStream(
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_extension()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_extension()));
} else {
goto handle_unusual;
}
@@ -3673,7 +3662,8 @@ bool DescriptorProto::MergePartialFromCodedStream(
case 8: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(66u /* 66 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_oneof_decl()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_oneof_decl()));
} else {
goto handle_unusual;
}
@@ -3684,7 +3674,8 @@ bool DescriptorProto::MergePartialFromCodedStream(
case 9: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(74u /* 74 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_reserved_range()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_reserved_range()));
} else {
goto handle_unusual;
}
@@ -3749,55 +3740,69 @@ void DescriptorProto::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->field_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, this->field(static_cast<int>(i)), output);
+ 2,
+ this->field(static_cast<int>(i)),
+ output);
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->nested_type_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, this->nested_type(static_cast<int>(i)), output);
+ 3,
+ this->nested_type(static_cast<int>(i)),
+ output);
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->enum_type_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 4, this->enum_type(static_cast<int>(i)), output);
+ 4,
+ this->enum_type(static_cast<int>(i)),
+ output);
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->extension_range_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 5, this->extension_range(static_cast<int>(i)), output);
+ 5,
+ this->extension_range(static_cast<int>(i)),
+ output);
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->extension_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 6, this->extension(static_cast<int>(i)), output);
+ 6,
+ this->extension(static_cast<int>(i)),
+ output);
}
// optional .google.protobuf.MessageOptions options = 7;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 7, *this->options_, output);
+ 7, *options_, output);
}
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->oneof_decl_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 8, this->oneof_decl(static_cast<int>(i)), output);
+ 8,
+ this->oneof_decl(static_cast<int>(i)),
+ output);
}
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->reserved_range_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 9, this->reserved_range(static_cast<int>(i)), output);
+ 9,
+ this->reserved_range(static_cast<int>(i)),
+ output);
}
// repeated string reserved_name = 10;
@@ -3880,7 +3885,7 @@ void DescriptorProto::SerializeWithCachedSizes(
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 7, *this->options_, deterministic, target);
+ 7, *options_, deterministic, target);
}
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
@@ -4023,7 +4028,7 @@ size_t DescriptorProto::ByteSizeLong() const {
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->options_);
+ *options_);
}
}
@@ -4123,14 +4128,14 @@ void DescriptorProto::UnsafeArenaSwap(DescriptorProto* other) {
}
void DescriptorProto::InternalSwap(DescriptorProto* other) {
using std::swap;
- field_.InternalSwap(&other->field_);
- nested_type_.InternalSwap(&other->nested_type_);
- enum_type_.InternalSwap(&other->enum_type_);
- extension_range_.InternalSwap(&other->extension_range_);
- extension_.InternalSwap(&other->extension_);
- oneof_decl_.InternalSwap(&other->oneof_decl_);
- reserved_range_.InternalSwap(&other->reserved_range_);
- reserved_name_.InternalSwap(&other->reserved_name_);
+ CastToBase(&field_)->InternalSwap(CastToBase(&other->field_));
+ CastToBase(&nested_type_)->InternalSwap(CastToBase(&other->nested_type_));
+ CastToBase(&enum_type_)->InternalSwap(CastToBase(&other->enum_type_));
+ CastToBase(&extension_range_)->InternalSwap(CastToBase(&other->extension_range_));
+ CastToBase(&extension_)->InternalSwap(CastToBase(&other->extension_));
+ CastToBase(&oneof_decl_)->InternalSwap(CastToBase(&other->oneof_decl_));
+ CastToBase(&reserved_range_)->InternalSwap(CastToBase(&other->reserved_range_));
+ reserved_name_.InternalSwap(CastToBase(&other->reserved_name_));
name_.Swap(&other->name_);
swap(options_, other->options_);
swap(_has_bits_[0], other->_has_bits_[0]);
@@ -4215,9 +4220,6 @@ const ExtensionRangeOptions& ExtensionRangeOptions::default_instance() {
return *internal_default_instance();
}
-ExtensionRangeOptions* ExtensionRangeOptions::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<ExtensionRangeOptions>(arena);
-}
void ExtensionRangeOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ExtensionRangeOptions)
@@ -4245,7 +4247,8 @@ bool ExtensionRangeOptions::MergePartialFromCodedStream(
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_uninterpreted_option()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
@@ -4288,7 +4291,9 @@ void ExtensionRangeOptions::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 999, this->uninterpreted_option(static_cast<int>(i)), output);
+ 999,
+ this->uninterpreted_option(static_cast<int>(i)),
+ output);
}
// Extension range [1000, 536870912)
@@ -4428,7 +4433,7 @@ void ExtensionRangeOptions::UnsafeArenaSwap(ExtensionRangeOptions* other) {
}
void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) {
using std::swap;
- uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
+ CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_));
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
@@ -4447,10 +4452,6 @@ void FieldDescriptorProto::InitAsDefaultInstance() {
::google::protobuf::_FieldDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::FieldOptions*>(
::google::protobuf::FieldOptions::internal_default_instance());
}
-void FieldDescriptorProto::_slow_mutable_options() {
- options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::FieldOptions >(
- GetArenaNoVirtual());
-}
void FieldDescriptorProto::unsafe_arena_set_allocated_options(
::google::protobuf::FieldOptions* options) {
if (GetArenaNoVirtual() == NULL) {
@@ -4585,9 +4586,6 @@ const FieldDescriptorProto& FieldDescriptorProto::default_instance() {
return *internal_default_instance();
}
-FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<FieldDescriptorProto>(arena);
-}
void FieldDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto)
@@ -4892,7 +4890,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes(
// optional .google.protobuf.FieldOptions options = 8;
if (cached_has_bits & 0x00000020u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 8, *this->options_, output);
+ 8, *options_, output);
}
// optional int32 oneof_index = 9;
@@ -4990,7 +4988,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes(
if (cached_has_bits & 0x00000020u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 8, *this->options_, deterministic, target);
+ 8, *options_, deterministic, target);
}
// optional int32 oneof_index = 9;
@@ -5066,7 +5064,7 @@ size_t FieldDescriptorProto::ByteSizeLong() const {
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->options_);
+ *options_);
}
// optional int32 number = 3;
@@ -5235,10 +5233,6 @@ void OneofDescriptorProto::InitAsDefaultInstance() {
::google::protobuf::_OneofDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::OneofOptions*>(
::google::protobuf::OneofOptions::internal_default_instance());
}
-void OneofDescriptorProto::_slow_mutable_options() {
- options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::OneofOptions >(
- GetArenaNoVirtual());
-}
void OneofDescriptorProto::unsafe_arena_set_allocated_options(
::google::protobuf::OneofOptions* options) {
if (GetArenaNoVirtual() == NULL) {
@@ -5330,9 +5324,6 @@ const OneofDescriptorProto& OneofDescriptorProto::default_instance() {
return *internal_default_instance();
}
-OneofDescriptorProto* OneofDescriptorProto::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<OneofDescriptorProto>(arena);
-}
void OneofDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.OneofDescriptorProto)
@@ -5433,7 +5424,7 @@ void OneofDescriptorProto::SerializeWithCachedSizes(
// optional .google.protobuf.OneofOptions options = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, *this->options_, output);
+ 2, *options_, output);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -5466,7 +5457,7 @@ void OneofDescriptorProto::SerializeWithCachedSizes(
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 2, *this->options_, deterministic, target);
+ 2, *options_, deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -5498,7 +5489,7 @@ size_t OneofDescriptorProto::ByteSizeLong() const {
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->options_);
+ *options_);
}
}
@@ -5671,9 +5662,6 @@ const EnumDescriptorProto_EnumReservedRange& EnumDescriptorProto_EnumReservedRan
return *internal_default_instance();
}
-EnumDescriptorProto_EnumReservedRange* EnumDescriptorProto_EnumReservedRange::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<EnumDescriptorProto_EnumReservedRange>(arena);
-}
void EnumDescriptorProto_EnumReservedRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto.EnumReservedRange)
@@ -5923,10 +5911,6 @@ void EnumDescriptorProto::InitAsDefaultInstance() {
::google::protobuf::_EnumDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::EnumOptions*>(
::google::protobuf::EnumOptions::internal_default_instance());
}
-void EnumDescriptorProto::_slow_mutable_options() {
- options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::EnumOptions >(
- GetArenaNoVirtual());
-}
void EnumDescriptorProto::unsafe_arena_set_allocated_options(
::google::protobuf::EnumOptions* options) {
if (GetArenaNoVirtual() == NULL) {
@@ -6027,9 +6011,6 @@ const EnumDescriptorProto& EnumDescriptorProto::default_instance() {
return *internal_default_instance();
}
-EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<EnumDescriptorProto>(arena);
-}
void EnumDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto)
@@ -6085,7 +6066,8 @@ bool EnumDescriptorProto::MergePartialFromCodedStream(
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_value()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_value()));
} else {
goto handle_unusual;
}
@@ -6108,7 +6090,8 @@ bool EnumDescriptorProto::MergePartialFromCodedStream(
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_reserved_range()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_reserved_range()));
} else {
goto handle_unusual;
}
@@ -6173,20 +6156,24 @@ void EnumDescriptorProto::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->value_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, this->value(static_cast<int>(i)), output);
+ 2,
+ this->value(static_cast<int>(i)),
+ output);
}
// optional .google.protobuf.EnumOptions options = 3;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, *this->options_, output);
+ 3, *options_, output);
}
// repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->reserved_range_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 4, this->reserved_range(static_cast<int>(i)), output);
+ 4,
+ this->reserved_range(static_cast<int>(i)),
+ output);
}
// repeated string reserved_name = 5;
@@ -6237,7 +6224,7 @@ void EnumDescriptorProto::SerializeWithCachedSizes(
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 3, *this->options_, deterministic, target);
+ 3, *options_, deterministic, target);
}
// repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4;
@@ -6317,7 +6304,7 @@ size_t EnumDescriptorProto::ByteSizeLong() const {
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->options_);
+ *options_);
}
}
@@ -6407,9 +6394,9 @@ void EnumDescriptorProto::UnsafeArenaSwap(EnumDescriptorProto* other) {
}
void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
using std::swap;
- value_.InternalSwap(&other->value_);
- reserved_range_.InternalSwap(&other->reserved_range_);
- reserved_name_.InternalSwap(&other->reserved_name_);
+ CastToBase(&value_)->InternalSwap(CastToBase(&other->value_));
+ CastToBase(&reserved_range_)->InternalSwap(CastToBase(&other->reserved_range_));
+ reserved_name_.InternalSwap(CastToBase(&other->reserved_name_));
name_.Swap(&other->name_);
swap(options_, other->options_);
swap(_has_bits_[0], other->_has_bits_[0]);
@@ -6429,10 +6416,6 @@ void EnumValueDescriptorProto::InitAsDefaultInstance() {
::google::protobuf::_EnumValueDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::EnumValueOptions*>(
::google::protobuf::EnumValueOptions::internal_default_instance());
}
-void EnumValueDescriptorProto::_slow_mutable_options() {
- options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::EnumValueOptions >(
- GetArenaNoVirtual());
-}
void EnumValueDescriptorProto::unsafe_arena_set_allocated_options(
::google::protobuf::EnumValueOptions* options) {
if (GetArenaNoVirtual() == NULL) {
@@ -6528,9 +6511,6 @@ const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() {
return *internal_default_instance();
}
-EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<EnumValueDescriptorProto>(arena);
-}
void EnumValueDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueDescriptorProto)
@@ -6651,7 +6631,7 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes(
// optional .google.protobuf.EnumValueOptions options = 3;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, *this->options_, output);
+ 3, *options_, output);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -6689,7 +6669,7 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes(
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 3, *this->options_, deterministic, target);
+ 3, *options_, deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -6721,7 +6701,7 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const {
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->options_);
+ *options_);
}
// optional int32 number = 2;
@@ -6838,10 +6818,6 @@ void ServiceDescriptorProto::InitAsDefaultInstance() {
::google::protobuf::_ServiceDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::ServiceOptions*>(
::google::protobuf::ServiceOptions::internal_default_instance());
}
-void ServiceDescriptorProto::_slow_mutable_options() {
- options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ServiceOptions >(
- GetArenaNoVirtual());
-}
void ServiceDescriptorProto::unsafe_arena_set_allocated_options(
::google::protobuf::ServiceOptions* options) {
if (GetArenaNoVirtual() == NULL) {
@@ -6936,9 +6912,6 @@ const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() {
return *internal_default_instance();
}
-ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<ServiceDescriptorProto>(arena);
-}
void ServiceDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceDescriptorProto)
@@ -6992,7 +6965,8 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream(
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_method()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_method()));
} else {
goto handle_unusual;
}
@@ -7052,13 +7026,15 @@ void ServiceDescriptorProto::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->method_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, this->method(static_cast<int>(i)), output);
+ 2,
+ this->method(static_cast<int>(i)),
+ output);
}
// optional .google.protobuf.ServiceOptions options = 3;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, *this->options_, output);
+ 3, *options_, output);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -7099,7 +7075,7 @@ void ServiceDescriptorProto::SerializeWithCachedSizes(
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 3, *this->options_, deterministic, target);
+ 3, *options_, deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -7142,7 +7118,7 @@ size_t ServiceDescriptorProto::ByteSizeLong() const {
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->options_);
+ *options_);
}
}
@@ -7230,7 +7206,7 @@ void ServiceDescriptorProto::UnsafeArenaSwap(ServiceDescriptorProto* other) {
}
void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
using std::swap;
- method_.InternalSwap(&other->method_);
+ CastToBase(&method_)->InternalSwap(CastToBase(&other->method_));
name_.Swap(&other->name_);
swap(options_, other->options_);
swap(_has_bits_[0], other->_has_bits_[0]);
@@ -7250,10 +7226,6 @@ void MethodDescriptorProto::InitAsDefaultInstance() {
::google::protobuf::_MethodDescriptorProto_default_instance_._instance.get_mutable()->options_ = const_cast< ::google::protobuf::MethodOptions*>(
::google::protobuf::MethodOptions::internal_default_instance());
}
-void MethodDescriptorProto::_slow_mutable_options() {
- options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::MethodOptions >(
- GetArenaNoVirtual());
-}
void MethodDescriptorProto::unsafe_arena_set_allocated_options(
::google::protobuf::MethodOptions* options) {
if (GetArenaNoVirtual() == NULL) {
@@ -7368,9 +7340,6 @@ const MethodDescriptorProto& MethodDescriptorProto::default_instance() {
return *internal_default_instance();
}
-MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<MethodDescriptorProto>(arena);
-}
void MethodDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto)
@@ -7562,7 +7531,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes(
// optional .google.protobuf.MethodOptions options = 4;
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 4, *this->options_, output);
+ 4, *options_, output);
}
// optional bool client_streaming = 5 [default = false];
@@ -7627,7 +7596,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes(
if (cached_has_bits & 0x00000008u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 4, *this->options_, deterministic, target);
+ 4, *options_, deterministic, target);
}
// optional bool client_streaming = 5 [default = false];
@@ -7683,7 +7652,7 @@ size_t MethodDescriptorProto::ByteSizeLong() const {
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->options_);
+ *options_);
}
// optional bool client_streaming = 5 [default = false];
@@ -7961,9 +7930,6 @@ const FileOptions& FileOptions::default_instance() {
return *internal_default_instance();
}
-FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<FileOptions>(arena);
-}
void FileOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions)
@@ -8309,7 +8275,8 @@ bool FileOptions::MergePartialFromCodedStream(
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_uninterpreted_option()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
@@ -8484,7 +8451,9 @@ void FileOptions::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 999, this->uninterpreted_option(static_cast<int>(i)), output);
+ 999,
+ this->uninterpreted_option(static_cast<int>(i)),
+ output);
}
// Extension range [1000, 536870912)
@@ -8940,7 +8909,7 @@ void FileOptions::UnsafeArenaSwap(FileOptions* other) {
}
void FileOptions::InternalSwap(FileOptions* other) {
using std::swap;
- uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
+ CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_));
java_package_.Swap(&other->java_package_);
java_outer_classname_.Swap(&other->java_outer_classname_);
go_package_.Swap(&other->go_package_);
@@ -9052,9 +9021,6 @@ const MessageOptions& MessageOptions::default_instance() {
return *internal_default_instance();
}
-MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<MessageOptions>(arena);
-}
void MessageOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions)
@@ -9141,7 +9107,8 @@ bool MessageOptions::MergePartialFromCodedStream(
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_uninterpreted_option()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
@@ -9205,7 +9172,9 @@ void MessageOptions::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 999, this->uninterpreted_option(static_cast<int>(i)), output);
+ 999,
+ this->uninterpreted_option(static_cast<int>(i)),
+ output);
}
// Extension range [1000, 536870912)
@@ -9404,7 +9373,7 @@ void MessageOptions::UnsafeArenaSwap(MessageOptions* other) {
}
void MessageOptions::InternalSwap(MessageOptions* other) {
using std::swap;
- uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
+ CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_));
swap(message_set_wire_format_, other->message_set_wire_format_);
swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_);
swap(deprecated_, other->deprecated_);
@@ -9504,9 +9473,6 @@ const FieldOptions& FieldOptions::default_instance() {
return *internal_default_instance();
}
-FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<FieldOptions>(arena);
-}
void FieldOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions)
@@ -9636,7 +9602,8 @@ bool FieldOptions::MergePartialFromCodedStream(
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_uninterpreted_option()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
@@ -9712,7 +9679,9 @@ void FieldOptions::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 999, this->uninterpreted_option(static_cast<int>(i)), output);
+ 999,
+ this->uninterpreted_option(static_cast<int>(i)),
+ output);
}
// Extension range [1000, 536870912)
@@ -9941,7 +9910,7 @@ void FieldOptions::UnsafeArenaSwap(FieldOptions* other) {
}
void FieldOptions::InternalSwap(FieldOptions* other) {
using std::swap;
- uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
+ CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_));
swap(ctype_, other->ctype_);
swap(packed_, other->packed_);
swap(lazy_, other->lazy_);
@@ -10031,9 +10000,6 @@ const OneofOptions& OneofOptions::default_instance() {
return *internal_default_instance();
}
-OneofOptions* OneofOptions::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<OneofOptions>(arena);
-}
void OneofOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.OneofOptions)
@@ -10061,7 +10027,8 @@ bool OneofOptions::MergePartialFromCodedStream(
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_uninterpreted_option()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
@@ -10104,7 +10071,9 @@ void OneofOptions::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 999, this->uninterpreted_option(static_cast<int>(i)), output);
+ 999,
+ this->uninterpreted_option(static_cast<int>(i)),
+ output);
}
// Extension range [1000, 536870912)
@@ -10244,7 +10213,7 @@ void OneofOptions::UnsafeArenaSwap(OneofOptions* other) {
}
void OneofOptions::InternalSwap(OneofOptions* other) {
using std::swap;
- uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
+ CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_));
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
@@ -10336,9 +10305,6 @@ const EnumOptions& EnumOptions::default_instance() {
return *internal_default_instance();
}
-EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<EnumOptions>(arena);
-}
void EnumOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions)
@@ -10397,7 +10363,8 @@ bool EnumOptions::MergePartialFromCodedStream(
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_uninterpreted_option()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
@@ -10451,7 +10418,9 @@ void EnumOptions::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 999, this->uninterpreted_option(static_cast<int>(i)), output);
+ 999,
+ this->uninterpreted_option(static_cast<int>(i)),
+ output);
}
// Extension range [1000, 536870912)
@@ -10624,7 +10593,7 @@ void EnumOptions::UnsafeArenaSwap(EnumOptions* other) {
}
void EnumOptions::InternalSwap(EnumOptions* other) {
using std::swap;
- uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
+ CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_));
swap(allow_alias_, other->allow_alias_);
swap(deprecated_, other->deprecated_);
swap(_has_bits_[0], other->_has_bits_[0]);
@@ -10713,9 +10682,6 @@ const EnumValueOptions& EnumValueOptions::default_instance() {
return *internal_default_instance();
}
-EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<EnumValueOptions>(arena);
-}
void EnumValueOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueOptions)
@@ -10758,7 +10724,8 @@ bool EnumValueOptions::MergePartialFromCodedStream(
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_uninterpreted_option()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
@@ -10807,7 +10774,9 @@ void EnumValueOptions::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 999, this->uninterpreted_option(static_cast<int>(i)), output);
+ 999,
+ this->uninterpreted_option(static_cast<int>(i)),
+ output);
}
// Extension range [1000, 536870912)
@@ -10961,7 +10930,7 @@ void EnumValueOptions::UnsafeArenaSwap(EnumValueOptions* other) {
}
void EnumValueOptions::InternalSwap(EnumValueOptions* other) {
using std::swap;
- uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
+ CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_));
swap(deprecated_, other->deprecated_);
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
@@ -11049,9 +11018,6 @@ const ServiceOptions& ServiceOptions::default_instance() {
return *internal_default_instance();
}
-ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<ServiceOptions>(arena);
-}
void ServiceOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceOptions)
@@ -11094,7 +11060,8 @@ bool ServiceOptions::MergePartialFromCodedStream(
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_uninterpreted_option()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
@@ -11143,7 +11110,9 @@ void ServiceOptions::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 999, this->uninterpreted_option(static_cast<int>(i)), output);
+ 999,
+ this->uninterpreted_option(static_cast<int>(i)),
+ output);
}
// Extension range [1000, 536870912)
@@ -11297,7 +11266,7 @@ void ServiceOptions::UnsafeArenaSwap(ServiceOptions* other) {
}
void ServiceOptions::InternalSwap(ServiceOptions* other) {
using std::swap;
- uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
+ CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_));
swap(deprecated_, other->deprecated_);
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
@@ -11390,9 +11359,6 @@ const MethodOptions& MethodOptions::default_instance() {
return *internal_default_instance();
}
-MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<MethodOptions>(arena);
-}
void MethodOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodOptions)
@@ -11460,7 +11426,8 @@ bool MethodOptions::MergePartialFromCodedStream(
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u /* 7994 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_uninterpreted_option()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
@@ -11515,7 +11482,9 @@ void MethodOptions::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 999, this->uninterpreted_option(static_cast<int>(i)), output);
+ 999,
+ this->uninterpreted_option(static_cast<int>(i)),
+ output);
}
// Extension range [1000, 536870912)
@@ -11690,7 +11659,7 @@ void MethodOptions::UnsafeArenaSwap(MethodOptions* other) {
}
void MethodOptions::InternalSwap(MethodOptions* other) {
using std::swap;
- uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
+ CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_));
swap(deprecated_, other->deprecated_);
swap(idempotency_level_, other->idempotency_level_);
swap(_has_bits_[0], other->_has_bits_[0]);
@@ -11782,9 +11751,6 @@ const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instan
return *internal_default_instance();
}
-UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<UninterpretedOption_NamePart>(arena);
-}
void UninterpretedOption_NamePart::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption.NamePart)
@@ -12158,9 +12124,6 @@ const UninterpretedOption& UninterpretedOption::default_instance() {
return *internal_default_instance();
}
-UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<UninterpretedOption>(arena);
-}
void UninterpretedOption::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption)
@@ -12207,7 +12170,8 @@ bool UninterpretedOption::MergePartialFromCodedStream(
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_name()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_name()));
} else {
goto handle_unusual;
}
@@ -12330,7 +12294,9 @@ void UninterpretedOption::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->name_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, this->name(static_cast<int>(i)), output);
+ 2,
+ this->name(static_cast<int>(i)),
+ output);
}
cached_has_bits = _has_bits_[0];
@@ -12606,7 +12572,7 @@ void UninterpretedOption::UnsafeArenaSwap(UninterpretedOption* other) {
}
void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
using std::swap;
- name_.InternalSwap(&other->name_);
+ CastToBase(&name_)->InternalSwap(CastToBase(&other->name_));
identifier_value_.Swap(&other->identifier_value_);
string_value_.Swap(&other->string_value_);
aggregate_value_.Swap(&other->aggregate_value_);
@@ -12715,9 +12681,6 @@ const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() {
return *internal_default_instance();
}
-SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<SourceCodeInfo_Location>(arena);
-}
void SourceCodeInfo_Location::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo.Location)
@@ -13149,7 +13112,7 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {
using std::swap;
path_.InternalSwap(&other->path_);
span_.InternalSwap(&other->span_);
- leading_detached_comments_.InternalSwap(&other->leading_detached_comments_);
+ leading_detached_comments_.InternalSwap(CastToBase(&other->leading_detached_comments_));
leading_comments_.Swap(&other->leading_comments_);
trailing_comments_.Swap(&other->trailing_comments_);
swap(_has_bits_[0], other->_has_bits_[0]);
@@ -13232,9 +13195,6 @@ const SourceCodeInfo& SourceCodeInfo::default_instance() {
return *internal_default_instance();
}
-SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<SourceCodeInfo>(arena);
-}
void SourceCodeInfo::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo)
@@ -13261,7 +13221,8 @@ bool SourceCodeInfo::MergePartialFromCodedStream(
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_location()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_location()));
} else {
goto handle_unusual;
}
@@ -13298,7 +13259,9 @@ void SourceCodeInfo::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->location_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1, this->location(static_cast<int>(i)), output);
+ 1,
+ this->location(static_cast<int>(i)),
+ output);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -13422,7 +13385,7 @@ void SourceCodeInfo::UnsafeArenaSwap(SourceCodeInfo* other) {
}
void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) {
using std::swap;
- location_.InternalSwap(&other->location_);
+ CastToBase(&location_)->InternalSwap(CastToBase(&other->location_));
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
@@ -13519,9 +13482,6 @@ const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instan
return *internal_default_instance();
}
-GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<GeneratedCodeInfo_Annotation>(arena);
-}
void GeneratedCodeInfo_Annotation::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation)
@@ -13948,9 +13908,6 @@ const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() {
return *internal_default_instance();
}
-GeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<GeneratedCodeInfo>(arena);
-}
void GeneratedCodeInfo::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo)
@@ -13977,7 +13934,8 @@ bool GeneratedCodeInfo::MergePartialFromCodedStream(
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_annotation()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_annotation()));
} else {
goto handle_unusual;
}
@@ -14014,7 +13972,9 @@ void GeneratedCodeInfo::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->annotation_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1, this->annotation(static_cast<int>(i)), output);
+ 1,
+ this->annotation(static_cast<int>(i)),
+ output);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -14138,7 +14098,7 @@ void GeneratedCodeInfo::UnsafeArenaSwap(GeneratedCodeInfo* other) {
}
void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {
using std::swap;
- annotation_.InternalSwap(&other->annotation_);
+ CastToBase(&annotation_)->InternalSwap(CastToBase(&other->annotation_));
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
@@ -14153,5 +14113,90 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FileDescriptorSet* Arena::CreateMessage< ::google::protobuf::FileDescriptorSet >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::FileDescriptorSet >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FileDescriptorProto* Arena::CreateMessage< ::google::protobuf::FileDescriptorProto >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::FileDescriptorProto >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DescriptorProto_ExtensionRange* Arena::CreateMessage< ::google::protobuf::DescriptorProto_ExtensionRange >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::DescriptorProto_ExtensionRange >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DescriptorProto_ReservedRange* Arena::CreateMessage< ::google::protobuf::DescriptorProto_ReservedRange >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::DescriptorProto_ReservedRange >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DescriptorProto* Arena::CreateMessage< ::google::protobuf::DescriptorProto >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::DescriptorProto >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ExtensionRangeOptions* Arena::CreateMessage< ::google::protobuf::ExtensionRangeOptions >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::ExtensionRangeOptions >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FieldDescriptorProto* Arena::CreateMessage< ::google::protobuf::FieldDescriptorProto >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::FieldDescriptorProto >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::OneofDescriptorProto* Arena::CreateMessage< ::google::protobuf::OneofDescriptorProto >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::OneofDescriptorProto >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumDescriptorProto_EnumReservedRange* Arena::CreateMessage< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumDescriptorProto* Arena::CreateMessage< ::google::protobuf::EnumDescriptorProto >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::EnumDescriptorProto >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumValueDescriptorProto* Arena::CreateMessage< ::google::protobuf::EnumValueDescriptorProto >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::EnumValueDescriptorProto >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ServiceDescriptorProto* Arena::CreateMessage< ::google::protobuf::ServiceDescriptorProto >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::ServiceDescriptorProto >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::MethodDescriptorProto* Arena::CreateMessage< ::google::protobuf::MethodDescriptorProto >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::MethodDescriptorProto >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FileOptions* Arena::CreateMessage< ::google::protobuf::FileOptions >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::FileOptions >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::MessageOptions* Arena::CreateMessage< ::google::protobuf::MessageOptions >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::MessageOptions >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FieldOptions* Arena::CreateMessage< ::google::protobuf::FieldOptions >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::FieldOptions >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::OneofOptions* Arena::CreateMessage< ::google::protobuf::OneofOptions >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::OneofOptions >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumOptions* Arena::CreateMessage< ::google::protobuf::EnumOptions >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::EnumOptions >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumValueOptions* Arena::CreateMessage< ::google::protobuf::EnumValueOptions >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::EnumValueOptions >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ServiceOptions* Arena::CreateMessage< ::google::protobuf::ServiceOptions >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::ServiceOptions >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::MethodOptions* Arena::CreateMessage< ::google::protobuf::MethodOptions >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::MethodOptions >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UninterpretedOption_NamePart* Arena::CreateMessage< ::google::protobuf::UninterpretedOption_NamePart >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::UninterpretedOption_NamePart >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UninterpretedOption* Arena::CreateMessage< ::google::protobuf::UninterpretedOption >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::UninterpretedOption >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::SourceCodeInfo_Location* Arena::CreateMessage< ::google::protobuf::SourceCodeInfo_Location >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::SourceCodeInfo_Location >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::SourceCodeInfo* Arena::CreateMessage< ::google::protobuf::SourceCodeInfo >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::SourceCodeInfo >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::GeneratedCodeInfo_Annotation* Arena::CreateMessage< ::google::protobuf::GeneratedCodeInfo_Annotation >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::GeneratedCodeInfo_Annotation >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::GeneratedCodeInfo* Arena::CreateMessage< ::google::protobuf::GeneratedCodeInfo >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::GeneratedCodeInfo >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h
index ee3ad7d7..2eecfa29 100644
--- a/src/google/protobuf/descriptor.pb.h
+++ b/src/google/protobuf/descriptor.pb.h
@@ -214,6 +214,37 @@ LIBPROTOBUF_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _Unint
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::DescriptorProto* Arena::CreateMessage< ::google::protobuf::DescriptorProto>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::DescriptorProto_ExtensionRange* Arena::CreateMessage< ::google::protobuf::DescriptorProto_ExtensionRange>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::DescriptorProto_ReservedRange* Arena::CreateMessage< ::google::protobuf::DescriptorProto_ReservedRange>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumDescriptorProto* Arena::CreateMessage< ::google::protobuf::EnumDescriptorProto>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumDescriptorProto_EnumReservedRange* Arena::CreateMessage< ::google::protobuf::EnumDescriptorProto_EnumReservedRange>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumOptions* Arena::CreateMessage< ::google::protobuf::EnumOptions>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumValueDescriptorProto* Arena::CreateMessage< ::google::protobuf::EnumValueDescriptorProto>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumValueOptions* Arena::CreateMessage< ::google::protobuf::EnumValueOptions>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::ExtensionRangeOptions* Arena::CreateMessage< ::google::protobuf::ExtensionRangeOptions>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::FieldDescriptorProto* Arena::CreateMessage< ::google::protobuf::FieldDescriptorProto>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::FieldOptions* Arena::CreateMessage< ::google::protobuf::FieldOptions>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::FileDescriptorProto* Arena::CreateMessage< ::google::protobuf::FileDescriptorProto>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::FileDescriptorSet* Arena::CreateMessage< ::google::protobuf::FileDescriptorSet>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::FileOptions* Arena::CreateMessage< ::google::protobuf::FileOptions>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::GeneratedCodeInfo* Arena::CreateMessage< ::google::protobuf::GeneratedCodeInfo>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::GeneratedCodeInfo_Annotation* Arena::CreateMessage< ::google::protobuf::GeneratedCodeInfo_Annotation>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::MessageOptions* Arena::CreateMessage< ::google::protobuf::MessageOptions>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::MethodDescriptorProto* Arena::CreateMessage< ::google::protobuf::MethodDescriptorProto>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::MethodOptions* Arena::CreateMessage< ::google::protobuf::MethodOptions>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::OneofDescriptorProto* Arena::CreateMessage< ::google::protobuf::OneofDescriptorProto>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::OneofOptions* Arena::CreateMessage< ::google::protobuf::OneofOptions>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::ServiceDescriptorProto* Arena::CreateMessage< ::google::protobuf::ServiceDescriptorProto>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::ServiceOptions* Arena::CreateMessage< ::google::protobuf::ServiceOptions>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::SourceCodeInfo* Arena::CreateMessage< ::google::protobuf::SourceCodeInfo>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::SourceCodeInfo_Location* Arena::CreateMessage< ::google::protobuf::SourceCodeInfo_Location>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::UninterpretedOption* Arena::CreateMessage< ::google::protobuf::UninterpretedOption>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::UninterpretedOption_NamePart* Arena::CreateMessage< ::google::protobuf::UninterpretedOption_NamePart>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
enum FieldDescriptorProto_Type {
FieldDescriptorProto_Type_TYPE_DOUBLE = 1,
@@ -410,9 +441,13 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message
// implements Message ----------------------------------------------
- inline FileDescriptorSet* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline FileDescriptorSet* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FileDescriptorSet>(NULL);
+ }
- FileDescriptorSet* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ FileDescriptorSet* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FileDescriptorSet>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FileDescriptorSet& from);
@@ -457,11 +492,11 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message
int file_size() const;
void clear_file();
static const int kFileFieldNumber = 1;
- const ::google::protobuf::FileDescriptorProto& file(int index) const;
::google::protobuf::FileDescriptorProto* mutable_file(int index);
- ::google::protobuf::FileDescriptorProto* add_file();
::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*
mutable_file();
+ const ::google::protobuf::FileDescriptorProto& file(int index) const;
+ ::google::protobuf::FileDescriptorProto* add_file();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&
file() const;
@@ -538,9 +573,13 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
// implements Message ----------------------------------------------
- inline FileDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline FileDescriptorProto* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FileDescriptorProto>(NULL);
+ }
- FileDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ FileDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FileDescriptorProto>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FileDescriptorProto& from);
@@ -607,11 +646,11 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
int message_type_size() const;
void clear_message_type();
static const int kMessageTypeFieldNumber = 4;
- const ::google::protobuf::DescriptorProto& message_type(int index) const;
::google::protobuf::DescriptorProto* mutable_message_type(int index);
- ::google::protobuf::DescriptorProto* add_message_type();
::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*
mutable_message_type();
+ const ::google::protobuf::DescriptorProto& message_type(int index) const;
+ ::google::protobuf::DescriptorProto* add_message_type();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&
message_type() const;
@@ -619,11 +658,11 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
int enum_type_size() const;
void clear_enum_type();
static const int kEnumTypeFieldNumber = 5;
- const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const;
::google::protobuf::EnumDescriptorProto* mutable_enum_type(int index);
- ::google::protobuf::EnumDescriptorProto* add_enum_type();
::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*
mutable_enum_type();
+ const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const;
+ ::google::protobuf::EnumDescriptorProto* add_enum_type();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&
enum_type() const;
@@ -631,11 +670,11 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
int service_size() const;
void clear_service();
static const int kServiceFieldNumber = 6;
- const ::google::protobuf::ServiceDescriptorProto& service(int index) const;
::google::protobuf::ServiceDescriptorProto* mutable_service(int index);
- ::google::protobuf::ServiceDescriptorProto* add_service();
::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >*
mutable_service();
+ const ::google::protobuf::ServiceDescriptorProto& service(int index) const;
+ ::google::protobuf::ServiceDescriptorProto* add_service();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >&
service() const;
@@ -643,11 +682,11 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
int extension_size() const;
void clear_extension();
static const int kExtensionFieldNumber = 7;
- const ::google::protobuf::FieldDescriptorProto& extension(int index) const;
::google::protobuf::FieldDescriptorProto* mutable_extension(int index);
- ::google::protobuf::FieldDescriptorProto* add_extension();
::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*
mutable_extension();
+ const ::google::protobuf::FieldDescriptorProto& extension(int index) const;
+ ::google::protobuf::FieldDescriptorProto* add_extension();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&
extension() const;
@@ -751,9 +790,6 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
bool has_options() const;
void clear_options();
static const int kOptionsFieldNumber = 8;
- private:
- void _slow_mutable_options();
- public:
const ::google::protobuf::FileOptions& options() const;
::google::protobuf::FileOptions* release_options();
::google::protobuf::FileOptions* mutable_options();
@@ -766,9 +802,6 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
bool has_source_code_info() const;
void clear_source_code_info();
static const int kSourceCodeInfoFieldNumber = 9;
- private:
- void _slow_mutable_source_code_info();
- public:
const ::google::protobuf::SourceCodeInfo& source_code_info() const;
::google::protobuf::SourceCodeInfo* release_source_code_info();
::google::protobuf::SourceCodeInfo* mutable_source_code_info();
@@ -871,9 +904,13 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto
// implements Message ----------------------------------------------
- inline DescriptorProto_ExtensionRange* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline DescriptorProto_ExtensionRange* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<DescriptorProto_ExtensionRange>(NULL);
+ }
- DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<DescriptorProto_ExtensionRange>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const DescriptorProto_ExtensionRange& from);
@@ -918,9 +955,6 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto
bool has_options() const;
void clear_options();
static const int kOptionsFieldNumber = 3;
- private:
- void _slow_mutable_options();
- public:
const ::google::protobuf::ExtensionRangeOptions& options() const;
::google::protobuf::ExtensionRangeOptions* release_options();
::google::protobuf::ExtensionRangeOptions* mutable_options();
@@ -1024,9 +1058,13 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob
// implements Message ----------------------------------------------
- inline DescriptorProto_ReservedRange* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline DescriptorProto_ReservedRange* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<DescriptorProto_ReservedRange>(NULL);
+ }
- DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<DescriptorProto_ReservedRange>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const DescriptorProto_ReservedRange& from);
@@ -1159,9 +1197,13 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
// implements Message ----------------------------------------------
- inline DescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline DescriptorProto* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<DescriptorProto>(NULL);
+ }
- DescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ DescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<DescriptorProto>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const DescriptorProto& from);
@@ -1209,11 +1251,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
int field_size() const;
void clear_field();
static const int kFieldFieldNumber = 2;
- const ::google::protobuf::FieldDescriptorProto& field(int index) const;
::google::protobuf::FieldDescriptorProto* mutable_field(int index);
- ::google::protobuf::FieldDescriptorProto* add_field();
::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*
mutable_field();
+ const ::google::protobuf::FieldDescriptorProto& field(int index) const;
+ ::google::protobuf::FieldDescriptorProto* add_field();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&
field() const;
@@ -1221,11 +1263,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
int nested_type_size() const;
void clear_nested_type();
static const int kNestedTypeFieldNumber = 3;
- const ::google::protobuf::DescriptorProto& nested_type(int index) const;
::google::protobuf::DescriptorProto* mutable_nested_type(int index);
- ::google::protobuf::DescriptorProto* add_nested_type();
::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*
mutable_nested_type();
+ const ::google::protobuf::DescriptorProto& nested_type(int index) const;
+ ::google::protobuf::DescriptorProto* add_nested_type();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&
nested_type() const;
@@ -1233,11 +1275,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
int enum_type_size() const;
void clear_enum_type();
static const int kEnumTypeFieldNumber = 4;
- const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const;
::google::protobuf::EnumDescriptorProto* mutable_enum_type(int index);
- ::google::protobuf::EnumDescriptorProto* add_enum_type();
::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*
mutable_enum_type();
+ const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const;
+ ::google::protobuf::EnumDescriptorProto* add_enum_type();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&
enum_type() const;
@@ -1245,11 +1287,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
int extension_range_size() const;
void clear_extension_range();
static const int kExtensionRangeFieldNumber = 5;
- const ::google::protobuf::DescriptorProto_ExtensionRange& extension_range(int index) const;
::google::protobuf::DescriptorProto_ExtensionRange* mutable_extension_range(int index);
- ::google::protobuf::DescriptorProto_ExtensionRange* add_extension_range();
::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >*
mutable_extension_range();
+ const ::google::protobuf::DescriptorProto_ExtensionRange& extension_range(int index) const;
+ ::google::protobuf::DescriptorProto_ExtensionRange* add_extension_range();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >&
extension_range() const;
@@ -1257,11 +1299,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
int extension_size() const;
void clear_extension();
static const int kExtensionFieldNumber = 6;
- const ::google::protobuf::FieldDescriptorProto& extension(int index) const;
::google::protobuf::FieldDescriptorProto* mutable_extension(int index);
- ::google::protobuf::FieldDescriptorProto* add_extension();
::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*
mutable_extension();
+ const ::google::protobuf::FieldDescriptorProto& extension(int index) const;
+ ::google::protobuf::FieldDescriptorProto* add_extension();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&
extension() const;
@@ -1269,11 +1311,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
int oneof_decl_size() const;
void clear_oneof_decl();
static const int kOneofDeclFieldNumber = 8;
- const ::google::protobuf::OneofDescriptorProto& oneof_decl(int index) const;
::google::protobuf::OneofDescriptorProto* mutable_oneof_decl(int index);
- ::google::protobuf::OneofDescriptorProto* add_oneof_decl();
::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >*
mutable_oneof_decl();
+ const ::google::protobuf::OneofDescriptorProto& oneof_decl(int index) const;
+ ::google::protobuf::OneofDescriptorProto* add_oneof_decl();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >&
oneof_decl() const;
@@ -1281,11 +1323,11 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
int reserved_range_size() const;
void clear_reserved_range();
static const int kReservedRangeFieldNumber = 9;
- const ::google::protobuf::DescriptorProto_ReservedRange& reserved_range(int index) const;
::google::protobuf::DescriptorProto_ReservedRange* mutable_reserved_range(int index);
- ::google::protobuf::DescriptorProto_ReservedRange* add_reserved_range();
::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >*
mutable_reserved_range();
+ const ::google::protobuf::DescriptorProto_ReservedRange& reserved_range(int index) const;
+ ::google::protobuf::DescriptorProto_ReservedRange* add_reserved_range();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >&
reserved_range() const;
@@ -1339,9 +1381,6 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
bool has_options() const;
void clear_options();
static const int kOptionsFieldNumber = 7;
- private:
- void _slow_mutable_options();
- public:
const ::google::protobuf::MessageOptions& options() const;
::google::protobuf::MessageOptions* release_options();
::google::protobuf::MessageOptions* mutable_options();
@@ -1436,9 +1475,13 @@ class LIBPROTOBUF_EXPORT ExtensionRangeOptions : public ::google::protobuf::Mess
// implements Message ----------------------------------------------
- inline ExtensionRangeOptions* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline ExtensionRangeOptions* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<ExtensionRangeOptions>(NULL);
+ }
- ExtensionRangeOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ ExtensionRangeOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<ExtensionRangeOptions>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ExtensionRangeOptions& from);
@@ -1483,11 +1526,11 @@ class LIBPROTOBUF_EXPORT ExtensionRangeOptions : public ::google::protobuf::Mess
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
mutable_uninterpreted_option();
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
@@ -1567,9 +1610,13 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa
// implements Message ----------------------------------------------
- inline FieldDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline FieldDescriptorProto* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FieldDescriptorProto>(NULL);
+ }
- FieldDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ FieldDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FieldDescriptorProto>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FieldDescriptorProto& from);
@@ -1820,9 +1867,6 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa
bool has_options() const;
void clear_options();
static const int kOptionsFieldNumber = 8;
- private:
- void _slow_mutable_options();
- public:
const ::google::protobuf::FieldOptions& options() const;
::google::protobuf::FieldOptions* release_options();
::google::protobuf::FieldOptions* mutable_options();
@@ -1961,9 +2005,13 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa
// implements Message ----------------------------------------------
- inline OneofDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline OneofDescriptorProto* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<OneofDescriptorProto>(NULL);
+ }
- OneofDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ OneofDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<OneofDescriptorProto>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const OneofDescriptorProto& from);
@@ -2032,9 +2080,6 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa
bool has_options() const;
void clear_options();
static const int kOptionsFieldNumber = 2;
- private:
- void _slow_mutable_options();
- public:
const ::google::protobuf::OneofOptions& options() const;
::google::protobuf::OneofOptions* release_options();
::google::protobuf::OneofOptions* mutable_options();
@@ -2121,9 +2166,13 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : public ::google
// implements Message ----------------------------------------------
- inline EnumDescriptorProto_EnumReservedRange* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline EnumDescriptorProto_EnumReservedRange* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumDescriptorProto_EnumReservedRange>(NULL);
+ }
- EnumDescriptorProto_EnumReservedRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ EnumDescriptorProto_EnumReservedRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumDescriptorProto_EnumReservedRange>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumDescriptorProto_EnumReservedRange& from);
@@ -2256,9 +2305,13 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag
// implements Message ----------------------------------------------
- inline EnumDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline EnumDescriptorProto* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumDescriptorProto>(NULL);
+ }
- EnumDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ EnumDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumDescriptorProto>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumDescriptorProto& from);
@@ -2305,11 +2358,11 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag
int value_size() const;
void clear_value();
static const int kValueFieldNumber = 2;
- const ::google::protobuf::EnumValueDescriptorProto& value(int index) const;
::google::protobuf::EnumValueDescriptorProto* mutable_value(int index);
- ::google::protobuf::EnumValueDescriptorProto* add_value();
::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >*
mutable_value();
+ const ::google::protobuf::EnumValueDescriptorProto& value(int index) const;
+ ::google::protobuf::EnumValueDescriptorProto* add_value();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >&
value() const;
@@ -2317,11 +2370,11 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag
int reserved_range_size() const;
void clear_reserved_range();
static const int kReservedRangeFieldNumber = 4;
- const ::google::protobuf::EnumDescriptorProto_EnumReservedRange& reserved_range(int index) const;
::google::protobuf::EnumDescriptorProto_EnumReservedRange* mutable_reserved_range(int index);
- ::google::protobuf::EnumDescriptorProto_EnumReservedRange* add_reserved_range();
::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >*
mutable_reserved_range();
+ const ::google::protobuf::EnumDescriptorProto_EnumReservedRange& reserved_range(int index) const;
+ ::google::protobuf::EnumDescriptorProto_EnumReservedRange* add_reserved_range();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >&
reserved_range() const;
@@ -2375,9 +2428,6 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag
bool has_options() const;
void clear_options();
static const int kOptionsFieldNumber = 3;
- private:
- void _slow_mutable_options();
- public:
const ::google::protobuf::EnumOptions& options() const;
::google::protobuf::EnumOptions* release_options();
::google::protobuf::EnumOptions* mutable_options();
@@ -2467,9 +2517,13 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M
// implements Message ----------------------------------------------
- inline EnumValueDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline EnumValueDescriptorProto* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumValueDescriptorProto>(NULL);
+ }
- EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumValueDescriptorProto>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumValueDescriptorProto& from);
@@ -2538,9 +2592,6 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M
bool has_options() const;
void clear_options();
static const int kOptionsFieldNumber = 3;
- private:
- void _slow_mutable_options();
- public:
const ::google::protobuf::EnumValueOptions& options() const;
::google::protobuf::EnumValueOptions* release_options();
::google::protobuf::EnumValueOptions* mutable_options();
@@ -2637,9 +2688,13 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes
// implements Message ----------------------------------------------
- inline ServiceDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline ServiceDescriptorProto* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<ServiceDescriptorProto>(NULL);
+ }
- ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<ServiceDescriptorProto>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ServiceDescriptorProto& from);
@@ -2684,11 +2739,11 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes
int method_size() const;
void clear_method();
static const int kMethodFieldNumber = 2;
- const ::google::protobuf::MethodDescriptorProto& method(int index) const;
::google::protobuf::MethodDescriptorProto* mutable_method(int index);
- ::google::protobuf::MethodDescriptorProto* add_method();
::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >*
mutable_method();
+ const ::google::protobuf::MethodDescriptorProto& method(int index) const;
+ ::google::protobuf::MethodDescriptorProto* add_method();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >&
method() const;
@@ -2720,9 +2775,6 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes
bool has_options() const;
void clear_options();
static const int kOptionsFieldNumber = 3;
- private:
- void _slow_mutable_options();
- public:
const ::google::protobuf::ServiceOptions& options() const;
::google::protobuf::ServiceOptions* release_options();
::google::protobuf::ServiceOptions* mutable_options();
@@ -2810,9 +2862,13 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess
// implements Message ----------------------------------------------
- inline MethodDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline MethodDescriptorProto* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<MethodDescriptorProto>(NULL);
+ }
- MethodDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ MethodDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<MethodDescriptorProto>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const MethodDescriptorProto& from);
@@ -2929,9 +2985,6 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess
bool has_options() const;
void clear_options();
static const int kOptionsFieldNumber = 4;
- private:
- void _slow_mutable_options();
- public:
const ::google::protobuf::MethodOptions& options() const;
::google::protobuf::MethodOptions* release_options();
::google::protobuf::MethodOptions* mutable_options();
@@ -3044,9 +3097,13 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
// implements Message ----------------------------------------------
- inline FileOptions* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline FileOptions* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FileOptions>(NULL);
+ }
- FileOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ FileOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FileOptions>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FileOptions& from);
@@ -3119,11 +3176,11 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
mutable_uninterpreted_option();
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
@@ -3519,9 +3576,13 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /*
// implements Message ----------------------------------------------
- inline MessageOptions* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline MessageOptions* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<MessageOptions>(NULL);
+ }
- MessageOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ MessageOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<MessageOptions>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const MessageOptions& from);
@@ -3566,11 +3627,11 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /*
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
mutable_uninterpreted_option();
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
@@ -3690,9 +3751,13 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@
// implements Message ----------------------------------------------
- inline FieldOptions* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline FieldOptions* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FieldOptions>(NULL);
+ }
- FieldOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ FieldOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FieldOptions>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FieldOptions& from);
@@ -3793,11 +3858,11 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
mutable_uninterpreted_option();
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
@@ -3937,9 +4002,13 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@
// implements Message ----------------------------------------------
- inline OneofOptions* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline OneofOptions* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<OneofOptions>(NULL);
+ }
- OneofOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ OneofOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<OneofOptions>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const OneofOptions& from);
@@ -3984,11 +4053,11 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
mutable_uninterpreted_option();
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
@@ -4068,9 +4137,13 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p
// implements Message ----------------------------------------------
- inline EnumOptions* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline EnumOptions* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumOptions>(NULL);
+ }
- EnumOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ EnumOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumOptions>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumOptions& from);
@@ -4115,11 +4188,11 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
mutable_uninterpreted_option();
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
@@ -4219,9 +4292,13 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /
// implements Message ----------------------------------------------
- inline EnumValueOptions* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline EnumValueOptions* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumValueOptions>(NULL);
+ }
- EnumValueOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ EnumValueOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumValueOptions>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumValueOptions& from);
@@ -4266,11 +4343,11 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
mutable_uninterpreted_option();
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
@@ -4360,9 +4437,13 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /*
// implements Message ----------------------------------------------
- inline ServiceOptions* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline ServiceOptions* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<ServiceOptions>(NULL);
+ }
- ServiceOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ ServiceOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<ServiceOptions>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ServiceOptions& from);
@@ -4407,11 +4488,11 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /*
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
mutable_uninterpreted_option();
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
@@ -4501,9 +4582,13 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @
// implements Message ----------------------------------------------
- inline MethodOptions* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline MethodOptions* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<MethodOptions>(NULL);
+ }
- MethodOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ MethodOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<MethodOptions>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const MethodOptions& from);
@@ -4576,11 +4661,11 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
mutable_uninterpreted_option();
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
@@ -4680,9 +4765,13 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu
// implements Message ----------------------------------------------
- inline UninterpretedOption_NamePart* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline UninterpretedOption_NamePart* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<UninterpretedOption_NamePart>(NULL);
+ }
- UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<UninterpretedOption_NamePart>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const UninterpretedOption_NamePart& from);
@@ -4835,9 +4924,13 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag
// implements Message ----------------------------------------------
- inline UninterpretedOption* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline UninterpretedOption* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<UninterpretedOption>(NULL);
+ }
- UninterpretedOption* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ UninterpretedOption* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<UninterpretedOption>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const UninterpretedOption& from);
@@ -4884,11 +4977,11 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag
int name_size() const;
void clear_name();
static const int kNameFieldNumber = 2;
- const ::google::protobuf::UninterpretedOption_NamePart& name(int index) const;
::google::protobuf::UninterpretedOption_NamePart* mutable_name(int index);
- ::google::protobuf::UninterpretedOption_NamePart* add_name();
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >*
mutable_name();
+ const ::google::protobuf::UninterpretedOption_NamePart& name(int index) const;
+ ::google::protobuf::UninterpretedOption_NamePart* add_name();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >&
name() const;
@@ -5076,9 +5169,13 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me
// implements Message ----------------------------------------------
- inline SourceCodeInfo_Location* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline SourceCodeInfo_Location* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<SourceCodeInfo_Location>(NULL);
+ }
- SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<SourceCodeInfo_Location>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const SourceCodeInfo_Location& from);
@@ -5296,9 +5393,13 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /*
// implements Message ----------------------------------------------
- inline SourceCodeInfo* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline SourceCodeInfo* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<SourceCodeInfo>(NULL);
+ }
- SourceCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ SourceCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<SourceCodeInfo>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const SourceCodeInfo& from);
@@ -5345,11 +5446,11 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /*
int location_size() const;
void clear_location();
static const int kLocationFieldNumber = 1;
- const ::google::protobuf::SourceCodeInfo_Location& location(int index) const;
::google::protobuf::SourceCodeInfo_Location* mutable_location(int index);
- ::google::protobuf::SourceCodeInfo_Location* add_location();
::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >*
mutable_location();
+ const ::google::protobuf::SourceCodeInfo_Location& location(int index) const;
+ ::google::protobuf::SourceCodeInfo_Location* add_location();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >&
location() const;
@@ -5426,9 +5527,13 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu
// implements Message ----------------------------------------------
- inline GeneratedCodeInfo_Annotation* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline GeneratedCodeInfo_Annotation* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<GeneratedCodeInfo_Annotation>(NULL);
+ }
- GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<GeneratedCodeInfo_Annotation>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const GeneratedCodeInfo_Annotation& from);
@@ -5602,9 +5707,13 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message
// implements Message ----------------------------------------------
- inline GeneratedCodeInfo* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline GeneratedCodeInfo* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<GeneratedCodeInfo>(NULL);
+ }
- GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<GeneratedCodeInfo>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const GeneratedCodeInfo& from);
@@ -5651,11 +5760,11 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message
int annotation_size() const;
void clear_annotation();
static const int kAnnotationFieldNumber = 1;
- const ::google::protobuf::GeneratedCodeInfo_Annotation& annotation(int index) const;
::google::protobuf::GeneratedCodeInfo_Annotation* mutable_annotation(int index);
- ::google::protobuf::GeneratedCodeInfo_Annotation* add_annotation();
::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >*
mutable_annotation();
+ const ::google::protobuf::GeneratedCodeInfo_Annotation& annotation(int index) const;
+ ::google::protobuf::GeneratedCodeInfo_Annotation* add_annotation();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >&
annotation() const;
@@ -5690,23 +5799,23 @@ inline int FileDescriptorSet::file_size() const {
inline void FileDescriptorSet::clear_file() {
file_.Clear();
}
-inline const ::google::protobuf::FileDescriptorProto& FileDescriptorSet::file(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorSet.file)
- return file_.Get(index);
-}
inline ::google::protobuf::FileDescriptorProto* FileDescriptorSet::mutable_file(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorSet.file)
return file_.Mutable(index);
}
-inline ::google::protobuf::FileDescriptorProto* FileDescriptorSet::add_file() {
- // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorSet.file)
- return file_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*
FileDescriptorSet::mutable_file() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorSet.file)
return &file_;
}
+inline const ::google::protobuf::FileDescriptorProto& FileDescriptorSet::file(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorSet.file)
+ return file_.Get(index);
+}
+inline ::google::protobuf::FileDescriptorProto* FileDescriptorSet::add_file() {
+ // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorSet.file)
+ return file_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&
FileDescriptorSet::file() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorSet.file)
@@ -6023,23 +6132,23 @@ inline int FileDescriptorProto::message_type_size() const {
inline void FileDescriptorProto::clear_message_type() {
message_type_.Clear();
}
-inline const ::google::protobuf::DescriptorProto& FileDescriptorProto::message_type(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.message_type)
- return message_type_.Get(index);
-}
inline ::google::protobuf::DescriptorProto* FileDescriptorProto::mutable_message_type(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.message_type)
return message_type_.Mutable(index);
}
-inline ::google::protobuf::DescriptorProto* FileDescriptorProto::add_message_type() {
- // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.message_type)
- return message_type_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*
FileDescriptorProto::mutable_message_type() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.message_type)
return &message_type_;
}
+inline const ::google::protobuf::DescriptorProto& FileDescriptorProto::message_type(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.message_type)
+ return message_type_.Get(index);
+}
+inline ::google::protobuf::DescriptorProto* FileDescriptorProto::add_message_type() {
+ // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.message_type)
+ return message_type_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&
FileDescriptorProto::message_type() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.message_type)
@@ -6053,23 +6162,23 @@ inline int FileDescriptorProto::enum_type_size() const {
inline void FileDescriptorProto::clear_enum_type() {
enum_type_.Clear();
}
-inline const ::google::protobuf::EnumDescriptorProto& FileDescriptorProto::enum_type(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.enum_type)
- return enum_type_.Get(index);
-}
inline ::google::protobuf::EnumDescriptorProto* FileDescriptorProto::mutable_enum_type(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.enum_type)
return enum_type_.Mutable(index);
}
-inline ::google::protobuf::EnumDescriptorProto* FileDescriptorProto::add_enum_type() {
- // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.enum_type)
- return enum_type_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*
FileDescriptorProto::mutable_enum_type() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.enum_type)
return &enum_type_;
}
+inline const ::google::protobuf::EnumDescriptorProto& FileDescriptorProto::enum_type(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.enum_type)
+ return enum_type_.Get(index);
+}
+inline ::google::protobuf::EnumDescriptorProto* FileDescriptorProto::add_enum_type() {
+ // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.enum_type)
+ return enum_type_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&
FileDescriptorProto::enum_type() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.enum_type)
@@ -6083,23 +6192,23 @@ inline int FileDescriptorProto::service_size() const {
inline void FileDescriptorProto::clear_service() {
service_.Clear();
}
-inline const ::google::protobuf::ServiceDescriptorProto& FileDescriptorProto::service(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.service)
- return service_.Get(index);
-}
inline ::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::mutable_service(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.service)
return service_.Mutable(index);
}
-inline ::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::add_service() {
- // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.service)
- return service_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >*
FileDescriptorProto::mutable_service() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.service)
return &service_;
}
+inline const ::google::protobuf::ServiceDescriptorProto& FileDescriptorProto::service(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.service)
+ return service_.Get(index);
+}
+inline ::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::add_service() {
+ // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.service)
+ return service_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >&
FileDescriptorProto::service() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.service)
@@ -6113,23 +6222,23 @@ inline int FileDescriptorProto::extension_size() const {
inline void FileDescriptorProto::clear_extension() {
extension_.Clear();
}
-inline const ::google::protobuf::FieldDescriptorProto& FileDescriptorProto::extension(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.extension)
- return extension_.Get(index);
-}
inline ::google::protobuf::FieldDescriptorProto* FileDescriptorProto::mutable_extension(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.extension)
return extension_.Mutable(index);
}
-inline ::google::protobuf::FieldDescriptorProto* FileDescriptorProto::add_extension() {
- // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.extension)
- return extension_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*
FileDescriptorProto::mutable_extension() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.extension)
return &extension_;
}
+inline const ::google::protobuf::FieldDescriptorProto& FileDescriptorProto::extension(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.extension)
+ return extension_.Get(index);
+}
+inline ::google::protobuf::FieldDescriptorProto* FileDescriptorProto::add_extension() {
+ // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.extension)
+ return extension_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&
FileDescriptorProto::extension() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.extension)
@@ -6176,7 +6285,8 @@ inline ::google::protobuf::FileOptions* FileDescriptorProto::unsafe_arena_releas
inline ::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
- _slow_mutable_options();
+ options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::FileOptions >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.options)
return options_;
@@ -6241,7 +6351,8 @@ inline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::unsafe_arena_rel
inline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() {
set_has_source_code_info();
if (source_code_info_ == NULL) {
- _slow_mutable_source_code_info();
+ source_code_info_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::SourceCodeInfo >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.source_code_info)
return source_code_info_;
@@ -6443,7 +6554,8 @@ inline ::google::protobuf::ExtensionRangeOptions* DescriptorProto_ExtensionRange
inline ::google::protobuf::ExtensionRangeOptions* DescriptorProto_ExtensionRange::mutable_options() {
set_has_options();
if (options_ == NULL) {
- _slow_mutable_options();
+ options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ExtensionRangeOptions >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.ExtensionRange.options)
return options_;
@@ -6616,23 +6728,23 @@ inline int DescriptorProto::field_size() const {
inline void DescriptorProto::clear_field() {
field_.Clear();
}
-inline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::field(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.field)
- return field_.Get(index);
-}
inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_field(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.field)
return field_.Mutable(index);
}
-inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_field() {
- // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.field)
- return field_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*
DescriptorProto::mutable_field() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.field)
return &field_;
}
+inline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::field(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.field)
+ return field_.Get(index);
+}
+inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_field() {
+ // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.field)
+ return field_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&
DescriptorProto::field() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.field)
@@ -6646,23 +6758,23 @@ inline int DescriptorProto::extension_size() const {
inline void DescriptorProto::clear_extension() {
extension_.Clear();
}
-inline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::extension(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension)
- return extension_.Get(index);
-}
inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_extension(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension)
return extension_.Mutable(index);
}
-inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_extension() {
- // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension)
- return extension_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*
DescriptorProto::mutable_extension() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension)
return &extension_;
}
+inline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::extension(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension)
+ return extension_.Get(index);
+}
+inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_extension() {
+ // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension)
+ return extension_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&
DescriptorProto::extension() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension)
@@ -6676,23 +6788,23 @@ inline int DescriptorProto::nested_type_size() const {
inline void DescriptorProto::clear_nested_type() {
nested_type_.Clear();
}
-inline const ::google::protobuf::DescriptorProto& DescriptorProto::nested_type(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.nested_type)
- return nested_type_.Get(index);
-}
inline ::google::protobuf::DescriptorProto* DescriptorProto::mutable_nested_type(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.nested_type)
return nested_type_.Mutable(index);
}
-inline ::google::protobuf::DescriptorProto* DescriptorProto::add_nested_type() {
- // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.nested_type)
- return nested_type_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*
DescriptorProto::mutable_nested_type() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.nested_type)
return &nested_type_;
}
+inline const ::google::protobuf::DescriptorProto& DescriptorProto::nested_type(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.nested_type)
+ return nested_type_.Get(index);
+}
+inline ::google::protobuf::DescriptorProto* DescriptorProto::add_nested_type() {
+ // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.nested_type)
+ return nested_type_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&
DescriptorProto::nested_type() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.nested_type)
@@ -6706,23 +6818,23 @@ inline int DescriptorProto::enum_type_size() const {
inline void DescriptorProto::clear_enum_type() {
enum_type_.Clear();
}
-inline const ::google::protobuf::EnumDescriptorProto& DescriptorProto::enum_type(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.enum_type)
- return enum_type_.Get(index);
-}
inline ::google::protobuf::EnumDescriptorProto* DescriptorProto::mutable_enum_type(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.enum_type)
return enum_type_.Mutable(index);
}
-inline ::google::protobuf::EnumDescriptorProto* DescriptorProto::add_enum_type() {
- // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.enum_type)
- return enum_type_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*
DescriptorProto::mutable_enum_type() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.enum_type)
return &enum_type_;
}
+inline const ::google::protobuf::EnumDescriptorProto& DescriptorProto::enum_type(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.enum_type)
+ return enum_type_.Get(index);
+}
+inline ::google::protobuf::EnumDescriptorProto* DescriptorProto::add_enum_type() {
+ // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.enum_type)
+ return enum_type_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&
DescriptorProto::enum_type() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.enum_type)
@@ -6736,23 +6848,23 @@ inline int DescriptorProto::extension_range_size() const {
inline void DescriptorProto::clear_extension_range() {
extension_range_.Clear();
}
-inline const ::google::protobuf::DescriptorProto_ExtensionRange& DescriptorProto::extension_range(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension_range)
- return extension_range_.Get(index);
-}
inline ::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::mutable_extension_range(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension_range)
return extension_range_.Mutable(index);
}
-inline ::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::add_extension_range() {
- // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension_range)
- return extension_range_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >*
DescriptorProto::mutable_extension_range() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension_range)
return &extension_range_;
}
+inline const ::google::protobuf::DescriptorProto_ExtensionRange& DescriptorProto::extension_range(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension_range)
+ return extension_range_.Get(index);
+}
+inline ::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::add_extension_range() {
+ // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension_range)
+ return extension_range_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >&
DescriptorProto::extension_range() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension_range)
@@ -6766,23 +6878,23 @@ inline int DescriptorProto::oneof_decl_size() const {
inline void DescriptorProto::clear_oneof_decl() {
oneof_decl_.Clear();
}
-inline const ::google::protobuf::OneofDescriptorProto& DescriptorProto::oneof_decl(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.oneof_decl)
- return oneof_decl_.Get(index);
-}
inline ::google::protobuf::OneofDescriptorProto* DescriptorProto::mutable_oneof_decl(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.oneof_decl)
return oneof_decl_.Mutable(index);
}
-inline ::google::protobuf::OneofDescriptorProto* DescriptorProto::add_oneof_decl() {
- // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.oneof_decl)
- return oneof_decl_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >*
DescriptorProto::mutable_oneof_decl() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.oneof_decl)
return &oneof_decl_;
}
+inline const ::google::protobuf::OneofDescriptorProto& DescriptorProto::oneof_decl(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.oneof_decl)
+ return oneof_decl_.Get(index);
+}
+inline ::google::protobuf::OneofDescriptorProto* DescriptorProto::add_oneof_decl() {
+ // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.oneof_decl)
+ return oneof_decl_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >&
DescriptorProto::oneof_decl() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.oneof_decl)
@@ -6829,7 +6941,8 @@ inline ::google::protobuf::MessageOptions* DescriptorProto::unsafe_arena_release
inline ::google::protobuf::MessageOptions* DescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
- _slow_mutable_options();
+ options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::MessageOptions >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.options)
return options_;
@@ -6861,23 +6974,23 @@ inline int DescriptorProto::reserved_range_size() const {
inline void DescriptorProto::clear_reserved_range() {
reserved_range_.Clear();
}
-inline const ::google::protobuf::DescriptorProto_ReservedRange& DescriptorProto::reserved_range(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_range)
- return reserved_range_.Get(index);
-}
inline ::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::mutable_reserved_range(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_range)
return reserved_range_.Mutable(index);
}
-inline ::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::add_reserved_range() {
- // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_range)
- return reserved_range_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >*
DescriptorProto::mutable_reserved_range() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_range)
return &reserved_range_;
}
+inline const ::google::protobuf::DescriptorProto_ReservedRange& DescriptorProto::reserved_range(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_range)
+ return reserved_range_.Get(index);
+}
+inline ::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::add_reserved_range() {
+ // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_range)
+ return reserved_range_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >&
DescriptorProto::reserved_range() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_range)
@@ -6964,23 +7077,23 @@ inline int ExtensionRangeOptions::uninterpreted_option_size() const {
inline void ExtensionRangeOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
-inline const ::google::protobuf::UninterpretedOption& ExtensionRangeOptions::uninterpreted_option(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.ExtensionRangeOptions.uninterpreted_option)
- return uninterpreted_option_.Get(index);
-}
inline ::google::protobuf::UninterpretedOption* ExtensionRangeOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.ExtensionRangeOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
-inline ::google::protobuf::UninterpretedOption* ExtensionRangeOptions::add_uninterpreted_option() {
- // @@protoc_insertion_point(field_add:google.protobuf.ExtensionRangeOptions.uninterpreted_option)
- return uninterpreted_option_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
ExtensionRangeOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.ExtensionRangeOptions.uninterpreted_option)
return &uninterpreted_option_;
}
+inline const ::google::protobuf::UninterpretedOption& ExtensionRangeOptions::uninterpreted_option(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.ExtensionRangeOptions.uninterpreted_option)
+ return uninterpreted_option_.Get(index);
+}
+inline ::google::protobuf::UninterpretedOption* ExtensionRangeOptions::add_uninterpreted_option() {
+ // @@protoc_insertion_point(field_add:google.protobuf.ExtensionRangeOptions.uninterpreted_option)
+ return uninterpreted_option_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
ExtensionRangeOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.ExtensionRangeOptions.uninterpreted_option)
@@ -7554,7 +7667,8 @@ inline ::google::protobuf::FieldOptions* FieldDescriptorProto::unsafe_arena_rele
inline ::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
- _slow_mutable_options();
+ options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::FieldOptions >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.options)
return options_;
@@ -7708,7 +7822,8 @@ inline ::google::protobuf::OneofOptions* OneofDescriptorProto::unsafe_arena_rele
inline ::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
- _slow_mutable_options();
+ options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::OneofOptions >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.options)
return options_;
@@ -7881,23 +7996,23 @@ inline int EnumDescriptorProto::value_size() const {
inline void EnumDescriptorProto::clear_value() {
value_.Clear();
}
-inline const ::google::protobuf::EnumValueDescriptorProto& EnumDescriptorProto::value(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.value)
- return value_.Get(index);
-}
inline ::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::mutable_value(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.value)
return value_.Mutable(index);
}
-inline ::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::add_value() {
- // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.value)
- return value_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >*
EnumDescriptorProto::mutable_value() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.value)
return &value_;
}
+inline const ::google::protobuf::EnumValueDescriptorProto& EnumDescriptorProto::value(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.value)
+ return value_.Get(index);
+}
+inline ::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::add_value() {
+ // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.value)
+ return value_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >&
EnumDescriptorProto::value() const {
// @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.value)
@@ -7944,7 +8059,8 @@ inline ::google::protobuf::EnumOptions* EnumDescriptorProto::unsafe_arena_releas
inline ::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
- _slow_mutable_options();
+ options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::EnumOptions >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.options)
return options_;
@@ -7976,23 +8092,23 @@ inline int EnumDescriptorProto::reserved_range_size() const {
inline void EnumDescriptorProto::clear_reserved_range() {
reserved_range_.Clear();
}
-inline const ::google::protobuf::EnumDescriptorProto_EnumReservedRange& EnumDescriptorProto::reserved_range(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.reserved_range)
- return reserved_range_.Get(index);
-}
inline ::google::protobuf::EnumDescriptorProto_EnumReservedRange* EnumDescriptorProto::mutable_reserved_range(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.reserved_range)
return reserved_range_.Mutable(index);
}
-inline ::google::protobuf::EnumDescriptorProto_EnumReservedRange* EnumDescriptorProto::add_reserved_range() {
- // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.reserved_range)
- return reserved_range_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >*
EnumDescriptorProto::mutable_reserved_range() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.reserved_range)
return &reserved_range_;
}
+inline const ::google::protobuf::EnumDescriptorProto_EnumReservedRange& EnumDescriptorProto::reserved_range(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.reserved_range)
+ return reserved_range_.Get(index);
+}
+inline ::google::protobuf::EnumDescriptorProto_EnumReservedRange* EnumDescriptorProto::add_reserved_range() {
+ // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.reserved_range)
+ return reserved_range_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >&
EnumDescriptorProto::reserved_range() const {
// @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.reserved_range)
@@ -8221,7 +8337,8 @@ inline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::unsafe_ar
inline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
- _slow_mutable_options();
+ options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::EnumValueOptions >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.options)
return options_;
@@ -8342,23 +8459,23 @@ inline int ServiceDescriptorProto::method_size() const {
inline void ServiceDescriptorProto::clear_method() {
method_.Clear();
}
-inline const ::google::protobuf::MethodDescriptorProto& ServiceDescriptorProto::method(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.method)
- return method_.Get(index);
-}
inline ::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::mutable_method(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.method)
return method_.Mutable(index);
}
-inline ::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::add_method() {
- // @@protoc_insertion_point(field_add:google.protobuf.ServiceDescriptorProto.method)
- return method_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >*
ServiceDescriptorProto::mutable_method() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceDescriptorProto.method)
return &method_;
}
+inline const ::google::protobuf::MethodDescriptorProto& ServiceDescriptorProto::method(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.method)
+ return method_.Get(index);
+}
+inline ::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::add_method() {
+ // @@protoc_insertion_point(field_add:google.protobuf.ServiceDescriptorProto.method)
+ return method_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >&
ServiceDescriptorProto::method() const {
// @@protoc_insertion_point(field_list:google.protobuf.ServiceDescriptorProto.method)
@@ -8405,7 +8522,8 @@ inline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::unsafe_arena_
inline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
- _slow_mutable_options();
+ options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ServiceOptions >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.options)
return options_;
@@ -8729,7 +8847,8 @@ inline ::google::protobuf::MethodOptions* MethodDescriptorProto::unsafe_arena_re
inline ::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
- _slow_mutable_options();
+ options_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::MethodOptions >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.options)
return options_;
@@ -9734,23 +9853,23 @@ inline int FileOptions::uninterpreted_option_size() const {
inline void FileOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
-inline const ::google::protobuf::UninterpretedOption& FileOptions::uninterpreted_option(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.uninterpreted_option)
- return uninterpreted_option_.Get(index);
-}
inline ::google::protobuf::UninterpretedOption* FileOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
-inline ::google::protobuf::UninterpretedOption* FileOptions::add_uninterpreted_option() {
- // @@protoc_insertion_point(field_add:google.protobuf.FileOptions.uninterpreted_option)
- return uninterpreted_option_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
FileOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileOptions.uninterpreted_option)
return &uninterpreted_option_;
}
+inline const ::google::protobuf::UninterpretedOption& FileOptions::uninterpreted_option(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.uninterpreted_option)
+ return uninterpreted_option_.Get(index);
+}
+inline ::google::protobuf::UninterpretedOption* FileOptions::add_uninterpreted_option() {
+ // @@protoc_insertion_point(field_add:google.protobuf.FileOptions.uninterpreted_option)
+ return uninterpreted_option_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
FileOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileOptions.uninterpreted_option)
@@ -9864,23 +9983,23 @@ inline int MessageOptions::uninterpreted_option_size() const {
inline void MessageOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
-inline const ::google::protobuf::UninterpretedOption& MessageOptions::uninterpreted_option(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.uninterpreted_option)
- return uninterpreted_option_.Get(index);
-}
inline ::google::protobuf::UninterpretedOption* MessageOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.MessageOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
-inline ::google::protobuf::UninterpretedOption* MessageOptions::add_uninterpreted_option() {
- // @@protoc_insertion_point(field_add:google.protobuf.MessageOptions.uninterpreted_option)
- return uninterpreted_option_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
MessageOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.MessageOptions.uninterpreted_option)
return &uninterpreted_option_;
}
+inline const ::google::protobuf::UninterpretedOption& MessageOptions::uninterpreted_option(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.uninterpreted_option)
+ return uninterpreted_option_.Get(index);
+}
+inline ::google::protobuf::UninterpretedOption* MessageOptions::add_uninterpreted_option() {
+ // @@protoc_insertion_point(field_add:google.protobuf.MessageOptions.uninterpreted_option)
+ return uninterpreted_option_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
MessageOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.MessageOptions.uninterpreted_option)
@@ -10044,23 +10163,23 @@ inline int FieldOptions::uninterpreted_option_size() const {
inline void FieldOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
-inline const ::google::protobuf::UninterpretedOption& FieldOptions::uninterpreted_option(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.uninterpreted_option)
- return uninterpreted_option_.Get(index);
-}
inline ::google::protobuf::UninterpretedOption* FieldOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
-inline ::google::protobuf::UninterpretedOption* FieldOptions::add_uninterpreted_option() {
- // @@protoc_insertion_point(field_add:google.protobuf.FieldOptions.uninterpreted_option)
- return uninterpreted_option_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
FieldOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldOptions.uninterpreted_option)
return &uninterpreted_option_;
}
+inline const ::google::protobuf::UninterpretedOption& FieldOptions::uninterpreted_option(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.uninterpreted_option)
+ return uninterpreted_option_.Get(index);
+}
+inline ::google::protobuf::UninterpretedOption* FieldOptions::add_uninterpreted_option() {
+ // @@protoc_insertion_point(field_add:google.protobuf.FieldOptions.uninterpreted_option)
+ return uninterpreted_option_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
FieldOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.FieldOptions.uninterpreted_option)
@@ -10078,23 +10197,23 @@ inline int OneofOptions::uninterpreted_option_size() const {
inline void OneofOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
-inline const ::google::protobuf::UninterpretedOption& OneofOptions::uninterpreted_option(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.OneofOptions.uninterpreted_option)
- return uninterpreted_option_.Get(index);
-}
inline ::google::protobuf::UninterpretedOption* OneofOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.OneofOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
-inline ::google::protobuf::UninterpretedOption* OneofOptions::add_uninterpreted_option() {
- // @@protoc_insertion_point(field_add:google.protobuf.OneofOptions.uninterpreted_option)
- return uninterpreted_option_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
OneofOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.OneofOptions.uninterpreted_option)
return &uninterpreted_option_;
}
+inline const ::google::protobuf::UninterpretedOption& OneofOptions::uninterpreted_option(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.OneofOptions.uninterpreted_option)
+ return uninterpreted_option_.Get(index);
+}
+inline ::google::protobuf::UninterpretedOption* OneofOptions::add_uninterpreted_option() {
+ // @@protoc_insertion_point(field_add:google.protobuf.OneofOptions.uninterpreted_option)
+ return uninterpreted_option_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
OneofOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.OneofOptions.uninterpreted_option)
@@ -10160,23 +10279,23 @@ inline int EnumOptions::uninterpreted_option_size() const {
inline void EnumOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
-inline const ::google::protobuf::UninterpretedOption& EnumOptions::uninterpreted_option(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.uninterpreted_option)
- return uninterpreted_option_.Get(index);
-}
inline ::google::protobuf::UninterpretedOption* EnumOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
-inline ::google::protobuf::UninterpretedOption* EnumOptions::add_uninterpreted_option() {
- // @@protoc_insertion_point(field_add:google.protobuf.EnumOptions.uninterpreted_option)
- return uninterpreted_option_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
EnumOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumOptions.uninterpreted_option)
return &uninterpreted_option_;
}
+inline const ::google::protobuf::UninterpretedOption& EnumOptions::uninterpreted_option(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.uninterpreted_option)
+ return uninterpreted_option_.Get(index);
+}
+inline ::google::protobuf::UninterpretedOption* EnumOptions::add_uninterpreted_option() {
+ // @@protoc_insertion_point(field_add:google.protobuf.EnumOptions.uninterpreted_option)
+ return uninterpreted_option_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
EnumOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.EnumOptions.uninterpreted_option)
@@ -10218,23 +10337,23 @@ inline int EnumValueOptions::uninterpreted_option_size() const {
inline void EnumValueOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
-inline const ::google::protobuf::UninterpretedOption& EnumValueOptions::uninterpreted_option(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.uninterpreted_option)
- return uninterpreted_option_.Get(index);
-}
inline ::google::protobuf::UninterpretedOption* EnumValueOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
-inline ::google::protobuf::UninterpretedOption* EnumValueOptions::add_uninterpreted_option() {
- // @@protoc_insertion_point(field_add:google.protobuf.EnumValueOptions.uninterpreted_option)
- return uninterpreted_option_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
EnumValueOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValueOptions.uninterpreted_option)
return &uninterpreted_option_;
}
+inline const ::google::protobuf::UninterpretedOption& EnumValueOptions::uninterpreted_option(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.uninterpreted_option)
+ return uninterpreted_option_.Get(index);
+}
+inline ::google::protobuf::UninterpretedOption* EnumValueOptions::add_uninterpreted_option() {
+ // @@protoc_insertion_point(field_add:google.protobuf.EnumValueOptions.uninterpreted_option)
+ return uninterpreted_option_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
EnumValueOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.EnumValueOptions.uninterpreted_option)
@@ -10276,23 +10395,23 @@ inline int ServiceOptions::uninterpreted_option_size() const {
inline void ServiceOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
-inline const ::google::protobuf::UninterpretedOption& ServiceOptions::uninterpreted_option(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.uninterpreted_option)
- return uninterpreted_option_.Get(index);
-}
inline ::google::protobuf::UninterpretedOption* ServiceOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.ServiceOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
-inline ::google::protobuf::UninterpretedOption* ServiceOptions::add_uninterpreted_option() {
- // @@protoc_insertion_point(field_add:google.protobuf.ServiceOptions.uninterpreted_option)
- return uninterpreted_option_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
ServiceOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceOptions.uninterpreted_option)
return &uninterpreted_option_;
}
+inline const ::google::protobuf::UninterpretedOption& ServiceOptions::uninterpreted_option(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.uninterpreted_option)
+ return uninterpreted_option_.Get(index);
+}
+inline ::google::protobuf::UninterpretedOption* ServiceOptions::add_uninterpreted_option() {
+ // @@protoc_insertion_point(field_add:google.protobuf.ServiceOptions.uninterpreted_option)
+ return uninterpreted_option_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
ServiceOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.ServiceOptions.uninterpreted_option)
@@ -10359,23 +10478,23 @@ inline int MethodOptions::uninterpreted_option_size() const {
inline void MethodOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
-inline const ::google::protobuf::UninterpretedOption& MethodOptions::uninterpreted_option(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.uninterpreted_option)
- return uninterpreted_option_.Get(index);
-}
inline ::google::protobuf::UninterpretedOption* MethodOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.MethodOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
-inline ::google::protobuf::UninterpretedOption* MethodOptions::add_uninterpreted_option() {
- // @@protoc_insertion_point(field_add:google.protobuf.MethodOptions.uninterpreted_option)
- return uninterpreted_option_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
MethodOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.MethodOptions.uninterpreted_option)
return &uninterpreted_option_;
}
+inline const ::google::protobuf::UninterpretedOption& MethodOptions::uninterpreted_option(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.uninterpreted_option)
+ return uninterpreted_option_.Get(index);
+}
+inline ::google::protobuf::UninterpretedOption* MethodOptions::add_uninterpreted_option() {
+ // @@protoc_insertion_point(field_add:google.protobuf.MethodOptions.uninterpreted_option)
+ return uninterpreted_option_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
MethodOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.MethodOptions.uninterpreted_option)
@@ -10506,23 +10625,23 @@ inline int UninterpretedOption::name_size() const {
inline void UninterpretedOption::clear_name() {
name_.Clear();
}
-inline const ::google::protobuf::UninterpretedOption_NamePart& UninterpretedOption::name(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.name)
- return name_.Get(index);
-}
inline ::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::mutable_name(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.name)
return name_.Mutable(index);
}
-inline ::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::add_name() {
- // @@protoc_insertion_point(field_add:google.protobuf.UninterpretedOption.name)
- return name_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >*
UninterpretedOption::mutable_name() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.UninterpretedOption.name)
return &name_;
}
+inline const ::google::protobuf::UninterpretedOption_NamePart& UninterpretedOption::name(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.name)
+ return name_.Get(index);
+}
+inline ::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::add_name() {
+ // @@protoc_insertion_point(field_add:google.protobuf.UninterpretedOption.name)
+ return name_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >&
UninterpretedOption::name() const {
// @@protoc_insertion_point(field_list:google.protobuf.UninterpretedOption.name)
@@ -11170,23 +11289,23 @@ inline int SourceCodeInfo::location_size() const {
inline void SourceCodeInfo::clear_location() {
location_.Clear();
}
-inline const ::google::protobuf::SourceCodeInfo_Location& SourceCodeInfo::location(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.location)
- return location_.Get(index);
-}
inline ::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::mutable_location(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.location)
return location_.Mutable(index);
}
-inline ::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::add_location() {
- // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.location)
- return location_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >*
SourceCodeInfo::mutable_location() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.location)
return &location_;
}
+inline const ::google::protobuf::SourceCodeInfo_Location& SourceCodeInfo::location(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.location)
+ return location_.Get(index);
+}
+inline ::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::add_location() {
+ // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.location)
+ return location_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >&
SourceCodeInfo::location() const {
// @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.location)
@@ -11371,23 +11490,23 @@ inline int GeneratedCodeInfo::annotation_size() const {
inline void GeneratedCodeInfo::clear_annotation() {
annotation_.Clear();
}
-inline const ::google::protobuf::GeneratedCodeInfo_Annotation& GeneratedCodeInfo::annotation(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.annotation)
- return annotation_.Get(index);
-}
inline ::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::mutable_annotation(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.annotation)
return annotation_.Mutable(index);
}
-inline ::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::add_annotation() {
- // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.annotation)
- return annotation_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >*
GeneratedCodeInfo::mutable_annotation() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.annotation)
return &annotation_;
}
+inline const ::google::protobuf::GeneratedCodeInfo_Annotation& GeneratedCodeInfo::annotation(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.annotation)
+ return annotation_.Get(index);
+}
+inline ::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::add_annotation() {
+ // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.annotation)
+ return annotation_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >&
GeneratedCodeInfo::annotation() const {
// @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.annotation)
diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc
index 6cca0ada..b0337035 100644
--- a/src/google/protobuf/descriptor_unittest.cc
+++ b/src/google/protobuf/descriptor_unittest.cc
@@ -431,6 +431,7 @@ TEST_F(FileDescriptorTest, FindExtensionByNumber) {
EXPECT_TRUE(pool_.FindExtensionByNumber(foo_message_, 2) == NULL);
}
+
TEST_F(FileDescriptorTest, BuildAgain) {
// Test that if te call BuildFile again on the same input we get the same
// FileDescriptor back.
@@ -973,6 +974,7 @@ TEST_F(DescriptorTest, FieldEnumType) {
EXPECT_EQ(enum_, bar_->enum_type());
}
+
// ===================================================================
// Test simple flat messages and fields.
@@ -1943,6 +1945,7 @@ TEST_F(ExtensionDescriptorTest, FindAllExtensions) {
EXPECT_EQ(39, extensions[3]->number());
}
+
TEST_F(ExtensionDescriptorTest, DuplicateFieldNumber) {
DescriptorPool pool;
FileDescriptorProto file_proto;
diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc
index 0a8aad48..b4d5eb5f 100644
--- a/src/google/protobuf/duration.pb.cc
+++ b/src/google/protobuf/duration.pb.cc
@@ -191,9 +191,6 @@ const Duration& Duration::default_instance() {
return *internal_default_instance();
}
-Duration* Duration::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Duration>(arena);
-}
void Duration::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Duration)
@@ -427,5 +424,12 @@ void Duration::InternalSwap(Duration* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Duration* Arena::CreateMessage< ::google::protobuf::Duration >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Duration >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h
index 0489df43..23f7f4bb 100644
--- a/src/google/protobuf/duration.pb.h
+++ b/src/google/protobuf/duration.pb.h
@@ -57,6 +57,11 @@ LIBPROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Duration* Arena::CreateMessage< ::google::protobuf::Duration>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
// ===================================================================
@@ -111,9 +116,13 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot
// implements Message ----------------------------------------------
- inline Duration* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Duration* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Duration>(NULL);
+ }
- Duration* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Duration* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Duration>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Duration& from);
diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc
index cdd43243..48d6aad8 100644
--- a/src/google/protobuf/dynamic_message.cc
+++ b/src/google/protobuf/dynamic_message.cc
@@ -263,7 +263,7 @@ class DynamicMessage : public Message {
Message* New() const;
Message* New(::google::protobuf::Arena* arena) const;
- ::google::protobuf::Arena* GetArena() const { return NULL; };
+ ::google::protobuf::Arena* GetArena() const { return arena_; }
int GetCachedSize() const;
void SetCachedSize(int size) const;
@@ -282,7 +282,6 @@ class DynamicMessage : public Message {
#endif // !_MSC_VER
private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage);
DynamicMessage(const TypeInfo* type_info, ::google::protobuf::Arena* arena);
void SharedCtor(bool lock_factory);
@@ -302,25 +301,25 @@ class DynamicMessage : public Message {
}
const TypeInfo* type_info_;
+ Arena* const arena_;
// TODO(kenton): Make this an atomic<int> when C++ supports it.
mutable int cached_byte_size_;
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage);
};
DynamicMessage::DynamicMessage(const TypeInfo* type_info)
- : type_info_(type_info),
- cached_byte_size_(0) {
+ : type_info_(type_info), arena_(NULL), cached_byte_size_(0) {
SharedCtor(true);
}
DynamicMessage::DynamicMessage(const TypeInfo* type_info,
::google::protobuf::Arena* arena)
- : type_info_(type_info),
- cached_byte_size_(0) {
+ : type_info_(type_info), arena_(arena), cached_byte_size_(0) {
SharedCtor(true);
}
DynamicMessage::DynamicMessage(const TypeInfo* type_info, bool lock_factory)
- : type_info_(type_info), cached_byte_size_(0) {
+ : type_info_(type_info), arena_(NULL), cached_byte_size_(0) {
SharedCtor(lock_factory);
}
@@ -342,10 +341,10 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
}
new (OffsetToPointer(type_info_->internal_metadata_offset))
- InternalMetadataWithArena;
+ InternalMetadataWithArena(arena_);
if (type_info_->extensions_offset != -1) {
- new (OffsetToPointer(type_info_->extensions_offset)) ExtensionSet;
+ new (OffsetToPointer(type_info_->extensions_offset)) ExtensionSet(arena_);
}
for (int i = 0; i < descriptor->field_count(); i++) {
const FieldDescriptor* field = descriptor->field(i);
@@ -354,14 +353,14 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
continue;
}
switch (field->cpp_type()) {
-#define HANDLE_TYPE(CPPTYPE, TYPE) \
- case FieldDescriptor::CPPTYPE_##CPPTYPE: \
- if (!field->is_repeated()) { \
- new(field_ptr) TYPE(field->default_value_##TYPE()); \
- } else { \
- new(field_ptr) RepeatedField<TYPE>(); \
- } \
- break;
+#define HANDLE_TYPE(CPPTYPE, TYPE) \
+ case FieldDescriptor::CPPTYPE_##CPPTYPE: \
+ if (!field->is_repeated()) { \
+ new (field_ptr) TYPE(field->default_value_##TYPE()); \
+ } else { \
+ new (field_ptr) RepeatedField<TYPE>(arena_); \
+ } \
+ break;
HANDLE_TYPE(INT32 , int32 );
HANDLE_TYPE(INT64 , int64 );
@@ -376,7 +375,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
if (!field->is_repeated()) {
new(field_ptr) int(field->default_value_enum()->number());
} else {
- new(field_ptr) RepeatedField<int>();
+ new (field_ptr) RepeatedField<int>(arena_);
}
break;
@@ -397,7 +396,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
ArenaStringPtr* asp = new(field_ptr) ArenaStringPtr();
asp->UnsafeSetDefault(default_value);
} else {
- new(field_ptr) RepeatedPtrField<string>();
+ new (field_ptr) RepeatedPtrField<string>(arena_);
}
break;
}
@@ -412,15 +411,28 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
// when the constructor is called inside GetPrototype(), in which
// case we have already locked the factory.
if (lock_factory) {
- new (field_ptr) DynamicMapField(
- type_info_->factory->GetPrototype(field->message_type()));
+ if (arena_ != NULL) {
+ new (field_ptr) DynamicMapField(
+ type_info_->factory->GetPrototype(field->message_type()),
+ arena_);
+ } else {
+ new (field_ptr) DynamicMapField(
+ type_info_->factory->GetPrototype(field->message_type()));
+ }
} else {
- new (field_ptr)
- DynamicMapField(type_info_->factory->GetPrototypeNoLock(
- field->message_type()));
+ if (arena_ != NULL) {
+ new (field_ptr)
+ DynamicMapField(type_info_->factory->GetPrototypeNoLock(
+ field->message_type()),
+ arena_);
+ } else {
+ new (field_ptr)
+ DynamicMapField(type_info_->factory->GetPrototypeNoLock(
+ field->message_type()));
+ }
}
} else {
- new (field_ptr) RepeatedPtrField<Message>();
+ new (field_ptr) RepeatedPtrField<Message>(arena_);
}
}
break;
@@ -568,19 +580,17 @@ void DynamicMessage::CrossLinkPrototypes() {
}
}
-Message* DynamicMessage::New() const {
- void* new_base = operator new(type_info_->size);
- memset(new_base, 0, type_info_->size);
- return new(new_base) DynamicMessage(type_info_);
-}
+Message* DynamicMessage::New() const { return New(NULL); }
Message* DynamicMessage::New(::google::protobuf::Arena* arena) const {
if (arena != NULL) {
- Message* message = New();
- arena->Own(message);
- return message;
+ void* new_base = Arena::CreateArray<char>(arena, type_info_->size);
+ memset(new_base, 0, type_info_->size);
+ return new (new_base) DynamicMessage(type_info_, arena);
} else {
- return New();
+ void* new_base = operator new(type_info_->size);
+ memset(new_base, 0, type_info_->size);
+ return new (new_base) DynamicMessage(type_info_);
}
}
diff --git a/src/google/protobuf/dynamic_message_unittest.cc b/src/google/protobuf/dynamic_message_unittest.cc
index fe51d8cf..34f3641b 100644
--- a/src/google/protobuf/dynamic_message_unittest.cc
+++ b/src/google/protobuf/dynamic_message_unittest.cc
@@ -60,7 +60,7 @@
namespace google {
namespace protobuf {
-class DynamicMessageTest : public testing::Test {
+class DynamicMessageTest : public ::testing::TestWithParam<bool> {
protected:
DescriptorPool pool_;
DynamicMessageFactory factory_;
@@ -144,38 +144,54 @@ TEST_F(DynamicMessageTest, Defaults) {
reflection_tester.ExpectClearViaReflection(*prototype_);
}
-TEST_F(DynamicMessageTest, IndependentOffsets) {
+TEST_P(DynamicMessageTest, IndependentOffsets) {
// Check that all fields have independent offsets by setting each
// one to a unique value then checking that they all still have those
// unique values (i.e. they don't stomp each other).
- google::protobuf::scoped_ptr<Message> message(prototype_->New());
+ Arena arena;
+ Message* message = prototype_->New(GetParam()? &arena : NULL);
TestUtil::ReflectionTester reflection_tester(descriptor_);
- reflection_tester.SetAllFieldsViaReflection(message.get());
+ reflection_tester.SetAllFieldsViaReflection(message);
reflection_tester.ExpectAllFieldsSetViaReflection(*message);
+
+ if (!GetParam()) {
+ delete message;
+ }
}
-TEST_F(DynamicMessageTest, Extensions) {
+TEST_P(DynamicMessageTest, Extensions) {
// Check that extensions work.
- google::protobuf::scoped_ptr<Message> message(extensions_prototype_->New());
+ Arena arena;
+ Message* message = extensions_prototype_->New(GetParam()? &arena : NULL);
TestUtil::ReflectionTester reflection_tester(extensions_descriptor_);
- reflection_tester.SetAllFieldsViaReflection(message.get());
+ reflection_tester.SetAllFieldsViaReflection(message);
reflection_tester.ExpectAllFieldsSetViaReflection(*message);
+
+ if (!GetParam()) {
+ delete message;
+ }
}
-TEST_F(DynamicMessageTest, PackedFields) {
+TEST_P(DynamicMessageTest, PackedFields) {
// Check that packed fields work properly.
- google::protobuf::scoped_ptr<Message> message(packed_prototype_->New());
+ Arena arena;
+ Message* message = packed_prototype_->New(GetParam()? &arena : NULL);
TestUtil::ReflectionTester reflection_tester(packed_descriptor_);
- reflection_tester.SetPackedFieldsViaReflection(message.get());
+ reflection_tester.SetPackedFieldsViaReflection(message);
reflection_tester.ExpectPackedFieldsSetViaReflection(*message);
+
+ if (!GetParam()) {
+ delete message;
+ }
}
-TEST_F(DynamicMessageTest, Oneof) {
+TEST_P(DynamicMessageTest, Oneof) {
// Check that oneof fields work properly.
- google::protobuf::scoped_ptr<Message> message(oneof_prototype_->New());
+ Arena arena;
+ Message* message = oneof_prototype_->New(GetParam()? &arena : NULL);
// Check default values.
const Descriptor* descriptor = message->GetDescriptor();
@@ -226,29 +242,46 @@ TEST_F(DynamicMessageTest, Oneof) {
// Check set functions.
TestUtil::ReflectionTester reflection_tester(oneof_descriptor_);
- reflection_tester.SetOneofViaReflection(message.get());
+ reflection_tester.SetOneofViaReflection(message);
reflection_tester.ExpectOneofSetViaReflection(*message);
+
+ if (!GetParam()) {
+ delete message;
+ }
}
-TEST_F(DynamicMessageTest, SpaceUsed) {
+TEST_P(DynamicMessageTest, SpaceUsed) {
// Test that SpaceUsed() works properly
// Since we share the implementation with generated messages, we don't need
// to test very much here. Just make sure it appears to be working.
- google::protobuf::scoped_ptr<Message> message(prototype_->New());
+ Arena arena;
+ Message* message = prototype_->New(GetParam()? &arena : NULL);
TestUtil::ReflectionTester reflection_tester(descriptor_);
int initial_space_used = message->SpaceUsed();
- reflection_tester.SetAllFieldsViaReflection(message.get());
+ reflection_tester.SetAllFieldsViaReflection(message);
EXPECT_LT(initial_space_used, message->SpaceUsed());
+
+ if (!GetParam()) {
+ delete message;
+ }
}
TEST_F(DynamicMessageTest, Arena) {
Arena arena;
Message* message = prototype_->New(&arena);
- (void)message; // avoid unused-variable error.
+ Message* extension_message = extensions_prototype_->New(&arena);
+ Message* packed_message = packed_prototype_->New(&arena);
+ Message* oneof_message = oneof_prototype_->New(&arena);
+
+ // avoid unused-variable error.
+ (void)message;
+ (void)extension_message;
+ (void)packed_message;
+ (void)oneof_message;
// Return without freeing: should not leak.
}
@@ -286,6 +319,7 @@ TEST_F(DynamicMessageTest, Proto3) {
delete message;
}
+INSTANTIATE_TEST_CASE_P(UseArena, DynamicMessageTest, ::testing::Bool());
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc
index caa019e8..ffff80b9 100644
--- a/src/google/protobuf/empty.pb.cc
+++ b/src/google/protobuf/empty.pb.cc
@@ -180,9 +180,6 @@ const Empty& Empty::default_instance() {
return *internal_default_instance();
}
-Empty* Empty::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Empty>(arena);
-}
void Empty::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Empty)
@@ -338,5 +335,12 @@ void Empty::InternalSwap(Empty* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Empty* Arena::CreateMessage< ::google::protobuf::Empty >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Empty >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h
index 1d7c5887..3d44429a 100644
--- a/src/google/protobuf/empty.pb.h
+++ b/src/google/protobuf/empty.pb.h
@@ -57,6 +57,11 @@ LIBPROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_;
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Empty* Arena::CreateMessage< ::google::protobuf::Empty>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
// ===================================================================
@@ -111,9 +116,13 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_
// implements Message ----------------------------------------------
- inline Empty* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Empty* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Empty>(NULL);
+ }
- Empty* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Empty* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Empty>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Empty& from);
diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc
index cf6b6fb4..8f104800 100644
--- a/src/google/protobuf/extension_set.cc
+++ b/src/google/protobuf/extension_set.cc
@@ -33,6 +33,7 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include <google/protobuf/stubs/hash.h>
+#include <utility>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/extension_set.h>
@@ -750,8 +751,10 @@ MessageLite* ExtensionSet::AddMessage(int number, FieldType type,
// RepeatedPtrField<MessageLite> does not know how to Add() since it cannot
// allocate an abstract object, so we have to be tricky.
- MessageLite* result = extension->repeated_message_value
- ->AddFromCleared<GenericTypeHandler<MessageLite> >();
+ MessageLite* result =
+ reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>(
+ extension->repeated_message_value)
+ ->AddFromCleared<GenericTypeHandler<MessageLite> >();
if (result == NULL) {
result = prototype.New(arena_);
extension->repeated_message_value->AddAllocated(result);
@@ -925,8 +928,10 @@ void ExtensionSet::InternalExtensionMergeFrom(
other_extension.repeated_message_value;
for (int i = 0; i < other_repeated_message->size(); i++) {
const MessageLite& other_message = other_repeated_message->Get(i);
- MessageLite* target = extension->repeated_message_value
- ->AddFromCleared<GenericTypeHandler<MessageLite> >();
+ MessageLite* target =
+ reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>(
+ extension->repeated_message_value)
+ ->AddFromCleared<GenericTypeHandler<MessageLite> >();
if (target == NULL) {
target = other_message.New(arena_);
extension->repeated_message_value->AddAllocated(target);
@@ -1747,6 +1752,9 @@ void ExtensionSet::Extension::Free() {
// Defined in extension_set_heavy.cc.
// int ExtensionSet::Extension::SpaceUsedExcludingSelf() const
+// Dummy key method to avoid weak vtable.
+void ExtensionSet::LazyMessageExtension::UnusedKeyMethod() {}
+
// ==================================================================
// Default repeated field instances for iterator-compatible accessors
diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h
index 0a5d98f2..b0f3b8dd 100644
--- a/src/google/protobuf/extension_set.h
+++ b/src/google/protobuf/extension_set.h
@@ -483,6 +483,8 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
}
private:
+ virtual void UnusedKeyMethod(); // Dummy key method to avoid weak vtable.
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyMessageExtension);
};
struct Extension {
diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc
index fad31340..432c0fd7 100644
--- a/src/google/protobuf/extension_set_heavy.cc
+++ b/src/google/protobuf/extension_set_heavy.cc
@@ -259,8 +259,10 @@ MessageLite* ExtensionSet::AddMessage(const FieldDescriptor* descriptor,
// RepeatedPtrField<Message> does not know how to Add() since it cannot
// allocate an abstract object, so we have to be tricky.
- MessageLite* result = extension->repeated_message_value
- ->AddFromCleared<GenericTypeHandler<MessageLite> >();
+ MessageLite* result =
+ reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>(
+ extension->repeated_message_value)
+ ->AddFromCleared<GenericTypeHandler<MessageLite> >();
if (result == NULL) {
const MessageLite* prototype;
if (extension->repeated_message_value->size() == 0) {
@@ -391,7 +393,9 @@ size_t ExtensionSet::Extension::SpaceUsedExcludingSelfLong() const {
// type handler.
total_size +=
sizeof(*repeated_message_value) +
- RepeatedMessage_SpaceUsedExcludingSelfLong(repeated_message_value);
+ RepeatedMessage_SpaceUsedExcludingSelfLong(
+ reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>(
+ repeated_message_value));
break;
}
} else {
diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc
index 3e71b253..b8b6e428 100644
--- a/src/google/protobuf/extension_set_unittest.cc
+++ b/src/google/protobuf/extension_set_unittest.cc
@@ -792,11 +792,16 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) {
message.AddExtension(unittest::repeated_##type##_extension, value); \
EXPECT_EQ(empty_repeated_field_size, message.SpaceUsed()) << #type; \
message.ClearExtension(unittest::repeated_##type##_extension); \
+ const int old_capacity = \
+ message.GetRepeatedExtension(unittest::repeated_##type##_extension) \
+ .Capacity(); \
+ EXPECT_GE(old_capacity, kMinRepeatedFieldAllocationSize); \
for (int i = 0; i < 16; ++i) { \
message.AddExtension(unittest::repeated_##type##_extension, value); \
} \
- int expected_size = sizeof(cpptype) * (16 - \
- kMinRepeatedFieldAllocationSize) + empty_repeated_field_size; \
+ int expected_size = sizeof(cpptype) * \
+ (message.GetRepeatedExtension(unittest::repeated_##type##_extension) \
+ .Capacity() - old_capacity) + empty_repeated_field_size; \
EXPECT_LE(expected_size, message.SpaceUsed()) << #type; \
} while (0)
diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc
index c55a697a..abee4fe7 100644
--- a/src/google/protobuf/field_mask.pb.cc
+++ b/src/google/protobuf/field_mask.pb.cc
@@ -169,13 +169,6 @@ const FieldMask& FieldMask::default_instance() {
return *internal_default_instance();
}
-FieldMask* FieldMask::New(::google::protobuf::Arena* arena) const {
- FieldMask* n = new FieldMask;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
void FieldMask::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldMask)
@@ -355,7 +348,7 @@ void FieldMask::Swap(FieldMask* other) {
}
void FieldMask::InternalSwap(FieldMask* other) {
using std::swap;
- paths_.InternalSwap(&other->paths_);
+ paths_.InternalSwap(CastToBase(&other->paths_));
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
}
@@ -369,5 +362,12 @@ void FieldMask::InternalSwap(FieldMask* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FieldMask* Arena::Create< ::google::protobuf::FieldMask >(Arena* arena) {
+ return Arena::CreateInternal< ::google::protobuf::FieldMask >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h
index 3275dc54..e94cdd03 100644
--- a/src/google/protobuf/field_mask.pb.h
+++ b/src/google/protobuf/field_mask.pb.h
@@ -57,6 +57,11 @@ LIBPROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instan
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::FieldMask* Arena::Create< ::google::protobuf::FieldMask>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
// ===================================================================
@@ -104,9 +109,13 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro
// implements Message ----------------------------------------------
- inline FieldMask* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline FieldMask* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<FieldMask>(NULL);
+ }
- FieldMask* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ FieldMask* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<FieldMask>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FieldMask& from);
diff --git a/src/google/protobuf/generated_enum_reflection.h b/src/google/protobuf/generated_enum_reflection.h
index fdcdc277..983d3185 100644
--- a/src/google/protobuf/generated_enum_reflection.h
+++ b/src/google/protobuf/generated_enum_reflection.h
@@ -41,7 +41,6 @@
#include <string>
-#include <google/protobuf/stubs/template_util.h>
#include <google/protobuf/generated_enum_util.h>
namespace google {
diff --git a/src/google/protobuf/generated_enum_util.h b/src/google/protobuf/generated_enum_util.h
index e4242055..4f5ded5b 100644
--- a/src/google/protobuf/generated_enum_util.h
+++ b/src/google/protobuf/generated_enum_util.h
@@ -31,7 +31,7 @@
#ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__
#define GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__
-#include <google/protobuf/stubs/template_util.h>
+#include <google/protobuf/stubs/type_traits.h>
namespace google {
namespace protobuf {
diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc
index f0f207ea..b0c975b4 100644
--- a/src/google/protobuf/generated_message_reflection.cc
+++ b/src/google/protobuf/generated_message_reflection.cc
@@ -1124,9 +1124,6 @@ string GeneratedMessageReflection::GetString(
return GetField<ArenaStringPtr>(message, field).Get();
}
}
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return GetEmptyString(); // Make compiler happy.
}
}
@@ -1144,9 +1141,6 @@ const string& GeneratedMessageReflection::GetStringReference(
return GetField<ArenaStringPtr>(message, field).Get();
}
}
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return GetEmptyString(); // Make compiler happy.
}
}
@@ -1188,9 +1182,6 @@ string GeneratedMessageReflection::GetRepeatedString(
case FieldOptions::STRING:
return GetRepeatedPtrField<string>(message, field, index);
}
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return GetEmptyString(); // Make compiler happy.
}
}
@@ -1206,9 +1197,6 @@ const string& GeneratedMessageReflection::GetRepeatedStringReference(
case FieldOptions::STRING:
return GetRepeatedPtrField<string>(message, field, index);
}
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return GetEmptyString(); // Make compiler happy.
}
}
diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h
index 02ecba61..3c6701cf 100644
--- a/src/google/protobuf/generated_message_reflection.h
+++ b/src/google/protobuf/generated_message_reflection.h
@@ -655,12 +655,9 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL : public Refl
// dynamic_cast_if_available() implements this logic. If RTTI is
// enabled, it does a dynamic_cast. If RTTI is disabled, it just returns
// NULL.
-//
-// If you need to compile without RTTI, simply #define GOOGLE_PROTOBUF_NO_RTTI.
-// On MSVC, this should be detected automatically.
template<typename To, typename From>
inline To dynamic_cast_if_available(From from) {
-#if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI))
+#ifdef GOOGLE_PROTOBUF_NO_RTTI
// Avoid the compiler warning about unused variables.
(void)from;
return NULL;
@@ -688,8 +685,7 @@ T* DynamicCastToGenerated(const Message* from) {
const Message* unused = static_cast<T*>(NULL);
(void)unused;
-#if defined(GOOGLE_PROTOBUF_NO_RTTI) || \
- (defined(_MSC_VER) && !defined(_CPPRTTI))
+#ifdef GOOGLE_PROTOBUF_NO_RTTI
bool ok = &T::default_instance() ==
from->GetReflection()->GetMessageFactory()->GetPrototype(
from->GetDescriptor());
diff --git a/src/google/protobuf/generated_message_table_driven_lite.h b/src/google/protobuf/generated_message_table_driven_lite.h
index 20b4da21..4dfbf678 100644
--- a/src/google/protobuf/generated_message_table_driven_lite.h
+++ b/src/google/protobuf/generated_message_table_driven_lite.h
@@ -307,6 +307,7 @@ inline bool HandleEnum(const ParseTable& table, io::CodedInputStream* input,
class RepeatedMessageTypeHandler {
public:
typedef MessageLite Type;
+ typedef MessageLite WeakType;
static Arena* GetArena(Type* t) { return t->GetArena(); }
static void* GetMaybeArenaPointer(Type* t) {
return t->GetMaybeArenaPointer();
@@ -351,7 +352,7 @@ inline bool ReadMessage(io::CodedInputStream* input, MessageLite* value) {
std::pair<io::CodedInputStream::Limit, int> p =
input->IncrementRecursionDepthAndPushLimit(length);
if (GOOGLE_PREDICT_FALSE(p.second < 0 ||
- !value->MergePartialFromCodedStream(input))) {
+ !value->MergePartialFromCodedStream(input))) {
return false;
}
@@ -394,7 +395,8 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
continue;
}
- if (GOOGLE_PREDICT_FALSE(!UnknownFieldHandler::Skip(msg, table, input, tag))) {
+ if (GOOGLE_PREDICT_FALSE(
+ !UnknownFieldHandler::Skip(msg, table, input, tag))) {
return false;
}
@@ -421,7 +423,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
#define HANDLE_TYPE(TYPE, CPPTYPE) \
case (WireFormatLite::TYPE_##TYPE): { \
CPPTYPE value; \
- if (GOOGLE_PREDICT_FALSE( \
+ if (GOOGLE_PREDICT_FALSE( \
(!WireFormatLite::ReadPrimitive< \
CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \
return false; \
@@ -432,8 +434,8 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
case (WireFormatLite::TYPE_##TYPE) | kRepeatedMask: { \
google::protobuf::RepeatedField<CPPTYPE>* values = \
Raw<google::protobuf::RepeatedField<CPPTYPE> >(msg, offset); \
- if (GOOGLE_PREDICT_FALSE((!WireFormatLite::ReadRepeatedPrimitive< \
- CPPTYPE, WireFormatLite::TYPE_##TYPE>( \
+ if (GOOGLE_PREDICT_FALSE((!WireFormatLite::ReadRepeatedPrimitive< \
+ CPPTYPE, WireFormatLite::TYPE_##TYPE>( \
data->tag_size, tag, input, values)))) { \
return false; \
} \
@@ -442,7 +444,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
case (WireFormatLite::TYPE_##TYPE) | kOneofMask: { \
uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset); \
CPPTYPE value; \
- if (GOOGLE_PREDICT_FALSE( \
+ if (GOOGLE_PREDICT_FALSE( \
(!WireFormatLite::ReadPrimitive< \
CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \
return false; \
@@ -578,29 +580,32 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
}
#endif
case WireFormatLite::TYPE_ENUM: {
- if (GOOGLE_PREDICT_FALSE((!HandleEnum<UnknownFieldHandler, InternalMetadata,
- Cardinality_SINGULAR>(
- table, input, msg, has_bits, presence_index, offset, tag,
- field_number)))) {
+ if (GOOGLE_PREDICT_FALSE(
+ (!HandleEnum<UnknownFieldHandler, InternalMetadata,
+ Cardinality_SINGULAR>(
+ table, input, msg, has_bits, presence_index, offset, tag,
+ field_number)))) {
return false;
}
break;
}
case WireFormatLite::TYPE_ENUM | kRepeatedMask: {
- if (GOOGLE_PREDICT_FALSE((!HandleEnum<UnknownFieldHandler, InternalMetadata,
- Cardinality_REPEATED>(
- table, input, msg, has_bits, presence_index, offset, tag,
- field_number)))) {
+ if (GOOGLE_PREDICT_FALSE(
+ (!HandleEnum<UnknownFieldHandler, InternalMetadata,
+ Cardinality_REPEATED>(
+ table, input, msg, has_bits, presence_index, offset, tag,
+ field_number)))) {
return false;
}
break;
}
case WireFormatLite::TYPE_ENUM | kOneofMask: {
uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset);
- if (GOOGLE_PREDICT_FALSE((!HandleEnum<UnknownFieldHandler, InternalMetadata,
- Cardinality_ONEOF>(
- table, input, msg, oneof_case, presence_index, offset, tag,
- field_number)))) {
+ if (GOOGLE_PREDICT_FALSE(
+ (!HandleEnum<UnknownFieldHandler, InternalMetadata,
+ Cardinality_ONEOF>(table, input, msg, oneof_case,
+ presence_index, offset, tag,
+ field_number)))) {
return false;
}
break;
@@ -619,8 +624,8 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
*submsg_holder = submsg;
}
- if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadGroup(
- field_number, input, submsg))) {
+ if (GOOGLE_PREDICT_FALSE(
+ !WireFormatLite::ReadGroup(field_number, input, submsg))) {
return false;
}
@@ -635,8 +640,8 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
MessageLite* submsg =
MergePartialFromCodedStreamHelper::Add(field, prototype);
- if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadGroup(
- field_number, input, submsg))) {
+ if (GOOGLE_PREDICT_FALSE(
+ !WireFormatLite::ReadGroup(field_number, input, submsg))) {
return false;
}
@@ -727,7 +732,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
case WireFormatLite::TYPE_##TYPE: { \
google::protobuf::RepeatedField<CPPTYPE>* values = \
Raw<google::protobuf::RepeatedField<CPPTYPE> >(msg, offset); \
- if (GOOGLE_PREDICT_FALSE( \
+ if (GOOGLE_PREDICT_FALSE( \
(!WireFormatLite::ReadPackedPrimitive< \
CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, values)))) { \
return false; \
@@ -809,7 +814,8 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
}
// process unknown field.
- if (GOOGLE_PREDICT_FALSE(!UnknownFieldHandler::Skip(msg, table, input, tag))) {
+ if (GOOGLE_PREDICT_FALSE(
+ !UnknownFieldHandler::Skip(msg, table, input, tag))) {
return false;
}
}
diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h
index 8ebfc13b..cd74b45e 100644
--- a/src/google/protobuf/generated_message_util.h
+++ b/src/google/protobuf/generated_message_util.h
@@ -47,6 +47,7 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/has_bits.h>
+#include <google/protobuf/implicit_weak_message.h>
#include <google/protobuf/map_entry_lite.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/wire_format_lite.h>
@@ -120,6 +121,21 @@ template <class Type> bool AllAreInitialized(const Type& t) {
return true;
}
+// "Weak" variant of AllAreInitialized, used to implement implicit weak fields.
+// This version operates on MessageLite to avoid introducing a dependency on the
+// concrete message type.
+template <class T>
+bool AllAreInitializedWeak(const ::google::protobuf::RepeatedPtrField<T>& t) {
+ for (int i = t.size(); --i >= 0;) {
+ if (!reinterpret_cast<const ::google::protobuf::internal::RepeatedPtrFieldBase&>(t)
+ .Get< ::google::protobuf::internal::ImplicitWeakTypeHandler<T> >(i)
+ .IsInitialized()) {
+ return false;
+ }
+ }
+ return true;
+}
+
LIBPROTOBUF_EXPORT void InitProtobufDefaults();
struct LIBPROTOBUF_EXPORT FieldMetadata {
diff --git a/src/google/protobuf/implicit_weak_message.h b/src/google/protobuf/implicit_weak_message.h
index 12cc7db9..a822172e 100644
--- a/src/google/protobuf/implicit_weak_message.h
+++ b/src/google/protobuf/implicit_weak_message.h
@@ -35,10 +35,16 @@
#include <google/protobuf/arena.h>
#include <google/protobuf/message_lite.h>
+// This file is logically internal-only and should only be used by protobuf
+// generated code.
+
namespace google {
namespace protobuf {
namespace internal {
+// An implementation of MessageLite that treats all data as unknown. This type
+// acts as a placeholder for an implicit weak field in the case where the true
+// message type does not get linked into the binary.
class LIBPROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
public:
ImplicitWeakMessage() : arena_(NULL) {}
@@ -69,7 +75,7 @@ class LIBPROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
output->WriteString(data_);
}
- int GetCachedSize() const { return data_.size(); }
+ int GetCachedSize() const { return static_cast<int>(data_.size()); }
typedef void InternalArenaConstructable_;
@@ -79,6 +85,49 @@ class LIBPROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImplicitWeakMessage);
};
+// A type handler for use with implicit weak repeated message fields.
+template <typename ImplicitWeakType>
+class ImplicitWeakTypeHandler {
+ public:
+ typedef ImplicitWeakType Type;
+ typedef ::google::protobuf::MessageLite WeakType;
+#if LANG_CXX11
+ static const bool Moveable = false;
+#endif
+
+ // With implicit weak fields, we need separate NewFromPrototype and
+ // NewFromPrototypeWeak functions. The former is used when we want to create a
+ // strong dependency on the message type, and it just delegates to the
+ // GenericTypeHandler. The latter avoids creating a strong dependency, by
+ // simply calling MessageLite::New.
+ static inline ::google::protobuf::MessageLite* NewFromPrototype(
+ const ::google::protobuf::MessageLite* prototype, ::google::protobuf::Arena* arena = NULL) {
+ return prototype->New(arena);
+ }
+
+ static inline void Delete(::google::protobuf::MessageLite* value, Arena* arena) {
+ if (arena == NULL) {
+ delete value;
+ }
+ }
+ static inline ::google::protobuf::Arena* GetArena(::google::protobuf::MessageLite* value) {
+ return value->GetArena();
+ }
+ static inline void* GetMaybeArenaPointer(::google::protobuf::MessageLite* value) {
+ return value->GetArena();
+ }
+ static inline void Clear(::google::protobuf::MessageLite* value) {
+ value->Clear();
+ }
+ static void Merge(const ::google::protobuf::MessageLite& from,
+ ::google::protobuf::MessageLite* to) {
+ to->CheckTypeAndMergeFrom(from);
+ }
+ static inline size_t SpaceUsedLong(const Type& value) {
+ return value.SpaceUsedLong();
+ }
+};
+
extern ::google::protobuf::internal::ExplicitlyConstructed<ImplicitWeakMessage>
implicit_weak_message_default_instance;
diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc
index 79cff2c7..d3bc7c6d 100644
--- a/src/google/protobuf/io/coded_stream.cc
+++ b/src/google/protobuf/io/coded_stream.cc
@@ -121,9 +121,9 @@ CodedInputStream::Limit CodedInputStream::PushLimit(int byte_limit) {
// security: byte_limit is possibly evil, so check for negative values
// and overflow. Also check that the new requested limit is before the
// previous limit; otherwise we continue to enforce the previous limit.
- if GOOGLE_PREDICT_TRUE(byte_limit >= 0 &&
- byte_limit <= INT_MAX - current_position &&
- byte_limit < current_limit_ - current_position) {
+ if (GOOGLE_PREDICT_TRUE(byte_limit >= 0 &&
+ byte_limit <= INT_MAX - current_position &&
+ byte_limit < current_limit_ - current_position)) {
current_limit_ = current_position + byte_limit;
RecomputeBufferLimits();
}
@@ -173,10 +173,7 @@ int CodedInputStream::BytesUntilLimit() const {
return current_limit_ - current_position;
}
-void CodedInputStream::SetTotalBytesLimit(
- int total_bytes_limit, int warning_threshold) {
- (void) warning_threshold;
-
+void CodedInputStream::SetTotalBytesLimit(int total_bytes_limit) {
// Make sure the limit isn't already past, since this could confuse other
// code.
int current_position = CurrentPosition();
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index 02d87ea4..ec85147b 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -367,42 +367,32 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Total Bytes Limit -----------------------------------------------
// To prevent malicious users from sending excessively large messages
- // and causing integer overflows or memory exhaustion, CodedInputStream
- // imposes a hard limit on the total number of bytes it will read.
+ // and causing memory exhaustion, CodedInputStream imposes a hard limit on
+ // the total number of bytes it will read.
// Sets the maximum number of bytes that this CodedInputStream will read
- // before refusing to continue. To prevent integer overflows in the
- // protocol buffers implementation, as well as to prevent servers from
- // allocating enormous amounts of memory to hold parsed messages, the
- // maximum message length should be limited to the shortest length that
- // will not harm usability. The theoretical shortest message that could
- // cause integer overflows is 512MB. The default limit is 64MB. Apps
- // should set shorter limits if possible. For backwards compatibility all
- // negative values get squashed to -1, as other negative values might have
- // special internal meanings. An error will always be printed to stderr if
- // the limit is reached.
+ // before refusing to continue. To prevent servers from allocating enormous
+ // amounts of memory to hold parsed messages, the maximum message length
+ // should be limited to the shortest length that will not harm usability.
+ // The default limit is INT_MAX (~2GB) and apps should set shorter limits
+ // if possible. An error will always be printed to stderr if the limit is
+ // reached.
//
- // This is unrelated to PushLimit()/PopLimit().
+ // Note: setting a limit less than the current read position is interpreted
+ // as a limit on the current position.
//
- // Hint: If you are reading this because your program is printing a
- // warning about dangerously large protocol messages, you may be
- // confused about what to do next. The best option is to change your
- // design such that excessively large messages are not necessary.
- // For example, try to design file formats to consist of many small
- // messages rather than a single large one. If this is infeasible,
- // you will need to increase the limit. Chances are, though, that
- // your code never constructs a CodedInputStream on which the limit
- // can be set. You probably parse messages by calling things like
- // Message::ParseFromString(). In this case, you will need to change
- // your code to instead construct some sort of ZeroCopyInputStream
- // (e.g. an ArrayInputStream), construct a CodedInputStream around
- // that, then you can adjust the limit. Then call
- // Message::ParseFromCodedStream() instead. Yes, it's more work, but
- // you're doing something unusual.
- void SetTotalBytesLimit(int total_bytes_limit, int warning_threshold);
-
- // The Total Bytes Limit minus the Current Position, or -1 if there
- // is no Total Bytes Limit.
+ // This is unrelated to PushLimit()/PopLimit().
+ void SetTotalBytesLimit(int total_bytes_limit);
+
+ PROTOBUF_RUNTIME_DEPRECATED(
+ "Please use the single parameter version of SetTotalBytesLimit(). The "
+ "second parameter is ignored.")
+ void SetTotalBytesLimit(int total_bytes_limit, int) {
+ SetTotalBytesLimit(total_bytes_limit);
+ }
+
+ // The Total Bytes Limit minus the Current Position, or -1 if the total bytes
+ // limit is INT_MAX.
int BytesUntilTotalBytesLimit() const;
// Recursion Limit -------------------------------------------------
@@ -580,8 +570,6 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Recursion depth limit, set by SetRecursionLimit().
int recursion_limit_;
- bool disable_strict_correctness_enforcement_;
-
// See SetExtensionRegistry().
const DescriptorPool* extension_pool_;
MessageFactory* extension_factory_;
@@ -1053,8 +1041,7 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoffNoLastTag(
// Other hot case: cutoff >= 0x80, buffer_ has at least two bytes available,
// and tag is two bytes. The latter is tested by bitwise-and-not of the
// first byte and the second byte.
- if (cutoff >= 0x80 &&
- GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
+ if (cutoff >= 0x80 && GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
GOOGLE_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {
const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f;
uint32 tag = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80);
@@ -1364,7 +1351,6 @@ inline CodedInputStream::CodedInputStream(ZeroCopyInputStream* input)
total_bytes_limit_(kDefaultTotalBytesLimit),
recursion_budget_(default_recursion_limit_),
recursion_limit_(default_recursion_limit_),
- disable_strict_correctness_enforcement_(true),
extension_pool_(NULL),
extension_factory_(NULL) {
// Eagerly Refresh() so buffer space is immediately available.
@@ -1385,7 +1371,6 @@ inline CodedInputStream::CodedInputStream(const uint8* buffer, int size)
total_bytes_limit_(kDefaultTotalBytesLimit),
recursion_budget_(default_recursion_limit_),
recursion_limit_(default_recursion_limit_),
- disable_strict_correctness_enforcement_(true),
extension_pool_(NULL),
extension_factory_(NULL) {
// Note that setting current_limit_ == size is important to prevent some
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h
index 7d9cc5c5..a75fb786 100644
--- a/src/google/protobuf/map.h
+++ b/src/google/protobuf/map.h
@@ -48,6 +48,10 @@
#include <google/protobuf/map_type_handler.h>
#include <google/protobuf/stubs/hash.h>
+#if LANG_CXX11
+#include <initializer_list>
+#endif
+
namespace google {
namespace protobuf {
@@ -741,7 +745,7 @@ class Map {
return true;
}
} else if (GOOGLE_PREDICT_FALSE(new_size <= lo_cutoff &&
- num_buckets_ > kMinTableSize)) {
+ num_buckets_ > kMinTableSize)) {
size_type lg2_of_size_reduction_factor = 1;
// It's possible we want to shrink a lot here... size() could even be 0.
// So, estimate how much to shrink by making sure we don't shrink so
@@ -1113,6 +1117,11 @@ class Map {
}
}
}
+#if LANG_CXX11
+ void insert(std::initializer_list<value_type> values) {
+ insert(values.begin(), values.end());
+ }
+#endif
// Erase and clear
size_type erase(const key_type& key) {
diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h
index 7c477c56..1646ce43 100644
--- a/src/google/protobuf/map_entry_lite.h
+++ b/src/google/protobuf/map_entry_lite.h
@@ -34,6 +34,7 @@
#include <assert.h>
#include <google/protobuf/arena.h>
+#include <google/protobuf/arenastring.h>
#include <google/protobuf/map.h>
#include <google/protobuf/map_type_handler.h>
#include <google/protobuf/stubs/port.h>
@@ -603,7 +604,9 @@ template <>
struct FromHelper<WireFormatLite::TYPE_STRING> {
static ArenaStringPtr From(const string& x) {
ArenaStringPtr res;
- *res.UnsafeRawStringPointer() = const_cast<string*>(&x);
+ TaggedPtr< ::std::string> ptr;
+ ptr.Set(const_cast<string*>(&x));
+ res.UnsafeSetTaggedPointer(ptr);
return res;
}
};
@@ -611,7 +614,9 @@ template <>
struct FromHelper<WireFormatLite::TYPE_BYTES> {
static ArenaStringPtr From(const string& x) {
ArenaStringPtr res;
- *res.UnsafeRawStringPointer() = const_cast<string*>(&x);
+ TaggedPtr< ::std::string> ptr;
+ ptr.Set(const_cast<string*>(&x));
+ res.UnsafeSetTaggedPointer(ptr);
return res;
}
};
diff --git a/src/google/protobuf/map_field.cc b/src/google/protobuf/map_field.cc
index 64dcc990..ec4f83e1 100644
--- a/src/google/protobuf/map_field.cc
+++ b/src/google/protobuf/map_field.cc
@@ -43,13 +43,15 @@ MapFieldBase::~MapFieldBase() {
const RepeatedPtrFieldBase& MapFieldBase::GetRepeatedField() const {
SyncRepeatedFieldWithMap();
- return *repeated_field_;
+ return *reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>(
+ repeated_field_);
}
RepeatedPtrFieldBase* MapFieldBase::MutableRepeatedField() {
SyncRepeatedFieldWithMap();
SetRepeatedDirty();
- return repeated_field_;
+ return reinterpret_cast< ::google::protobuf::internal::RepeatedPtrFieldBase*>(
+ repeated_field_);
}
size_t MapFieldBase::SpaceUsedExcludingSelfLong() const {
@@ -130,6 +132,7 @@ DynamicMapField::DynamicMapField(const Message* default_entry)
DynamicMapField::DynamicMapField(const Message* default_entry,
Arena* arena)
: TypeDefinedMapFieldBase<MapKey, MapValueRef>(arena),
+ map_(arena),
default_entry_(default_entry) {
}
diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc
index 080c71a7..d59f92d2 100644
--- a/src/google/protobuf/map_test.cc
+++ b/src/google/protobuf/map_test.cc
@@ -676,6 +676,16 @@ TEST_F(MapImplTest, InsertByIterator) {
ExpectElements(map1);
}
+#if LANG_CXX11
+TEST_F(MapImplTest, InsertByInitializerList) {
+ map_.insert({{1, 100}, {2, 200}});
+ ExpectElements({{1, 100}, {2, 200}});
+
+ map_.insert({{2, 201}, {3, 301}});
+ ExpectElements({{1, 100}, {2, 200}, {3, 301}});
+}
+#endif
+
TEST_F(MapImplTest, EraseSingleByKey) {
int32 key = 0;
int32 value = 100;
diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h
index ab018596..fc630b58 100644
--- a/src/google/protobuf/message.h
+++ b/src/google/protobuf/message.h
@@ -152,6 +152,9 @@ class CodedOutputStream; // coded_stream.h
namespace python {
class MapReflectionFriend; // scalar_map_container.h
}
+namespace expr {
+class CelMapReflectionFriend; // field_backed_map_impl.cc
+}
namespace internal {
@@ -406,9 +409,6 @@ class MutableRepeatedFieldRef;
// double the message's memory footprint, probably worse. Allocating the
// objects on-demand, on the other hand, would be expensive and prone to
// memory leaks. So, instead we ended up with this flat interface.
-//
-// TODO(kenton): Create a utility class which callers can use to read and
-// write fields from a Reflection without paying attention to the type.
class LIBPROTOBUF_EXPORT Reflection {
public:
inline Reflection() {}
@@ -815,6 +815,7 @@ class LIBPROTOBUF_EXPORT Reflection {
//
// for T = Cord and all protobuf scalar types except enums.
template<typename T>
+ PROTOBUF_RUNTIME_DEPRECATED("Please use GetRepeatedFieldRef() instead")
const RepeatedField<T>& GetRepeatedField(
const Message&, const FieldDescriptor*) const;
@@ -822,6 +823,7 @@ class LIBPROTOBUF_EXPORT Reflection {
//
// for T = Cord and all protobuf scalar types except enums.
template<typename T>
+ PROTOBUF_RUNTIME_DEPRECATED("Please use GetMutableRepeatedFieldRef() instead")
RepeatedField<T>* MutableRepeatedField(
Message*, const FieldDescriptor*) const;
@@ -830,6 +832,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// for T = string, google::protobuf::internal::StringPieceField
// google::protobuf::Message & descendants.
template<typename T>
+ PROTOBUF_RUNTIME_DEPRECATED("Please use GetRepeatedFieldRef() instead")
const RepeatedPtrField<T>& GetRepeatedPtrField(
const Message&, const FieldDescriptor*) const;
@@ -838,6 +841,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// for T = string, google::protobuf::internal::StringPieceField
// google::protobuf::Message & descendants.
template<typename T>
+ PROTOBUF_RUNTIME_DEPRECATED("Please use GetMutableRepeatedFieldRef() instead")
RepeatedPtrField<T>* MutableRepeatedPtrField(
Message*, const FieldDescriptor*) const;
@@ -949,6 +953,8 @@ class LIBPROTOBUF_EXPORT Reflection {
template<typename T, typename Enable>
friend class MutableRepeatedFieldRef;
friend class ::google::protobuf::python::MapReflectionFriend;
+#define GOOGLE_PROTOBUF_HAS_CEL_MAP_REFLECTION_FRIEND
+ friend class ::google::protobuf::expr::CelMapReflectionFriend;
friend class internal::MapFieldReflectionTest;
friend class internal::MapKeySorter;
friend class internal::WireFormat;
diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h
index 5cd6babc..0b2b24b2 100644
--- a/src/google/protobuf/message_lite.h
+++ b/src/google/protobuf/message_lite.h
@@ -48,6 +48,8 @@
namespace google {
namespace protobuf {
class Arena;
+template <typename T>
+class RepeatedPtrField;
namespace io {
class CodedInputStream;
class CodedOutputStream;
@@ -56,6 +58,7 @@ class ZeroCopyOutputStream;
}
namespace internal {
+class RepeatedPtrFieldBase;
class WireFormatLite;
#ifndef SWIG
@@ -380,6 +383,22 @@ class LIBPROTOBUF_EXPORT MessageLite {
virtual uint8* InternalSerializeWithCachedSizesToArray(bool deterministic,
uint8* target) const;
+ protected:
+ // CastToBase allows generated code to cast a RepeatedPtrField<T> to
+ // RepeatedPtrFieldBase. We try to restrict access to RepeatedPtrFieldBase
+ // because it is an implementation detail that user code should not access
+ // directly.
+ template <typename T>
+ static ::google::protobuf::internal::RepeatedPtrFieldBase* CastToBase(
+ ::google::protobuf::RepeatedPtrField<T>* repeated) {
+ return repeated;
+ }
+ template <typename T>
+ static const ::google::protobuf::internal::RepeatedPtrFieldBase& CastToBase(
+ const ::google::protobuf::RepeatedPtrField<T>& repeated) {
+ return repeated;
+ }
+
private:
// TODO(gerbens) make this a pure abstract function
virtual const void* InternalGetTable() const { return NULL; }
diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc
index d1867311..eb2a0e7a 100644
--- a/src/google/protobuf/reflection_ops.cc
+++ b/src/google/protobuf/reflection_ops.cc
@@ -31,13 +31,15 @@
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#include <google/protobuf/reflection_ops.h>
#include <string>
#include <vector>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/descriptor.h>
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.h>
#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/descriptor.h>
#include <google/protobuf/map_field.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/stubs/strutil.h>
@@ -46,6 +48,17 @@ namespace google {
namespace protobuf {
namespace internal {
+static const Reflection* GetReflectionOrDie(const Message& m) {
+ const Reflection* r = m.GetReflection();
+ if (r == NULL) {
+ const Descriptor* d = m.GetDescriptor();
+ const string& mtype = d ? d->name() : "unknown";
+ // RawMessage is one known type for which GetReflection() returns NULL.
+ GOOGLE_LOG(FATAL) << "Message does not support reflection (type " << mtype << ").";
+ }
+ return r;
+}
+
void ReflectionOps::Copy(const Message& from, Message* to) {
if (&from == to) return;
Clear(to);
@@ -61,8 +74,8 @@ void ReflectionOps::Merge(const Message& from, Message* to) {
<< "(merge " << descriptor->full_name()
<< " to " << to->GetDescriptor()->full_name() << ")";
- const Reflection* from_reflection = from.GetReflection();
- const Reflection* to_reflection = to->GetReflection();
+ const Reflection* from_reflection = GetReflectionOrDie(from);
+ const Reflection* to_reflection = GetReflectionOrDie(*to);
std::vector<const FieldDescriptor*> fields;
from_reflection->ListFields(from, &fields);
@@ -128,7 +141,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) {
}
void ReflectionOps::Clear(Message* message) {
- const Reflection* reflection = message->GetReflection();
+ const Reflection* reflection = GetReflectionOrDie(*message);
std::vector<const FieldDescriptor*> fields;
reflection->ListFields(*message, &fields);
@@ -141,7 +154,7 @@ void ReflectionOps::Clear(Message* message) {
bool ReflectionOps::IsInitialized(const Message& message) {
const Descriptor* descriptor = message.GetDescriptor();
- const Reflection* reflection = message.GetReflection();
+ const Reflection* reflection = GetReflectionOrDie(message);
// Check required fields of this message.
for (int i = 0; i < descriptor->field_count(); i++) {
@@ -201,7 +214,7 @@ bool ReflectionOps::IsInitialized(const Message& message) {
}
void ReflectionOps::DiscardUnknownFields(Message* message) {
- const Reflection* reflection = message->GetReflection();
+ const Reflection* reflection = GetReflectionOrDie(*message);
reflection->MutableUnknownFields(message)->Clear();
@@ -248,7 +261,7 @@ void ReflectionOps::FindInitializationErrors(
const string& prefix,
std::vector<string>* errors) {
const Descriptor* descriptor = message.GetDescriptor();
- const Reflection* reflection = message.GetReflection();
+ const Reflection* reflection = GetReflectionOrDie(message);
// Check required fields of this message.
for (int i = 0; i < descriptor->field_count(); i++) {
diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc
index 5ca964c1..310000aa 100644
--- a/src/google/protobuf/repeated_field.cc
+++ b/src/google/protobuf/repeated_field.cc
@@ -103,6 +103,22 @@ void RepeatedPtrFieldBase::CloseGap(int start, int num) {
rep_->allocated_size -= num;
}
+google::protobuf::MessageLite* RepeatedPtrFieldBase::AddWeak(
+ const google::protobuf::MessageLite* prototype) {
+ if (rep_ != NULL && current_size_ < rep_->allocated_size) {
+ return reinterpret_cast<google::protobuf::MessageLite*>(
+ rep_->elements[current_size_++]);
+ }
+ if (!rep_ || rep_->allocated_size == total_size_) {
+ Reserve(total_size_ + 1);
+ }
+ ++rep_->allocated_size;
+ google::protobuf::MessageLite* result = prototype ? prototype->New(arena_) :
+ Arena::CreateMessage<ImplicitWeakMessage>(arena_);
+ rep_->elements[current_size_++] = result;
+ return result;
+}
+
} // namespace internal
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h
index 8eb6c795..5fc619f2 100644
--- a/src/google/protobuf/repeated_field.h
+++ b/src/google/protobuf/repeated_field.h
@@ -57,8 +57,8 @@
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/type_traits.h>
#include <google/protobuf/arena.h>
+#include <google/protobuf/implicit_weak_message.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/stubs/port.h>
@@ -86,7 +86,7 @@ void LogIndexOutOfBounds(int index, int size);
template <typename Iter>
inline int CalculateReserve(Iter begin, Iter end, std::forward_iterator_tag) {
- return std::distance(begin, end);
+ return static_cast<int>(std::distance(begin, end));
}
template <typename Iter>
@@ -279,9 +279,19 @@ class RepeatedField PROTOBUF_FINAL {
// a "gap" after the field arena and before the field elements (e.g., when
// Element is double and pointer is 32bit).
static const size_t kRepHeaderSize;
- // Contains arena ptr and the elements array. We also keep the invariant that
- // if rep_ is NULL, then arena is NULL.
- Rep* rep_;
+
+ // 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.
+ Rep* rep; // When total_size_ != 0.
+ } ptr_;
+
+ Rep* rep() const {
+ GOOGLE_DCHECK_GT(total_size_, 0);
+ return ptr_.rep;
+ }
friend class Arena;
typedef void InternalArenaConstructable_;
@@ -297,7 +307,7 @@ class RepeatedField PROTOBUF_FINAL {
// Internal helper expected by Arena methods.
inline Arena* GetArenaNoVirtual() const {
- return (rep_ == NULL) ? NULL : rep_->arena;
+ return (total_size_ == 0) ? ptr_.arena : ptr_.rep->arena;
}
// Internal helper to delete all elements and deallocate the storage.
@@ -399,7 +409,12 @@ struct TypeImplementsMergeBehavior< ::std::string> {
// class TypeHandler {
// public:
// typedef MyType Type;
+// // WeakType is almost always the same as MyType, but we use it in
+// // ImplicitWeakTypeHandler.
+// typedef MyType WeakType;
// static Type* New();
+// static WeakType* NewFromPrototype(const WeakType* prototype,
+// ::google::protobuf::Arena* arena);
// static void Delete(Type*);
// static void Clear(Type*);
// static void Merge(const Type& from, Type* to);
@@ -409,31 +424,6 @@ struct TypeImplementsMergeBehavior< ::std::string> {
// };
class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
protected:
- // The reflection implementation needs to call protected methods directly,
- // reinterpreting pointers as being to Message instead of a specific Message
- // subclass.
- friend class GeneratedMessageReflection;
-
- // ExtensionSet stores repeated message extensions as
- // RepeatedPtrField<MessageLite>, but non-lite ExtensionSets need to implement
- // SpaceUsedLong(), and thus need to call SpaceUsedExcludingSelfLong()
- // reinterpreting MessageLite as Message. ExtensionSet also needs to make use
- // of AddFromCleared(), which is not part of the public interface.
- friend class ExtensionSet;
-
- // The MapFieldBase implementation needs to call protected methods directly,
- // reinterpreting pointers as being to Message instead of a specific Message
- // subclass.
- friend class MapFieldBase;
-
- // The table-driven MergePartialFromCodedStream implementation needs to
- // operate on RepeatedPtrField<MessageLite>.
- friend class MergePartialFromCodedStreamHelper;
-
- // To parse directly into a proto2 generated class, the upb class GMR_Handlers
- // needs to be able to modify a RepeatedPtrFieldBase directly.
- friend class upb::google_opensource::GMR_Handlers;
-
RepeatedPtrFieldBase();
explicit RepeatedPtrFieldBase(::google::protobuf::Arena* arena);
~RepeatedPtrFieldBase() {}
@@ -446,13 +436,35 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
int size() const;
template <typename TypeHandler>
- const typename TypeHandler::Type& Get(int index) const;
- template <typename TypeHandler>
typename TypeHandler::Type* Mutable(int index);
template <typename TypeHandler>
void Delete(int index);
template <typename TypeHandler>
typename TypeHandler::Type* Add(typename TypeHandler::Type* prototype = NULL);
+
+ public:
+ // The next few methods are public so that they can be called from generated
+ // code when implicit weak fields are used, but they should never be called by
+ // application code.
+
+ template <typename TypeHandler>
+ const typename TypeHandler::WeakType& Get(int index) const;
+
+ // Creates and adds an element using the given prototype, without introducing
+ // a link-time dependency on the concrete message type. This method is used to
+ // implement implicit weak fields. The prototype may be NULL, in which case an
+ // ImplicitWeakMessage will be used as a placeholder.
+ google::protobuf::MessageLite* AddWeak(const google::protobuf::MessageLite* prototype);
+
+ template <typename TypeHandler>
+ void Clear();
+
+ template <typename TypeHandler>
+ void MergeFrom(const RepeatedPtrFieldBase& other);
+
+ inline void InternalSwap(RepeatedPtrFieldBase* other);
+
+ protected:
#if LANG_CXX11
template <typename TypeHandler>
void Add(typename TypeHandler::Type&& value,
@@ -462,10 +474,6 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
void RemoveLast();
template <typename TypeHandler>
- void Clear();
- template <typename TypeHandler>
- void MergeFrom(const RepeatedPtrFieldBase& other);
- template <typename TypeHandler>
void CopyFrom(const RepeatedPtrFieldBase& other);
void CloseGap(int start, int num);
@@ -491,7 +499,6 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
size_t SpaceUsedExcludingSelfLong() const;
-
// Advanced memory management --------------------------------------
// Like Add(), but if there are no cleared objects to use, returns NULL.
@@ -524,9 +531,6 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
typename TypeHandler::Type* ReleaseCleared();
- protected:
- inline void InternalSwap(RepeatedPtrFieldBase* other);
-
template <typename TypeHandler>
void AddAllocatedInternal(typename TypeHandler::Type* value, google::protobuf::internal::true_type);
template <typename TypeHandler>
@@ -601,7 +605,33 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
// Reserve() and MergeFrom() to reduce code size. |extend_amount| must be > 0.
void** InternalExtend(int extend_amount);
+ // The reflection implementation needs to call protected methods directly,
+ // reinterpreting pointers as being to Message instead of a specific Message
+ // subclass.
+ friend class GeneratedMessageReflection;
+
+ // ExtensionSet stores repeated message extensions as
+ // RepeatedPtrField<MessageLite>, but non-lite ExtensionSets need to implement
+ // SpaceUsedLong(), and thus need to call SpaceUsedExcludingSelfLong()
+ // reinterpreting MessageLite as Message. ExtensionSet also needs to make use
+ // of AddFromCleared(), which is not part of the public interface.
+ friend class ExtensionSet;
+
+ // The MapFieldBase implementation needs to call protected methods directly,
+ // reinterpreting pointers as being to Message instead of a specific Message
+ // subclass.
+ friend class MapFieldBase;
+
+ // The table-driven MergePartialFromCodedStream implementation needs to
+ // operate on RepeatedPtrField<MessageLite>.
+ friend class MergePartialFromCodedStreamHelper;
+
+ // To parse directly into a proto2 generated class, the upb class GMR_Handlers
+ // needs to be able to modify a RepeatedPtrFieldBase directly.
+ friend class upb::google_opensource::GMR_Handlers;
+
friend class AccessorHelper;
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPtrFieldBase);
};
@@ -609,6 +639,7 @@ template <typename GenericType>
class GenericTypeHandler {
public:
typedef GenericType Type;
+ typedef GenericType WeakType;
#if LANG_CXX11
static const bool Moveable = false;
#endif
@@ -636,9 +667,6 @@ class GenericTypeHandler {
static inline size_t SpaceUsedLong(const GenericType& value) {
return value.SpaceUsedLong();
}
- static inline const Type& default_instance() {
- return Type::default_instance();
- }
};
template <typename GenericType>
@@ -700,28 +728,10 @@ DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES(Message)
#undef DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES
-template <>
-inline const MessageLite& GenericTypeHandler<MessageLite>::default_instance() {
- // Yes, the behavior of the code is undefined, but this function is only
- // called when we're already deep into the world of undefined, because the
- // caller called Get(index) out of bounds.
- MessageLite* null = NULL;
- return *null;
-}
-
-template <>
-inline const Message& GenericTypeHandler<Message>::default_instance() {
- // Yes, the behavior of the code is undefined, but this function is only
- // called when we're already deep into the world of undefined, because the
- // caller called Get(index) out of bounds.
- Message* null = NULL;
- return *null;
-}
-
-
class StringTypeHandler {
public:
typedef string Type;
+ typedef string WeakType;
#if LANG_CXX11
static const bool Moveable =
std::is_move_constructible<Type>::value &&
@@ -753,9 +763,6 @@ class StringTypeHandler {
}
static inline void Clear(string* value) { value->clear(); }
static inline void Merge(const string& from, string* to) { *to = from; }
- static inline const Type& default_instance() {
- return ::google::protobuf::internal::GetEmptyString();
- }
static size_t SpaceUsedLong(const string& value) {
return sizeof(value) + StringSpaceUsedExcludingSelfLong(value);
}
@@ -766,7 +773,7 @@ class StringTypeHandler {
// RepeatedPtrField is like RepeatedField, but used for repeated strings or
// Messages.
template <typename Element>
-class RepeatedPtrField PROTOBUF_FINAL : public internal::RepeatedPtrFieldBase {
+class RepeatedPtrField PROTOBUF_FINAL : private internal::RepeatedPtrFieldBase {
public:
RepeatedPtrField();
explicit RepeatedPtrField(::google::protobuf::Arena* arena);
@@ -1025,6 +1032,8 @@ class RepeatedPtrField PROTOBUF_FINAL : public internal::RepeatedPtrFieldBase {
google::protobuf::internal::false_type);
friend class Arena;
+ friend class MessageLite;
+
typedef void InternalArenaConstructable_;
};
@@ -1035,33 +1044,25 @@ template <typename Element>
inline RepeatedField<Element>::RepeatedField()
: current_size_(0),
total_size_(0),
- rep_(NULL) {
+ ptr_(NULL) {
}
template <typename Element>
inline RepeatedField<Element>::RepeatedField(Arena* arena)
: current_size_(0),
total_size_(0),
- rep_(NULL) {
- // In case arena is NULL, then we do not create rep_, as code has an invariant
- // `rep_ == NULL then arena == NULL`.
- if (arena != NULL) {
- rep_ = reinterpret_cast<Rep*>(
- ::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize));
- rep_->arena = arena;
- }
+ ptr_(arena) {
}
template <typename Element>
inline RepeatedField<Element>::RepeatedField(const RepeatedField& other)
: current_size_(0),
total_size_(0),
- rep_(NULL) {
+ ptr_(NULL) {
if (other.current_size_ != 0) {
- Reserve(other.current_size_);
- CopyArray(rep_->elements,
- other.rep_->elements, other.current_size_);
- current_size_ = other.current_size_;
+ Reserve(other.size());
+ AddNAlreadyReserved(other.size());
+ CopyArray(Mutable(0), &other.Get(0), other.size());
}
}
@@ -1070,7 +1071,7 @@ template <typename Iter>
RepeatedField<Element>::RepeatedField(Iter begin, const Iter& end)
: current_size_(0),
total_size_(0),
- rep_(NULL) {
+ ptr_(NULL) {
int reserve = internal::CalculateReserve(begin, end);
if (reserve != -1) {
Reserve(reserve);
@@ -1086,9 +1087,9 @@ RepeatedField<Element>::RepeatedField(Iter begin, const Iter& end)
template <typename Element>
RepeatedField<Element>::~RepeatedField() {
- // See explanation in Reserve(): we need to invoke destructors here for the
- // case that Element has a non-trivial destructor.
- InternalDeallocate(rep_, total_size_);
+ if (total_size_ > 0) {
+ InternalDeallocate(rep(), total_size_);
+ }
}
template <typename Element>
@@ -1148,19 +1149,21 @@ inline int RepeatedField<Element>::Capacity() const {
template<typename Element>
inline void RepeatedField<Element>::AddAlreadyReserved(const Element& value) {
GOOGLE_DCHECK_LT(current_size_, total_size_);
- rep_->elements[current_size_++] = value;
+ rep()->elements[current_size_++] = value;
}
template<typename Element>
inline Element* RepeatedField<Element>::AddAlreadyReserved() {
GOOGLE_DCHECK_LT(current_size_, total_size_);
- return &rep_->elements[current_size_++];
+ return &rep()->elements[current_size_++];
}
template<typename Element>
inline Element* RepeatedField<Element>::AddNAlreadyReserved(int elements) {
GOOGLE_DCHECK_LE(current_size_ + elements, total_size_);
- Element* ret = &rep_->elements[current_size_];
+ // Warning: total_size_ can be NULL if elements == 0 && current_size_ == 0.
+ // Existing callers depend on this behavior. :(
+ Element* ret = &ptr_.rep->elements[current_size_];
current_size_ += elements;
return ret;
}
@@ -1170,8 +1173,8 @@ inline void RepeatedField<Element>::Resize(int new_size, const Element& value) {
GOOGLE_DCHECK_GE(new_size, 0);
if (new_size > current_size_) {
Reserve(new_size);
- std::fill(&rep_->elements[current_size_],
- &rep_->elements[new_size], value);
+ std::fill(&rep()->elements[current_size_],
+ &rep()->elements[new_size], value);
}
current_size_ = new_size;
}
@@ -1180,33 +1183,33 @@ template <typename Element>
inline const Element& RepeatedField<Element>::Get(int index) const {
GOOGLE_DCHECK_GE(index, 0);
GOOGLE_DCHECK_LT(index, current_size_);
- return rep_->elements[index];
+ return rep()->elements[index];
}
template <typename Element>
inline Element* RepeatedField<Element>::Mutable(int index) {
GOOGLE_DCHECK_GE(index, 0);
GOOGLE_DCHECK_LT(index, current_size_);
- return &rep_->elements[index];
+ return &rep()->elements[index];
}
template <typename Element>
inline void RepeatedField<Element>::Set(int index, const Element& value) {
GOOGLE_DCHECK_GE(index, 0);
GOOGLE_DCHECK_LT(index, current_size_);
- rep_->elements[index] = value;
+ rep()->elements[index] = value;
}
template <typename Element>
inline void RepeatedField<Element>::Add(const Element& value) {
if (current_size_ == total_size_) Reserve(total_size_ + 1);
- rep_->elements[current_size_++] = value;
+ rep()->elements[current_size_++] = value;
}
template <typename Element>
inline Element* RepeatedField<Element>::Add() {
if (current_size_ == total_size_) Reserve(total_size_ + 1);
- return &rep_->elements[current_size_++];
+ return &rep()->elements[current_size_++];
}
template <typename Element>
@@ -1245,10 +1248,10 @@ template <typename Element>
inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) {
GOOGLE_DCHECK_NE(&other, this);
if (other.current_size_ != 0) {
- Reserve(current_size_ + other.current_size_);
- CopyArray(rep_->elements + current_size_,
- other.rep_->elements, other.current_size_);
- current_size_ += other.current_size_;
+ int existing_size = size();
+ Reserve(existing_size + other.size());
+ AddNAlreadyReserved(other.size());
+ CopyArray(Mutable(existing_size), &other.Get(0), other.size());
}
}
@@ -1277,18 +1280,17 @@ inline typename RepeatedField<Element>::iterator RepeatedField<Element>::erase(
template <typename Element>
inline Element* RepeatedField<Element>::mutable_data() {
- return rep_ ? rep_->elements : NULL;
+ return total_size_ > 0 ? rep()->elements : NULL;
}
template <typename Element>
inline const Element* RepeatedField<Element>::data() const {
- return rep_ ? rep_->elements : NULL;
+ return total_size_ > 0 ? rep()->elements : NULL;
}
template <typename Element>
inline const Element* RepeatedField<Element>::unsafe_data() const {
- GOOGLE_DCHECK(rep_);
- return rep_->elements;
+ return rep()->elements;
}
template <typename Element>
@@ -1296,7 +1298,7 @@ inline void RepeatedField<Element>::InternalSwap(RepeatedField* other) {
GOOGLE_DCHECK(this != other);
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
- std::swap(rep_, other->rep_);
+ std::swap(ptr_, other->ptr_);
std::swap(current_size_, other->current_size_);
std::swap(total_size_, other->total_size_);
}
@@ -1323,43 +1325,43 @@ void RepeatedField<Element>::UnsafeArenaSwap(RepeatedField* other) {
template <typename Element>
void RepeatedField<Element>::SwapElements(int index1, int index2) {
using std::swap; // enable ADL with fallback
- swap(rep_->elements[index1], rep_->elements[index2]);
+ swap(rep()->elements[index1], rep()->elements[index2]);
}
template <typename Element>
inline typename RepeatedField<Element>::iterator
RepeatedField<Element>::begin() {
- return rep_ ? rep_->elements : NULL;
+ return total_size_ > 0 ? rep()->elements : NULL;
}
template <typename Element>
inline typename RepeatedField<Element>::const_iterator
RepeatedField<Element>::begin() const {
- return rep_ ? rep_->elements : NULL;
+ return total_size_ > 0 ? rep()->elements : NULL;
}
template <typename Element>
inline typename RepeatedField<Element>::const_iterator
RepeatedField<Element>::cbegin() const {
- return rep_ ? rep_->elements : NULL;
+ return total_size_ > 0 ? rep()->elements : NULL;
}
template <typename Element>
inline typename RepeatedField<Element>::iterator
RepeatedField<Element>::end() {
- return rep_ ? rep_->elements + current_size_ : NULL;
+ return total_size_ > 0 ? rep()->elements + current_size_ : NULL;
}
template <typename Element>
inline typename RepeatedField<Element>::const_iterator
RepeatedField<Element>::end() const {
- return rep_ ? rep_->elements + current_size_ : NULL;
+ return total_size_ > 0 ? rep()->elements + current_size_ : NULL;
}
template <typename Element>
inline typename RepeatedField<Element>::const_iterator
RepeatedField<Element>::cend() const {
- return rep_ ? rep_->elements + current_size_ : NULL;
+ return total_size_ > 0 ? rep()->elements + current_size_ : NULL;
}
template <typename Element>
inline size_t RepeatedField<Element>::SpaceUsedExcludingSelfLong() const {
- return rep_ ? (total_size_ * sizeof(Element) + kRepHeaderSize) : 0;
+ return total_size_ > 0 ? (total_size_ * sizeof(Element) + kRepHeaderSize) : 0;
}
// Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant
@@ -1367,7 +1369,7 @@ inline size_t RepeatedField<Element>::SpaceUsedExcludingSelfLong() const {
template <typename Element>
void RepeatedField<Element>::Reserve(int new_size) {
if (total_size_ >= new_size) return;
- Rep* old_rep = rep_;
+ Rep* old_rep = total_size_ > 0 ? rep() : NULL;
Arena* arena = GetArenaNoVirtual();
new_size = std::max(google::protobuf::internal::kMinRepeatedFieldAllocationSize,
std::max(total_size_ * 2, new_size));
@@ -1377,12 +1379,12 @@ void RepeatedField<Element>::Reserve(int new_size) {
<< "Requested size is too large to fit into size_t.";
size_t bytes = kRepHeaderSize + sizeof(Element) * static_cast<size_t>(new_size);
if (arena == NULL) {
- rep_ = static_cast<Rep*>(::operator new(bytes));
+ ptr_.rep = static_cast<Rep*>(::operator new(bytes));
} else {
- rep_ = reinterpret_cast<Rep*>(
+ ptr_.rep = reinterpret_cast<Rep*>(
::google::protobuf::Arena::CreateArray<char>(arena, bytes));
}
- rep_->arena = arena;
+ ptr_.rep->arena = arena;
int old_total_size = total_size_;
total_size_ = new_size;
// Invoke placement-new on newly allocated elements. We shouldn't have to do
@@ -1394,13 +1396,13 @@ void RepeatedField<Element>::Reserve(int new_size) {
// effect unless its side-effects are required for correctness.
// Note that we do this before MoveArray() below because Element's copy
// assignment implementation will want an initialized instance first.
- Element* e = &rep_->elements[0];
- Element* limit = &rep_->elements[total_size_];
+ Element* e = &rep()->elements[0];
+ Element* limit = e + total_size_;
for (; e < limit; e++) {
new (e) Element;
}
if (current_size_ > 0) {
- MoveArray(rep_->elements, old_rep->elements, current_size_);
+ MoveArray(&rep()->elements[0], old_rep->elements, current_size_);
}
// Likewise, we need to invoke destructors on the old array.
@@ -1516,14 +1518,13 @@ inline int RepeatedPtrFieldBase::size() const {
}
template <typename TypeHandler>
-inline const typename TypeHandler::Type&
+inline const typename TypeHandler::WeakType&
RepeatedPtrFieldBase::Get(int index) const {
GOOGLE_DCHECK_GE(index, 0);
GOOGLE_DCHECK_LT(index, current_size_);
return *cast<TypeHandler>(rep_->elements[index]);
}
-
template <typename TypeHandler>
inline typename TypeHandler::Type*
RepeatedPtrFieldBase::Mutable(int index) {
@@ -1632,18 +1633,18 @@ void RepeatedPtrFieldBase::MergeFromInnerLoop(
// to avoid a branch within the loop.
for (int i = 0; i < already_allocated && i < length; i++) {
// Already allocated: use existing element.
- typename TypeHandler::Type* other_elem =
- reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]);
- typename TypeHandler::Type* new_elem =
- reinterpret_cast<typename TypeHandler::Type*>(our_elems[i]);
+ typename TypeHandler::WeakType* other_elem =
+ reinterpret_cast<typename TypeHandler::WeakType*>(other_elems[i]);
+ typename TypeHandler::WeakType* new_elem =
+ reinterpret_cast<typename TypeHandler::WeakType*>(our_elems[i]);
TypeHandler::Merge(*other_elem, new_elem);
}
Arena* arena = GetArenaNoVirtual();
for (int i = already_allocated; i < length; i++) {
// Not allocated: alloc a new element first, then merge it.
- typename TypeHandler::Type* other_elem =
- reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]);
- typename TypeHandler::Type* new_elem =
+ typename TypeHandler::WeakType* other_elem =
+ reinterpret_cast<typename TypeHandler::WeakType*>(other_elems[i]);
+ typename TypeHandler::WeakType* new_elem =
TypeHandler::NewFromPrototype(other_elem, arena);
TypeHandler::Merge(*other_elem, new_elem);
our_elems[i] = new_elem;
diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc
index 4a290e1e..b9d8f3cb 100644
--- a/src/google/protobuf/source_context.pb.cc
+++ b/src/google/protobuf/source_context.pb.cc
@@ -175,13 +175,6 @@ const SourceContext& SourceContext::default_instance() {
return *internal_default_instance();
}
-SourceContext* SourceContext::New(::google::protobuf::Arena* arena) const {
- SourceContext* n = new SourceContext;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
void SourceContext::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceContext)
@@ -377,5 +370,12 @@ void SourceContext::InternalSwap(SourceContext* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::SourceContext* Arena::Create< ::google::protobuf::SourceContext >(Arena* arena) {
+ return Arena::CreateInternal< ::google::protobuf::SourceContext >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h
index 1e5499ca..74a41850 100644
--- a/src/google/protobuf/source_context.pb.h
+++ b/src/google/protobuf/source_context.pb.h
@@ -57,6 +57,11 @@ LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_defaul
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::SourceContext* Arena::Create< ::google::protobuf::SourceContext>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
// ===================================================================
@@ -104,9 +109,13 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @
// implements Message ----------------------------------------------
- inline SourceContext* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline SourceContext* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<SourceContext>(NULL);
+ }
- SourceContext* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ SourceContext* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::Create<SourceContext>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const SourceContext& from);
diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc
index fe3ba327..309a4d2d 100644
--- a/src/google/protobuf/struct.pb.cc
+++ b/src/google/protobuf/struct.pb.cc
@@ -298,9 +298,6 @@ const Struct& Struct::default_instance() {
return *internal_default_instance();
}
-Struct* Struct::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Struct>(arena);
-}
void Struct::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Struct)
@@ -762,9 +759,6 @@ const Value& Value::default_instance() {
return *internal_default_instance();
}
-Value* Value::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Value>(arena);
-}
void Value::clear_kind() {
// @@protoc_insertion_point(one_of_clear_start:google.protobuf.Value)
@@ -1268,9 +1262,6 @@ const ListValue& ListValue::default_instance() {
return *internal_default_instance();
}
-ListValue* ListValue::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<ListValue>(arena);
-}
void ListValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ListValue)
@@ -1296,7 +1287,8 @@ bool ListValue::MergePartialFromCodedStream(
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_values()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_values()));
} else {
goto handle_unusual;
}
@@ -1333,7 +1325,9 @@ void ListValue::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->values_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1, this->values(static_cast<int>(i)), output);
+ 1,
+ this->values(static_cast<int>(i)),
+ output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
@@ -1457,7 +1451,7 @@ void ListValue::UnsafeArenaSwap(ListValue* other) {
}
void ListValue::InternalSwap(ListValue* other) {
using std::swap;
- values_.InternalSwap(&other->values_);
+ CastToBase(&values_)->InternalSwap(CastToBase(&other->values_));
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
}
@@ -1471,5 +1465,21 @@ void ListValue::InternalSwap(ListValue* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Struct_FieldsEntry_DoNotUse* Arena::CreateMessage< ::google::protobuf::Struct_FieldsEntry_DoNotUse >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Struct_FieldsEntry_DoNotUse >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Struct* Arena::CreateMessage< ::google::protobuf::Struct >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Struct >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Value* Arena::CreateMessage< ::google::protobuf::Value >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Value >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ListValue* Arena::CreateMessage< ::google::protobuf::ListValue >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::ListValue >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h
index 83b7da6d..45c168b9 100644
--- a/src/google/protobuf/struct.pb.h
+++ b/src/google/protobuf/struct.pb.h
@@ -70,6 +70,14 @@ LIBPROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_;
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::ListValue* Arena::CreateMessage< ::google::protobuf::ListValue>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Struct* Arena::CreateMessage< ::google::protobuf::Struct>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Struct_FieldsEntry_DoNotUse* Arena::CreateMessage< ::google::protobuf::Struct_FieldsEntry_DoNotUse>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Value* Arena::CreateMessage< ::google::protobuf::Value>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
enum NullValue {
NULL_VALUE = 0,
@@ -165,9 +173,13 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc
// implements Message ----------------------------------------------
- inline Struct* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Struct* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Struct>(NULL);
+ }
- Struct* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Struct* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Struct>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Struct& from);
@@ -298,9 +310,13 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
// implements Message ----------------------------------------------
- inline Value* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Value* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Value>(NULL);
+ }
- Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Value>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Value& from);
@@ -398,9 +414,6 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
bool has_struct_value() const;
void clear_struct_value();
static const int kStructValueFieldNumber = 5;
- private:
- void _slow_mutable_struct_value();
- public:
const ::google::protobuf::Struct& struct_value() const;
::google::protobuf::Struct* release_struct_value();
::google::protobuf::Struct* mutable_struct_value();
@@ -413,9 +426,6 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
bool has_list_value() const;
void clear_list_value();
static const int kListValueFieldNumber = 6;
- private:
- void _slow_mutable_list_value();
- public:
const ::google::protobuf::ListValue& list_value() const;
::google::protobuf::ListValue* release_list_value();
::google::protobuf::ListValue* mutable_list_value();
@@ -510,9 +520,13 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro
// implements Message ----------------------------------------------
- inline ListValue* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline ListValue* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<ListValue>(NULL);
+ }
- ListValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ ListValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<ListValue>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ListValue& from);
@@ -557,11 +571,11 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro
int values_size() const;
void clear_values();
static const int kValuesFieldNumber = 1;
- const ::google::protobuf::Value& values(int index) const;
::google::protobuf::Value* mutable_values(int index);
- ::google::protobuf::Value* add_values();
::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >*
mutable_values();
+ const ::google::protobuf::Value& values(int index) const;
+ ::google::protobuf::Value* add_values();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >&
values() const;
@@ -881,9 +895,8 @@ inline ::google::protobuf::Struct* Value::mutable_struct_value() {
if (!has_struct_value()) {
clear_kind();
set_has_struct_value();
- kind_.struct_value_ =
- ::google::protobuf::Arena::CreateMessage< ::google::protobuf::Struct >(
- GetArenaNoVirtual());
+ kind_.struct_value_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::Struct >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.Value.struct_value)
return kind_.struct_value_;
@@ -947,9 +960,8 @@ inline ::google::protobuf::ListValue* Value::mutable_list_value() {
if (!has_list_value()) {
clear_kind();
set_has_list_value();
- kind_.list_value_ =
- ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ListValue >(
- GetArenaNoVirtual());
+ kind_.list_value_ = ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ListValue >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.Value.list_value)
return kind_.list_value_;
@@ -975,23 +987,23 @@ inline int ListValue::values_size() const {
inline void ListValue::clear_values() {
values_.Clear();
}
-inline const ::google::protobuf::Value& ListValue::values(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.ListValue.values)
- return values_.Get(index);
-}
inline ::google::protobuf::Value* ListValue::mutable_values(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.ListValue.values)
return values_.Mutable(index);
}
-inline ::google::protobuf::Value* ListValue::add_values() {
- // @@protoc_insertion_point(field_add:google.protobuf.ListValue.values)
- return values_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >*
ListValue::mutable_values() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.ListValue.values)
return &values_;
}
+inline const ::google::protobuf::Value& ListValue::values(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.ListValue.values)
+ return values_.Get(index);
+}
+inline ::google::protobuf::Value* ListValue::add_values() {
+ // @@protoc_insertion_point(field_add:google.protobuf.ListValue.values)
+ return values_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >&
ListValue::values() const {
// @@protoc_insertion_point(field_list:google.protobuf.ListValue.values)
diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc
index 36e3bb36..f57d4d66 100644
--- a/src/google/protobuf/timestamp.pb.cc
+++ b/src/google/protobuf/timestamp.pb.cc
@@ -191,9 +191,6 @@ const Timestamp& Timestamp::default_instance() {
return *internal_default_instance();
}
-Timestamp* Timestamp::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Timestamp>(arena);
-}
void Timestamp::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Timestamp)
@@ -427,5 +424,12 @@ void Timestamp::InternalSwap(Timestamp* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Timestamp* Arena::CreateMessage< ::google::protobuf::Timestamp >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Timestamp >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h
index 4ec7f0a0..b4dbb379 100644
--- a/src/google/protobuf/timestamp.pb.h
+++ b/src/google/protobuf/timestamp.pb.h
@@ -57,6 +57,11 @@ LIBPROTOBUF_EXPORT extern TimestampDefaultTypeInternal _Timestamp_default_instan
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Timestamp* Arena::CreateMessage< ::google::protobuf::Timestamp>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
// ===================================================================
@@ -111,9 +116,13 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro
// implements Message ----------------------------------------------
- inline Timestamp* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Timestamp* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Timestamp>(NULL);
+ }
- Timestamp* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Timestamp* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Timestamp>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Timestamp& from);
diff --git a/src/google/protobuf/timestamp.proto b/src/google/protobuf/timestamp.proto
index 06750ab1..6074b1f7 100644
--- a/src/google/protobuf/timestamp.proto
+++ b/src/google/protobuf/timestamp.proto
@@ -114,8 +114,8 @@ option objc_class_prefix = "GPB";
// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
-// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--)
-// to obtain a formatter capable of generating timestamps in this format.
+// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--
+// ) to obtain a formatter capable of generating timestamps in this format.
//
//
message Timestamp {
diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc
index 92f6589c..a2edabb6 100644
--- a/src/google/protobuf/type.pb.cc
+++ b/src/google/protobuf/type.pb.cc
@@ -420,10 +420,6 @@ void Type::InitAsDefaultInstance() {
::google::protobuf::_Type_default_instance_._instance.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>(
::google::protobuf::SourceContext::internal_default_instance());
}
-void Type::_slow_mutable_source_context() {
- source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >(
- GetArenaNoVirtual());
-}
void Type::unsafe_arena_set_allocated_source_context(
::google::protobuf::SourceContext* source_context) {
if (GetArenaNoVirtual() == NULL) {
@@ -533,9 +529,6 @@ const Type& Type::default_instance() {
return *internal_default_instance();
}
-Type* Type::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Type>(arena);
-}
void Type::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Type)
@@ -585,7 +578,8 @@ bool Type::MergePartialFromCodedStream(
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_fields()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_fields()));
} else {
goto handle_unusual;
}
@@ -613,7 +607,8 @@ bool Type::MergePartialFromCodedStream(
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_options()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_options()));
} else {
goto handle_unusual;
}
@@ -687,7 +682,9 @@ void Type::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->fields_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, this->fields(static_cast<int>(i)), output);
+ 2,
+ this->fields(static_cast<int>(i)),
+ output);
}
// repeated string oneofs = 3;
@@ -704,13 +701,15 @@ void Type::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->options_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 4, this->options(static_cast<int>(i)), output);
+ 4,
+ this->options(static_cast<int>(i)),
+ output);
}
// .google.protobuf.SourceContext source_context = 5;
if (this->has_source_context()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 5, *this->source_context_, output);
+ 5, *source_context_, output);
}
// .google.protobuf.Syntax syntax = 6;
@@ -774,7 +773,7 @@ void Type::SerializeWithCachedSizes(
if (this->has_source_context()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 5, *this->source_context_, deterministic, target);
+ 5, *source_context_, deterministic, target);
}
// .google.protobuf.Syntax syntax = 6;
@@ -841,7 +840,7 @@ size_t Type::ByteSizeLong() const {
if (this->has_source_context()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->source_context_);
+ *source_context_);
}
// .google.protobuf.Syntax syntax = 6;
@@ -932,9 +931,9 @@ void Type::UnsafeArenaSwap(Type* other) {
}
void Type::InternalSwap(Type* other) {
using std::swap;
- fields_.InternalSwap(&other->fields_);
- oneofs_.InternalSwap(&other->oneofs_);
- options_.InternalSwap(&other->options_);
+ CastToBase(&fields_)->InternalSwap(CastToBase(&other->fields_));
+ oneofs_.InternalSwap(CastToBase(&other->oneofs_));
+ CastToBase(&options_)->InternalSwap(CastToBase(&other->options_));
name_.Swap(&other->name_);
swap(source_context_, other->source_context_);
swap(syntax_, other->syntax_);
@@ -1059,9 +1058,6 @@ const Field& Field::default_instance() {
return *internal_default_instance();
}
-Field* Field::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Field>(arena);
-}
void Field::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Field)
@@ -1198,7 +1194,8 @@ bool Field::MergePartialFromCodedStream(
case 9: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(74u /* 74 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_options()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_options()));
} else {
goto handle_unusual;
}
@@ -1314,7 +1311,9 @@ void Field::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->options_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 9, this->options(static_cast<int>(i)), output);
+ 9,
+ this->options(static_cast<int>(i)),
+ output);
}
// string json_name = 10;
@@ -1615,7 +1614,7 @@ void Field::UnsafeArenaSwap(Field* other) {
}
void Field::InternalSwap(Field* other) {
using std::swap;
- options_.InternalSwap(&other->options_);
+ CastToBase(&options_)->InternalSwap(CastToBase(&other->options_));
name_.Swap(&other->name_);
type_url_.Swap(&other->type_url_);
json_name_.Swap(&other->json_name_);
@@ -1641,10 +1640,6 @@ void Enum::InitAsDefaultInstance() {
::google::protobuf::_Enum_default_instance_._instance.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>(
::google::protobuf::SourceContext::internal_default_instance());
}
-void Enum::_slow_mutable_source_context() {
- source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >(
- GetArenaNoVirtual());
-}
void Enum::unsafe_arena_set_allocated_source_context(
::google::protobuf::SourceContext* source_context) {
if (GetArenaNoVirtual() == NULL) {
@@ -1751,9 +1746,6 @@ const Enum& Enum::default_instance() {
return *internal_default_instance();
}
-Enum* Enum::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Enum>(arena);
-}
void Enum::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Enum)
@@ -1802,7 +1794,8 @@ bool Enum::MergePartialFromCodedStream(
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_enumvalue()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_enumvalue()));
} else {
goto handle_unusual;
}
@@ -1813,7 +1806,8 @@ bool Enum::MergePartialFromCodedStream(
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_options()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_options()));
} else {
goto handle_unusual;
}
@@ -1887,20 +1881,24 @@ void Enum::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->enumvalue_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, this->enumvalue(static_cast<int>(i)), output);
+ 2,
+ this->enumvalue(static_cast<int>(i)),
+ output);
}
// repeated .google.protobuf.Option options = 3;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->options_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, this->options(static_cast<int>(i)), output);
+ 3,
+ this->options(static_cast<int>(i)),
+ output);
}
// .google.protobuf.SourceContext source_context = 4;
if (this->has_source_context()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 4, *this->source_context_, output);
+ 4, *source_context_, output);
}
// .google.protobuf.Syntax syntax = 5;
@@ -1954,7 +1952,7 @@ void Enum::SerializeWithCachedSizes(
if (this->has_source_context()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 4, *this->source_context_, deterministic, target);
+ 4, *source_context_, deterministic, target);
}
// .google.protobuf.Syntax syntax = 5;
@@ -2013,7 +2011,7 @@ size_t Enum::ByteSizeLong() const {
if (this->has_source_context()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->source_context_);
+ *source_context_);
}
// .google.protobuf.Syntax syntax = 5;
@@ -2103,8 +2101,8 @@ void Enum::UnsafeArenaSwap(Enum* other) {
}
void Enum::InternalSwap(Enum* other) {
using std::swap;
- enumvalue_.InternalSwap(&other->enumvalue_);
- options_.InternalSwap(&other->options_);
+ CastToBase(&enumvalue_)->InternalSwap(CastToBase(&other->enumvalue_));
+ CastToBase(&options_)->InternalSwap(CastToBase(&other->options_));
name_.Swap(&other->name_);
swap(source_context_, other->source_context_);
swap(syntax_, other->syntax_);
@@ -2197,9 +2195,6 @@ const EnumValue& EnumValue::default_instance() {
return *internal_default_instance();
}
-EnumValue* EnumValue::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<EnumValue>(arena);
-}
void EnumValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValue)
@@ -2257,7 +2252,8 @@ bool EnumValue::MergePartialFromCodedStream(
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_options()));
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+ input, add_options()));
} else {
goto handle_unusual;
}
@@ -2309,7 +2305,9 @@ void EnumValue::SerializeWithCachedSizes(
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->options_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, this->options(static_cast<int>(i)), output);
+ 3,
+ this->options(static_cast<int>(i)),
+ output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
@@ -2469,7 +2467,7 @@ void EnumValue::UnsafeArenaSwap(EnumValue* other) {
}
void EnumValue::InternalSwap(EnumValue* other) {
using std::swap;
- options_.InternalSwap(&other->options_);
+ CastToBase(&options_)->InternalSwap(CastToBase(&other->options_));
name_.Swap(&other->name_);
swap(number_, other->number_);
_internal_metadata_.Swap(&other->_internal_metadata_);
@@ -2488,10 +2486,6 @@ void Option::InitAsDefaultInstance() {
::google::protobuf::_Option_default_instance_._instance.get_mutable()->value_ = const_cast< ::google::protobuf::Any*>(
::google::protobuf::Any::internal_default_instance());
}
-void Option::_slow_mutable_value() {
- value_ = ::google::protobuf::Arena::Create< ::google::protobuf::Any >(
- GetArenaNoVirtual());
-}
void Option::unsafe_arena_set_allocated_value(
::google::protobuf::Any* value) {
if (GetArenaNoVirtual() == NULL) {
@@ -2588,9 +2582,6 @@ const Option& Option::default_instance() {
return *internal_default_instance();
}
-Option* Option::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Option>(arena);
-}
void Option::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Option)
@@ -2683,7 +2674,7 @@ void Option::SerializeWithCachedSizes(
// .google.protobuf.Any value = 2;
if (this->has_value()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, *this->value_, output);
+ 2, *value_, output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
@@ -2715,7 +2706,7 @@ void Option::SerializeWithCachedSizes(
if (this->has_value()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
- 2, *this->value_, deterministic, target);
+ 2, *value_, deterministic, target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
@@ -2746,7 +2737,7 @@ size_t Option::ByteSizeLong() const {
if (this->has_value()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
- *this->value_);
+ *value_);
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
@@ -2840,5 +2831,24 @@ void Option::InternalSwap(Option* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Type* Arena::CreateMessage< ::google::protobuf::Type >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Type >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Field* Arena::CreateMessage< ::google::protobuf::Field >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Field >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Enum* Arena::CreateMessage< ::google::protobuf::Enum >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Enum >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumValue* Arena::CreateMessage< ::google::protobuf::EnumValue >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::EnumValue >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Option* Arena::CreateMessage< ::google::protobuf::Option >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Option >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h
index 85bd660f..9d19d39f 100644
--- a/src/google/protobuf/type.pb.h
+++ b/src/google/protobuf/type.pb.h
@@ -84,6 +84,15 @@ LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_;
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Enum* Arena::CreateMessage< ::google::protobuf::Enum>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumValue* Arena::CreateMessage< ::google::protobuf::EnumValue>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Field* Arena::CreateMessage< ::google::protobuf::Field>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Option* Arena::CreateMessage< ::google::protobuf::Option>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Type* Arena::CreateMessage< ::google::protobuf::Type>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
enum Field_Kind {
Field_Kind_TYPE_UNKNOWN = 0,
@@ -220,9 +229,13 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
// implements Message ----------------------------------------------
- inline Type* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Type* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Type>(NULL);
+ }
- Type* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Type* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Type>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Type& from);
@@ -267,11 +280,11 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
int fields_size() const;
void clear_fields();
static const int kFieldsFieldNumber = 2;
- const ::google::protobuf::Field& fields(int index) const;
::google::protobuf::Field* mutable_fields(int index);
- ::google::protobuf::Field* add_fields();
::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >*
mutable_fields();
+ const ::google::protobuf::Field& fields(int index) const;
+ ::google::protobuf::Field* add_fields();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >&
fields() const;
@@ -301,11 +314,11 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
int options_size() const;
void clear_options();
static const int kOptionsFieldNumber = 4;
- const ::google::protobuf::Option& options(int index) const;
::google::protobuf::Option* mutable_options(int index);
- ::google::protobuf::Option* add_options();
::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
mutable_options();
+ const ::google::protobuf::Option& options(int index) const;
+ ::google::protobuf::Option* add_options();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
options() const;
@@ -336,9 +349,6 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
bool has_source_context() const;
void clear_source_context();
static const int kSourceContextFieldNumber = 5;
- private:
- void _slow_mutable_source_context();
- public:
const ::google::protobuf::SourceContext& source_context() const;
::google::protobuf::SourceContext* release_source_context();
::google::protobuf::SourceContext* mutable_source_context();
@@ -423,9 +433,13 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
// implements Message ----------------------------------------------
- inline Field* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Field* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Field>(NULL);
+ }
- Field* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Field* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Field>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Field& from);
@@ -560,11 +574,11 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
int options_size() const;
void clear_options();
static const int kOptionsFieldNumber = 9;
- const ::google::protobuf::Option& options(int index) const;
::google::protobuf::Option* mutable_options(int index);
- ::google::protobuf::Option* add_options();
::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
mutable_options();
+ const ::google::protobuf::Option& options(int index) const;
+ ::google::protobuf::Option* add_options();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
options() const;
@@ -764,9 +778,13 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
// implements Message ----------------------------------------------
- inline Enum* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Enum* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Enum>(NULL);
+ }
- Enum* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Enum* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Enum>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Enum& from);
@@ -811,11 +829,11 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
int enumvalue_size() const;
void clear_enumvalue();
static const int kEnumvalueFieldNumber = 2;
- const ::google::protobuf::EnumValue& enumvalue(int index) const;
::google::protobuf::EnumValue* mutable_enumvalue(int index);
- ::google::protobuf::EnumValue* add_enumvalue();
::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >*
mutable_enumvalue();
+ const ::google::protobuf::EnumValue& enumvalue(int index) const;
+ ::google::protobuf::EnumValue* add_enumvalue();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >&
enumvalue() const;
@@ -823,11 +841,11 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
int options_size() const;
void clear_options();
static const int kOptionsFieldNumber = 3;
- const ::google::protobuf::Option& options(int index) const;
::google::protobuf::Option* mutable_options(int index);
- ::google::protobuf::Option* add_options();
::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
mutable_options();
+ const ::google::protobuf::Option& options(int index) const;
+ ::google::protobuf::Option* add_options();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
options() const;
@@ -858,9 +876,6 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
bool has_source_context() const;
void clear_source_context();
static const int kSourceContextFieldNumber = 4;
- private:
- void _slow_mutable_source_context();
- public:
const ::google::protobuf::SourceContext& source_context() const;
::google::protobuf::SourceContext* release_source_context();
::google::protobuf::SourceContext* mutable_source_context();
@@ -944,9 +959,13 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
// implements Message ----------------------------------------------
- inline EnumValue* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline EnumValue* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumValue>(NULL);
+ }
- EnumValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ EnumValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<EnumValue>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumValue& from);
@@ -991,11 +1010,11 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
int options_size() const;
void clear_options();
static const int kOptionsFieldNumber = 3;
- const ::google::protobuf::Option& options(int index) const;
::google::protobuf::Option* mutable_options(int index);
- ::google::protobuf::Option* add_options();
::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
mutable_options();
+ const ::google::protobuf::Option& options(int index) const;
+ ::google::protobuf::Option* add_options();
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
options() const;
@@ -1095,9 +1114,13 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc
// implements Message ----------------------------------------------
- inline Option* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Option* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Option>(NULL);
+ }
- Option* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Option* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Option>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Option& from);
@@ -1165,9 +1188,6 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc
bool has_value() const;
void clear_value();
static const int kValueFieldNumber = 2;
- private:
- void _slow_mutable_value();
- public:
const ::google::protobuf::Any& value() const;
::google::protobuf::Any* release_value();
::google::protobuf::Any* mutable_value();
@@ -1282,23 +1302,23 @@ inline int Type::fields_size() const {
inline void Type::clear_fields() {
fields_.Clear();
}
-inline const ::google::protobuf::Field& Type::fields(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.Type.fields)
- return fields_.Get(index);
-}
inline ::google::protobuf::Field* Type::mutable_fields(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.Type.fields)
return fields_.Mutable(index);
}
-inline ::google::protobuf::Field* Type::add_fields() {
- // @@protoc_insertion_point(field_add:google.protobuf.Type.fields)
- return fields_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >*
Type::mutable_fields() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.fields)
return &fields_;
}
+inline const ::google::protobuf::Field& Type::fields(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Type.fields)
+ return fields_.Get(index);
+}
+inline ::google::protobuf::Field* Type::add_fields() {
+ // @@protoc_insertion_point(field_add:google.protobuf.Type.fields)
+ return fields_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >&
Type::fields() const {
// @@protoc_insertion_point(field_list:google.protobuf.Type.fields)
@@ -1381,23 +1401,23 @@ inline int Type::options_size() const {
inline void Type::clear_options() {
options_.Clear();
}
-inline const ::google::protobuf::Option& Type::options(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.Type.options)
- return options_.Get(index);
-}
inline ::google::protobuf::Option* Type::mutable_options(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.Type.options)
return options_.Mutable(index);
}
-inline ::google::protobuf::Option* Type::add_options() {
- // @@protoc_insertion_point(field_add:google.protobuf.Type.options)
- return options_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
Type::mutable_options() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.options)
return &options_;
}
+inline const ::google::protobuf::Option& Type::options(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Type.options)
+ return options_.Get(index);
+}
+inline ::google::protobuf::Option* Type::add_options() {
+ // @@protoc_insertion_point(field_add:google.protobuf.Type.options)
+ return options_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
Type::options() const {
// @@protoc_insertion_point(field_list:google.protobuf.Type.options)
@@ -1434,7 +1454,8 @@ inline ::google::protobuf::SourceContext* Type::unsafe_arena_release_source_cont
inline ::google::protobuf::SourceContext* Type::mutable_source_context() {
if (source_context_ == NULL) {
- _slow_mutable_source_context();
+ source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.Type.source_context)
return source_context_;
@@ -1703,23 +1724,23 @@ inline int Field::options_size() const {
inline void Field::clear_options() {
options_.Clear();
}
-inline const ::google::protobuf::Option& Field::options(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.Field.options)
- return options_.Get(index);
-}
inline ::google::protobuf::Option* Field::mutable_options(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.Field.options)
return options_.Mutable(index);
}
-inline ::google::protobuf::Option* Field::add_options() {
- // @@protoc_insertion_point(field_add:google.protobuf.Field.options)
- return options_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
Field::mutable_options() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.Field.options)
return &options_;
}
+inline const ::google::protobuf::Option& Field::options(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Field.options)
+ return options_.Get(index);
+}
+inline ::google::protobuf::Option* Field::add_options() {
+ // @@protoc_insertion_point(field_add:google.protobuf.Field.options)
+ return options_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
Field::options() const {
// @@protoc_insertion_point(field_list:google.protobuf.Field.options)
@@ -1962,23 +1983,23 @@ inline int Enum::enumvalue_size() const {
inline void Enum::clear_enumvalue() {
enumvalue_.Clear();
}
-inline const ::google::protobuf::EnumValue& Enum::enumvalue(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.Enum.enumvalue)
- return enumvalue_.Get(index);
-}
inline ::google::protobuf::EnumValue* Enum::mutable_enumvalue(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.Enum.enumvalue)
return enumvalue_.Mutable(index);
}
-inline ::google::protobuf::EnumValue* Enum::add_enumvalue() {
- // @@protoc_insertion_point(field_add:google.protobuf.Enum.enumvalue)
- return enumvalue_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >*
Enum::mutable_enumvalue() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.enumvalue)
return &enumvalue_;
}
+inline const ::google::protobuf::EnumValue& Enum::enumvalue(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Enum.enumvalue)
+ return enumvalue_.Get(index);
+}
+inline ::google::protobuf::EnumValue* Enum::add_enumvalue() {
+ // @@protoc_insertion_point(field_add:google.protobuf.Enum.enumvalue)
+ return enumvalue_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >&
Enum::enumvalue() const {
// @@protoc_insertion_point(field_list:google.protobuf.Enum.enumvalue)
@@ -1992,23 +2013,23 @@ inline int Enum::options_size() const {
inline void Enum::clear_options() {
options_.Clear();
}
-inline const ::google::protobuf::Option& Enum::options(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.Enum.options)
- return options_.Get(index);
-}
inline ::google::protobuf::Option* Enum::mutable_options(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.Enum.options)
return options_.Mutable(index);
}
-inline ::google::protobuf::Option* Enum::add_options() {
- // @@protoc_insertion_point(field_add:google.protobuf.Enum.options)
- return options_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
Enum::mutable_options() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.options)
return &options_;
}
+inline const ::google::protobuf::Option& Enum::options(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Enum.options)
+ return options_.Get(index);
+}
+inline ::google::protobuf::Option* Enum::add_options() {
+ // @@protoc_insertion_point(field_add:google.protobuf.Enum.options)
+ return options_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
Enum::options() const {
// @@protoc_insertion_point(field_list:google.protobuf.Enum.options)
@@ -2045,7 +2066,8 @@ inline ::google::protobuf::SourceContext* Enum::unsafe_arena_release_source_cont
inline ::google::protobuf::SourceContext* Enum::mutable_source_context() {
if (source_context_ == NULL) {
- _slow_mutable_source_context();
+ source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.Enum.source_context)
return source_context_;
@@ -2183,23 +2205,23 @@ inline int EnumValue::options_size() const {
inline void EnumValue::clear_options() {
options_.Clear();
}
-inline const ::google::protobuf::Option& EnumValue::options(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.options)
- return options_.Get(index);
-}
inline ::google::protobuf::Option* EnumValue::mutable_options(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.options)
return options_.Mutable(index);
}
-inline ::google::protobuf::Option* EnumValue::add_options() {
- // @@protoc_insertion_point(field_add:google.protobuf.EnumValue.options)
- return options_.Add();
-}
inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
EnumValue::mutable_options() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValue.options)
return &options_;
}
+inline const ::google::protobuf::Option& EnumValue::options(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.options)
+ return options_.Get(index);
+}
+inline ::google::protobuf::Option* EnumValue::add_options() {
+ // @@protoc_insertion_point(field_add:google.protobuf.EnumValue.options)
+ return options_.Add();
+}
inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
EnumValue::options() const {
// @@protoc_insertion_point(field_list:google.protobuf.EnumValue.options)
@@ -2315,7 +2337,8 @@ inline ::google::protobuf::Any* Option::unsafe_arena_release_value() {
inline ::google::protobuf::Any* Option::mutable_value() {
if (value_ == NULL) {
- _slow_mutable_value();
+ value_ = ::google::protobuf::Arena::Create< ::google::protobuf::Any >(
+ GetArenaNoVirtual());
}
// @@protoc_insertion_point(field_mutable:google.protobuf.Option.value)
return value_;
diff --git a/src/google/protobuf/unittest_lite_imports_nonlite.proto b/src/google/protobuf/unittest_lite_imports_nonlite.proto
index 132d6a82..8a470160 100644
--- a/src/google/protobuf/unittest_lite_imports_nonlite.proto
+++ b/src/google/protobuf/unittest_lite_imports_nonlite.proto
@@ -41,4 +41,7 @@ option optimize_for = LITE_RUNTIME;
message TestLiteImportsNonlite {
optional TestAllTypes message = 1;
+
+ // Verifies that transitive required fields generates valid code.
+ optional TestRequired message_with_required = 2;
}
diff --git a/src/google/protobuf/util/field_comparator.cc b/src/google/protobuf/util/field_comparator.cc
index a1a56ee6..86ddf06a 100644
--- a/src/google/protobuf/util/field_comparator.cc
+++ b/src/google/protobuf/util/field_comparator.cc
@@ -36,6 +36,7 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/message.h>
+#include <google/protobuf/util/message_differencer.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/mathlimits.h>
#include <google/protobuf/stubs/mathutil.h>
@@ -130,6 +131,15 @@ FieldComparator::ComparisonResult DefaultFieldComparator::Compare(
}
}
+bool DefaultFieldComparator::Compare(
+ MessageDifferencer* differencer,
+ const Message& message1,
+ const Message& message2,
+ const google::protobuf::util::FieldContext* field_context) {
+ return differencer->Compare(
+ message1, message2, field_context->parent_fields());
+}
+
void DefaultFieldComparator::SetDefaultFractionAndMargin(double fraction,
double margin) {
default_tolerance_ = Tolerance(fraction, margin);
diff --git a/src/google/protobuf/util/field_comparator.h b/src/google/protobuf/util/field_comparator.h
index 26a7ba4d..27ef4c77 100644
--- a/src/google/protobuf/util/field_comparator.h
+++ b/src/google/protobuf/util/field_comparator.h
@@ -35,6 +35,7 @@
#include <map>
#include <string>
+#include <vector>
#include <google/protobuf/stubs/common.h>
@@ -48,6 +49,7 @@ class FieldDescriptor;
namespace util {
class FieldContext;
+class MessageDifferencer;
// Base class specifying the interface for comparing protocol buffer fields.
// Regular users should consider using or subclassing DefaultFieldComparator
@@ -153,6 +155,15 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator {
// REQUIRES: float_comparison_ == APPROXIMATE
void SetDefaultFractionAndMargin(double fraction, double margin);
+ protected:
+ // Compare using the provided message_differencer. For example, a subclass can
+ // use this method to compare some field in a certain way using the same
+ // message_differencer instance and the field context.
+ bool Compare(MessageDifferencer* differencer,
+ const google::protobuf::Message& message1,
+ const google::protobuf::Message& message2,
+ const google::protobuf::util::FieldContext* field_context);
+
private:
// Defines the tolerance for floating point comparison (fraction and margin).
struct Tolerance {
diff --git a/src/google/protobuf/util/field_mask_util.h b/src/google/protobuf/util/field_mask_util.h
index 01642c6f..91787bd5 100644
--- a/src/google/protobuf/util/field_mask_util.h
+++ b/src/google/protobuf/util/field_mask_util.h
@@ -94,6 +94,13 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
// Creates a FieldMask with all fields of type T. This FieldMask only
// contains fields of T but not any sub-message fields.
template <typename T>
+ static FieldMask GetFieldMaskForAllFields() {
+ FieldMask out;
+ InternalGetFieldMaskForAllFields(T::descriptor(), &out);
+ return out;
+ }
+ template <typename T>
+ PROTOBUF_RUNTIME_DEPRECATED("Use *out = GetFieldMaskForAllFields() instead")
static void GetFieldMaskForAllFields(FieldMask* out) {
InternalGetFieldMaskForAllFields(T::descriptor(), out);
}
@@ -122,6 +129,8 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
// Returns true if path is covered by the given FieldMask. Note that path
// "foo.bar" covers all paths like "foo.bar.baz", "foo.bar.quz.x", etc.
+ // Also note that parent paths are not covered by explicit child path, i.e.
+ // "foo.bar" does NOT cover "foo", even if "bar" is the only child.
static bool IsPathInFieldMask(StringPiece path, const FieldMask& mask);
class MergeOptions;
diff --git a/src/google/protobuf/util/field_mask_util_test.cc b/src/google/protobuf/util/field_mask_util_test.cc
index 7939f733..0664d9e5 100644
--- a/src/google/protobuf/util/field_mask_util_test.cc
+++ b/src/google/protobuf/util/field_mask_util_test.cc
@@ -206,12 +206,12 @@ TEST(FieldMaskUtilTest, TestIsValidFieldMask) {
TEST(FieldMaskUtilTest, TestGetFieldMaskForAllFields) {
FieldMask mask;
- FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes::NestedMessage>(&mask);
+ mask = FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes::NestedMessage>();
EXPECT_EQ(1, mask.paths_size());
EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("bb", mask));
- FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes>(&mask);
- EXPECT_EQ(76, mask.paths_size());
+ mask = FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes>();
+ EXPECT_EQ(75, mask.paths_size());
EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("optional_int32", mask));
EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("optional_int64", mask));
EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("optional_uint32", mask));
diff --git a/src/google/protobuf/util/internal/json_escaping.h b/src/google/protobuf/util/internal/json_escaping.h
index 9b8b2afd..5495c57f 100644
--- a/src/google/protobuf/util/internal/json_escaping.h
+++ b/src/google/protobuf/util/internal/json_escaping.h
@@ -28,8 +28,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef NET_PROTO2_UTIL_CONVERTER_STRINGS_JSON_ESCAPING_H_
-#define NET_PROTO2_UTIL_CONVERTER_STRINGS_JSON_ESCAPING_H_
+#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__
+#define GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/bytestream.h>
@@ -86,6 +86,6 @@ class JsonEscaping {
} // namespace converter
} // namespace util
} // namespace protobuf
-} // namespace google
-#endif // NET_PROTO2_UTIL_CONVERTER_STRINGS_JSON_ESCAPING_H_
+} // namespace google
+#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__
diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc
index 6e4edd88..a431177a 100644
--- a/src/google/protobuf/util/internal/json_objectwriter.cc
+++ b/src/google/protobuf/util/internal/json_objectwriter.cc
@@ -57,7 +57,7 @@ JsonObjectWriter::~JsonObjectWriter() {
JsonObjectWriter* JsonObjectWriter::StartObject(StringPiece name) {
WritePrefix(name);
WriteChar('{');
- Push();
+ PushObject();
return this;
}
@@ -71,7 +71,7 @@ JsonObjectWriter* JsonObjectWriter::EndObject() {
JsonObjectWriter* JsonObjectWriter::StartList(StringPiece name) {
WritePrefix(name);
WriteChar('[');
- Push();
+ PushArray();
return this;
}
@@ -172,8 +172,7 @@ void JsonObjectWriter::WritePrefix(StringPiece name) {
bool not_first = !element()->is_first();
if (not_first) WriteChar(',');
if (not_first || !element()->is_root()) NewLine();
- bool empty_key_ok = GetAndResetEmptyKeyOk();
- if (!name.empty() || empty_key_ok) {
+ if (!name.empty() || element()->is_json_object()) {
WriteChar('"');
if (!name.empty()) {
ArrayByteSource source(name);
@@ -184,12 +183,6 @@ void JsonObjectWriter::WritePrefix(StringPiece name) {
}
}
-bool JsonObjectWriter::GetAndResetEmptyKeyOk() {
- bool retval = empty_name_ok_for_next_key_;
- empty_name_ok_for_next_key_ = false;
- return retval;
-}
-
} // namespace converter
} // namespace util
} // namespace protobuf
diff --git a/src/google/protobuf/util/internal/json_objectwriter.h b/src/google/protobuf/util/internal/json_objectwriter.h
index 31edc292..81da0500 100644
--- a/src/google/protobuf/util/internal/json_objectwriter.h
+++ b/src/google/protobuf/util/internal/json_objectwriter.h
@@ -89,12 +89,11 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
public:
JsonObjectWriter(StringPiece indent_string,
google::protobuf::io::CodedOutputStream* out)
- : element_(new Element(NULL)),
+ : element_(new Element(/*parent=*/NULL, /*is_json_object=*/false)),
stream_(out),
sink_(out),
indent_string_(indent_string.ToString()),
- use_websafe_base64_for_bytes_(false),
- empty_name_ok_for_next_key_(false) {}
+ use_websafe_base64_for_bytes_(false) {}
virtual ~JsonObjectWriter();
// ObjectWriter methods.
@@ -118,17 +117,13 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
use_websafe_base64_for_bytes_ = value;
}
- // Whether empty strings should be rendered for the next JSON key. This
- // setting is only valid until the next key is rendered, after which it gets
- // reset to false.
- virtual void empty_name_ok_for_next_key() {
- empty_name_ok_for_next_key_ = true;
- }
-
protected:
class LIBPROTOBUF_EXPORT Element : public BaseElement {
public:
- explicit Element(Element* parent) : BaseElement(parent), is_first_(true) {}
+ Element(Element* parent, bool is_json_object)
+ : BaseElement(parent),
+ is_first_(true),
+ is_json_object_(is_json_object) {}
// Called before each field of the Element is to be processed.
// Returns true if this is the first call (processing the first field).
@@ -140,8 +135,13 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
return false;
}
+ // Whether we are currently renderring inside a JSON object (i.e., between
+ // StartObject() and EndObject()).
+ bool is_json_object() const { return is_json_object_; }
+
private:
bool is_first_;
+ bool is_json_object_;
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(Element);
};
@@ -175,8 +175,15 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
return this;
}
- // Pushes a new element to the stack.
- void Push() { element_.reset(new Element(element_.release())); }
+ // Pushes a new JSON array element to the stack.
+ void PushArray() {
+ element_.reset(new Element(element_.release(), /*is_json_object=*/false));
+ }
+
+ // Pushes a new JSON object element to the stack.
+ void PushObject() {
+ element_.reset(new Element(element_.release(), /*is_json_object=*/true));
+ }
// Pops an element off of the stack and deletes the popped element.
void Pop() {
@@ -204,10 +211,6 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
// Writes an individual character to the output.
void WriteChar(const char c) { stream_->WriteRaw(&c, sizeof(c)); }
- // Returns the current value of empty_name_ok_for_next_key_ and resets it to
- // false.
- bool GetAndResetEmptyKeyOk();
-
google::protobuf::scoped_ptr<Element> element_;
google::protobuf::io::CodedOutputStream* stream_;
ByteSinkWrapper sink_;
@@ -217,11 +220,6 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
// to regular base64 encoding.
bool use_websafe_base64_for_bytes_;
- // Whether empty strings should be rendered for the next JSON key. This
- // setting is only valid until the next key is rendered, after which it gets
- // reset to false.
- bool empty_name_ok_for_next_key_;
-
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonObjectWriter);
};
diff --git a/src/google/protobuf/util/internal/json_objectwriter_test.cc b/src/google/protobuf/util/internal/json_objectwriter_test.cc
index bbd9d78a..8cc588a6 100644
--- a/src/google/protobuf/util/internal/json_objectwriter_test.cc
+++ b/src/google/protobuf/util/internal/json_objectwriter_test.cc
@@ -95,6 +95,12 @@ TEST_F(JsonObjectWriterTest, EmptyList) {
output_.substr(0, out_stream_->ByteCount()));
}
+TEST_F(JsonObjectWriterTest, EmptyObjectKey) {
+ ow_ = new JsonObjectWriter("", out_stream_);
+ ow_->StartObject("")->RenderString("", "value")->EndObject();
+ EXPECT_EQ("{\"\":\"value\"}", output_.substr(0, out_stream_->ByteCount()));
+}
+
TEST_F(JsonObjectWriterTest, ObjectInObject) {
ow_ = new JsonObjectWriter("", out_stream_);
ow_->StartObject("")
diff --git a/src/google/protobuf/util/internal/object_writer.h b/src/google/protobuf/util/internal/object_writer.h
index b6fbd19b..5781aa1e 100644
--- a/src/google/protobuf/util/internal/object_writer.h
+++ b/src/google/protobuf/util/internal/object_writer.h
@@ -119,13 +119,6 @@ class LIBPROTOBUF_EXPORT ObjectWriter {
return use_strict_base64_decoding_;
}
- // Whether empty strings should be rendered for the next name for Start/Render
- // calls. This setting is only valid until the next key is rendered, after
- // which it gets reset.
- // It is up to the derived classes to interpret this and render accordingly.
- // Default implementation ignores this setting.
- virtual void empty_name_ok_for_next_key() {}
-
protected:
ObjectWriter() : use_strict_base64_decoding_(true) {}
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc
index 02360a1a..72ad5a7a 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource.cc
+++ b/src/google/protobuf/util/internal/protostream_objectsource.cc
@@ -300,8 +300,6 @@ StatusOr<uint32> ProtoStreamObjectSource::RenderMap(
return Status(util::error::INTERNAL, "Invalid map entry.");
}
ASSIGN_OR_RETURN(map_key, MapKeyDefaultValueAsString(*key_field));
- // Key is empty, force it to render as empty (for string values).
- ow->empty_name_ok_for_next_key();
}
RETURN_IF_ERROR(RenderField(field, map_key, ow));
} else {
diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc
index 11780ee8..b1007765 100644
--- a/src/google/protobuf/util/internal/utility.cc
+++ b/src/google/protobuf/util/internal/utility.cc
@@ -353,8 +353,6 @@ bool IsMap(const google::protobuf::Field& field,
google::protobuf::Field_Cardinality_CARDINALITY_REPEATED &&
(GetBoolOptionOrDefault(type.options(), "map_entry", false) ||
GetBoolOptionOrDefault(type.options(),
- "google.protobuf.MessageOptions.map_entry", false) ||
- GetBoolOptionOrDefault(type.options(),
"google.protobuf.MessageOptions.map_entry",
false));
}
@@ -362,9 +360,6 @@ bool IsMap(const google::protobuf::Field& field,
bool IsMessageSetWireFormat(const google::protobuf::Type& type) {
return GetBoolOptionOrDefault(type.options(), "message_set_wire_format",
false) ||
- GetBoolOptionOrDefault(type.options(),
- "google.protobuf.MessageOptions.message_set_wire_format",
- false) ||
GetBoolOptionOrDefault(
type.options(),
"google.protobuf.MessageOptions.message_set_wire_format", false);
diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc
index e964e041..c32e941c 100644
--- a/src/google/protobuf/util/message_differencer.cc
+++ b/src/google/protobuf/util/message_differencer.cc
@@ -363,9 +363,6 @@ void MessageDifferencer::TreatAsMapUsingKeyComparator(
const MapKeyComparator* key_comparator) {
GOOGLE_CHECK(field->is_repeated()) << "Field must be repeated: "
<< field->full_name();
- GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type())
- << "Field has to be message type. Field name is: "
- << field->full_name();
GOOGLE_CHECK(set_fields_.find(field) == set_fields_.end())
<< "Cannot treat this repeated field as both Map and Set for "
<< "comparison.";
@@ -1751,6 +1748,13 @@ void MessageDifferencer::StreamReporter::ReportUnknownFieldIgnored(
printer_->Print("\n"); // Print for newlines.
}
+MessageDifferencer::MapKeyComparator*
+MessageDifferencer::CreateMultipleFieldsMapKeyComparator(
+ const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths) {
+ return new MultipleFieldsMapKeyComparator(this, key_field_paths);
+}
+
+
} // namespace util
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h
index b7d4de00..11d6cc03 100644
--- a/src/google/protobuf/util/message_differencer.h
+++ b/src/google/protobuf/util/message_differencer.h
@@ -64,6 +64,7 @@ class Printer;
namespace util {
+class DefaultFieldComparator;
class FieldContext; // declared below MessageDifferencer
// A basic differencer that can be used to determine
@@ -372,7 +373,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// repeated fields have different numbers of elements, the
// unpaired elements are reported using ReportAdded() or
// ReportDeleted().
- AS_SET, // Treat all the repeated fields as sets by default.
+ AS_SET, // Treat all the repeated fields as sets.
// See TreatAsSet(), as below.
};
@@ -386,6 +387,11 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// the only differences between the compared messages is that some fields
// have been moved, then the comparison returns true.
//
+ // Note that despite the name of this method, this is really
+ // comparison as multisets: if one side of the comparison has a duplicate
+ // in the repeated field but the other side doesn't, this will count as
+ // a mismatch.
+ //
// If the scope of comparison is set to PARTIAL, then in addition to what's
// above, extra values added to repeated fields of the second message will
// not cause the comparison to fail.
@@ -470,6 +476,10 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
const FieldDescriptor* field,
const MapKeyComparator* key_comparator);
+ // Initiates and returns a new instance of MultipleFieldsMapKeyComparator.
+ MapKeyComparator* CreateMultipleFieldsMapKeyComparator(
+ const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths);
+
// Add a custom ignore criteria that is evaluated in addition to the
// ignored fields added with IgnoreField.
// Takes ownership of ignore_criteria.
@@ -660,6 +670,8 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
};
private:
+ friend class DefaultFieldComparator;
+
// A MapKeyComparator to be used in TreatAsMapUsingKeyComparator.
// Implementation of this class needs to do field value comparison which
// relies on some private methods of MessageDifferencer. That's why this
diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc
index cd343b74..1d8cda5a 100644
--- a/src/google/protobuf/wire_format_lite.cc
+++ b/src/google/protobuf/wire_format_lite.cc
@@ -34,9 +34,6 @@
#include <google/protobuf/wire_format_lite_inl.h>
-#ifdef __SSE_4_1__
-#include <immintrin.h>
-#endif
#include <stack>
#include <string>
#include <vector>
@@ -635,12 +632,12 @@ bool WireFormatLite::VerifyUtf8String(const char* data,
return true;
}
-#ifdef __SSE_4_1__
-template<typename T, bool ZigZag, bool SignExtended>
-static size_t VarintSize(
- const T* data, const int n,
- const internal::enable_if<sizeof(T) == 4>::type* = NULL) {
+// this code is deliberately written such that clang makes it into really
+// efficient SSE code.
+template<bool ZigZag, bool SignExtended, typename T>
+static size_t VarintSize(const T* data, const int n) {
#if __cplusplus >= 201103L
+ static_assert(sizeof(T) == 4, "This routine only works for 32 bit integers");
// is_unsigned<T> => !ZigZag
static_assert((std::is_unsigned<T>::value ^ ZigZag) ||
std::is_signed<T>::value,
@@ -649,101 +646,83 @@ static size_t VarintSize(
static_assert((std::is_unsigned<T>::value ^ SignExtended) ||
std::is_signed<T>::value,
"Cannot SignExtended unsigned types");
+ static_assert(!(SignExtended && ZigZag),
+ "Cannot SignExtended and ZigZag on the same type");
#endif
-
- union vus32 {
- uint32 u[4];
- int32 s[4];
- __m128i v;
- };
-
- static const vus32 ones = {{1, 1, 1, 1}};
-
- // CodedOutputStream::VarintSize32SignExtended returns 10 for negative
- // numbers. We can apply the UInt32Size algorithm, and simultaneously logical
- // shift the MSB into the LSB to determine if it is negative.
- static const vus32 fives = {{5, 5, 5, 5}};
-
- // sum is the vectorized-output of calling CodedOutputStream::VarintSize32 on
- // the processed elements.
- //
- // msb_sum is the count of set most-significant bits. When computing the
- // vectorized CodedOutputStream::VarintSize32SignExtended, negative values
- // have the most significant bit set. VarintSize32SignExtended returns 10 and
- // VarintSize32 returns 5. msb_sum allows us to compute:
- // VarintSize32SignExtended = msb_sum * 5 + VarintSize32
- vus32 sum, v, msb_sum;
- sum.v = _mm_setzero_si128();
- msb_sum.v = _mm_setzero_si128();
-
- int rounded = n & ~(3);
- int i;
- for (i = 0; i < rounded; i += 4) {
- v.v = _mm_loadu_si128(reinterpret_cast<const __m128i*>(&data[i]));
-
+ uint32 sum = n;
+ uint32 msb_sum = 0;
+ for (int i = 0; i < n; i++) {
+ uint32 x = data[i];
if (ZigZag) {
- // Note: the right-shift must be arithmetic
- v.v = _mm_xor_si128(_mm_slli_epi32(v.v, 1), _mm_srai_epi32(v.v, 31));
- }
-
- sum.v = _mm_add_epi32(sum.v, ones.v);
- if (SignExtended) {
- msb_sum.v = _mm_add_epi32(msb_sum.v, _mm_srli_epi32(v.v, 31));
- }
-
- v.v = _mm_srli_epi32(v.v, 7);
-
- for (int j = 0; j < 4; j++) {
- __m128i min = _mm_min_epi32(v.v, ones.v);
-
- sum.v = _mm_add_epi32(sum.v, min);
- v.v = _mm_srli_epi32(v.v, 7);
+ x = WireFormatLite::ZigZagEncode32(x);
+ } else if (SignExtended) {
+ msb_sum += x >> 31;
}
+ // clang is so smart that it produces optimal SSE sequence unrolling
+ // the loop 8 ints at a time. With a sequence of 4
+ // cmpres = cmpgt x, sizeclass ( -1 or 0)
+ // sum = sum - cmpres
+ if (x > 0x7F) sum++;
+ if (x > 0x3FFF) sum++;
+ if (x > 0x1FFFFF) sum++;
+ if (x > 0xFFFFFFF) sum++;
}
+ if (SignExtended) sum += msb_sum * 5;
+ return sum;
+}
- if (SignExtended) {
- vus32 extensions;
- extensions.v = _mm_mullo_epi32(msb_sum.v, fives.v);
-
- sum.v = _mm_add_epi32(sum.v, extensions.v);
- }
-
- // TODO(ckennelly): Can we avoid the sign conversion?
- size_t out = _mm_cvtsi128_si32(
- _mm_hadd_epi32(_mm_hadd_epi32(sum.v, ones.v), ones.v));
-
- // Finish tail.
- for (; i < n; i++) {
+template<bool ZigZag, typename T>
+static size_t VarintSize64(const T* data, const int n) {
+#if __cplusplus >= 201103L
+ static_assert(sizeof(T) == 8, "This routine only works for 64 bit integers");
+ // is_unsigned<T> => !ZigZag
+ static_assert(!ZigZag || !std::is_unsigned<T>::value,
+ "Cannot ZigZag encode unsigned types");
+#endif
+ uint64 sum = n;
+ for (int i = 0; i < n; i++) {
+ uint64 x = data[i];
if (ZigZag) {
- out += WireFormatLite::SInt32Size(data[i]);
- } else if (SignExtended) {
- out += WireFormatLite::Int32Size(data[i]);
- } else {
- out += WireFormatLite::UInt32Size(data[i]);
+ x = WireFormatLite::ZigZagEncode64(x);
}
+ // First step is a binary search, we can't branch in sse so we use the
+ // result of the compare to adjust sum and appropriately. This code is
+ // written to make clang recognize the vectorization.
+ uint64 tmp = x >= (static_cast<uint64>(1) << 35) ? -1 : 0;
+ sum += 5 & tmp;
+ x >>= 35 & tmp;
+ if (x > 0x7F) sum++;
+ if (x > 0x3FFF) sum++;
+ if (x > 0x1FFFFF) sum++;
+ if (x > 0xFFFFFFF) sum++;
}
-
- return out;
+ return sum;
}
+// GCC does not recognize the vectorization opportunity
+// and other platforms are untested, in those cases using the optimized
+// varint size routine for each element is faster.
+// Hence we enable it only for clang
+#if defined(__SSE__) && defined(__clang__)
size_t WireFormatLite::Int32Size(const RepeatedField<int32>& value) {
- return VarintSize<int32, false, true>(value.data(), value.size());
+ return VarintSize<false, true>(value.data(), value.size());
}
size_t WireFormatLite::UInt32Size(const RepeatedField<uint32>& value) {
- return VarintSize<uint32, false, false>(value.data(), value.size());
+ return VarintSize<false, false>(value.data(), value.size());
}
size_t WireFormatLite::SInt32Size(const RepeatedField<int32>& value) {
- return VarintSize<int32, true, true>(value.data(), value.size());
+ return VarintSize<true, false>(value.data(), value.size());
}
size_t WireFormatLite::EnumSize(const RepeatedField<int>& value) {
// On ILP64, sizeof(int) == 8, which would require a different template.
- return VarintSize<int, false, true>(value.data(), value.size());
+ return VarintSize<false, true>(value.data(), value.size());
}
-#else // !__SSE_4_1__
+#else // !(defined(__SSE4_1__) && defined(__clang__))
+
size_t WireFormatLite::Int32Size(const RepeatedField<int32>& value) {
size_t out = 0;
const int n = value.size();
@@ -779,6 +758,56 @@ size_t WireFormatLite::EnumSize(const RepeatedField<int>& value) {
}
return out;
}
+
+#endif
+
+// Micro benchmarks show that the SSE improved loop only starts beating
+// the normal loop on Haswell platforms and then only for >32 ints. We
+// disable this for now. Some specialized users might find it worthwhile to
+// enable this.
+#define USE_SSE_FOR_64_BIT_INTEGER_ARRAYS 0
+#if USE_SSE_FOR_64_BIT_INTEGER_ARRAYS
+size_t WireFormatLite::Int64Size (const RepeatedField< int64>& value) {
+ return VarintSize64<false>(value.data(), value.size());
+}
+
+size_t WireFormatLite::UInt64Size(const RepeatedField<uint64>& value) {
+ return VarintSize64<false>(value.data(), value.size());
+}
+
+size_t WireFormatLite::SInt64Size(const RepeatedField< int64>& value) {
+ return VarintSize64<true>(value.data(), value.size());
+}
+
+#else
+
+size_t WireFormatLite::Int64Size (const RepeatedField< int64>& value) {
+ size_t out = 0;
+ const int n = value.size();
+ for (int i = 0; i < n; i++) {
+ out += Int64Size(value.Get(i));
+ }
+ return out;
+}
+
+size_t WireFormatLite::UInt64Size(const RepeatedField<uint64>& value) {
+ size_t out = 0;
+ const int n = value.size();
+ for (int i = 0; i < n; i++) {
+ out += UInt64Size(value.Get(i));
+ }
+ return out;
+}
+
+size_t WireFormatLite::SInt64Size(const RepeatedField< int64>& value) {
+ size_t out = 0;
+ const int n = value.size();
+ for (int i = 0; i < n; i++) {
+ out += SInt64Size(value.Get(i));
+ }
+ return out;
+}
+
#endif
} // namespace internal
diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h
index cf614c02..265f5f93 100644
--- a/src/google/protobuf/wire_format_lite.h
+++ b/src/google/protobuf/wire_format_lite.h
@@ -674,13 +674,13 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
static inline size_t SInt64Size ( int64 value);
static inline size_t EnumSize ( int value);
- static size_t Int32Size (const RepeatedField< int32>& value);
- static inline size_t Int64Size (const RepeatedField< int64>& value);
- static size_t UInt32Size(const RepeatedField<uint32>& value);
- static inline size_t UInt64Size(const RepeatedField<uint64>& value);
- static size_t SInt32Size(const RepeatedField< int32>& value);
- static inline size_t SInt64Size(const RepeatedField< int64>& value);
- static size_t EnumSize (const RepeatedField< int>& value);
+ static size_t Int32Size (const RepeatedField< int32>& value);
+ static size_t Int64Size (const RepeatedField< int64>& value);
+ static size_t UInt32Size(const RepeatedField<uint32>& value);
+ static size_t UInt64Size(const RepeatedField<uint64>& value);
+ static size_t SInt32Size(const RepeatedField< int32>& value);
+ static size_t SInt64Size(const RepeatedField< int64>& value);
+ static size_t EnumSize (const RepeatedField< int>& value);
// These types always have the same size.
static const size_t kFixed32Size = 4;
diff --git a/src/google/protobuf/wire_format_lite_inl.h b/src/google/protobuf/wire_format_lite_inl.h
index b264bd7e..82fb62ae 100644
--- a/src/google/protobuf/wire_format_lite_inl.h
+++ b/src/google/protobuf/wire_format_lite_inl.h
@@ -1043,33 +1043,6 @@ inline size_t WireFormatLite::LengthDelimitedSize(size_t length) {
static_cast<uint32>(length));
}
-size_t WireFormatLite::Int64Size (const RepeatedField< int64>& value) {
- size_t out = 0;
- const int n = value.size();
- for (int i = 0; i < n; i++) {
- out += Int64Size(value.Get(i));
- }
- return out;
-}
-
-size_t WireFormatLite::UInt64Size(const RepeatedField<uint64>& value) {
- size_t out = 0;
- const int n = value.size();
- for (int i = 0; i < n; i++) {
- out += UInt64Size(value.Get(i));
- }
- return out;
-}
-
-size_t WireFormatLite::SInt64Size(const RepeatedField< int64>& value) {
- size_t out = 0;
- const int n = value.size();
- for (int i = 0; i < n; i++) {
- out += SInt64Size(value.Get(i));
- }
- return out;
-}
-
} // namespace internal
} // namespace protobuf
diff --git a/src/google/protobuf/wire_format_unittest.cc b/src/google/protobuf/wire_format_unittest.cc
index cafe9a48..736a1282 100644
--- a/src/google/protobuf/wire_format_unittest.cc
+++ b/src/google/protobuf/wire_format_unittest.cc
@@ -1436,6 +1436,7 @@ TEST(RepeatedVarint, Enum) {
EXPECT_EQ(expected, WireFormatLite::EnumSize(v));
}
+
} // namespace
} // namespace internal
} // namespace protobuf
diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc
index 00e01256..34c6fed1 100644
--- a/src/google/protobuf/wrappers.pb.cc
+++ b/src/google/protobuf/wrappers.pb.cc
@@ -463,9 +463,6 @@ const DoubleValue& DoubleValue::default_instance() {
return *internal_default_instance();
}
-DoubleValue* DoubleValue::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<DoubleValue>(arena);
-}
void DoubleValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DoubleValue)
@@ -725,9 +722,6 @@ const FloatValue& FloatValue::default_instance() {
return *internal_default_instance();
}
-FloatValue* FloatValue::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<FloatValue>(arena);
-}
void FloatValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FloatValue)
@@ -987,9 +981,6 @@ const Int64Value& Int64Value::default_instance() {
return *internal_default_instance();
}
-Int64Value* Int64Value::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Int64Value>(arena);
-}
void Int64Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Int64Value)
@@ -1251,9 +1242,6 @@ const UInt64Value& UInt64Value::default_instance() {
return *internal_default_instance();
}
-UInt64Value* UInt64Value::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<UInt64Value>(arena);
-}
void UInt64Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UInt64Value)
@@ -1515,9 +1503,6 @@ const Int32Value& Int32Value::default_instance() {
return *internal_default_instance();
}
-Int32Value* Int32Value::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<Int32Value>(arena);
-}
void Int32Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Int32Value)
@@ -1779,9 +1764,6 @@ const UInt32Value& UInt32Value::default_instance() {
return *internal_default_instance();
}
-UInt32Value* UInt32Value::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<UInt32Value>(arena);
-}
void UInt32Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UInt32Value)
@@ -2043,9 +2025,6 @@ const BoolValue& BoolValue::default_instance() {
return *internal_default_instance();
}
-BoolValue* BoolValue::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<BoolValue>(arena);
-}
void BoolValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.BoolValue)
@@ -2310,9 +2289,6 @@ const StringValue& StringValue::default_instance() {
return *internal_default_instance();
}
-StringValue* StringValue::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<StringValue>(arena);
-}
void StringValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.StringValue)
@@ -2592,9 +2568,6 @@ const BytesValue& BytesValue::default_instance() {
return *internal_default_instance();
}
-BytesValue* BytesValue::New(::google::protobuf::Arena* arena) const {
- return ::google::protobuf::Arena::CreateMessage<BytesValue>(arena);
-}
void BytesValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.BytesValue)
@@ -2792,5 +2765,36 @@ void BytesValue::InternalSwap(BytesValue* other) {
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
+namespace google {
+namespace protobuf {
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DoubleValue* Arena::CreateMessage< ::google::protobuf::DoubleValue >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::DoubleValue >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FloatValue* Arena::CreateMessage< ::google::protobuf::FloatValue >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::FloatValue >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Int64Value* Arena::CreateMessage< ::google::protobuf::Int64Value >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Int64Value >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UInt64Value* Arena::CreateMessage< ::google::protobuf::UInt64Value >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::UInt64Value >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Int32Value* Arena::CreateMessage< ::google::protobuf::Int32Value >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::Int32Value >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UInt32Value* Arena::CreateMessage< ::google::protobuf::UInt32Value >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::UInt32Value >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::BoolValue* Arena::CreateMessage< ::google::protobuf::BoolValue >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::BoolValue >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::StringValue* Arena::CreateMessage< ::google::protobuf::StringValue >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::StringValue >(arena);
+}
+template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::BytesValue* Arena::CreateMessage< ::google::protobuf::BytesValue >(Arena* arena) {
+ return Arena::CreateMessageInternal< ::google::protobuf::BytesValue >(arena);
+}
+} // namespace protobuf
+} // namespace google
// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h
index be49c3ec..4d7efec1 100644
--- a/src/google/protobuf/wrappers.pb.h
+++ b/src/google/protobuf/wrappers.pb.h
@@ -105,6 +105,19 @@ LIBPROTOBUF_EXPORT extern UInt64ValueDefaultTypeInternal _UInt64Value_default_in
} // namespace google
namespace google {
namespace protobuf {
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::BoolValue* Arena::CreateMessage< ::google::protobuf::BoolValue>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::BytesValue* Arena::CreateMessage< ::google::protobuf::BytesValue>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::DoubleValue* Arena::CreateMessage< ::google::protobuf::DoubleValue>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::FloatValue* Arena::CreateMessage< ::google::protobuf::FloatValue>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Int32Value* Arena::CreateMessage< ::google::protobuf::Int32Value>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::Int64Value* Arena::CreateMessage< ::google::protobuf::Int64Value>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::StringValue* Arena::CreateMessage< ::google::protobuf::StringValue>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::UInt32Value* Arena::CreateMessage< ::google::protobuf::UInt32Value>(Arena*);
+template<> LIBPROTOBUF_EXPORT ::google::protobuf::UInt64Value* Arena::CreateMessage< ::google::protobuf::UInt64Value>(Arena*);
+} // namespace protobuf
+} // namespace google
+namespace google {
+namespace protobuf {
// ===================================================================
@@ -159,9 +172,13 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p
// implements Message ----------------------------------------------
- inline DoubleValue* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline DoubleValue* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<DoubleValue>(NULL);
+ }
- DoubleValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ DoubleValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<DoubleValue>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const DoubleValue& from);
@@ -273,9 +290,13 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr
// implements Message ----------------------------------------------
- inline FloatValue* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline FloatValue* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FloatValue>(NULL);
+ }
- FloatValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ FloatValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<FloatValue>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FloatValue& from);
@@ -387,9 +408,13 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr
// implements Message ----------------------------------------------
- inline Int64Value* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Int64Value* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Int64Value>(NULL);
+ }
- Int64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Int64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Int64Value>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Int64Value& from);
@@ -501,9 +526,13 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p
// implements Message ----------------------------------------------
- inline UInt64Value* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline UInt64Value* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<UInt64Value>(NULL);
+ }
- UInt64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ UInt64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<UInt64Value>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const UInt64Value& from);
@@ -615,9 +644,13 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr
// implements Message ----------------------------------------------
- inline Int32Value* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline Int32Value* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Int32Value>(NULL);
+ }
- Int32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ Int32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<Int32Value>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Int32Value& from);
@@ -729,9 +762,13 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p
// implements Message ----------------------------------------------
- inline UInt32Value* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline UInt32Value* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<UInt32Value>(NULL);
+ }
- UInt32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ UInt32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<UInt32Value>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const UInt32Value& from);
@@ -843,9 +880,13 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro
// implements Message ----------------------------------------------
- inline BoolValue* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline BoolValue* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<BoolValue>(NULL);
+ }
- BoolValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ BoolValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<BoolValue>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const BoolValue& from);
@@ -957,9 +998,13 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p
// implements Message ----------------------------------------------
- inline StringValue* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline StringValue* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<StringValue>(NULL);
+ }
- StringValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ StringValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<StringValue>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const StringValue& from);
@@ -1088,9 +1133,13 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr
// implements Message ----------------------------------------------
- inline BytesValue* New() const PROTOBUF_FINAL { return New(NULL); }
+ inline BytesValue* New() const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<BytesValue>(NULL);
+ }
- BytesValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ BytesValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
+ return ::google::protobuf::Arena::CreateMessage<BytesValue>(arena);
+ }
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const BytesValue& from);